Commit graph

168 commits

Author SHA1 Message Date
Berthold Stoeger
f3ef38ca0d Dive pictures: remove hashes
In the last commits, the canonical-to-local filename map was made
independent from the image hashes and the location of moved images
was based on filename not hashes. The hashes are now in principle
unused (except for conversion of old-style local filename lookups).

Therefore, remove the hashes in this commit. This makes addition
of images distinctly faster.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Berthold Stoeger
08962cb38d Dive pictures: index local file name by canonical filname
The connection canonical filename to local filename was done via
two maps:
  1) canonical filename -> hash
  2) hash -> local filename
But the local filename was always queried from the canonical filename.
Therefore, directly index the former with the latter.

On startup, convert the old map to the new one.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Robert C. Helling
69de9d8f98 Add planner infra structure for bailout
Add a divemode column to the planner model and a
corresponding field to struct divepoint and fill it
in the corresponding functions.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Dirk Hohndel
ea83b5ed37 Core: remove dive.h from files that don't need it
Of course, quite a few of them indirectly get it through other header
files.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Dirk Hohndel
d577467f97 Core: introduce new subsurface-string header
First small step to shrinking dive.h.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Miika Turkia
4186733740 CSV import: fix setpoint (typo)
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-19 15:09:02 +03:00
Jeremie Guichard
7753352e62 Change taglist_get_tagstring to support 'unlimited' tag list size
Previous taglist_get_tagstring signature/implementation did not allow
handling of cases where inputted buffer could not contain all tags.
New implementation allocates buffer based on pre-computed size allowing to
insert all tags in the returned string.

Added get_taglist_string in qthelper to handle conversion to QString
Added TestTagList with tests for taglist_get_tagstring

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-09 07:59:51 -07:00
Stefan Fuchs
5c9345976c CSV import/export: Sort parameter list and add comment
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-19 11:59:58 -07:00
Berthold Stoeger
d1572a8d95 Cleanup: introduce copy_qstring() function
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common
occurrences that they seem worthy of a short helper-function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
b72cc1f317 Cleanup: consistently use qPrintable()
Replace constructs of the kind
  s.toUtf8().data(),
  s.toUtf8().constData(),
  s.toLocal8Bit().data(),
  s.toLocal8Bit.constData() or
  qUtf8Printable(s)
by
  qPrintable(s).

This is concise, consistent and - in principle - more performant than
the .data() versions.

Sadly, owing to a suboptimal implementation, qPrintable(s) currently
is a pessimization compared to s.toUtf8().data(). A fix is scheduled for
new Qt versions: https://codereview.qt-project.org/#/c/221331/

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
bdc470a80e Cleanup: Remove hash field from picture-structure
The hash field in the picture-structure was in principle non-operational.
It was set on loading, but never actually changed. The authoritative
hash comes from the filename->hash map.

Therefore, make this explicit by removing the hash field from the
picture structure.

Instead of filling the picture structure on loading, add the
hash directly to the filename->hash map. This is done in the
register_hash() function, which does not overwrite old entries.
I.e. the local hash has priority over the save-file. This
policy might be refined in the future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
f5eafe2a71 Cleanup: Fold add_hash() call into learnHash() function
learnHash() was always called in conjunction with add_hash(). The
pattern was that a local filename and a hash were connected in
the hash-to-filename and the filename-to-hash maps. Then, the
original picture-filename or url were registered in the filename-to-hash
map.

This commit changes learnHash() to take three parameters (original-filename,
local-filename and hash) and do all of the above. The new code is
simpler because no dummy picture struct has to be generated in
DiveListView::loadImageFromURL().

The tests were extended to check for all hash<->filename associations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
b750a48f0f Cleanup: Don't store hash in picture struct in learnHash()
learnHash() is called either on a local picture structure
[DiveListView::loadImageFromURL()] or on a cloned picture structure
[ImageDownloader::saveImage()]. In neither case the picture structure
is passed to the frontend. Therefore, storing the new hash in the
picture struct is not necessary.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Miika Turkia
f2beeb4078 Parameter size needs to be increased for test
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
4a5b40c144 Update DL7 tests to current import
As we now parse dives without profile, we get 2 more dives from the
sample log import (3 in total). And naturally also the resulting XML to
compare against needs to be updated.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
e2197a56a4 Compare DL7 import to saved conversion
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
fbbca93d53 Add test for DL7 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Berthold Stoeger
59526e948a Remove cloud_background_sync preferences option
The preferences flag cloud_background_sync used to be used heavily in
the mobile code, but is not used there anymore. Now, it is accessed
only in one place, but does not do what it actually says: If it is off,
the remote storage is not synced on save (but will be synced on next
load).

Syncing on save can also be prevented by unchecking the "Cloud online"
menu checkbox. Since the latter seems more logical and general
(support for non-cloud remote git repositories), remove the cloud_background_sync
option.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 10:46:07 -08:00
Berthold Stoeger
cab0699d4c Fix typo in TestGitStorage: SapleDives -> SampleDives
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-03 19:07:03 -08:00
Berthold Stoeger
d775adfb29 Add tests to read/write "file://..." style local git repositories
Requested-by: Dirk Hohndel <dirk@hohndel.org>

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-03 08:26:43 -08:00
Miika Turkia
02c80a60b0 Refactore parse-xml.c into parse.c and parse-xml.c
This should help us to move parsing that is not XML related to other
files, hopefully making the code cleaner.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
e17ad1b0e0 Add test for DM5 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Robert C. Helling
8e21a65653 Localize global planner state
For UI responsiveness, we need to be able to run the planner in the background. This needs the
planner state to be localized (and we need to pass a pointer around).

In order to not let too many lines overrun (and to save typing in the future)
I have renamed instances of struct deco_state to ds. Yes this should have gone
to a separate commit but I accidentally commit --amend'ed it.

Computing of planner variations is temporarily disabled.

Unlock the planner when returning early

So we don't deadlock in add dive and recreational mode (which
use the planner without actually planning).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Berthold Stoeger
dd8e4fae2a Make handling of booleans consistent on the C++-side of preferences
In general, the C++-side of the preferences code consistently uses
the bool data type for boolean settings. There are five exceptions,
which use short instead:
  showPo2
  showPn2
  showPhe
  saveUserIdLocal
  displayInvalidDives
This patch attempts to make the code more consistent by turning
these into bools as well.

Tests showed that writing as short and reading as bool is handled
gracefully by the Qt variant code. Therefore, an upgrade should not
cause user-visible changes to their settings.

As a bonus, two extern declarations of the set_save_userid_local()
function, which is not defined anywhere, were removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-20 20:56:13 +01:00
Berthold Stoeger
b32251a5a8 Typo: modp02 -> modpO2
Fixes two function names, where O2 was written as 02.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-12 15:11:30 +01:00
Stefan Fuchs
4e320cca5b Remove three obsolete preferences options for geocoding
These options are not used any longer/were never used and can be
removed to not confuse the users.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-29 11:07:52 -07:00
Robert C. Helling
1f50485732 More VPMB state in special structure
... and reset deco information in profile ceiling computation.

The planner test then needs to know about the struct holding the deco
state.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-01 23:58:55 +03:00
Robert C. Helling
5b080bedde Remove option to apply GFlow at maxdepth
This option should have never been there. This is not how
gradient factors are supposed to work. It would only trick
users to use the wrong value..

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20 08:54:41 -07:00
Robert C. Helling
e6545a7b0f Store a table of deco stops in planner
... in addition to struct diveplan which combines all kinds
of information

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Robert C. Helling
82aac4efff Make plan take dive and decotimestep as arguments
...rather than use a global variable and a macro.

This should be a no-op in preparation to allow planning
several versions of a dive.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Seamus Boyle
252dfaf6d1 TestPreferences: Fix update manager test date
QDate::addDays() returns a copy with the changed date, calling it and
ignoring the return value does nothing.

Signed-off-by: Seamus Boyle <seamus@beantrader.com.au>
2017-07-04 11:54:54 +09:00
Dirk Hohndel
c6bc88b50d Fix some warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:21:37 -07:00
Robert C. Helling
7b18be2a50 Adopt planner state caching to new struct
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:44:36 -07:00
Miika Turkia
726c9e859c Test case for CSV profile export to imperial and back
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-12 14:05:33 -07:00
Dirk Hohndel
d7cf3408e5 Merge branch 'seabear-refactor'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-07 07:52:55 -07:00
Miika Turkia
0829d601c6 Change test case to use new Seabear parsing function
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 16:32:11 +03:00
Miika Turkia
ab1813a445 Move intdup to qthelper
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 09:41:27 +03:00
Stefan Fuchs
67fbf6009a Test for adding a picture with data after JFIF EOI to a dive
Add one more picture to the already existing test.
This new picture is a JPEG and has data after JFIF EOI tag.

Suggested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-06 10:31:09 -07:00
Miika Turkia
b7c6998cf7 Enable test mode in UDDF export test
Using the units parameter to indicate test mode on UDDF export.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-06 08:06:42 -07:00
Miika Turkia
e52d9c2846 Add UDDF export-import test
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-06 08:06:42 -07:00
Miika Turkia
52426b8585 Fix memory leak
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-06 08:06:42 -07:00
Dirk Hohndel
ee1bf18189 Add SPDX header to tests
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Miika Turkia
2b2df88e87 Cleanup for CSV testing
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-04-01 08:06:09 -07:00
Miika Turkia
8bb9eb501b Enable CSV import-export unit conversion test
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-04-01 08:06:09 -07:00
Miika Turkia
acd791b7c1 Export-import test for manual CSV
Note that the actual validation of the result is currently disabled, so
the tests will pass even though there are some bugs and rounding errors
present.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-04-01 08:06:09 -07:00
Miika Turkia
a0ed0ff823 Change parseCSV to support unit and file selection
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-04-01 08:06:09 -07:00
Jan Mulder
622ab2286a minimal pO2 threshold: corrected testpreferences
Adapt the testpreferences procedure for the new min/max pO2 preference.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-03-28 11:17:03 -07:00
Jeremie Guichard
597539ce39 Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code
Fix warnings raised by the flag using lrint

Original issue reported on the mailing list:
The ascent/descent rates are sometimes not what is expected.
E.g. setting the ascent rate to 10m/min results in an actual
ascent rate of 9m/min.
This is due to truncating the ascent rate preference,
then effectively rounding up the time to reach each stop to 2s intervals.
The result being that setting the ascent rate to 10m/min
results in 20s to ascend 3m (9m/min), when it should be exactly 18s.

Reported-by: John Smith <noseygit@hotmail.com>
Reported-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-24 09:39:25 -07:00
Stefan Fuchs
6f21d2749e Tests for minimum gas
Add automatic tests in TestPlan for minimum gas:
- Copy minimum gas result (pressure) to diveplan.
- Add cylinder size and working pressure for bottom gas to every dive in TestPlan
  Hint: Unrealistic cylinder sizes (100l, 200l) have to be used for the very long and deep dives in TestPlan
- Add minimum gas check for every dive
- Add two additional test dives in TestPlan which produce sane minimum gas results with 24l tank
  Hint: Deco check for these new dives is commented out at the moment

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-19 17:11:52 -07:00
Jeremie Guichard
1ff0aeed4c Fix error in install target for tests on Windows
The rule was working when called from the fake test
used as preparation step in check target on Windows,
but did not work for the normal install target.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-11 08:05:22 -08:00