This completely changes how we keep track of selected dives: instead of
having an array listing the selection ("selectiontracker") or trusting
the gtk selection information, just save the information about whether a
dive is selected in the dive itself.
That makes it trivial to keep track of the state of selection across
group collapse/expand events, or when changing the tree view model. It
also ends up simplifying the code and logic in other ways.
HOWEVER, it does currently (re-)introduce an annoying oddity with gtk:
if you collapse a dive trip that has individual selections, gtk will
forget those selections ("out of sight, out of mind"), and when you do
*new* selections, the old hidden ones remain.
So there's some games required to make gtk do sane things. We may need
to either explicitly drop selections when collapsing trips, or make sure
the group entry gets selected when collapsing a group that has
selections in it. Or something.
There may be other issues introduced by this too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
I lied in the commit message for commit 0468535524a3 ("When editing multiple
files, don't override existing equipment entries"); the changes there did
not parallel the logic for the string entries. Now I think it does.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This fixes the bug that triggered the SIGSEGV that Linus worked around
earlier. I had forgotten to update this call path to the
edit_multi_dive_info function.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Pull dive-trip grouping from Dirk Hohndel:
"This turned into an updated pull request for the tree2 branch where I
implemented the date based grouping - but is actually a very different
topic: this adds the ability to edit multiple dives (and fixes some
issues with the dive editing overall). The reason for that is that it
reuses some of the infrastructure that I implemented in the tree2
branch for tracking the selected dives. More details in the commit
messages."
* 'tree2' of git://git.hohndel.org/subsurface:
Switch from date based to dive trip based grouping
Redo dive editing
Fix selecting and unselecting summary items
Apply sort functions to the correct model, don't select summary entries
Maintain selected rows when switching between list model and tree model
Create duplicate list model so sorting by columns works again
Improve tree model implementation
Allow date based grouping
This commit addresses two issues:
We now can add / edit / delete equipment from the edit dive dialog
We now can edit multiple dives at once
The latter feature has some interesting design constraints:
It picks the 'selected_dive' as the one to start the edit from - so if
this dive already has some information filled in, that information needs
to be overwritten before it is stored in all of the dives. Similarly, only
changes to the cylinders or weightsystems are recorded. Also, the notes
field is not editable in the multi dive edit mode (as that didn't seem
useful).
The workflow seems to work best if using the multi-edit right after
importing new dives from a dive computer. The user then can select all the
new dives and only needs to edit things like location, divemaster, buddy,
weights, etc. once.
This commit will create some obvious conflicts with the commit that adds
exposure protection tracking. It was implemented on top of the tree_view
changes as it reuses some of the infrastructure for tracking the selected
dives.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For simplicity and shortness, throughout subsurface exposure protection is
simply referred to as "suit".
Add the fields to the data structures, add the column to the dive_list
and the preferences dialog (once again with it being turned invisible by
default). Support loading and saving of the suit information.
Display the suit information in the Dive Info pane (this may be a bit
controversial as people could argue this should be in the Equipment pane)
and allow editing of the suit info, with our usual support for completion
and drop down lists to pick from.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the total weight carried on the dive in different weight systems
to the divelist. The column is by default not shown, which can be changed
in the preferences. The column is sortable.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was simply an omission in the current implementation. All the
plumbing was there but never got hooked up with the fixup_dive function as
intended.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Do a right-click to get a menu with the "Add dive" entry. Should do
delete too, but that's for later.
What's also apparently for later is to make this *useful*. It's the
butt-ugliest time entry field ever, and there's no way to set depth for
the dive either. So this is more of a RFC than anything truly useful.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Convert feet to mm, psi to mbar, and F to mkelvin. We do this elsewhere
too, but I'm going to need it for the Cochran CSV files, so let's do the
helpers now.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
On Linux and MacOS the subsurface_close_conf() doesn't really close the
config file (it flushes writes on MacOS), but on Windows it does
actually close the registry hkey.
Which is bad, if you change the settings multiple times - we assume that
the config file is open the whole time.
So add a "subsurface_flush_conf()" function, and call *that* when
changing configuration parameters. And call the close function only at
the very end.
Alternatively, maybe we should just open the config file separately
every time. I don't much care, maybe somebody else does.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This interface works the same way the "edit dive" menu item does: it's a
text entry meny item on the dive text entries (ie buddy/divemaster/notes
sections). Except you pick the "Delete" entry rather than the "Edit"
entry.
It kind of works, but it really is a pretty horrible interface. I'll
need to add a top-level dive menu entry for just deleting all selected
dives instead. And it would be good to be able to get a drop-down menu
from the divelist instead of having to do it from the dive text entries,
which is just insane.
But that requires gtk work. I'm not quite ready to get back into that.
Thus the "exact same insane interface as the explicit 'Edit' mode".
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Pull weight management from Dirk Hohndel:
"This is the fifth or sixth version of this code, I'm begining to lose
track. I still struggle with the balance between code duplication and
unnecessary indirectness and complexity. Maybe I'm just not finding
the right level of abstraction. Maybe I'm just trying too hard.
The code here is reasonably well tested. Works for me :-)
It can import DivingLog xml files with weight systems and correctly
parses those. It obviously can read and write weight systems in its
own file format. It adds a KG/lbs unit default (and correctly stores
that).
The thing I still worry about is the code in equipment.c. You'll see
that I tried to abstract things in a way that weight systems and
cylinders share quite a bit of code - but there's more very similar
code that isn't shared as my attempts to do so turned into ugly and
hard to read code. It always felt like trying to write C++ in C..."
* 'weight' of git://subsurface.hohndel.org/subsurface:
Add weight system tracking
Fix up some trivial conflicts due to various renaming of globals and
simplification in function interfaces.
- supports multiple weight systems per dive
- supports multiple weight system types
- supports import of weight as tracked by DivingLog
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We're going to eventually import non-xml files too, so let's begin
splitting the logic up.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Miika fixed the statistics code that didn't properly check for the "no
cylinder info" case - this cleans it up and just uses the helper
function in equipment.c.
Rename the helper to be slightly better named while at it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This works ok-ish, but doesn't allow us to click on the stars and edit
them in the divelist, which a user might expect to be able to do - in
most "star rating UIs" you simply click on the n-th star to set that
rating. Here you need to edit the dive and pick the rating from a drop
down menu.
Minor oddity: you can actually (if you force it) write anything you want
into the star rating. But anything that isn't one of the predefined
strings simply results in a zero star rating.
Overall the UI feels a bit... forced. But I think this is quite useful
anyway.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now that the dive info window is read-only, we need to edit the dives
some other way. We bring up a dive info edit dialog when you
double-click on the dive list entry for that dive.
I do want to have an "edit" button or keyboard shortcut or something
too, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Keep the sample pressure start/end data separate from the overall
cylinder start/end data - and clean the overall cylinder start/end data
if it matches the samples exactly to avoid the redundancy.
This breaks all the SAC calculations etc, which expect the cylinder
pressures to always be in the cylinder data. I'll fix that up
separately.
The reason for this is that we really want to keep the manually entered
data separate: the pressure plotting doesn't need the confusion, and
considers end-point data (with interpolation) very different from sample
data. Also, we do not want to pollute the xml save-file with data that
is computed.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Open JDiveLog files by translating them to subsurface format using XSLT.
These files are identified by the name of the first element (JDiveLog)
and transform is applied to only these.
The XSLT feature is compiled in only if libxslt is installed. The
transformation files are installed globally in Linux under
/usr/share/subsurface/xslt. Windows and OSX still need appropriate Makefile
changes and testing.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* 'add-info-stats-page' of git://github.com/dirkhh/subsurface:
Add Info & Stats page to the notebook
Even more places with pressure and volume conversions
Further cleanup of pressure and volume conversions
Use unit functions to get column headers, add unit function for pressure
More consistency improvements
Add new helper function to get temperature and unit
This provides the relevant information for the currently selected dive
plus a bunch of statistics over all dives in the dive_table.
The visual design has lots of room for improvement
- right now the different fields change size
- it might be nice to have a more modern look for the entries
- the O2/He field is odd - for most divers the He value will
always be 0, so maybe we should only show He if there's at least one
dive that uses He? Also, we simply do a comma separated list of gases
for all the tanks used
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Finally getting more consistent overall in how we convert between the
different units and how we decide which units to display.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Treat SAC and OTU consistently:
- SAC is now a member of struct dive
- it's calculated / populated at the same time with a helper function with
consistent API
Create get_volume_units function that returns volumes (e.g. used in SAC
rates) based on preferred units - make sure we have these conversions just
once in the code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Designed along the lines of get_depth_units - except we don't define a
specific number of digits to show.
Use this in the one spot we need it right now in profile.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
That's what gtk_init() does with gtk-specific arguments. IOW, if you do
things like
subsurface --g-fatal-warnings dives.xml
to get a real abort on gtk warnings, gtk_init needs to be able to
actually change argc/argv.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
No change at all to non-Windows builds.
Everything seems to work with preferences - but only tested on Win7
Remaining issue: displaying an icon (or the logo in the About dialog)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Right now they are displayed in one hbox which doesn't work if you have
many events - but the code itself works and correctly toggles the events
on and off.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
First step to being able to filter the events that we display in the
profile. We could (in theory) walk all the dives in the divelist when we
need this data, but it seems much more convenient to have them in an array
in one place.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way you can just type the first few characters of a location you've
been to before, and it will show you a list of possible completions.
Same for buddies and divemasters (which take the completions from a list
of people you've used before).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This way the cylinder model list will contain all the different
cylinders that we have ever seen, rather than only containing the models
that we have *edited*.
That makes it much more practical to add new dives with the same
cylinders that we've used before, because now those cylinders will show
up as cylinder models even if we haven't looked and edited the old dives
first.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Open (or adding a file name on the command line) means that this is just
one of the files that you consider part of your dive history. So dives
don't get automagically numbered and the dive_list is not considered
"changed" just because another file was opened.
Import (or adding a file on the command line after --import) means that
you are importing the content of this file to your dive history. So if the
imported file has un-numbered dives that are newer than everything else,
those get correctly renumbered. And importing marks the dive_list as
changed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When importing (or reading xml from files) new dives, we now renumber
them based on preexisting dive data, *if* such re-numbering is obvious.
NOTE! In order to be "obvious", there can be no overlap between old and
new dives: all the new dives have to come at the end. That's what
happens with a normal libdivecomputer import, since we cut the import
short when we find a preexisting dive.
But if any of the new dives overlap the old dives in any way, or already
have been numbered separately, the automatic renumbering is not done,
and you need to do a manual renumber.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We can instead 'Open' these files as they are just bastardized XML files.
This gets us back to a more consistent point where 'Import' gets data
directly from the dive computer (and hopefully soon we will add the
ability to load a dive directly from a uemis SDA to libdivecomputer),
and 'Open' loads a file from the filesystem of the computer we are
running on (this last sentence phrased so awkwardly as the uemis Zurich
SDA is a computer and presents a file system when connected via USB - it
just doesn't have the dive data in an accessible format in that file
system).
As a bonus we get to throw away quite a bit of code (the uemis specific
file handling, mini-XML parser with helper functions, the file open dialog
in the importer). Yay!
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
* 'otu-tracking-v2' of git://github.com/dirkhh/subsurface:
Make OTU column invisible by default
Add OTU to divelist
Calculate OTUs for every dive
Fix up trivial conflicts in dive.h (due to dive event handling also
adding a field to the dive structure)
Parse them, save them, take them from libdivecomputer.
This doesn't merge them or show them in the profile yet, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The calculation assumes that the cylinderindex in each sample tells us
which PO2 the dive was breathing at that time. This needs to be verified
with dives where there is an actual gas switch.
No idea where to display them, yet. Far fewer people will care about this
than care about SAC - does this still rate a spot in the dive_list?
I guess I could make it part of the dive_info - but it's not editable.
It doesn't seem to fit with the equipment page (even though this is the
one editable field that is related - nitrox %)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
* 'quit-handling' of git://github.com/dirkhh/subsurface:
Use the last (or only) filename on command line as default for saving
Show the "save changes" dialog before the main window is destroyed
Check for changes at regular 'quit' events as well
Catch changes to the info of the current dive when quitting
Tracking changes to tanks is trivial
Simplistic first attempt to get changes saved when quitting subsurface
Use the actual degree sign for temperatures (°F and °C), and make sure
everything uses the proper "set_source_rgb[a]()" wrappers to set the
colors.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The following are UI toolkit specific:
gtk-gui.c - overall layout, main window of the UI
divelist.c - list of dives subsurface maintains
equipment.c - equipment / tank information for each dive
info.c - detailed dive info
print.c - printing
The rest is independent of the UI:
main.c i - program frame
dive.c i - creates and maintaines the internal dive list structure
libdivecomputer.c
uemis.c
parse-xml.c
save-xml.c - interface with dive computers and the XML files
profile.c - creates the data for the profile and draws it using cairo
This commit should contain NO functional changes, just moving code around
and a couple of minor abstractions.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It got removed by some of my overly aggressive cleanup in commit
fefcbf125e ("Remove dive info frame") because the dive info frame
initialization also initialized the main window title..
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>