diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/locationinformation.cpp | 14 | ||||
-rw-r--r-- | qt-ui/locationinformation.h | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp index b3acc6682..d029dd2a1 100644 --- a/qt-ui/locationinformation.cpp +++ b/qt-ui/locationinformation.cpp @@ -11,6 +11,7 @@ #include <QDebug> #include <QShowEvent> #include <QItemSelectionModel> +#include <cstdlib> LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), modified(false) { @@ -56,12 +57,23 @@ bool LocationInformationWidget::eventFilter(QObject*, QEvent *ev) 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.addAction(tr("Merge dive Sites"), this, SLOT(mergeSelectedDiveSites())); contextMenu.exec(ctx->globalPos()); } } } +void LocationInformationWidget::mergeSelectedDiveSites() { + QModelIndexList selection = ui.diveSiteListView->selectionModel()->selectedIndexes(); + uint32_t *selected_dive_sites = (uint32_t*) malloc(sizeof(u_int32_t) * selection.count()); + int i = 0; + Q_FOREACH(const QModelIndex& idx, selection) { + selected_dive_sites[i] = (uint32_t) idx.data(LocationInformationModel::UUID_ROLE).toInt(); + } + merge_dive_sites(selected_dive_sites, i); + free(selected_dive_sites); +} + void LocationInformationWidget::updateLabels() { if (displayed_dive_site.name) diff --git a/qt-ui/locationinformation.h b/qt-ui/locationinformation.h index 2442e16aa..080e013a8 100644 --- a/qt-ui/locationinformation.h +++ b/qt-ui/locationinformation.h @@ -27,6 +27,7 @@ public slots: void on_diveSiteName_textChanged(const QString& text); void on_diveSiteNotes_textChanged(); void reverseGeocode(); + void mergeSelectedDiveSites(); private slots: void updateLabels(); signals: |