From 10e7835290fef4275fb85e5efc9e37c06887b9e6 Mon Sep 17 00:00:00 2001 From: Willem Ferguson Date: Thu, 28 Feb 2019 15:35:34 -0800 Subject: Filter panel: add suit and notes search fields All the field in the Notes Panel of the main window are now supported. This needs some testing especially for the Notes field that may contain markup. It appears ok to me for single term searches. One would like to think about the default search option for the Notes. There is a vertical spacer in the Filter panel that I moved downwards and whose function I am not quite sure of. [Dirk Hohndel: small adjustments] Signed-off-by: willemferguson Signed-off-by: Dirk Hohndel --- qt-models/filtermodels.cpp | 29 +++++++++++++++++++++++++++++ qt-models/filtermodels.h | 4 ++++ 2 files changed, 33 insertions(+) (limited to 'qt-models') diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 359b9a7f6..a5ba07204 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -74,6 +74,27 @@ namespace { { return true; } + + bool hasSuits(const QStringList &suits, const struct dive *d, FilterData::Mode mode) + { + if (suits.isEmpty()) + return true; + QStringList diveSuits; + if (d->suit) + diveSuits.push_back(QString(d->suit)); + return check(suits, diveSuits, mode); + } + + bool hasNotes(const QStringList &dnotes, const struct dive *d, FilterData::Mode mode) + { + if (dnotes.isEmpty()) + return true; + QStringList diveNotes; + if (d->notes) + diveNotes.push_back(QString(d->notes)); + return check(dnotes, diveNotes, mode); + } + } MultiFilterSortModel *MultiFilterSortModel::instance() @@ -149,6 +170,14 @@ bool MultiFilterSortModel::showDive(const struct dive *d) const if (!hasLocations(filterData.location, d, filterData.locationMode)) return false; + // Suit + if (!hasSuits(filterData.suit, d, filterData.suitMode)) + return false; + + // Notes + if (!hasNotes(filterData.dnotes, d, filterData.dnotesMode)) + return false; + if (!hasEquipment(filterData.equipment, d, filterData.equipmentMode)) return false; diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h index 996c2efaa..3b3e14abc 100644 --- a/qt-models/filtermodels.h +++ b/qt-models/filtermodels.h @@ -41,10 +41,14 @@ struct FilterData { QStringList tags; QStringList people; QStringList location; + QStringList suit; + QStringList dnotes; QStringList equipment; Mode tagsMode = Mode::ALL_OF; Mode peopleMode = Mode::ALL_OF; Mode locationMode = Mode::ANY_OF; + Mode dnotesMode = Mode::ALL_OF; + Mode suitMode = Mode::ANY_OF; Mode equipmentMode = Mode::ALL_OF; bool logged = true; bool planned = true; -- cgit v1.2.3-70-g09d2