Commit graph

14530 commits

Author SHA1 Message Date
Dirk Hohndel
afe7e847d6 Whitespace cleanup tests
Again, entirely script based.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-26 16:32:51 +03:00
Dirk Hohndel
128fc5f4b8 Whitespace cleanup core/settings
We can argue about any of the changes here, but they are the result of our
whitespace.pl script - so if any of this is offensive to you, part of the
resolution will be fixing the script...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-26 16:32:51 +03:00
Dirk Hohndel
68b5fe9ccb Small edit of whitespace script
This makes sure we don't end up indenting macro invocations.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-26 16:32:51 +03:00
jan Iversen
19871a6ab2 core: qPrefCloudStorage save userid to new location
userid was saved outside all groups, even though it belongs to cloudStorage

Add code to save in new location and read from new/old location

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
daf8921d6f tests: add DiveComputer qml test cases
Add tst_qPrefDiveComputer qml file to test C++ qml connection

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
87b00aea2b tests: move DiveComputer test from testpreferences
Remove DiveComputer test in testpreferences
add the same DiveComputer tests to testqPrefDiveComputer

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
bb5c1da1b7 tests: add qPrefDiveComputer testcases
add test cases to secure struct preferences and qPrefDiveComputer work together

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
3d6848b22c core: activate qPrefDiveComputer
remove DiveComputer from SettingsObjectWrapper and reference qPrefDiveComputer

update files using SettingsObjectWrapper/DiveComputer to use qPrefDiveComputer

this activated qPrefDiveComputer and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
98820cf970 core: update qPrefDisplay to new consensus
add inline to load/sync
remove const from QString getters

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
8cfe048150 core: update qPrefCloudStorage to new consensus
make load/sync inline
remove const from QString getters

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
5f3471bf86 core: make load/sync inline in qPref
Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
254ba61fd9 core: make load/sync inline in qPrefAnimations
Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
0002cd2d20 core: create qPrefDiveComputer from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct diveComputer
- set function have set_<name>
- signal function have <name>_changed

one class one .h/.cpp is the C++ idiom. Having load/sync of each
variable in 1 functions (in contrast to the distributed way
SettingsObjectWrapper handles it) secures the same storage name
is used. Having the set/get/load/sync functions grouped together
makes it easier to get an overview.

REMARK: this commit only defines the class, it is not active in production

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
69c7ed676a core: add qPrefAnimations to SettingsObjectWrapper/qPref load
correct missng qPrefAnimations in global load functions

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
ead05c8e17 core: expand qPref macros to handle sub structure
Expand SET_, DISK_ and HANDLE_ macros with field for substructure

Structure prefs contains e.g. prefs.dive_computer.vendor an extra field
are added to the macros to allow this.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
92ade62260 core: remove LOADSYNC* macros
expend LOADSYNC* into DISK_* macros
remove LOADSYNC* from qPrefPrivate.h
update qPrefDisplay to not use LOADSYNC*

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
3eae683b57 core: make qPrefAnimations/CloudStorage getters static and inline
Add static and inline to getter in all qPref header files
Remove call to GET_PREFERENCE_* in qPrefDisplay.cpp
Remove GET_PREFERENCE_* from qPrefPrivate.h

static inline is slightly faster than a function call, but it saves
a lot of coding lines (no lines in qPref*.cpp). Getters are a direct
reference to struct preferences, so they will normally only be used
from QML.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
87d8963c78 core: make qPrefDisplay getters static and inline
Add static and inline to getter in all qPref header files
Remove call to GET_PREFERENCE_* in qPrefDisplay.cpp

static inline is slightly faster than a function call, but it saves
a lot of coding lines (no lines in qPref*.cpp). Getters are a direct
reference to struct preferences, so they will normally only be used
from QML.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
7f4123d0d1 core: isolate qPrefPrivate to qPref* classes
Make functions in qPrefPrivate private and add
qPref* as friends

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
f1648d297b core: qPref replace COPY_TXT with copy_txt in qPrefPrivate
Add copy_txt function to qPrefPrivate class
Remove macro COPY_TXT from qPrefPrivate.h
Replace use of COPY_TXT with copy_txt in qPref classes

copy_txt is only once, COPY_TXT was expanded approx. 160 times, so
this commit saves space (and removes a macro).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
Berthold Stoeger
597aa75348 Update CHANGELOG.md
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 15:58:55 -07:00
Berthold Stoeger
b3feaa80e2 Dive video: paint duration-bar above thumbnail in profile plot
Paint a rectangle on top of thumbnails indicating the run-time
of the video.

Use the z=100.0-101.0 range for painting the thumbnails, whereby
the z-value increases uniformly from first to last thumbnail
(sorted by timestamp). The duration-bars are placed at z-values
midway between those of the thumbnails.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 15:58:55 -07:00
Berthold Stoeger
c742885984 Dive media: prepare for video-thumbnails
Video thumbnails are more complex than simple picture thumbnails.
We store a duration and might want to store multiple images.

Therefore, refactor the thumbnailing in imagedownloader.cpp. Move
the thumbnail-writing down in the call chain to where the thumbnails
are created, since we have more information there (i.e. whether we
could parse the file but not extract an image, etc.).

Split the write-to-cache function into three versions:
  - pictures
  - videos
  - unknown

Define the video-thumbnail on-disk format as
  - uint32  MEDIATYPE_VIDEO
  - uint32  duration of video in seconds
  - uint32  number of pictures
  for each picture:
	- uint32  offset in msec from begining of video
	- QImage  frame

Currently, we write 0 pictures. This will be filled in subsequent commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 15:58:55 -07:00
Berthold Stoeger
7dd49acf4b Cleanup: remove DiveItem::icon_names member array
Each DiveItem (which is a wrapper around diveId with some virtual
functions), had a member icon_names, which is an array of
four QStrings. These were not used anywhere and must be an obscure
oversight and was probably planned as a static cons array?.
In any case, remove it.

There *was* a function-local analogous icon_names array in
DiveItem::data() though. This array would initialize four
QStrings from C-string literals on every invocation. Make
this array static, local to the translation unit and use
the QStringLiteral macro to construct the QString object at
compile-time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 17:05:15 +03:00
jan Iversen
be50ee2017 tests: add CloudStorage qml test cases
Add tst_qPrefCloudStorage qml file to test C++ qml connection

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
be8e93d28a tests: move CloudStorage test from testpreferences
Remove CloudStorage test in testpreferences
add the same CloudStorage tests to testqPrefCloudStorage

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
cabdf71bf7 tests: add qPrefCloudStorage testcases
add test cases to secure struct preferences and qPrefCloudStorage work together

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
b9b1f03f0d core: activate qPrefCloudStorage
remove CloudStorage from SettingsObjectWrapper and reference qPrefCloudStorage

update files using SettingsObjectWrapper/CloudStorage to use qPrefCloudStorage

this activated qPrefCloudStorage and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
4b68329c9d core: create qPrefCloudStorage from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct preferences
- set function have set_<name> (from struct preferences>)
- signal function have <name>_changed (from struct preferences>)

one class one .h/.cpp is the C++ idiom. Having load/sync of each
variable in 1 functions (in contrast to the distributed way SettingsObjectWrapper
handles it) secures the same storage name is used. Having the set/get/load/sync
functions grouped together makes it easier to get an overview.

REMARK: this commit only defines the class, it is not active in production
Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
Berthold Stoeger
f23425c558 Uninline functions in dive.h
There were numerous inlined functions in dive.h. For many of them
inlining is dubious. Let's uninline most of them, with the exception
of trivial accessors and interpolate().

On current master, this gave a size reduction of 5 pages:

-rwxrwxr-x 1 bs bs 5863656 Jul 18 20:57 subsurface-inline
-rwxrwxr-x 1 bs bs 5843176 Jul 18 20:48 subsurface-noinline
-----------------------------------------------------------
                     20480

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-21 07:46:44 -07:00
Berthold Stoeger
6b9380efb0 Fetch sqlite from https:// site
The http:// version is down an makes Travis fail.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-21 00:14:49 +03:00
Berthold Stoeger
4bb56db35e Update CHANGELOG.md
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-20 08:29:27 +02:00
Berthold Stoeger
4f42e4fd50 Dive media: implement "Open folder of selected media files"
Add a context-menu entry to TabDivePhotos which opens the folder(s)
of all selected files.

Fixes #1514.

Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-20 08:29:27 +02:00
Berthold Stoeger
325b8bba35 Undo: remember deleted trip in UndoRemoveDivesFromTrip::undo()
If the last dive of a trip is removed, the trip is deleted.
On redo the dive is added to a non existing trip, leading to a
segfault.

Therefore, keep a copy of the trip to reinstate it on redo.
Note: this cannot work for a sequence of multiple commands.
One would have to rewrite the whole undo-history. Nevertheless,
let's do this as a stop-gap measure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-19 02:43:08 +03:00
Berthold Stoeger
b51e616b6a Undo: clear list of trips to be recreated in UndoDeleteDive::undo()
UndoDeleteDive::tripList kept track of the trips to be recreated on
undo. But the list wasn't cleared on undo, thus on subsequent redo
the same trip was readded to the list, leading to double-free.

This could trivially be reproduced by repeated CTRL-Z, CTRL-SHIFT-Z
pairs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-19 02:43:08 +03:00
jan Iversen
6c95714b9f tests: update qPrefAnimations test cases
remove include of QtTest in header, becaue it is not needed,
add include of QObject in header, so moc can generate code.
add QTest in cpp file, which replaces QtTest

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
0363e590f3 tests: update qPrefDisplay test cases
remove include of QtTest in header, becaue it is not needed,
add include of QObject in header, so moc can generate code.
add QTest in cpp file, which replaces QtTest

Change content of strings to test divelist_font to a not normal
font name, to ensure less confusion by readers. Remark the old
surrounding code accept illegal font names, but correcting this
is not covered in this commit.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
3c3729711c core: remove QSettings in qPref* and use a shared variable
Add qPrefPrivate class which contains one QSettings variable,
delete QSettings from qPref* class definitions

this secures there are only instance of QSettings
(QSettings needs to be in a QObject class to work)

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
c0e9e978a1 core: remove include QSettings from QPref
remove QSettings header file from qPref.h (which is included in many files)
to isolate the use of QSettings in the total system.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
4719af308f tests: update CMakeLists.txt to incude qPref* in both places
Files are listed in 2 places in CMakeLists.txt, update file to
secure qPrefAnimations and qPrefDisplay are listed correctly

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
Berthold Stoeger
c5f66c5538 Dive media: transport dive-id in drag'n'drop events
9efb56e2d4 introduced rather complex
logic for picture drag'n'drop events onto the profile. Among other
things, the code had to check whether the picture actually belongs
to the displayed dive.

This can be simplified by transporting the dive-id in the drag'n'drop
event structure. The flow goes like this:
DivePictureModel--(1)-->DivePictureWidget--(2)-->ProfileWidget

For (1), we can use the Qt::UserRole role. This was used to transport
the picture-offset, but this is not needed anymore since ProfileWidget
was decoupled from DivePictureModel.

For (2), we simply replace the "position" value, which was never used.
Why would the receiver care which pixel was pressed in the media-tab?

This commit also contains a minor cleanup in DivePictureWidget:
QListView::mousePressEvent(event) was called in both branches of an
if and can therefore be removed from the if. This is so trivial,
that it doesn't warrant its own commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 09:06:37 -07:00
Berthold Stoeger
8ff7314b21 Cleanup: rename trip->index to trip->saved
The index-field was misused by the IO routines to mark which dives
had been saved. Somewhat questionable, but let's at least name the
field accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 09:04:47 -07:00
Berthold Stoeger
3a933637da Cleanup: removed unused functions in divelist.h
find_trip_by_idx() and find_matching_trip() weren't used anywhere.
The trip index actually is only misused as a "trip saved"-flag.

trip_has_selected_dives() only existed as a comment.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 09:04:47 -07:00
Berthold Stoeger
b7bb9b4177 Bluetooth: don't call deviceDiscoveryError() on scan finished
In the remoteDeviceScanFinished slot, the old code called into
the deviceDiscoveryError() in case the device discovery agent
had the error flag set. This is not necessary, since the agent
will send an error signal in such a case.

For Qt's device discovery agent, the whole check-for-error is
unnecessary, as the documentation states:
"The signal is not going to be emitted if the device discovery
finishes with an error."

But for the homebrew WinBluetoothDeviceDiscoveryAgent, which
derives from QThread, both an error() *and* a finished()
signal will be sent. Therefore keep the test, but don't call
into the slot twice.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 02:11:16 +03:00
Berthold Stoeger
6d72871942 Cleanups to core/color.[c|hpp]
A number of small cleanups to the color-table:

1) Make the profile_color map of static linkage - it is not
used outside of this file.

2) Remove the third color, which originally was planned for
printing. It was not accessed anywhere.

3) Replace QVector<QColor> by std::array<QColor, 2>. Using a
reference-counted, copy-on-write, dynamic container for static
data seems like overkill. std::array<QColor, 2> has exactly the
same run-time impact as QColor[2], but allows for assignment.

4) Use brace-initialization and remove the unneeded COLOR macro.

5) Remove the fill_profile_color function. Simply use static
initialization.

6) Move #includes from .h to .cpp file.

7) Remove text_render_options(_t), which were not used anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 02:09:15 +03:00
Berthold Stoeger
2c6b1a99af Cleanup: simplify dive_getUniqID()
dive_getUniqID() is used to create unique dive ids, which are
stable during application lifetime. It was passed a dive, checked
that the id was not set (if it was that it is know to the application)
and set a new id (in contradiction to its name!) if it hadn't any.

There were three callers:

alloc_dive(): called the function on a zeroed dive struct.
fixup_dive(): called the function only if the dive had a 0 id.
MainWindow::setupForAddAndPlan(): called the function on a zeroed dive
struct.

Thus, in all three callers the id is guaranteed to be zero and
the whole keeping-track-of-ids logic is moot. Remove the logic,
don't pass a dive struct to dive_getUniqID() and move the function
to the C-backend.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-17 15:20:52 -07:00
Berthold Stoeger
4931b5a8e6 Dive media: fix stacking of thumbnails in profile plot
9efb56e2d4 added code to rearrange
pictures on drag'n'drop. To keep the correct repainting order (i.e.
later thumbnails are painted on top of previous thumbnails), the
z-value was set accordingly. In principle a sound idea, but it did
not work out, because on hoverEnter and hoverExit events, the z-values
were modified, thus restoring the wrong drawing order.

Instead, use the QGraphicsItem::packBefore() function. Experimentation
showed that this only works if stacking is done from the back
of the list.

Silence an erroneous compiler warning by initializing a variable to 0.0.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-16 23:29:21 +03:00
Berthold Stoeger
b53672507d Fix typo in INSTALL: add missing backspace at end of line
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-16 00:09:59 +03:00
Stefan Fuchs
397ff368d5 Update CHANGELOG.md
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-15 09:38:12 -07:00
Stefan Fuchs
bb2dfdfe54 For media file open dialog add different file filters
On top of the file filter for all media files add a file filter
for images only, one for videos only and one for all files.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-15 09:38:12 -07:00