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 <github@ike.ch>
This commit is contained in:
Michael Keller 2023-04-22 00:18:32 +12:00 committed by bstoeger
parent 84d9d0abe7
commit 2aa13ea9d7
4 changed files with 25 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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<dive_site *>();
if (!selected_dive_site)
return;
QVector<dive_site *> 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)
{

View file

@ -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();