aboutsummaryrefslogtreecommitdiffstats
path: root/save-xml.c
AgeCommit message (Collapse)Author
2013-01-09Assemble the actual Suunto serial numberGravatar Linus Torvalds
It turns out that the serial number returned by libdivecomputer isn't really the serial number as interpreted by the vendor. Those tend to be strings, but libdivecomputer gives us a 32bit number. Some experimenting showed that for the Suunto devies tested the serial number is encoded in that 32bit number: It so happens that the Suunto serial number strings are strings that have all numbers, but they aren't *one* number. They are four bytes representing two numbers each, and the "23500027" string is actually the four bytes 23 50 00 27 (0x17 0x32 0x00 0x1b). And libdivecomputer has incorrectly parsed those four bytes as one number, not as the encoded serial number string it is. So the value 389152795 is actually hex 0x1732001b, which is 0x17 0x32 0x00 0x1b, which is - 23 50 00 27. This should be done by libdivecomputer, but hey, in the meantime this at least shows the concept. And helps test the XML save/restore code. It depends on the two patches that create the whole "device.c" infrastructure, of course. With this, my dive file ends up having the settings section look like this: <divecomputerid model='Suunto Vyper Air' deviceid='d4629110' serial='01201094' firmware='1.1.22'/> <divecomputerid model='Suunto HelO2' deviceid='995dd566' serial='23500027' firmware='1.0.4'/> where the format of the firmware version is something I guessed at, but it was the obvious choice (again, it's byte-based, I'm ignoring the high byte that is zero for both of my Suuntos). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-09Move device_info handling into a new 'device.c' fileGravatar Linus Torvalds
The legacy nickname wrappers (that use the device_info structure) are left in gtk-gui.c. We can slowly start moving away from them, we don't want to start exporting that thing as some kind of generic interface. This isn't a pure code movement - because we leave the legacy interfaces alone, there are a few new interfaces in device.c (like "create a new device_info entry") that were embedded into the legacy "create nickname" code, and needed to be abstracted out. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-09Add support to planner to use additional gases during the ascentGravatar Dirk Hohndel
This change ended up being quite a bit bigger than expected as it uncovered a number of bugs in the existing code. The planner now handles gas changes correctly by creating (and later parsing) events in the simulated divecomputer. At the end of the dive specified in the input form the algorithm starts with the deepest interesting depth: either the first stop below our ceiling or the deepest depth at which we can change gases. It then traverses all the stop and all the gas change depth and at each stage ensures that we are allowed to ascend further before going on. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Remove autogroup from the preferences and store per file insteadGravatar Dirk Hohndel
Having two spots to toggle autogroup had always been a clear sign of insanity. The inconsistent ludicrous semantic of when we remembered the state of autogroup was even worse. This finally gets rid of that disaster and drops the autogroup setting from the preferences and makes it instead a per file property. When you save a file, it saves the state of the autogroup toggle. This seems much more useful - you may have files where you want to create trips by default. And others, where you don't. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Clear divecomputer saved status before saving the nicknames to XMLGravatar Dirk Hohndel
In commit c7169bd24f22 "Fix nickname saving in XML file to deal with utf8 characters" I added the helper function to clear the "this divecomputer has already been saved"-flag. But then forgot to call it from save_dives before saving the divecomputer nicknames. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30First step in cleaning up cylinder pressure sensor logicGravatar Linus Torvalds
This clarifies/changes the meaning of our "cylinderindex" entry in our samples. It has been rather confused, because different dive computers have done things differently, and the naming really hasn't helped. There are two totally different - and independent - cylinder "indexes": - the pressure sensor index, which indicates which cylinder the sensor data is from. - the "active cylinder" index, which indicates which cylinder we actually breathe from. These two values really are totally independent, and have nothing what-so-ever to do with each other. The sensor index may well be fixed: many dive computers only support a single pressure sensor (whether wireless or wired), and the sensor index is thus always zero. Other dive computers may support multiple pressure sensors, and the gas switch event may - or may not - indicate that the sensor changed too. A dive computer might give the sensor data for *all* cylinders it can read, regardless of which one is the one we're actively breathing. In fact, some dive computers might give sensor data for not just *your* cylinder, but your buddies. This patch renames "cylinderindex" in the samples as "sensor", making it quite clear that it's about which sensor index the pressure data in the sample is about. The way we figure out which is the currently active gas is with an explicit has change event. If a computer (like the Uemis Zurich) joins the two concepts together, then a sensor change should also create a gas switch event. This patch also changes the Uemis importer to do that. Finally, it should be noted that the plot info works totally separately from the sample data, and is about what we actually *display*, not about the sample pressures etc. In the plot info, the "cylinderindex" does in fact mean the currently active cylinder, and while it is initially set to match the sensor information from the samples, we then walk the gas change events and fix it up - and if the active cylinder differs from the sensor cylinder, we clear the sensor data. [Dirk Hohndel: this conflicted with some of my recent changes - I think I merged things correctly...] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Fix nickname saving in XML file to deal with utf8 charactersGravatar Dirk Hohndel
This makes the whole code much cleaner and simpler. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Allow overlapping (and disjoint) dive tripsGravatar Linus Torvalds
We used to have the rule that a dive trip has to have all dives in it in sequential order, even though our XML file really is much more flexible, and allows arbitrary nesting of dives within a dive trip. Put another way, the old model had fairly inflexible rules: - the dive array is sorted by time - a dive trip is always a contiguous slice of this sorted array which makes perfect sense when you think of the dive and trip list as a physical activity by one person, but leads to various very subtle issues in the general case when there are no guarantees that the user then uses subsurface that way. In particular, if you load the XML files of two divers that have overlapping dive trips, the end result is incredibly messy, and does not conform to the above model at all. There's two ways to enforce such conformance: - disallow that kind of behavior entirely. This is actually hard. Our XML files aren't date-based, they are based on XML nesting rules, and even a single XML file can have nesting that violates the date ordering. With multiple XML files, it's trivial to do in practice, and while we could just fail at loading, the failure would have to be a hard failure that leaves the user no way to use the data at all. - try to "fix it up" by sorting, splitting, and combining dive trips automatically. Dirk had a patch to do this, but it really does destroy the actual dive data: if you load both mine and Dirk's dive trips, you ended up with a result that followed the above two technical rules, but that didn't actually make any *sense*. So this patch doesn't try to enforce the rules, and instead just changes them to be more generic: - the dive array is still sorted by dive time - a dive trip is just an arbitrary collection of dives. The relaxed rules means that mixing dives and dive trips for two people is trivial, and we can easily handle any XML file. The dive trip is defined by the XML nesting level, and is totally independent of any date-based sorting. It does require a few things: - when we save our dive data, we have to do it hierarchically by dive trip, not just by walking the dive array linearly. - similarly, when we create the dive tree model, we can't just blindly walk the array of dives one by one, we have to look up the correct trip (parent) - when we try to merge two dives that are adjacent (by date sorting), we can't do it if they are in different trips. but apart from that, nothing else really changes. NOTE! Despite the new relaxed model, creating totally disjoing dive trips is not all that easy (nor is there any *reason* for it to be easty). Our GUI interfaces still are "add dive to trip above" etc, and the automatic adding of dives to dive trips is obviously still based on date. So this does not really change the expected normal usage, the relaxed data structure rules just mean that we don't need to worry about the odd cases as much, because we can just let them be. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Update deco handlingGravatar Dirk Hohndel
This commit makes deco handling in Subsurface more compatible with the way libdivecomputer creates the data. Previously we assumed that having a stopdepth or stoptime and no ndl meant that we were in deco. But libdivecomputer supports many dive computers that provide the deco state of the diver but with no information about the next stop or the time needed there. In order to be able to model this in Subsurface this adds an in_deco flag to the samples. This is only stored to the XML file when it changes so it doesn't add much overhead but will allow us to display some deco information on dive computers like the Atomic Aquatics Cobalt or many of the Suuntos (among others). The commit also removes the old event based deco code that was commented out already. And fixes the code so that the deco / ndl information is stored for the very last sample as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Make add_dc_to_string() skip redundant entriesGravatar Linus Torvalds
There is no point writing out divecomputer nicknames that do not exist (or that match the dive computer model), so don't. Also, make the function to do this static to save-xml.c, which is the only user (I initially didn't _find_ the function to create the XML string because it was illogically hidden in gtk-gui.c), and change the calling convention to be more direct (pass in a string and return a result, rather than modify a "pointer to string"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-26Add settings section to XML file format and store dive computer IDsGravatar Dirk Hohndel
We only store the model/deviceid/nickname for those dive computers that are mentioned in the XML file. This should make the XML files nicely selfcontained. This also changes the code to consistently use model & deviceid to identify a dive computer. The deviceid is NOT guaranteed to be collision free between different libdivecomputer backends... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-21Remove nickname from divecomputer data structureGravatar Dirk Hohndel
Having it there with the model information seemed to make sense but on second thought it's the wrong spot to keep that information, especially since we were storing it in the XML file in every single dive. This change removes the nickname member from the divecomputer and makes the rest of the code reasonably self consistent. It does not add much of the new code for the new design to handle nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-13Add the ability to set a nickname for a dive computerGravatar Dirk Hohndel
We maintain a list of dive computers that we know about (by deviceid) and their nicknames in our config. If the user downloads dive from a dive computer that we haven't seen before, we give them the option to set a nickname for that dive computer. That nickname is displayed in the profile (and stored in the XML file, assuming it is not the same as the model). This implementation attempts to make sure that it correctly deals with utf8 nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07Add CNS and pO2 tracking in the samplesGravatar Dirk Hohndel
This adds the new members to the sample structure and fills them from supported dive computers (Uemis SDA and OSTC / Shearwater Predator, assuming you have libdivecomputer 0.3). Save relvant values of this to the XML file and load it back. Handle the new fields when merging dives. At this stage we don't DO anything with this, all we do is extract them from the dive computer, save them to the XML file and load them back. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-05Fix saving of salinityGravatar Dirk Hohndel
Several things were wrong. - we saved it as floating point (that was stupid, given the locale issue with that and given the fact that the precision was really artificial) - we always saved it when set (we should only save it if the value is different from our default of 1030g/l == salt water) - most embarrassing - the unit we assigned was wrong. That's g/l, not kg/l... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-05Turn latitude and longitude into integer micro-degree valuesGravatar Linus Torvalds
This actually makes us internally use 'micro-degrees' for latitude and longitude, and we never turn them into floating point either at parse time or save time. That said, the Uemis downloader internally does still use atof() when converting things, which is likely a bug (locale issues and all that), but I'll ask Dirk to check it out. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-05Save latitude/longitude using integer mathGravatar Linus Torvalds
I hate using floating point, this tries to at least make parts of it be integer logic, and avoid the whole locale issue. This still keeps the latitude and longitude internally as a floating point value, and parses it that way, but I'm slowly moving towards less and less FP use. We're going to use micro-degrees for location information: that's sufficient to about a tenth of a meter precision, and it fits in a 32-bit integer. If you specify dive sites with more precision than that, you may have OCD. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-04Improve deco handling and add NDL supportGravatar Dirk Hohndel
This commit changes the code that was recently introduced to deal with deco ceilings. Instead of handling these through events we now store the ceiling (which in reality is the deepest deco stop with all known dive computers) and the stop time at that ceiling in the samples. This also adds support for NDL (non stop dive limit) which both dive computers that appear to give us ceiling / deco information appear to give us as well (when the diver isn't in deco). If the mouse hovers over the profile we now add support for displaying the NDL, the current deco obligation and (if we are able to tell from the data) whether we are at a safety stop. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-26Simplify tripflags: remove tripflag_names[]Gravatar Linus Torvalds
This removes the tripflag name array, since it's not actually useful. The only information we ever save in the XML file is whether a dive is explicitly not supposed to ever be grouped with a trip ("NOTRIP"), and everything else is implicit. I'm going to simplify the trip flags further (possibly removing it entirely - like I did for dive trips already), and don't like having to maintain the tripflag_names[] array logic. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25Improve on divecomputer data handlingGravatar Linus Torvalds
This simplifies the vendor/product fields into just a single "model" string for the dive computer, since we can't really validly ever use it any other way anyway. Also, add 'deviceid' and 'diveid' fields: they are just 32-bit hex values that are unique for that particular dive computer model. For libdivecomputer, they are basically the first word of the SHA1 of the data that libdivecomputer gives us. (Trying to expose it in some other way is insane - different dive computers use different models for the ID, so don't try to do some kind of serial number or something like that) For the Uemis Zurich, which doesn't use the libdivecomputer import, we currently only set the model name. The computer does have some kind of device ID string, and we could/should just do the same "SHA1 over the ID" to give it a unique ID, but the pseudo-xml parsing confuses me, so I'll let Dirk fix that up. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25Start merging dives by keeping the dive computer data from both divesGravatar Linus Torvalds
Also, note that we do *not* do the "find_sample_offset()" any more when we merge two dives that happen at the same time - since we just keep both sets of dive computer data around. But we keep the function to find the best offset around, because we may well want to use it later when *showing* the dive, and trying to match up the different sample data from the multiple dive computers associated with the dive. Because of that, this causes warnings about the now unused function. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25Add basic divecomputer info setup with xml parsing and savingGravatar Linus Torvalds
This also knows how to save and restore multiple dive computers in the XML data, but there's no way to actually *create* that kind of information yet (nor do we display it). Tested by creating fake XML files with multiple dive computers by hand so far. The dive computer information right now contains (apart from the sample and event data that we've always had): - the vendor and product name of the dive computer - the date of the dive according to the dive computer (so if you change the dive date manually, the dive computer date stays around) Note that if the dive computer date matches the dive date, we won't bother saving the redundant information in the XML file. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23Move events and samples into a 'struct divecomputer'Gravatar Linus Torvalds
For now we only have one fixed divecomputer associated with each dive, so this doesn't really change any current semantics. But it will make it easier for us to associate a dive with multiple dive computers. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-19Fix the XML gps parsing and saving when using non-US localesGravatar Linus Torvalds
The GPS parsing and saving was using sscanf and sprintf respecively, and since it is using floating point values (boo!) that affects both of them. In a C/US locale, we use a period for decimal values, while most European locales use a comma. We really should probably just fix things to use integer values (degrees and nanodegrees?) but this is the simplest fix/workaround for the issue. Probably nobody ever really noticed until I tested the Swedish locale for grins, since we don't have a good way to actually set the GPS coordinates yet. I've got a few dives with GPS information that I entered manually. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-12Store and parse salinity and surface pressureGravatar Dirk Hohndel
In my excitement about extracting these from libdivecomputer I forgot to actually store them and then parse them again. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-28Add support for visibility tracking and allow manual entry air tempGravatar Dirk Hohndel
Turns out we had a data field for visibility as a length unit - but never used it. I can never guess how much visibility we actually had on a dive - but I think most everyone can assign a rating between abysmal (zero stars, "I couldn't read my dive computer even right in front of my mask" - trust me, I had some of those dives) to amazing ("five stars, I could see farther than I though possible" - and I had one or two of those, too). So I changed this to an integer and am re-using the star infrastructure we have for the overall dive rating. When displaying this I was dismayed that we are running out of space in the "Dive Notes" notbook. So I moved this to the "Dive Info" notebook. This is not consistent and not logical. I think we need to revisit the notebooks and think about what we want to display where. While adding the infrastructure to manually enter the visibility I went ahead and added the ability to manually enter the air temperature as well (that was one of the things missing in the previous commit). Fixes #7 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-04Use GLib's g_fopen() and g_open() when working with filesGravatar Lubomir I. Ivanov
On Windows, the GLib wrappers for fopen() and open() deal with the UTF-8 format used for file names when we have to open or save a file with unicode characters in its name. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-30New XML format for saving divesGravatar Linus Torvalds
This patch makes the trips nest, and it also fixes the fact that you never saved the trip notes (you could edit it, but saving would throw it away). I did *not* change the indentation of the dives, so the trip stuff shows up the the beginning of the line, at the same level as the <dive> and <dives> thing. I think it's fairly readable xml, though, and we haven't really had proper "indentation shows nesting" anyway, since the top-level "<dives>" thing also didn't indent stuff inside of it. Anyway, the way I wrote it, it still parses your old "INTRIP" stuff etc, so as far as I know, it should happily read the old-style XML too. At least it seemed to work with your xml file that already had the old-style one (I haven't committed my divetrips, exactly because I didn't like the new format). It always saves in the new style, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-21Fix missing save of (almost empty) cylinder informationGravatar Linus Torvalds
If we have no explicit cylinder info at all (it's normal air, no size or working pressure information, and no beginning/end pressure information), we don't save the cylinders in question because that would be redundant. Such non-saved cylinders may still show up in the equipment list because there may be implicit mention of them elsewhere, notably due to sample data, so not saving them is the right thing to do - there is nothing to save. However, we missed one case: if there were other cylinders that *did* have explicit information in it following such an uninteresting cylinder, we do need to save the cylinder information for the useless case - if only in order to be able to save the non-useless information for subsequent cylinders. This patch does that. Now, if you had an air-filled cylinder with no information as your first cylinder, and a 51% nitrox as your second one, it will save that information as <cylinder /> <cylinder o2='51.0%' /> rather than dropping the cylinder information entirely. This bug has been there for a long time, and was hidden by the fact that normally you'd fill in cylinder descriptions etc after importing new dives. It also used to be that we saved the cylinder beginning/end pressure even if that was generated from the sample data, so if you imported from a air-integrated computer and had samples for that cylinder, we used to save it even though it was technically redundant. We stopped saving redundant air sample information in commit 0089dd8819b7 ("Don't save cylinder start/end pressures unless set by hand"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Removed start and end in save_cylinder_info(). These two variables are no longer used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-20Fix dive trip saving bugGravatar Dirk Hohndel
When switching the dive trips to be stored in a different data structure I forgot to update the code in save_trip() - and since we were passing the pointer around via a gpointer the compiler didn't catch this. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-19Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'Gravatar Linus Torvalds
This makes the time type unambiguous, and we can use G_TYPE_INT64 for it in the divelist too. It also implements a portable (and thread-safe) "utc_mkdate()" function that acts kind of like gmtime_r(), but using the 64-bit timestamp_t. It matches our original "utc_mktime()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-11Display yearly/monthly statisticsGravatar Miika Turkia
Display yearly statistics in a statistics window with option to expand the viewing on monthly level. The amount of dives along with basic information like duration, depth, water temperature and air consumption is displayed in yearly and monthly level. Thus you are able to compare e.g. development of air consumption or diving activity from year to year. Using already existing macro for splitting seconds into minutes:seconds. Moving repetitive code to a function (couldn't think of the suggested clever macro, but this should pretty much do the trick). Now the statistics are updated every time the process_all_dives function is called. It might make sense to actually verify the structures need to be re-allocated, but such optimization is currently not implemented. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Combined two commits. Minor cleanups for white space and boolean values. Significant changes to use the correct units for volumes vs. depths and to avoid unneccesary lookups of the model storage based on the tree. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-01Clean up macros and auxiliary functionsGravatar Dirk Hohndel
In preparation for the next stage of the trips handling this commit makes the macros used to access trips (and some frequently used variables for the tree and list models) more consistent. This also changes the way we display un-grouped dives in the dive list, i.e. dives that are not part of a dive trip. Their dive number is now printed bold. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27Merge branch 'trips' of git://git.hohndel.org/subsurfaceGravatar Linus Torvalds
Merge the initial 'track trips explicitly' code from Dirk Hohndel. Fix up trivial conflicts in save-xml.c due to the new 'is_attribute' flag. * 'trips' of git://git.hohndel.org/subsurface: Fix an issue with trips that have dives from multiple input files Some simple test dives for the trips code First cut of explicit trip tracking
2012-08-27First cut of explicit trip trackingGravatar Dirk Hohndel
This code establishes the explicit trip data structures and loads and saves them in the XML data. No attempts are made to edit / modify the trips, yet. Loading XML files without trip data creates the trips based on timing as before. Saving out the same, unmodified data will create 'trip' entries in the XML file with a 'number' that reflects the number of dives in that trip. The trip tag also stores the beginning time of the first dive in the trip and the location of the trip (which we display in the summary entries in the UI). The logic allows for dives that aren't part of a dive trip. All other dives simply belong to the "previous" dive trip - i.e. the dive trip with the latest start time that is earlier or equal to the start time of this dive. This logic significantly simplifies the tracking of trips compared to other approaches that I have tried. The automatic grouping into trips now is an option that defaults to off (as it makes changes to the XML file - and people who don't want this feature shouldn't have trips added to their XML files that they then need to manually remove). For now you have to select this option, then exit the program and start it again. Still to do is to trigger the trip generation at run time. We also need a way to mark dives as not part of trips and to allow options to combine trips, split trips, edit trip location data, etc. The code has only had some limited testing when opening multiple files. The code is known to fail if a location name contains unquoted special characters like an "'". This commit also fixes a visual inconsistency in the preferences dialog where the font selector button didn't have a frame around it that told you what this option was about. Inspired-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27Only quote the quote characters in xml attributesGravatar Linus Torvalds
The quoting of single and double quotes is only necessary for attributes, and is irritating for other fields in that it makes the fields almost unreadable in the xml file. Single quotes in particular are common, and turning "it's" into "it&apos;s" is just not reasonable for dive notes etc. So add a flag to whether the xml quoting is for an attribute or not, and take that into account. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-27Add single and double quotes to escaped characters in XML outputGravatar Dirk Hohndel
We already escape '<', '>', and '&'. This adds the remaining two special entities in XML: '\'' and '\"'. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-14Add exposure protection trackingGravatar Dirk Hohndel
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>
2012-03-24Add weight system trackingGravatar Dirk Hohndel
- 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>
2011-12-07Fix some issues with star rating codeGravatar Dirk Hohndel
To waste less space in the tree view heading we simply put a star in the heading instead of "Rating". We now treat "zero stars" to mean "not rated" and don't store that value in the XML file. Rating is no longer a top level tag in the dive entry but instead a property of the dive tag. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-07Add typical 0 to 5 star rating for divesGravatar Dirk Hohndel
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>
2011-11-10Save cylinder O2/He content after the cylinder type descriptionGravatar Linus Torvalds
This changes the save format xml to be a bit more readable: instead of putting the gasmix first, put the cylinder type (size, workpressure and description) first, then gasmix, then pressure details. It makes no difference for machine parsing, but I think it's a lot more logical for humans that actually look at the xml file. And we really do want to make the xml file readable by humans. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-09Don't drop precision from floating point GP coordinatesGravatar Linus Torvalds
Using '%f' limits the precision to 6 decimals, which may well be perfectly ok. But at least in theory you *could* have higher precision, and gps units will report it, so don't mindlessly limit us to what %f shows. This arbitrarily uses '%.12g' instead. %g will drop excess zeroes at the end, so it actually results in the same (or shorter) ascii representation unless you have the extra precision. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22Start handling dive eventsGravatar Linus Torvalds
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>
2011-09-15Support gps coordinates for the location infoGravatar Linus Torvalds
Sadly, no way to show them yet. But it would be nice to let people enter them (and it would be doubly nice to have a dive computer that does it at the surface), and then perhaps just do the "point browser at google maps" thing. Saving/parsing tested by hand-feeding the location of Enenui (Molokini Crater) from google maps by hand into my divelog. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15Rename the project 'subsurface'Gravatar Linus Torvalds
I never really liked 'diveclog' as a name - it's not like the C part is all that important. And while I could try to just make up another slang word for despicable person (in the tradition of naming all my projects after myself), I just can't see it. So let's just call it "subsurface". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13Add divemaster/buddy field and text entryGravatar Linus Torvalds
I have it in some of my notes, and Dirk seems to fill that in too, so let's just show it, save it, and allow editing of it.. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12Don't save empty cylinder descriptions in the xmlGravatar Linus Torvalds
They get created when the equipment thing doesn't have a name for the cylinder, but we don't want to save that lack of description. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11Be more careful about unit changesGravatar Linus Torvalds
When we change units, we need to flush any currently active dive information in the old units, and then carefully reload it in the new units. Otherwise crazy stuff happens - like having current cylinder working pressure values that are in PSI because that *used* to be the output unit, but then interpreting those values as BAR, because we changed the units. Also, since we now properly import working pressure from Diving Log, stop importing the (useless) cylinder description. The Diving Log cylinder descriptions are things like "Alu" or "Steel". We're better off just making up our own. Finally, since Diving Log has cylinder size in metric, make sure that we do the "match standard cylinder sizes" *after* we've done all the cylinder size conversions to proper units. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11Fix up dive number namingGravatar Linus Torvalds
Use "dive->number" instead of "dive->nr". And make the XML match too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>