aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.cpp
AgeCommit message (Collapse)Author
2020-03-10mobile: remove no longer used DiveListModelGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09mobile: remove collapsed model that we no longer useGravatar Dirk Hohndel
The dive list now uses the mobile list model. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-01mobile/filter: derive numShown from a new Q_PROPERTYGravatar Berthold Stoeger
The number of dives was updated when the model of the list was changed. Since we removed the multi-threading, the model is not disconnected/connected anymore and therefore we don't get the appropriate signal. Instead of introducing a different signal, make the shown-value a Q_PROPERTY. Thus, we can easily send a changed signal if we have to. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: introduce people- and tags-filtering in the mobile UIGravatar Berthold Stoeger
Add a combo-box where the user can switch between "fulltext", "people" and "tags" filtering. Connect the combobox to the already existing filter-code. Dirk: make combo-box smaller by using a smaller font and restricting the width. Setting both maximum and preferred widths gives more consistent results. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-01filter: use DiveFilter on mobileGravatar Berthold Stoeger
Use the DiveFilter class on mobile to update the filter. This is mostly for convergence of the mobile and desktop models. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01mobile: remove DiveListSortModel::getFilterString()Gravatar Berthold Stoeger
This member function was never used. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04Cleanup: remove capture-all lambda clausesGravatar Berthold Stoeger
These were forgotten the last time. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-13qt-models: remove LOG_STP from mobile/desktopGravatar jan Iversen
LOG_STP is on longer providing the data needed, since a lot of the startup is indirectly in QML, furthermore using the xcode project and running profiler gives much more detailed information Signed-off-by: Jan Iversen <jani@apache.org>
2019-11-08Mobile: correctly update filter text and update all three modelsGravatar Dirk Hohndel
This is even harder because setActiveTrip is called from an action slot from QML. If the C++ code called from that slot causes the object to which this slot belongs to be destroyed, we get very strange crashes. The only workaround I could come up with was to update the filter asynchronously. This all seems very ugly and fragile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08Mobile: ensure the sort order is always setGravatar Dirk Hohndel
This shouldn't be necessary every time we replace the sort model, but it can't hurt, either (famous last words?). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08Mobile: add second filter proxy model for dive listGravatar Dirk Hohndel
This one significantly reduces the number of dives that are handed to the ListView in QML. For every trip that isn't expanded (only zero or one trips are expanded at any time, so almost all the others are collapsed), send only first dive to the View to allow creation of the section. Hide the rest so we don't have all these invisible, zero height entries for the vertical dive list. A big part of this commit is moving a few functions from the DiveListSortModel to the CollapsedDiveListSortModel. Those are the ones that are needed for the trip header. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-20Mobile: remove remaining accesses to DiveObjectHelper from QMLGravatar Dirk Hohndel
Add a couple more roles and remove the dive role that allows accesss to the DiveObjectHelper in the first place. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-20Mobile: get dive details directly from the modelGravatar Dirk Hohndel
By getting a DiveObjectHelper and then dereferencing that we ended up creating hundres and hundreds of these objects, only to immediately destroy them after using a tiny part of the data. Instead make those data available directly from the model, without having to create a DiveObjectHelper forst. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-04Cleanup: Turn DiveListSortModel into classical singletonGravatar Berthold Stoeger
To make this class available from QMLManager, the run_ui() function would create the object and then set a pointer in QMLManager. It works, but is inconsistent with the rest of the code. Therefore, make it a classical singleton class, which is generated on demand. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-04Cleanup: turn DiveListModel into standard singletonGravatar Berthold Stoeger
DiveListModel was one of those "special" singletons that could be created explicitly with new. This would make sense if a parameter were passed to the constructor. We only passed null, so one might as well turn that into a classical singleton with default constructor. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-04Cleanup: initialize DiveListSortModel in constructorGravatar Berthold Stoeger
The model was initialized in the global run_ui() function. Move that into the constructor of the class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-27Mobile: replace model-reset by row-addition in DiveListModel::reload()Gravatar Berthold Stoeger
Owing to apparent QML breakage, a model-reset leads to the DiveDetail page being reloaded for every dive in the list(!). Therefore, add rows instead. This leads to extremely subtle code, as it is now imperative that the model has been properly cleared beforehand. Nevertheless, for now we have to do this to fix a severe performance regression. Fixes #2295 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-27Mobile: clear dive data via modelGravatar Berthold Stoeger
Clearing the dive data directly in the core leaves us with an inconsistent model. Therefore, clear via the model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-27Revert the singleton PRGravatar Dirk Hohndel
It turns out that this isn't working the way it was intended to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-25Cleanup: unify idiosyncratic singletonsGravatar Berthold Stoeger
The way we handle singletons in QML, QML insists on allocating the objects. This leads to a very idiosyncratic way of handling singletons: The global instance pointer is set in the constructor. Unify all these by implementing a "SillySingleton" template. All of the weird singleton-classes can derive from this template and don't have to bother with reimplementing the instance() function with all the safety-checks, etc. This serves firstly as documentation but also improves debugging as we will now see wanted and unwanted creation and destruction of these weird singletons. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-21Mobile: pass section directly to tripTitle() and tripShortDate()Gravatar Berthold Stoeger
Instead of converting the section-heading string to a trip-pointer in QML and pass that to the tripTitle() and tripShortDate() functions, pass the string and convert in C++ code. Hopefully, this makes the code more robust. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-21Mobile: pass trip-ids through QML, not formatted pointersGravatar Berthold Stoeger
The section heading in the QtQuick ListView has to be a string. Therefore, we passed a pointer formatted using hexadecimal notation. Later, that was converted back without being checked. A very scary proposition, so let's pass unique integer trip-id instead. This means that on converting back we have to scan the trip table, but that is a very minor cost comsidering to the gained robustness. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: Map directly from source in DiveListSortModel::getIdxForId()Gravatar Berthold Stoeger
Instead of looping over all dives and search the dive with the given id, let the source model determine the index and map that. Thus, we do only one mapping and don't generate a ton of DiveObjectHelpers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: provide direct access to dives in DiveListModelGravatar Berthold Stoeger
Accesses were via DiveObjectHelpers. Provide a direct access to struct dive *. Use this for the filter - there is no point in mass generating DiveHelperObjects in the filter code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: create DiveObjectHelper only when neededGravatar Berthold Stoeger
In DiveListModel::data() a DiveObjectHelper was created for any data-access. Create it only when a DiveObjectHelper is actually returned. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: remove dive argument from DiveListModel::insertDive()Gravatar Berthold Stoeger
Since DiveListModel does not keep its own list of dives anymore, insertDive() doesn't use the DiveObjectHelper argument. Remove it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: replace clear()/addAllDives() pairs by reload()Gravatar Berthold Stoeger
The clear()/addAllDives() pair was bogus as the former didn't clear the model (this is not possible anymore - the model represents the core dive list) and the latter readded all dives again. Replace this by a reload() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Cleanup: remove DiveListSortModel::addAllDives()Gravatar Berthold Stoeger
This function was never used. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: Generate DiveObjectHelpers on the flyGravatar Berthold Stoeger
Instead of keeping track of a list of DiveObjectHelpers, generate them on-the-fly in DiveListModel. Thus, there is less danger of model and core getting out of sync. On the flip-side, now the DiveListModel and the DiveListSortModel might get out of sync. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14DiveObjectHelper: Turn DiveObjectHelper into Q_GADGET based objectGravatar Berthold Stoeger
DiveObjectHelper is a tiny wrapper around dive * to allow access to dive data from QML and grantlee. It doesn't have to be a full-fledged QObject with support for signals, etc. Therefore, turn it into a Q_GADGET based object. This allows us passing the object around as object, not as pointer to DiveObjectHelper. This makes memory-management distinctly easier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return depthDuration directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this data directly from the model. In this case, don't remove from DiveObjectHelper, as these data might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return location directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. In this case, don't remove from DiveObjectHelper, as this datum might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return dive-number directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. In this case, don't remove from DiveObjectHelper, as this datum might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return dive-id directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. In this case, don't remove from DiveObjectHelper, as this datum might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return dateTime directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this data directly from the model. In this case, don't remove from DiveObjectHelper, as these data might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: move tripNrDive from DiveObjectHelper to DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: move tripId from DiveObjectHelper to DiveListModelGravatar Berthold Stoeger
The canonical way of displaying lists in Qt is via models. Thus, return the tripId directly from the DiveListModel instead of going indirectly via a DiveObjectHelper. In the future, this will allow us to make the DiveObjectHelper value-based, as it is not generated numerous times for every list item. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: remove full-text properties from DiveObjectHelperGravatar Berthold Stoeger
These properties are not needed anymore, because the full text search was decoupled from the DiveObjectHelper. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: decouple full text search from DiveObjectHelperGravatar Berthold Stoeger
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>
2019-08-13Mobile: fix bound check in DiveListModel::data()Gravatar Berthold Stoeger
Indexes go from 0 to count - 1. Thus, the comparison for invalid indexes has to read ">= count", not "> count". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19Cleanup: move trip-related functions into own translation unitGravatar Berthold Stoeger
These functions were spread out over dive.c and divelist.c. Move them into their own file to make all this a bit less monolithic. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-15Core: turn add_single_dive() to append_dive()Gravatar Berthold Stoeger
The only external caller of add_single_dive() used it to append a dive to the global dive list. Rename the function accordingly and remove the index parameter. The internal caller can use the local insert_dive() function, which doesn't consider selection. That shouldn't be a problem, as the caller is doing import. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12get rid of some foreach and Q_FOREACH constructsGravatar Rolf Eike Beer
See https://www.kdab.com/goodbye-q_foreach/ This is reduced to the places where the container is const or can be made const without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7) and std::as_const (C++17) are not available in all supported setups. Also do some minor cleanups along the way. Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-01-09Cleanup: Make add_dive_to_table local to divelist.cGravatar Berthold Stoeger
This function was not used outside of divelist.c, therefore make it local. Moreover rename it to add_to_divetable so that the name is generic and can be generated by a macro. Moreover, remove the special case idx = -1, which would determine the insertion index. Instead let the single caller who used this feature do this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-27Cleanup: remove getDiveId() functionsGravatar Berthold Stoeger
These functions in DiveListSortModel and DiveListModel had no users. Remove them. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-23Filter: use hidden_by_filter also on mobileGravatar Berthold Stoeger
Desktop used the hidden_in_filter flag in struct dive, mobile used its own vector plus a new showndives member in struct dive_trip. Unifiy these to use the same core-facility, viz. hidden_by_filter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-23Mobile: don't format trip heading for all divesGravatar Berthold Stoeger
QML's ListView uses the "section" property to test if items belong to the same section. Apparently, this must be a string and therefore we can't pass e.g. a dive-trip object. Therefore a specially formatted string was passed in, which was guaranteed to be unique (contained the dive-trip pointer value) and the fully formatted trip-title and short-date. The disadvantage of that approach is that the formatting is performed for every dive and not every trip. Perhaps not a problem now, but it makes it for example necessary to cache the number of filtered dives. To be more flexible, pass in only the pointer value formatted as hexadecimal string and provide a function to convert that string back to a trip-pointer (in the form of a QVariant, so that it can be passed to QML). Moreover provide two functions for formatting the title and the short-date. The three new functions are members of DiveListSortModel. This might not be the perfect place, but it is easy to reach from the DiveListView. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-18Dive list: replace dive-list of trips by a tableGravatar Berthold Stoeger
The dives of each trip were kept in a list. Replace this by a struct dive_table. This will make it significantly easier to keep the dives of a trip in sorted state. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-25Mobile/filtering: update nr of dives shown in a trip when filteringGravatar Dirk Hohndel
Whenever the filter changes, simply walk the filtered dive list and ensure that we have the correct count for dives that match this filter. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: roll our own filtering for performance reasonsGravatar Dirk Hohndel
The regular expression based generic filtering made things very slow on a cell phone or other, slower device. With this the results seem more reasonable. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>