When importing a divelog, import filter presets. If there are
equal names, import only if the presets differ. In that case,
disambiguate the name. This made things a bit more complicated,
as comparison of filter presets had to be implemented.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
So far, the fulltext-query structure only saves an canonicalized
upper-cased version of the query. However, if we want to save the
fulltext query to the log (filter presets) or want to restore an old
fulltext query, we have to store the original query. We don't want
to confront the user with the mangled upper-cased version.
Therefore, also save the original version.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
get_cylinder(d, i) is more readable than d->cylinders.cylinders[i].
Moreover, it does bound checking and is more flexible with respect to
changing the core data structures. Most places already used this accessor,
but some still accessed the cylinders directly.
This patch unifies the accesses by consistently switching to get_cylinder().
The affected code is in C++ and accesses the cylinder as reference or
object, whereas the get_cylinder() function is C and returns a pointer.
This results in funky looking "*get_cylinder(d, i)" expressions.
Arguably still better than the original.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When initializing the fulltext-cache and the dive-list, every
100 dives a notification was shown. I had a feeling that this
made startup significantly slower, but that could have been
purely psychological.
Therefore I measured and indeed, removing the fine-grained
notification, it becomes *significantly* faster. For a 3500
dives test log with mobile-on-desktop:
Initialization of the fulltext: 1350 ms -> 730 ms (-46%)
Initialization of the divelistmodel: 689 ms -> 113 ms (-83%)
Let's remove the fine-grained notification. There *is* a visual
indication of work-in-progress anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function was not meant to be called with already existing data.
However, if it was, it cleared the words without clearing the fulltext
caches of the dives. This lead to crashes.
Be more resilient by not clearing the words: Already existing dives
are unregistered during the process of populating anyway. So this
now *should* work if new dives are added to the dive list and then
this function is called.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function was named improperly: it was only used on freshly
loaded data. Indeed, attempts to use it to actually reload lead
to crashes.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add code that indexes all words of a dive and provides searching
for words.
A query is represented by the FullTextQuery class, which can be
initialized by assigning a string to it. It is basically a list
of words.
The result of a search is stored in the FullTextResult class,
which is a list of dives.
The actual indexing and searching is implemented in the FullText
class. However, this class is not exported because the interface
is partially accessible to C. Notably, the reloading of the
fulltext index is done from the C core.
Currently, the indexing and searching is totally unoptimized.
In a ~4000 dives test-log searches typically took single-digit
ms times. There is ample room for optimization (e.g. when
searching for multiple words, chose the words with few dives
first and when down to a few dives, check them individually).
The words of each dive are tokenized and uppercased and
cached with the dive. A pointer to these words is stashed
in the dive structure.
For now, compile only on desktop.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>