mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Correctly refresh dive site list
And also show a warning to the user saying that that action is non-cancelable. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1ef20ee5d8
commit
2da439f34c
2 changed files with 11 additions and 1 deletions
|
@ -292,7 +292,7 @@ void merge_dive_sites(uint32_t ref, uint32_t* uuids, int count)
|
|||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
for(i = 0; i < count; i++) {
|
||||
if (uuids[i] == ref)
|
||||
continue;
|
||||
delete_dive_site(uuids[i]);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <QDebug>
|
||||
#include <QShowEvent>
|
||||
#include <QItemSelectionModel>
|
||||
#include <qmessagebox.h>
|
||||
#include <cstdlib>
|
||||
|
||||
LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), modified(false)
|
||||
|
@ -64,13 +65,22 @@ bool LocationInformationWidget::eventFilter(QObject*, QEvent *ev)
|
|||
}
|
||||
|
||||
void LocationInformationWidget::mergeSelectedDiveSites() {
|
||||
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;
|
||||
|
||||
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();
|
||||
i++;
|
||||
}
|
||||
merge_dive_sites(displayed_dive_site.uuid, selected_dive_sites, i);
|
||||
LocationInformationModel::instance()->update();
|
||||
QSortFilterProxyModel *m = (QSortFilterProxyModel *) ui.diveSiteListView->model();
|
||||
m->invalidate();
|
||||
free(selected_dive_sites);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue