aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2019-06-15Undo: add undo button to multi-dive-edited warning messageGravatar Berthold Stoeger
Simply connect the button the the undo-action and the hide-message action. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Undo: hide multi-dive-edit warning message on subsequent editGravatar Berthold Stoeger
When a different field is edited, hide any old multi-dive-edit warning message. The reason is that we might want to add an "undo" button to the message. But this will undo the wrong command if we don't hide the message. Sadly, this means that we can't use animated show / hide, because an animatedHide() followed immediately by an animatedShow() does not necessarily show the message. In other words, and animatedShow() does not interupt a started animatedHide()!? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Undo: only show warning message if dives were actually editedGravatar Berthold Stoeger
The multiple-dives-edited message was shown even if the value was not changed. Notably, when tab-flipping through the dive fields. Therefore, changed the execute_edit() function to return zero when no command was executed. For this, return a boolean from the execute() function indicating whether the command was really executed or trashed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Undo: show warning message if more than one dive editedGravatar Berthold Stoeger
On the MainTab, warn if more than one dive was edited. To this purpose, add a new KMessageWidget with an "OK" button that closes the message. Code is mostly a copy of the already existing "Editing dive" message. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Cleanup: remove MainTab::addMessageAction() functionGravatar Berthold Stoeger
This is a pointless one-liner function. Let's remove it. The message it shows will probably be moved to the profile in the not-so-distant future anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Cleanup: unify comments in desktop-widgets/command.hGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Undo: return number of changed dives from undo commandsGravatar Berthold Stoeger
To enable a "multiple dives edited" message, return the number of edited dives from dive edit undo commands. Since there are two kinds of these commands, viz. normal fields and tag fields, and the former use templates, create a common base class that can return the number of dives. Yes, the class hierarchy is getting scarily deep! At least, this gives a tiny bit of code-reuse. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Undo: don't create spurious undo commands for temperature fieldsGravatar Berthold Stoeger
When tabbing through the dive-info fields we get *EditingFinished signals. This would create undo commands. The undo commands should recognize if nothing changed. But for the temperature fields, owing to rounding, an unchanged text could actually represent a different value. This would lead to very confusing situations: 1) Edit air temperature 2) Press tab to finish editing 3) Focus goes to water temperature 4) Try to undo change in menu 5) When opening the menu water temperature loses focus 6) Water temperature is edited 7) Undo undos the water temperature, not the air temperature 8) Goto 4 Fortunately, QLineEdit fields have the isModified() member function that returns true if the field was changed by the user. Use this to prevent this case. This is not a general method, i.e. it has to applied to every field with that problem. But it is less intrusive than subclassing the QLineEdit class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Cleanup: remove silly typo in translation commentsGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-10Cleanup: remove Q_PROPERTYs from MinMaxWidgetGravatar Berthold Stoeger
This is not used from QML - no apparent need for this property cruft. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-10Cleanup: Un-PIMPL-ize MinMaxAvgWidgetGravatar Berthold Stoeger
The PIMPL idiom is used by some frameworks (notably Qt) to ensure binary compatibility. Objects consist only the general object header (ref-count, connections, children, etc..) plus a single pointer to private data. MinMaxAvgWidget was implemented using this idiom. This seems to make no sense, as we don't produce a general library with the need of a stable ABI. Let's remove this unnecessary indirection. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-07Desktop: invalidate dive cache on equipment editGravatar Berthold Stoeger
Owing to the recent undo-changes, the git id was not invalidated when accepting changes to cylinders and weights. Do this in the MODIFY_DIVES macro for now. Reported-by: Jan Iversen <jani@apache.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-07Desktop: don't show location-popup button in trip-edit modeGravatar Berthold Stoeger
The location fields are hidden in trip mode. Only the location-popup button was shown. Hide it as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-06Cleanup: remove unnecessary QRegularExpression copiesGravatar Berthold Stoeger
A regular expression was generated and then copied twice without apparent reason. Remove these copies. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-06Printing: use regexp in preprocessTemplate()Gravatar Berthold Stoeger
preprocessTemplate() replaces variables of the kind "dive.weight0" by "dive.weights.0". Replace the old code by regexps. This not only makes the code significantly shorter, it also makes it independent from the name of the dive variable (i.e. "dive"). Moreover, it removes a dependency on MAX_WEIGHTSYSTEMS and MAX_CYLINDERS, which might help in removing these restrictions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-03Reword configure dive computerGravatar Robert C. Helling
Some users understood "Configure dive computer" as the menu entry where you configure which dive computer to use. Reworded to make clear that this modifies the settings on the dive computer. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-05-29Check if dive_site exists before accessing its nameGravatar Robert C. Helling
... in copy dive to clipboad. Fixes #2109 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-05-20Undo: be smarter about dive computer shown after deletionGravatar Berthold Stoeger
When deleting a dive computer, don't just show the first dive computer, but the next one in the list (if it exists). Moreover, on undo jump to the previously shown dive computer. Do this by keeping track of the before and after dive computer number in the undo command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20Cleanup: rename clone_dive() to move_dive()Gravatar Berthold Stoeger
This function clones a dive and clear out the old dive. This corresponds to move semantics. Name the function accordingly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20Cleanup: fix a few comments and debug messagesGravatar Berthold Stoeger
This is just minor fixes that are not user-visible: Fix a few erroneous comments and a debug message. These are copy & paste mistakes and mistakes introduced during code- refactoring. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20Undo: make "delete dive computer" undoableGravatar Berthold Stoeger
Simply reuse the code for "move dive computer" by creating a DiveComputerBase base class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20Undo: make "move dive computer to front" undoableGravatar Berthold Stoeger
Instead of the elegant solution that just modifies the dive, keep two copies and add either the old or the new copy. This is primitive, but it trivially keeps the dives in the right order. The order might change on renumbering the dive computers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-17Undo: properly reference-count dive sitesGravatar Berthold Stoeger
Recently, the undo code was changed to consider dive sites. The undo code uses a DiveToAdd structure, which was extended by the dive site to which the dive should be added. The split and merge commands were not adapted and therefore the dive counts of the dive sites were wrong after split and merge. Fix this by properly setting the dive site field and removing the reference in the dive structure (in the split case, the merge case already cleared the reference). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-17Undo: sort list of dives to add and deleteGravatar Berthold Stoeger
In 5729f93e1f512aa9e68b0e01743152aaee2b7c12, the dive addition / deletion code was simplified in that indexes were calculated on the fly. This made it, in principle, possible to pass in dives in any order. But there was a small oversight: the recipients of the dives-added and dives-deleted signals expect the dives to be sorted as in the core list. Only then will the lists be consistent. Therefore, sort the lists before adding / deleting dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-17Implement height-to-pressure functions in plannerGravatar willemferguson
The units.h file has two functions to convert atm pressure to mbar and also to convert mbar to atm pressure. Implement these two functions in the planner. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-05-15Cleanup: small coding style fixesGravatar Dirk Hohndel
And addressing a cut and paste error in a comment. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-05-15Convert the atmospheric pressure in the Information Tab to an editable fieldGravatar willemferguson
The Information tab shows the atmospheric pressure. Make this value editable and also ensure that changes to it are undo-able. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-05-12Mainwindow: simplify application-state codeGravatar Berthold Stoeger
The way the application state would enable/disable widgets was very "dynamic". A property-list would be generated and put in a set of arrays. Very hard to figure out what is going on. Replace these property-list by flags and explicit old-fashioned boolean expressions. Join the two arrays (widget- and property-lists) into an array of a unified data structure. Replace the macro that sets the widgets by a simple static function. Factor out the four loops that added widgets to the quadrants into a simple static function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-12Turn application state into enumGravatar Berthold Stoeger
The application state was encoded in a QByteArray. Thus, there was no compile-time checking. Typos would lead to silent failures. Turn the application state into an enum. Use the enum-class construct, so that the values don't polute the global namespace. Moreover, this makes them strongly typed, i.e. they don't auto-convert to integers. A disadvantage is that the enums now have to be cast to int explicitly when used to index an array. Replace two hash-maps in MainWindow to arrays of fixed sizes. Move the application-state details into their own files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Dive site: Add button to display all dive sitesGravatar Berthold Stoeger
On the main dive tab, add a button that opens the dive-site selection widget showing all dive sites. This is done by setting the "temporary dive site name" to the empty string. Thus no dive sites are filtered and the "add new dive site" entries are not shown. Moreover, the text is selected. The user can therefore immediately start typing to activate the filter or enter the name of a new dive site. The idea is that after downloading dives with GPS information the user can select one of the close dive sites. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Cleanup: simplify DiveLocationLineEdit::showPopup()Gravatar Berthold Stoeger
DiveLocationLineEdit::showPopup() called the functions - fixPopupPosition() - proxy->invalidate() - proxy->sort(LocationInformationModel::NAME) - view->show() All these calls are redundant, as they are already performed by setTemporaryDiveSiteName(). Remove them. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Dive site: show distance to current dive using extra dataGravatar Berthold Stoeger
Currently, in the dive-site selection widget the distance to the dive site of the current dive is shown. Instead, use the recently introduced dive_get_gps_location() function. Thus, the actual GPS coordinates extracted by libdivecomputer are used. The function is only called when the current dive changes and the location is stored in the item delegate. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Dive site: sort by distance to current diveGravatar Berthold Stoeger
When presenting the list of dive sites on the dive-info tab, sort the dive sites by distance to the current dive. The idea is that when the user wants to select a dive site, close dive sites should be prioritized. The location of the dive is determined with the dive_get_gps_location() function introduced in the previous commit. This actual GPS data get precedence over the currently set dive site for that dive. On change of dive, the current location is updated in the DiveLocationFilterProxyModel so that a potentially expensive search for GPS data is not repeated for every comparison. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Dive site: create new dive site at location from GPS dataGravatar Berthold Stoeger
Some dive computers save GPS data. Currently, this is stored by libdivecomputer in an "extra field". When generating a new dive site for a dive try to use this data to place the dive site. To do so, create a "dive_get_gps_location()" function. This function can be extended later to use e.g. event. When creating a dive site, use the result of this function over a potential pre-existing dive site. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Map: automatically update names on the mapGravatar Berthold Stoeger
Currently, dive site names are only updated on full reload. Instead hook directly into the corresponding signal in the MapLocationModel to set the name. Also to the coordinates directly there instead of going via the MapWidgetHelper. In the MapWidgetHelper, just center on the changed dive site. Hook into the signal directly there and remove the slot from the MapWidget. This makes the whole call-chain at least one call shorter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Map: construct list of dive sites from dive site tableGravatar Berthold Stoeger
Instead of looping over the dive table and extract dive sites, loop over the dive site table. This makes it possible to show dive sites that have no dive associated with them. But we have to create to functions that check whether a dive site has any shown dives or has any selected dives. Moreover, change the code to add near dive sites of the same name if in edit mode. Other wise (erroneously added?) dive sites with the same name cannot be moved on the map. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Map: remove skipReload logic in mapwidget.cppGravatar Berthold Stoeger
There used to be a flag to avoid reloading of the map. Since this is not used anymore, remove it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Filter: add reference counting for dive-site modeGravatar Berthold Stoeger
The dive-site-edit and dive-site-table tabs both put the filter into a special dive-site mode. When switching between both, it could happen that the one got its show befor the other got its hide event. Thus, the first would start dive-site filtering and the second stop it. Now the app was not in filter mode even though it should. To solve this problem, add reference counting for the filter's dive-site mode. In both tabs call the enter/exit functions on show/hide. In the dive-site-table tab, when the selection changes, use a set function that doesn't modify the reference count. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Map: make edit mode depend on dive-site-filteringGravatar Berthold Stoeger
Since the dive-site-filter is active either on the dive-site-edit page or the dive-site-list page, use that as the flag for dive-site-edit mode. Moreover, when the filter is reset, the MapWidgetHelper::reloadMapLocations() function is called, so we can use that place to enter/exit edit mode. This makes it easier to keep everything consistent. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Selection: automatically unselect old selection in selectDives()Gravatar Berthold Stoeger
DiveListView::selectDives() would only select new dives but not clear the old selection. Thus, callers would have to clear the selection first. That would lead to two selection-changed signals. Move the unselectDives() call into DiveListView::selectDives(). The DiveListView has an internal flag to prevent double signals. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Map: remove MapWidget::centerOnSelectedDiveSiteGravatar Berthold Stoeger
This was only used locally and only a stub for calling MapWidgetHelper::centerOnSelectedDiveSite. Call the latter directly instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Map: reload on selection change directlyGravatar Berthold Stoeger
When changing the dive selection, we have to reload the map to show the correctly highlighted flags. Do this directly by hooking into the DiveListNotifier::divesChanged signal instead of indirectly via the MainTab. Moreover, on reload center on the highlighted dive sites. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Cleanup: remove MapWidgetHelper::m_selectedDiveIds memberGravatar Berthold Stoeger
This member variable was only used locally in functions. Accordingly, make it a function-local variable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Map: don't reload map when in edit modeGravatar Berthold Stoeger
During edit mode, we could get spurious reload() requests owing to tabs being hidden. This led to undefined behavior: In some cases entering dive site edit mode would show all dive sites, in some only the dive site of the currently edited dive. Therefore, refuse to reload the map while in edit mode. The corresponding flag already exists. Partially fixes #2076 Reported-by: Doug Junkins <junkins@foghead.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Map: don't call exitEditMode() in MapWidget::reload()Gravatar Berthold Stoeger
On reload of the map, the map exits edit mode. Sounds logical at first, but the whole map-mode code is very unpredictable. What happened was that when switching from the dive site table to dive site edit mode, the code would enter map edit mode first. Then, the dive site tab got its hide-signal, which would reset the filter. This would reload the map and thus exit mode. Hence the user can't drag the flag on the map. Partially fixes #2076 Reported-by: Doug Junkins <junkins@foghead.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11CSV Import: add heartrate supportGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2019-05-06Create DivesiteImportDialog to select sites to importGravatar Doug Junkins
Creates the dialog box to select which sites to import from the file selected in mainwindow.cpp. The DivesiteImportModel is created as a table to display and select which sites are to be imported. Once the sites are selected, the Command::importDiveSites command is called to add the sites to the core dive site table with undo/redo functions. Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-05-06Add "Import dive sites" menu to mainwindowGravatar Doug Junkins
Adds "Import->Import dive sites" menu to mainwindow.cpp and adds the on_actionImportDiveSites_triggered() method to prompt for the filename to import from. The files are parsed and then any dive and trip data is cleared before opening a dialog box to select which sites are to be imported. Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-05-06Add undo/redo commands for importing dive sitesGravatar Doug Junkins
ImportDiveSites adds the provided dive sites to the core dive site table and stores the source data so it can be undone. Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-05-05Desktop: fix crash on dive site tabGravatar Berthold Stoeger
An interesting crash: 1) On the dive site tab select a dive site such that only one trip is shown. 2) Unselect all dives. 3) Press CTRL-A while the dive list has focus. 4) This will select a trip. 5) In MainTab::updateDiveInfo() this will switch to the previous tab active when in trip mode. 6) This will reset the filter. 7) This will reset the currentTrip field which we just set. 8) Since we just set the currentTrip field, we don't expect it to change and reference a null pointer. To fix, don't switch tabs when on the dive site tab. This also improves user experience as there seems to be no reason to switch away from the dive site tab. Currently the index of the dive site tab is hard-coded - this should be changed! Fixes #2077 Reported-by: Doug Junkins <junkins@foghead.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>