aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
AgeCommit message (Collapse)Author
2018-05-31Desktop: Derive UserManual from QDialogGravatar Berthold Stoeger
In commit d21d42b69117aae04b68ecc9cc2139e034bde146 helpView was made a child-object of MainWindow, which is Qt's idiomatic way of having helpView deleted with MainWindow. As an unintended consequence, the helpView didn't show. The reason is that UserManual derives directly from QObject. In contrast, UserSurvey derives from QDialog and is correctly shown. Therefore also derive UserManual from QDialog. Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-26Cleanup: remove three instances of deleteLater() in mainwindow.cppGravatar Berthold Stoeger
deleteLater() can be dangerous. Remove where not necessary. Analysis: 1) `helpView` was a pointer which was initialized on demand. close() and deleteLater() were called on closure of the main window. Firstly, there's no point in calling deleteLater(), because no references to helpView are used later on. Secondly, the deletion (and closing) can be done automatically in the destructor, by passing `this` as parent object. 2) `survey`: pretty much the same situation. But here, `this` was already passed as parent object. 3) `progressDialog` is a global (not thread safe!) pointer. The object is deleted after use. There is no point in using deleteLater(), because the callers are not active after hideProgressBar(), which is the place were the deleteLater() call was found. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21desktop-widgets: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-17Dive pictures: Don't plot pictures twice when changing current diveGravatar Berthold Stoeger
In MainWindow::current_dive_changed() first plotDive() is called, which replots all the pictures by calling plotPictures(). This is pointess, because it plots the pictures of the previous dive. Then, updateDiveInfo() is called, which resets the dive pictures and automatically replots them. Thus, switching between dives both with hundreds of pictures is way slower than necessary. Switching the plotDive() and updateDiveInfo() calls doesn't work. The reason is not 100% clear, but it doesn't make sense to plot pictures of the new dive as long as the profile still shows the old dive anyway. As a quick-fix, add a flag to plotDive(), which tells the function to clear the pictures list instead of redrawing it. Ultimately, plotDive() should probably be split in two functions. One for the callers who update the pictures themselves and one for the others. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-14Cloud-storage: consistently don't save empty file on desktop versionGravatar Berthold Stoeger
Make the behavior consistent: Don't save an empty file to the cloud, neither on selection of "Save to cloud" nor on "Save". The latter was not the case. It was a bit hard to trigger: Open cloud, delete all dives, save. Fixes #1228 Reported-by: Jan Iversen <jani@apache.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-13Desktop: On dive edit from the dive list or map, switch to new stateGravatar Berthold Stoeger
If "Edit dive" is selected from the dive list or the map view, switch to a new mode, which shows the dive infos and the profile. After the edit, switch back to the previous state. Fixes #1213 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Desktop: Make "Edit dive" menu entry work for downloaded divesGravatar Berthold Stoeger
Confusingly, "Edit dive" did only work for planned / manually entered dives. Change this, but only start profile-editing for planned / manually entered dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-11Corrected file name "weigthsysteminfomodel" to "weightsysteminfomodel"Gravatar Oliver Schwaneberg
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-04-03Revert "GPS: use applyGpsLocation::applyLocations from core"Gravatar Dirk Hohndel
This reverts commit 70e0e80de5470216df939f994ffda0222560def0. This caused the GPS workflow to break for Linus. Let's revert for 4.7.8 and figure out how to do this cleanup correctly, later. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-19Profile heatmap/heartrate: Only enable max one of these at same timeGravatar Stefan Fuchs
Only allow to enable maximum one of both items tissue heatmap or heartrate in profile. This is done by always switching off the other one at the moment you turn on one of the two items (heatmap or heartrate). Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-14Cleanup: introduce copy_qstring() functionGravatar Berthold Stoeger
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common occurrences that they seem worthy of a short helper-function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14Cleanup: consistently use qPrintable()Gravatar Berthold Stoeger
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31Make report_error() reentrantGravatar Berthold Stoeger
Remove the global error buffer and pass the error string directly to the frontend. The frontend is then responsible for accumulating errors. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31Remove unnecessary check for MainWindow instanceGravatar Berthold Stoeger
The error-callback is installed in the MainWindow constructor. Therefore, in the error-callback the existence of the MainWindow instance is guaranteed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31Use queued connection to thread-safe MainWindow error handlingGravatar Berthold Stoeger
Up to now, errors produced by threads were not directly shown in the MainWindow. Code running in the GUI thread had to manually show the errors. This can be simplified by using Qt's queued connection as message passing facility. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-13Resize progress bar width to fit all textGravatar Robert C. Helling
At least on Mac with larger font sizes part of the label text of the git access progress bar is cut off (even though it should automatically resize). This patch adds explicit resize. Fixes #1041 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-11Use helper function empty_string() instead of manual checksGravatar Berthold Stoeger
For code consistency, substitute boolean expressions: s && *s -> !empty_string(s) s && s[0] -> !empty_string(s) !s || !*s -> empty_string(s) !s || !s[0] -> empty_string(s) Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11Introduce helper function empty_string()Gravatar Berthold Stoeger
There are ca. 50 constructs of the kind same_string(s, "") to test for empty or null strings. Replace them by the new helper function empty_string(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08Remove redundant setting of prefs.git_local_onlyGravatar Berthold Stoeger
In MainWindow::on_actionCloudOnline_triggered(), prefs.git_local_only was set twice in the case of going online. Remove the second, unnecessary, assignment. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08Move resetting of current file out of clear_dive_file_data()Gravatar Berthold Stoeger
This is the only case where C-code sets the current file. Remove this call for a better separation of C-backend and C++-frontend parts. There were four callers of clear_dive_file_data(). Two of them would call set_filename() anyway. For the remaining two add an explicit call to set_filename(). This commit fixes a bug introduced in commit b3901aa8f90499ee2a34efdddc2463105afc53f1: The cloud-online menu entry was still enabled after "closing" the cloud storage. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06Enable cloud-online menu entry only if connected to cloudGravatar Berthold Stoeger
Enable the menu item cloud-online only if the current file is the cloud storage. Since this has to be checked every time the current file is set, factor this out into the new MainWindow::setCurrentFile() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06Turn take-cloud-online menu action into checkboxGravatar Berthold Stoeger
Replace the "Take cloud storage online" menu entry by a "Cloud online" checkbox. After this change, the user can also force going offline. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06Sync cloud storage on take-cloud-onlineGravatar Berthold Stoeger
When taking the cloud online, actually sync with the online cloud storage. If there are no unsaved changes, do the same as "Open cloud storage". If there are unsaved changes, ask the user if they want to commit them (do the same as "Save to cloud storage") or if they want to sync manually. If syncing failed, inform the user. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06GPS: use applyGpsLocation::applyLocations from coreGravatar Jan Mulder
Fixes a big duplication of code. The code to apply GPS locations from the location service was already in core, and used from mobile, but there was an almost literal copy in the desktop code. See also commits 6f42ab46da1b59 and ee9531f76ec31a, where only one side of the duplicated code was fixed. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-04Replace BEHAVIOR macro by initializer listsGravatar Berthold Stoeger
The macro BEHAVIOR expanded to "QList<int>()". This was used to generate temporary QList<int>s with constructs such as BEHAVIOR << COLLAPSED << EXPANDED Instead, simply use initializer lists such as {COLLAPSED, EXPANDED} Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04Replace macro TOGGLE_COLLAPSABLE by function toggleCollapsible()Gravatar Berthold Stoeger
There was no reason to do this in a macro. Let the compiler decide if it wants to inline or not. Note that for consistency with the Qt functions, collapsAble was replaced by collabsIble. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04Use set_autogroup() functionGravatar Berthold Stoeger
Since this function exists, use it instead of setting the global variable directly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-02Desktop: follow autogroup setting in UIGravatar Jan Mulder
When importing a dive (using import from logfile) and it is a ssrf/xml file that contains the autogroup setting, the autogroup is effectuated in the dive list. Not sure that I like this behavior, but thats the way it currently is. Simply wrong is that in this case the menu item toggle is not adapted so we end up with a dive list that is autogrouped, but the menu toggle is off. This can be solved by setting the UI toggle in a more central location. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29Desktop: Don't hide errors on opening cloud storageGravatar Berthold Stoeger
In MainWindow::on_actionCloudstorageopen_triggered(), getNotificationWidget()->hideNotification() was called, thus hiding any error message produced by the cloud code. Notably, the information "Cannot sync with cloud server, working with offline copy" was not shown. Therefore, remove this call. Note that on cloud save messages were not hidden. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-11Simplify mainwindow title logic: remove MainWindowTitleFormat enumGravatar Berthold Stoeger
The MainWindow::setTitle() function was passed an enum, which depended on whether existing_file is set or not. The check can be (and was!) done directly in setTitle(). Therefore, remove the whole enum. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-12Remove unused variable in on_actionCloudstorageopen_triggered()Gravatar Berthold Stoeger
This was an artifact of commit 136110784ebe2a188ca867bea3a7ff3037281a57 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-11Remove second parameter (bool force) in set_filename()Gravatar Berthold Stoeger
The last force=false case was removed in commit 96d1cc570e31396039e4970d2bf75d5f00f1e550. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-04Use QDir::exists() instead of QDir::setCurrent() to check for existenceGravatar Berthold Stoeger
Don't change into a directory just to see if it exists. Remove unnecessary braces of one of the changed if statements. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-01On failed cloud save hide progress barGravatar Berthold Stoeger
The progressbar was not hidden on failed save to cloud. In return remove an unnecessary variable on loading from cloud. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-01Actually compute variations in backgroundGravatar Robert C. Helling
This reenables the computation of plan variations but now in a separate thread. Once finieshed, a signal is sent to update the notes. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-30Use icons relative path.Gravatar Martin Měřinský
Icon paths are defined in one place only - application's embedded resources. Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-12-01Fix views in mainwindowGravatar Stefan Fuchs
Divelist only view was broken. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01Don't use action tooltip to access recently used fileGravatar Berthold Stoeger
Currently, the path to the recently used file is stored in the tooltip of the corresponding recent file action. Instead, store the number of the recent file in the action. This allows for more flexibility concerning formating of the tooltips (think git repositories, etc.). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-01Dynamically generate recent files actionsGravatar Berthold Stoeger
Instead of using four recent files actions defined in mainwindow.ui, generate these actions dynamically depending on the macro NUM_RECENT_FILES. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-30Remove "#if !defined(SUBSURFACE_MOBILE)" in mainwindow.cppGravatar Berthold Stoeger
The file mainwindow.cpp is only compiled for desktop versions, so the condition is redundant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-30Move creation of QSession object into MainWindow::checkSurvey()Gravatar Berthold Stoeger
Instead of handing the QSession object down, simply create it in MainWindow::checkSurvey() Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-30implify recent file handling in mainwindow.cppGravatar Berthold Stoeger
The old code used to be unnecessarily complex: the recent files list was extended for each file and shrunk if a load failed. By adding a file to the recent file list only if the load succeeded, a whole method could be removed. Other changes: keep track of the recent files using a QStringList and clearly separate the actions: - Read recent files from settings [loadRecentFiles()] - Write recent files to settings [updateRecentFiles()] - Update the recent files actions in the menu [updateRecentFilesMenu()] - Add a file to the list of recent files [addRecentFile()] With this reorganization the code hopefully became more clear. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-29Revert "Use icons relative path."Gravatar Dirk Hohndel
This reverts commit b0d98f6e269be9560de1b9c140855c85fecf1dd1.
2017-11-29Use icons relative path.Gravatar Martin Měřinský
Icon paths are defined in one place only - application's embedded resources. Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-27When replanning logged dive call CylindersModel->updateDiveGravatar Stefan Fuchs
reset_cylinder may transform unused cylinders into zombie cylinders inside the planner because it adds a depth info and therefore the planner will use them. By calling CylindersModel->updateDive these cylinders will become visible and can be deleted by the user. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-26Simplify signal handling after dive site editingGravatar Berthold Stoeger
Since commit 01d961086c1d175732c597dc9acdba7cc4cd2d26, MainWindow::refreshDisplay() is called in the refreshDiveInfo() signal of maintab after editing a dive site. Since this was the only use of the refreshDiveInfo signal, remove this signal and instead connect to MainWindow::refreshDisplay directly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25Merge branch 'print' of https://github.com/neolit123/subsurfaceGravatar Dirk Hohndel
2017-11-25Update filters on refreshDisplay and remember old selecttionsGravatar Berthold Stoeger
Update the filters if the list of dives is updated by calling MultiFilterSortModel::instance()->myInvalidate(); This had the side effect of clearing all selections. Thus, in the repopulate() methods of the FilterModels, check those entries that were checked previously. Since all the filter models use the same code, introduce a base class FilterModelBase. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-24printing: update the coping of bundled templatesGravatar Lubomir I. Ivanov
This update includes: - Instead of copyPath() use a new specialized function: copy_bundled_templates() - The new function supports overwriting of templates in the user path, but only if a template file is read-only - If the file is RW create a backup of the file in the form of: <file-name>-User.html - Collect backup files and store them in a QStringList which is then shown in a QMessageBox from MainWindow to notifying the user about the backup This change allows moving the maintenance of the bundled templates back to the application developers and contributors as currently the only one who can edit the templates in the user path was the user. Suggested-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>