aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models
AgeCommit message (Collapse)Author
2020-03-10mobile/divelist: create memory management class for modelsGravatar Berthold Stoeger
Since we want to add a second model, but not have to manage two models everywhere, create a class MobileModels that contains both of the models. When calling reset() on that class, it will reset both of the models, etc. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile: unify download code on mobile and desktopGravatar Berthold Stoeger
Use the undo-command for importing dives also on mobile. This should make the whole disconnect-model shenigans unnecessary. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10undo: clear undo-stack when clearing dive dataGravatar Berthold Stoeger
When the dive data is cleared, all pointers in the undo-stack become stale. Desktop explicitly called Command::clear() in that case, but mobile doesn't. Thus, move the clear() call into DiveTripModelBase::clear() Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09mobile/undo: compile WSInfoModelGravatar Berthold Stoeger
The weight-undo commands need this. Therefore, we have to compile the WSInfoModel if we want to access the undo commands from mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09mobile/divelist: connect click on trip to toggle MobileListModelGravatar 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-09mobile/divelist: trip date and title roles for new modelGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09mobile/divelist: implement trip title and short date for mobileGravatar Dirk Hohndel
We pass this through to the underlying data function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09mobile/divelist: copy & paste the roles-code from DiveListModelGravatar Berthold Stoeger
To act as a drop-in replacement (at least as much as possible), move the roles from the old DiveListModel to the common base model of mobile and desktop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09mobile/divelist: add first version of new MobileListModel proxy modelGravatar Berthold Stoeger
Create a model which represents all top-level items and, potentially, one expanded trip as a flat list. Pass down roles to the source model and let the source model handle that. We'll have to do some ifdef-ery, but so be it. Additionally, compile the base model on mobile as well. This contains a couple of hacks to make things compile at all. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07divetripmodel: send shown changed signal on resetGravatar Berthold Stoeger
Once the the mobile app uses the new models, this will be necessary to get the correct number of filtered dives after startup. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-07divetripmodel: mark derived classes as finalGravatar Berthold Stoeger
This is an idle "optimization": The compiler may now not need to access the vtable when calling virtual functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06divetripmodel: use change of CURRENT_ROLE to propagate current diveGravatar Berthold Stoeger
If compiled on mobile, on change of the current dive, don't send a signal, but send changed-event with the CURRENT_ROLE for both dives that changed status (previously selected and newly selected). Mobile does not use this yet, but will do so with the new flattened models. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06divetripmodel: add TRIP_HAS_CURRENT_ROLEGravatar Berthold Stoeger
This role returns true if the given trip contains the current dive. This will be needed by the mobile list model to decide if a newly added trip should be expanded right away. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06divetripmodel: introduce CURRENT_ROLEGravatar Berthold Stoeger
Use this role to test whether a dive is the currently displayed dive. This will be needed to transport changes of the current dive to the mobile list models. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-28cleanup: simplify string-comparison in CylindersModel::setData()Gravatar Berthold Stoeger
Convert to QString instead of a QByteArray. Use qPrintable() instead of data(). This might do one more UTF16->UTF8 conversion. However, this is completely irrelevant, since we don't change the type of a cylinder in a tight loop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-28cleanup: fix leak in CylindersModel::setData()Gravatar Berthold Stoeger
The C-string cyl->type.description was set without the old data being freed. Free the old string before overwriting the pointer. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-28cleanup: make CylindersModel::cylinderAt privateGravatar Berthold Stoeger
The last outside use of the function was replaced by calls to data(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-28crash fix: Don't cast to CylindersModel or CylindersModelFilteredGravatar Berthold Stoeger
The tank-info-delegate cast its model to CylindersModelFiltered, since this is what the equipment-tab uses since implementing the filtering of unused cylinders. However, the planner users the same delegate and still uses the unfiltered CylindersModel. This means that the (dynamic) cast returns a null pointer and crashes. One possibility would be to derive CylindersModelFiltered and CylindersModel from the same class that defines virtual functions and cast to that class. This is a different attempt: don't cast (i.e. stay with a QAbstractItemModel and play it via Qt's model-view system. Firstly, replace the passInData function by a role to setData(). Secondly, read the working-pressure and size via new columns using data(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-24CylinderModel: remove unnecessary "Is used" headerGravatar Berthold Stoeger
This header is a rebase artifact and introduces a pointless column in the cylinder tables. It was erroneously introduced in 6622f42aab937e72cc11cb5512012394aa687767. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-23cleanup: remove CleanerTableModel::warningMessage signalGravatar Berthold Stoeger
Nobody was ever listening to this signal(?) and the last sender was removed in ac52034778bc5c82bb6c689d765b337b6d75b24a. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Filter: move actual filtering loop to core/divefilter.cppGravatar Berthold Stoeger
The DiveFilter class defined the showDive() function to test whether a dive should be filtered or not. This was used in DiveTripModel to loop over all dives or all dives affected by an editing action. This restricts us in how we do filtering: We can't use indexes that give us directly the result. To make the filtering more flexible, move the actual loops that do the filtering to the DiveFilter class. The undo-commands likewise called directly the showDive() function to check whether newly added dives are shown. Use the new interface here as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Filter: update current dive if change hides current diveGravatar Berthold Stoeger
When changing the filter-criterion and the current dive is hidden, a new dive is made current. However, when a dive is hidden because it was edited, it is still shown. Make this consistent by also selecing a new current dive in the latter case. Do this by comparing the current_dive before and after calculating the filter. Since this is now done in multiple places move this code to the ShownChange class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Cleanup: remove shown flag of DiveTripModelTree itemsGravatar Berthold Stoeger
Since we now filter at the model level, items are by definition shown. No need for a flag. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Cleanup: remove DiveTripModelBase::SHOWN_ROLEGravatar Berthold Stoeger
This role was used by the filter-proxy model as filter criterion. Since we don't use that model to filter anymore, we can remove the role. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Cleanup: remove DiveTripModelBase::sendShownChangedSignals()Gravatar Berthold Stoeger
This was used by the old filtering code. This is not necessary anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Dive list: remove filtering in MultiFilterSortModelGravatar Berthold Stoeger
Since we're doing the filtering at the core, don't filter in the sort-model (which is now inappropriately named). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Dive list: filter dives at DiveTripModel levelGravatar Berthold Stoeger
We use a QFilterProxyModel to filter out dives that are hidden according to the current filter-criterion. Instead, filter the dives already at the DiveTripModel level. Filter out hidden dives immediately when receiving them. The only difficult case is when dives are changed, because then visibility can change. This means that we have three cases to consider: 1) Visibility unchanged -> send change signal 2) Change from hidden to unhidden -> add dives to model 3) Change from unhidden to hidden -> remove dives from model Things get complicated by the fact that the tree-version of the model might have to add/remove full trips! Suggested-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11Planner: don't filter cylindersGravatar Berthold Stoeger
In the planner we used to filter out "unused" cylinders as in the equipment tab. It is unclear whether that makes sense or can even easily be reproduced, since such cylinders have to come from an imported dive. To be on the save side, let's not do this. Replace the CylindersFilteredModel introduced recently by a plain CylindersModel. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11Planner: make cylinder-model subobject of planner-modelGravatar Berthold Stoeger
The cylinder-model had an instance() function, but actually there were two cylinder models: one used by the equipment tab, one used by the planner. This is misleading. Therefore, remove the instance() function and make the cylinder-model a subobject of the planner-model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11Cylinders: Add CylindersModelFilteredGravatar Berthold Stoeger
When the show_unused_cylinders flag is not set, the cylinder tables in the equipment tab and the planner should not show unused cylinders. However, the code in CylindersModel is fundamentally broken if the unused cylinders are not at the end of the list: The correct number of cylinders is shown, but not the correct cylinders. Therefore, add a higher-level CylindersModelFiltered model on top of CylindersModel that does the actual filtering. Some calls are routed through to the base model (notably those that take indexes, as these have to be mapped), for some calls the caller has to get access to the source model first. We might want to adjust this. For filtering, reuse the already existing show_cylinder function and export it via CylindersModel. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11Cleanup: make CylindersModel::updateBestMixes non-slotGravatar Berthold Stoeger
This was not used as a target of a connection anywhere. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11Cleanup: remove filterSelectedDives function in divetripmodel.cppGravatar Berthold Stoeger
The last users of the returned vector were removed in commit e1abf9485cf59f1b8cb79d827fa386af48f095a4 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08mobile/summary: use more intuitive time periodsGravatar Dirk Hohndel
No one will ask you about your dives in the last seven months (and the existing code actually provided the past 210 days in that case). Instead do more intuitive periods. Last month, quarter, half year, year. Use Qt's ability to make sane date calculations easy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08mobile/summary: add section headersGravatar Berthold Stoeger
Add section headers to the dive summaries on mobile by adding a section-property. Of course, this will not work on desktop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08mobile/summary: create DiveSummaryModelGravatar Berthold Stoeger
Instead of passing the dive summary via a completely unstructured QStringList to QML, implement a dynamic model. For potential reuse on desktop (though somewhat unlikely) the model has two interfaces, one for QtWidgets and one for QML. The former is based on columns, whereas the later is based on roles. The number of columns is set dynamically. The roles currently support access to two columns. If more columns should be accessed from QML, more roles have to be added manually. This commit only creates the model and hooks it into QMLs global context, but does not yet change the QML page. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
2020-02-04Dive site: ignore dive sites without location in proximity searchGravatar Berthold Stoeger
When editing a dive site, the user can search for close dive sites to merge duplicates. Dive sites without location are treated as being located at 0N0E. This makes no sense, because: When selecting a dive site without location, we shouldn't list dive sites close to 0N0E. Likewise when having a dive site close to 0N0E, we shouldn't list dive sites that have no location. Therefore, ignore these cases. This also means that now dive sites without location are not considered as close to other dive sites without location. That might be a debatable point. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04Cleanup: lower-case filenames in core/subsurface-qt/Gravatar Berthold Stoeger
We tend to use lower-case filenames. Let's do it for these files as well. Simple search & replace. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-30CylindersModel: don't crash if accessing non-existing cylinderGravatar Berthold Stoeger
It shouldn't happen, but currently we overwrite the displayed_dive without updating the CylindersModel. Thus, CylindersModel may now crash when the new displayed_dive has less cylinders than the old one. For now, catch this condition. Treat the root cause later. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-25diveplanner: add comments explaining different scalingGravatar jan Iversen
In some case the scaling (real value <-> UI value) is different for mobile and desktop. In order to make the difference understandable comments are added to each function. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25diveplanner: move mobile specific calc to diveplannermodelGravatar jan Iversen
setBottomSac, setDecoSac and setFactor in diveplannermodel receives display value which are then converted. subsurface-mobile have slightly different values, move the correction of these from plannershared to diveplannermodel, in order to keep the whole convert in one place. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20qt-models: add suffix Display to unit system aware asc/desc settersGravatar jan Iversen
Change ascent/descent setter function names to set_<name>Display to show the value is prepared for displaying (common for desktop and QML). Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20qt-models: add getters to diveplanner modelGravatar jan Iversen
diveplannermodel already contains set_<asc/desc> function that convert from screen value to real value; this adds get functions that convert real value to screen value, so now all conversions are done in one place. Use prefix Display to identify this is values prepared for the UI (both desktop and QML). Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-10code cleanup: add empty table structuresGravatar Dirk Hohndel
It seemed to make sense to combine all three types in one commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-10code cleanup: introduce empty_cylinder constantGravatar Dirk Hohndel
This deals with the issue of initializing structs in C++. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>