aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/filtermodels.h
AgeCommit message (Collapse)Author
2018-08-14Filter: remove unused parameters from doFilter functionsGravatar Berthold Stoeger
Change the signature from of the virtual doFilter() functions from bool doFilter(struct dive *d, QModelIndex&, QAbstractItemModel*) const; to bool LocationFilterModel::doFilter(struct dive *d) const; as the QModelIndex and QAbstractItemModel parameters were not used. This makes this functions independent from Qt's model/view framework. This is in preparation for making the undo-machinery compatible with the filtering. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-01Cleanup: remove all override modifiersGravatar Berthold Stoeger
Commit df156a56c08a56eb380711a507ef739d8150a71f replaced "virtual" by "override" where appropriate. Unfortunately, this had the unintended consequence of producing numerous clang warnings. If clang finds a override-modified function in a class definition, it warns for *all* overriden virtual functions without the override modifier. To solve this, go the easy route and remove all overrides. At least it is consistent. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-31Cleanup: replace virtual by override where appropriateGravatar Berthold Stoeger
The keyword "virtual" signalizes that the function is virtual, i.e. the function of the derived class is called, even if the call is on the parent class. It is not necessary to repeat the "virtual" keyword in derived classes. To highlight derived virtual functions, the keyword "override" should be used instead. It results in a hard compile- error, if no function is overridden, thus avoiding subtle bugs. Replace "virtual" by "override" where appropriate. Moreover, replace Q_DECL_OVERRIDE by override, since we require reasonably recent compilers anyway. Likewise, replace /* reimp */ by "override" for consistency and compiler support. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-26Introduce negate-toggle buttons to filter listsGravatar Berthold Stoeger
Introduce toggle buttons which mean "filter all dives except those fulfilling the selected criteria". The old code used to check for rowCount() == 0. This should never happen, because there is always a row "empty field". This check was moved into the preamble of the functions to seperate it from the actual logic. Fixes #435 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24Add select-all, deselect-all and invert-selection options to filtersGravatar Berthold Stoeger
To every filter list add a menu button that allows selection of all, selection of none or inversion of selection. Implements #435. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24Move *FilterModel functions into base classGravatar Berthold Stoeger
The *FilterModels had a number of of virtual functions, which only accessed members of the base class. Moreover, these functions were identical and generated with macros. Therefore, move these functions to the base class. The one excption is data(), which uses different count functions (passed as a macro parameter). Thus, introduce a virtual countDives() function and likewise move data() to the base class. A function pointer might be even more clear, but since the rest of the code/Qt relies heavily on runtime polymorphism, let's do the same here. The only macros left are those creating the singleton accessors. This could be more clearly realized by templates, but let's likewise keep it the way is. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24Fold MultiFilterInterface into FilterModelBaseGravatar Berthold Stoeger
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>
2017-11-26Inform LocationFilterModel of added dive site nameGravatar Berthold Stoeger
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>
2017-11-26Inform LocationFilterModel of changed dive site nameGravatar Berthold Stoeger
Since commit 01d961086c1d175732c597dc9acdba7cc4cd2d26, 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>
2017-11-25Update filters on refreshDisplay and remember old selecttionsGravatar Berthold Stoeger
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>
2017-11-25Replace bool * array by std::vector<char> in MultiFilterInterfaceGravatar Berthold Stoeger
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>
2017-04-29Add SPDX header to Qt modelsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29Move the models to its own folderGravatar Tomaz Canabrava
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>