diff options
Diffstat (limited to 'qt-models/divelocationmodel.cpp')
-rw-r--r-- | qt-models/divelocationmodel.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index fbeab7be8..538f27e16 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -178,8 +178,14 @@ void LocationInformationModel::diveSiteDivesChanged(struct dive_site *ds) bool DiveSiteSortedModel::filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const { - // TODO: filtering - return true; + if (fullText.isEmpty()) + return true; + + if (sourceRow < 0 || sourceRow > dive_site_table.nr) + return false; + struct dive_site *ds = dive_site_table.dive_sites[sourceRow]; + QString text = QString(ds->name) + QString(ds->description) + QString(ds->notes); + return text.contains(fullText, Qt::CaseInsensitive); } bool DiveSiteSortedModel::lessThan(const QModelIndex &i1, const QModelIndex &i2) const @@ -272,6 +278,12 @@ void DiveSiteSortedModel::remove(const QModelIndex &index) } #endif // SUBSURFACE_MOBILE +void DiveSiteSortedModel::setFilter(const QString &text) +{ + fullText = text.trimmed(); + invalidateFilter(); +} + GeoReferencingOptionsModel *GeoReferencingOptionsModel::instance() { static GeoReferencingOptionsModel *self = new GeoReferencingOptionsModel(); |