diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-08-31 21:11:28 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-31 18:42:56 -0700 |
commit | 560426bf82ef7cb163d8046b722c12b76604006c (patch) | |
tree | 59973bb1bb0b077e4c097e85f13d227860bc00ba /qt-ui | |
parent | b52b95f3ec2e0dc730f991f25b7cefe30750cc72 (diff) | |
download | subsurface-560426bf82ef7cb163d8046b722c12b76604006c.tar.gz |
Offer the option to merge dive sites.
Almost finishing. :)
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/locationInformation.ui | 3 | ||||
-rw-r--r-- | qt-ui/locationinformation.cpp | 15 | ||||
-rw-r--r-- | qt-ui/locationinformation.h | 3 |
3 files changed, 20 insertions, 1 deletions
diff --git a/qt-ui/locationInformation.ui b/qt-ui/locationInformation.ui index e7ab45ce0..a2fd63576 100644 --- a/qt-ui/locationInformation.ui +++ b/qt-ui/locationInformation.ui @@ -98,6 +98,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="selectionMode"> + <enum>QAbstractItemView::MultiSelection</enum> + </property> <property name="modelColumn"> <number>0</number> </property> diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp index 616a7147e..b3acc6682 100644 --- a/qt-ui/locationinformation.cpp +++ b/qt-ui/locationinformation.cpp @@ -10,6 +10,7 @@ #include <QDebug> #include <QShowEvent> +#include <QItemSelectionModel> LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), modified(false) { @@ -35,7 +36,7 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo filter_model->setFilterRow(filter_same_gps_cb); ui.diveSiteListView->setModel(filter_model); ui.diveSiteListView->setModelColumn(LocationInformationModel::NAME); - + ui.diveSiteListView->installEventFilter(this); #ifndef NO_MARBLE // Globe Management Code. connect(this, &LocationInformationWidget::requestCoordinates, @@ -49,6 +50,18 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo #endif } +bool LocationInformationWidget::eventFilter(QObject*, QEvent *ev) +{ + if( ev->type() == QEvent::ContextMenu ) { + if (ui.diveSiteListView->selectionModel()->selectedIndexes().count() >= 2) { + QContextMenuEvent *ctx = (QContextMenuEvent*) ev; + QMenu contextMenu; + contextMenu.addAction(tr("Merge dive Sites"), this, SLOT(merge_dive_sites())); + contextMenu.exec(ctx->globalPos()); + } + } +} + void LocationInformationWidget::updateLabels() { if (displayed_dive_site.name) diff --git a/qt-ui/locationinformation.h b/qt-ui/locationinformation.h index 445fd87d4..2442e16aa 100644 --- a/qt-ui/locationinformation.h +++ b/qt-ui/locationinformation.h @@ -9,6 +9,8 @@ class LocationInformationWidget : public QGroupBox { Q_OBJECT public: LocationInformationWidget(QWidget *parent = 0); + virtual bool eventFilter(QObject*, QEvent*); + protected: void showEvent(QShowEvent *); @@ -35,6 +37,7 @@ signals: void stopFilterDiveSite(); void requestCoordinates(); void endRequestCoordinates(); + private: Ui::LocationInformation ui; bool modified; |