summaryrefslogtreecommitdiffstats
path: root/qt-models/filtermodels.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-11-26 22:21:58 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-11-26 18:50:40 -0800
commit24c72cb359e98eb22418789f397bd72e0a29919b (patch)
treebff97ead133f4cf8747625bb95a877905375d096 /qt-models/filtermodels.cpp
parentf4bcdf46aa6498c449be8f63c052a7cbeaf8baa6 (diff)
downloadsubsurface-24c72cb359e98eb22418789f397bd72e0a29919b.tar.gz
Inform LocationFilterModel of added dive site name
If the user implicitly adds a dive site by editing a dive, and a location filter is active, check the new dive site in the location filter. This is done by informing the LocationFilterModel of the new dive site name prior to repopulation. The LocationFilterModel then adds a corresponding entry and marks it as checked. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filtermodels.cpp')
-rw-r--r--qt-models/filtermodels.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index 568fcd9e2..07ec1a250 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -333,6 +333,20 @@ void LocationFilterModel::changeName(const QString &oldName, const QString &newN
checkState[newIndex] = true;
}
+void LocationFilterModel::addName(const QString &newName)
+{
+ // If any item is checked and a new location is added, add the name
+ // of the new location in front of the list and mark it as checked.
+ // Thus, on subsequent repopulation of the list, the new entry will
+ // be registered as already checked.
+ QStringList list = stringList();
+ if (!anyChecked || newName.isEmpty() || list.indexOf(newName) >= 0)
+ return;
+ list.prepend(newName);
+ setStringList(list);
+ checkState.insert(checkState.begin(), true);
+}
+
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) :
QSortFilterProxyModel(parent),
divesDisplayed(0),