aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2019-07-27Desktop: fix index in weightsystems_equal()Gravatar Berthold Stoeger
The weightsystem_equal() function compares weightsystems of two dives to decide whether the "commit changes" message should be shown and to decide which dives are edited when changing multiple dives. Due to an index mixup the function returned wrong results for more than two weightsystems. Fix it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-19Undo: make editing of dive number undoableGravatar Berthold Stoeger
When pressing F2 in the dive list, the number can be edited. Make this action undoable by implementing a EditNumber command. This command is differs from the other undo commands, as not the currently selected dives are changed. This means that the EditCommand needs an alternative constructor taking a single dive. This constructor was implemented in the base class so that all edit commands can now be called with a single dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18Core: dynamically resize weight tableGravatar Berthold Stoeger
Replace the fixed-size weightsystem table by a dynamically relocated table. Reuse the table-macros used in other parts of the code. The table stores weightsystem entries, not pointers to weightsystems. Thus, ownership of the description string is taken when adding a weightsystem. An extra function adds a cloned weightsystem at the end of the table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18Cleanup: Remove unused function calls in main tabGravatar Berthold Stoeger
per_cylinder_mean_depth() and selected_dives_gas_parts() are used in the dive-information and statistics tab, respectively. Nevertheless, these functions are called on the main tab as well and the result is trashed. Therefore remove the calls. Must have been an artifact. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18Cleanup: remove includes from qthelper.hGravatar Berthold Stoeger
To reduce interdependencies, remove the dive.h and divelist.h includes in qthelper.h Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18Cleanup: move deco function declarations to deco.hGravatar Berthold Stoeger
Another tiny step in making dive.h smaller: move function declarations to deco.h if these functions are defined in deco.c and don't directly concern dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18Cleanup: remove includes from qt-models/models.hGravatar Berthold Stoeger
qt-models/models.h included dive.h and divelist.h. Remove these unnecessary includes, to reduce interdependencies. A drop in the bucket, for sure. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-13Fixed filter scrollarea not adjusting to parent heightGravatar Doug Junkins
Changed the Qt Layout for FilterWidget2 to "Lay Out on a Grid" to allow the scrollarea to adjust when the height of FilterWidget2 changes. Fixes issues #2174. Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-07-11Desktop: clear notes on empty diveGravatar Berthold Stoeger
If no dive is set, all fields except the note field were cleared. Also clear notes. Fixes #2172 Reported-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-11Preferences: warn if ffmpeg can't be loadedGravatar Berthold Stoeger
In the preferences widget warn the user when they enter a non-executable path to ffmpeg. Thus they don't have to start thumbnailing just to find out that the path is wrong. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-09Desktop: update BT selection when picking remembered dive computerGravatar Dirk Hohndel
When switching to a BT dive computer, the device selection dialog is opened, when switching away from BT, the device address is set. Fixes #2139 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>