summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.h
AgeCommit message (Collapse)Author
2020-05-07desktop: don't update models in MainWindow::refreshDisplay()Gravatar Berthold Stoeger
The models should now properly reset themselves if data in the core changes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04Planner: fold MainWindow::setupForAddAndPlan into createSimpleDive()Gravatar Berthold Stoeger
There was only one caller of MainWindow::setupForAddAndPlan() left and that caller immediately called DivePlannerPointsModel::createSimpleDive(). Thus, we might just as fold the former in the latter and thus concentrate all the prepare-dive-for-plan business in one place. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04planner: send plan in calculatedPlanNotesGravatar Berthold Stoeger
Thus, the MainWindow doesn't have to extract the plan from displayed_dive. This is a tiny step in an attempt to detangle the interfaces. The bigger goal will be to make displayed_dive local to the planner. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04planner: update variations in planner not mainwindowGravatar Berthold Stoeger
When calculating variations, they were sent to the mainwindow, which updated displayed_dive accordingly. Do this directly in the planner-model. The idea is to detangle interdependencies and to make the code reusable (planner on mobile?). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-19desktop: remove user surveyGravatar Dirk Hohndel
We have never made good use of the results. Let's just remove it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-07desktop: remove EDIT modeGravatar Berthold Stoeger
The only way to enter edit mode is to edit the profile. However, that means that the profile is already visible, so there is no need to change the mode. Simply remove the EDIT mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-07debug: try to capture changes that don't invalidate git cacheGravatar Dirk Hohndel
At least in those cases where we are sending a divesChanged signal we can easily check if the cache was properly invalidated. Of course this won't help in cases where we don't notify the dive list about changes, either. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-19Cleanup: remove MainWindow::recreateDiveList() functionGravatar Berthold Stoeger
The function had only one line and had only one caller. We might just as well fold that line into the caller. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19Filter: split out filter from modelGravatar Berthold Stoeger
Split out the actual filtering from the MultiFilterSortModel. Create a DiveFilter class that does the actual filtering. Currently, mobile and desktop have their own version of this class, though ultimately we may want to merge them. The idea here is that the trip-model and undo-commands have direct access to the filter-function and thus can take care of keeping track of the number of shown dives, etc. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16Cleanup: fold cleanUpEmpty() into closeCurrentFile()Gravatar Berthold Stoeger
The latter was the only caller of the former and there seems to be no clear separation between the two. By making a single function out of this the code is easier to follow and duplicate code can be more easily detected. Matter of fact, the profile was cleared twice. 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-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-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-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-04-14Desktop: destroy maintab before destructing mainwindowGravatar Berthold Stoeger
Apparently, in some Qt-versions the destructor of the base class calls hide on child-objects (according to Qt's object hierarchy). This is obviously called after the derived class has been destructed. In a concrete case, the base class of the destructed MainWindow would hide the TabDiveSite object. That would reset the filtering if a dive site was selected, which would indirectly access the MainWindow, which is already partially destroyed. Therefore, destroy the MainTab before destroying the MainWindow. Do this by keeping it as a std::unique_ptr subobject. Thus, it will be destroyed before the MainWindow and remove itself from Qt's object hierarchy. Reported-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: use QUndoStack::isClean() to determine unsaved changesGravatar Berthold Stoeger
Properly implement the unsaved-changes flag(s). Since we currently have two kinds of changes, there are two flags: 1) dive_list_changed in divelist.c marks non-undoable changes. This flag is only cleared on save or load. 2) QUndoStack::isClean() is used to determine the state of undoable changes. Every time the user returns to the state where they saved, this flag is cleared. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: remove unnecessary signalGravatar Berthold Stoeger
The edit dive site button was connected to a *signal* of MainWindow, which was connected to a slot of MainWindow. Remove the unnecessary intermediate signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add edit field to dive site tableGravatar Berthold Stoeger
Add an edit column that calls the new editDiveSite() function of MainWindow. The calling code is in DiveSiteSortedModel. Quite illogical, but that's how TableView works, for now. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-11Desktop: show filter panel with maximized dive listGravatar Dirk Hohndel
This way we can filter both in the default layout and in the dive list layout. Fixes #1951 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-01facebook: remove the featute from the code baseGravatar Lubomir I. Ivanov
Remove from: - unit tests - desktop widgets - preferences - core intergration - cmakefiles - build scripts - icons - docs Also remove the plugins and social network integration. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2019-01-26Cleanup: remove unused function setCheckedActionFilterTags()Gravatar Berthold Stoeger
Last caller was removed in e0f473fcb49c8121a0a9c52bf0536049b0f342ed Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19Desktop: Make filterWidget2 a subobject of MainWindowGravatar Berthold Stoeger
In commit b0556abdd35f96b816ba11e40bf5707abe0c3ebf, the filter-widget and the filter were connected by a direct function call. This led to a rather obscure crash on application-close with Qt 5.12. The crash is due to the Ui::MainWindow class being a sub-object of MainWindow, but the FilterWidget2 being *not* a subobject. What happens is that after calling the MainWindow destructor, the subobjects are destructed, notably the Ui class. Then the base-class destructor is called (which makes sense, as destructors are called in reverse order of constructors). But: the QObject destructor calls hide() on all still existing child-objects according to Qt's object hierarchy, notably the visible FilterWidget2. Now the FilterWidget2, on hiding, updates the MainWindow, which has already destructed all its subobjects. Crash. Prevent this crash by making FilterWidget2 a subobject of MainWindow and thus have it destructed before running the QObject destructor. Alternative ways would be: 1) Use signal/slot() instead of function calls, as these are automatically removed if an object is destroyed. 2) Make the FilterWidget2 subobject a smart-pointer. Thus, we probably wouldn't have to include the corresponding header. 3) Make the FilterWidget2 subobject a plain pointer and delete it explicitly in the constructor. Reported-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14Drop old filter codeGravatar Tomaz Canabrava
Drop tons of now-unused-code. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14Start the FilterDive stateGravatar Tomaz Canabrava
Register the new FilterDive widget on the mainwindow so we can trigger a shortcut to display it. The shortcut currently doesn't exists. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-10-14Desktop: Enable next/prev DCs only for applicable divesGravatar Jan Mulder
Does not solve any problem, but might help users that are confused about the next/prev DC menu items, to select a different profile for the currently selected dive. So, enable these menu items only for dives where more than one DC is used. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-13Cleanup: rename MainWindow member variablesGravatar Berthold Stoeger
Instead of the weirdly named "information" and the inconsistent "dive_list" use the logical "mainTab" and the camel-cased "diveList", respectively. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Cleanup: Turn widget accessor-functions into simple pointersGravatar Berthold Stoeger
The keeps track of different sub widgets needed by other parts of the code, notably: MainTab PlannerDetails PlannerSettingsWidget ProfileWidget2 DivePlannerWidget DiveListView Access to these widgets was provided with accessor functions. Now these functions were very weird: instead of simply returning pointers that were stored in the class, they accessed a data structure which describes the different application states. But this data structure was "duck-typed", so there was an implicit agreement at which position the pointers to the widgets were put inside. The widgets were then down-cast by the accessor functions. This might make sense if the individual widgets could for some reason be replaced by other widgets [dynamic plugins?], but even then it would be strange, as one would expect to get a pointer to some base class. Therefore, directly store the properly typed pointers to the widgets and simply remove the accessor functions. Why bother? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Dive site: explicitly init displayed_dive_site on show widgetGravatar Berthold Stoeger
The global object "displayed_dive_site" is used to store the old dive site data for the edit-dive-site widget. The fields of the widget were initialized from this object in the show event. Therefore the object was updated in numerous parts of the code to make sure that it was up-to-date. Instead, move the initialization of the object to the function that also initiatlizes the fields. Call this function explicitly before showing the widget. This makes the data-fow distinctly easier to understand. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Dive list view: replace signal-magic by flagGravatar Berthold Stoeger
In DiveListView, we have a very fundamental problem: When On the one hand, we get informed of user-selection in the DiveListView::selectionChanged() slot. This has to set the correct flags in the C-backend. On the other hand, sometimes we have to set the selection programatically, e.g. when selecting a trip. This is done by calling QItemSelectionModel::select(). But: this will *also* call into the above slot, in which we can't tell whether it was a user interaction or an internal call. This can lead to either infinite loops or very inefficient behavior, because the current dive is set numerous times. The current code is aware of that and disconnects the corresponding signal. This is scary, as these signals are set internally by the model and view. Replace this by a global "command executing" flag in DiveListNotifier. The flag is set using a "marker" class, which resets the flag once it goes out of scope (cf. RAII pattern). In DiveListView, only process a selection if the flag is not set. Otherwise simply call the QTreeView base class, to reflect the new selection in the UI. To have a common point for notifications of selection changes, add such a signal to DiveListNotifier. This signal will be used by the DiveListView as well as the Command-objects. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: disable undo- and redo-actions in edit modeGravatar Berthold Stoeger
We have to avoid that undo/redo removes the currently edited dive from under our feet. This code can be removed once proper undo/redo (including editing) is implemented. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: isolate undo-commandsGravatar Berthold Stoeger
This refactors the undo-commands (which are now only "commands"). - Move everything in namespace Command. This allows shortening of names without polluting the global namespace. Moreover, the prefix Command:: will immediately signal that the undo-machinery is invoked. This is more terse than UndoCommands::instance()->... - Remove the Undo in front of the class-names. Creating an "UndoX" object to do "X" is paradoxical. - Create a base class for all commands that defines the Qt-translation functions. Thus all translations end up in the "Command" context. - Add a workToBeDone() function, which signals whether this should be added to the UndoStack. Thus the caller doesn't have to check itself whether this any work will be done. Note: Qt5.9 introduces "setObsolete" which does the same. - Split into public and internal header files. In the public header file only export the function calls, thus hiding all implementation details from the caller. - Split in different translation units: One for the stubs, one for the base classes and one for groups of commands. Currently, there is only one class of commands: divelist-commands. - Move the undoStack from the MainWindow class into commands_base.cpp. If we want to implement MDI, this can easily be moved into an appropriate Document class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-04Import: import Poseidon MkVI logs via DiveLogImportDialogGravatar Berthold Stoeger
Poseidon MkVI logs (.txt) were special cased in MainWindow.cpp, which led to a user-interface inconsistency. In some cases [user chooses ".txt" (non-Poseidon) and ".csv"], *two* import-dialogs were shown. Move handling of Poseidon MkVI logs into DiveLogImportDialog. There are already other "special" cases handled in this dialog. At the moment, this shows the first 10 depth-values, which is kind of useless, as this will all be at surface level. We might think about something more useful. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-14Desktop: remove "edit dive" from log menuGravatar Jan Mulder
Nowadays, we edit dives just by starting to enter data for the dive. There is no need to explicitly ask to start editing the dive, using the now removed menu option. This was a left-over of a long past history. This is fallout from PR #1673. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-09Desktop: Remove webservice, remove UI components (2)Gravatar Jan Mulder
Actually remove the Subsurface webservice UI from the source, and deal with all the fallout. Notice that a part of the change in subsurfacewebservices.cpp is a block of code that becomes unused, but might contain some valid logic to be used later. Very similar code is in core/gpslocation.cpp. And as I earlier broke something here, the unused code is ifdef-ed for now. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-08-29Revert "desktop-widgets: remove QSettings from desktop-widgets"Gravatar Dirk Hohndel
This reverts commit 321a920a9873a3828a24c1b28cf8eb5fe1bff2cb. It appears that the load_xxx functions aren't called, so while the correct values are stored to the settings, they aren't retrieved. Let's revert while this gets fixed. Fixes #1609 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-25desktop-widgets: remove QSettings from desktop-widgetsGravatar jan Iversen
The variables referenced are moved into qPref in earlier commits so in general all QSettings calls are replaced by qPref*:: calls Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-31Cleanup: replace virtual by override where appropriateGravatar Berthold Stoeger
The keyword "virtual" signalizes that the function is virtual, i.e. the function of the derived class is called, even if the call is on the parent class. It is not necessary to repeat the "virtual" keyword in derived classes. To highlight derived virtual functions, the keyword "override" should be used instead. It results in a hard compile- error, if no function is overridden, thus avoiding subtle bugs. Replace "virtual" by "override" where appropriate. Moreover, replace Q_DECL_OVERRIDE by override, since we require reasonably recent compilers anyway. Likewise, replace /* reimp */ by "override" for consistency and compiler support. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-30Cleanup: Make WindowsTitleUpdate a global objectGravatar Berthold Stoeger
WindowsTitleUpdate is such a trivial object (a QObject with a single signal and no own state), that it's not really understandable why it would need all that "singleton" boiler-plate. Just make it a default constructed/destructed global object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-30Cleanup: remove parameter from currentDiveChanged signalGravatar Berthold Stoeger
The currentDiveChanged signal was emitted by the DiveListView to inform the MainWindow of a change of current dive. The new current dive was passed as a parameter. The slot in MainWindow then called select_dive() on the dive. This seems pointless because: 1) In both emits, selected_dive dive was passed as argument. But MainWindow can read this global variable itself. 2) Calling select_dive() again is a no-op, because obviously, this already *was* the selected dive. Moreover it seems conceptually wrong to set the current dive in the slot that is informed of the change of the current dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04Dive pictures: implement FindMovedImagesDialogGravatar Berthold Stoeger
Move the find-moved-images functions into a new translation unit and present the user with the identified matches before applying them. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-09Cleanup: make lastUsedDir() functions static and non-slot, respectivelyGravatar Berthold Stoeger
The lastUsedDir() functions of MainWindow and Smrtk2ssrfcWindow don't use any member-objects and are only used in their respective translation units. Therefore, remove them from the class and made of static linkage. The lastUsedImageDir() function was declared as a slog, which makes no sense. Make it a normal static function (though one might argue why it is assiociated with the DiveListView class in the first place). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-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-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-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-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-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>