diff options
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveEquipment.cpp | 6 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp | 3 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveSite.cpp | 24 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveSite.h | 1 |
4 files changed, 29 insertions, 5 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp index 1ea57e703..cb7182e02 100644 --- a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp +++ b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp @@ -33,8 +33,10 @@ TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent), ui.weights->setModel(weightModel); connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveEquipment::divesChanged); - connect(ui.cylinders->view(), &QTableView::clicked, this, &TabDiveEquipment::editCylinderWidget); - connect(ui.weights->view(), &QTableView::clicked, this, &TabDiveEquipment::editWeightWidget); + connect(ui.cylinders, &TableView::itemClicked, cylindersModel, &CylindersModel::remove); + connect(ui.cylinders, &TableView::itemClicked, this, &TabDiveEquipment::editCylinderWidget); + connect(ui.weights, &TableView::itemClicked, weightModel, &WeightModel::remove); + connect(ui.weights, &TableView::itemClicked, this, &TabDiveEquipment::editWeightWidget); // Current display of things on Gnome3 looks like shit, so // let's fix that. diff --git a/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp b/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp index cc46fb957..caf7c99bf 100644 --- a/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp +++ b/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "TabDiveExtraInfo.h" #include "ui_TabDiveExtraInfo.h" - -#include <qt-models/divecomputerextradatamodel.h> +#include "qt-models/divecomputerextradatamodel.h" TabDiveExtraInfo::TabDiveExtraInfo(QWidget *parent) : TabBase(parent), diff --git a/desktop-widgets/tab-widgets/TabDiveSite.cpp b/desktop-widgets/tab-widgets/TabDiveSite.cpp index 3ff693e59..9e269ee26 100644 --- a/desktop-widgets/tab-widgets/TabDiveSite.cpp +++ b/desktop-widgets/tab-widgets/TabDiveSite.cpp @@ -4,9 +4,10 @@ #include "core/divesite.h" #include "core/divefilter.h" #include "qt-models/divelocationmodel.h" +#include "desktop-widgets/mainwindow.h" // to place message box #include "commands/command.h" -#include <qt-models/divecomputerextradatamodel.h> +#include <QMessageBox> TabDiveSite::TabDiveSite(QWidget *parent) : TabBase(parent) { @@ -25,6 +26,7 @@ TabDiveSite::TabDiveSite(QWidget *parent) : TabBase(parent) ui.diveSites->view()->setColumnHidden(i, true); connect(ui.diveSites, &TableView::addButtonClicked, this, &TabDiveSite::add); + connect(ui.diveSites, &TableView::itemClicked, this, &TabDiveSite::diveSiteClicked); connect(ui.diveSites->view()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &TabDiveSite::selectionChanged); // Subtle: We depend on this slot being executed after the slot in the model. @@ -40,6 +42,26 @@ void TabDiveSite::clear() { } +void TabDiveSite::diveSiteClicked(const QModelIndex &index) +{ + struct dive_site *ds = model.getDiveSite(index); + if (!ds) + return; + switch (index.column()) { + case LocationInformationModel::EDIT: + MainWindow::instance()->editDiveSite(ds); + break; + case LocationInformationModel::REMOVE: + if (ds->dives.nr > 0 && + QMessageBox::warning(MainWindow::instance(), tr("Delete dive site?"), + tr("This dive site has %n dive(s). Do you really want to delete it?\n", "", ds->dives.nr), + QMessageBox::Yes|QMessageBox::No) == QMessageBox::No) + return; + Command::deleteDiveSites(QVector<dive_site *>{ds}); + break; + } +} + void TabDiveSite::add() { // This is mighty dirty: We hook into the "dive site added" signal and diff --git a/desktop-widgets/tab-widgets/TabDiveSite.h b/desktop-widgets/tab-widgets/TabDiveSite.h index 5927b08a0..c5d69eecc 100644 --- a/desktop-widgets/tab-widgets/TabDiveSite.h +++ b/desktop-widgets/tab-widgets/TabDiveSite.h @@ -16,6 +16,7 @@ private slots: void add(); void diveSiteAdded(struct dive_site *, int idx); void diveSiteChanged(struct dive_site *ds, int field); + void diveSiteClicked(const QModelIndex &); void on_purgeUnused_clicked(); void on_filterText_textChanged(const QString &text); void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); |