summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2019-10-02Import: extract number of dives from model not from threadGravatar Berthold Stoeger
The plan is to make the model the authoritative source of the imported dives. Therefore, access the number of downloaded dives from there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-02Import: clear table via model not via threadGravatar Berthold Stoeger
Clearing the table in the thread leaves the model in an inconsistent state. Don't do that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-02Import: get tables from DiveImportedModel not DownloadThreadGravatar Berthold Stoeger
When importing dives, consume the tables from DiveImportedModel and not the DownloadThread. This appears more logical and avoids an inconsistent state of the DiveImportedModel: On import the tables would be reset, but the DiveImportedModel wasn't informed of that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-02Documentation: add comment to Command::importDivesGravatar Berthold Stoeger
Add a comment that the passed-in dives are consumed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-02Desktop: Use DiveImportedModel::deleteDeselected()Gravatar Berthold Stoeger
In DownloadFromDCWidget::on_ok_clicked() deselected dives were directly deleted from the dive table, leaving DiveImportedModel in an inconsistent state. Use the function in DiveImportedModel instead. This also removes code duplication. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-02Import: Make DownloadThread a subobject of DiveImportedModelGravatar Berthold Stoeger
Currently, desktop and mobile are accessing the DownloadThread and the DiveImportedModel concurrently. This makes a big data flow mess. To achieve a more hierarchical data flow, start by making the DownloadThread a subobject of DiveImportedModel. Start the download by calling a function in DiveImportedModel. Route the finished signal through DiveImportedModel. Thus, the model can reload itself with the new data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-27Revert the singleton PRGravatar Dirk Hohndel
It turns out that this isn't working the way it was intended to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-25Cleanup: unify idiosyncratic singletonsGravatar Berthold Stoeger
The way we handle singletons in QML, QML insists on allocating the objects. This leads to a very idiosyncratic way of handling singletons: The global instance pointer is set in the constructor. Unify all these by implementing a "SillySingleton" template. All of the weird singleton-classes can derive from this template and don't have to bother with reimplementing the instance() function with all the safety-checks, etc. This serves firstly as documentation but also improves debugging as we will now see wanted and unwanted creation and destruction of these weird singletons. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-21If only one dive selected, only one temperature in stats tabGravatar Fabio Rueda
In stats tab, when only one dive is selected, on one stat, only average is shown, except temperature which 3 same temps for max, min and avg are shown. [Dirk Hohndel: fixed whitespace] Signed-off-by: Fabio Rueda <avances123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21Export: special case dive site mode when exporting dive sitesGravatar Berthold Stoeger
In dive site mode, export selected dive sites, not dive sites of selected dives. Fixes #2275. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-21Cleanup: return each dive site only once in selectedDiveSites()Gravatar Berthold Stoeger
In TabDiveSite::selectedDiveSites(), the QItemSelectionModel:: selectedIndexes() function was used. Thus for every selected dive site 8 entries were added to the return-vector! Instead, use the QItemSelectionModel::selectedRows() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-21Export: move dive site selection logic to C++Gravatar Berthold Stoeger
When exporting dive sites, the dive sites to be selected were collected in the C-core. But that doesn't have access to the selected dive sites if in dive site mode. Therefore, collect the dive sites in C++ and pass down to the core. Use a std::vector to avoid memory management woes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-15if only one dive, max depth show in average fieldGravatar Fabio Rueda
Signed-off-by: Fabio Rueda <avances123@gmail.com>
2019-09-14Grantlee: split out grantlee-only property from DiveObjectHelperGravatar Berthold Stoeger
The cylindersObject list was only used by grantlee but not by the mobile code. Since it is quite heavy, split it out and thus don't generate it for every dive on mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: transform DiveObjectHelper into value-typeGravatar Berthold Stoeger
Instead of handing a reference-to-dive to QML, prerender all the needed properties and store them as values in DiveObjectHelper. Exception: - date(): generated from timestamp - time(): generated from timestamp - cylinderList(): does not depend on dive anyway and should be made static. This hopefully avoids the random mobile crashes that we are seeing. Clearly, this code needs to be optimized, but it is a start. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14DiveObjectHelper: Turn DiveObjectHelper into Q_GADGET based objectGravatar Berthold Stoeger
DiveObjectHelper is a tiny wrapper around dive * to allow access to dive data from QML and grantlee. It doesn't have to be a full-fledged QObject with support for signals, etc. Therefore, turn it into a Q_GADGET based object. This allows us passing the object around as object, not as pointer to DiveObjectHelper. This makes memory-management distinctly easier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-11Add the ability to export print template as htmlGravatar Anton Lundin
This way we can view the html generated from a print template, for debugging, validation or printing via your favorite browser. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2019-09-11Show correct notes entry when switching on stopsGravatar Robert C. Helling
When gas switching only on stops is selected, the notes showed an extra line at the not realized stop depth. This eliminates it. It also makes sure there are no 0 second spurious entries. And gas switching takes more than zero time (otherwise we would have to print a line of zero duration for at the gas switch depth). Reported-by: tormento <turment@gmail.com> Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-09-10Plan: introduce function that returns disclaimerGravatar Berthold Stoeger
The setting of the disclaimer variable was removed inadvertently some time ago, which removed the disclaimer from the printed plan. Instead, introduce a function that returns the disclaimer with the current deco mode. Use that function to generate the dive notes and for printing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-07Dive site: close dive site edit widget when dive site is deletedGravatar Berthold Stoeger
The application could be crashed by 1) Create dive site 2) Edit dive site 3) Undo until dive site is removed 4) Continue editing now non-existing dive site Therefore, hook into the dive-site-deleted signal and if the currently edited dive site is deleted, close the widget. When closing the widget, make sure that the potentially dangling pointer is reset to zero so that there is no other potential use-after-free bug. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Cleanup: remove unused MapWidget::repopulateLabels() functionGravatar Berthold Stoeger
There is the alternative MapWidget::reload() function, which centers on the selected dive-site. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Map: remove MapWidget::repopulateLabels() callGravatar Berthold Stoeger
For historic reasons MapWidget::repopulateLabels() was called in LocationInformationWidget::acceptChanges(). This should not be necessary anymore, as this is done when entering/exiting dive-site-mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Map: remove unnecessary MapLocationModel::repopulateLabels() callsGravatar Berthold Stoeger
The LocationInformationWidget repopulated the map labels if the name or location of a site changed. This is unnecessary because the MapLocationModel catches these signals itself. Remove these calls. As an added bonus, calling repopulateLabels() in QML context leads to crashes later on. Therefore this should fix at least one crash condition when dragging a flag on the map while the dive-site-edit-tab is shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Dive site: don't emit divesChanged signals when editing dive siteGravatar Berthold Stoeger
When editing the dive site, for certain fields a divesChanged signal was emitted so that the dive-list can be updated. Arguably it is wrong to decide which fields are relevant to the dive list in the undo-command code. Therefore, let the list catch the dive-site-edited signal and decide itself. But the actual reason for this commit is that if the dive-site field of a dive changes, we might have to reload the dive-location-model because suddenly a new dive site appears. Now if this is done in QML context on some Qt version (notably 5.9) we get crashes later on. But that can happen if the user moves a flag. So in that case only send a diveSiteChanged signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Map: highlight correct dive sites in dive site modeGravatar Berthold Stoeger
Since changing the highlighting to use the selected dive, dive sites with no dive were never highlighted in dive site mode. Obviously, because there was no dive to be selected. Therefore special-case all dive-site selection code to recognize when we are in dive site mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Cleanup: remove TabDiveSite::updateFilter() functionGravatar Berthold Stoeger
This one-liner was called in only one place from the same class. Just fold it into the caller. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Selection: properly update selection flag of map locationGravatar Berthold Stoeger
Owing to the recent changes, when the selection flag in the MapLocationModel was not updated correctly when the user manually selected the dive. Do that before raising the divesSelected signal in DiveListView::selectionChanged() because that will cause the MainWindow to repaint the flags. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Desktop: show all selected dive sites on clickGravatar Berthold Stoeger
When clicking a dive site on the map, the QML code would set the selected dive site, but then all dives of dive sites in the vicinity were set. But still only the clicked-on dive site was shown. Therefore, don't set the list of selected dive sites in QML, but later in DiveListView::selectDives(), where we know all the dives that were selected. This, again, gives nasty entanglement of diverse widgets and models. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Map: don't fully reset model on selection changeGravatar Berthold Stoeger
When changing the selection the MapLocationModel was reset. This lead to crashes on Qt-5.9 which are due to QML accessing data that was freed during model reset. This putative Qt bug doesn't happen on newer Qt versions. At least Qt-5.12 is known to work. Instead of fighting the bug, let's simply not reset the model but send a dataChanged() for every element of the MapLocationModel. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Desktop: reload map after refreshing the listGravatar Berthold Stoeger
In MainWindow::refreshDisplay() with doRecreateDiveList=true the map was reset before the dive list was recreated. This makes no sense and only worked because the map was reloaded again when a dive in the list was selected. Reload the map after recreating the dive list. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06Map: generate pixmap name in modelGravatar Berthold Stoeger
Experimentation has shown that the image of a flag will only be changed after dataChanged() if it is a simple property. The old code had a complex QML expression and then - for some reason - it didn't work. To give us better control over the flags and avoid full reloads of the map therefore introduce a model-property pixmap name. The name depends on whether the site is selected and if not, whether we are in divesite-edit mode. This makes the code rather convoluted. Firstly, we have to save whether the site is selected in the map-item. Secondly we have to access the global map-widget, which in turn has to go to the map-widget helper (layering violation!). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-30Desktop: improve recognition of HTML-notesGravatar Berthold Stoeger
To recognize HTML-notes the text was scanned for <div> tags. But apparently the planner notes do not feature such a thing. Therefore extend recognition of HTML to <table> tags. Note we can't use the <html> or <span> tags, because these are *always* produced by the QTextEdit::toHtml() function. Fixes #2265 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-29 Fix broken windows build with latest MXEGravatar Paul Buxton
Replaces some enums with names that do not clash with windows #defines. Specifically: ERROR -> ERRORED, PASCAL->PASCALS, IGNORE->IGNORED,FLOAT->FLOATVAL Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
2019-08-24Desktop: fix crash on copy & pasteGravatar Berthold Stoeger
The constructor of PasteState was clearing an uninitialized weightsystem-table. Very silly. Initialize it instead. Fixes #2253 Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22Cleanup: turn CylinderObjectHelper into value typeGravatar Berthold Stoeger
CylinderObjectHelper is used for structured formatting of cylinder values in grantlee types. Instead of keeping a reference to a cylinder, turn it into a value type containing the formatted strings. This should be distinctly safer, as we don't risk having stale references flying around. Moreover, we don't have to use pointers but can use containers containing plain CylinderObjectHelper. Thus, no explicit memory management is needed, making the code distinctly easier to understand. Sadly, currently grantlee does not support Q_GADGET based Q_PROPERTY. Therefore a GRANTLEE_*_LOOKUP block has to be added. This can be removed in due course, as a patch to remedy this issue is in current grantlee master. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-18Desktop: show local git repos in recent filesGravatar Dirk Hohndel
But don't show our cloud storage entry (as that is already in the File menu, anyway). This is extremely useful because while you can manually enter a file name to save to (and therefore can use the 'magic' git repo syntax), on most OSs there is no way to enter that non-existing 'file name' (which is the git branch in square brackets) in the file open dialog. Fixes: #2236 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-08Cleanup: move file-related function declarations to file.hGravatar Berthold Stoeger
A number of architecture-dependent functions were declared in dive.h. Move them to file.h so that not all file-manipulating translation units have to include dive.h. This is a small step in avoiding mass-recompilation on every change to dive.h Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: move error reporting function declarations to errorhelper.hGravatar Berthold Stoeger
Move the declarations of the "report_error()" and "set_error_cb()" functions and the "verbose" variable to errorhelper.h. Thus, error-reporting translation units don't have to import the big dive.h header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Move the Suit text box from the Notes tab to the Equipment tabGravatar willemferguson
Sqash latest commit with previous one. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-08-08Desktop: display trip time on main-tabGravatar Berthold Stoeger
On the main tab, the trip time was not shown when switching to a trip. Implement showing of the trip date in a function, as the undo-code will also have to update the trip date in certain circumstances. Fixes #2207 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-29Desktop: correct tooltip for filter close buttonGravatar Dirk Hohndel
This button only closes the filter panel but doesn't clear it. Reported-by: Adric Norris <landstander668@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>