remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).
Signed-off-by: Jan Iversen <jani@apache.org>
remove General from SettingsObjectWrapper and reference qPrefGeneral
update files using SettingsObjectWrapper/General to use qPrefGeneral
this activated qPrefGeneral and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove PartialPressureGas from SettingsObjectWrapper and reference qPrefPartialPressureGas
update files using SettingsObjectWrapper/PartialPressureGas to use qPrefPartialPressureGas
this activated qPrefPartialPressureGas and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove Geocoding from SettingsObjectWrapper and reference qPrefFacebook
update files using SettingsObjectWrapper/Geocoding to use qPrefFacebook
this activated qPrefGeocoding and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove Language from SettingsObjectWrapper and reference qPrefLanguage
update files using SettingsObjectWrapper/Language to use qPrefLanguage
this activated qPrefLanguage and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove TechnicalDetails from SettingsObjectWrapper and reference qPrefTechnicalDetails
update files using SettingsObjectWrapper/TechnicalDetails to use qPrefTechnicalDetails
this activated qPrefTechnicalDetails and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove UpdateManager from SettingsObjectWrapper and reference qPrefUpdateManager
update files using SettingsObjectWrapper/UpdateManager to use qPrefUpdateManager
this activated qPrefUpdateManager and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove DivePlanner from SettingsObjectWrapper and reference qPrefDivePlanner
update files using SettingsObjectWrapper/DivePlanner to use qPrefDivePlanner
this activated qPrefDivePlanner and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove Units from SettingsObjectWrapper and reference qPrefUnits
update files using SettingsObjectWrapper/Units to use qPrefUnits
this activated qPrefUnits and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
Commit df156a56c0 replaced "virtual"
by "override" where appropriate. Unfortunately, this had the
unintended consequence of producing numerous clang warnings. If
clang finds a override-modified function in a class definition,
it warns for *all* overriden virtual functions without the override
modifier.
To solve this, go the easy route and remove all overrides. At least
it is consistent.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>
The function DiveListView::fixMessyQtModelBehaviour() was used to
expand the first columns of dive-trips in the dive-list view.
This function was called everytime that the dive-list was modified.
It is kind of ludicrous that external callers would have to
tell the DiveListView, when it has to update its column headers.
Instead, place this functionality in the overriden reset() and
rowsInserted() functions, as these are the only ways that
rows can be added. Change the DiveTripModel to use the proper
beginResetModel()/endResetModel() pair instead of the previous
full deletion and full repopulation using the beginRemoveRows()/
endRemoveRows() and beginInsertRows()/endInsertRows().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
remove Proxy from SettingsObjectWrapper and reference qPrefProxy
update files using SettingsObjectWrapper/Proxy to use qPrefProxy
this activated qPrefProxy and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
This debugging-slot was not linked anywhere. And especially in the
light of the impending refactoring of DiveListView/DiveTreeModel
it seems pointless to keep old debugging code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Extract thumbnails using ffmpeg.
Behavior is controlled by three new preferences fields:
- extract_video_thumbnails (bool): if true, thumbnails are calculated.
- extract_video_thumbnail_position (int 0..100): position in video
where thumbnail is fetched.
- ffmpeg_executable (string): path of ffmpeg executable.
If ffmpeg refuses to start, extract_video_thumbnails is set to false
to avoid unnecessary churn.
Video thumbnails are marked by an overlay.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
remove Facebook from SettingsObjectWrapper and reference qPrefFacebook
update files using SettingsObjectWrapper/Facebook to use qPrefFacebook
this activated qPrefFacebook and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
The column-widths must only be set once the source-model is that.
The old code realized this with a rather complicated logic.
Instead, simply set the source-model in the constructor and
set the column widths after that. Rename the corresponding
function from "setupUi" to "setColumnWidths".
Moreover, the setupUi function had different code-paths for
the first and other calls. Since it is only called once,
remove the other code paths.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Conceptually, the width of the columns should probably reside in
the view not the model. But much more severly, the old code didn't
work: Columns were set in a DiveTripModel, which was deleted
right away.
Therefore, move the logic back to the DiveListView. Introduce
a QVector<int> of the initial column widths, so that they can be
erased from the setting if unchanged.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
remove DiveComputer from SettingsObjectWrapper and reference qPrefDiveComputer
update files using SettingsObjectWrapper/DiveComputer to use qPrefDiveComputer
this activated qPrefDiveComputer and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove CloudStorage from SettingsObjectWrapper and reference qPrefCloudStorage
update files using SettingsObjectWrapper/CloudStorage to use qPrefCloudStorage
this activated qPrefCloudStorage and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
Add a context-menu entry to TabDivePhotos which opens the folder(s)
of all selected files.
Fixes#1514.
Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If the last dive of a trip is removed, the trip is deleted.
On redo the dive is added to a non existing trip, leading to a
segfault.
Therefore, keep a copy of the trip to reinstate it on redo.
Note: this cannot work for a sequence of multiple commands.
One would have to rewrite the whole undo-history. Nevertheless,
let's do this as a stop-gap measure.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
UndoDeleteDive::tripList kept track of the trips to be recreated on
undo. But the list wasn't cleared on undo, thus on subsequent redo
the same trip was readded to the list, leading to double-free.
This could trivially be reproduced by repeated CTRL-Z, CTRL-SHIFT-Z
pairs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
9efb56e2d4 introduced rather complex
logic for picture drag'n'drop events onto the profile. Among other
things, the code had to check whether the picture actually belongs
to the displayed dive.
This can be simplified by transporting the dive-id in the drag'n'drop
event structure. The flow goes like this:
DivePictureModel--(1)-->DivePictureWidget--(2)-->ProfileWidget
For (1), we can use the Qt::UserRole role. This was used to transport
the picture-offset, but this is not needed anymore since ProfileWidget
was decoupled from DivePictureModel.
For (2), we simply replace the "position" value, which was never used.
Why would the receiver care which pixel was pressed in the media-tab?
This commit also contains a minor cleanup in DivePictureWidget:
QListView::mousePressEvent(event) was called in both branches of an
if and can therefore be removed from the if. This is so trivial,
that it doesn't warrant its own commit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the remoteDeviceScanFinished slot, the old code called into
the deviceDiscoveryError() in case the device discovery agent
had the error flag set. This is not necessary, since the agent
will send an error signal in such a case.
For Qt's device discovery agent, the whole check-for-error is
unnecessary, as the documentation states:
"The signal is not going to be emitted if the device discovery
finishes with an error."
But for the homebrew WinBluetoothDeviceDiscoveryAgent, which
derives from QThread, both an error() *and* a finished()
signal will be sent. Therefore keep the test, but don't call
into the slot twice.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
dive_getUniqID() is used to create unique dive ids, which are
stable during application lifetime. It was passed a dive, checked
that the id was not set (if it was that it is know to the application)
and set a new id (in contradiction to its name!) if it hadn't any.
There were three callers:
alloc_dive(): called the function on a zeroed dive struct.
fixup_dive(): called the function only if the dive had a 0 id.
MainWindow::setupForAddAndPlan(): called the function on a zeroed dive
struct.
Thus, in all three callers the id is guaranteed to be zero and
the whole keeping-track-of-ids logic is moot. Remove the logic,
don't pass a dive struct to dive_getUniqID() and move the function
to the C-backend.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On top of the file filter for all media files add a file filter
for images only, one for videos only and one for all files.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This changes the above mentioned terms everywhere in the UI to
reflect the fact that Subsurface now also supports video files on top
of image files.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
When we introduced the whole check for supported transports code, no one
noticed that it broke configuring all ostc's over bluetooth.
The configure code just used a placeholder model of OSTC 3 to get the
right backend code. With the new supported transports model it errored
out if you where trying to connect to a bluetooth enabled device, just
because the original OSTC 3's wasn't bluetooth enabled.
This switches the placeholder model over to a OSTC Plus which is both
bluetooth, serial and ble capable, so the code works again.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
remove Animations from SettingsObjectWrapper and reference qPrefAnimations
update files using SettingsObjectWrapper/Animations to user qPrefAnimations
this activated qPrefAnimations
Signed-off-by: Jan Iversen <jani@apache.org>
add the prepared class qPrefDisplay to SettingsObjectWrapper and thereby making it active.
As a consequence of the uniform naming standard desktop-widgets/preferences_defaults.cpp and
tests/testpreferences.cpp have been updated.
Signed-off-by: Jan Iversen <jani@apache.org>
Remove qmlRegister in desktop-widgets/mapwidget in order to have a shared
registration in subsurface-helper.cpp
Signed-off-by: Jan Iversen <jani@apache.org>
add enum to qPref and remove elsewhere
update source core to reference qPref.
the enum cannot be in pref.h because it is to be used in qml and Q_ENUM
need the enum to be defined as part of the class
Signed-off-by: Jan Iversen <jani@apache.org>
There were two catch-all classes for translations outside of class
context. gettextFromC was used exclusively from C, but C++ used
both, gettextFromC and QObject. Some of the string were even present
in both. Therefore, unify to gettextFromC throughout the code base.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove cloud_storage_status from qmlprefs.h.
usage to qPref::
enum cloud_storage_status is not used from C, but only from C++, and
having the same structure defined multiple times is a maintenance
challenge.
Signed-off-by: Jan Iversen <jani@apache.org>
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>
In the last commits, the canonical-to-local filename map was made
independent from the image hashes and the location of moved images
was based on filename not hashes. The hashes are now in principle
unused (except for conversion of old-style local filename lookups).
Therefore, remove the hashes in this commit. This makes addition
of images distinctly faster.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Users might have edited their pictures. Therefore, instead of identifying
pictures by the hash of the file-content, use the file path. The match
between original and new filename is graded by a score. Currently, this
is the number of path components that match, starting from the filename.
Camparison is case-insensitive.
After having identified the matching images, write the caches so that they
are saved even if the user doesn't cleanly quit the application.
Since the new code uses significantly less resources, it can be run in a
single background thread. Thus, the multi-threading can be simplified.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The connection canonical filename to local filename was done via
two maps:
1) canonical filename -> hash
2) hash -> local filename
But the local filename was always queried from the canonical filename.
Therefore, directly index the former with the latter.
On startup, convert the old map to the new one.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
move #include prefs-macros from SettingsObjectWrapper.h to SettingsObjectWrapper.cpp
include dive.h directly (only part of prefs-macros.h used) in preference classes
Signed-off-by: Jan Iversen <jani@apache.org>
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>
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>
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>
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>
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>
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>
Correctly use gettextFromC::instance()->tr(); instead of a simple
tr(); to translate the dive mode names.
This goes on top of 0bc9edf855
and finally makes the whole thing work.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
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>
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>
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>
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>
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>
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>
In commit d21d42b691 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>
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>
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>
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>
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>
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>
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>
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>
...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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This reverts commit 70e0e80de5.
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>
This reverts commit fc7729eb78.
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>
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>
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>
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>
learnHash() was always called in conjunction with add_hash(). The
pattern was that a local filename and a hash were connected in
the hash-to-filename and the filename-to-hash maps. Then, the
original picture-filename or url were registered in the filename-to-hash
map.
This commit changes learnHash() to take three parameters (original-filename,
local-filename and hash) and do all of the above. The new code is
simpler because no dummy picture struct has to be generated in
DiveListView::loadImageFromURL().
The tests were extended to check for all hash<->filename associations.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the configure dive computer dialog change the order of the DCs
(all HW first, then Suunto) and correct the names of some HW DCs
(make them the same as in the "download from DC selection list").
Plus added the OSTC Plus to the list of supported DC.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Add a combo box for water types with defaults for fresh water, sea water
and the EN 13319. All values taken from units.h, where EN 13319 was added
beforehand.
Custom values can be entered through a spinbox.
Also changed "Salinity" in TapDiveInformation.ui to "Water type".
Translation required!
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
Move the icd preference setting to the preference group that deals
with gas pressures.
I also reorganised the existing items so that the items within the
pressure widget are logically arranged according to the grid layout.
The order of items was very haphazard. No change of code at all in
this reorganisation.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Each callsite of saveBtDeviceInfo() has a QString, which is converted
to a C-string, passed and immediately converted back. Remove these
conversions by taking a reference to QString directly.
getBtDeviceInfo() is not as clear. Here, the callsite has a C-string
handed down from libdivecomputer. Nevertheless, pass a reference of
QString here as well. Firstly, for reasons of symmetry. Secondly,
to avoid multiple conversions in the getBtDeviceInfo() functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Use struct temperature_t for temperatures in struct stats_t and
use get_temperature_string() when printing these temperatures for
statistics and HTML export.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
In the configure dive computer dialogs remove all the spaces between
values and units. This makes it consistent with the standard used
all over the Subsurface UI.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Mostly replace "return (expression);" by "return expression;" and one
case of "function((parameter))" by "function(parameter)".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
As far as I know, Qt's emit is defined to nothing.
Thus, the construct "emit(lastError);" is compiled to
"(lastError);", which is a no-op.
Obviously "emit error(lastError)" was meant.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This transport option was defined at a time where libdc didn't know
anything about bluetooth. Nowadays, this enum is defined by libdc to
a different value.
Since it is never returned from libdc, not a problem at the moment.
But this looks like a recipe for desaster, therefore let's just use
the libdc version.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This change deals with issue #554.
If you enter a dive duration manually, the cell renderer cuts the seconds
away when the changes are saved. I added the helper "render_seconds_to_string"
as a counterpart to "parseDurationToSeconds". The helper keeps the seconds,
if not null. The rendering of the cell is done at two places in the code,
so I think it is cleaner to add a dedicated method for it.
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
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>
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>
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>
This fixes 2 problems related to entering passwords with
illegal characters in it:
1) Do not save an invalid password in the preferences, but keep the old
one.
2) On password change, check both old and new password for format
validity instead of pushing an invalid password to the server that
has to ignore it.
Fixes: #1048
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
In preferences_network.cpp, the CloudStorageAuthenticate::passwordChangeSuccessful
signal was connected to the PreferencesNetwork::passwordUpdateSuccessful
slot. This never worked, because passwordUpdateSuccessful() was declared
as a normal member function, not a slot (hooray for Qt's weird runtime-checked
signal system).
While touching this code, change the weird SIGNAL/SLOT macros to
actual member function, to at least get *some* compile-time checks.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>
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>
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 b3901aa8f9:
The cloud-online menu entry was still enabled after "closing" the
cloud storage.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The preferences flag cloud_background_sync used to be used heavily in
the mobile code, but is not used there anymore. Now, it is accessed
only in one place, but does not do what it actually says: If it is off,
the remote storage is not synced on save (but will be synced on next
load).
Syncing on save can also be prevented by unchecking the "Cloud online"
menu checkbox. Since the latter seems more logical and general
(support for non-cloud remote git repositories), remove the cloud_background_sync
option.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>
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>
Do not save the WebserviceID in the preferences until we ask
for this. That is simply wrong.
This is definitely not a full fix for all the weirdness that is
going in related to the WebserviceID but saving the ID even
if we do not ask for it, adds to possible confusion.
To always automatically pull in the ID from the server based
on cloud credentials, just leave the ID field empty in the
network preferences.
Fixes: #1013 (well ... a tiny part of this mess)
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
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 6f42ab46da and ee9531f76e, where only
one side of the duplicated code was fixed.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
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>
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>
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>
A very simple commit to start 2018. When hitting new logbook from
a currently open logbook, and the current dive has tags filled in,
they stayed around in the UI. Just clear them. Further, delete
an unused variable.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
If the BT dialog hasn't been shown, the device name was taken from
the text field, which contained a formatted string. The device open
would then fail.
Fixes#1002
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This fixes a bug reported by Willem that removing waypoints
using the right click context menu makes the cylinder
pressure lines partly disappear.
The reason was that clicking a dive handler disables the
pressure interpolation (and other things, controlled by
shouldCalculateMaxdepth). This is turned on again upon
the mouse release event. This event is not triggered when
selecting in item from the context menu (like remove
waypoint or gas selection) so we need to send it manually.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
See also commit c032006d91. Compare functions passed
to sort functions need to compare for less-than and not
less-or-equal.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
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>
DiveLocationFilterProxyModel::lessThan() used less-or-equal instead
of less-than comparison. This can lead to subtle bugs if two elements
compare as equal.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Introduce toggle buttons which mean "filter all dives except
those fulfilling the selected criteria".
The old code used to check for rowCount() == 0. This should never happen,
because there is always a row "empty field". This check was moved into
the preamble of the functions to seperate it from the actual logic.
Fixes#435
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Let the menu introduced in commit 5e86442bab
pop up on right-click instead of button-click.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since these classes do not possess any signals/slots,
these macro are unnecessary.
Likewise, the friend declaration in TagFilter is useless,
since the corresponding fields are in the base class.
Fallout of commit 1a4e7ad0dd.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We aren't really consistent. And I don't do this often enough. But based
on a few things that I saw in a recent commit, I wanted to at least fix
those. And then of course fixed everything in those two files.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
To every filter list add a menu button that allows selection of all,
selection of none or inversion of selection.
Implements #435.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The TagFilter, BuddyFilter, SuitFilter and LocationFilter classes
all did essentially the same thing. Therefore, factor out common
code / objects into a base class FilterBase.
The new base class stores a pointer to the filter model. It was
felt that this is simpler than introducing virtual methods.
The only thing the *Filter classes now do is setting a label and
in one case a tooltip. Thus, in principle, they could be removed
completely, but let's keep them for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The more complex handling is no longer needed because:
- Keyboard tracking for gfhigh/low UI fields was switched off here:
030c094854
- GFhigh was limited to 40 here:
53fffe0ce3
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
And why this one? Well, while this include is renamed in Qt 5.10
and gives deprecated compile warnings. And as it unused anyway, just
remove it.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Besides being the right thing to do (code reflects reality), it
silences a compiler warning.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This implements different zoom levels for the dive photos tab as
suggested by Stefan Fuchs <sfuchs@gmx.de> in #898.
The zoom level can be changed using a slider or CTRL+mousewheel.
Zoom levels range from a third of the standard thumbnail size to
thrice the standard thumbnail size.
Thumbnails are cached in maximum resolution and scaled down on
the fly. Because the profile widget took its pictures from the
photo list model, an extra picture copy with a fixed size had
to be introduced.
The UI is still a bit crude.
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Internal floating point (FP) calculations should be performed using double
unless there is a very good reason. This avoids headaches with conversions.
Indeed, the vast majority of FP calculations were already done using double.
This patch adapts most remaining calculations. Not converted where things
that were based on binary representations and variables which weren't used
anyway.
An analysis of all instances follows:
core/plannernotes.c, l.404:
This was a comparison between two floats. On the left side, first an integer
was cast to float then multiplied with and integer and divided by a constant
double. The right hand side was an integer cast to a float. Simply divide by
1000.0 first to convert to double and continue with calculations. On the right
hand side, remove the cast, because the integer will be implicitely cast to
double for comparison. This conversion actually emits less instructions,
because no conversion to double and back is performed.
core/planner.c, l.613:
Same analysis as previous case.
subsurface-desktop-main.cpp, l.155:
A local variable representing the version OpenGL version. Turn this into
integer logic. Not only does this avoid dreaded FP rounding issues, it also
works correctly for minor version > 10 (not that such a thing is to be
expected anytime soon).
abstractpreferenceswidget.[h/cpp]:
A widget where the position is described as a float. Turn into double.
desktop-widgets/divelogexportdialog.cpp, l.313:
total_weight is described as float. Use double arithmetics instead. This
instance fixes a truncation warning emitted by gcc.
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>
Before, we did not look at the path of the filename to export
to but we should write the images there and not in pwd.
Fixes#931
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Title is self explanatory.
[Dirk Hohndel: small edits to remove typo / improve readability]
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
ATM we were giving preference to a gps fix taken during dive time over
another taken before dive start time (proven both in predefined
SAME_GROUP 6 hours range).
While this logic is right for a static boat or a shore dive - as it
ensures a correct position - will fail for drift dives or dives where
boat changes its position during dive time.
Instead, will choose the gps fix closer to the dive start time.
fixes issue #666
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
This fixes an actual bug, where the current image dir would only be
remembered on closing the program.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
Calculating variations when in recreational mode doesn't make sense, and can
prevent variations from being calculated when switching back to Buhlmann or
VPM-B modes.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
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>
Small change to allow the dive pictures list to use the available
space if one resizes the window or switches to different mainwindow
view.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Some improvements for the dive picture tab and dive pictures in profile:
- Bugfix mouse event in profile: Only Left-click will open picture
- Bugfix mouse events in picture tab:
- Re-enable context menu (Windows bug mainly)
- Re-enable multi select in a nice way
- Only double-left-click will open picture
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Icon aliases were complete mess.
Some icons had alias some didn't.
Named with underscores vs. hyphens vs. camelCase.
Lower vs. upper case.
"ICON" prefix vs. suffix vs. nothing.
With vs. without filename suffix.
Some didn't make sence. Eg. mapwidget-marker-gray
(I can see, it's grey, but what does it represent?)
Some were duplicated, eg warning vs. warning-icon.
Some were name after widget, which is wrong.
Do not reinvent wheel. Use widely used naming scheme
close to Freedesktop Icon Naming Specification. This
will enable usage of common icons from current set in
the future. Thus Subsurface will fit nicely to GUI.
This changes icon aliases to one, easy grep-able style.
Signed-off-by: Martin Měřinský <mermar@centrum.cz>
Disable tabs for equipment, info, pictures and extra info if a
dive trip is selected.
Remember specific tab selection for dives and dive trip to recover
selection when browsing dive list.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
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>
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>
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>
Instead of handing the QSession object down, simply create it in
MainWindow::checkSurvey()
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
Icon aliases were inconsistent mess. Underscores vs. hyphens vs. camelCase.
With vs. without filename suffix. Lower vs. upper case. "icon" suffix vs.
prefix vs. nothing. Some were duplicated, eg warning vs. warning-icon. Some
icons didn't have alias at all.
This changes all icon aliases to one, easy grep-able style which complies
to Freedesktop Icon Naming Specification (Guidelines).
Signed-off-by: Martin Měřinský <mermar@centrum.cz>
After one selected a dive and then selects NO dive don't touch
the visibility of UI fields for depth and duration.
So if previously selected dive was a manually added dive, keep them
visible. If it was no manually added dive keep them invisible.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Remove duplicate and incorrect setPlainText call via macro for dive notes.
Deal correctly with ASCII line breaks "\n" in dive notes with html
markup (replace them with <br>).
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Currently when the user is typing new coordinates the
marker on the map changes location right away. Disable that and
add a 'flag' button that should be pressed instead. Also make the
coordinates update when pressing Enter or when the text
field loses focus.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
After editing the cylinder table (e.g. deleting a cylinder) and
accepting the changes copy the whole dc samples for the dive edited.
This is important because the sensor idx in the samples may have changed.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
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>
If the user implicitly adds a dive site by editing a dive, and
a location filter is active, check the new dive site in the
location filter.
This is done by informing the LocationFilterModel of the new
dive site name prior to repopulation. The LocationFilterModel
then adds a corresponding entry and marks it as checked.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since commit 01d961086c, the location filter
list is updated if a dive site is edited. The problem is that if the
name of a selected dive site is changed, the selection is lost.
Therefore, before repopulating, inform the location filter that a dive
site changed its name. The location filter then internally changes the
name and can properly transfer the old selection on repopulate. This is
performed via the new LocationInformationWidget::nameChanged signal,
which is connected to the new LocationFilterModel::changeName slot.
A special case to be handled is the following:
[ ] Site 1
[x] Site 2
and "Site 2" being renamed to "Site 1", i.e. both sites being merged.
Here, the merging is detected and "Site 1" will likewise be checked:
[x] Site 1
[x] Site 1
No merging is performed, as the list will be repopulated anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since commit 01d961086c, 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>
set_userid() was declared in core/dive.h and dektop_widgets/subsurfacewebservices.h.
Remove the second instance because two declarations of the same function
are a recipe for disaster.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Until now when selecting a dive w/o dive site after having a previous
dive with dive site and location tags displayed, the location tags of the
previously selected dive where still displayed.
This fixes this behavior.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Calls MainWindow::refreshDisplay() if a dive site was edited so that
the filter lists are updated. The old call to updateDiveInfo() was
removed because it is call implicitly in MainWindow::refreshDisplay()
anyway.
Fixes#675.
Requested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Don't accidentally enable o2breaks option when entering planner in
RECREATIONAL mode.
Disable also label for min_switch_duration according to dive mode.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
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>
Each preferences object owns its string members. In three cases, pointers
were copied instead of strings, leading to (in the best case) dangling
pointers if the user edited values:
1) In the GET_TXT macro in core/prefs-macros.h
2) In the PreferencesDialog::defaultsRequested() method
3) In main() of the mobile version
This patch fixes these issues, by using copy_string() or copy_prefs()
as appropriate.
The only reason that the old code didn't crash regularly is that the
default_prefs object was only used at startup and defaultsRequested()
is (at the moment?) dead code.
This patch also aligns the backslashes in core/pref.h and fixes a typo.
The declaration of copy_prefs() is moved to the core/prefs.h header.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
The function find_all_templates() thus far handled
all files in the user template directory.
This patch makes it so that only files with the .html
extension are loaded.
Also remove brackets for single lined `if` statement.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Prefix the path for 'statistics' templates when
detecting if a template is read-only.
Import / Export for statistic templates is not supported.
So the user has to manually copy and chown a '/statistics'
templates.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Show an error message if trying to:
1) Import over an existing read-only template with the same name
2) Export to a read-only file with the same name
3) Delete a read-only template
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Thus far the exported template did not had the .html
extension. This patch makes sure that the extension
is always added to the file if missing.
Also handle the case where the user used ".htm" and
replace that with ".html".
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Store the last template file name which the user
imported / exported and then try to pre-select
it in the combo box.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
1) on_deleteButton_clicked() show a proper message box with
icon title and also quote the file name.
2) When exporting a file, make sure that the destination is not
read-only even if the source is.
3) Do not allow editing of read-only templates (e.g. the bundled ones).
Instruct the user to Export first.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
1) Always open the user path on Import / Export
2) Update the list after Export, as the user might
have exported to the user path
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Add the function set_bundled_templates_as_read_only()
in templatelayout.cpp/h. The function is used to
mark the bundled template files as read-only in
the user folder. It is called in mainwindow.cpp,
after the files are copied from the bundle.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Currently, it was only possible to use a hard-coded default
cylinder in the preferences. At the same time, the user is
allowed to add own cylinders to a dive (by just typing in
a new name and cylinder properties). These own cylinders
could not be selected in the preferences, requiring the
user to manually add this every dive.
Not sure the reason for all this was intentional, or just
an overlooked aspect in the implementation. It appeared
that the selection list in the UI was constructed before
any logbook was parsed, so at that moment, there are only
hard-coded cylinders.
The fix is simple. Refresh the UI of the preferences just
before it is shown. While opening the logbook, a new
list of cylinders, including the own cylinders is
constructed, so the UI is refreshed to that.
While a simple change, there is a use case that might be
considered strange. Open a logbook, choose new logbook,
and change the default cylinder preference to an own
(from the previously opened logbook). Do not add a dive
with the new (own) cylinder and save this logbook.
Reopen this new logbook, and see that the default
cylinder in the preferences is empty. This is logical,
as the list of own possible cylinders is constructed
from the (new) logbook, that has no dive with that
specific own cylinder. I consider this acceptable
behavior, as it can be also be used to copy own
cylinders to a new logbook.
Fixes: #821
Proposed-by: Davide DB <dbdavide@gmail.com>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
In general, the C++-side of the preferences code consistently uses
the bool data type for boolean settings. There are five exceptions,
which use short instead:
showPo2
showPn2
showPhe
saveUserIdLocal
displayInvalidDives
This patch attempts to make the code more consistent by turning
these into bools as well.
Tests showed that writing as short and reading as bool is handled
gracefully by the Qt variant code. Therefore, an upgrade should not
cause user-visible changes to their settings.
As a bonus, two extern declarations of the set_save_userid_local()
function, which is not defined anywhere, were removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The almost 3 year old commit e1db5f21b1 introduced the behavior
that you need to type at least 1 character for a tag to show any
autocompleted data. While this went unnoticed for years, there
is always a user that notices this changed behavior.
The solution is rather simple. Do allow the 0 lenght string
to act as seed for autocompletion instead of just returning, and
doing no autocomplete at all.
As the afore mentioned commit was explicitly meant to prevent over
active firing of the tag list autocompleter, this (simple) change
is carefully tested on this, and no adverse effects are visible.
Fixes: #605 (wrt the 1 character issue)
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Until now accidentally the dateLabel was disabled and the timeLabel
was enabled. Changed this the other (correct) way round.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Some BT devices support both, classical and LE, modes. Users could
choose either by prepending or removing "LE:" in the device address
field. After commit d23bd46a1b, the
device field is always disabled in Bluetooth mode.
Therefore, add a mode combo box to the Bluetooth device selection
dialog. In the default mode (auto), the old code path (based on
the Qt device flags) is used. The two other modes (force LE, force
classical) allow the user to force the preferred behavior.
This feature is meant as a stop-gap measure until a more refined
transport choice is implemented. Therefore, the value of the new
combo box is not saved in the settings, to avoid cluttering of
the preferences with soon to be obsolete entries.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, on Linux, after selecting a Bluetooth device the name of the
device is shown. On reopening the download dialog, on the other hand,
the address is shown. In the device selection dialog both are shown.
This patch changes the download dialog such that both, name and address,
are shown. The bulk of the patch introduces the name of the device in
the preferences and DCDeviceData. It has to be noted that DCDeviceData
is an encapsulation of the libdivecomputer device_data_t. Nevertheless,
the new Bluetooth-name field is, at the moment, not passed through to
libdivecomputer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>