diff options
Diffstat (limited to 'qt-models/filtermodels.cpp')
-rw-r--r-- | qt-models/filtermodels.cpp | 14 |
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), |