Register the new FilterDive widget on the mainwindow
so we can trigger a shortcut to display it.
The shortcut currently doesn't exists.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
The idea of this new widget is to be able to filter more
types of data, while keeping it simple and extending the
feature set to something that was impossible with the old
implementation.
While the old implementation had 4 panels that you could
use to filter specific tags / people / types of dives
the new one will let you filter by visibility, temperature
people, name, equipment, etc, in a more natural way
than the old one.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
These two functions were called in different contexts:
- unregister_dive(): from the undo-commands to remove the dive
from the global dive table, but not delete it. The dive was
already removed from its trip.
- delete_single_dive(): from non-undo code. Most of it not in
use and removed in a sibling-commit. Here, the dive is supposed
to be removed from its trip and a new selection is calculated.
delete_single_dive() calls unregister_dive(), which removes the
dive from its trip. Move remove_dive_from_trip() from the former
to the latter and make both functions independent. Instead
of deleting the dive explicitly in delete_single_dive(), call
the delete_dive_from_table() function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
All callers of add_dive_to_trip() work on freshly generated dives,
with one exception, that was redundant anyway. Therefore it is not
necessary to remove the dive from a potential previous trip. Move the
responsibility of removing the dive from a trip to the caller,
respectively remove the redundant call. Add a warning message in the
case that trip is set.
Background: On import (either download or file-import) we might not
want to add trips to the global trip-list. For example to enable undo
of import but more generally to detangle that data flow. Thus,
add_dive_to_trip() should not mingle with the global trip-list,
which it has to do if a trip is deleted because the old dive was
removed.
Analysis of the add_dive_to_trip() callers:
1) core/dive.c
pick_trip():
called on freshly generated merged dive.
finish_split():
called on two freshly generated split dives.
2) core/divelist.c
create_and_hookup_trip_from_dive():
called on freshly downloaded dive in dive_cb().
called on freshly downloaded dive in record_uemis_dive().
autogroup_dives():
called on dive from get_dives_to_autogroup(), which only
finds dives that are outside of trips.
combine_trips():
unused - removed in sibling commit.
try_to_merge_into():
this call was actually erroneous - dive was already added
to trip in try_to_merge(). Remove call.
3) core/libdivecomputer.c
dive_cb():
called on freshly downloaded dive.
4) core/uemis_downloader.c
record_uemis_dive():
called on freshly downloaded dive.
5) core/load_git.c
create_new_dive():
called on freshly allocated dive.
6) core/parse.c
dive_end():
called on freshly parsed dive.
7) desktop-widgets/command_divelist.cpp
DiveListBase::addDive():
called on dive which is newly added to core.
moveDiveToTrip():
called on dive that was removed from trip a few lines above.
8) mobile-widgets/qmlmanager.cpp
QMLManager::undoDelete():
called on dive where divetrip was reset in the previous line.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In 302f6adb79 dive-splitting was made
undo-able. To this goal, the dive-splitting functions were split in
two types: Those that operate directly on the divelist and those that
only allocate the dives. The former are not in use anymore, therefore
remove them. Since only the latter remain, remove the "_dont_insert"
appendix of the name.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In 014c04f8bd merging dives was included
in the undo-system. This made the merge_two_dives() function caller-less.
Remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In f427226b3b autogrouping / removal
of autogrouping was moved into the undo-machinery. This made the
remove_autogen_trips() function caller-less. Remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In f427226b3b a combine_trips_create()
function was introduced that combined trips without deleting the old
trips. This was necessary for making combine-trips function undo-able.
The old combine_trips() function is not used anymore. Therefore remove
it. Rename the combine_trips_create() function to combine_trips() as
no differentiation is needed anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In moveDivesBetweenTrips() a the model is informed of dives
that are moved between trips. A flag tells the model to delete
empty trips. If dives were removed in batches [use case: split
a big trip into multiple smaller trips] the flag would be sent
for every batch. This was handled gracefully by the model code,
but it gave a warning message.
Set the flag only for the last batch, when the trip is *really*
empty.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, when selecting "Load media files even if time does not
match the dive time", the media are added to *all* selected dives.
Instead add it to the closest dive.
This seems like the less surprising behavior. Of course now if the
user really wants to add a media file to multiple dives, they will
have to do it manually.
To avoid a messy interface, this is solved by moving the iterate-
over-selected-dives loop to the core. Thus, a helper-function can
be made local to its translation unit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
At this point in time there seems something wrong with jcenter that
is used to download all Android build artifacts from. It simply does
not find the needed stuff on there and our build fails. Its unclear
if this is a temporary issue at jcenter, or its just an intended change.
This fix is a bit of a hack. It provides our own gradle build spec
instead of the one that is provided from Qt (which is pulled in using
androiddeployqt). Added is a working download link to maven, and a
newer com.android.tools.build:gradle is used compared to Qt.
All this makes Travis happy again.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
dive_create_picture() is called from DiveListView::matchImagesToDives()
with a copy of the picture-filename. But:
- On error the filename is not freed
- On success the filename is strdup()ed
Thus, in all cases the memory is lost. Instead, pass in a temporary
buffer using qPrintable().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
... otherwise this change is not saved when saving to git.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit 911edfca71 changed the dive list
on desktop to update positions of trips when adding/removing dives.
A very unlikely case, but necessary for consistency.
For a trip to be moveable down, its index has to be one-less than
the maximum index, which is "items - 1". The code was doubly wrong:
it forget the "1" and checked for less-or-equal instead less-than.
Thus this was effectively an off-by-two error. Fix it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make sure all required Android SDK components are explicitly installed
before starting the actual build.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
With commit 0d8fc7ef970e of qt-android-cmake, the buildtools version
is automatically detected. So do not try to pass it any more, as
this breaks the build.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
EMPTY_DIVE_STRING used to be a string-literal representing missing
information ("--"). In 6985c123d4 it
was replaced by the actual empty string. Using a literal to represent
the empty string seems a bit pointless, therefore remove it completely.
Notably:
QString(EMPTY_DIVE_STRING) -> QString()
if (temp.isEmpty()) temp = EMPTY_DIVE_STRING; -> noop
if (s == EMPTY_DIVE_STRING) -> if (s.isEmpty())
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In dive.h there was a redundant 'extern "C"' block defined inside
another 'extern "C"' block. Remove.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Desktop used the hidden_in_filter flag in struct dive, mobile
used its own vector plus a new showndives member in struct dive_trip.
Unifiy these to use the same core-facility, viz. hidden_by_filter.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functionality was used by the desktop filter. To unify desktop
and mobile, move it into two new functions in divelist.c
Since one of them is the only caller of is_same_day() move that
likewise into divelist.c and make it of static linkage.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
QML's ListView uses the "section" property to test if items belong to the
same section. Apparently, this must be a string and therefore we can't
pass e.g. a dive-trip object. Therefore a specially formatted string
was passed in, which was guaranteed to be unique (contained the dive-trip
pointer value) and the fully formatted trip-title and short-date.
The disadvantage of that approach is that the formatting is performed for
every dive and not every trip. Perhaps not a problem now, but it makes
it for example necessary to cache the number of filtered dives.
To be more flexible, pass in only the pointer value formatted as
hexadecimal string and provide a function to convert that string
back to a trip-pointer (in the form of a QVariant, so that it can
be passed to QML). Moreover provide two functions for formatting the
title and the short-date.
The three new functions are members of DiveListSortModel. This might not
be the perfect place, but it is easy to reach from the DiveListView.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveObjectHelper::trip() function was
1) Misnamed: it returned the *location* of the trip
2) Not used outside of DiveObjectHelper
Remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Just as we did for pointer to struct dive_site, make pointers to
struct dive and struct dive_trip "Qt metatypes". This means that
they can be passed through QVariants without taking a detour via
void *.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implement the protocol in Erik Baker's document
"Oxygen Toxicity Calculations". This code uses a
third-order polynomial approximation of Baker's
equation 2. Provision is made for
PSCR and CCR dive logs and dive plans. In the
case of dive logs, the values of o2 sensors are
used if there are data from such sensors. For CCR
only the data from the first O2 sensor is used even if
there are more than one sensor. This is a potential
weakness, but this function is probably NOT the
place to calculate mean o2 values accross all sensors
and to emulate voting logic to reject info from
aberrant sensors.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
In 64e6e435f8 the when field of struct
trip was removed. Accordingly it was not read from git repositories.
This produced a large amount of user-visible error messages.
Reinstate the trip-date and time parsing functions, but ignore
the value.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit 6b283e598a replaced the linked
list of dives in a trip by a table. Embarassingly, on dive deletion
the index of the dive in the table was compared for "!= 0" instead
of ">= 0". Thus, the first dive of a trip wouldn't be deleted, which
ultimately led to a crash, as different parts of the code were now
in disagreement over whether the trip is empty or not.
Fix the comparison.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The whole point of the undo-command system is that the divelist
doesn't have to be refreshed. Therefore, don't do it for autogrouping
/ deautogrouping.
Moreover, the divelist-changed flag is also set by the command and
doesn't have to be set explicitly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The only remaining use of the tripflag was to mark dives that
were removed explicitly from a trip, i.e. shouldn't be autogrouped.
Therefore replace the enum by a simple boolean.
Currently, there is no way of unsetting the notrip flag. But this
shouldn't result in a user-visible change.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The distinction between ASSIGNED_TRIP and IN_TRIP was used to
prefer non-autogenerated trips on merging of dives. But owing
to bit rot this seem to have worked only partially anyway:
The IN_TRIP field was set in create_and_hookup_trip_from_dive()
and immediately overwritten in add_dive_to_trip() called
in the next line.
Instead, use the trip->autogen flag to check for priority and
remove the ASSIGNED_TRIP flag alltogether.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
New gcc (v8.2) complains about memcpy()ing an object with non-POD
members. Even though this seems not to be an issue for template_options,
the warning has some merrit. The compiler will recognize when to do
a memcpy() anyway. Moreover, the assignment is easier to read and also
more secure, as a-priory we can't know if Qt's QColor copy-constructor
does some strange things (hopefully not).
Thus, replace memcpy() by simple assignment.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since upgrading to gcc 8.2 it produces noisy warnings about
potentially truncated strings. It doesn't recognize that
filenr can never become >4000. So clamp it down explicitly.
Do this by adding a function that does the assembly of the
filename path. Adding unnecessary code to silence compiler warnings
is dubious, but in this case it might be reasonable.
Fix a second instance by increasing the stack-allocated buffer
to 32 bytes. Hopefully nobody has more divespots than would
fit in a 9-decimal digit number!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When adding the dive to its trip before having filled out "when", the
dive gets added at the first position (when=0), which is usually not
correct. Instead, add the dive to its trip when all fields are correctly
filled out.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If the date of a dive changed, it might be necessary to reorder
the trips, as the date of the trip changed. Although this seems
like an odd usecase, move the trip if necessary, for consistency's
sake.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The when field gives the time of the first dive. Instead of keeping
this field in sync, replace it by a function that determines the time
of the first dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
addDivesToTrip() had one level of indentation too much owing
to a copy-and-paste error. Remove.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To make sorting more controlled, move all sorting functions into
the core. For this, introduce a "dive_or_trip" structure, which
represents a top-level item. Adapt the DiveTripModel accordingly.
There are now three sorting functions:
1) dive_less_than
2) trip_less_than
3) dive_or_trip_less_than
These should be used by all sorting code. By moving them to a
single place, the mess can hopefully be cleaned up.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On shift-times, the list of dives in a trip may become disordered.
Reestablish order with sort_table().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
As a step towards proper sorting, introduce a trip_less_than()
function in core. It simply sorts by the first dive, which should
be unique as dives may belong to only one trip.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dives of each trip were kept in a list. Replace this by a
struct dive_table. This will make it significantly easier to
keep the dives of a trip in sorted state.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Up to now, dives were added to the global dive table with
add_single_dive(). Split out the funtionality to add a dive to
an arbitrary dive in the add_dive_to_table_function(). The
difference compared to record_dive_to_table is that dives
are added at a specific position or the sort-criterion given
by dive_less_than(). This will allow to use a dive tabe for trips
instead of a linked list.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There were two versions of the insert_trip() function: one
would merge trips if a trip with the same date already existed,
the other wouldn't. The latter was introduced with the dive-list
undo work.
The problem is that the "date" of a trip (i.e. the first dive)
seems ill-defined as this is a volatile value. Moreover in
the context of making dive-import undoable this is a very
dangerous notion, as the caller needs control over when the dives
are added to a trip.
Therefore, unify these two functions and never merge trips.
The decision on merging dives now has to made by the caller.
This will be implemented in a future commit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The Cressi specific PID was not used
when serial_ftdi_open_device tried
to open the device.
Reported-by: Daniel Krupp
Signed-off-by: Daniel Krupp <daniel.krupp@gmail.com>