There are now three filter modes:
1) Dive site
2) Fulltext
3) Normal
When doing a fulltext search, get the dives that match the
fulltext filter and then apply the other filters on that list.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The FilterData struct has the enum StringMode, which describes how
strings are searched (substring, startswith, exact). To make it
more generally accessible, remove it from the class. Since it is
an "enum class", the values don't pollute the global namespace anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, we do substring search. Implement starts-with and
exact mode (for example when search for "Cave vs. Cavern" tags).
For each textual search criterion add a combo-box.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Split out the actual filtering from the MultiFilterSortModel.
Create a DiveFilter class that does the actual filtering.
Currently, mobile and desktop have their own version of this
class, though ultimately we may want to merge them.
The idea here is that the trip-model and undo-commands have
direct access to the filter-function and thus can take care
of keeping track of the number of shown dives, etc.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We mark hidden/shown dives in the core but store the number
of shown dives in the MultiFilterSortModel. Move this datum
to the core for improved locality.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The application state was encoded in a QByteArray. Thus, there was
no compile-time checking. Typos would lead to silent failures.
Turn the application state into an enum. Use the enum-class construct,
so that the values don't polute the global namespace. Moreover,
this makes them strongly typed, i.e. they don't auto-convert to
integers.
A disadvantage is that the enums now have to be cast to int
explicitly when used to index an array.
Replace two hash-maps in MainWindow to arrays of fixed sizes.
Move the application-state details into their own files.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of sending a signal when counts change, catching them
in the filter widget and update the window title there,
directly update the window title in the model. This removes a
signal/slot pair.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove a few cases of
void fun() {
...
}
While touching these functions, fix a few other whitespace
coding style violations.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is only in Qt 5.7 and therefore can't be used in Qt 5.5 and 5.6
builds. Moreover, we can't simply reuse Qt's version owing to
licensing concerns.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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 <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of using the filter widget itself to show the information how many
dives are displayed, put it in the window title where it's visible even if the
filter widget isn't shown.
If the filter is not active, simply show the total number of dives.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Only clear the filter when the user explicitly resets it. This way the user can
toggle between the map and the filter widget without losing the filter state.
Fixes#1952
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is not perfect - if you open the filter, set some criterion and then
remove it again (without resetting the filter), this variable will give you a
false positive).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add an additional mode to the tags, people and location filters: any_of.
Replace the original invert-bool by an enum.
Move the common code into a distinct function.
Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The texts may not be perfect, but this is a start. Replace the buttons
by combo-boxes. This will allow potential extension to "any of".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add negate buttons to the Tags, People, Location and Equipment
filters. Currently, if nothing is entered the filter is ignored
whether negate is on or off. One might think about filtering all
dives without tags, etc. instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implement the close & reset functionality, by reseting the
application state to "Default". This is currently the only
state from where the fiter can be called.
To make it consistent with CTRL^F, clear the filter in the
hide() slot, which is called in both cases.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Move initialization to a separate function and connect that to the
reset button.
Two points of note:
1) Reseting the text-fields causes signals. Thus, signals have to
be ignored during reset. Do this with a new flag.
2) To make reset of the from-date work, the from-date has to be
initialized to a distinct value. Setting a default-constructed
QDateTime leaves the widget unchanged.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Update the filter counts if dives were added removed by the
undo commands. The undo commands call into the filter model
at the right time so that hidden_by_filter is already set.
The filter model keeps track of the counts and emits a signal,
which is caught by the widget.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The temperature range 0-100 was inadequate in both supported
scales (Celsius and Fahrenheit). Extend the range to encompass
all physically meaningful values in both scales.
Use the default-values to set the minimum and maximum of the
UI-fields. Thus, these values are configurable in a single place.
In the future we should use a scale-independent representation
(e.g. mkelvin as in the rest of the code base). But this would
mean implementing a custom widget with a conversion function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
1) Choose the correct conversion function for comparison.
2) Add a unit suffix to the fields.
3) Update the suffixes on change of preferences.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On all (most?) places we use separate date/time fields for the time of a
dive, and we follow the setting from the preferences to format those.
Make the new filter widget consistent, with respect to the to and from
interval.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Commit 8e81d3f100 changed a bunch
of Ui classes to be subobject of the widget. For consistency do
the same with the filter widget.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In FilterWidget2::updateFilter() a new FilterData object is generated
and then copied onto the filterData member variable. Instead, modify
filterData directly. This seems also more logical from a semantic
point of view: Do we want to reset fields that were not set by the
user?
Contains trivial whitespace fix.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the latest version of the new filter-widget the connection
between widget and filter was lost. Connect both - but use a
simple function call instead of a signal, since it is not
immediately obivous where the connection should be made.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The idea is that this struct will have all the needed data
that will be passed to the filter model. Everything that happens
on the filterwidget will fill out this struct, then forward it
to the model, that in turn will activate the filter hiding
some of the dives that matches on your divelist.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
The idea of this new widget is to be able to filter more
types of data, while keeping it simple and extending the
feature set to something that was impossible with the old
implementation.
While the old implementation had 4 panels that you could
use to filter specific tags / people / types of dives
the new one will let you filter by visibility, temperature
people, name, equipment, etc, in a more natural way
than the old one.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>