In signals dives were sorted by date. This criterion is not be unique.
Therefore sort by the dive_less_than() function of the core to avoid
any inconsistencies between the Qt-models and the core data.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is this anti-pattern in QModel data() functions to assign
to a "ret" variable and return at the end of the function. This
is inefficient, as the object is not directly constructed at
the space reserved by the caller.
Change the functions in WeightModel and CylinderModel to return
the objects directly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The last direct user of the used parameter was removed in
16276faa45, the last actual user in
e2bbd0ceec.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was reimplementing functionality that was already there.
Simply call the already existing function.
Thus, we don't have to export the grow_dive_table function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The cns_table was only used in divelist.c. Make it of static
linkage accordingly.
The cns_table_headers enum is likewise only used in divelist.c.
Therefore move it from the header to the .c file.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The function declarations of regressiona(), regressionb() and
reset_regression() were given in an independent translation unit.
Move them into the proper header file. To ensure consistent function
signatures is the whole point of header files, after all.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The lookup tables decostoplevels_metric and decostoplevels_imperial
in planner.c were not used outside the translation unit. Make them
static.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
gaspressure.h had definitions of non-exported structs, but did
not declare the only function exported by gaspressure.c.
Therefore, move the struct definitions into gaspressure.c and
the declarations of the populate_pressure_information() function
from profile.c to gaspressures.h.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
But only functions that operate only on gases. Functions concerning
cylinders or dives remain in dive.c or are moved to equipment.c
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
gas_density() was declared extern in the header and defined inline
in the translation unit. I didn't even realize that this oxymoron
is valid. Remove inline and an Java-style function definition.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions were spread out over dive.c and divelist.c.
Move them into their own file to make all this a bit less monolithic.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is an equipment.c file, but no corresponding header. Move the
corresponding functions into a newly created header. This does not
improve compile time since, at least for now, equipment.h is included
in dive.h. But it makes things more consistent.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The comment said "Clear everything but the first element" but
actually the macro freed the whole list including the first element.
For dive computers it was explicitly called on the second element.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make dive.h a bit slimmer. It's only a drop in the bucket - but at
least when modifying tag functions not the *whole* application is
rebuilt anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Headers should not have to be included in a certain order.
Therefore include stdarg.h and stdio.h in membuffer.h, since
the latter uses FILE and va_list.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is a function for copying tag-lists, use that instead of the
raw STRUCTURED_LIST_COPY macro-invocation. This will help in moving
tag functions into their own translation unit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was probably used for debugging but has no callers anymore.
Let's remove it. If needed, it can be trivially readded.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When a different field is edited, hide any old multi-dive-edit
warning message. The reason is that we might want to add an "undo"
button to the message. But this will undo the wrong command if
we don't hide the message.
Sadly, this means that we can't use animated show / hide, because
an animatedHide() followed immediately by an animatedShow() does
not necessarily show the message. In other words, and animatedShow()
does not interupt a started animatedHide()!?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The multiple-dives-edited message was shown even if the value was
not changed. Notably, when tab-flipping through the dive fields.
Therefore, changed the execute_edit() function to return zero
when no command was executed. For this, return a boolean from
the execute() function indicating whether the command was really
executed or trashed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On the MainTab, warn if more than one dive was edited. To this purpose,
add a new KMessageWidget with an "OK" button that closes the message.
Code is mostly a copy of the already existing "Editing dive" message.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a pointless one-liner function. Let's remove it. The
message it shows will probably be moved to the profile in the
not-so-distant future anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To enable a "multiple dives edited" message, return the number
of edited dives from dive edit undo commands. Since there are
two kinds of these commands, viz. normal fields and tag fields,
and the former use templates, create a common base class that
can return the number of dives. Yes, the class hierarchy is
getting scarily deep! At least, this gives a tiny bit of
code-reuse.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When tabbing through the dive-info fields we get *EditingFinished
signals. This would create undo commands. The undo commands should
recognize if nothing changed. But for the temperature fields,
owing to rounding, an unchanged text could actually represent a
different value.
This would lead to very confusing situations:
1) Edit air temperature
2) Press tab to finish editing
3) Focus goes to water temperature
4) Try to undo change in menu
5) When opening the menu water temperature loses focus
6) Water temperature is edited
7) Undo undos the water temperature, not the air temperature
8) Goto 4
Fortunately, QLineEdit fields have the isModified() member function
that returns true if the field was changed by the user. Use
this to prevent this case. This is not a general method, i.e.
it has to applied to every field with that problem. But it is
less intrusive than subclassing the QLineEdit class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The PIMPL idiom is used by some frameworks (notably Qt) to
ensure binary compatibility. Objects consist only the general
object header (ref-count, connections, children, etc..) plus
a single pointer to private data.
MinMaxAvgWidget was implemented using this idiom. This seems
to make no sense, as we don't produce a general library with
the need of a stable ABI. Let's remove this unnecessary
indirection.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Owing to the recent undo-changes, the git id was not invalidated
when accepting changes to cylinders and weights.
Do this in the MODIFY_DIVES macro for now.
Reported-by: Jan Iversen <jani@apache.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The location fields are hidden in trip mode. Only the location-popup
button was shown. Hide it as well.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A regular expression was generated and then copied twice without
apparent reason. Remove these copies.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
preprocessTemplate() replaces variables of the kind "dive.weight0"
by "dive.weights.0". Replace the old code by regexps. This not
only makes the code significantly shorter, it also makes it independent
from the name of the dive variable (i.e. "dive").
Moreover, it removes a dependency on MAX_WEIGHTSYSTEMS and MAX_CYLINDERS,
which might help in removing these restrictions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>