One major downside of the switch to a tree model is that sorting by
columns other than date was broken - it would sort the entries within each
date which is not all that useful.
After playing with some Gtk trickery that would allow us to filter out
those rows it quickly became clear that the much easier solution is to
simply maintain TWO models (and therefore two storages). This causes some
overhead and requires some careful tracking of all changes, but it turned
out to be rather straight forward to do.
dive_list now has three model related members:
model - current model displayed (which is one of the following two)
treemodel - the tree model
listmodel - the list model
One side effect is that the callbacks no longer can pass the model around
(as this could have changed since the callback was registered), but that
seems only a minor drawback and was easily addressed.
The implementation in this commit still has a couple of obvious flaws:
when switching back from the list model to the tree model all the
expansion state of the rows is lost and we end up with just a list of the
different years visible. Also, selections aren't maintained when switching
models.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We now support three hierarchy levels: day, month, and year. Each
indicated by a negative DIVE_INDEX for -1 to -3. This allows a nice
compact overview when doing date based sorting (the default).
As indicated in the previous commit, things still go wrong with sorting by
other columns as the entries are only sorted within each day, not globally
across the whole dive list.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is the very first rough cut. It switches things over to a tree model
so we can have date based summary nodes.
It uses a DIVE_INDEX of -1 for summary nodes to easily tell them apart
from actual dives. All the data functions are changed so the summary
nodes only show the date they cover.
The commit also adds a couple of debug functions to be able to easily peek
into the model from the debugger.
Lots of things left to do. There is no longer a first dive selected when
starting subsurface. Sorting by columns other than date is messed up. We
almost certainly want month and year summary entries as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For consistency with the rest of the dive_list we should interpret "no
weight systems recorded" as "no information" and therefore print nothing
instead of printing a total weight of "0" for these dives.
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>
This existed in the initial implementation to deal with an implementation
problem that was long since resolved. So now it just created just an ugly
empty line in the drop down menu for weightsystems.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With this change, if the user adds a new weightsystem to a dive, on
subsequent edits the weight amount for this weightsystem no longer
defaults to 0 but to the last weight that was used with this weightsystem.
So when the program imports a set of dives from the divecomputer and the
user starts editing them, once they enter the weight for the "integrated"
weightsystem the first time, for each of the consecutive dives that same
weight is the default once "integrated" is selected - which usually will
be the correct amount.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The "Save" entry will now automatically save over the last used file. If
no filename has been set, then that entry will also prompt the user for a
filename.
The filename is set when saving as well, so the next save will use the
same filename.
Signed-off-by: Mikko Rasa <tdb@tdb.fi>
It's customary for menu bars to not have icons.
Some items were lacking icons when there's perfectly good stock icons
available. I was a bit torn between the "new" and "add" icons for the
"add dive" item, since what it really does is create a new dive, but
the "add" icon is an uninteresting sheet of paper in the default icon
theme so I decided to use the "add" icon.
Signed-off-by: Mikko Rasa <tdb@tdb.fi>
This calculates a mean depth for the dive with a fixed ascent/descent
rate and an assumption that all of the bottom time is at the maximum
depth. It's not much, but it allows some derived values such as SAC to
make more sense.
The depth profile for such dives is now also generated with the same
assumptions instead of putting the samples at fixed percentages of the
dive duration.
Signed-off-by: Mikko Rasa <tdb@tdb.fi>
In file.c::readfile() the file was being opened once at fd declaration
time and then again a few lines later and only being closed once. Remove
the open() at fd declaration time leaving the later one where the fd check
is done.
Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Subsurface doesn't compile on OS X any more, because libdivecomputer
changed the way the header inclusion works: the include path from
pkg-config no longer includes the final "libdivecomputer" component, and
instead of doing
#include <header.h>
for libdivecomputer headers, we're now supposed to do
#include <libdivecomputer/header.h>
instead. Which is cleaner anyway.
The reason this only bit us on OS X is that I never trusted pkg-config
that much for non-system libraries on Linux (maybe it works, maybe it
doesn't, I've seen it go both ways), so on Linux we just used our own
version of the include path, and thus weren't affected by the
libdivecomputer config change.
Clean up the includes while at it - we no longer need (or want) the
device-specific header files, since we just use the generic functions.
Reported-by: Grischa Toedt <toedt@embl.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Several people reported the average time problem, but there's another
one lurking there too: if the dive duration is zero, you get bogus
average depth information too (but because that one was a floating point
divide, and by default they are unsignalling on x86, it didn't crash, it
just resulted in bogus results).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
I still suspect that using spinbuttons for the time handling is the
wrong way, and I'm a bit surprised the Calendar widget doesn't have a
mode where you can see/set the time too.
But this makes things at least minimally prettier, and initializes the
time entries to the current time (which is obviously not what anybody
really wants, but looks a lot better than defaulting to "midnight" or
some other random time that *also* won't be what anybody actually
wants).
I think this might be something we can live with, although I hope
somebody with good taste comes along and say "don't use spinbuttons, do
this: xyzzy" and makes things look better yet.
Also, I have this suspicion that I should put the time/depth/duration
stuff to the right of the calendar. Most displays are wider than they
are tall, so tall and skinny dialogs are bad especially if you have
limited vertical pixels. I still have flashbacks to my netbook-using
days, hating applictions that did that.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
No need for right-clicks. It's inconvenient on lots of laptops etc, so
allow just using the Dive menu as an alternative.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Christ, if you look up "Ugly dialog" on Wikipedia, I think it has a
picture of this "New dive" thing. Or it should have.
But it kind of works. Although with only a "max depth" entry, you can't
currently set average depths etc, so SAC-rates etc cannot be calculated
for these kinds of dives.
And the dive numbering is wrong. We do auto-number new dives that get
added at the end, but we do it as we add them, so when you *edit* the
dive information (before it has been added) the dive number shows up as
"#0".
So there's certainly room for improvement here.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.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>
This does mean that you have to build subsurface against a new version
of libdivecomputer, and that version is likely going to have various
slightly incompatible changes. But the new interfaces allow for easily
adding new supported dive computers without subsurface having to be
updated for each new vendor and model, so some slight pain is definitely
worth it this time.
I'm not even going to try to have some backwards-compatible version
here, the libdivecomputer interface changes are so extensive. Native
enumeration of devices is just the smallest part of it: the constants
and types that libdivecomputer uses now have much nicer names that all
start with DC_ or dc_, so you don't get the kinds of name clashes we had
with "gasmix_t" etc.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The cochran CSV pressure data is actually in units of '4 psi', not in
just psi. That seems to be the resolution cochran internally keeps
things in, and unlike the depth reading there's no conversion to
standard units in the export (for depth, the quarter-foot depth
resolution is converted to tenths of feet when exporting).
Yeah, none of this makes any sense to me either, but I knew it was the
case. I had just forgotten that factor-of-four when I did the importer.
With this fix, I get the same subsurface data (modulo some rounding
differences particularly for temperature) whether I go through David
McNett's UDDF converter, or just import the CSV data directly.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The Cochran Analyst software can export the basic dive information as
CSV files (comma-separated values).
Individual CSV files contain just one particular type of information:
depth, temperature or cylinder pressure, which is rather inconvenient.
However, the way subsurface works, you can just import these CSV files
all as individual dives, and then subsurface will automatically merge
the dives with the same date and time - and in the process it will also
merge all the samples.
So it turns out that we don't really need any special handling. You can
literally just do
subsurface <list-your-cochran-export-files-here>
and you're all done.
Of course, the CSV files really *are* pretty useless, since they don't
contain all the nice information about where the dive took place etc.
So you literally just get the dive profile. But that's better than
getting nothing at all.
I'd love to actually be able to parse the real native Cochran Analyst
software CAN files, but in the meantime this is at least a starting
point. And if I'm ever able to parse those nasty CAN-files, this makes
comparisons with the exports much easier.
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>
The Cochran CSV depth exports are indeed in tenths of feet, but the
decimal is always 0, 3, 5 or 8. Where the 3 and 8 are obviously 0.25
and 0.75 rounded up to one decimal place.
So Cochran does seem to be very much about imperial units, with depth
and cylinder pressure scaled by four (depth in quarter-foot increments,
pressume in 4-psi increments)
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The code is pretty useless, the comments perhaps equally so. I'm trying
to figure out what the data pattern is for the cochran CAN files. There
definitely *is* a pattern, but it actually seems to be different for the
files of different people - and it's not obvious in any case.
There probably are multiple versions of the format, and there might be
things like "David has a high-pressure sensor, and Alex does not" going
on too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
David McNett sent me some example Cochran CAN file data, along with his
UDDF exports of same. I still have absolutely no idea how to decode the
CAN files (although the subsurface decrypting code seems to correctly
decrypt the data, and I see binary patters rather than just noise), but
at least I can make sure we parse the UDDF portion better.
See also
https://github.com/nugget/cochran2uddf
for David's tool to convert the Cochran CSV exports into UDDF.
Data-source: David McNett <nugget@macnugget.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It should be possible to have a certain limit where we
stop zooming so that short dives are visible as such
at first glance. Therefore a "Zoom" button has been
added to the "Log" menu along with a shortcut (Ctrl + "0").
The user can now zoom/unzoom the plot and is still able to
quickly distinguish short dives from normal ones when
browsing the log.
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
The time marker increments have also been changed to better values.
Also, display more time information for short dives.
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
It is really annoying to have to type the device name each time you need
to import a dive from your computer, if you are not using the default
device name. This will save the device name in the configuration file and
matches the logic currently used to save the dive computer name in the
configuration file.
Signed-off-by: Terrance Stanfield <t@hollowcranium.com>
It's very annoying to have to do "make install" to test a new xslt file,
just because the default xslt path has the standard install path as the
first entry.
At the same time, we do want to default to just using the standard
install location first.
So to allow both testing, and having a nice sane default, just add
support for a SUBSURFACE_XSLT_PATH environment variable that overrides
the default one if it exists.
So then you can just do
SUBSURFACE_XSLT_PATH=xslt ./subsurface
to run subsurface from inside the git tree itself, using the current
files in the git xslt subdirectory.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This is, I think, the last piece of relevant information that I can find
in Szymon's SDE file.
Which is not to mean that we get all the conversions right, or that we
handle the more complex cases (still no multi-cylinder import, for
example). But it should be much better than it used to be.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This converts the weight information into subsurface weights, and also
adds visibility info (if it exists) into the notes for the dive.
More fall-out from me looking at the nasty suunto xml files, now that I
have a few that actually have some info that isn't just from the
computer download.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Looking at the XML of the two dives Szymon Kosecki sent out to the
subsurface list, I notice that our cylinder size conversion was wrong.
It looks like CYLINDERUNITS is what determines whether the cylinder size
is in metric (0) or imperial (1) units.
Of course, if you gave a cylinder size in cuft and didn't give a working
pressure, subsurface will just ignore the size as the random crap it is.
We *could* default to a working pressure of 3000 psi, of course.
This also picks up the CYLINDERDESCRIPTION value, although neither of
Szymon's dives actually had any description.
I need more SDE xml files to figure out how multi-cylinder dives look
etc, but I think this gets most *simple* SDE files converted almost
correctly now.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The xslt translation didn't add the <notes> tag for the notes, so while
it did select the notes from the SDM file, that never made it into the
subsurface notes.
Also added weather info to the notes, mainly as an example.
There are probably other things we could do, but this fixes at least the
trivial test-case from Szymon Kosecki.
Reported-by: Szymon Kosecki <skosecki@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This desktop entry lists a category that is not one of the registered
Main or Additional Categories in the FreeDesktop specification.
Refer to
http://standards.freedesktop.org/menu-spec/1.0/apa.html
for details.
Signed-off-by: Khalid El Fathi <khalid@elfathi.fr>
Acked-By: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It's missing a brief description. The "NAME" section is parsed by
lexgrog and used to generate a database that's queried by commands like
apropos and whatis. Replacement a hyphen by a minus sign.
Signed-off-by: Khalid El Fathi <khalid@elfathi.fr>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
flushing the entire registry is not required on windows. simply
closing the registry key when done would suffice.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
I'm hoping most other dive computers are quicker to import from than the
Suunto I have, but mine can take minutes to import all the dives. Sure,
we have that nice progress bar, so it shows that it's doing something,
but it's not really showing *what* it is doing.
So instead of showing just "Parsing dive X", let's show the date of the
dive. That way, when it takes two minutes to import all the dives, at
least you can see "oh, it's going back to the dives of last year" and it
then feels like you have some good reason for the delay.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Instead of using printf() to print the string updates ("Parsing sample
data" etc), introduce a function to show those strings in the graphical
progress bar itself.
Subsurface hasn't been a text-mode application in a long time ;)
This partially fixes the second todo entry from commit b0ba22a068
("Show dive import error messages in the import dialog") and generally
makes for a more helpful import - at least for the largely error-free
cases.
Sadly, the messages that really come from within libdivecomputer itself
(like "suunto_vyper2.c:193: Failed to receive the answer.") when things
go really wrong are not caught. libdivecomputer does have a notion of a
logfile (set with "message_set_logfile()"), but that ends up being
really inconvenient.
Maybe we could use some pipe setup or something. Oh well.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This was a todo item in commit b0ba22a068 ("Show dive import error
messages in the import dialog") which made the import dialog able to
retry the import on errors.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Sure, you can import a file too, but it really makes more sense to have
the actions related to importing new logs under "Log", I think. I don't
think of it as a file operation.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
.. not in the main window. And leave the import dialog open, so that
you can either try doing it again, or cancel. This makes it much easier
to re-try a failed dive import, and actually makes the failure more
obvious too.
Todo:
- make the "Ok" button change to "Retry" when an error happens
- try to see if we can catch the actual status update messages from
libdivecomputer and show them too in the import dialog. Right now
they are printed out to stderr by the library.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Always having to re-select the same dive computer got really annoying
when I had trouble importing the dives. Let's not force the user to do
that, since we could just remember the last dive computer used, and
default to that one.
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>
libdivecomputer has the absolute worst interfaces to any library *ever*,
and randomly changes those crappy interfaces when it adds support for
new dive computers.
It would have been much better if the interface was just a "open this
device" with a device descriptor structure pointer, so that when Jef
adds support for new devices, the old descriptors still stay around and
work the same way - there's just a new descriptor structure that you
*can* use if you want. Along with a data structure to name the devices
and their descriptors, this would actually mean that users could just
support pretty much any random device that LD supports.
But no, that's not how libdivecomputer works. It has random enums and
crazy different ad-hoc interfaces for different dive computers. Or,
like in this case, crazy different ad-hoc interfaces for the *same*old*
dive computer.
Right now, for example, the support for the new Heinrichs Weikamp "Frog"
computer added a flag to the interface for the old OSTC_2 support.
Breaking any libdivecomputer users even if you didn't need Frog support.
And is there a version number in the header files to check for? Yes,
there's a version number. But no, it's not useful, since it doesn't
actually change with the interface changes. This time, Jef actually did
change the version number (from 0.1.0 to 0.2.0) as part of new
development version, but there's no reason to believe that it will
change in the future as the interfaces change - it never has before.
So it's actually safer - and easier to understand - to check for the
existence of the new header file inclusion mechanism. A new version of
libdivecomputer that supports the HW Frog computer will include the
"ostc_frog.h" header file when you include the libdivecomputer device.h
file, and that will result in HW_FROG_H being defined.
So we can check whether libdivecomputer has the new interface and
supports the Frog by doing an "#ifdef HW_FROG_H" hack. Ugh.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We used to not properly update the dive info until we switched to
another dive when we edited it. This should fix it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus found this embarrassing bug: double clicking on a weight system in
order to edit it launched the edit function for the first cylinder
instead. Oops.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>