Commit graph

1639 commits

Author SHA1 Message Date
Berthold Stoeger
c0095f690f mobile/undo: compile undo commands and call undo command for deletion.
First steps towards full undo on mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:11 -07:00
Berthold Stoeger
730fd26814 mobile/divelist: connect click on trip to toggle MobileListModel
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
edeaf7fa57 mobile: remove collapsed model that we no longer use
The dive list now uses the mobile list model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
b382445e59 mobile/divelist: rewrite the QML dive list
This isn't perfect yet, but it looks fairly reasonable.

This commit was mainly written by Dirk, but includes a few fixes from Berthold
which where squashed into this commit as they really should have been part of
the initial version.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
90f8c1138e mobile/DC-download: be more careful exiting download page
Don't just pop the top page off the stack, but pop the download page.
Also explicitly switch to the dive list afterwards.

Additionally, fix a typo in the code that attempts to deal with the
shortcut buttons. I believe that right now this code is completely
broken, but while I contemplate how this should work, let's at least fix
the stupid typo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:40:44 -07:00
Dirk Hohndel
8138279a04 mobile UI: ensure download page is shown if started by plug-in event
The order of execution of the various routines is a bit counter intuitive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:40:44 -07:00
Dirk Hohndel
174bb91326 mobile UI: move code to open download page on device plug-in
This makes the code easier to reuse and uses the helper we just added.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:40:44 -07:00
Dirk Hohndel
93080f129d mobile UI: add consistent way to show a page
And have the existing shortcut functions use that helper.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:40:44 -07:00
Berthold Stoeger
2fcd4fff0a cleanup: fix NOCLOUD_LOCALSTORAGE leak
The macro NOCLOUD_LOCALSTORAGE creates the path to the local git
repository as a C-string. None of the users were freeing the string
and thus leaking memory.

Replace the macro by an inline function that creates a QString
and pass down to C-functions using the qPrintable() macro.
Note that every qPrintable() invocation does a UTF16->UTF8
conversion. This could be avoided by either using a std::string
or a QByteArray. However, we are talking about microseconds of
CPU time in operations that typically take seconds. Not worth
it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09 12:11:01 -07:00
Dirk Hohndel
fe932059fe usb-serial-for-android: switch detection to usb-serial and add more PID/VID
If we detect any of the known PID/VID combinations, use 'usb-serial' instead of
'FTDI'. Also add the now supported additional PID/VID combinations.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-08 11:21:54 -07:00
Dirk Hohndel
7d9e907681 debug: try to capture changes that don't invalidate git cache
At least in those cases where we are sending a divesChanged signal we can
easily check if the cache was properly invalidated. Of course this won't help
in cases where we don't notify the dive list about changes, either.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 18:47:34 -08:00
Dirk Hohndel
45d37fd51b mobile UI: remove obsolete access to already removed model role
We no longer have a dive role - on the plus side, we also don't use this
variable, so I guess this isn't a big deal.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 18:47:18 -08:00
Dirk Hohndel
b92b5998ff mobile UI: re-enable download status when restarting download
When tapping on 'retry' we didn't clear the flag that decided which message to
display.

Fixes: #2651

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 16:48:34 -08:00
Dirk Hohndel
97e26fd51b mobile: allow disabling BT support from the command line
This is a quick hack to reduce the noise in the log file when chasing other
bugs. Maybe this should not be enabled on release builds, but right now I don't
think the harm that having this in would do.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-06 10:00:13 +01:00
Dirk Hohndel
9f8d593a15 Mobile UI: fix typo in disabled planner setup
While this is disabled and is unlikely to be completed, the typo caused
confusion with translators.

This shows one of the weaknesses of the way we set up our translations, in that
always both desktop and mobile are translated together, and disabled code is
also included in those translations, causing unnecessary work for the
translators.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-04 08:03:44 -08:00
Berthold Stoeger
d6114fc37e mobile/filter: derive numShown from a new Q_PROPERTY
The number of dives was updated when the model of the list was
changed. Since we removed the multi-threading, the model is
not disconnected/connected anymore and therefore we don't get
the appropriate signal. Instead of introducing a different
signal, make the shown-value a Q_PROPERTY. Thus, we can easily
send a changed signal if we have to.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
4cff23ef7a mobile: remove filter settings
These are not used anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
eed4e2746d filter: don't search in background on mobile
I experienced weird crashes that seemed timing-related when
using the filter. Therefore, remove the multi-threading thing.
So far no more crashes, but keep a close eye on that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Dirk Hohndel
b5a427c880 mobile/filter: use more appropriate placeholder text
This way it matches the filter mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
e0766aa4bd filter: introduce people- and tags-filtering in the mobile UI
Add a combo-box where the user can switch between "fulltext",
"people" and "tags" filtering. Connect the combobox to the
already existing filter-code.

Dirk: make combo-box smaller by using a smaller font and restricting
the width. Setting both maximum and preferred widths gives more
consistent results.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-01 10:21:44 -08:00
Dirk Hohndel
140d552e6d mobile/profile: make the wait before dragging even shorter
Several users still found the wait too long - this is near instantaneous it
just ignores brief taps.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-25 10:17:57 -08:00
Dirk Hohndel
c6f73ae144 mobile/export: fix styling of radio buttons
Use the TemplateRadioButton to get the default styling - and by switching to the
RadioButton from Controls.2 we also get exclusivity by default.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-18 07:34:46 -08:00
Dirk Hohndel
4d72352e64 mobile/profile: enable zoom and pan for the QML profile
When running mobile on desktop there are some odd jumps in the mouse position while in
drag mode (press and hold, then move). They make the user interface seem jerky.
But I haven't observed the same behavior on the mobile device when testing. So
I'm not sure what to do with that.

Using opacity to indicate that the user is able to pan the profile seems reasonably
obvious; not sure if it's the best possible way to do this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-18 07:34:46 -08:00
Dirk Hohndel
3cf958e658 mobile/profile: add invisible rectangle around QMLProfile
This way we can clip the profile to it's designated size.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-18 07:34:46 -08:00
Dirk Hohndel
becaa1227f mobile/developer: add menu entry to temporarily enable verbose mode
One could argue that this should be a preference. I like the fact that it isn't
persistent, though.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-18 07:34:46 -08:00
Dirk Hohndel
d6c47ad362 mobile/export: fix horrendous user interface
This should never have been merged as it was. The UI was atrocious and the
functionality was by and large untested.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-17 10:50:51 -08:00
Dirk Hohndel
d8cc2b57b2 mobile/resources: fix incorrectly coded XSLT stylesheets
The prefix meant that on device these weren't found.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-17 10:50:51 -08:00
Dirk Hohndel
9e36968881 mobile/export: don't allow file based exports on Android
There is no native file dialog, access to the file system is highly restricted
and will be much more so in Android 11. Let's not even start with this.

This should never have been merged as it was.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-17 10:50:51 -08:00
Dirk Hohndel
0178f0c7e7 mobile/export: remove most of the export options
A tablet or phone is not a computer. What would you do with a CSV or TeX/LaTeX
file on a phone. Yeah, I get it, feature parity.

This should never have been merged.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-17 10:50:51 -08:00
Dirk Hohndel
b8c02c9b03 mobile/export: clean up whitespace
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-17 10:50:51 -08:00
Dirk Hohndel
619de80dfd mobile UI: restructure menu
This changes the 'GPS' entry to be called 'Location', moves the 'Map' entry
below that, and reuses the map icon for both the map inside this submenu and
for the main menu item.

It moves the 'About' entry under 'Help' and both 'Export' and 'Dive summary'
under 'Dive management'.

This way we have only five (or with 'Developer' enabled, six) entries in the
main menu making it much more appropriate for really tiny screens.

Additionally, the entrieis moved into sub-menus are ones that are not all that
commonly used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-13 14:01:34 -08:00
Dirk Hohndel
f915c45c43 mobile/summary: remove some debug output
I don't think we need that anymore.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-10 08:02:56 -08:00
Dirk Hohndel
4b3761861e mobile/summary: expand refresh button
Buttons ignore the width of the enclosed label and base their width on the
illogically named implicitWidth instead.

Also translate the button text.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-10 08:02:56 -08:00
Dirk Hohndel
57024d188c mobile/summary: more UI fine tuning
Creating more space for the header column and a little visual separation for
the different sections.

The commit is much smaller than it looks - try 'git show -w'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-10 08:02:56 -08:00
Dirk Hohndel
a7d1dbd013 mobile UI: fix font size breakage on Android
The pointSize() of a font can return -1 if the font was originally specificied
with a pixelSize. Work around this by using QFontInfo to calculate the correct
value.

Additionally, don't use the pointSize() of a font when we can instead use the
calculated size.

This fixes the problem with the missing star ratings on Android.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-09 16:45:04 -08:00
Dirk Hohndel
ba201eabc7 mobile UI: fix alignment issue in dive details view
The 'Map it' button could overlap with the dive number below, depending on font
size. This fixes the issue.

Reported-by: Peter Reinold <mcc.nash@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-09 12:45:55 -08:00
Jason Bramwell
caabf1b888 Correcting typos of the word celsius
Corrected typo of the word celsius in three files:
core/import-csv.c
core/divefileter.h
mobile-widgets/qml/Settings.qml

These were spelled as celcius but corrected these to celsius.
The 'core files were just comments but the mobile-widgets file would be
'active' code.

Reported by: tormento <turment@gmail.com>
Signed-off-by: Jason Bramwell <jb2cool@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-09 12:45:55 -08:00
Berthold Stoeger
2ec570098b Cleanup: remove exportFunc class
exportFunc was a collections of functions for exporting dive data.
It had no state, therefore there is no reason for it to ever be
instantiated.

Simply remove the class. Rename the saveProfile function to
exportProfile so that all export functions start with "export".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-09 12:13:18 -08:00
Dirk Hohndel
3bb9b08f33 mobile UI: correctly determine the number of columns when screen size changes
This also deals with a bug we had before where we didn't re-start the calculation
for the various sizes from the assumption of 'at least 21 grid units'. Now you can
rotate the device and the right thing will happen.

Small warning - this checks the orientation of the screen, which is exactly what
you want it to do on your device. When running mobile on desktop this may not be
what you expect. Even if the window has a portrait aspect ratio, your screen is
likely still landscape... so testing this feature in mobile on desktop mode is a
bit harder...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08 13:58:54 -08:00
Dirk Hohndel
96a56cf04d mobile/settings: add UI for single column preference
This is placed in the Advanced section as I expect this to be rather unusual
for people to enable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08 13:58:54 -08:00
Dirk Hohndel
6c7411c776 mobile/summary: use more intuitive time periods
No one will ask you about your dives in the last seven months (and the
existing code actually provided the past 210 days in that case). Instead
do more intuitive periods. Last month, quarter, half year, year.

Use Qt's ability to make sane date calculations easy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08 10:29:36 -08:00
Dirk Hohndel
fb057b7094 mobile/summary: improve the spacing of the content
Use more idiomatic ways to indent the rows, replace the TemplateLabel with a
simple Label since drawing the extra rectangle for the background of the
TemplateLabel is obviously redundant and using it doesn't change the number
of properties we need to set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08 10:29:36 -08:00
Dirk Hohndel
5f6b7450a9 mobile/summary: correctly align text to vertical center
I keep forgetting that the verticalAlignment is only within the current object,
which means that in a single line label it has no meaning at all.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08 10:29:36 -08:00
Berthold Stoeger
feab249bf2 mobile/summary: add refresh button
On tablet devices, the summary page stays open and therefore
the summary is not refreshed. For now, add a button. Later, this
should be connected to signals when dives are edited, added or
deleted.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08 10:29:36 -08:00
Berthold Stoeger
a93c303b8b mobile/summary: add section headers
Add section headers to the dive summaries on mobile by adding
a section-property. Of course, this will not work on desktop.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08 10:29:36 -08:00
Berthold Stoeger
1809dbd00a mobile/summary: remove dive summary calculation
Since we now use a model to calculate the dive summary, there
is no need to export recalculation of the dive summary via
QMLInterface.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08 10:29:36 -08:00
Dirk Hohndel
a5823a5b0d mobile/summary: implement frontend code for the new summary model
Implements the ListView and its delegate to use the dynamic data
provided by the DiveSummaryModel

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08 10:29:36 -08:00
Berthold Stoeger
48ccd114fc mobile/summary: recalculate first and last dive on visibility change
Recalcluate not only the statistics for the given period, but also
the global first and last dive date.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08 10:29:36 -08:00
Berthold Stoeger
f7c73f1987 mobile/summary: implement firstDiveDate and lastDiveDate
Instead of transporting the global first and last dive date
in the dive summary, calculate it in an external function.
Since we already have time and date functions in qthelper.cpp
implement those functions there. Provide a stub in QMLInterface
so that QML can access these standalone functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08 10:29:36 -08:00
Dirk Hohndel
988ccba710 mobile: prevent crash adding dives
When the cylinders became a dynamic data structure, a get_cylinder() call
suddenly could return a NULL pointer. So use get_or_create_cylinder() for the
first call when parsing the user's data.

Also, deal with an oddity where the string lists look different because an
empty list technically isn't the same as a list with one empty string.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08 10:26:21 -08:00
Dirk Hohndel
102f3bf295 mobile/notes-edit: ensure cursor stays visible editing dive notes
This seems to work much more reliably as it specifically compares the cursor
position to the visible bottom and top of the screen.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-07 14:01:23 -08:00
Dirk Hohndel
074dcfb656 mobile/settings: fix the width of cylinder drop down
The GridLayout isn't part of a Layout, so set its width and
have the combo box fill it's part of the grid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
5735c1f387 mobile UI: set correct width for TeplatePage
A page by default fits in a column.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
bb123c78fa random white space fix
QtCreator fixes that for me after every edit, I'm getting tired
of manually removing those hunks.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
eb410aee55 mobile UI: redo the screen size magic
This still is way to fragile. Ordering of object completion doesn't appear
consistent. Hopefully bringing the properties all into one (now reasonably
named) object will help.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
f1a08eb952 mobile: comment out planner references
I don't expect this to be complieted. I'll keep it in the tree
for the moment, but expect to remove all of the related code
eventually.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
f44e63b427 mobile/settings: correctly draw the size buttons
With the columnSpan 3 (in a grid with only two columns) they were drawn
on top of the drop down for the theme.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
b7433b15ff mobile/settings: refer to the correct theme object
This was missed when switching object names.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
b3994ffd3f mobile/settings: white space cleanup
Some odd empty lines and an unnecessary line break.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
2a0ba04d33 mobile/settings: make the color swatches work as color swatches
In a color swatch the color of the body of the swatch is the one that
matters. And we need to ensure readability. So for each pair of colors,
use the combination in the regular order (color/textcolor) for the
background swatch, and inverted for the text swatch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
0f33aee1af mobile/settings: correctly set label background
The TemplateLabel comes with a set background color which creates a very odd
effect and makes the text generally unreadable in the color swatches.
Fix this by matching the color of the parent rectangle.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Dirk Hohndel
f532aae2e9 mobile/settings: remove confusing frame around column titles
These are not color swatches like the rest, these are the column titles, so
don't draw them the same way as the color swatches.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-06 21:45:00 -08:00
Berthold Stoeger
5e0ce206a0 Cleanup: remove capture-all lambda clauses
These were forgotten the last time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 16:24:29 +01:00
jan Iversen
35de9c49a4 mobile-widgets: switch to new subsurfaceTheme
Remove subsurfaceTheme from main.qml
Replace ThemeNew -> subsurfaceTheme
change registration ThemeNew -> subsurfaceTheme

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:35 -08:00
jan Iversen
38120d555f mobile-widgets/qml: secure subsurfaceTheme.initial*
move initialWidth/initialHeight out of subsurfaceTheme to placeHolder,
this secures no change in behaviour.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:29 -08:00
jan Iversen
c3be85fbd9 mobile-widgets/qml/settings.qml: show all colors
Show all colors in a theme, allowing user to change theme.

This is preparation for allowing users to click on the individual
colors and change them.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:20 -08:00
jan Iversen
15fbcb655a mobile-widgets/themeinterface: make most part static
Make variables and functions static where possible, this is done
to prevent different versions of theme with different values.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:15 -08:00
jan Iversen
f16dc72556 mobile-widgets/qml: use new templates in converted pages
Use the TemplatePage and TemplateButton in the converted pages.

In order to avoid a bigger search/replace all other pages are left
untouched (for now).

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:06 -08:00
jan Iversen
3aa43f3ea5 mobile-widgets/qml: add TemplateButton
Do "git mv SsrfButton TemplateButton", and search/replace
all uses.

The general idea of the templates are to secure common layout,
but also to isolate the Kirigami parts (slowly) in the templates.

Signed-off-by: Jan Iversen <jani@apache.org>
2020-02-03 17:29:58 -08:00
jan Iversen
fb7920ef58 mobile-widgets/qml: add TemplatePage
Signed-off-by: Jan Iversen <jani@apache.org>
2020-02-03 17:29:51 -08:00
Berthold Stoeger
d27b6805f3 Cleanup: rename plannerShared to PlannerShared
Usually, we use PascalCase (i.e. camelCase with a capital
letter at the start) for class names. For consistency, let's
do it here as well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:17:52 +01:00
Berthold Stoeger
3b42de66dc Cleanup: remove QMLInterface::instance()
QMLInterface::instance() is only used in one single place. This
makes the whole notion of having a global instance of the object
moot, isn't it?

Simply make the object static to the function that uses it, which
guarantees that the object will be created when the function is
called. I.e. the same behavior is retained with less complexity.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-31 21:28:45 +01:00
Berthold Stoeger
188e513761 Cleanup: connect QMLInterface signals in constructor
It appears weird to connect the QMLInterface signal/slot combination
in a static helper function. This generates a bunch of lambdas that
call the instance() function.

Instead, simply do the connections in the constructor as we do it
in numerous other places.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-31 21:28:45 +01:00
jan Iversen
a65ec77263 mobile-widgets/qml/divesummary.qml: detect change in units
When either length or volume unit is changed, the text needs to be
changed.

Let signal lengthChanged and volumeChanged cause a recalcation and therefore
new text.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-30 19:51:50 +02:00
jan Iversen
906cce9e88 mobile-widgets: emit signals for each color
Emit signals for each standard color when theme changes.

The iconStyle property was changed from being a constant, because it can
change, and thus a signal was added.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:53:34 +02:00
jan Iversen
5a7ebe15a5 mobile-widgets: correct empty lines
Remove extra empty lines in themeinterface.cpp just a cleanup, no functionality
change.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:53:12 +02:00
jan Iversen
8339384eeb mobile-widgets/qml: move fontMetrics to ThemeTest
fontMetrics is no longer used in production code, but still in the theme test
page.

Isolate fontMetrics in ThemeTest page.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:52:57 +02:00
jan Iversen
3d871ef0de mobile-widgets: do not use fontmetric for height
In order to remove fontMetrics from QML, replace references (height)
in DownloadFromDiveComputer and Settings

Add include kirigami as needed

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:52:31 +02:00
jan Iversen
2cc215d3f2 mobile-widgets: move font property to themeInterface
Move setting of font properties used throughout to themeInterface.
Add new settings "currentScale".

The properties are kept in main (subsurfaceTheme) in order not to do
a big search/replace.

Update settings to use currectScale and signal changes in themeinterface.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:52:14 +02:00
jan Iversen
a3e3a30b70 mobile-widgets: move basePointSize to themeinterface
Check defaultfont and calculate basepointsize in themeinterface instead
of in QML.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:51:05 +02:00
Dirk Hohndel
08e39f9d2d mobile/dive summary: rewrite statistics code
There were quite a few issues with the code - clearly a complete failure of
code review.

- all values were '??' if a period contained no dives
- imperial units were not calculated at all
- significant truncation and data loss in the way totals were added as meters
  and minutes instead of the higher precision data that is available
- several issues in striing conversion methodology, e.g. missing zero padding
  for minutes
- missing maxSac
- incorrectly calculated avgSac
- incorrectly claculated number of EANx dives
- hard to read code with most variables named 'temp'

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:45:25 +02:00
jan Iversen
a534f1a25c mobile-widgets/qml: Fix Kirigami error.
Solve kirigami error:
INFO: qrc:/org/kde/kirigami/ScrollablePage.qml:187: TypeError: Cannot assign to read-only property "parent".

Kirigami.scrollPage does not allow a ListModel be defined, even though it is allowed in QtQuick.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-29 06:19:25 -08:00
jan Iversen
303b5865cd mobile-widgets/qml: add icon to dive summary entry
Add sigma icon to menu entry "dive summary".

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-28 15:34:34 -08:00
jan Iversen
7ebfdd6232 mobile icons: add sigma svg
Add svg sigma to be used for dive summary.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-28 15:34:14 -08:00
jan Iversen
2d8af34016 mobile-widgets: add dive_mode variable to QML
Add dive_move variable to qmlinterface, to make it aviable to QML.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-28 11:28:30 -08:00
jan Iversen
f424f9292e mobile-widget/qml/Settings.qml: correct theme switches
Replace subsurfaceTheme with ThemeNew, since there are still 2 objects
subsurfaceTheme in main.qml and ThemeNew in themeinterface.*

Replace theme color references with ThemeNew, as they are no longer available
in main.qml (subsurfaceTheme).

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-28 11:05:45 -08:00
jan Iversen
1d35942249 themeinterface: move registration to themeinterface
Move setup call and registration from subsurface-helper
to themeInterface, in order to keep the registration where the code
are.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-28 11:05:45 -08:00
jan Iversen
97e2890990 mobile-widgets/qml: integrate DiveSummary in menu.
Add DiveSummary to globalDrawer

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
b6e86a1c70 mobile-widgets/qml: add DiveSummary.qml
Add DivePlannerSummary, a page to show in dive centers.

Allow user to select period for the 2 colums in DiveSummary.

Default is "Total" and "3 month", but allowing the user to change
these, make it a very simple tool to view how the user progresses.

Variables are taken from Backend.

[Dirk Hohndel: adjusted text strings as these aren't really months]

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
6cd46bee06 divesummary: add DiveSummary class to shared and backend
Create DiveSummary class in backend-shared and make the DiveSummary calculation
results available to QML.

This adds a loop over all dives (could have been done with a model, but the
models available to mobile are very limited, so use the basic way).

[Dirk Hohndel: renamed the results variable and combined a couple of commits]

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
bb13065a75 mobile-widgets/qml: add background color property
Add property "colorBackground" to allow instances of templateLabel to have
background color overwritten.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
0920adf40f mobile-widgets/qml: correct spelling error
Correct spelling error in TemplateTitle.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
Dirk Hohndel
5b81997459 code cleanup: whitespace cleanup
A lot of whitespace issues have snuck in recently, this just cleans those up so
that I don't need to hand-edit patches every time I touch this file (since
QtCreator automatically fixes whitespace when I make changes).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-26 16:51:05 -08:00
Dirk Hohndel
2268b6b212 code cleanup: QLatin1Literal is deprecated in Qt 5.14
Simply replace it with QLatin1String. There is a tiny performance penalty,
but none of that code would care.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-26 16:49:42 -08:00
jan Iversen
df9164f7e5 mobile-widgets/qml: integrate ThemeNew in qml
Update Settings to use ThemeNew (for theme change)
Reduce subsurfaceTheme in main

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-26 16:42:35 -08:00
jan Iversen
9de296f3dd mobile-widgets: add themeInterface
Currently subsurfaceTheme resides in main.qml, where it does not naturally
belong.

Add C++ class that will replace subsurfaceTheme in main.qml in a 1-1 manner.

This opens future posibilities
- on top of the 3 themes, allow users to select colors/fonts
- add stylesheets to Template* components
- make day/night shift automatically.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-26 16:42:35 -08:00
jan Iversen
6584cd82d5 mobile-widgets/qml: correct backgroundcolor in setup
Use subsurfaceTheme in DivePlannerSetup.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25 17:26:11 -08:00
jan Iversen
3ff65dd7cf mobile-widgets: update design of TemplateSection
Update size and colors.

Changing the TemplateSection, automatically changes all sections
in the system, converted to the new layout.

The styling would be better in a style/theme class, but
subsurfaceTheme is in main.qml and not in a C++ class, so for now
use primitive styling.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25 17:25:54 -08:00
jan Iversen
a97a6d607c mobile-widgets: update design of TemplateSpinBox
The standard SpinBox uses far too much real estate.

The new SpinBox have a smaller footprint, and more visual effect.

Changing the TemplateSpinBox, automatically changes all spinboxes
in the system, converted to the new layout.

The styling would be better in a style/theme class, but
subsurfaceTheme is in main.qml and not in a C++ class, so for now
use primitive styling.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25 17:25:23 -08:00
jan Iversen
c1bbab6eaa mobile-widgets/qml: connect QML to Backend.
Add property pressureUnit to use as BAR/PSI text.

Added slot to catch when user changes BAR <-> PSI.

Add Backend variables to Planning section.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
ff360d28f5 diveplanner: add surface_segment to plannershared
Add surface_segment to plannerShared and then
update desktop-widgets.

Signed-off-by: jan Iversen <jan@casacondor.com>

desktop-widgets: use plannerShared for surface_segment

Change getter/setter for surface_segment to plannerShared, in
order to share the conversion with mobile diveplanner

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
995340b68a mobile-widgets: make planning vars available to QML.
Update qmlinterface.h with the planning variables (calling
plannerShared).

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
ee839fe5d9 mobile-widgets: make DECO_MODE and DIVE_MODE available to QML
Duplicate deco_mode to DECO_MODE, in order to make it available to QML.

Duplicate enum divemode_t to DIVE_MODE in order to make it
available to QML. Only part of the enum is made available.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
59ac506091 mobile-widgets/qml: correct reference in TemplateComboBox
theme is not available, use older subsurfaceTheme.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
8f6aaaba25 mobile-widgets/qml: graphic layout Planner (Planning)
Add all needed graphical elements for DivePlannerSetup
planning section.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
1e3879d87d diveplanner: add last gas variables to QMLInterface
Add bottompo2, decopo2 and bestmixend to QMLInterface

Bestmixend in gas options changing with
meter/feet

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
86fd49f2d7 diveplanner: adjust sac-factor calculation.
The real values are 1.0 to 10.0, but QML needs int so mobile
gets values 10.0 to 100.0

add sacfactor() to QMLInterface and update QML.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
cd3c2266f9 dive planner: correct bottomsac/decosac calc.
Move conversion cuft <-> liter from desktop-widget/diveplanner.cpp
to plannerShared, to facilitate the same results in mobile
diveplanner

Use Backend for bottomsac/decosac and update to check
for switch LITER <-> CUFT

Add bottomsac/decosac to QMLinterface.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
e55c740d84 diveplanner: call planner model directly for simple variables.
Variables without conversion, do not need to pass plannerShared
(due to the QML interface).

Simple variables do not pass plannerShared, but diveplanner
in desktop-widgets and qmlinterface in mobile-widgets call the
implementation directly.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
1e14c3f0d3 mobile-widgets/qml: add slot for volume change
Catch when volume type is changed and update bottomsac/decosac.

Also update text l/min <-> cuft/min and add a space between value and unit.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24 20:23:37 -08:00
jan Iversen
2ef0d23c29 mobile-widgets/qml: Add drop_stone to rates
Drop_stone_mode, when set, affect the descent rate, so place it alongside the
descent rate.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24 20:23:37 -08:00
jan Iversen
0710e610d3 mobile-widgets: add simple part of remaining planner variables
Add simple variables, where getter uses prefs. and setters call directly to set
function (without using plannerShared).

rename last_stop --> last_stop6m

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24 20:23:15 -08:00
jan Iversen
b0e46c208d mobile: move dive planner notes access to pure interface
Make notes rates available to QML through the Backend interface.
Remove the corresponding variables from plannerShared.

Getters are from prefs. while setters are linked to diveplan model.

Remark: signals from qPrefDivePlanner is used, because the diveplanner model
sets qPrefDivePlanner but do not issue special signals.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24 20:20:42 -08:00
jan Iversen
e22943fa21 mobile-widgets/qml: use Kirigami Units instead of hardcoded values
This allows for better scaling of the UI.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24 20:20:41 -08:00
jan Iversen
97376eb382 mobile-widgets/qml: add radiobuttons for single units.
For METRIC and IMPERIAL, show the radiobuttons disabled
For PERSONALIZED, allow user to select individual units.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-24 10:55:04 -08:00
jan Iversen
cc5b856280 mobile-widgets: use radiobuttons for Units
Change to radiobuttons for units, and add a third choice (personalize).

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-24 10:55:04 -08:00
jan Iversen
6db7e6d278 mobile-widgets/qml: use Backend instead of Planner
Use Backend instead of Planner for ascent/descent variables.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20 15:47:26 -08:00
jan Iversen
699665ce9e mobile-widgets: add asc/desc rates to pure interface
Make ascent/descent rates available to QML through the Backend interface.

Remark signals from qPrefDivePlanner is used because the diveplanner model
sets qPrefDivePlanner but does not issue its own signals.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20 15:46:08 -08:00
Dirk Hohndel
51a242a1db mobile UI: add ability to unset the default cylinder
This was requested in a 'bug report' by a user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20 15:39:22 -08:00
jan Iversen
6e06550631 core/settings:: remove string functions for units
Remove string version of unit_system, duration_units, length, pressure,
temperature, vertical_speed_time, and volume, including tests and make signals
strongly typed in C++

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20 09:55:26 -08:00
jan Iversen
75fe59b0da mobile-widgets/qml: use strongly typed units in QML
Change Settings and DivePlannerSetup to use the strongly typed enums

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20 09:49:36 -08:00
jan Iversen
25a5be0fe9 mobile-widgets: allow qPrefUnit strongly typed in QML
Add qPrefUnit Q_PROPERTY but using QMLInterface enums, that way
all variables become strongly typed in QML.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20 09:49:05 -08:00
jan Iversen
11c6851c74 mobile-widgets: move rest of gridlayout to section advanced
Create section advanced around the remaining gridlayouts, and adjust.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:59:48 -08:00
jan Iversen
5bce4895cc mobile-widgets/qml: create units section and move unit_settings
Move gridlayout unit_settings to TemplateSection units, without changing
anything (apart from adding a visible: attribute).

Removed first label in units_settings, since it is the title of the section

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:59:04 -08:00
jan Iversen
0443d7f2c9 mobile-widgets/qml: create theme section and move themesettings
Move gridlayout themesetting to TemplateSection theme and use the
TemplateTitle.  Also switch from using PrefDisplay.mobile_scale to
subsurfaceTheme.currentScale

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:56:13 -08:00
jan Iversen
ba7a8f68bc mobile-widgets/qml: move dive computers to general section.
move gridlayout divecomputers to TemplateSection general, without changing
anything (apart from adding a visible: attribute and replacing the Rectangle
used to draw a line at the bottom with a TemplateLine on top.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:54:54 -08:00
jan Iversen
3d239a7903 mobile-widgets/qml: move default cylinder to general section.
move gridlayout defaultCylinder to TemplateSection general, without changing
anything (apart from adding a visible: attribute and replacing the Rectangle
used to draw a line at the end with a TemplateLine at the top).

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:53:45 -08:00
jan Iversen
bf7464788e mobile-widgets/qml: move cloudSettings to general section.
move gridlayout cloudSettings to TemplateSection general, without changing
anything (apart from adding a visible: attribute and removing the rectangle
used to create a line).

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:52:47 -08:00
jan Iversen
12631ef2bb mobile-widgets/qml: add General section to Settings
ColumnLayout does not work well with TemplateSection,
so change to Column

Add TemplateSection "General Settings"

"General Settings" are open when visiting page first time.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:52:13 -08:00
jan Iversen
8ee39aa6b6 mobile-widgets/qml: bump versions for settings
bump import versions to reflect Qt 5.12
and remove unused imports

remark QtQuick 1 and QtQuick.Controls 1 are depreciated since Qt 5.12

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:51:56 -08:00
jan Iversen
96ec585179 mobile-widgets/qml: settings Control.TextEdit -> TemplateTextEdit
Replace Control.TextEdit with TemplateTextEdit, in order to use
common font/color scheme.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:51:48 -08:00
jan Iversen
ee1d5ba94e mobile-widgets/qml: settings Control.comboBox -> TemplateComboBox
Replace Control.ComboBox with TemplateComboBox, in order to use
common font/color scheme.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:51:19 -08:00
jan Iversen
2ce32277db mobile-widgets/qml: settings Control.label -> TemplateLabel
Replace Control.label with TemplateLabel, in order to use
common font/color scheme.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:51:06 -08:00
jan Iversen
da25b107a5 mobile-widgets/qml: add TemplateTitle
Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:50:31 -08:00
jan Iversen
bd06ec371c mobile-widgets/qml: add TemplateLine
Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:50:19 -08:00
jan Iversen
07c4d94f8a mobile-widgets/qml: add TemplateTextField
Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-19 11:50:10 -08:00
jan Iversen
93c3a18db7 mobile-widgets/qml: use strongly typed CloudStatus
Replace CloudStatus.<value> with backend.<value> as part
of making enum sharing between C/C++ and QML more robust.

Replace PrefCloudStorage.verification_status with
backend.verification_status to use the strongly typed function.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-18 17:35:16 -08:00
jan Iversen
c93b76eee6 mobile-widgets: make cloud_verification_status type proof in QML.
Add CLOUD_STATUS enum to interface.

Add cloud_verifification_status variable to interface, and make
it strongly typed in QML.

using backend.cloud_verification_status = 1 will fail but
backend.cloud_verification_status = backend.CS_UNKNOWN is correct.

Added note to the original definitions of the enums that they have been
duplicated.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-18 17:35:04 -08:00
jan Iversen
fdc2fd35bf mobile-widgets: add pure interface for passing values to QML
Add a header file that contains a duplicate of the enums,
that are needed in QML in one class.
the unit enums are added imidiatly, since they are needed
or will be neede shortly in Settings and DivePlannerSettings

This class will also contain Q_PROPERTY and signal/slot for
variables used in QML. This is done to allow e.g.

deco_mode qPrefUnits::planner_deco_mode()
void qPrefUnits::set_planner_deco_mode(deco_mode)
as strongly typed in C++
and
DECO_MODE planner_deco_mode()
void set_planner_deco_mode(DECO_MODE)
as strongly typed in QML
Remark: wrong assignments gives errors in QML

The advantage over using strings or the value directly is that
QML detects typos and flags them as errors/warnings.

It is important to note that the class may only contain
a) a function call to the implementation
b) a reference to a global variable e.g. prefs.

Added note to the original definitions of the enums that they
have been duplicated.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-18 17:31:58 -08:00
jan Iversen
fe8b7e3b72 mobile-widget/qml: add missing colors to dark theme
add missing colors so that dark theme contains the
same colors as "colors in use".

Update the darkTheme() to correctly copy colors from
pink theme

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-18 12:44:05 -08:00
jan Iversen
65a0a9c7eb mobile-widget/qml: add missing colors to pink theme
add missing colors so that pink theme contains the
same colors as "colors in use".

Update the pinkTheme() to correctly copy colors from
pink theme

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-18 12:44:05 -08:00
jan Iversen
f17aeb92e3 mobile-widget/qml: add missing colors to blue theme
add missing colors so that blue theme contains the
same colors as "colors in use".

Update the blueTheme() to correctly copy colors from
blue theme

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-18 12:44:05 -08:00
jan Iversen
5c2e08199f mobile-widgets/qml: secure block of used colors is correct
move contrastAccentColor, lightDrawerColor
to block of used colors in order to avoid confusion.

move darkDrawerColor to dark theme.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-18 12:44:05 -08:00
jan Iversen
bcfe505f09 mobile-widgets/qml: remove M126 warnings in main.qml
changed != --> !==
and == --> ===
to make QML happy.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-18 12:44:05 -08:00
jan Iversen
2d12d251b7 mobile-widgets/qml: columnWidth undefined
Remove reference to columnWidth, because it is
not defined in main.qml (subsurfaceTheme).

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-18 12:44:05 -08:00
jan Iversen
b25e791d13 mobile-widgets/qml: main reference qPrefGeneral.default_cylinder wrongly
change qPrefGeneral.default_cylinder -> qPrefEquipment.default_cylinder

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-17 08:51:04 -08:00
jan Iversen
59d72474d6 mobile-widgets/qml: change PrefGeneral -> PrefEquipment
default_cylinder was moved from PrefGeneral to PrefEquipment,
but Settings was not updated

update Settings.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-17 08:51:04 -08:00
Dirk Hohndel
de846bad96 whitespace cleanup
Since writing the file with QtCreator in the previous commit
pointed all these out...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-10 02:37:03 +09:00
Dirk Hohndel
e1cd055111 code cleanup: add empty table structures
It seemed to make sense to combine all three types in one commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-10 02:37:03 +09:00
jan Iversen
c77bad6c3e mobile-widgets/qml: secure text on ascent/descend get updated
When changing METERS <-> FEET, the text change automatically
between "m/min" and "ft/min".

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-04 10:56:55 -08:00
jan Iversen
d000cb2b0d mobile-widgetes/qml: standardize QML/C++ interface
Do not use a.set_b(value); it works, but it introduces yet another way of using
the QML/C++ interface, furthermore the function might not be called set_b in
some future, which is the reason the function is define in Q_PROPERTY

Use a.b = value, that respects Q_PROPERTY, and is slightly more performant,
most importantly it's like all the other settings so noone starts wondering why
this is special.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-04 10:56:55 -08:00
jan Iversen
342a8db93a mobile-widgets/qml: switch between m/min and ft/min
Set the text of ascent/descent rates.

This shows the correct speed units when the user switches between metric and imperial.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-04 10:44:02 -08:00
jan Iversen
6d6a4278c4 mobile-widgets/qml: reintroduce showPin
but the proper way, as a direct check on
PrefCloudStorage.

This secures PrefCloudStorage is only tested once and not
n times. As a sideeffect it saves typing and control.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2020-01-02 06:36:18 +09:00
jan Iversen
d7f87ee93c mobile-widgets/qml: add spinbox values to planner setup
(planning is excluded, due to not finished UI).

Connect all spinboxes with plannerShared.

This change allows live testing and compare with the desktop version.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-31 07:44:51 +09:00
jan Iversen
d83c74606d mobile-widgets/qml: add checkbox values
(planning is excluded, due to not finished UI).

Connect all checkboxes with plannerShared.

This change allows live testing and compare with the desktop version.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-31 07:44:51 +09:00
jan Iversen
360add37a8 mobile-widgets: remove qmlprefs.*
class is not longer used, remove it.
(also from qml)

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
e268af0d9f mobile-widgets: use oldStatus in qmlmanager
Switch oldStatus from qmlprefs to qmlmanager

This is the last use of QMLPrefs, which can later be safely removed.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
3d6d71aa9f mobile-widgets: add oldStatus variable to qmlmanager
oldStatus() is kept in qmlPrefs during the login process to allow
for a couple of special cases:
- if a user have added dives in NO_CLOUD mode and changes to use the
  cloud these dives are copied to the Cloud, instead of being lost.
- if a user does a bailout from the login process (this should not
  happen anymore) the old status is restored.

The pure solution would be to have oldStatus at the top level (e.g.
a property in qml) and only change it when actually being in the
login process, however due to way the qmlmanager is written it proved
very difficult and not worth the effort.

In order to be able to remove qmlPrefs, oldStatus are moved to
qmlManager.

This commit only contain the creation of the variable and the supporting
code.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
25e17443f9 mobile-widgets: remove showPin from qmlprefs
showPin is no longer used so remove it.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
a729d1a576 mobile-widgets: remove showPin from qmlmanager
Setting showPin is no longer needed, so remove it.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
b92c2d280c mobile-widgets/qml: remove prefs.showPin
prefs.showpin is the same as
PrefCloudStorage.cloud_verification_status === CloudStatus.CS_NEED_TO_VERIFY
but is actually implemented as a separate variable.

Removing showPin in order to limit use of QMLPrefs, which is the overall goal.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
5b3ecea4a0 mobile-widgets: remove setCredentialStatus() from qmlprefs
Remove no longer used function setCredentialStatus() from qmlprefs.

This is done to secure there are no missing setCredentialStatus calls
in the code.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
1fd6b59a21 mobile-widgets: remove second setCredentialStatus()
call setOldStatus() and set_filename().

saveCredentials() will adjust email and password.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
6084a27229 mobile-widgets: remove first setCredentialStatus() in finishSetup()
This setCredentialStatus() will never do anything, because qPrefCloudStorage
is identical to prefs.cloud_verification_status, and can thus be
safely removed.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
0c840ba22a mobile-widgets: remove setCredentialStatus() from saveCloudCredentials()
Revert to the divelist by setting oldStatus() directly to
set_cloud_verification_status()

This is done to further limit the use of setCredentialStatus() and
prepare to remove qmlPrefs.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
814f6b3579 mobile-widgets: remove setCredentialStatus from revertToNoCloudIfNeeded
Update revertToNoCloudIfNeeded() to not use setCredentialStatus() by adding an
extra call to setOldStatus()

setOldStatus() is called in setCredentialStatus together with
set_cloud_verification_status() therefore these 2 calls need to added when
removing setCredentialStatus().

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
dc98b0a2ac mobile-widgets: replace simple setCredentialStatus
qmlprefs::setCredentialStatus() basically only does something when called with
CS_NOCLOUD.

A number of setCredentialStatus() calls happen where status cannot be
CS_NOCLOUD, and therefore setCredentialStatus() can be safely replaced with
set_cloud_verification_status()

This limits the use of qmlprefs::setCredentialStatus(), but there are still a
couple of more complicated calls.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
783332561a mobile-widgets: credentialStatus() -> cloud_verification_status()
Replace all credentialStatus() with cloud_verification_status()

Where both prefs.credentialStatus and
PrefCloudStorage.cloud_verification_status are being set, remove
prefs.credentialStatus.

These replacements are valid since credentialStatus() is a simple
envelope over cloud_verification_status().

Also remove qmlPrefs::credentialStatus() from qmlPrefs (mostly to ensure no
replacements was forgotten).

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
beacc00f2d mobile-widgets: remove m_cloudCredentialStatus in qmlpref
Remove m_credentialStatus in qmlpref, but let the setter/getter
stay, using qPrefCloudStorage::cloud_verification_status()
instead.

This change ensures that qmlPrefs:credentialStatus() returns the
same as qPrefCloudStorage::cloud_verification_status(), and the
setter/getter of credentialStatus can later be removed safely.

This is a "checkpoint" to ensure everything works without a temporary
credentialStatus. No code part depend on the difference between
qmlPrefs::credentialStatus() and
qPrefCloudStorage::cloud_verification_status(), but the code reference
both.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 12:20:19 -08:00
jan Iversen
e80c27a2bd mobile-widgets/qml: correct missing parm in saveCredentials() call
Add missing empty pin ("") in saveCredentials() call.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:36:55 -08:00
jan Iversen
07ad455ea2 mobile-widgets/qml: prefs.credentialStatus -> PrefCloudStorage
Remove use of prefs. (apart from instanciating the object) in
main.qml

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:36:55 -08:00
jan Iversen
7e0e489d45 mobile-widgets/qml: "Add dive manually" is always allowed
Since the divelist is only visible if online/offline (CS_VERIFIED/CS_NOCLOUD),
there is no need to check that to enable "Add dive manually".

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:36:20 -08:00
jan Iversen
a73ce80eee mobile-widgets/qml: don't offer manual sync to cloud in no-cloud mode
Manual sync was enabled both for CS_VERIFIED (online) and CS_NOCLOUD (offline)
and then in the trigger CS_NOCLOUD lead to a login screen, potentially
confusing the user.

Only enable manual sync with verified cloud credentials.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:35:45 -08:00
jan Iversen
bdbaf72d27 mobile-widgets/qml: remove use of prefs. in DiveList.qml
prefs. is only important during the signin process, so use the standard
PrefCloudStorage variable

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
3cca6b9e9b mobile-widgets: remove cloudPin from qmlprefs
cloudPin is no longer used, remove it.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
e3a9166f46 mobile-widgets: remove cloudPin() from qmlmanager
cloudPin does only have the values "" and NULL, so replace cloudPin()
with "" in csa->backend() call

remove setting of cloudPin to ""

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
f1a48d7f79 mobile-widget: simplify saveCredentials() in qmlmanager
cloudPin is only set to "" and NULL, therefore and "if" checking if
cloudPin is not empty will never have affect.

Remove else part.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
3155b03917 mobile-widgets: make verifyCredentials() an internal function
Move verifyCredentials() from public slots to private, eliminating
the need to MOC and making the C++/QML interface on function less
complicated.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
096f9773f0 mobile-widgets: make saveCredentials() an atom
Add pin parameter to saveCredentials() thereby having all info about
credentials in one function call.

Add "" as pin in saveCredentials() - main.qml, when verifying
credentials.

replace verifyCredentials() with saveCredentials() in the register
button on the pin page.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
ad1c3892f9 mobile-widgets: remove clearCredentials()
clearCredentials() was only called from one place (in the same file), copy
functionality and remove function.

It was declared as a public slot, so this saves a little bit of overhead too.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
e944a93050 mobile-widgets: remove cancelCredentialsPinSetup() from qmlprefs
cancelCredentialsPinSetup() is no longer used, so remove it.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
de4e1c1efa mobile-widgets/qml: don't call cancelCredentialsPinSetup()
Copy functionality from cancelCredentialsPinSetup() into Cancel in
CloudCredentials.qml, this is part of the general qmlprefs cleanup.

Remove rootItem.returnTopPage() since the user stays on this page
(sees credentials again).

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
dc018cd77d mobile-widgets/qml: remove cancelCredentialsPinSetup() from Settings
For now just copy the functionality into Settings.qml, this is part
of the qmlprefs cleanup.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
baec098eb3 mobile-widgets/qml: correct reference to credentialStatus
PrefCloudStorage uses cloud_verification_status where qmlprefs uses
credentialStatus

Corrected reference.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
jan Iversen
944455a821 mobile-widgets/qml: remove property credentialStatus
Property is unused, remove it.

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28 08:34:56 -08:00
Dirk Hohndel
a2246753d8 mobile UI: add menu item for cloud password reset
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 01:16:23 +09:00
Dirk Hohndel
ab93e0f55c mobile UI: restructure help/support menu
Instead of having two entries on the main menu, move them into a sub menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 01:16:23 +09:00
Dirk Hohndel
69f06f7043 mobile: small whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 01:16:23 +09:00
Dirk Hohndel
56d959f733 mobile UI: add support and account icons
These were again copied from the material design icon set and will be used to
differentiate the various help topics.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 01:16:23 +09:00
Dirk Hohndel
5c0b864a55 mobile UI: add back button to planner menu
Otherwise you are stuck in there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 01:16:23 +09:00
Dirk Hohndel
602f49e012 mobile UI: remove confusing gDrawer id
The global drawer already has a name that can be referenced. This was adding
confusion as now both names were used in the menu structure.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29 01:16:23 +09:00
jan Iversen
25d2f9b84d mobile-widgets/qml: add "forgot password" button
The user is most likely to find out, that he does not remember
the password, when asked for it.

Add "forgot password" button in the signin dialog
(both credentials and pin dialog).

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-29 01:05:44 +09:00
jan Iversen
9e3d85f0e2 mobile-widgets: correct faulty connect.
1) add comment line (signal to signal)
2) correct spelling error in comment
3) correct connect

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-28 06:53:29 +09:00
jan Iversen
2d353a756b mobile-widgets/qml: correct first view of divelist
pageStack.initPage cannot be used as a function and causes an error

Replace with showDiveList()

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-28 02:21:20 +09:00
jan Iversen
af1ca2af81 mobile-widget/qml: avoid binding loop in GlobalDrawer
rightPadding seems defined in Kirigami and the default value
causes a binding loop.

set rightPadding directly.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-28 02:21:20 +09:00
jan Iversen
52b8a1304f mobile-widgets: remove envelope of saveCredentials
Remove QML saveCredentials since it only calls manager.saveCredentials

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-26 10:24:55 -08:00
jan Iversen
e9d519444d mobile-widgets/qml: correct Pin page
Did not switch to divelog page.

call verifyCredentials() not saveCredentials when checking pin

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-26 10:24:55 -08:00
jan Iversen
c4952b0dcb mobile-widgets: correct switch to no-cloud mode.
saveCredentials() missed parameters

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-26 10:24:55 -08:00
jan Iversen
b58d403906 mobile-widgets/qml: diveplannersetup graphical layout
Add graphical layout to setup page

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-26 10:21:30 -08:00
jan Iversen
0974c7524f mobile-widgets/qml: add diveplanner pages to globalDrawer
Add "Dive planner" menu entry in GlobalDrawer/Developer
with 4 subitems one for each diveplanner pages.

Developer is chosen in order to allow interested access to
pages, without raising expectations for the normal user.

That allow a step-by-step implementation

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-26 10:21:16 -08:00
jan Iversen
fac8d5b125 mobile-widgets/qml: add diveplanner pages
Diveplanner consist of 3 pages:
- Edit, creation of the plan
- View, view the plan
- Manager, list/delete/select stored diveplans

With the current navigation system (pageStack)
View needs to be split in multiple pages.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-26 10:21:11 -08:00
jan Iversen
800973a920 mobile-widgets/qml: add TemplateComboBox
standard font-size as well as color are set
in the template (but can be overwritten in
the object)

Using TemplateComboBox allows central change of how
labels are presented in the UI.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26 10:18:11 -08:00
jan Iversen
f44fa1aa27 mobile-widgets/qml: add TemplateCheckBox
standard font-size as well as color are set
in the template (but can be overwritten in
the object)

Using TemplateCheckBox allows central change of how
labels are presented in the UI.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26 10:18:10 -08:00
jan Iversen
43b813d58e mobile-widgets/qml: add TemplateRadioButton
standard font-size as well as color are set
in the template (but can be overwritten in
the object)

Using TemplateRadioButton allows central change of how
labels are presented in the UI.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26 10:18:10 -08:00
jan Iversen
6c8dae5a04 mobile-widgets/qml: add TemplateSpinBox
standard font-size are set in the template (but can
be overwritten in the object)

Using TemplateSpinBox allows central change of how
spinBoxes are presented in the UI.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26 10:18:09 -08:00
jan Iversen
99cce7e807 mobile-widgets/qml: add TemplateLabel
standard font-size as well as color are set
in the template (but can be overwritten in
the object)

Using TemplateLabel allows central change of how
labels are presented in the UI.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26 10:18:09 -08:00
jan Iversen
8468d28a41 mobile-widgets/qml: add TemplateSection
TempleSection is a clickable rectangle that contains
information.

It is used to
- group information
- hide/unhide details

And are an important building block in decluttering small
screen, while showing all information on bigger screens

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26 10:18:08 -08:00
jan Iversen
9c74ac23a5 mobile-widgets/qml: remove console messages
Remove console.log messagees used to test the
split of startpage/divelist.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-27 01:29:30 +09:00
Dirk Hohndel
3dbdd2ee5e mobile UI/login: fix PIN entry page
In commit a4d299e01e ("mobile-widgets/qml: use showPin/oldStatus consistently")
one instance of rootItem.showPin wasn't replaced with prefs.showPin and as a
result we had a very strange password entry line in the middle of the PIN entry
screen.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 15:53:15 -08:00
jan Iversen
611c4bb088 mobile UI/login: move startpage to main
StartPage does not belong in divelist.

Remove startPage from diveList and anchor in main.

Make needed functional changes.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 15:53:15 -08:00
jan Iversen
11810d5d06 mobile UI/login: remove startpage dependency in divelist
DiveList should not depend on StartPage, so remove references to
startPage.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 15:53:14 -08:00
jan Iversen
b83dcc4b25 mobile UI/login: make divelist a proper object in main
Instanciate DiveList like all the other pages.

Move DiveList properties set in main to DiveList.qml

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 15:53:14 -08:00
jan Iversen
4687de8c82 mobile UI/login: clean startPage/setupActions from Divelist
setupActions() in StartPage contained a mixture of StartPage
actions and DiveList actions.

Split setupActions to be pure.

However currently StartPage is embedded inside DiveList so the
action onVisibleChanged must be simulated.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 15:53:13 -08:00
jan Iversen
d1bee58dad mobile UI/login: move onCompleted actions to main
manager.finishSetup() have nothing to do with startpage/divelist,
but belong in main (seeing main as responsible for setup and window layout).

Move onCompleted functionality to main.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 15:53:11 -08:00
jan Iversen
48bae80577 mobile UI/login: remove cloudPassword from QMLPrefs
cloudPassword is no longer used as a temporary variable

Remove cloudPassword from QMLPrefs.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 10:24:41 -08:00
jan Iversen
5af7727ad0 mobile UI/login: replace use of cloudPassword
Replace prefs.cloudPassword with PrefCloudStorage.cloud_storage_password in QML

Replace QMLPrefs.....cloudPassword with PrefCloudStorage::cloud_storage_password in C++

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 10:24:15 -08:00
jan Iversen
a97cc83458 mobile UI/login: remove cloudUserName from QMLPrefs
cloudUserName is no longer used as a temporary variable.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 10:23:11 -08:00
jan Iversen
ac28896a5d mobile UI/login: replace use of cloudUserName
Replace prefs.cloudUserName with PrefCloudStorage.cloud_storage_email in QML

Replace QMLPrefs.....cloudUserName with PrefCloudStorage::cloud_storage_email in C++

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 10:22:39 -08:00
jan Iversen
4b713ece96 mobile UI/login: do not revert to old credentials.
If the user asked to change credentials it is equivalent to a signout,
so no need to store old credentials. This simplification allows removal
of the temporary credentials in qmlPrefs.

this commits secures the user is locked in the login page, until one
of 3 things happen:

- enter verified credentials (divelist is loaded from cloud)
- select no-cloud mode (divelist is loaded from local)
- enter new credentials, PIN page shows, enter PIN or
  cancel (back to enter credentials).

This is consistent even if the program is restarted.

Old version had a non consistent way:
A user enters new credentials,
  sees the PIN screen,
  but does not receive the email immediately,
  so works with other applications (causing the mobile app to close)

Having received the email with the PiN,
  the user starts mobile again,
  BUT does not see the PIN screen, instead the old credentials are used.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24 10:17:45 -08:00
jan Iversen
9117aa2a52 mobile-widgets: make saveCredentials() an atom
Call saveCredentials with username/password to avoid first
setting the two and then calling.

Change saveCredentials() to use newUser, newPassword.

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-25 03:15:52 +09:00
jan Iversen
e92dbe7974 mobile-widgets/qml: clean whitespace in main.qml
Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-25 03:15:52 +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
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
a4d299e01e mobile-widgets/qml: use showPin/oldStatus consistently
Remove aliases for showPin/oldStatus and reference prefs.showPin/oldStatus directly.

showPin/oldStatus are "temporary" variables, that are not saved in settings,
so they easily be replaced

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-24 08:25:51 +09:00
jan Iversen
ab28008679 new mobile login: remove non existing function from CloudCredentials
the function manager.accessingCloud is not defined in QMLManager.h

Remove manager.accessingCloud.

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-24 08:25:51 +09:00
jan Iversen
1468af3519 new mobile login: remove saveCredentials() from StartPage.qml
The local qml function saveCredentials() in StartPage are not used.

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-24 08:25:51 +09:00
jan Iversen
5f5d4ffbc9 mobile-widgets/qml: disable global drawer in startpage
Do not show global drawer when user is doing login.

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-24 08:25:51 +09:00
jan Iversen
d48a748a25 mobile-widgets: limit use of QSettings in qmlmanager
Replace QSettings for userName/Password/credentials with proper qPrefCloudStorage calls

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-24 08:25:51 +09:00
jan Iversen
7503242914 build-system: Add CMakeLists.txt to mobile-widgets
In order to make the central CMakeLists cleaner and more consistent
add a CMakeLists.txt to mobile-widgets, like in other root directories.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-24 06:18:36 +09:00
jan Iversen
9d74b4dc82 mobile-widgets/qml: remove use of eval()
eval() cannot be used in combination with the Qt5 qml compiler,

replace eval() with switch statements.

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-24 03:52:40 +09:00
jan Iversen
161bedf58d mobile-widget: use qPref variable
change prefs.cloudUserName to PrefCloudStage.cloud_storage_email.

This is slightly more effective (direct instead of indirect), and
reduces the use of prefs.

This is part of limiting the use of prefs. (which is a precessor to
qPref) to the login process, and ultimately remove it.

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-18 13:26:29 +09:00
jan Iversen
1dd7d9df3a mobile-widget: correct set of default_cylinder
set_default_cylinder is accepted, because it is defined in Qt Meta system,
however the call is never carried out, because the Q_INVOKE macro is missing

Change PrefGeneral.set_default_cylinder(...) which is a function call
to PrefGeneral.default_cylinder = ... which is a builtin assignment

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-18 13:26:29 +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
080ddc0df2 mobile/qml: Integrate/activate diveshare in Export
Integrate diveshare in Export
Activate diveshare radio button

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 21:35:55 -05:00
jan Iversen
53069fe777 mobile-widgets: activate uploadDiveShare in qmlmanager
Remove "TO BE IMPLEMENTED" and add call doUpload

Connect signal to signal in QMLManager to avoid registring the
upload class.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 21:35:55 -05:00
jan Iversen
dd183eaabf mobile/qml: Clear status field in Export
When opening the saveAsDialog a second time, it contains
the last status from first time.

Clear statusText before calling saveAsDialog

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 10:10:01 -05:00
jan Iversen
786b0db724 mobile/qml: make close dialog in Connect work
When using Connect, the context is switched, so close()
might or might not work.

Change unqualified close() to qualified uploadDialog.close()

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 10:10:01 -05:00
jan Iversen
adedfe5965 mobile/qml: remove empty line
Remove empty line that does not make sense.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 10:10:01 -05:00
jan Iversen
a2717c558a mobile/qml: close upload dialog if success
Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
1d74eb509f mobile/qml: handle upload signals
Add uploadFinish and uploadProgress to Export page

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
4b2cae3f7c mobile-widgets: make upload signals available to QML
Connect signal to signal in QMLManager to avoid registring the
upload class.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
5cba410aa6 mobile/qml: close export page after upload
pop from pagestack.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
422bb0da57 mobile/qml: add pref suppport for userid in Export
Handle reading/writing of userid/password settings in the
saveAsDialog and set field to visible when needed.

Activate divelogsde radio button

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
03c9cdfbed mobile-widgets: activate uploadDiveLogsDE in qmlmanager
Remove "TO BE IMPLEMENTED" and add call doUpload

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
5aba24248f mobile/qml: correct typo in Export.qml
Correct default value for export type.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
190b024bec mobile-widgets/qml: add divelogsde stylesheet to resources
Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
936362c102 mobile/qml: activate dive_site export in UI
Dive_site export is now implemented in Exportfuncs, so
allow users to select it.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-05 10:11:42 -08:00
jan Iversen
599984d44a mobile-widgets/qml: close Export page after export (or cancel)
Remove page from pageStack, which removes the page from user view.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-05 09:57:06 -08: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
jan Iversen
92b56d0583 mobile-widgets/qml: block profile export (temporary)
The current png generation is intertangled with the desktop
UI, and a shared Webservice needs to be developed.

Block Radiobutton

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
d2b633b2a8 mobile-widgets/qml: block DiveLogs.de and DiveShare export (temporary)
The current Webservice implementation is intertangled with the desktop
UI, and a shared Webservice needs to be developed.

Block Radiobutton

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
c6348e96de mobile-widgets/qml: block dive sites export (temporary)
DiveFilter have 2 implementation on or desktop and one for mobile,
the common export function uses DiveFilter (desktop version).

Block Radiobutton

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
117aa13dbe mobile-widgets/qml: add upload dialog to export page
divelogs.de and diveShare are web uploads, which need a special
custom dialog.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
093813698c mobile-widgets/qml: add filedialog to export page
All exports are to file except 2 which are upload to web.

Integrate standard qml filedialog for all exports (minus 2).

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
5307cbc1c7 mobile-widgets/qml: integrate export page in main.qml
Add export function to GlobalDrawer, allowing the user to
export the divelog.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
578abeda80 mobile-widgets/qml: add export page
Prepare page for exporting the diveLog (feature currently
only in the desktop version).

Add Radiobuttons to select type of export
also add "anonymize button"
and a "explain" text field

Subsurface-mobile does not allow selection of dives, therefore
export will always be all dives

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
86aa96936a mobile-widgets/qml: add export stylesheets as resource
Add export stylesheets to mobile-resources.qrc to ensure
they get installed.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
27ce89a6e5 mobile-widgets: add export functionality to qmlmanager
Add enum with different export types (used to signal which type
of export QML desires).

Add QML export functions (one for file and one for upload to web)

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
jan Iversen
7eda75d7ab mobile-widgets/qml: add qmldir to include map-widget
qml demands all qml files to be in 1 directory, but allows
a "qmldir" file to reference qml files in other directories.

Add qmldir to reference map-widget.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-11-26 09:44:13 -08:00
Dirk Hohndel
1b058d58f7 Mobile: make it clear that 'all BT devices' setting is temporary
Making this persistant creates a very unpleasant user experience.
And if a dive computer needs this setting, we really want people
to report this to us so we can fix it.

Fixes: #2358

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-22 16:53:29 -08:00
jan Iversen
bd7357238f mobile-widget/qml: correct syntax error introduced in e63257f0e
default parameter values is not supported as this syntax was introduced
in ECMA-262 6th edition while QML only implements the fifth edition
(as of Qt 5.11).

remove default parameter and check for undefined instead.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-11-11 20:44:35 +01:00
Dirk Hohndel
4f0d437f1e Mobile: add ability to directly open support email
This is even easier and more obvious than copying the logs on the About page
and then manually creating an email and pasting those logs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-10 21:59:32 +01:00
Berthold Stoeger
794066b236 Cylinders: access cylinders with get_cylinder()
Instead of accessing the cylinder table directly, use the get_cylinder()
function. This gives less unwieldy expressions. But more importantly,
the function does bound checking. This is crucial for now as the code
hasn't be properly audited since the change to arbitrarily sized
cylinder tables. Accesses of invalid cylinder indexes may lead to
silent data-corruption that is sometimes not even noticed by
valgrind. Returning NULL instead of an invalid pointer will make
debugging much easier.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
7c9f46acd2 Core: remove MAX_CYLINDERS restriction
Instead of using fixed size arrays, use a new cylinder_table structure.
The code copies the weightsystem code, but is significantly more complex
because cylinders are such an integral part of the core.

Two functions to access the cylinders were added:
get_cylinder() and get_or_create_cylinder()
The former does a simple array access and supposes that the cylinder
exists. The latter is used by the parser(s) and if a cylinder with
the given id does not exist, cylinders up to that id are generated.

One point will make C programmers cringe: the cylinder structure is
passed by value. This is due to the way the table-macros work. A
refactoring of the table macros is planned. It has to be noted that
the size of a cylinder_t is 64 bytes, i.e. 8 long words on a 64-bit
architecture, so passing on the stack is probably not even significantly
slower than passing as reference.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Dirk Hohndel
15674f1a71 Mobile: modify filter so that all models get notified
When we change the filter string, we need to make sure that the collapsed model is
also aware of the change.

Similarly, instead of just calling resetFilter and directly changing the core
data structures, we need to set the filter to the empty string which ensures
that all three models get notified and the view updates correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
20fda8afc3 Mobile: reconnect the correct model after changing filter
This caused a blank, unusable dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
ae27dd77a7 Mobile: consistently refer to the dive list model
The number of different ways we tried to refer to the model made my head spin.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
9e09a7d920 Mobile: ensure there's some space between date and depth/duration
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
8b0f4e65d3 Mobile: use the CollapsedDiveListSortModel for dive list
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
c759157331 Mobile: setup CollapsedDiveListSortModel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
b01e9fb0a8 Mobile: derive the index from the dive id
The previous code assumes that both the vertical dive list and the list of dive
details which allows the horizontal swiping from dive to dive are based on the
same model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
9d9047d040 Mobile: give visual indication that we are saving dives
Allow showing that the app is busy and showing why at the same time.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
e63257f0e9 Mobile: allow message argument to showBusy function
When called without arguments, no message is shown.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
505ff4032a Mobile: add UI feature tests to Developer menu
Running Subsurface-mobile on iOS, the notification texts are sometimes very
hard to read, and in some situations the busy indicator isn't showing up at
all.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
3a7b8d73d8 Mobile: let the user know if we can't save changes
While the error that caused this to happen should be fixed, we should at least
let the user know if things failed catastrophically and we can't figure out how
to save their data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
ccace53b83 Mobile: remember if we were able to open the local cache
If there is a local cache, we at least once successfully accessed the cloud, so
this is a valid cloud based git tree.

Without this change we run into a subtle bug: after a fresh install, or when
switching users, when the cloud data is accessed the very first time, we don't
remember that this was indeed loaded from the cloud. So if we then download
from a dive computer or make any other changes to the dive log, we cannot save
those dives to cloud storage - but we fail silently doing so. Which to the user
would look that inexplicable data loss.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
08e2013d1e Mobile: remove useless attempt to prevent access to the cloud
This code really made no sense, adding a comment to try to explain that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
4111de70e8 Mobile: drop extra argument to QString
Clearly a cut and paste error. Only creates a harmless warning, still...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
f1e7adfedc Mobile: don't dereference the dive list model when it's disconnected
This avoids a bunch of annoying warnings.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-03 04:02:00 -08:00
Dirk Hohndel
9f34f4f97d Mobile: disconnect model while updating dive list
If the dive list is connected to the model while the model is updated
with the downloaded dives, sometimes the UI hangs completely.

Disconnecting the model and then reconnecting it does add a fairly
noticeable delay on longer dive lists, so there are tradeoffs here.

Of course the obvious solution is to make reconnecting the model
faster...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-03 04:02:00 -08:00
Dirk Hohndel
113cb1acc0 Mobile: use appendTextToLog to get timestamps in logs
This helps tremendously when tracking down some problems. We should
never use console.log.

In the process this also updates a couple of the messages to be clearer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-03 04:02:00 -08:00
Dirk Hohndel
d401271dab Mobile: make the GPS service icon work again
I don't recall when this stopped working.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-27 12:42:38 -07:00
Dirk Hohndel
fdf03966d4 Mobile: ensure we go back to the dive list after download
The pop() by itself wasn't enough to do that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
d709cfb0b8 Mobile: try harder to get the right dive list
This should ensure that the dive list correctly repopulates after the model
was updated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
65910177b2 Mobile: also show busy spinner when applying GPS fixes
That's another function that can take a little while.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
9b6ec64853 Mobile: simple message and busy spinner while storing downloaded dives
Due to some recent changes processing the downloaded dives and
re-displaying the dive list can take quite a while. So show a small
message and the busy spinner to warn the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
84920fd657 Mobile: change show/hide busy functions
The old code was ill named - this way the busy spinner itself
becomes reusable with a reasonable set of function names.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
bf6a644fc6 Mobile: provide better tracking of applied GPS fixes
Also reset the page stack to make sure we don't end up with stale data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
4c55074bd7 Mobile: more code to deal with undefined elements
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
dc5f22d047 Mobile: reset dive list after applying GPS fixes
This way new fixes are actually shown when the user looks at the dive
list after applying the GPS fixes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
e03d3ac5d6 Mobile: don't show nothing for the location
We use 'Dive details' as page title, everywhere else we use
'<unnamed dive site>'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
320d2c47aa Mobile: fix incorrect variable dereference for dive site
Since we are accessing the model, this is the variable we should use.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
f69b93de40 Mobile: don't push map page if it's already on the stack
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
4e583f9120 Mobile: avoid dereferencing undefined values
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
face9ba1a8 Mobile: fix cacheBuffer for log window
The old value made no sense at all. Why would we want to cache up to 10k
entries of the log?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
e6298f9352 Mobile: allow editing dive number
No checks regarding duplicate numbers - we trust the user knows what
they are doing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-21 15:50:41 -04:00
Dirk Hohndel
158a2ec159 Mobile: remove remaining accesses to DiveObjectHelper from QML
Add a couple more roles and remove the dive role that allows accesss to
the DiveObjectHelper in the first place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-20 16:08:55 -04:00
Dirk Hohndel
613a3112d2 Mobile: get dive details directly from the model
By getting a DiveObjectHelper and then dereferencing that we ended up
creating hundres and hundreds of these objects, only to immediately
destroy them after using a tiny part of the data.

Instead make those data available directly from the model, without
having to create a DiveObjectHelper forst.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-20 16:08:55 -04:00
Dirk Hohndel
01f1bea995 Mobile: ensure input fields stay visible after keyboard opens
When the user taps on a TextField to enter text, usually the virtual
keyboard will pop up. This code tries to ensure that the keyboard
doesn't cover the entry field that the user was trying to work on.

In order to centralize these changes, this introduces a new
SsrfTextField type which we use to also remove a few redundant default
settings that we previously had for every field. The one TextArea for
the Notes field didn't seem worth creating yet another type for, so
there the changes are done directly in DiveDetailsEdit.

The awkward timer mechanism is necessary as the keyboard pops up
asynchronously and then triggers a change of height for the app, so we
need to wait a little bit before doing the adjustment.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-14 13:39:45 -07:00
Dirk Hohndel
85d810119b Mobile: pick icons depending on theme
QML has ways to style icons - and we use that for the main theme color,
but it doesn't seem to work (anymore?) for the edit and save icons.
Instead of tracking down what changed there, simply switch between icons
with different foreground color, depending on theme.

All the other icons seem to work well in all three themes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-14 13:39:45 -07:00
Dirk Hohndel
5f11c94f02 Mobile: improve helper function to track selected dives
While on mobile there should always be only one selected dive, it's very
cheap to make sure that amount_selected is tracked correctly.  The
incrementing of amount_selected is done in case an invalid id is passed
in.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
fe56fa587a Mobile: bring back the adaptive size for the tool bar
When switching to the global tool bar this was lost, and then it turned
out to be broken and required more patches to fix.

Commented out because it doesn't work at all.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
56713842b9 Mobile: ensure consistent path when accessing arrow icons
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
e3eaf03d2f Mobile: implement our own back entry for GlobalDrawer
This way we'll get a working back icon on Android and also correct font
size for the (translated) Back text.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
fda10b8baa Mobile: update the map when the selected dive changes
Now we see the highlighted dive flag match the dive selected in the dive
list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
9a73be9207 Mobile: add helper function to keep selection in sync
Without this the core data structure never gets updated to reflect which
dive is currently selected.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
2f0689d3b8 Mobile: move pageIndex function to main.qml
This way it can be more easily called from other pages.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
2ef401ef5f Mobile: when selecting dive via map, expand its trip
Previously if the dive was in a different trip, we'd scroll to that trip
but not expand the trip, which was a confusing user experience.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
6422079de5 Mobile: when selecting dive via map, update details view
We updated the selected dive in the dive list, but not the one shown in
the details view.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
b07a1cc8b6 Mobile: when switching to the details, reuse existing page
While pageStack.push() can handle pushing a page that's already there,
that creates an unfortunate sequence of currentItemChanged signal which
leads us to do the wrong thing with our map hack.

This commit changes things around to first look for the page in the page
stack and just switch to it, and only pushing the page as new if it
cannoot be found oon the page stack.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
d8cc8732bd Mobile: use tri-state variable to improve the map hack
QML enums are a bit painful to use, so this uses poor man's emums
instead.

Basically what this changes is that a forced switch to the map doesn't
count as picking the map. That seems obviously correct, as otherwise you
could end up in a situation where a legitimate switch away from the map
is ignored.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
4e4fcda91c Mobile: insane hack to make map page work
This makes no sense and seems crazy. But it also seems to work,

For some reason with the current Kirigami version and Qt 5.13.1
selecting the map page makes the pageStack jump back to the previous
page right away. I cannot find what triggers this behavior.
Since I cannot fix the root cause, I am working around the bug. When we
select the map page we remember that fact and when a different page is
picked with the mapPage being the last page on the stack, we force the
page selection back to the map page. I can imagine countless ways in
which this could go horribly wrong - but right now I can't figure out a
better solution.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
8cd1abb7f7 Mobile: keep existing page stack when showing map
There doesn't appear to be a reason to pop all of the existing pages from the stack.
Just on principle, only close the drawer if it was open.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
a200ac0982 Mobile: need to recalculate column width when rotating
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
5025943bc4 Mobile: don't make sub-pages fill the parent
This had very strange results with the current Kirigami.
Instead set the width of those pages based on our overall column width.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
b9861a0059 Mobile: change handling of columns and column width
The old calculation was clearly bogus, we'd also get zero columns here.
Instead do a correct calculation of the number of columns and make the
resulting column width a property of the rootItem so we can refer to it
elsewhere.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
e047e97190 Mobile: ApplicationHeader is now deprecated
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
57d50d0101 Mobile: show the undo for delete for 5 seconds
Before that it was 3 seconds that was a little too short for peopl to
be happy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Paul Buxton
65ec16e59d Fix text in darkmode on mobile app.
Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
2019-10-06 11:39:46 -07:00
Berthold Stoeger
3db50aedea Cleanup: Turn DiveListSortModel into classical singleton
To make this class available from QMLManager, the run_ui()
function would create the object and then set a pointer in
QMLManager. It works, but is inconsistent with the rest of
the code. Therefore, make it a classical singleton class,
which is generated on demand.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-04 09:19:10 -07:00
Dirk Hohndel
e7e21aec6b Mobile: fix reloading dive list after download
There was a sad typo in commit eecca6aab0 ("Mobile: replace model-reset
by row-addition in DiveListModel::reload()").

Additionally, we need to also refresh the dive list so that the new
dives are shown.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02 08:04:49 -07:00
Dirk Hohndel
1c24ac1a94 Mobile: don't allow width change without rotation
We get incorrect changes to a new screen width that causes us to try
draw to a much larger screen than we actually have. Ignore those
changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02 08:04:49 -07:00
Dirk Hohndel
cd98cb8921 Mobile: add more debugging output for screen width issue
Somehow we need to be able to figure out which width information is
correct.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02 08:04:49 -07:00
Dirk Hohndel
c90050f449 Mobile: recalculate base units only for first real change
Different Android devices seem to have different patterns of throwing
incorrect width information at us. This seems like a really bad hack,
but for the ones I've seen so far this should give us the right width
information.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02 08:04:49 -07:00
Dirk Hohndel
d635d5de1f Mobile: only print debug output if there's information
On many devices the Screen property doesn't give us a manufacturer,
model, or name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02 08:04:49 -07:00
Berthold Stoeger
ad7ffa0af0 Import: Make DownloadThread a subobject of DiveImportedModel
Currently, desktop and mobile are accessing the DownloadThread
and the DiveImportedModel concurrently. This makes a big data
flow mess. To achieve a more hierarchical data flow, start
by making the DownloadThread a subobject of DiveImportedModel.

Start the download by calling a function in DiveImportedModel.

Route the finished signal through DiveImportedModel. Thus,
the model can reload itself with the new data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-02 08:04:49 -07:00
Berthold Stoeger
eecca6aab0 Mobile: replace model-reset by row-addition in DiveListModel::reload()
Owing to apparent QML breakage, a model-reset leads to the DiveDetail
page being reloaded for every dive in the list(!). Therefore, add
rows instead.

This leads to extremely subtle code, as it is now imperative that
the model has been properly cleared beforehand. Nevertheless, for
now we have to do this to fix a severe performance regression.

Fixes #2295

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-27 16:33:37 -07:00
Berthold Stoeger
649ac1f83a Mobile: clear dive data via model
Clearing the dive data directly in the core leaves us with an
inconsistent model. Therefore, clear via the model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-27 16:33:37 -07:00
Berthold Stoeger
f0fc1f3a56 Mobile: Don't access dive-id via DiveObjectHelper
There is already a role to do that. Query the model directly to
avoid creating a full DiveHelperObject.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-27 16:33:37 -07:00
Dirk Hohndel
9ae7040a91 Revert the singleton PR
It turns out that this isn't working the way it was intended to.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-27 16:26:58 -07:00
Berthold Stoeger
4d3686edec Cleanup: Pass gpsTrackers directly to GpsListModel::update()
Instead of using the GpsLocation singleton in GpsListModel::update()
to extract the gpsTrackers, pass the gpsTrackers as function argument.

The caller has direct access to the GpsLocation object anyway and this
make things less entangled.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-25 13:35:30 -07:00
Berthold Stoeger
05200f9266 Cleanup: unify idiosyncratic singletons
The way we handle singletons in QML, QML insists on allocating the
objects. This leads to a very idiosyncratic way of handling
singletons: The global instance pointer is set in the constructor.

Unify all these by implementing a "SillySingleton" template. All
of the weird singleton-classes can derive from this template and
don't have to bother with reimplementing the instance() function
with all the safety-checks, etc.

This serves firstly as documentation but also improves debugging
as we will now see wanted and unwanted creation and destruction
of these weird singletons.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-25 13:35:30 -07:00
Dirk Hohndel
b2230855e6 Mobile: make sure QML gets notified when value changes
This addresses the following warning when running the mobile app:
INFO: QQmlExpression: Expression qrc:/qml/DownloadFromDiveComputer.qml:339:5 depends on non-NOTIFYable properties:
INFO:     QMLManager::DC_forceDownload

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 16:31:27 -07:00
Dirk Hohndel
71a75bfda5 Mobile: more space around menu button on Download page
This looked fine when playing with it on the desktop, but required
more space on device for some reason.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 16:30:12 -07:00
Berthold Stoeger
9322c54b6a Mobile: pass section directly to tripTitle() and tripShortDate()
Instead of converting the section-heading string to a trip-pointer
in QML and pass that to the tripTitle() and tripShortDate()
functions, pass the string and convert in C++ code.

Hopefully, this makes the code more robust.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-21 16:12:23 -07:00
Dirk Hohndel
cefebc17bd Mobile: don't show filter button when entering credentials
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
cf4dbbe5f2 Android: print Android HW information
This uses Android methods through JNI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
e68d287c91 Mobile: print out Qt information on the system we are running on
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
7c3b8f32db Mobile: dump the information QML has about the screen
Maybe this will allow us to customize things for certain devices?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
dab2613791 Mobile: correct font size of 'Previously used DC' label
This appears to be the one label where we didn't set the
correct font size based on the global scaling.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
8c0af2b147 Mobile: recalculate gridUnit and font size if width changes
This could happen when you rotate a mobile device, or when running
Subsurface-mobile on the desktop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
54f48f0b37 Mobile: move gridUnit and font adjustment to function
This way we can call it in other situations when needed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Berthold Stoeger
e780b0a96c Mobile: don't generate numerous DiveObjectHelpers in startEditMode()
Since that object is very heavy, generate one object and read out all
the necessary values. The old code accessed the model again and again.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
6a9df3bba3 Mobile: transform DiveObjectHelper into value-type
Instead of handing a reference-to-dive to QML, prerender all the needed
properties and store them as values in DiveObjectHelper. Exception:
 - date(): generated from timestamp
 - time(): generated from timestamp
 - cylinderList(): does not depend on dive anyway and should be made
   static.

This hopefully avoids the random mobile crashes that we are seeing.
Clearly, this code needs to be optimized, but it is a start.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
a4f3580e10 Mobile: remove dive argument from DiveListModel::insertDive()
Since DiveListModel does not keep its own list of dives anymore,
insertDive() doesn't use the DiveObjectHelper argument. Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
feb11f6f5f Mobile: use value semantics for DiveObjectHelper in qmlmanager.cpp
Instead of creating a pointer-to-DiveObjectHelper in commitChanges,
use a normal object. Thus, we don't have to think about ownership
issues with respect to this object.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
0026aa3955 Mobile: replace clear()/addAllDives() pairs by reload()
The clear()/addAllDives() pair was bogus as the former didn't
clear the model (this is not possible anymore - the model
represents the core dive list) and the latter readded all
dives again.

Replace this by a reload() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
a79c45e401 Mobile: return depthDuration directly from DiveListModel
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this data directly
from the model. In this case, don't remove from DiveObjectHelper,
as these data might be used by grantlee templates.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
c4831d7ace Mobile: return location directly from DiveListModel
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
4b389e267d Mobile: return dive-number directly from DiveListModel
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
bf081866e9 Mobile: return dive-id directly from DiveListModel
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
c6b3309d13 Mobile: return dateTime directly from DiveListModel
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this data directly
from the model. In this case, don't remove from DiveObjectHelper,
as these data might be used by grantlee templates.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
54720e6cff Mobile: move tripNrDive from DiveObjectHelper to DiveListModel
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
1b9581369a Mobile: move tripId from DiveObjectHelper to DiveListModel
The canonical way of displaying lists in Qt is via models.
Thus, return the tripId directly from the DiveListModel instead
of going indirectly via a DiveObjectHelper. In the future, this
will allow us to make the DiveObjectHelper value-based, as it
is not generated numerous times for every list item.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Dirk Hohndel
b1ba687a1d Mobile: deal better with incorrect credentials
This could happen if the password was changed from a different Subsurface instance.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
f6f6a20555 Mobile: check if credentials are valid before accepting them
It seems crazy to simply assume that the later code can successfully
untangle the various states that the credentials can be in - let's just
stay on the credentials enrty page until we have verified credentials.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
d717b9d2a7 Mobile: add helper function to check cloud credentials
This should do the right thing in the various situations of correct &
verified credentials, credentials needing PIN verification, invalid
email/password combination, incorrect PIN, correct PIN.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
6ab4105211 Mobile: adjust grid unit on very narrow screens
If the default font size is big enough to leave us fewer than 21 grid
units per row, shrink the grid unit.

In order for this to create consistent results, we need to reduce the
default column width to 21 grid units as well. And with that change, the
columnWidth property becomes obsolete.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
00e673230a Mobile: reserve space for the hamburger menu on Download page
Having a label with no width that can expand wasn't really a great way
to do so.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
0eb14828b5 Mobile: use a default weight name when adding weight system
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11 12:23:33 -07:00
Berthold Stoeger
6b92edc9ab Mobile: support editing of dives with no weightsystem
If a dive has no weightsystems, editing the weight system has to add
a new entry in the table. Implement that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-11 12:23:33 -07:00
Berthold Stoeger
f3acb0ca02 Mobile: catch null references in DownloadDCThread
There are reported crashes on Android that suggest a null
"tables" attribute in DownloadDCThread. This should never
happen, as the table() function connected to this attribute
returns the address of a subobject. Thus, even if the original
DownloadThread is null, this would not return a null pointer
(the subobject is not at address 0).

Catch these null-object accesses and write a warning message
to the console. Hopefully, this will help is localizing the
problem.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10 09:58:19 -07:00
Berthold Stoeger
0cce3ef2a8 Mobile: update dive site model if dive sites are created
Always keep the dive site model up to date when adding dive sites.
This hopefully avoids creation of invalid indexes followed by crashes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10 09:55:11 -07:00
Berthold Stoeger
5da09a21bb Cleanup: move error reporting function declarations to errorhelper.h
Move the declarations of the "report_error()" and "set_error_cb()"
functions and the "verbose" variable to errorhelper.h.
Thus, error-reporting translation units don't have to import the
big dive.h header file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:30 -07:00
Berthold Stoeger
a5e7f4253a Core: dynamically resize weight table
Replace the fixed-size weightsystem table by a dynamically
relocated table. Reuse the table-macros used in other parts
of the code.

The table stores weightsystem entries, not pointers to
weightsystems. Thus, ownership of the description string is
taken when adding a weightsystem. An extra function adds
a cloned weightsystem at the end of the table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 06:01:07 -07:00
Berthold Stoeger
7f4d9db962 Cleanup: move trip-related functions into own translation unit
These functions were spread out over dive.c and divelist.c.
Move them into their own file to make all this a bit less monolithic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Dirk Hohndel
144de49ad4 Mobile: add checkbox to force downloading all dives
This has been a feature people have asked for quite frequently. It is
taking up some valuable screen real estate - so the question could
become if there should be a switch to enable / disable it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-05-11 11:40:07 -07:00
Linus Torvalds
263c87b1cc Update (and fix) device mobile ID's for Scubapro dive computers
I'm not sure this is actually relevant for anything any more, but this
adds the USB device ID's for the Scubapro G2 Console and HUD versions.
It also fixes things to use the proper vendor name (a bit too much
cut-and-paste, where the code said "Suunto" instead of "Scubapro").

The real device ID changes are in libdivecomputer, this is just the
Android xml list for recognized USB devices that likely nobody really
uses.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-04-25 13:22:21 +02:00
Berthold Stoeger
e99c4c9059 Dive site: introduce proxy model DiveSiteSortedModel
The LocationInformationModel used to sort its entries and was completely
rebuilt after every change. This makes it rather complex to support
incremental changes.

Instead, keep LocationInformationModel sorted by UUID so that indexes
are consistent with indices in the core dive site table.

Implement sorting by other columns than name and enable sorting in the
dive site view.

Finally, don't cache the list of dive site names for the mobile app,
since that would also need some rather convoluted methods of keeping
the list up to date. Calculate it on the fly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
e2df38d868 Dive site: add dive site ref-counting
Instead of setting dive->dive_site directly, call the
add_dive_to_dive_site() and unregister_dive_from_dive_site()
functions. In the parser this turned out to be a bit tricky.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f3e1187e65 Cleanup: move parse-function declarations out of "dive.h"
Move the declaration of these functions to "file.h" and "parse.h"
according to the translation unit they are defined in. Thus, not
all users of "dive.h" have to suck in "sqlite3.h".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
31291b1c56 Dive site: set UUID only on save or load
Since the UUID will be overwritten on save and is only used on save
and load, set it only on save or load. For other created dive sites,
leave the UUID field uninitialized.

This means that the UUID will change between saves. Let's see how
the git saver handles that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
82af1b2377 Undo: make undo-system dive site-aware
As opposed to dive trips, dive sites were always directly added
to the global table, even on import. Instead, parse the divesites
into a distinct table and merge them on import.

Currently, this does not do any merging of dive sites, i.e. dive
sites are considered as either equal or different. Nevertheless,
merging of data should be rather easy to implement and simply
follow the code of the dive merging.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
37146c5742 Parser: parse into custom dive site table
To extend the undo system to dive sites, the importers and downloaders
must not parse directly into the global dive site table. Instead,
pass a dive_site_table argument to parse into.

For now, always pass the global dive_site_table so that this commit
should not cause any functional change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f6e7bdc5ef Dive site: add dive site table parameter to dive site functions
To enable undo of dive site functions, it is crucial to work
with different dive site tables. Therefore add a dive site table
parameter to dive site functions. For now, always pass the global
dive site table. Thus, this commit shouldn't alter any functionality.

After this change, a simple search for dive_site_table reveals all
places where the global dive site table is accessed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Rolf Eike Beer
c4c8094e32 get rid of some foreach and Q_FOREACH constructs
See https://www.kdab.com/goodbye-q_foreach/

This is reduced to the places where the container is const or can be made const
without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7)
and std::as_const (C++17) are not available in all supported setups.

Also do some minor cleanups along the way.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Berthold Stoeger
40a3e562b0 Cleanup: provide printGPSCoords in C and C++ versions
printGPSCoords() returned a newly allocated C-style string. Most
callers simply made a QString out of it and freed the C-style string.
This is paradoxical, as printGPSCoords internally works with QStrings
and converts them to C-style on return.

Therefore, let printGPSCoords() return a QString and create a
printGPSCoordsC() wrapper for the two C-callers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-27 13:58:15 +01:00
Berthold Stoeger
04593e8ec4 Cleanup: fix printGPSCoords signature and leaks
The printGPSCoords() function returns a copied C-style string. Since
the owndership is transferred to the caller, the correct return type
is "char *" instead of "const char *".

Thus a number of casts when calling free can be removed.

Moreover a number of callers didn't free the string and thus were
leaking memory. Fix them. Ultimately we might want two versions
of the function: one for QString, one for C-style strings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-24 21:57:13 -07:00
Dirk Hohndel
9d582c5512 Mobile: only show dive computers in the Bluetooth connection list
And offer an option to show all devices in the settings. This is intentionally
not stored in the preferences as this should never be needed. We don't support
BT or BLE dive computers that we don't recognize. This is a last resort in case
a new firmware were to change the name or some other weird issue causes us not
to recognize a dive computer - and that should be fixed instead of worked
around.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-14 09:05:58 -08:00
Berthold Stoeger
891fcbf520 Import: control process_imported_dives() by flags
process_imported_dives() takes four boolean parameters. Replace these
by flags. This makes the function calls much more descriptive. Morover,
it becomes easier to add or remove flags.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
ff9506b21b Import: don't add to new trip while downloading
Since process_imported_dives() can add dives to a newly generated
trip, this need not be done in the downloading code. This makes
data flow distinctly simpler, as no trip table and no add-new-trip
flag has to be passed down to the libdivecomputer glue code.

Moreover, since now the trip creation is done at the import step
rather than the download step, the latest status of the "add to
new trip" checkbox will be considered.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
1cd0863cca Import: add add_to_new_trip flag to process_imported_dives()
If this flag is set, dives that are not assigned to a trip will
be assigned to a new trip. This flag is set if the user checked
"add to new trip" in the download dialog of the desktop version.

Currently this is a no-op as the dives will already have been
added to a new trip by the downloading code. This will be removed
in a subsequent commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
0249e12589 Import: split process_imported_dives() function
Split the process_imported_dives() function in two:
1) process_imported_dives() processes the dives and generates
   a list of dives and trips to be added and removed.
2) add_imported_dives() calls process_imported_dives() and
   does the actual removal / addition of dives and trips.

The goal is to split preparation and actual work, to
make dive import undo-able.

The code adds extra checks to never merge into the same
dive twice, as this would lead to a double-free() bug.
This should in principle never happen, as dives that
compare equal according to is_same_dive() are merged
in the imported-dives list, but perhaps in some pathologival
corner-cases is_same_dive() turns out to be non-transitive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
0dfc59f38c Import: add merge_all_trips parameter to process_imported_dives()
When importing log-files we generally want to merge trips. But
when downloading and the user chose "generate new trip", that
new trip should not be merged into existing trips.

Therefore, add a "merge_all_trips" parameter to process_imported_dives().
If false only autogenerated trips [via autogroup] will be merged.
In the future we might want to let the user choose if trips
should be merged when importing log-files.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
1593f2ebad Import: merge dives trip-wise
The old way of merging log-files was not well defined: Trips
were recognized as the same if and only if the first dives
started at the same instant. Later dives did not matter.

Change this to merge dives if they are overlapping.
Moreover, on parsing and download generate trips in a separate
trip-table.

This will be fundamental for undo of dive-import: Firstly, we
don't want to mix trips of imported and not-yet imported dives.
Secondly, by merging trip-wise, we can autogroup the dives
in the import-data to trips and merge these at once. This will
simplify the code to decide to which trip dives should be
autogrouped.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
f542dc4030 Import: add trip_table argument to DiveImportedModel::repopulate()
In the future we want to download trips into a distinct trip-table
instead of the global trip-table to allow for undo of import.

Therefore add a trip_table argument to DiveImportedModel::repopulate()
and a trip_table member to DiveImportedModel. To correctly set these,
add a DownloadThread::trips() function, which currently simply returns
the global trip table.

Finally, make "struct trip_table *" a Q_METATYPE, so that the corresponding
arguments can be passed from QML.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
7e33369dc8 Parser: add trip_table parameter to parsing functions
To allow parsing into arbitrary trip_tables, add the corresponding
parameter to the parsing functions and the parser state. Currently,
all callers pass the global trip_table so there should be no change
in functionality. These arguments will be replaced in subsequent commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
ec37c71f5e Core: add trip_table parameter to trip-functions
Currently trips are added to the global trip table. If we want to
make dive-import undoable, we should be able to parse trips of a
log-file into a distinct table. Therefore, add a trip_table
parameter to
	- insert_trip()
	- create_and_hookup_trip_from_dive()
	- autogroup_dives()
	- unregister_trip()
	- remove_dive_from_trip()

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
517fb7a462 Core: keep trips in table(s)
Currently, all trips are kept in a linked list. Replace the list
by a table in analogy to dive_table. Use this to keep the trip_table
sorted as suggested by dump_trip_list(). When inserting a trip into
the table do that after adding the dives, to avoid warnings coming
out of dump_trip_list().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
d1971a64f9 Core: Rename functions to more generic names
Rename
 - dive_get_insertion_index() -> dive_table_get_insertion_index()
 - unregister_dive_from_table() -> remove_from_dive_table()
 - get_idx_in_table() -> get_idx_in_dive_table()
 - sort_table() -> sort_dive_table()
This will make it more straight-forward to generate these functions
from macros.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Lubomir I. Ivanov
0903bef9db update year to 2019 in about screens
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2019-01-02 09:45:01 -08:00
Berthold Stoeger
691d44dfd1 Mobile: fix editing dive site
Commit 68961a169e made it impossible
to edit a dive site on mobile if a dive-site was already set: If
divesite was non-null, no actions were taken. Remove the conditional.

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-29 16:19:56 -08:00
Dirk Hohndel
c38215dfa7 Mobile: deal with BT name and address when tapping Download
Instead of trying to update this whenever the connection text changes,
instead deal with it right before it actually gets used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 14:53:45 -08:00
Dirk Hohndel
ef8656998a Mobile: add helper function to fill in the BT name
For some devices the BT device name is different from the product name.
Make sure that name is available to the mobile UI. This helper fills it
in from the scan data (based on the device address).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 14:52:02 -08:00
Miika Turkia
10a0393b1b Mobile: force update of ui on paste
Apparently this does the trick of updating the dive list when pasting
data on mobile. Tnx janmulder.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
3f8583de36 Mobile: initialize copy variables
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
53ba950c8f Mobile: copy the dive data when configuring settings
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
8e7a9a4f4c Mobile: UI for selecting what to copy-paste
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Berthold Stoeger
bfe69239df Import: unglobalize downloadTable
To make data flow more clear, unglobalize the downloadTable object.
Make it a subobject of DownloadThread. The difficult part was making
this compatible with QML, because somehow the pointer to the
download-table has to be passed to the DiveImportedModel. Desktop would
simply pass it to the constructor. But with objects generated in QML
this is not possible. Instead, pass the table in the repopulate()
function. This seems to make sense, but for this to work, we have to
declare pointer-to-dive-table as a Q_METATYPE. And this only works
if we use a typedef, because MOC removes the "struct" from "struct
dive_table". This leads to compilation errors, because dive_table is
the symbol-name of the global dive table! Sigh.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
abf942f303 Cleanup: make DCDeviceData a "normal" singleton
DCDeviceData was using that weird pattern where the instance
variable was set in the constructor. There is no apparent
reason to do so, therefore convert to a "normal" singleton.

Access that directly in QMLManager instead of saving it in
a member variable first.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00