summaryrefslogtreecommitdiffstats
path: root/qt-models/filterpresetmodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-28 00:19:22 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-29 16:13:03 -0700
commit51959d0feb9fa560f388b4f1204f5028fb80f70d (patch)
tree5c885fc580fcdf62874a21e0ff00c0eca6330bc1 /qt-models/filterpresetmodel.cpp
parent581eb1f563df9e7fa72371d936521e0bd55d9f18 (diff)
downloadsubsurface-51959d0feb9fa560f388b4f1204f5028fb80f70d.tar.gz
filter: connect DiveListNotifier signals to filter preset model
Thus, the model is kept up to date if filter presets are changed by undo commands. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filterpresetmodel.cpp')
-rw-r--r--qt-models/filterpresetmodel.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/qt-models/filterpresetmodel.cpp b/qt-models/filterpresetmodel.cpp
index 446dd5e16..3853b4c34 100644
--- a/qt-models/filterpresetmodel.cpp
+++ b/qt-models/filterpresetmodel.cpp
@@ -9,6 +9,9 @@ FilterPresetModel::FilterPresetModel()
{
setHeaderDataStrings(QStringList{ "", tr("Name") });
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &FilterPresetModel::reset);
+ connect(&diveListNotifier, &DiveListNotifier::filterPresetAdded, this, &FilterPresetModel::filterPresetAdded);
+ connect(&diveListNotifier, &DiveListNotifier::filterPresetRemoved, this, &FilterPresetModel::filterPresetRemoved);
+ connect(&diveListNotifier, &DiveListNotifier::filterPresetChanged, this, &FilterPresetModel::filterPresetChanged);
}
FilterPresetModel::~FilterPresetModel()
@@ -57,3 +60,21 @@ void FilterPresetModel::reset()
beginResetModel();
endResetModel();
}
+
+void FilterPresetModel::filterPresetAdded(int index)
+{
+ beginInsertRows(QModelIndex(), index, index);
+ endInsertRows();
+}
+
+void FilterPresetModel::filterPresetChanged(int i)
+{
+ QModelIndex idx = index(i, 0);
+ dataChanged(idx, idx);
+}
+
+void FilterPresetModel::filterPresetRemoved(int index)
+{
+ beginRemoveRows(QModelIndex(), index, index);
+ endRemoveRows();
+}