aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2020-03-22Typo fix: Programm to programGravatar Johan Hansson
Signed-off-by: Johan Hansson <reply.johan@gmail.com>
2020-03-22cleanup: remove unnecessary <QDebug> includeGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22cleanup: split uiLanguage() in two functionsGravatar Berthold Stoeger
The uiLanguage() function was used for two purposes: to initialize the language related preferences and to read the current language. To make things more easy to follow, split this function in two: one for initializing, one for getting the current language. Moreover, don't return the current locale in an out-parameter as there is already a function to do that [getLocale()]. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Dive filter: reset filter on change of display_invalid_dives flagGravatar Berthold Stoeger
The user had to restart the application or manually change the filter if they changed the flag. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Dive list: add option to mark dives validGravatar Berthold Stoeger
If the dive the user clicked on is invalid show an option to make the dive valid. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Undo: implement invalidate-dive commandGravatar Berthold Stoeger
Connect command to context menu. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-19Typo: UCT to UTCGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-03-18models: update divesite-model when clearing/updating dive modelGravatar Berthold Stoeger
When the dive list is cleared or updated, the entries in the divesite-model become stale and therefore the divesite-model (with the actual name LocationInformationModel) also must be updated. This was done manually in some parts of the code and forgotten in others. Therefore, do it directly in the clear() and reset() function of the dive list-model. This might be a bit of a layering violation: why should one model call into another if they are not in parent/child relationship? However, this seems easier than introducing a global "reset dives" function that coordinates the models. Moreover, it does not appear 100% safe: if the clearing of the divesite model causes accesses to the divelist-model, they happen in the midst of a model reset and we had horrible bugs with that kind of things. However, I don't think that should happen. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-12Make statistics window resizable on MacGravatar Robert C. Helling
For some reason, the window needs an active maximize button to be resizable on Mac. Fixes #2671 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-11Grammar: replaces 'indexes' by 'indices'Gravatar Robert C. Helling
Grammar-nazi ran git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g' to prevent future wincing when reading the source code. Unfortunatly, Qt itself is infected as in QModelIndexList QItemSelection::indexes() const Signed-off-by: Robert C. Helling <helling@atdotde.de>
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-07debug: try to capture changes that don't invalidate git cacheGravatar Dirk Hohndel
At least in those cases where we are sending a divesChanged signal we can easily check if the cache was properly invalidated. Of course this won't help in cases where we don't notify the dive list about changes, either. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-06Cleanup: Move stringToList to core/qthelper.cppGravatar Berthold Stoeger
The same code was used in desktop and undo commands. Let's unify. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06Cleanup: use getDiveSelection() for shifting timeGravatar Berthold Stoeger
There are two cases where dive-times are shifted: in an explicit dialog and when editing the date/time of a dive. In each of these cases, the selected dives were collected manually. Instead use the getDiveSelection() function. Since this returns a std::vector, change the argument of Command::ShiftTime() to such a std::vector. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-05desktop UI: fix typo in GPS import UIGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-01selection: update selection on key-pressesGravatar Berthold Stoeger
Commit 2cea115ddb7528d9e6dd1bf918ebf5c670b82479 "fixed" the selection by hooking into mouseRelease events. An unintended consequence was that scrolling with the cursor keys didn't update the current dive. Therefore, also hook into the corresponding key-press events. This is just horrible, but I'm not aware of any possibility to fix it properly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: fix tab-order of filter widgetGravatar Berthold Stoeger
This was basically random. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: on show focus on fulltext-fieldGravatar Berthold Stoeger
After pressing CTRL-F let the user immediately enter a search string. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: connect fulltext filter to frontendGravatar Berthold Stoeger
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>
2020-03-01filter: add fulltext field to filter widgetGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: move StringMode out of FilterDataGravatar Berthold Stoeger
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>
2020-02-28cleanup: remove setTabIcon() calls in MainTabGravatar Berthold Stoeger
These were used to remove warning-icons to mark tabs with user changes. However these icons haven't been set since commit a86aca037843167b26726926dbf2aebe0513afba. 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-27cleanup: don't update tabs twice in MainTab::rejectChangesGravatar Berthold Stoeger
The updateDiveInfo() call updates all tabs. No need to do it right afterwards. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27cleanup: remove weightsystems_equal functionGravatar Berthold Stoeger
This was used to test whether the "really discard changes?" message should be shown. However, we now edit weightsystems directly with undo commands. Therefore, the check is unnecessary and the whole function can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27cleanup: remove MainTab::modifiedGravatar Berthold Stoeger
This field was not set to true since introducing undo of dive fields. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-16Cleanup: remove unneeded QtConcurrent includesGravatar Berthold Stoeger
These became unneeded owing to code reshuffling. 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-11Filter: update filter if any of the string-modes changedGravatar Berthold Stoeger
Simply hook the corresponding signals to the update-filter slot. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11Filter: implement starts-with and exact modesGravatar Berthold Stoeger
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>
2020-02-09Cleanup: remove const bool parameters and return typesGravatar Berthold Stoeger
These just make no sense. Since the value is copied, it has no meaning to the caller whether the function can change the value (and vice versa for return types). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-09Cleanup: remove exportFunc classGravatar Berthold Stoeger
exportFunc was a collections of functions for exporting dive data. It had no state, therefore there is no reason for it to ever be instantiated. Simply remove the class. Rename the saveProfile function to exportProfile so that all export functions start with "export". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-09Cleanup: Remove global QFuture from exportFuncsGravatar Berthold Stoeger
When exporting dives we show a message. The message is closed when the export is finished. This is coordinated by a QFuture. Instead of keeping a global QFuture in the export-code, pass it around as a local variable. This is supported according to Qt's documentation: "QFuture is a lightweight reference counted class that can be passed by value." and the source code indicates the same. Not only does this remove a global, it also makes the code more flexible: Now we could show one notification per export, for example. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08Dive list: be more careful on when updating the UI after selectionGravatar Berthold Stoeger
Fix two issues: 1) When narrowing the selection, we didn't get setSelection() calls. Only, when the user released the mouse button was the selection updated. Therefore, hook into the mouse-release- event and update the UI if the selection changed. 2) We updated the ui in setSelection(). However, this was called on mouse-move even if the actual selection didn't change. Therefore, compare selection before and after processing of the event and only refresh the UI if there are changes. Clearly, this can only be a quick stopgap solution and we should find out how to properly hook into the selection change machinery. Though see commit 4928c4ae0421193bbd371cb0924091a970489611 for the reason why we do things as we do them. Fixes #2595 Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06Cleanup: don't initialize DivePlannerPointsModel at startupGravatar Berthold Stoeger
The whole point of having X::instance() functions is to solve the infamous "Static Initialization Order Fiasco": When having global objects in different translation units, their order of initialization is undefined. Thus, when these objects access each other one cannot guarantee the correct order of initialization. The X::instance() functions generate the objects on first use. DivePlannerPointsModel has such an instance() function. However, for convenience(?) in diveplanner.cpp we find the global variable static DivePlannerPointsModel* plannerModel = DivePlannerPointsModel::instance(); Thus, the DivePlannerPointsModel constructor is run before main(), negating the whole purpose of the instance() function. Let's remove this line to avoid hard-to-debug startup issues. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06Dive site: don't save invalid GPS coordinatesGravatar Berthold Stoeger
On the dive site screen, when entering invalid GPS coordinates, we cleared the location of the dive site. Don't do this. To clear the location, the user now has to enter the empty string. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06Dive site: give visual clue for invalid coordinatesGravatar Berthold Stoeger
On the dive site edit screen, when the user enters invalid coordinates and saves, we treat this as "no location". This is rather unfriendly, therefore warn the user with a visual clue. This is performed by setting the background color of the widget to red. 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>
2020-02-04Dive sites: select each dive site only onceGravatar Berthold Stoeger
After selecting dives, the selected dive sites are collected. This was done using the selectionModel()->selection().indexes(), which is wrong, because it gives one index per row *and* column. Accordingly, every dive site was added numerous times to the array of dive sites to be selected. Change this to selectionModel()->selectedRows(), which gives one entry per row. Moreover, if multiple dives with the same site were selected, this site was also added to the array multiple times. Therefore, check the array before adding sites. Note that all this should not change the user experience in any way, it is only a code-hygiene thing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04Cleanup: rename plannerShared to PlannerSharedGravatar Berthold Stoeger
Usually, we use PascalCase (i.e. camelCase with a capital letter at the start) for class names. For consistency, let's do it here as well. 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-31Remove plannerShared::instance()Gravatar Berthold Stoeger
This class contains only static functions (i.e. it does not contain any state). There does not seem to be a reason to have an instance of that class. Therefore, remove the instance() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-25diveplanner: add surface_segment to plannersharedGravatar jan Iversen
Add surface_segment to plannerShared and then update desktop-widgets. Signed-off-by: jan Iversen <jan@casacondor.com> desktop-widgets: use plannerShared for surface_segment Change getter/setter for surface_segment to plannerShared, in order to share the conversion with mobile diveplanner Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25dive planner: correct bottomsac/decosac calc.Gravatar jan Iversen
Move conversion cuft <-> liter from desktop-widget/diveplanner.cpp to plannerShared, to facilitate the same results in mobile diveplanner Use Backend for bottomsac/decosac and update to check for switch LITER <-> CUFT Add bottomsac/decosac to QMLinterface. Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25mobile-widgets: correct error in connectGravatar jan Iversen
connect to set_o2narcotics missed an & but the compiler did not complain (which it usually does). Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25diveplanner: call planner model directly for simple variables.Gravatar jan Iversen
Variables without conversion, do not need to pass plannerShared (due to the QML interface). Simple variables do not pass plannerShared, but diveplanner in desktop-widgets and qmlinterface in mobile-widgets call the implementation directly. Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-24mobile: move dive planner notes access to pure interfaceGravatar jan Iversen
Make notes rates available to QML through the Backend interface. Remove the corresponding variables from plannerShared. Getters are from prefs. while setters are linked to diveplan model. Remark: signals from qPrefDivePlanner is used, because the diveplanner model sets qPrefDivePlanner but do not issue special signals. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>