From 6a67aba33655539c2bed83af06e269557473b7a5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 6 Dec 2014 15:08:51 +0100 Subject: [PATCH] added double click with modifier actions in report table --- apps/opencs/view/tools/reporttable.cpp | 42 +++++++++++++++++++++----- apps/opencs/view/tools/reporttable.hpp | 4 +-- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/apps/opencs/view/tools/reporttable.cpp b/apps/opencs/view/tools/reporttable.cpp index eee1da35f..4cd11925e 100644 --- a/apps/opencs/view/tools/reporttable.cpp +++ b/apps/opencs/view/tools/reporttable.cpp @@ -33,6 +33,39 @@ void CSVTools::ReportTable::mouseMoveEvent (QMouseEvent *event) 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, const CSMWorld::UniversalId& id, QWidget *parent) : 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); connect (mRemoveAction, SIGNAL (triggered()), this, SLOT (removeSelection())); addAction (mRemoveAction); - - connect (this, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&))); } std::vector CSVTools::ReportTable::getDraggedRecords() const @@ -82,18 +113,13 @@ void CSVTools::ReportTable::updateUserSetting (const QString& name, const QStrin 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() { QModelIndexList selectedRows = selectionModel()->selectedRows(); for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end(); ++iter) - show (*iter); + emit editRequest (mModel->getUniversalId (iter->row()), mModel->getHint (iter->row())); } void CSVTools::ReportTable::removeSelection() diff --git a/apps/opencs/view/tools/reporttable.hpp b/apps/opencs/view/tools/reporttable.hpp index 2f53425d4..7a5b232f9 100644 --- a/apps/opencs/view/tools/reporttable.hpp +++ b/apps/opencs/view/tools/reporttable.hpp @@ -32,6 +32,8 @@ namespace CSVTools void mouseMoveEvent (QMouseEvent *event); + virtual void mouseDoubleClickEvent (QMouseEvent *event); + public: ReportTable (CSMDoc::Document& document, const CSMWorld::UniversalId& id, @@ -43,8 +45,6 @@ namespace CSVTools private slots: - void show (const QModelIndex& index); - void showSelection(); void removeSelection();