aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2018-06-26desktop: fix multi-keystroke input on locationGravatar Murillo Bernardes
When the tooltip is hidden QInputMethodEvent is handled by QLineEdit and works properly. When the tooltip is visible DiveLocationListView gains focus and receives QInputMethodEvent, without handling them properly. This patch just forwards the event back to the QLineEdit object. Fix #1405 Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
2018-06-24Localization: make cache thread safe and robust against use-after-freeGravatar Berthold Stoeger
The old trGettext() was not thread-safe and the returned C-strings could be freed in the case of empty translations strings. Therefore: 1) Introduce a mutex protecting access to the cache. 2) Never change existing entries, even if the translation string is empty. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24Localization: remove gettextFromC::instance()Gravatar Berthold Stoeger
There were a handfull instances of the kind 1) gettextFromC::instance()->tr(...) 2) gettextFromC::instance()->trGettext(...) 1) is pointless, as tr is a static function. All instances of 2) were likewise pointless, because trGettext() returns a C-string, which was then immediately converted to a QString. Thus, replace both constructs by gettextFromC::tr(...). After this change there was only one user of gettextFromC::instance() left, viz. the C-interface funtion trGettext(). Therefore, remove gettextFromC::instance() and do all the caching / translating directly in the global trGettext(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-21android/desktop: remove mapWidget from subsurface.qrcGravatar jan Iversen
remove mapWidget entries from subsurface.qrc, and add reference to map-widget.qrc in CMakelist.txt Android uses the same CMakelist.txt Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-20equipment: sanitize 'tank_info' loop limitsGravatar Lubomir I. Ivanov
In a number of places the global 'tank_info' array is being iterated based on a 'tank_info[idx].name != NULL' condition. This is dangerous because if the user has added a lot of tanks, such loops can reach 'tank_info[MAX_TANK_INFO]'. This is an out of bounds read and if the 'name' pointer there happens to be non-NULL, passing that address to a peace of code that tries to read it (like strlen()) would either SIGSEGV or have undefined behavior. Clamp all loops that iterate 'tank_info' to MAX_TANK_INFO. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-06-18In dive picture shift time dialog suppress double triggering of timeEditGravatar Stefan Fuchs
In dive picture shift time dialog when pressing the up or down arrow of the timeEdit widged there is some risk of double triggering because the function called after this UI action ("updateInvalid()") can have quite some runtime. Suppress any potential double triggering by disabling the timeEdit widget after each change until the code is processed. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18Change from gettextFromC::instance()->tr() to gettextFromC::tr();Gravatar Stefan Fuchs
Code cleanup. Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18Use correct "tr" call for translating dive mode namesGravatar Stefan Fuchs
Correctly use gettextFromC::instance()->tr(); instead of a simple tr(); to translate the dive mode names. This goes on top of 0bc9edf855caf95e2d58ccaf704ceeda079e06f1 and finally makes the whole thing work. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17Dive computers: turn QMultiMap into sorted vectorGravatar Berthold Stoeger
The list of known dive computers was stored in a multi-map indexed by the device name. Turn this into a sorted QVector. Thus, no map-to-list conversion is needed in the device editing dialog, which distinctly simplifies the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17Cleanup: fold DiveComputerManagementDialog::update() into init()Gravatar Berthold Stoeger
update() was only called in conjunction with init(). No point in having two functions. The separation between both functions seemed arbitrary anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17Cleanup: use QScopedPointer for DiveComputerManagementDialog::modelGravatar Berthold Stoeger
Not necessary to do own memory management. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17Fix an error around translation of dive modes in the UIGravatar Stefan Fuchs
This fixes an mistake introduced in 3d1072f8862e4c329dc2678df52a24137b8d4704 Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17desktop: better handling of progress dialog widthGravatar Dirk Hohndel
We shouldn't need to manually set it, but it appears we do. To avoid constant resizing, let's only grow it - and let's set the size before we update the text. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-16Cleanup: Don't clear WA_QuitOnClose attribute on dialogsGravatar Berthold Stoeger
According to Qt's documentation, the application exits if all windows with the WA_QuitOnClose attribute are closed. This attribute was cleared for three dialogs. This seems not necessary because: 1) The application can't be closed as long as the modal dialog is shown. 2) The flag only concerns primary windows, which these are not. See: http://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop 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-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
helpers.h included qthelper.h and all functions declared in helpers.h were defined in qthelper.h. Therefore fold the former into the latter, since the split seems completely arbitrary. While doing so, change the return-type of get_dc_nichname from "const QString" to "QString". 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-28Distinguish between user and internal divemode namesGravatar Robert C. Helling
The former should be translated but not those that go to xml/git. ... and fix capitalization of pSCR. Suggested-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-27Dive pictures: automatically recalculate thumbnailsGravatar Berthold Stoeger
If a thumbnail and the original picture can be accessed and the modification date of the thumbnail is before the modification date of the picture, recalculate the thumbnail. This causes more disk access and might give strange effects for picture files with messed up file timestamps (i.e. lying in the future) or messed up computer clocks (i.e. running in the past). Therefore, add a preference option to disable the new behavior. Default is set to enabled. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-27Dive pictures: give user option to recalculate thumbnailsGravatar Berthold Stoeger
Even though hashes of image contents are calculated, the hashes are not compared to actual file contents in routine-operation. Therefore give the user the option to recalculate thumbnails, should they have edited the picture. 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-25Cleanup: Don't defer deletion of oldModel in DiveListView::reload()Gravatar Berthold Stoeger
There seems to be no point in using deleteLater() of the previous model. Set the new model and delete the old one. This fixes a crash with Qt 5.11. Tested-by: Gaetan Bisson <bisson@archlinux.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-24desktop-widgets: replace (void) with no parameter nameGravatar jan Iversen
Unused parameters in C++ are "silenced" by removing the name. Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-23Fix includes for building against Qt-5.11.0Gravatar Gaetan Bisson
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
2018-05-21desktop-widgets/statistics: 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-21desktop-widgets/.../facebook: 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-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-21Dive pictures: change removePicture() interfaceGravatar Berthold Stoeger
The function removePicture() had a flag "last", which would indicate that the called had finished removing pictures. Only then would the model be recalculated. This is a strange interface and, matter of fact, the caller was buggy: if the last picture to be removed didn't have a proper url, removePicture() was never called with "last" being set. Change the interface to take a list of pictures to be deleted. This will allow us to make picture deletion smarter in follow-up commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-14Planner: Add combo box for dive mode selectionGravatar Robert C. Helling
I am not really sure what I am doing here but I copied code from the gas selection. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14Rename enum dive_comp_type to divemode_tGravatar Robert C. Helling
...as the usuage is not anymore about a computer but a momentary dive mode. Rename the end indicator as well. Signed-off-by: Robert C. Helling <helling@atdotde.de>
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: remove dive.h from files that don't need itGravatar Dirk Hohndel
Of course, quite a few of them indirectly get it through other header files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-13Dive pictures: Update pictures when thumbnails are readyGravatar Berthold Stoeger
Connect the thumbnailer signal to the dive picture model slot. This needs some code-reshuffling in the dive picture model. 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-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-11Fixed erroneous comparison of cylinders and weight systems.Gravatar Oliver Schwaneberg
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-05-11Corrected file name "weigthsysteminfomodel" to "weightsysteminfomodel"Gravatar Oliver Schwaneberg
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-05-10Removed a duplicate include in maintab.cppGravatar Oliver Schwaneberg
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-05-04Desktop: fix time format in main tabGravatar Dirk Hohndel
Fixes #1234 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-01CSV import: include visibility and rating in importGravatar Miika Turkia
Add support for visibility and rating to CSV import dialog. Fixes #1212 Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-01CSV import: parse (unit) style headersGravatar Miika Turkia
Commit fc010456 introduced the units to column headers. Thus the matching of these labels must take the unit into account when doing automatic matching of the header line with our field naming. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-28Plot OC-pO2 graph for SCR divesGravatar Willem Ferguson
This commit allows plotting the OC-equivalent pO2 graph for PSCR dives. This happens in both the cases where there is no external O2-monitoring AND when there is external pO2 monitoring. The calculations are only done for PSCR dives and is achieved as follows: 1) Within plot-info create a pressure-t called OC_pO2 in profile.h and populate this variable with the open-circuit pO2 values in profile.c. 2) Create a new partialPressureGasItem ocpo2GasItem in profilewidget2.h and, in profilewidget2.cpp, initialise it to read the plot-info OC_pO2 values and enable its display by using the setVisible method. The diveplotdatamodel was also touched in order to achieve this. 3) Create a pref button that controls the display of OC-pO2 for SCR dives 4) Change the colour of the OC-pO2 grpah to orange 5) Change the connection of the crr_OC_pO2 signal to be appropriate 6) rename the OC_pO2 attribute to scr_OC-pO2 Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-04-27Configure ostc3: Remove obsoleted settingGravatar Anton Lundin
In firmware version 2.97 the setting 0x38, SETPOINT FALLBACK, has bin obsoleted and we get a error when trying to write to it. This removes this setting. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-04-24Convert our custom IO model to new libdivecomputer IO modelGravatar Linus Torvalds
This converts our old custom IO model to the new model that libdivecomputer introduced. This is partly based on Jef's rough patch to make things build, with further work by me. The FTDI code is temporarily disabled here, because it will need to be integrated with the new way of opening devices. The ble_serial code goes away entirely, since now libdivecomputer knows about BLE transport natively, and doesn't need to have any serial wrapper around it. Signed-off-by: Jef Driesen <jef@libdivecomputer.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-19CSV import: fix setpoint (typo)Gravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-09Change taglist_get_tagstring to support 'unlimited' tag list sizeGravatar Jeremie Guichard
Previous taglist_get_tagstring signature/implementation did not allow handling of cases where inputted buffer could not contain all tags. New implementation allocates buffer based on pre-computed size allowing to insert all tags in the returned string. Added get_taglist_string in qthelper to handle conversion to QString Added TestTagList with tests for taglist_get_tagstring Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-04Add "Tags" column in Desktop app's dive list viewGravatar Jeremie Guichard
Add DiveItem::displayTags helper method to return Tags as a QString New Tags column is by default inserted before "Photos" column by default disabled Signed-off-by: Jeremie Guichard <djebrest@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>