aboutsummaryrefslogtreecommitdiffstats
path: root/divelist.c
AgeCommit message (Collapse)Author
2013-11-19Fix trip summary line in dive listGravatar Dirk Hohndel
Two errors fixed. - With no location set, the summary line would start with a ','. - When auto creating a trip for a manually added dive or when editing the dates of dives in a trip, the timestamp for the trip was not updated after editing the dive. Fixes #293 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16Removed duplicated method.Gravatar Tomaz Canabrava
This patch removes a duplicated method: get_divenr and get_index_for_dive. The two are exactly the same ( if my c is not broken, but I may be broken since I'm working like crazy for almost 30h nonstop. ), so please take a good look before applying this one. [Dirk Hohndel: Tomaz took the slightly broken of the two implementations, so I switched that out for the correct one] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-02Replaced the tag implementationGravatar Maximilian Güntner
The new implementation supports custom tags which are provided by the user as well as default tags which are provided by subsurface. Default tags can be translated and will be written to XML in their non-localized form. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2013-10-16Helpers: move some date related function to qt-gui.cppGravatar Lubomir I. Ivanov
divelist.c: get_dive_date_string() get_short_dive_date_string() get_trip_date_string() MinGW support for *printf and parameter positions (e.g. %1$d) is horribly broken. Instead of implementing *proper* support for this feature Microsoft decide to ignore the standard (again) and they implement new functions with the '_p' suffix, such as 'sprintf_p', which seem to be available from a 2003 runtime. To top that 'sprintf_p' is not really a 'sprintf' but rather a 'snprintf'. It seems that the MinGW people ignore the issue and do not provide wrappers of any sort, or at least for the current recommended compiler for Qt 4.8.5 on Windows - which is a 4.4.0. A note of warning; inspecting how MinGW does certain things in headers such as stdio.h, can ensue bad dreams or other negative effects on to the viewer. This forces us to move the following functions from the 'back-end' (divelist.c) to the 'front-end' (qt-gui.cpp) and use QString. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09Next step towards working translationsGravatar Dirk Hohndel
This may seem like a really odd change - but with this change the Qt tools can correctly parse the C files (and qt-gui.cpp) and get the context for the translatable strings right. It's not super-pretty (I'll admit that _("string literal") is much easier on the eye than translate("gettextFromC", "string literal") ) but I think this will be the price of success. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07Next round of code removal and header cleanupGravatar Dirk Hohndel
None of this is used anywhere Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07Remove even more code and declarationsGravatar Dirk Hohndel
There's lots more stuff that can go. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Delete code and files that are no longer usedGravatar Dirk Hohndel
Most of this is Gtk related, some of it is helpers that we don't need anymore. I love the diffstat. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Remove lots of ifdef'ed out code from GTK/glib versionGravatar Dirk Hohndel
There's still a ton more left, but this is a start. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Trying to switch to Qt translationGravatar Dirk Hohndel
This compiles and looks about right, but it doesn't appear to work, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06First steps towards removing glib dependenciesGravatar Dirk Hohndel
- remove the build flags and libraries from the Makefile / Configure.mk - remove the glib types (gboolean, gchar, gint64, gint) - comment out / hack around gettext - replace the glib file helper functions - replace g_ascii_strtod - replace g_build_filename - use environment variables instead of g_get_home_dir() & g_get_user_name() - comment out GPS string parsing (uses glib utf8 macros) This needs massive cleanup, but it's a snapshot of what I have right now, in case people want to look at it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-24Disable info widget when canceling 'add dive' for a first diveGravatar Dirk Hohndel
One more corner case that we cover correctly. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-24Only offer to merge dives if they are consecutive in the divelistGravatar Dirk Hohndel
You cannot merge dives if there is another, unselected dive "between" them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-23Add "merge selected dives" to dive list popup menuGravatar Dirk Hohndel
This is fairly straight forward. What I dislike is the check for the magic number of "14 indeces". I'm sure there's a better way to tell if more than one dive is selected... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18Converting the device_info list into a Qt data structureGravatar Dirk Hohndel
This data structure was quite fragile and made 'undo' when editing rather hard to implement. So instead I decided to turn this into a QMultiMap which seemed like the ideal data structure for it. This map holds all the dive computer related data indexed by the model. As QMultiMap it allows multiple entries per key (model string) and disambiguates between them with the deviceId. This commit turned out much larger than I wanted. But I didn't manage to find a clean way to break it up and make the pieces make sense. So this brings back the Ok / Cancel button for the dive computer edit dialog. And it makes those two buttons actually do the right thing (which is what started this whole process). For this to work we simply copy the map to a working copy and do all edits on that one - and then copy that over the 'real' map when we accept the changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-13Improve the trip headerGravatar Linus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31Use a slightly shorter date string for Info tabGravatar Dirk Hohndel
This way the spacing of the elements looks nicer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22The never ending, futile fight for whitespace consistencyGravatar Dirk Hohndel
I just need to write a tool that does this... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-17Merge branch 'Qt'Gravatar Dirk Hohndel
After the 3.1 release it is time to shift the focus on the Qt effort - and the best way to do this is to merge the changes in the Qt branch into master. Linus was extremely nice and did a merge for me. I decided to do my own merge instead (which by accident actually based on a different version of the Qt branch) and then used his merge to double check what I was doing. I resolved a few things differently but overall what we did was very much the same (and I say this with pride since Linus is a professional git merger) Here's his merge commit message: This is a rough and tumble merge of the Qt branch into 'master', trying to sort out the conflicts as best as I could. There were two major kinds of conflicts: - the Makefile changes, in particular the split of the single Makefile into Rules.mk and Configure.mk, along with the obvious Qt build changes themselves. Those changes conflicted with some of the updates done in mainline wrt "release" targets and some helper macros ($(NAME) etc). Resolved by largely taking the Qt branch versions, and then editing in the most obvious parts of the Makefile updates from mainline. NOTE! The script/get_version shell script was made to just fail silently on not finding a git repository, which avoided having to take some particularly ugly Makefile changes. - Various random updates in mainline to support things like dive tags. The conflicts were mainly to the gtk GUI parts, which obviously looked different afterwards. I fixed things up to look like the newer code, but since the gtk files themselves are actually dead in the Qt branch, this is largely irrelevant. NOTE! This does *NOT* introduce the equivalent Qt functionality. The fields are there in the code now, but there's no Qt UI for the whole dive tag stuff etc. This seems to compile for me (although I have to force "QMAKE=qmake-qt4" on f19), and results in a Linux binary that seems to work, but it is otherwise largely untested. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-14code to show profile againGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-11Require libzip, xslt and osm-gps-map in all buildsGravatar Henrik Brautaset Aronsen
Conditional inclusion of libzip, xslt and osm-gps-map just makes testing more cumbersome, since testers might lack Subsurface features without knowing. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03Fix compiler warningsGravatar Dirk Hohndel
Doing this on Arch Linux with gcc 4.8.0 helped find one real bug. The rest are simply changes to make static functions externally visible (as they are kept around to eventually become helpers used by Qt) which for now avoids the warnings. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03Remove the majority of the Gtk related codeGravatar Dirk Hohndel
- rip all Gtk code from qt-gui.cpp - don't compile Gtk specific files - don't link against Gtk libraries - don't compile modules we don't use at all (yet) - use #if USE_GTK_UI on the remaining files to disable Gtk related parts - disable the non-functional Cochran support while I'm at it Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02Move gas string computation into core logic codeGravatar Dirk Hohndel
This is now a helper called from the Gtk UI code (and will soon be used by the Qt UI code). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-24Call the get_date functions with timestamp_t instead of struct tmGravatar Dirk Hohndel
This is the much more natural way to use this function, now that I look at it... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-24Split report_dives into UI and logic and move to divelist filesGravatar Dirk Hohndel
Functionality is unchanged, except we now have a nice process_dives function that deals with all the logic and that gets called from report_dives from the Gtk code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-23Add a simple table-based cns calculationsGravatar Anton Lundin
For dives where divecomputers haven't provided us with a cns, we calculate our cns accumulated during that dive based on a simple table. We also check if we did a dive in the prior 12 ours and grab the cns from it and calculate how much of that still affects us. [Dirk Hohndel: a couple of small changes: remove unnecessary check of cns values in the samples of the first dive computer, changed the way we determine the 'previous dive' and used the end time of that previous dive for the decay calculation] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-21Move creation of dive and dive trip date string into helper functionsGravatar Dirk Hohndel
This allows this code to easily be shared by Gtk and Qt UI. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-18Move creation of dive and dive trip date string into helper functionsGravatar Dirk Hohndel
This allows this code to easily be shared by Gtk and Qt UI. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-18Delay Qt ui constructionGravatar Amit Chaudhuri
The Qt ui will need to read the dive_table to populate widgets with dives. Gtk functionality in init_ui is required to parse the dives. Split init_ui to allow parsing to proceed and complete before Qt ui mainwindow constructor is called. Play with qDebug()'s printf style (Thiago!) Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-10Fix selection handling for invalid divesGravatar Dirk Hohndel
This is the downside of having to track our own selection state. We now have a class of dives that potentially isn't known to Gtk as we aren't adding them to the TreeView. So we need to make sure that their selection state is consistent by deselecting them (either when they are marked as invalid OR when we change preferences to no longer show invalid dives). And because Gtk sends out another set of selection events when clearing the TreeView (not sure why), we also need to make sure that their selection state isn't reset to selected by mistake when the divelist is recreated. A bit of a pain, but it seems to work now and be consistent. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-09Add a simple table-based cns calculationsGravatar Anton Lundin
For dives where divecomputers haven't provided us with a cns, we calculate our cns accumulated during that dive based on a simple table. We also check if we did a dive in the prior 12 ours and grab the cns from it and calculate how much of that still affects us. [Dirk Hohndel: a couple of small changes: remove unnecessary check of cns values in the samples of the first dive computer, changed the way we determine the 'previous dive' and used the end time of that previous dive for the decay calculation] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-07Continue to separate Gtk related code from core logic: divelistGravatar Dirk Hohndel
Move some more logic out of the divelist-gtk.c file. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-07Separate Gtk related code from core logic: divelistGravatar Dirk Hohndel
This is simplistic & brute force: any function that touches Gtk related data structures is moved to divelist-gtk.c, everything else stays in divelist.c. Header files have been adjusted so that this still compiles and appears to work. More thought is needed to truly abstract this out, but this seems to be a good point to commit this change. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-06Continue to separate Gtk related code from core logic: divelistGravatar Dirk Hohndel
Move some more logic out of the divelist-gtk.c file. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-06Separate Gtk related code from core logic: divelistGravatar Dirk Hohndel
This is simplistic & brute force: any function that touches Gtk related data structures is moved to divelist-gtk.c, everything else stays in divelist.c. Header files have been adjusted so that this still compiles and appears to work. More thought is needed to truly abstract this out, but this seems to be a good point to commit this change. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-24Export dives to UDDF fileGravatar Miika Turkia
This patch implements exporting dives from Subsurface to UDDF format. Events and cylinder info are the most remarkable things still missing from the export. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-20divelist.c: Fix an 'implicit declaration' warningGravatar Lubomir I. Ivanov
close() should be included from unistd.h, instead of fcntl.h for better portability. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-18Correctly handle first gas when deciding if gas is usedGravatar Robert C. Helling
Gas with index 0 is assumed to be the first gas only if there is no gaschage event in the first 30 seconds of the dive. [Dirk Hohndel: minor formatting change in a logical expression] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-18Take only used gases into account when showing gas in divelistGravatar Robert C. Helling
Here is a patch that restricts the gases listed in the divelist to those that are actually used. I seem to have the indentation now under control but I am not sure about the logic: 1) First gas (with index 0) is always used. 2) If there is a gas switch event, the new gas is also used (determined by walking the list of dive computers and then the list of events). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-15Use a generic 64bit int typeGravatar Dirk Hohndel
The zip_int64_t type appears to be missing with mingw so it breaks my cross builds - and this is clearly equivalent. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-13First simplistic implementation of a divelogs.de uploadGravatar Dirk Hohndel
This has no user interface and hardcodes a testing username / password. But it can successfully create a DLD file (thanks to Miika and Lubomir) and then uses libsoup to upload that to the server. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-12DLD upload: Avoid using open_memstream() and non-portable functionsGravatar Lubomir I. Ivanov
patch contains: - replacement for open_memstream() - storage of the temporary zip file in the OS temporary directory - replacement usage of mktemp() with g_mkstemp() patch based on work by Miika Turkia. [Dirk Hohndel: as suggested by Miika I commented out the deletion of the DLD file] Acked-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-10.DLD generation for uploading to divelogs.deGravatar Miika Turkia
This generates a .DLD file of selected dives to be uploaded to divelogs.de. The actual upload functionality along with sensible user interface is still to be implemented. However, the resulting file from this patch is tested to work (as far as I can tell) using upload API of divelogs.de. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03Saving individual dives should not change the exiting filenameGravatar Dirk Hohndel
The current data file is not the same as the file to which individual dives were saved. Reported-by: Jan Schubert <Jan.Schubert@GMX.li> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03Try to capture some more potential buffer overflows caused by localizationGravatar Dirk Hohndel
A couple of these could clearly cause a crash just like the one fixed by commit 00865f5a1e1a ("equipment.c: Fix potential buffer overflow in size_data_funct()"). One would append user input to fixed length buffer without checking. We were hardcoding the (correct) max path length in macos.c - replaced by the actual OS constant. But the vast majority are just extremely generous guesses how long localized strings could possibly be. Yes, this commit is likely leaning towards overkill. But we have now been bitten by buffer overflow crashes twice that were caused by localization, so I tried to go through all of the code and identify every possible buffer that could be affected by this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-27When manually adding a dive allow user to set avg depth as wellGravatar Dirk Hohndel
So far we only allowed setting the max depth. This changes the layout of the entry widget and makes our helper function create_date_time_widget return the hbox in which it positions the time entry. I plan to reuse this later when allowing to edit the duration as well as the start date and time under certain circumstances. This is a small part of a feature request; see #75 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25Take incompressibility of gas into account at higher pressuresGravatar Linus Torvalds
This creates a helper function called "gas_volume()" that takes the cylinder and a particular pressure, and returns the estimated volume of the gas at surface pressure, including proper approximation of the incompressibility of gas. It very much is an approximation, but it's closer to reality than assuming a pure ideal gas. See for example compressibility at http://en.wikipedia.org/wiki/Compressibility_factor Suggested-by: Jukka Lind <jukka.lind@iki.fi> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24Use the improved duration and average depth for everythingGravatar Linus Torvalds
The code was written to get the SAC rate correct, but we probably do want to have the duration and mean depth of the dive always be shown for the non-surface-time. So move the code from the sac-rate calculation to the generic dive fixup part. This makes the dive list and statistics all show the duration as the under-water duration, which is not necessarily the same as "difference between beginning and end of dive". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24Correctly calculate SAC rate in the presense of surface eventsGravatar Linus Torvalds
This assumes that you are not breathing your cylinders while at the surface, which may or may not be correct, but is usually the right thing. Regardless, we're better off giving a conservative (higher) SAC rate estimate for a diver that breathes his cylinder at the surface too than giving an artificially low one because the diver ended up using his snorkel and we didn't take that into account. NOTE! This basically calculates a better duration and average depth than the ones we end up showing in the dive list. Maybe we should actually show this "no-surface-time" duration and average depth instead of the ones we do show? That's a separate question, though. Added a test-case for the surface case to the sac-test.xml dives. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>