aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/locationInformation.ui3
-rw-r--r--qt-ui/locationinformation.cpp15
-rw-r--r--qt-ui/locationinformation.h3
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;