aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2019-07-04Desktop: reduce minimum vertical sizeGravatar Dirk Hohndel
The Filter widget really needed to be scrollable as it is very tall. Fixes #2152 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-04Cleanup: remove DiveLocationLineEdit::currTypeGravatar Berthold Stoeger
Apparently this field was never used...? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-04Desktop: enable clearing of dive siteGravatar Berthold Stoeger
Clearing dive site did not work for two reasons: 1) We didn't get a signal when editing was finished. 2) When clearing the dive site, the "add new dive site" site was set. Thus, connect to the editingFinished signal and in DiveLocationLineEdit::currDiveSite() return a null pointer if the string is empty. This means that it is not possible to have a dive site with an empty string, but that shouldn't be a problem, right? Fixes #2148 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-04Cleanup: avoid spurious updateDiveInfo() callsGravatar Berthold Stoeger
In 2e230da3610dd1fc61badaf328a084512895fb90 the dive-selection signals were unified. Sadly, this was done in a suboptimal way resulting in numerous calls to updateDiveInfo(), which refreshes the main-tab. Firstly, the MainWindow connected to selection changes from both, the undo-command and the divelist. Secondly, every selected dive in the divelist caused a single signal. Thus, connect only to the divelist (this is necessary for user-initiated selection changes) and only send a single signal in the divelist per selection-reset. This is still less than perfect as updateDiveInfo() is called even if the current dive doesn't change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-28Dive merge: don't use unset dive numbersGravatar Berthold Stoeger
On merging, don't use the number of the first dive if it is 0. Use the first non-zero number. Fixes #2126 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-24Desktop: small optimizationGravatar Dirk Hohndel
This way we don't need to iteratively grow the QVector. Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24Desktop: update dive list when dive sites changeGravatar Dirk Hohndel
Now when we change dive site location or name through a redo, the dive list is updated as expected. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24Desktop: update flags on the map when dive sites changeGravatar Dirk Hohndel
Now when we change dive site location or name through a redo, the flags and associated name are always reflected correctly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24Cleanup: simple consistencyGravatar Dirk Hohndel
Same pattern as the other functions in this group. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24Desktop: fix time editingGravatar Dirk Hohndel
We were shifting in the wrong direction. Which caused the field to be marked as 'edited' again, which meant we shifted the wrong way and twice the distance. This seems to fix the problem for both date and time editing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-23Cleanup: unify selection signalsGravatar Berthold Stoeger
For historic reasons, there where three distinct signals concerning dive-selection from the undo-machinery: 1) divesSelected: sent newly selected dives 2) currentDiveChanged: sent if the current dive changed 3) selectionChanged: sent at the end of a command if either the selection or the current dive changed Since now the undo-commands do a full reset of the selection, merge these three signals into a single signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23Cleanup: remove selectionChanged logic from dive-list commandsGravatar Berthold Stoeger
Since all commands now fully reset the selection, there is no point in keeping track of whether the selection changed on addition or removal of dives. This can be done in the function that sets the selection. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23Undo: unify selection behavior in dive-list commandsGravatar Berthold Stoeger
Some commands tried to retain the current selection on undo/redo, others set the selection to the modified dives. The latter was introduced because it was easier in some cases, but it is probably more user-friendly because the user gets feedback on the change. Therefore, unify to always select the affected dives on undo()/redo(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23Undo: don't send signals batched by tripGravatar Berthold Stoeger
Since the default view is batched by trips, signals were sent trip-wise. This seemed like a good idea at first, but when more and more parts used these signals, it became a burden. Therefore push the batching to the part of the code where it is needed: the trip view. The divesAdded and divesDeleted are not yet converted, because these are combined with trip addition/deletion. This should also be detangled, but not now. Since the dive-lists were sorted in the processByTrip function, the dive-list model now does its own sorting. This will have to be audited. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23Desktop: use local variable instead of displayed_diveGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-23Desktop: don't use planner to manually add diveGravatar Dirk Hohndel
Instead of calling into the planner, simply create the dive computer information right there, using the existing helper function we have to create simple profiles. Fixes #2128 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-19Undo: sort dives by dive_less_than() in signalsGravatar Berthold Stoeger
In signals dives were sorted by date. This criterion is not be unique. Therefore sort by the dive_less_than() function of the core to avoid any inconsistencies between the Qt-models and the core data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19Cleanup: remove unnecessary get_gas_used() callGravatar Berthold Stoeger
The result was not used anywhere, so why bother? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19Cleanup: use quotation marks for non-system includesGravatar Berthold Stoeger
That's common practice, so lets do it that way. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19Cleanup: generate clear_*_table() functions by macroGravatar Berthold Stoeger
In analogy to the other table functions, generate these by a macro as well. 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-06-19Cleanup: move tag functions into own translation unitGravatar Berthold Stoeger
Make dive.h a bit slimmer. It's only a drop in the bucket - but at least when modifying tag functions not the *whole* application is rebuilt anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>