From 2aa13ea9d7d1a8b960d9d5a7b094b4896201b601 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Sat, 22 Apr 2023 00:18:32 +1200 Subject: [PATCH] Desktop: Add mergeing into the selected dive site. When editing a dive site in the 'Dive sites' view, add a context menu entry to allow mergeing of the displayed dive site into the dive site seleted in the 'Near dive sites' list. This merge has the opposite direction of the existing 'Merge into current site' function, which can simplify the workflow when maintaining a large number of dive sites, as the facilities to sort dive sites in the 'Dive sites' view does not have a way to sort by location or proximity. Signed-off-by: Michael Keller --- CHANGELOG.md | 1 + Documentation/user-manual.txt | 2 ++ desktop-widgets/locationinformation.cpp | 21 +++++++++++++++++++++ desktop-widgets/locationinformation.h | 1 + 4 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e2ef55a3..f88593843 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ export: change format produced by 'CSV summary dive details' from TSV (tab separated) to CSV +desktop: add function to merge dive site into site selected in list import: add option to synchronise dive computer time when downloading dives core: fix bug when save sea water salinity given by DC desktop: add option to force firmware update on OSTC4 diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index deef9350a..c933ce4b0 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -1650,6 +1650,8 @@ Select the dive site to be merged by right-clicking it. A confirmation message is presented (see image above). Clicking the confirmation message merges the selected dive with the dive named at the top of the panel and returns you to the dive sites management panel. +Alternatively, if exactly one dive site is selected in the 'Near dive sites' list, there is an additional function 'Merge current site into this site' available in the context menu. This can be helpful if the name of the destination dive site is not known, e.g. when importing dive sites from a third party source. + ==== Add a dive site At the top right of the dive sites management table is a round button with a "+". Clicking that button inserts a diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index 942d1b6ff..53f0e6d94 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -64,6 +64,9 @@ bool LocationInformationWidget::eventFilter(QObject *, QEvent *ev) QContextMenuEvent *ctx = (QContextMenuEvent *)ev; QMenu contextMenu; contextMenu.addAction(tr("Merge into current site"), this, &LocationInformationWidget::mergeSelectedDiveSites); + const QModelIndexList selection = ui.diveSiteListView->selectionModel()->selectedIndexes(); + if (selection.count() == 1) + contextMenu.addAction(tr("Merge current site into this site"), this, &LocationInformationWidget::mergeIntoSelectedDiveSite); contextMenu.exec(ctx->globalPos()); return true; } @@ -91,6 +94,24 @@ void LocationInformationWidget::mergeSelectedDiveSites() Command::mergeDiveSites(diveSite, selected_dive_sites); } +void LocationInformationWidget::mergeIntoSelectedDiveSite() +{ + if (!diveSite) + return; + + const QModelIndexList selection = ui.diveSiteListView->selectionModel()->selectedIndexes(); + if (selection.count() != 1) + return; + + dive_site *selected_dive_site = selection[0].data(LocationInformationModel::DIVESITE_ROLE).value(); + if (!selected_dive_site) + return; + + QVector dive_sites; + dive_sites.push_back(diveSite); + Command::mergeDiveSites(selected_dive_site, dive_sites); +} + // If we can't parse the coordinates, inform the user with a visual clue void LocationInformationWidget::coordinatesSetWarning(bool warn) { diff --git a/desktop-widgets/locationinformation.h b/desktop-widgets/locationinformation.h index ec8554feb..8cd3ba280 100644 --- a/desktop-widgets/locationinformation.h +++ b/desktop-widgets/locationinformation.h @@ -34,6 +34,7 @@ public slots: void on_diveSiteDistance_textChanged(const QString &s); void reverseGeocode(); void mergeSelectedDiveSites(); + void mergeIntoSelectedDiveSite(); void on_GPSbutton_clicked(); private slots: void updateLabels();