summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-16 07:56:41 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-23 22:45:29 +0100
commit8f7633eff867e7d5437f9caf24e82f581bf624c0 (patch)
tree9ffb789d402a9095fd7d7a5ad57cf4e8ff459b46
parent0bc0b6bfe8666744611f8afa775a58b95e686652 (diff)
downloadsubsurface-8f7633eff867e7d5437f9caf24e82f581bf624c0.tar.gz
Mobile/filtering: full text filter, instead of just dive site
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/subsurface-qt/DiveObjectHelper.cpp6
-rw-r--r--core/subsurface-qt/DiveObjectHelper.h2
-rw-r--r--qt-models/divelistmodel.cpp9
-rw-r--r--qt-models/divelistmodel.h2
4 files changed, 14 insertions, 5 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
index a4d05f0ca..46809b403 100644
--- a/core/subsurface-qt/DiveObjectHelper.cpp
+++ b/core/subsurface-qt/DiveObjectHelper.cpp
@@ -434,3 +434,9 @@ QStringList DiveObjectHelper::firstGas() const
}
return gas;
}
+
+// for a full text search / filter function
+QString DiveObjectHelper::fullText() const
+{
+ return trip() + location() + buddy() + divemaster() + suit() + tags();
+}
diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h
index d36ef550e..86c2a6748 100644
--- a/core/subsurface-qt/DiveObjectHelper.h
+++ b/core/subsurface-qt/DiveObjectHelper.h
@@ -49,6 +49,7 @@ class DiveObjectHelper : public QObject {
Q_PROPERTY(QStringList startPressure READ startPressure CONSTANT)
Q_PROPERTY(QStringList endPressure READ endPressure CONSTANT)
Q_PROPERTY(QStringList firstGas READ firstGas CONSTANT)
+ Q_PROPERTY(QString fullText READ fullText CONSTANT)
public:
DiveObjectHelper(struct dive *dive = NULL);
~DiveObjectHelper();
@@ -93,6 +94,7 @@ public:
QStringList startPressure() const;
QStringList endPressure() const;
QStringList firstGas() const;
+ QString fullText() const;
private:
struct dive *m_dive;
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 76c0db7e3..38c8c86c0 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -10,8 +10,9 @@ DiveListSortModel::DiveListSortModel(QObject *parent) : QSortFilterProxyModel(pa
void DiveListSortModel::setFilter(QString f)
{
- setFilterRole(DiveListModel::DiveSiteRole);
- setFilterRegExp(f);
+ setFilterRole(DiveListModel::FullTextRole);
+ setFilterRegExp(QString(".*%1.*").arg(f));
+ setFilterCaseSensitivity(Qt::CaseInsensitive);
}
void DiveListSortModel::resetFilter()
@@ -162,7 +163,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
switch(role) {
case DiveRole: return QVariant::fromValue<QObject*>(curr_dive);
case DiveDateRole: return (qlonglong)curr_dive->timestamp();
- case DiveSiteRole: return curr_dive->location();
+ case FullTextRole: return curr_dive->fullText();
}
return QVariant();
@@ -173,7 +174,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
QHash<int, QByteArray> roles;
roles[DiveRole] = "dive";
roles[DiveDateRole] = "date";
- roles[DiveSiteRole] = "site";
+ roles[FullTextRole] = "fulltext";
return roles;
}
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index 2773ce33d..c34fb931d 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -29,7 +29,7 @@ public:
enum DiveListRoles {
DiveRole = Qt::UserRole + 1,
DiveDateRole,
- DiveSiteRole
+ FullTextRole
};
static DiveListModel *instance();