summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-15 20:59:13 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-16 08:29:53 -0800
commit8a33c04894d6830885d7f47140962d5fdafd648f (patch)
treead14b83881042f4d9ec2f6dcdcc2db5d9a81fb43 /qt-models
parentf0a89759bf38375d32ad70ba4710a98d30a47e5d (diff)
downloadsubsurface-8a33c04894d6830885d7f47140962d5fdafd648f.tar.gz
Cleanup: use DiveTripModelBase::clear() to reset the log
Introduce a DiveTripModelBase::clear() function that cleanly clears all dive data inside a beginResetModel()/endResetModel() pair. Thus, the UI will be cleanly reset and we can remove explicit calls to - graphics->setEmptyState() - mainTab->clearTabs() - mainTab->clearTabs() - diveList->reload() from MainWindow::closeCurrentFile(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divetripmodel.cpp7
-rw-r--r--qt-models/divetripmodel.h3
2 files changed, 10 insertions, 0 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index d8166d2eb..5fedd432f 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -372,6 +372,13 @@ void DiveTripModelBase::resetModel(DiveTripModelBase::Layout layout)
currentModel.reset(new DiveTripModelList);
}
+void DiveTripModelBase::clear()
+{
+ beginResetModel();
+ clear_dive_file_data();
+ endResetModel();
+}
+
DiveTripModelBase::DiveTripModelBase(QObject *parent) : QAbstractItemModel(parent)
{
}
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index dc0d4b299..6b3f26fd7 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -70,6 +70,9 @@ public:
// by instance().
static void resetModel(Layout layout);
+ // Clear all dives
+ void clear();
+
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;