summaryrefslogtreecommitdiffstats
path: root/qt-models/divecomputermodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-09-12 23:38:45 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-25 13:59:04 -0700
commit4467477389cf0d6de8e3797b1941c07162896907 (patch)
tree39c2f49f9e4f68f2d46c719254f4a213884b3619 /qt-models/divecomputermodel.cpp
parent3a2f1b17b65b8c0eca12d60f94a16d573c13537d (diff)
downloadsubsurface-4467477389cf0d6de8e3797b1941c07162896907.tar.gz
models: update DiveComputerModel when core data is reset
To implement undo-semantics, we want a longer-lived dive-computer-model (currently, it is regenerated when the dialog is opened). Therefore, it must be reloaded when the core data is reset. Do this like for other models: listen to the dataReset() signal of DiveListNotifier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divecomputermodel.cpp')
-rw-r--r--qt-models/divecomputermodel.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/qt-models/divecomputermodel.cpp b/qt-models/divecomputermodel.cpp
index 356e24ef8..c51e19279 100644
--- a/qt-models/divecomputermodel.cpp
+++ b/qt-models/divecomputermodel.cpp
@@ -2,11 +2,21 @@
#include "qt-models/divecomputermodel.h"
#include "core/dive.h"
#include "core/divelist.h"
+#include "core/subsurface-qt/divelistnotifier.h"
DiveComputerModel::DiveComputerModel(QObject *parent) : CleanerTableModel(parent),
dcs(device_table.devices)
{
+ connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &DiveComputerModel::update);
setHeaderDataStrings(QStringList() << "" << tr("Model") << tr("Device ID") << tr("Nickname"));
+ update();
+}
+
+void DiveComputerModel::update()
+{
+ beginResetModel();
+ dcs = device_table.devices;
+ endResetModel();
}
QVariant DiveComputerModel::data(const QModelIndex &index, int role) const