summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-04-07profile: use lambda for addDivemodeSwitch callsGravatar Berthold Stoeger
The data was transported via the action in a most complicated way: The text was backtranslated. Simply use a lambda - perhaps hard to read, but much simpler to follow and less brittle. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: use SAMPLE_EVENT_BOOKMARK in add_event() callsGravatar Berthold Stoeger
In two cases we were passing the magic value 8 instead of the symbolic SAMPLE_EVENT_BOOKMARK. Use the symbolic version instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove DIVE EditMode in MainTabGravatar Berthold Stoeger
That mode is not used anymore, since only the editing of profiles of manually added dives enters editing mode. For that case we have the MANUALLY_ADDED_DIVE edit mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove parameter to MainTab::enableEditionGravatar Berthold Stoeger
All remaining callers were passing MANUALLY_ADDED_DIVE as a new mode, so we may just as well remove the parameter and thus simplify the logic. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07desktop: remove EDIT modeGravatar Berthold Stoeger
The only way to enter edit mode is to edit the profile. However, that means that the profile is already visible, so there is no need to change the mode. Simply remove the EDIT mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07desktop: move undo-disabling from enterEditState to disableShortcutsGravatar Berthold Stoeger
When entering the edit state, we don't want the user to be able to undo/redo lest things become inconsistent. Since the only way to enter edit state is to edit the profile, we can simply use the disableShortcuts() function that is used by the profile when it goes into edit state. This has one desirable side-effect: Undo is now also disabled in the planner. Undo during planning likewise can lead to inconsistent state. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: update profile on cylinder editingGravatar Berthold Stoeger
In the profile, catch cylinder-editing signals and redraw the profile if the currently displayed dive has changed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07CylindersModel: use flag to decide whether we are in plannerGravatar Berthold Stoeger
On desktop, we have two CylindersModel concurrently: One in the planner and one on the equipment-tab. They act differently, because the former modifies displayed_dive directly, the latter issues undo commands. To differentiate, we used the in_planner() function. However, that appears extremely brittle, especially when combined with undo-commands. Therefore when generating the model, pass in a parameter that says whether this is for the planner or the equipment tab and use that flag to decide how to act. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo/cylinder: call undo command to edit cylinder fieldsGravatar Berthold Stoeger
Call an undo command when editing cylinders, but only if on the EquipmentTab. To keep code changes small, make a copy of the cylinder first, then edit the cylinder as before and then either call an undo command (EquipmentTab) or overwrite the old cylinder (Planner). The memory management here is a bit strange: Since the undo-command itself makes a deep-copy of the passed in cylinder, we only do a shallow copy. If we have to change the type, we allocate the string with an std::string, so that the memory is automatically freed at the end of the function. However, this means that in the planner we have to make a deep copy first, swap old and new cylinder and finally release the old cylinder. Certainly not ideal, but for now the pragmatic thing to do. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo/cylinders: Implement editing of the typeGravatar Berthold Stoeger
This one is tricky, as when browsing through the types-combobox, the user is presented with presets without actually changing the dive. We do not want an undo-command for every change-event in the combo-box. Therefore, implement a scheme analoguous to the weight-editing: A temporary row can be set / committed or reset. Sadly, the code is more complex because we have to consider the planner, which is not included in the undo system. Firstly, the planner uses a different model, therefore all interactions are channeled through setData() with special roles. Secondly, in the planner we shouldn't place an undo command, but simply overwrite the dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove default-code for editCurrentDiveGravatar Berthold Stoeger
The profile can only be edited for manually added or planned dives. No point in keeping code for other kinds of dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07desktop: don't disable tabs in edit stateGravatar Berthold Stoeger
The edit state is now only used to edit the profile. There is no reason to disable random tabs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: don't center map on rejecting editGravatar Berthold Stoeger
The editing of the dive site is controlled via an undo command. No point in centering the map when cancelling a profile-edit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove lastMode variable in MainTab::rejectChanges()Gravatar Berthold Stoeger
This stored the old editMode. However, it was not read after editMode was changed, so there is no point to it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07edit: remove multi-dive version of edit informationGravatar Berthold Stoeger
The "dive is currently" edited is only shown when the profile is edited. This affects only the current dive and therefore a message saying that multiple dives are edited makes no sense. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove strange recursive code in MainTab::enableEditionGravatar Berthold Stoeger
When enableEdition() was called with mode == NONE and the dive was a manually added dive, it would call into MainWindow:: editCurrentDive(), which would in turn call enableEdition(), however with another mode. Since the only caller of enableEdition() is now editCurrentDive() anyway, we can remove that weird code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove cylinders_equal check in MainTab::rejectChanges()Gravatar Berthold Stoeger
This check make no more sense since cylinder editing is now treated by undo commands. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove unused CylindersModelFiltered functionsGravatar Berthold Stoeger
add() and remove() are not used anymore since this is done using undo commands. The planner uses CylindersModel instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: add cylinders via undoGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07CylindersModel: fold CHANGED() macro into setData()Gravatar Berthold Stoeger
The CHANGED macro was defined in the cleanerTableModel header. Since it had only one user, expand it there. The macro was very questionably anyway, as it would set the local "vString" variable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07CylindersModel: test for CHANGED() outside of switch statementGravatar Berthold Stoeger
A small code consolidation: With one exception, all targets of the switch statement would test for CHANGED(). Instead do the test once and exit early. This changes the behavior of the function: if not changed, there will be no more dataChanged-signal. However, this appears to be the correct thing to do anyway. And it is easily changed if it matters after all. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07CylindersModel: remove mark_dive_list_changedGravatar Berthold Stoeger
Cylinder-editing is controlled by undo (either by saving a planned dive or by using the equipment tab). There is no point in setting the dive_list_changed flag. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cylinders: remove CylindersModel::changedGravatar Berthold Stoeger
Nobody is testing that flag anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: remove TabDiveWidget::acceptChanges and rejectChangesGravatar Berthold Stoeger
Since cylinders are now edited using the undo system, these functions are not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07CylindersModel: listen and react to signalsGravatar Berthold Stoeger
React to signals from the undo-commands and update the model accordingly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07CylindersModel: don't test for planner-state in remove()Gravatar Berthold Stoeger
This is only called from the planner. Therefore, the test is redundant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: call removeCylinder undo command in equipment tabGravatar Berthold Stoeger
Instead of connecting to the remove() function of the model, call the removeCylinder undo command. Take care to translate the index into the source index, should cylinders be hidden! Apart from the map-to-source call, this copies the weightsystem code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: remove only "non-protected" cylindersGravatar Berthold Stoeger
The undo-code must take care not to remove used cylinders. To do so, extend the constructor of EditCylinderBase, which collects the cylinders and dives to edit, by the "nonProtectedOnly" boolean argument. If true, only those cylinders for wich "is_cylinder_prot" returns false will be added. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: reorder cylinders on remove-cylinder undo/redoGravatar Berthold Stoeger
The cylinders in the events must be reordered if we remove a cylinder. To avoid duplication of code, move the reordering function into qthelper.cpp, though it might not be ideal there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove CylindersModels::rowsGravatar Berthold Stoeger
Access the number of cylinders in the dive directly instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07CylinderModel: make dive dynamicGravatar Berthold Stoeger
The CylinderModel always accessed the global "displayed_dive" and in some special cases also "current_dive". To implement cylinder undo, the model should work on an arbitrary dive. Therefore, in analogy to the weight model, make the dive dynamic. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: add cylinder undo commands by copy & pasteGravatar Berthold Stoeger
Do a simple copy & paste followed by a simple search & replace to generate cylinder undo commands from weight undo commands. Obviously, this is still missing the necessary code to keep the dive-data consistent after cylinder editing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: move fill_default_cylinder from planner.c to equipment.cGravatar Berthold Stoeger
Moreover, move the declaration from dive.h to equipment.h. The result is a) more consistent and b) more logical. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: add create_new_cylinder() functionGravatar Berthold Stoeger
Turn the code in CylindersModel that creates a new cylinder for addition into its own function to avoid code duplication. This will be used from the undo commands. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: introduce set_cylinder() functionGravatar Berthold Stoeger
We have a set_weightsystem() function. For symmetry, introduce a set_cylinder() function so that we can more-or-less copy&paste the weightsystem undo code for cylinder undo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: make free_cylinder() globalGravatar Berthold Stoeger
The cylinder undo commands will keep a copy of a cylinder and therefore need the ability to free a cylinder object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: introduce clone_cylinder() functionGravatar Berthold Stoeger
We have a clone_weightsystem function. For symmetry, introduce a clone_cylinder() function so that we can more-or-less copy&paste the weightsystem undo code for cylinder undo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-06delegate: don't add WSInfo entry in delegateGravatar Berthold Stoeger
The weightsystem info for new weightsystem types is added by the undo command. Remove this redundant code. Use the lookup only to determine the weight and the canonical name (i.e. use the capitalization according to the saved entry, in analogy to tanks). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-06delegates: don't use starts-with search to fetch cylinder/weight dataGravatar Berthold Stoeger
In the wightsystem-type and cylinder-type delegates, when entering data, when entering known weight- or cylinder-types, some ui fields (notably weight, size and working-pressure) are automatically filled out. The search was using the default flags provided by Qt: starts-with and case-insensitive. This had a few strange effects, when entering a string that is the beginning of a known string (e.g. "AL6" when "AL63" already exists): 1) The wrong data was used if the new string didn't exist. 2) For cylinders it was impossible to create new cylinder types whose name is the starting string of a different type. 3) For weights, the new type was not added to the list of known types. This, however, is no problem, because it will be added by the undo command anyway. A future commit will address that redundancy. Therefore use only the case-insensitive flag (which has to be performed by passing the MatchFixedString flag - very weird). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/startup: fix potential crash when switching back and forthGravatar Dirk Hohndel
If the user switches away from Subsurface-mobile and back while we are in our initialization phase, that code might run more than once leading to undesirable results. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04CHANGELOG updateGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/cleanup: create helper function to hide verbose castsGravatar Dirk Hohndel
The strange enum casts (that apparently we needed in order to have strongly typed enums in QML) are really ugly and confusing in the code. Since we had this three times it seemed worth to create a little helper that hides this nonsense. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/cloud-storage: correctly transition from no-cloud to cloudGravatar Dirk Hohndel
We know that we have valid credentials, so calling openLocalThenRemote() makes no sense, worse, it doesn't respect the special case of transitioning between accounts. That's the whole point of having a separate loadDivesWithValidCredentials() call. Once we have transitioned state, we need to record the now current state as the old state so that future transitions will work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/cloud-storage: fix test for no cloud to cloud transitionGravatar Dirk Hohndel
The noCloud variable contains our desired state, we need to test for the previous state for this to make sense. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/cleanup: remove outdated comment and fix whitespaceGravatar Dirk Hohndel
We haven't supported the GPS web service for a long time. Also, add another message for the log to be able to more easily trace one error case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/undo: set undo stack as clean after saveGravatar Berthold Stoeger
If we're using the undo stack for determining the whether there are unsaved changes, we have to mark the undo stack as clean after save. This duplicates code from desktop. It is planned to unify this in the near future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04mobile/undo: consider undo-stack when checking for unsaved changesGravatar Berthold Stoeger
In analogy to desktop, also consider the state of the undo-stack when testing for unsaved changes. This prevents us from missing changes. This adds duplicate code, which will be unified in the near future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04mobile/edits: ensure changesNeedSaving is calledGravatar Dirk Hohndel
These appear to be the only cases where we forgot to ensure data is saved. And pastDiveData is currently not called as the UI to use it has been removed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile: when creating gps dive site use the new dive site nameGravatar Berthold Stoeger
The code was using the pre-editing dive site name, which appears weird. Not sure if that was on purpose. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04mobile: properly recognize changed dive siteGravatar Berthold Stoeger
QMLManager::checkLocation() would only return true if the dive-site itself was changed, not if the dive-site was set to a different site. Thus, in some cases edit events could be lost. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>