summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/locationinformation.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-15 17:41:31 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit59239cec02aedda8c2651a04c65c580a9ff190a9 (patch)
tree3aa2ce298c132eb6ccacb77d5b2a508e46aa724c /desktop-widgets/locationinformation.cpp
parent7c63956ee4798a835794eee8189b73e3df07594d (diff)
downloadsubsurface-59239cec02aedda8c2651a04c65c580a9ff190a9.tar.gz
Undo: make dive site merging undoable
This one was rather trivial, as there is no actual merging done. Quite simply, a number of dive sites are removed and their dive added to a different dive site. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/locationinformation.cpp')
-rw-r--r--desktop-widgets/locationinformation.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 244e85f8d..330ccd6f5 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -62,24 +62,16 @@ void LocationInformationWidget::mergeSelectedDiveSites()
{
if (!diveSite)
return;
- if (QMessageBox::warning(MainWindow::instance(), tr("Merging dive sites"),
- tr("You are about to merge dive sites, you can't undo that action \n Are you sure you want to continue?"),
- QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok)
- return;
const QModelIndexList selection = ui.diveSiteListView->selectionModel()->selectedIndexes();
- // std::vector guarantees contiguous storage and can therefore be passed to C-code
- std::vector<struct dive_site *> selected_dive_sites;
+ QVector<dive_site *> selected_dive_sites;
selected_dive_sites.reserve(selection.count());
for (const QModelIndex &idx: selection) {
dive_site *ds = idx.data(LocationInformationModel::DIVESITE_ROLE).value<dive_site *>();
if (ds)
selected_dive_sites.push_back(ds);
}
- merge_dive_sites(diveSite, selected_dive_sites.data(), (int)selected_dive_sites.size());
- LocationInformationModel::instance()->update();
- QSortFilterProxyModel *m = (QSortFilterProxyModel *)ui.diveSiteListView->model();
- m->invalidate();
+ Command::mergeDiveSites(diveSite, selected_dive_sites);
}
void LocationInformationWidget::updateLabels()