summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-08-13 20:23:54 +0200
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2019-09-14 13:20:59 +0200
commit37a3daf2dd51330a9dc0a26f1b923698546373ed (patch)
tree61a8d6362b15e144f300200ab902629a2b02d7a8 /core/qthelper.cpp
parent36aab0fe9516f55b410404f379cd083a891afa3a (diff)
downloadsubsurface-37a3daf2dd51330a9dc0a26f1b923698546373ed.tar.gz
Mobile: decouple full text search from DiveObjectHelper
1) The full text search was looping over the DiveListModel when it could simply loop over the core model. Do that instead. 2) Don't generate a DiveObjectHelper to do a full text search. Currently this is harmless as the DiveObjectHelper is only a disguised "dive *". But from a conceptual point of view, it represents the full representation of a dive and we don't want to generate that in a tight loop. This will help in 1) Making the DiveObjectHelper a non-reference object. 2) Moving fulltext search to the core and thus making it available to desktop and more performant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index cd9fc7b90..8082db742 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1403,6 +1403,23 @@ QString getUUID()
return uuidString;
}
+static bool contains(const char *s, const QString &filterstring, Qt::CaseSensitivity cs)
+{
+ return !empty_string(s) && QString(s).contains(filterstring, cs);
+}
+
+bool diveContainsText(const struct dive *d, const QString &filterstring, Qt::CaseSensitivity cs, bool includeNotes)
+{
+ if (!d)
+ return false;
+ return contains(get_dive_location(d), filterstring, cs) ||
+ (d->divetrip && contains(d->divetrip->location, filterstring, cs)) ||
+ contains(d->buddy, filterstring, cs) ||
+ contains(d->divemaster, filterstring, cs) ||
+ contains(d->suit, filterstring, cs) ||
+ get_taglist_string(d->tag_list).contains(filterstring, cs) ||
+ (includeNotes && contains(d->notes, filterstring, cs));
+}
int parse_seabear_header(const char *filename, char **params, int pnr)
{
QFile f(filename);