- fixed attachments list + initial work to accept file drops
This commit is contained in:
parent
6bc7985b44
commit
e5a5aa5680
@ -5,13 +5,14 @@
|
||||
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
#include <QDropEvent>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -54,6 +54,10 @@ private:
|
||||
ChangesHistory mHistory;
|
||||
|
||||
void updateActionsState();
|
||||
|
||||
protected:
|
||||
void dropEvent(QDropEvent *ev) override;
|
||||
|
||||
public slots:
|
||||
void contextualMenu(const QPoint& point);
|
||||
void importFile();
|
||||
|
||||
@ -31,6 +31,9 @@
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DropOnly</enum>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
</property>
|
||||
|
||||
@ -19,7 +19,7 @@ void NodePropertiesWidget::setTask(const PTask& task)
|
||||
if (mTask != task)
|
||||
{
|
||||
mTask = task;
|
||||
update();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user