forked from teamnwah/openmw-tes3coop
added double click with modifier actions in report table
This commit is contained in:
parent
58f4cc882f
commit
6a67aba336
2 changed files with 36 additions and 10 deletions
|
@ -33,6 +33,39 @@ void CSVTools::ReportTable::mouseMoveEvent (QMouseEvent *event)
|
||||||
startDrag (*this);
|
startDrag (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVTools::ReportTable::mouseDoubleClickEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
Qt::KeyboardModifiers modifiers =
|
||||||
|
event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier);
|
||||||
|
|
||||||
|
QModelIndex index = currentIndex();
|
||||||
|
|
||||||
|
selectionModel()->select (index,
|
||||||
|
QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
|
||||||
|
switch (modifiers)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
|
||||||
|
event->accept();
|
||||||
|
showSelection();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::ShiftModifier:
|
||||||
|
|
||||||
|
event->accept();
|
||||||
|
removeSelection();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::ControlModifier:
|
||||||
|
|
||||||
|
event->accept();
|
||||||
|
showSelection();
|
||||||
|
removeSelection();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
|
CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
|
||||||
const CSMWorld::UniversalId& id, QWidget *parent)
|
const CSMWorld::UniversalId& id, QWidget *parent)
|
||||||
: CSVWorld::DragRecordTable (document, parent), mModel (document.getReport (id))
|
: CSVWorld::DragRecordTable (document, parent), mModel (document.getReport (id))
|
||||||
|
@ -58,8 +91,6 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
|
||||||
mRemoveAction = new QAction (tr ("Remove from list"), this);
|
mRemoveAction = new QAction (tr ("Remove from list"), this);
|
||||||
connect (mRemoveAction, SIGNAL (triggered()), this, SLOT (removeSelection()));
|
connect (mRemoveAction, SIGNAL (triggered()), this, SLOT (removeSelection()));
|
||||||
addAction (mRemoveAction);
|
addAction (mRemoveAction);
|
||||||
|
|
||||||
connect (this, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() const
|
std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() const
|
||||||
|
@ -82,18 +113,13 @@ void CSVTools::ReportTable::updateUserSetting (const QString& name, const QStrin
|
||||||
mIdTypeDelegate->updateUserSetting (name, list);
|
mIdTypeDelegate->updateUserSetting (name, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::ReportTable::show (const QModelIndex& index)
|
|
||||||
{
|
|
||||||
emit editRequest (mModel->getUniversalId (index.row()), mModel->getHint (index.row()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVTools::ReportTable::showSelection()
|
void CSVTools::ReportTable::showSelection()
|
||||||
{
|
{
|
||||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
|
|
||||||
for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
|
for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
|
||||||
++iter)
|
++iter)
|
||||||
show (*iter);
|
emit editRequest (mModel->getUniversalId (iter->row()), mModel->getHint (iter->row()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::ReportTable::removeSelection()
|
void CSVTools::ReportTable::removeSelection()
|
||||||
|
|
|
@ -32,6 +32,8 @@ namespace CSVTools
|
||||||
|
|
||||||
void mouseMoveEvent (QMouseEvent *event);
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
|
|
||||||
|
virtual void mouseDoubleClickEvent (QMouseEvent *event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ReportTable (CSMDoc::Document& document, const CSMWorld::UniversalId& id,
|
ReportTable (CSMDoc::Document& document, const CSMWorld::UniversalId& id,
|
||||||
|
@ -43,8 +45,6 @@ namespace CSVTools
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void show (const QModelIndex& index);
|
|
||||||
|
|
||||||
void showSelection();
|
void showSelection();
|
||||||
|
|
||||||
void removeSelection();
|
void removeSelection();
|
||||||
|
|
Loading…
Reference in a new issue