There were two classes, MultiFilterInterface and FiterModelBase.
The latter derives from the former and from QStringListModel.
The former was not used anywhere else. Moreover, in contradiction
to its name, MultiFilterInterface is not an interface (in the Java
sense), because it actually has (non-virtual) data members. All in
all, the data model is very weird.
Merge these two classes, since there seems to be no gain whatsoever
from keeping MultiFilterInterface separate.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit 6343515fed introduced equality
instead of substring comparison for filters. This broke the buddy
filter in the case of more than one buddy, because in such a case
the buddy list is a comma-separated string.
Fix this by splitting the buddy string, trimming the individual
strings and search in the list.
Fixes#969
Reported-by: <yrevawerd@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If the user implicitly adds a dive site by editing a dive, and
a location filter is active, check the new dive site in the
location filter.
This is done by informing the LocationFilterModel of the new
dive site name prior to repopulation. The LocationFilterModel
then adds a corresponding entry and marks it as checked.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since commit 01d961086c, the location filter
list is updated if a dive site is edited. The problem is that if the
name of a selected dive site is changed, the selection is lost.
Therefore, before repopulating, inform the location filter that a dive
site changed its name. The location filter then internally changes the
name and can properly transfer the old selection on repopulate. This is
performed via the new LocationInformationWidget::nameChanged signal,
which is connected to the new LocationFilterModel::changeName slot.
A special case to be handled is the following:
[ ] Site 1
[x] Site 2
and "Site 2" being renamed to "Site 1", i.e. both sites being merged.
Here, the merging is detected and "Site 1" will likewise be checked:
[x] Site 1
[x] Site 1
No merging is performed, as the list will be repopulated anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is a continuation of commit 739b27427c,
in which a substring comparison was replaced by equality comparison to
avoid confusing UI behavior of the filter interface.
The suit and buddy filters were plagued by the same problem, so change
their code in analogy.
Fixes#551 (in conjunction with commit dd2466f518).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Update the filters if the list of dives is updated by calling
MultiFilterSortModel::instance()->myInvalidate();
This had the side effect of clearing all selections. Thus, in
the repopulate() methods of the FilterModels, check those
entries that were checked previously. Since all the filter
models use the same code, introduce a base class FilterModelBase.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This replaces a dynamically allocated array of bool by std::vector<char>.
1) This makes the code shorter and less error prone, because memory
management has not to be done by hand.
2) It fixes a bug in the old code:
memset(checkState, false, list.count()) is wrong, because bool is
not guaranteed to be the same size as char!
Two notes:
1) QMap<>, QVector<>, etc. are used numerous times in the code, so
this doesn't introduce a new C++ concept. Here, the std:: version
is used, because there is no need for reference counting, COW
semantics, etc.
2) std::vector<char> is used instead of std::vector<bool>, because
the latter does a pessimization where a bitfield is used!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The location filter used a substring comparison, which had
the side effect that dives with the location "Test 1" were
shown when filtering for "Test 12".
Moreover, avoid a deep copy of the location list. This is
done by looping over one item less than rowCount() instead
of removing the last item. While doing this, remove an
unnecessary if-statement.
This commit partially fixes#675.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit aa1446bed2 ("Make filters work again in master") makes filters
work again for the desktop app, but breaks building Subsurface-mobile.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since 6cd711a1 filters don't work. This went unnoticed because the
commit wasn't applied on v4.5-branch.
Partially reverting it makes filters work again.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Having subsurface-core as a directory name really messes with
autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an
autocomplete conflict and also was inconsistent with the desktop-widget
name for the directory containing the "other" UI.
And while cleaning up the resulting change in the path name for include
files, I decided to clean up those even more to make them consistent
overall.
This could have been handled in more commits, but since this requires a
make clean before the build, it seemed more sensible to do it all in one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we have now destkop and mobile versions, 'qt-ui' was a very
poor name choice for a folder that contains only destkop-enabled
widgets.
Also, move the graphicsview-common.h/cpp to subsurface-core because
it doesn't depend on qgraphicsview, it merely implements all the
colors that we use throughout Subsurface, and we will use colors on both
desktop and mobile versions
Same thing applies for metrics.h/cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Did a git rebase and some stuff changed in the meantime;
This is a compatibility commit: Add a few include directories
on the cmake to quiet some ui_headers.h not being found (the
ones that are created automatically by uic) and a few noiseances
like models requiring interface functionality.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some dive sites are separated in more than one real dive site
(for instance, a 'blue hole' dive site that has different
entry points on the gps), so instead of checking only the
dive_site id, also check it's name.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is an attempt to help share code between the desktop version of
Subsurface and the mobile version.
More code will be moved around and the models will be split in a way that
will help recompile times and also creation of different interfaces for
different form-factors.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>