The planner does not know about events except gas
changes. But if the dive comes from the log, we
should preserve the dive computer events. At least
those that happend before we started to delete
waypoints to let the planner take over.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
There is the free_picture() function with the same functionality.
The compiler/linker should recognize that and remove the duplicate
code, but still...
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
While having the local user information in the repo on Linux seemed
clever when we implemented it, it's inconsistent with all the other
platforms. Let's just not do that unless the user has indeed set
a global name/email pair for git.
Instead indicate if this was Subsurface or Subsurface-mobile.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Apparently this was used to hide events in pre-Qt times. However,
that has already been reimplemented in different ways. Let's remove
that commented-out code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
For undo, we want to create gas change events without adding them
immediately to the dive computer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is a slight complexity here owing to the fact that the profile
works on a copy of the current dive: We get a copy of the event and
have to search for the original event in the current dive. This
could be done in the undo command. Nevertheless, here we do it in
the profile so that when in the future the profile can work on a
non-copied dive we can simply remove this function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We have a remove_event() function that
1) frees the event
2) works on the current divecomputer
3) compares the events because the profile has copies of events
However, for undo commands
1) we want to keep the event so that we can readd it later
2) we have to work on arbitrary divecomputers
3) we don't work with copies of events
Therefore, create a new remove_event_from_dc() function that
does all that. Moreover, make the event argument to remove_event()
const to (slightly) point out the difference in the API.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
add_event() creates and adds an event from the given parameters.
For undo, we want to do these separately, therefore split this
function in two parts: create_event() and add_event_to_dc().
Keep the add_event() function for convenience. Moreover, keep
the remember_event() call in there, so that undo-commands can
call remember_event() once, not on every undo/redo action.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Moreover, move the declaration from dive.h to equipment.h.
The result is a) more consistent and b) more logical.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a quick hack to reduce the noise in the log file when chasing other
bugs. Maybe this should not be enabled on release builds, but right now I don't
think the harm that having this in would do.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When loading dive data, populate the fulltext index. When clearing
dive data, free the fulltext index. When deleting a dive, remove it
from the fulltext index.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add code that indexes all words of a dive and provides searching
for words.
A query is represented by the FullTextQuery class, which can be
initialized by assigning a string to it. It is basically a list
of words.
The result of a search is stored in the FullTextResult class,
which is a list of dives.
The actual indexing and searching is implemented in the FullText
class. However, this class is not exported because the interface
is partially accessible to C. Notably, the reloading of the
fulltext index is done from the C core.
Currently, the indexing and searching is totally unoptimized.
In a ~4000 dives test-log searches typically took single-digit
ms times. There is ample room for optimization (e.g. when
searching for multiple words, chose the words with few dives
first and when down to a few dives, check them individually).
The words of each dive are tokenized and uppercased and
cached with the dive. A pointer to these words is stashed
in the dive structure.
For now, compile only on desktop.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These just make no sense. Since the value is copied, it
has no meaning to the caller whether the function can
change the value (and vice versa for return types).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The user may modify the salinity by selecting a water type from the combobox.
The new datum does not replace the existing salinity value but is stored in a
separate variable within the dive structure. If the dc-based salinity is
overwritten, there is an exclamation mark next to the modified salinity value
to indicate that the salinity has been overwritten. The dc-derived salinity can
always be recovered by selecting the "use dc" option in the combobox.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Connect the UI to the underlying dive structure. Enable proper initialisation
and management of star widgets while Information tab is active. Enable undo for
the addtional star widgets.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add flag to subsurface_mobile (only when compiling for desktop)
to allow using qml files from disk instead of resources.
This allows testing qml changes with just restarting subsurface_mobile.
Signed-off-by: Jan Iversen <jan@casacondor.com>
Instead of using fixed size arrays, use a new cylinder_table structure.
The code copies the weightsystem code, but is significantly more complex
because cylinders are such an integral part of the core.
Two functions to access the cylinders were added:
get_cylinder() and get_or_create_cylinder()
The former does a simple array access and supposes that the cylinder
exists. The latter is used by the parser(s) and if a cylinder with
the given id does not exist, cylinders up to that id are generated.
One point will make C programmers cringe: the cylinder structure is
passed by value. This is due to the way the table-macros work. A
refactoring of the table macros is planned. It has to be noted that
the size of a cylinder_t is 64 bytes, i.e. 8 long words on a 64-bit
architecture, so passing on the stack is probably not even significantly
slower than passing as reference.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Memory is cheap these days. Still, this was wasteful. On a 64 bit machine we
went from 1620 to 1592 bytes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When computing the best mix for a target depth, for helium, one
can either require that the partial pressure of N2 is the same
as at the target depth or the partial pressure of N2 plus O2.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The dive-computer freeing code was local to dive.c. Implementing
the replan undo-command will need that functionality. Therefore,
export it as a global function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Even though the returned dive is not const, the table is not
changed, as it only contains pointers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When exporting dive sites, the dive sites to be selected were collected
in the C-core. But that doesn't have access to the selected dive sites
if in dive site mode. Therefore, collect the dive sites in C++ and
pass down to the core. Use a std::vector to avoid memory management
woes.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The fill_default_cylinder() function calculated the MOD based
on the currently displayed dive. This does not seem to make sense:
- When importing dives, why would we care about the altitude and
salinity of the currently displayed dive, possibly from a different
trip.
- The planner is supposed to be thread-safe and should not touch
global variables.
Of course this means that the importing-functions have to fill
out altitude and salinity before creating the default cylinder,
but this is their problem. For a freshly created dive they will
get the default values, which still seems less random than the
values from the displayed dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A number of architecture-dependent functions were declared in
dive.h. Move them to file.h so that not all file-manipulating
translation units have to include dive.h. This is a small step
in avoiding mass-recompilation on every change to dive.h
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Move the declarations of the "report_error()" and "set_error_cb()"
functions and the "verbose" variable to errorhelper.h.
Thus, error-reporting translation units don't have to import the
big dive.h header file.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace the fixed-size weightsystem table by a dynamically
relocated table. Reuse the table-macros used in other parts
of the code.
The table stores weightsystem entries, not pointers to
weightsystems. Thus, ownership of the description string is
taken when adding a weightsystem. An extra function adds
a cloned weightsystem at the end of the table.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Another tiny step in making dive.h smaller: move function
declarations to deco.h if these functions are defined in deco.c
and don't directly concern dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The string_to_*() functions were declared in dive.h and qthelper.h.
Moreover in one file they were declared with C in the other with
C++ linkage. This only works because qthelper.h includes dive.h
first.
Fix this anomaly by declaring the functions only in qthelper.h,
but moving them from the C++ to the C part.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since this function doesn't act on a dive and is only related
to cylinders, move it to equipment.c and equipment.h.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Steve Williams reported a crash when saving a previously loaded dive as
xml, and gave a gdb backtrace.
It turns out that if we can't parse the cylinder use type (OC, diluent,
oxygen, unused) we initialize the cylinder use to an invalid type, and
then when we save it, we mess up.
Fix it up by doing proper limit checking before accessing the
"cylinderuse_text[]" array when saving.
Reported-by: Steve <stevewilliams@internode.on.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
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>