diff --git a/client/attachmentslist.cpp b/client/attachmentslist.cpp index f95d6a6..cf06fca 100644 --- a/client/attachmentslist.cpp +++ b/client/attachmentslist.cpp @@ -5,13 +5,14 @@ #include #include +#include AttachmentsListModel::AttachmentsListModel(PTask task, ChangesHistory& history, const AttachmentArray &items, QObject *parent) :QAbstractListModel(parent), mTask(task), mHistory(history), mData(items) { } -int AttachmentsListModel::rowCount(const QModelIndex &parent) const +int AttachmentsListModel::rowCount(const QModelIndex &/*parent*/) const { return mData.size(); } @@ -41,7 +42,7 @@ QVariant AttachmentsListModel::data(const QModelIndex& index, int role) const } -Qt::ItemFlags AttachmentsListModel::flags(const QModelIndex &index) const +Qt::ItemFlags AttachmentsListModel::flags(const QModelIndex &/*index*/) const { Qt::ItemFlags result = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;// | Qt::ItemIsDropEnabled; //if (index.isValid()) @@ -143,6 +144,7 @@ void AttachmentsList::setParentWidget(QWidget *w) void AttachmentsList::updateActionsState() { bool hasSelectedItem = ui->mListView->currentIndex().isValid(); + ui->mRenameAction->setEnabled(hasSelectedItem); ui->mDeleteAction->setEnabled(hasSelectedItem); ui->mExportAction->setEnabled(hasSelectedItem); @@ -152,14 +154,15 @@ void AttachmentsList::contextualMenu(const QPoint& point) { updateActionsState(); - QMenu* menu = new QMenu(); + QMenu* menu = new QMenu(this); menu->addAction(ui->mRenameAction); menu->addAction(ui->mDeleteAction); menu->addAction(ui->mExportAction); menu->addAction(ui->mImportAction); //menu->addAction(tr("Add 10 mins to timeline"), this, SLOT(add10Mins())); - menu->exec(this->window()->mapToGlobal(point)); + menu->exec(this->mapToGlobal(point)); + //menu->exec(point); } void AttachmentsList::importFile() @@ -265,3 +268,8 @@ void AttachmentsList::renameFile() if (index.isValid()) ui->mListView->edit(index); } + +void AttachmentsList::dropEvent(QDropEvent *ev) +{ + ev->accept(); +} diff --git a/client/attachmentslist.h b/client/attachmentslist.h index aaed4fb..e3ca9ce 100644 --- a/client/attachmentslist.h +++ b/client/attachmentslist.h @@ -54,6 +54,10 @@ private: ChangesHistory mHistory; void updateActionsState(); + +protected: + void dropEvent(QDropEvent *ev) override; + public slots: void contextualMenu(const QPoint& point); void importFile(); diff --git a/client/attachmentslist.ui b/client/attachmentslist.ui index 1504ae3..62fb18e 100644 --- a/client/attachmentslist.ui +++ b/client/attachmentslist.ui @@ -31,6 +31,9 @@ Qt::CustomContextMenu + + QAbstractItemView::DropOnly + QListView::IconMode diff --git a/client/nodepropertieswidget.cpp b/client/nodepropertieswidget.cpp index f3c73d4..625a0d8 100644 --- a/client/nodepropertieswidget.cpp +++ b/client/nodepropertieswidget.cpp @@ -19,7 +19,7 @@ void NodePropertiesWidget::setTask(const PTask& task) if (mTask != task) { mTask = task; - update(); + refresh(); } }