diff options
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/filterpresetmodel.cpp | 21 | ||||
-rw-r--r-- | qt-models/filterpresetmodel.h | 3 |
2 files changed, 24 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(); +} diff --git a/qt-models/filterpresetmodel.h b/qt-models/filterpresetmodel.h index 26543666a..2c04456e0 100644 --- a/qt-models/filterpresetmodel.h +++ b/qt-models/filterpresetmodel.h @@ -16,6 +16,9 @@ public: private slots: void reset(); + void filterPresetAdded(int index); + void filterPresetChanged(int index); + void filterPresetRemoved(int index); public: // there is one global filter preset list, therefore this model is a singleton static FilterPresetModel *instance(); |