aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2020-11-07filter: don't render filter preset name as HTML textGravatar Berthold Stoeger
QLabels must be explicitly set to not accept HTML input. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07desktop: fix saving of column-widths of device and site tablesGravatar Berthold Stoeger
Qt's memory management scheme is completely broken and messes with common expectations. QObjects are organized as a tree. The children are destroyed in the destructor of QObject. This means that they are destructed after the destructor of the parent object has run and its sub-object were destructed. Obviously, this makes no sense as the child objects should be able to access their parent at any time. To restore the commonly expected deterministic order of construction and destruction, one might simply do away with Qt's silly object tree and organise things using classical subobjects. However, that breaks with the Qt-generated UI classes: The objects generated by these classes are *not* destructed with the UI class. Instead, they are attached to the widget's QObject tree. Thus these are again destructed *after* the widget! Who comes up with such a scheme? In our case this means that we cannot have models used for TableViews as subobjects, because the TableView needs the model to save the column widths in the destructor. Which, as detailed above is called *after* the desctructor of the widget! Thus, turn these models into heap-allocated objects and add them to the QObject tree. Funilly, this exposes another insanity of Qt's QObject tree: Children are destructed in order of construction! One would expect that if objects are constructed in the sequence A, B, C one can expect that C can, at any time, access B and A. Not so in Qt: The destruction order is likewise A, B, C! Thus, take care to init the widgets before the model. Jeez. Finally, print a warning in the column-saving code of TableWidget, so that these kind of subtleties are caught in the future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07desktop: rename table widget in DiveComputerTab to "devices"Gravatar Berthold Stoeger
The custom TableView widget saves the table width on destruction. For that, it uses the "objectName()". Since the table of the DiveComputerTab was simply called "table" in the UI file, the widths were saved in that generic section. To avoid future name-conflicts, rename the widget to "devices". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07desktop: maximize size of last column in filter-preset tableGravatar Berthold Stoeger
This was just ugly: the column with the "trash" symbol and the name had the same size. On creation of the object, make the last column expand and adapt the size of the "trash" column according to its content. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-04revert preference settings for title colorGravatar Dirk Hohndel
Because of subsequent changes there is no clean way to just revert the changes introduced in commit 8b36cf1051 ("desktop: offer different colors for info tab titles"), so this manually removes the parts we don't need anymore. This also restores a tooltip value that was inadvertantly removed in that commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-04desktop: automatically pick a good theme title colorGravatar Dirk Hohndel
The preference setting seemed far too strange to do this. And not very user friendly. So instead we figure out if this is a dark theme or not by looking at text and background colors in the palette, and make sure we get notified if that changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-04Reorganise the current statistics tabGravatar willemferguson
As the title above says.... Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-11-03desktop: generalize the colorization of the tab widgetGravatar Dirk Hohndel
Instead of doing it just for the Information tab, do it for all of the tabs. There's still room for improvement. But this certainly feels more consistent. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03desktop: allow update of tab widget colors at run timeGravatar Dirk Hohndel
Adding a new virtual function to all of these classes may seem like overkill, but of course the idea is that likely we'd allow similar changes to all of them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03desktop: offer different colors for info tab titlesGravatar willemferguson
Add a preference option to set the color of the text on the information tab to either MediumBlue, LightBlue or Black. The last two of these colors are meant to enable areadable font contrast on displays with dark mode. The choice is saved with the other preferences. [Dirk Hohndel: this isn't really about dark mode, so changed many of the types and variable names, changed the user visible texts, and addressed some whitespace issues] Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-29desktop: add label to dive computer tableGravatar Doug Junkins
There was no "title" property on the dive computer table which was causing an default label of "GroupBox" to appear above the table. Added a title property to clean up the UI. Signed-off-by: Doug Junkins <junkins@foghead.com>
2020-10-29desktop: use default colors for dive info labelsGravatar Doug Junkins
Removed the style change to force a style change for the labels on the dive information page to Medium Blue. This makes labels more readable in MacOSX dark mode since the default style changes colors when the mode is shifted from light to dark or vice versa. Signed-off-by: Doug Junkins <junkins@foghead.com>
2020-10-28cleanup: remove unnecessary includes from maintabGravatar Berthold Stoeger
These are artifacts from when the maintab contained more stuff. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-26desktop: move MinMaxAvgWidget to TabDiveStatisticsGravatar Berthold Stoeger
This is its only user and the widget is scheduled for removal. Let's move it there temporarilly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-26cleanup: remove dive.h include in simplewidgets.hGravatar Berthold Stoeger
Let's simply forward declare the needed structures. Also removes removes two more unnecessary includes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-26cleanup: fix deprecated QVector constructorGravatar Dirk Hohndel
Annoyingly, the replacement has only been available since Qt 5.14. To make the code less messy, implement our own stdToQt conversion helper. Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: remove reference to deprecated enum valueGravatar Dirk Hohndel
This had been deprecated for quite a while. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: don't initialize flags with just an integerGravatar Dirk Hohndel
This is slightly different from the previous cleanup around QFlag use as this one is related to QtWebKit flags. But the logic is the same. Just syntax to avoid a warning. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: replace deprecated signalGravatar Dirk Hohndel
Again, the replacement was only implemented in Qt 5.14, so more conditional code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: SkipEmptyParts syntax has changedGravatar Dirk Hohndel
Sadly, the new enum has only been available since Qt 5.14, so this is a rather ugly replacement. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: model isn't used in the lambdaGravatar Dirk Hohndel
Simply cleaning up a warning. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: remove obsolete connectionsGravatar Dirk Hohndel
Not sure how this even ended up in this .ui file. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: fix deprecated roleGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: replace deprecated use of child memberGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: fix deprecated form of QProcess::startGravatar Dirk Hohndel
You are now required to always provide a list of arguments. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: fix deprecated QFlags useGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-25filter: use 64-bit integer literal for generating bit fieldsGravatar Berthold Stoeger
For multiple-choice constraints we use a bit field of type uint64_t. This means we theoretically support up to 64 items. Currently use at most seven. Coverity complained (correctly) that we use the expression "1 << x" to generate the bitfields. However 1 is a 32-bit literal on most platforms, which makes this undefined behavior for x >= 32. Change the integer literal to 64-bit 1ULL. Moreover, when detecting items with an index >= 64, don't even attempt to set the according bit, since this is undefined behavior and the compiler is free to do as it pleases in such a case. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25cleanup: remove get_times() functionsGravatar Berthold Stoeger
The function 1) was misnamed: it determined the time of the first selcted dive. 2) had only one caller. 3) would crash if there was no selected dive. Let's just fold the functionality into the caller. It's a one-liner anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25cleanup: remove MainWindow::setFileClean()Gravatar Berthold Stoeger
This function was used to unify both methods of tracking unsaved changes. Since desktop now only uses the undo system, it can be replaced by a single call to "Command::setClean()". Arguably, the UI is the wrong place to do this and the appropriate calls should be done by the core. However, let's play it safe for now and avoid any breaking change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25cleanup: remove MainWindow::unsavedChanges() functionGravatar Berthold Stoeger
This function was used to unify both methods of checking for unsaved changes: the global unsaved_changes() flag and the Command::clean() function of the undo-system. However, all desktop functions are now undoable and therefore the function is not needed and can be replaced by calls to !Command::clean(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25desktop: remove DiveComputerManagementDialogGravatar Berthold Stoeger
This is now done in a TabWidget with undo-support. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25devices: connect DiveComputerModel to undo-commandGravatar Berthold Stoeger
Instead of modifying the device table directly, call the undo commands. Moreover, don't keep our own copy in the mode - show the original version. Connect to the appropriate signals. This means that the calls from the DiveComputerManagement dialog have to be removed, since this mode of editing is not supported. The whole dialog will be removed in a future commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25desktop: add tab-widget for dive computer namesGravatar Berthold Stoeger
If we want to include dive computer names in the undo system, there should be visual feedback on undo/redo. This would mean opening the divecomputer dialog, which would appear quite strange. Therefore, add a tab. This is not ideal, but consistent with the dive site tab, which probably shouldn't be there either. In the future, the UI needs some rethinking. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24devices: add devices in Command::importTable()Gravatar Berthold Stoeger
Add a device_table parameters to Command::importTable() and add_imported_dives(). The content of this table will be added to the global device list (respectively removed on undo). This is currently a no-op, as the parser doesn't yet fill out the device table, but adds devices directly to the global device table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24parser: add device_table to parser stateGravatar Berthold Stoeger
If we want to avoid the parsers to directly modify global data, we have to provide a device_table to parse into. This adds such a state and the corresponding function parameters. However, for now this is unused. Adding new parameters is very painful and this commit shows that we urgently need a "struct divelog" collecting all those tables! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24cleanup: remove TagWidget::fixPopupPosition()Gravatar Berthold Stoeger
No user of that member function! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24desktop: overwrite drag & drop in TagWidgetGravatar Berthold Stoeger
The interaction of Qt's drag & drop with GroupedLineEdit was exceedingly weird. The user was able to scroll the viewport making the text invisible. This implements a very primitive alternative drag & drop functionality: dropped text is regarged as a distinct tag. This means that it is not possible to modify existing tags by dropping in the middle of them. Arguably, this might even be better than arbitrary drag & drop. But even if not perfect, this fixes a very nasty UI behavior. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24desktop: avoid crashes on drag&drop in GroupedLineEditGravatar Berthold Stoeger
If the user manages to "scroll" through the QPlainTextEdit by a drag&drop action, the state of the widget becomes inconsistent. On the one hand, the text-block says that it has one line. On the other hand, its layout says that it has no line. When trying to fetch the line, a crash occurs. Try to detect such a strange state and return early in GroupedLineEdit::paintEvent(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-23parser: replace params[] code by new xml_params structGravatar Berthold Stoeger
This fixes a load of memory holes, and makes the code (hopefully) more readable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17filter: don't add to filter presets when importing dive sitesGravatar Berthold Stoeger
When importing dive-sites we would add to the global filter-preset table. This data should be thrown away, just like the other tables that might be imported. This shows that we really should introduce a "struct divelog", which collects all those tables into a single structure. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17filter: remove filter_preset_table_tGravatar Berthold Stoeger
We used a typedef "filter_preset_table_t" for the filter preset table, because it is a "std::vector<filter_preset>". However, that is in contrast to all the other global tables (dives, trips, sites) that we have. Therefore, turn this into a standard struct, which simply inherits from "std::vector<filter_preset>". Note that while inheriting from std::vector<> is generally not recommended, it is not a problem here, because we don't modify it in any shape or form. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-11desktop: make divecomputer table sortableGravatar Berthold Stoeger
Add a small proxy-model on top of DiveComputerModel so that clicking on table headers makes the table sortable. The UI feature here is not as important as the fact that the UI does its own sorting and we can keep the device-table in the core sorted differently. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-08build-system: remove building Grantlee cmakeGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08Remove code references to GrantleeGravatar Robert C. Helling
These are no longer needed. What is still missing is removing Grantlee from the various build systems. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08Interpret divelist printing templatesGravatar Robert C. Helling
This is a first step of an efford to get rid of the Grantlee dependency. This implements template processing for those constructs used in our divelist and statistics printing templates. It implements a template parser for loops over dives, cylinders and year and variable replacement. As the previous Grantlee code, it does not really use Qt's QObject introspection capabilities but reuses the old long chain of if-else-statements. The grantlee code is not yet removed. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-06cleanup: use safe connect() in ConfigureDiveComputerDialogGravatar Berthold Stoeger
The pointer-to-member-function version is compile-time checked and therefore less risky with respect to refactoring. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-05Remove empty vertical space from filter QListWidgetGravatar willemferguson
In the filter the dropdown lists for selecting dive mode or day-of-week has a lot of white space at the bottom. This PR removes that white space. Actually the white space at the bottom of a QListWidget appears to be a known bug (actually an omission) for the current Qt V15. The above solution is a brute-force workaround to achieve the same end result. The active line is actually the setFixedSize(). The other line, however, comprises good QT layout policy to minimise widget size. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-10-05clenup: remove bogus connect statement.Gravatar Berthold Stoeger
In OstcFirmwareCheck::saveOstcFirmware() we find the connect() call connect(dialog, SIGNAL(finished(int)), config, SLOT(dc_close())); whereby "config" is of the type "ConfigureDiveComputer". However, the function signature of ConfigureDiveComputer::dc_close reads as void dc_close(device_data_t *data); and indeed "data" is accessed inside the function. I don't understand how this doesn't crash, but clearly something is amiss. Let's remove that connect statement. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03planner: limit depth and time of segments to sane valuesGravatar Berthold Stoeger
Using non-sensical depth and times for segments in the planner may lead to an unresponsive UI. Therefore limit depth to 1000 m/3300 ft and time to 100 h. Limiting of depth is done in settingsChanged() since it has to adapt to the user changig their preferred units. Fixes #2762. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03cleanup: use getDiveSelection() to loop over selected divesGravatar Berthold Stoeger
getDiveSelection() returns a vector of the selected dives. Use that instead of looping over the dive table and checking manually. This removes a few lines of code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>