This function was globalized in be462ae1a6 to be used for the calender
widget, but that never came to be. Therefore, for now unglobalize it
until it is needed. That said, there probably is a helper function to
turn pictures into gray-scale.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is no reason that this dialog is a singleton. Since it is modal,
it can be created on demand. Apart from removing superfluous global state,
this simplifies code, because preparing the widget can now be done in
the constructor instead of overriding the showEvent() function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is no reason that this dialog is a singleton. Since it is modal,
it can be created on demand. This simplifies code, because the mode
(selected-only or all-dives) can be set in the constructor.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Use C-style function definitions (squirly brackets on new lines) and
remove empty lines at end of file.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The salinity value was not displayed with localized thousands separators.
E.g. to a user of a German locale the density read as slightly over
1 g/l, when it should be approximately 1000 g/l. For consistency, also
localize that value.
Also localize the CNS and OTU numbers, even though these should
(hopefully!) never come with thousands separators.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In analogy to the timestamp -> QDateTime conversion, create a
common function.
1) For symmetry with the opposite conversion.
2) To remove numerous inconsistencies.
3) To remove use of the deprecated QDateTime::toTime_t() function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Move this function from maintab.cpp to qthelper.cpp. Since the
functionality was used in numerous places, use the helper function
there as well. This removes a number of inconsistencies. For example,
sometime setTimeSpec(Qt::UTC) was called, even though the
QDateTime object was already created with that time spec.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was more painful than expected, because we get the "preferences"
changed signal too early when the user switches to system format.
The correct format is set by the preferences-widget, not the preferences
subsystem.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When switching to system defaults, refresh the fields in the preferences
UI so that the user can tell how the fields will be formatted.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was an old "optimization" to avoid double plotting of the
pictures, first by the profile itself, then by the picture tab.
Since the profile now updates the pictures itself, this must
be removed: The picture tab doesn't do it anymore.
Fixes#2833
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was still using the archaic macro version, because Qt decided
to parameter-overload the signals (which turned out to be a horrible
idea). However, since we switched to fairly recent Qt this can be
solved using the qOverload template.
In this case things are a bit more complicated because we overload
the corresponding slots. Since we have control over that, let's
just disambiguate their names instead of using the cryptic qOverload.
While doing this, tighten the access specifiers of the slots. Turn
public into private and protected as appropriate.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is no point in calling these functions directly, so we can
just make them private. Morover, add override specifiers were they
were missing and remove a pointless default parameter to the
testActivation() function. It was not used anywhere.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We put the pointer and reference modifier to the variable, not the
type. Some people don't like this, but
1) This is consistent with the rest of the code base.
2) This is how C and C++ parse, love it or hate it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This fixes a rather subtle bug.
In btdiscovery.cpp we are detecting dive computers based on their BT name and
are setting up product+vendor as the key for that lookup. QMap always uses case
sensitive comparisons and a tiny inconsistency snuck into our code.
libdivecomputer names for the Aqualung dive computers i200C / i300C / i550C end
in an upper case C (as matches the official branding), but in btdiscovery.cpp
we have those names with lower case c. And therefore didn't recognize these
dive computers.
Obviously this is easy to fix by fixing those three strings, but I decided that
it was silly to set ourselves up for similar oversights in the future. So
instead I switched the matching of the descriptor to simply be allways all
lower case.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Number 3 overall committer with currently 9% of total commits and 27% of all
commits in the last three years.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The tags of the dive site were shown/hidden when changing the
current dive.
Thus the following could happen:
1) User changes to dive with no tags. Tags are hidden.
2) User add image, which creates GPS tag
3) Tag is updated but not shown.
Fix this by showing/hiding tags when they are calculated not
when switching the dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is completely irrelevant, however out of principle,
let's free the tab-widgets at the end of the application.
To do so, use Qt's object hierarchy. I'm not a fan of this
kind of memory management, but it is how it is.
Moreover, remove the explicit constructor of MainTab, since
it doesn't differ from the default constructor anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Clearing displayed_dive here makes no sense for two reasons:
1) This is only called on startup, when displayed_dive is not
yet initialized.
2) The tab-widgets don't use displayed_dive anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code used displayed_dive. However, virtually all the
displayed data is now derived from current_dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since the displayed data is extracted from current_dive it makes no
sense to query displayed_dive for the dive mode.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If current_dive was not set, the code would clear the tabs
right after updating the data. We might just as well set the
data only if current_dive is set.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This used the displayed_dive object. However, we now use current_dive
to designate the currently displayed dive. Thus, use this instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should have been converted a long time ago.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The goal here is to remove a dependency on displayed_dive.
While doing so, make the model more general and display any dc.
Pass in the dc of the current dive instead of displayed dive,
since all other tabs are already converted to show data of
the current dive. The QStrings are cached since we generate
them anyway, so we may just keep them. Thus, there is no
danger of the dc becoming invalid.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To reset the core data structures, the mobile and desktop UIs
were calling into the dive-list models, which then reset the
core data structures, themselves and the unrelated
locationinformation model. The UI code then reset various other
things, such as the TankInformation model or the map. . This was
unsatisfying from a control-flow perspective, as the models should
display the core data, not act on it. Moreover, this meant lots
of intricate intermodule-dependencies.
Thus, straighten up the control flow: give the C core the
possibility to send a "all data reset" event. And do that
in those functions that reset the core data structures.
Let each module react to this event by itself. This removes
inter-module dependencies. For example, the MainWindow now
doesn't have to reset the TankInfoModel or the MapWidget.
Then, to reset the core data structures, let the UI code
simply directly call the respective core functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is a bit hairy, because two things might happen if the
picture has a geo location:
- A dive gets a newly generated dive site set.
- The dive site of a dive is edited.
Therefore the undo command has to store keep track of that.
Oh my.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If we want to make addition of pictures undoable, then create_picture()
must not add directly to the dive. Instead, return the dive to which the
picture should be added and let the caller perform the addition.
This means that the picture-test has to be adapted.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The code is rather complex. Firstly, we have different representations
of pictures throughout the code. Secondly, this tries to do add the
pictures in batches to the divepicture model and that is always rather
tricky.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
An empty class that was not used anywhere. This allows us to
remove a few include files as well.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
TabDivePhotos::saveSubtitles() had an unused local variable.
Clearly a copy&paste oversight.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
It makes no sense to have the view in item-selection mode, since
each picture represents a row. Thus we can remove a few lines
of code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The date and time fields of the main tab posted undo events
for every date/timeChanged signal. Thus, when changing the
day of the month to e.g. 21, this would result in two date
change events: one to the 2nd and one to the 21st. This is
very irritating.
Instead listen to editingFinished() events, which thankfully
exist for these widgets.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The cylinder-based statistics where not updated when an undo
command edited cylinder data. Do so.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The SAC rate, etc were only updated when switching between dives.
They should always be updated when an undo command changes (adds,
edits, removes) the cylinders of a dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
It was suggested in a review of a previous patchset that we should
capitalize the use of "use dc" to "Use DC" - but if we were going
to do that we should do it everywhere, not just in the one place.
This is the followup to do that.
Signed-off-by: Monty Taylor <mordred@inaugust.com>
In the code, the difference between SALTYWATER and SALTWATER is hard
to see. More importantly, in the UI - Brackish is the word for water
that has more salt that freshwater but less salt that seawater. The
docs already use the word to clarify what is meant.
These can be useful in a printed divelog, especially if the
log entry is also showing weight and exposure suit.
Signed-off-by: Monty Taylor <mordred@inaugust.com>
When printing, the dive plan was prepended with a logo, a disclaimer
and the profile. Then it was restored by setting the plan of
displayed_dive.
Instead, simply save the original plan in a QString and restore that.
This removes a further dependency on displayed_dive, which I'd like
to make local to the planner.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
MainWindow::editCurrentDive() used to be a general function to enter
edit mode. Nowadays, this is only called for one very specific case,
namely editing the profile of a manually added dive. Therefore, we
can remove the if-branch that dealt with planned dives.
Moreover, we can do the test right at the beginning and remove
a warning message for duplicate "edition", as this is not
possible anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was only one caller of MainWindow::setupForAddAndPlan() left
and that caller immediately called DivePlannerPointsModel::createSimpleDive().
Thus, we might just as fold the former in the latter and thus
concentrate all the prepare-dive-for-plan business in one place.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Thus, the MainWindow doesn't have to extract the plan from
displayed_dive. This is a tiny step in an attempt to detangle
the interfaces. The bigger goal will be to make displayed_dive
local to the planner.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When calculating variations, they were sent to the mainwindow,
which updated displayed_dive accordingly. Do this directly
in the planner-model.
The idea is to detangle interdependencies and to make the
code reusable (planner on mobile?).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveListView had a singleSelectedTrip function that
returns the selected trip if exactly one trip is selected.
This could be very slow if numerous non-trip items were
selected, because all the selection indices were back-
translated by the proxy model.
This could make selection changes very slow, because the
MainTab used said function to determine whether it should
show trip or dive data.. Indeed, with a 3500 dive test log,
when selecting all dives in tree mode, the updating of the
TabWidgets is sped up from 130 ms to 5 ms this commit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>