Commit graph

1942 commits

Author SHA1 Message Date
Dirk Hohndel
9be028659e tests: fix TestQPrefLog
There were several issues with these tests, including checking
the value argument against bool values even if the underlying
preference isn't bool.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:31:43 -08:00
jan Iversen
fc7aec5402 core/settings: make qPrefUnit accesable from QML
Use string literals to communicate with QML.

Instead of passing arounds enum/int value, it seems easier to pass string literals to QML and have that code respond to those

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-27 04:03:25 +09:00
jan Iversen
573a4a5e2d core: use set_lang_locale to modify prefs.locale.lang_locale
Do not set prefs.locale_lang_locale directly, but do it
indirectly through qPrefLanguage::set_lang_locale(),
to ensure the file plist is consistent with prefs.

the difference (prefs. contra plist) cause surprises
when restarting mobile (and playing with language).

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-27 03:41:20 +09:00
willemferguson
6212bb6721 Preferences UI: final cleanup
This commit does some final cleaning up to the code, mostly deleting
white space and comments.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-25 02:57:42 +09:00
willemferguson
b6c3cdb20c Preferences UI: add dive log tab
This adds a tab for dive log - related preferences.
A suitable test programs is still required.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-25 02:57:42 +09:00
willemferguson
b24caa4e2d Preferenced UI: add dive download tab
Add a preferences tab for dive download, allowing resetting the
buttons representing download connections in the Download panel.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-25 02:57:42 +09:00
willemferguson
2ac279d129 Pereferences UI: add media tab
Remove the preference settings dealing with thumbnails (currently under
General preferences and Profile preferences) and put them in a newly-created
Media preference tab.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-25 02:57:42 +09:00
willemferguson
3e853e37a5 Preferences UI: create new equipment tab
Remove the "Show unused cylinders" checkbox (Profile tab) and the
"Set default cylinder" qTextEdit box (General tab) and put them in a
separate and new Equipment tab. This sounds like a simple task but,
as can be seen from the files changed, was actually a complex matter.
Adapt the existing test programs (General and TechDetails) for creating
a test program that tests parts of the Equipment tab.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-25 02:57:42 +09:00
jan Iversen
7751ec1c78 build-system: move plannerShared to backend-shared
WARNING: multi directory commit, needed to secure it builds.

move the core/plannerShared.* to backend-shared.

update CMakeLists.txt to include backend-shared lib in link process.

update ios project to reflect new directory

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-24 08:44:23 +09:00
jan Iversen
9c52aaf043 build-system: move exportfuncs to backend-shared
WARNING: multi directory commit, needed to secure it builds.

move the core/exportfuncs.* to backend-shared.

update backend-shared/CMakeLists.txt to generate backend-shared lib

update CMakeLists.txt to include backend-shared lib in link process.

update ios project to reflect new directory

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-24 08:44:23 +09:00
jan Iversen
7181b7bcd1 core: correct include in exportfuncs
change include "dive.h" to "core/dive.h", in order to prepare
the file to moved away from core.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-24 08:44:23 +09:00
jan Iversen
f291e5e2d8 core: add convert between meter/feet to plannerShared
qPrefDiveplanner contains settings for ascent and descent in a neutral format.
diveplanner desktop uses a macro UNIT_FACTOR to convert between UI values and
qPref values.

In order not to dublicate these calculation (in C++ and QML) a set of shared
functions are made. The functions are identical to the calculations in diveplanner
desktop.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-24 06:30:57 +09:00
jan Iversen
c0069d6aee core: add plannerShared class
Add a plannerShared class, whose purpose is to contain shared
functions between mobile and desktop

This class is the inner workings of the diveplanner not the UI

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-24 06:30:57 +09:00
jan Iversen
bf7954ebe7 core: remove LOG_STP from mobile
LOG_STP is on longer providing the data needed, since a lot of the startup
is indirectly in QML, furthermore using the xcode project and running profiler
gives much more detailed information

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-13 07:04:00 -05:00
jan Iversen
820d9bcd56 core: divehare avoid race problem.
Do reply->readAll() before reply-deleteLater()

With UI deleteLater() seems to happen after the function exist,
but with QML it causes problems.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 10:10:01 -05:00
jan Iversen
aefe87112a core: divehare change slot names
change slot names from slot_* to *Slot

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 10:10:01 -05:00
jan Iversen
8ff19b6d54 core/settings: qPrefCloudStorage, correct diveshare_uid naming
The variable in Q_PROPERTY was wrongly named diveshare_userid

change diveshare_userid to diveshare_uid

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 10:10:01 -05:00
jan Iversen
85e6e90559 core: uploadDiveLogsDE::prepareDives no longer need to be public
Integration into desktop-widgets is complete.

Move prepareDives() from public to private

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 10:10:01 -05:00
jan Iversen
cb252f39d7 core: corrected timeout and error text problem in uploadDiveLogsDE
incorrectly stopped timer before the upload was started.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
5a4128a8f2 core: add uploadStatus signal to uploadDiveLogsDE
The uploadStatus signal can be used to inform the user about
the process e.g.
- preparing zip file
- starting actual upload

It is a suplement to uploadProgress, that only informs about
the network part.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
10ab833d7d core: make uploadDiveLogsDE slots workable for desktop
Secure that the slots/signals in uploadDiveLogsDE, which are without
UI, can be used in DivelogsDeWebServices (to add the UI part).

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
fa8acc0f40 core: rename slot in uploadDiveLogsDE
The difference between slot names and signal names was to insignificant
e.g. uploadFinish (signal) uploadFinished (slot).

Change slot names to slot_<name> should clear any confusion.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
d9f637a815 core: make prepareDives public in uploadDiveLogsDE
prepareDives needs to be public, in order to be used in
subsurfacewebservices.

"friend" is another option, but that gives subsurfacewebservices
too much freedom.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
49e6330399 core: make shared prepareDives identical to desktop prepare_dives_for_divelogs
In order to replace DivelogsDeWebServices::prepare_dives_for_divelogs with
uploadDiveLogsDE::prepareDives, first step is to make the functions identical.

amount_selected is not maintained for mobile, add #ifdef SUBSURFACE_MOBILE

Add comment, to make code more readable

add white line to make code more readable

change to use variable ds (created a couple of lines earlier

Avoid "goto" by adding close code

Remove label and close code (it was only called in 1 place)

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
738d3057da core: correct QString arg problem
use report_error directly, instead of making a QString first,
argument syntax are different (%s vs. %1)

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
976b2fc2a7 core: add timeout.stop() if upload successful
Stop timeout not only in case of errors, but also in
positive case.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
eb08f17a03 core: add upload divelogs.de class
The implementation is based on class DivelogsDeWebServices in
desktop-widgets but without the UI entanglement

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
42939ab7f8 core/settings: extend qPrefCloudStorage with divelogsde user info
Add divelogsde_userid and divelogsde_password to
qPrefCloudStorage to be used in Export.qml

Extending qPrefCloudStorage is more logical than adding QSettings
(and securing the same behaviour) outside qPref.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
fc740f6369 core: change uploadFinish() to include html
diveshareexport wants to show the HTML received
in a positive response, so signal cannot be
compatible with diveLogsDE

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 11:08:51 -05:00
jan Iversen
e3416fa152 core: copy doUpload from desktop-widgets to core
Add DiveShareExportDialog::do_upload() to
uploadDiveShare::do_upload(), while cleaning it from
UI.

Add signal connections as used in uploadDiveLogsDE

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 11:08:51 -05:00
jan Iversen
0a01072deb core/settings: extend qPrefCloudStorage with diveshare uid/private
Add diveshare/uid and diveshare/private to qPrefCloudStorage
to be used in Export.qml as well as diveshareexportdialog

Extending qPrefCloudStorage is more logical than adding QSettings
(and securing the same behaviour) outside qPref.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 11:08:51 -05:00
jan Iversen
e8e425edd8 core: add upload dive-share.com class
This is the framework that mobileExecutable needs, all
prepared to move functionality from desktop-widgets
(current implementation) into a shared version.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 11:08:51 -05:00
Berthold Stoeger
358fddd24e Filter: send filterReset via signal
The old code called directly into the DiveListModel. Instead,
send a signal and hook into the signal from the model. This
will allow us to remove the DiveListModel::instance() function.

This, in turn, is a step towards supporting multiple models
at the same time. However, currently the model manually
sets the hidden_by_filter flag in the core and therefore
only one active model is supported at a time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-10 18:45:30 -08:00
Berthold Stoeger
f4f9ba9263 Selection: provide convenience function for single-dive selection
Currently, selecting a single dive or deselecting all dives was
quite awkward: One had to pass in a single-dive vector and the
dive itself (as current dive). Provide a convenience function
that selects a single dive or deselects all dives if null is
passed in.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-07 10:23:44 -08:00
jan Iversen
90b8ccb705 core/settings: remove Q_PROPERTY warning in qPref headers
Q_PROPERTY contains an internal ";", making clang produce a warning
when ending the line with a ;

Remove ; at the end of Q_PROPERTY lines.

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-05 11:48:26 -08:00
jan Iversen
653a2baf11 core/settings: make qPref* constructors private
Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-05 11:48:26 -08:00
jan Iversen
54f8217eec core/settings: make qPrefGeocoding functions static
Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-05 11:48:26 -08:00
jan Iversen
d0dcc7b32a core: correct cloudstorage.cpp to use static qPrefCloudStorage functions.
qPrefCloudStorage set/get functions are static.

remove creation of qPrefCloudStorage instance, reference
static functions.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-05 11:48:26 -08:00
Berthold Stoeger
e114522a44 Cleanup: set description to null in free_[weightsystem|cylinder]
Currently, the caller is responsible for not reusing a freed
weightsystem / cylinder or resetting the description field to
null. This is very unfriendly. Set the description field to null,
because that allows us to call free_* repeatedly on the same
object. Use the new behavior to make the weightsystem model code
a bit cleaner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-05 10:14:25 -08:00
Berthold Stoeger
72c6b83866 Undo: make weight editing undoable
Implement the EditWeight undo command. Since there is common code
(storage of the old weight), this creates a common base class for
RemoveWeight and EditWeight. The model calls directly into the undo
command, which is somewhat unfortunate as it feels like a layering
violation. It's the easy thing to do for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-05 10:14:25 -08:00
Berthold Stoeger
ab99ca85f1 Cleanup: use free_weightsystem function instead of explicit free
Instead of freeing internal data of the weightsystem structure,
call the free_weightsystem function (which has to be made extern
at first). This makes things more future-proof, should the
weightsystem struct ever be extended.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-05 10:14:25 -08:00
Berthold Stoeger
dc67876c79 Cleanup: introduce empty_weightsystem constant
To make things more future-proof, introduce an empty_weightsystem
constant. Replace explicit aggragate initialization of empty
weightsystems by this constant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-05 10:14:25 -08:00
Berthold Stoeger
b3f530bfb9 Undo: make weight-deletion an undoable action
This one is a bit more complicated than weight adding, because the
multiple-dive case is not well defined. If multiple dives are selected,
this implementation will search for weights that are identical to the
weight deleted in the currently shown dive. The position of the weight
in the list is ignored.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-05 10:14:25 -08:00
Berthold Stoeger
147a36647c Undo: make adding of weights an undoable action
Introduce an AddWeight undo command. This is modelled after the
numerous dive-edit undo commands. The redo and undo actions are
connected to the WeightModel via two new signals, weightAdded
and weightRemoved.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-05 10:14:25 -08:00
jan Iversen
ed1264ce49 core: add dive_site export for mobile in Exportfuncs
DiveFilter is not available in Mobile, so another solution
is needed.

Use "for_each_dive_site" to loop over dive sites instead.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-05 10:11:42 -08:00
Berthold Stoeger
755f185cfc Selection: move selection of "first" dive to core
The DiveListView has a function to select the first dive. Move
this to the core to be able to call it from all parts (not only
desktop) of the code.

Currently, this has a (small?) UI regression: when filtering dives
and no selected dive is visible anymore, the old code would select
the first dive in the list. The new code selects the newest dive,
which might not be the first if some sort-criterion is active.

To revert to the old behavior, it will be necessary to move the
sorting function likewise to the core.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04 13:00:23 +01:00
Berthold Stoeger
ae753f4c4d Cleanup: remove superfluous includes from core/divelist.c
Most of these haven't been used in a long time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04 13:00:23 +01:00
Berthold Stoeger
4b1a3a1a6e Selection: move selection functions from divelist.c to selection.c
Since we now have a selection.c translation unit, put the selection-
related functions there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04 13:00:23 +01:00
Berthold Stoeger
7787bfbf9e Selection: move commands/command_private.* to core/selection.*
The file command_private.cpp had functions concerning selections
only. To make these functions accessible from outside the undo
machinery, turn it into a part of the core-library. Currently,
only C++ functions are exported. We might think about also
exporting a C interface.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04 13:00:23 +01:00
jan Iversen
4e690119ef core: add shared export functions (copy from desktop-widgets)
desktop-widgets/divelogexportdialog.* contains both the desktop
dialog as well as the "real" export functions.

Create a class to be shared between desktop and mobile

Copy the export functions 1-1 from divelogexportdialog.* of course
changing class names.

saveProfile is highly dependent on the UI, so the implementaion will
be done in each UI directory (desktop-widgets, mobile-widgets).

Remark this commit just add the copied functions, in order to secure
nothing is broken.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00