summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-02 22:52:27 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-05 10:14:25 -0800
commitb3253304a59b85c76f8a70f20ada4139e715a5b3 (patch)
tree8e21ae9d46d9d6ed1f651b7b6008512ae1fd622d /qt-models
parent147a36647ce6148ef2eccbe393faa658d0fe6834 (diff)
downloadsubsurface-b3253304a59b85c76f8a70f20ada4139e715a5b3.tar.gz
Desktop: don't connect to remove() slot of model from TableModel
When connecting a model to the TableModel class, it would connect clicking on an item to the remove() slot of the model. This breaks the program flow implied by the undo code: Ui --> Undo-Command --> Model --> UI Moreover, the naming of the remove() slot is illogical, because clicks can also have different effects, as for example in the cylinder-table. Therefore, move the connect() call from TableModel to the callers. In the case of TabDiveSite, move the remove() function from the model to the TabWidget, where it makes more sense. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divelocationmodel.cpp23
-rw-r--r--qt-models/divelocationmodel.h2
2 files changed, 0 insertions, 25 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index f68209a7e..0be755fd2 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -7,9 +7,7 @@
#include "core/metrics.h"
#ifndef SUBSURFACE_MOBILE
#include "cleanertablemodel.h" // for trashIcon() and editIcon()
-#include "desktop-widgets/mainwindow.h" // to place message box
#include "commands/command.h"
-#include <QMessageBox>
#endif
#include <QLineEdit>
#include <QIcon>
@@ -262,27 +260,6 @@ bool DiveSiteSortedModel::setData(const QModelIndex &index, const QVariant &valu
}
}
-// TODO: Remove or edit. It doesn't make sense to call the model here, which calls the undo command,
-// which in turn calls the model.
-void DiveSiteSortedModel::remove(const QModelIndex &index)
-{
- struct dive_site *ds = 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;
- }
-}
#endif // SUBSURFACE_MOBILE
void DiveSiteSortedModel::setFilter(const QString &text)
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index a42354737..661debc53 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -46,8 +46,6 @@ private:
QString fullText;
#ifndef SUBSURFACE_MOBILE
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
-public slots:
- void remove(const QModelIndex &index);
#endif // SUBSURFACE_MOBILE
public:
DiveSiteSortedModel();