Commit graph

1674 commits

Author SHA1 Message Date
Berthold Stoeger
76c52c87a3 core: move dive-site-table functions into class
There were a number of free standing functions acting on a
dive-site-table. Make them member functions. This allows
for shorter names. Use the get_idx() function of the base
class, which returns a size_t instead of an int (since that
is what the standard, somewhat unfortunately, uses).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
6b835710bc map: use value semantics for MapLocation
This makes memory management more simple, as not explicit deletion
is necessary.

A rather large commit, because changing QVector<> to std::vector<>
is propagated up the call chain.

Adds a new range_contains() helper function for collection
types such as std::vector<>. I didn't want to call it
contains(), since we already have a contains function
for strings and let's keep argument overloading simple.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
e39dea3d68 core: replace divesite_table_t by a vector of std::unique_ptr<>s
This is a long commit, because it introduces a new abstraction:
a general std::vector<> of std::unique_ptrs<>.

Moreover, it replaces a number of pointers by C++ references,
when the callee does not suppoert null objects.

This simplifies memory management and makes ownership more
explicit. It is a proof-of-concept and a test-bed for
the other core data structrures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
2df30a4144 core: remove ssrf.h include file
It didn't contain anything.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
4d183637d0 cleanup: remove unnecessary Q_UNUSED macros
Also remove the UNUSED() macro, as there were no users left.

The macro was silly anyway - there were many falso positives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
408b31b6ce core: default initialize units-type objects to 0
Makes the code much nicer to read.

Default initialize cylinder_t to the empty cylinder.

This produces lots of warnings, because most structure are now
not PODs anymore and shouldn't be erased using memset().

These memset()s will be removed one-by-one and replaced by
proper constructors.

The whole ordeal made it necessary to add a constructor to
struct event. To simplify things the whole optimization of
the variable-size event names was removed. In upcoming commits
this will be replaced by std::string anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
b56dd13add build: remove extern "C" linkage
No more C source files, no more necessity to use C-linkage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
7d3977481a core: convert divesite strings to std::string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
3f8b4604be core: convert taxonomy.c to C++
Since the taxonomy is now a real C++ struct with constructor
and destructor, dive_site has to be converted to C++ as well.

A bit hairy for now, but will ultimately be distinctly simpler.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Berthold Stoeger
3c1401785b core: use C++ structures for tanksystem info
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00
Michael Keller
a39f0e2891 Mobile: Fix QML Warnings.
Fix some runtime warnings when running the mobile build caused by
binding loops and deprecated handler syntax.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-06-06 16:17:32 +12:00
Michael Keller
1aa5438b2d Cleanup: Improve the Use of 'Planned dive' and 'Manually added dive'.
- standardise the naming;
- use it consistently;
- apply the 'samples < 50' only when putting manually added dives into
  edit mode - everywhere else manually added dives should be treated as
  such;
- do not show a warning before editing a manually added dive in planner.

Signed-off-by: Michael Keller <github@ike.ch>
2024-05-25 20:13:45 +02:00
Berthold Stoeger
556ecd5a9b core: use C++-primitives for g_tag_list
The old code was leaking memory. Use std::unique_ptr<> for
ownership management.

This is still very primitive and divetags are kept during
application lifetime. There should probably be some form
of reference counting. And the taglist should not be global,
but attached to the divelog.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
ab7218d543 Use report_info() instead of qDebug in mobile code
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
c6cd10a43f core: make getCloudURL() return an std::string
Let's use std::string in the core. Notably, I'd like to make
the numerous main() functions mostly independent of Qt. Some
things will have to remain, such as argument parsing, of course.

This changes the API: instead of returning an error code and
taking a pointer to the actual return-value, return an
std::optional<std::string>> that is set if the function succeeds.

Returning an empty string in the error case might be simpler,
but oh well...

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
da7ea17b66 cleanup: replace fprintf to stderr by report_info()
Let's try to unify debugging output!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
a123589efb core: convert git_info to std::string
Quite a bit of fallout in users of this structure.

Conveniently, since git-access.cpp is now C++ we can move
some helpers from the monstrous qthelper.cpp to git-access.cpp.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
de313bd01a mobile: save changes from main event loop
When autosync to cloud was enabled, the old code would crash,
because it synced to cloud from a signal handler, which executed
the main loop when checking the cloud connection, which deleted
the object which was causing the original signal. Or something
like that. See discussion in #4119.

To avoid such problems, send a signal via a 'QueuedConnection'
from QMLManager to itself. The slot will be called once the
signal handler terminates and the main event loop retakes
control.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-04 13:57:00 +02:00
Berthold Stoeger
2172e18298 mobile: pull undo/redo notification text up
When changes need saving, the notification text was set quite
deep in the calltree in "saveChangesLocal()". I don't know why
this was put so deep in the call tree. In any case, it prevents
asynchronous saving of the data. Therefore, pull it up to
chnagesNeedSaving().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-04 13:57:00 +02:00
Berthold Stoeger
916c88ded9 mobile: fix undo/redo
The signals of the undo-stack can only be connected after it
was initialized. One of those cases where I would have preferred
a crash over a warning message. The mobile version is extremely
noisy!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-31 14:19:44 +02:00
Berthold Stoeger
2bf7432a94 cleanup: remove unused macros in qmlmanager.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-25 21:41:57 +01:00
Berthold Stoeger
5ac64ab2cd cleanup: replace Q_FOREACH and foreach by range base for
Q_FOREACH and foreach are anachronisms.

Range based for may cause a performance regression: it can
lead to a copy of shared containers (one reason why Qt's
COW containers are broken). However, as long as there is no
user noticeable delay, there is no point in analyzing each case.
And also no point in slapping an 'asConst' on every container
that is looped over.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
41cb916060 core: turn existing_filename into std::string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
3a1122048b core: make logfile_name and dumpfile_name std::string
To avoid memory management woes. These shouldn't be global
variables, but let's fix that later.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Dirk Hohndel
d653cec7a4 ensure locale language info lands in the applog
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-03-11 11:30:14 -04:00
Dirk Hohndel
4b0fe3bc38 mobile: show incorrect cloud password state
While the startup flow should make it obvious when a user is not
correctly logged into the cloud, we still do see fairly frequent
situations where a user has an incorrect password on a mobile device and
is confused about why their data isn't syncing with their PC. Now this
is clearly shown in the main menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-23 20:12:12 -08:00
Michael Keller
a946dc323b Mobile: Add Input Validation and Conversion for Gradient Factors.
Add input validation and input conversion for the gradient factor
settings.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-17 12:36:15 +13:00
Dirk Hohndel
704b26ff1e Mobile: improve GFLow/High settings UI
- move the spinbox closer to the senter
- improve sizing and spacing of the spinbox
- hide it when we aren't showing the calculated ceiling

Also address an odd whitespace issue.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-14 18:57:41 +13:00
Michael Keller
31d1755efd Mobile: Fix Cloud Synch Status Management.
Fix how the cloud synch status is handled - currently the preference is
used incorrectly, switching cloud synch off when it should be on.
Also hide the 'Manual cloud synch' button when no cloud credentials are
stored, and don't show the 'manual synch' popup when auto synch is
enabled.

Signed-off-by: Michael Keller <github@ike.ch>
2024-02-12 16:47:46 -08:00
Michael Keller
345f0570a5 Mobile: Add 'Contribute' link.
Add a link to the 'Contribute' page to the mobile app.

Signed-off-by: Michael Keller <github@ike.ch>
2024-02-06 23:40:58 +13:00
Michael Keller
df1974a244 Mobile: Fix Configuration of Ceiling Display.
Fix the configuration of the deco ceilings in the mobile version:
- make the settings work;
- remove reading of the dive computer ceiling from git;
- hide the gradient factor in the profile when the calculated ceiling is
  not shown;
- when the calculated ceiling is disabled in the settings, disable
  editing of the gradient factor.

Signed-off-by: Michael Keller <github@ike.ch>
2024-02-06 11:58:49 +13:00
Michael Keller
aad0063c46 Mobile: Fix Link to the Online Manual.
Replace the link to the online manual to the post-website-revamp URL.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-04 14:59:55 -08:00
Michael Keller
fb41999c73 Mobile: Fix Gradient Factor Preference Setting.
Fix the persisting and use of gradient factor preferences for dive
profiles in the mobile version.
Also rename the mobile backend gradient factor settings to make it
obvious that they are used by the (not currently enabled) planner.

Signed-off-by: Michael Keller <github@ike.ch>
2024-01-27 20:55:32 -08:00
Dirk Hohndel
ef35c3e8cb update copyright year and version details
While the update to the copyright year really isn't required, it just looks
better.

By using the canonical instead of the git version in user visible strings we
are creating more consistency in how we refer to the version.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-01-07 16:01:55 -08:00
Michael Keller
5ad75e81c3 Mobile: Add Warning About Delay for Initial Synch.
Add a warning to the initial login screen telling the user that the
first synchronisation can take a few minutes.
Fixes a misunderstanding pointed out in a recent post in the Subsurface
mailing list.

Signed-off-by: Michael Keller <github@ike.ch>
2023-12-11 23:17:14 +13:00
Michael Keller
90e5de8357 Mobile: Make Cloud Auto Synch Status Easier to Understand.
Add an explicit checkbox to the 'cloud auto synch' status toggle in the
mobile 'Dive Management' menu in order to make it more intuitive to
understand.
This isn't super pretty, but I think it will improve the usability. A
prettier way to achieve this will be to redesign the `ic_cloud_off.svg`
/ `ic_cloud_done.svg` in order to make them intuitively recognisable as
unchecked / checked checkboxes.
Example of a support request caused by confusion from the current
implementation: https://groups.google.com/g/subsurface-divelog/c/9X-hTt9NFlE/m/ZcqtdOOhBQAJ

Signed-off-by: Michael Keller <github@ike.ch>
2023-06-26 07:54:48 -07:00
Michael Keller
a127c4ac63 Mobile: Make Gradient Factor Range Consistent with Desktop.
Change the range to be 10 to 150.

Signed-off-by: Michael Keller <github@ike.ch>
2023-05-30 16:21:41 +02:00
Michael Keller
50438b0456 Mobile: Fix Editing of Gradient Factors
Fix the issue that Gradient Factors cannot be set to 100 in the mobile
version. This is done by changing the edits from a text box to a spin
edit, which seems to be a better match for numerical values.
As a side effect this also solves the issue that the keyboard for the
text edit is not properly displayed when settings are opened when dive
details are already on the page stack.

Fixes #3911.

Reported-by: @gbetous
Signed-off-by: Michael Keller <github@ike.ch>
2023-05-30 16:21:41 +02:00
Berthold Stoeger
a7889d1f4e cleanup: fix typo: verboseEnabebled -> verboseEnabled
Not really relevant, because it only affects debugging output.

But shows why I dislike weakly typed, non-compiled languages.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-05-20 20:07:22 +02:00
Michael Keller
a38ea971a0 Import: Add option to sync time on dive computer download
Add an option for users to sync the dive computer time with the PC time
every time dives are downloaded.
Obviously this will only work on dive computers that have time
synchronisation support in libdivecomputer, for other computers a notice
is logged.
The selection for this option is persisted as a preference.

Signed-off-by: Michael Keller <github@ike.ch>
2023-04-17 07:56:02 -07:00
Berthold Stoeger
c5d6e0f44f core: make owning pointers a top-level features
The undo-code uses owning pointers based on std::unique_ptr to
manage lifetime of C-objects. Since these are generally useful,
move them from the undo-code to the core-code. In fact, this
eliminates one instance of code duplication.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
b61732da42 core: remove autogroup global
Use the flag in the divelog structure, since this will be saved
in the dive log.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
9c253ee6c5 core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.

Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).

The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.

To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.

The whole commit is large, but was mostly an automatic
conversion.

One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
261f07dfa4 core: add make_manually_added_dc() function
For reasons of symmetry (there is a is_manually_added_dc()
function), create a make_manually_added_dc() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-21 16:51:57 -07:00
Berthold Stoeger
f687e51d4b core: don't consider dives with many samples as manually added
This causes UI confusion. Notably we go into edit mode and
reduce the number of samples, leading to loss of information.

If someone really manually adds a dive with more than 50
samples, they should still be able to explicitly open the
dive in the planner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-21 16:51:57 -07:00
Berthold Stoeger
7c8dc016b5 mobile: flip through dive computers on mobile
UI fixed by Dirk.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-01 18:47:16 +02:00
Dirk Hohndel
42da08df20 mobile: enable sharing via email
Instead of using the save file dialog (which creates a horrendous user
experience - and isn't even supported on Android), simply allow the user
to email the file in question to a recipient of their choice, e.g.,
themselves.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-31 13:58:22 -07:00
Dirk Hohndel
f144fa0a1b mobile: allow sharing files via email
This will allow the user of the mobile app to export dive and dive site
data from their mobile device without using the Subsurface cloud.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-31 13:58:22 -07:00
Dirk Hohndel
ead15f622a mobile: remove export as UDDF
The export functionality is horridly poorly implemented, and the UDDF export
isn't actually functional on mobile. And why would we support this in the first
place? That's not a reasonable expectation for the mobile app.

So let's just completely remove that and good riddance.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-31 13:58:22 -07:00
Berthold Stoeger
aa4b48f440 core: move floating point functions to own header file
This were in subsurface-string.h for unknown reasons.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-08-30 22:34:38 +02:00