aboutsummaryrefslogtreecommitdiffstats
path: root/divelist.h
AgeCommit message (Collapse)Author
2015-10-30Move all core-functionality to subsurface-coreGravatar Tomaz Canabrava
And adapt a new CMakeLists.txt file for it. On the way I've also found out that we where double-compilling a few files. I've also set the subsurface-core as a include_path but that was just to reduce the noise on this commit, since I plan to remove it from the include path to make it obligatory to specify something like include "subsurface-core/dive.h" for the header files. Since the app is growing quite a bit we ended up having a few different files with almost same name that did similar things, I want to kill that (for instance Dive.h, dive.h, PrintDive.h and such). Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-01Make add_single_dive() grow the divelist allocation if necessaryGravatar Linus Torvalds
We only made sure the divelist allocation was big enough in "record_dive_to_table()", but add_single_dive() can add entries too. Now, in practice that never bit anybody, since (a) we allocate extra entries anyway, and it would be very unusual that the divelist table was exactly full (b) most "malloc()" implementations end up having their own slop on top of that (c) add_single_dive() was only used for merging dives, which actually ends up removing more divex than it adds (but it does add one first) but when I'm starting to split dives, this will be a bigger issue in practice. And it was wrong. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-24QML UI: make sure the dive list is empty before loading divesGravatar Dirk Hohndel
When testing subsurface-mobile on the desktop from an account that had a default file set up in the Subsurface preferences that file would already be loaded creating rather confusing output. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20Track minimum datafile versionGravatar Dirk Hohndel
Add infrastructure and helper functions to track minimum datafile version. To make this information useful we need to keep the XML and git data format versions in track moving forward. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01Simplify model handling and crashes fixesGravatar Tomaz Canabrava
So, there's only one crash left (that I put a big TODO: on the maintab.cpp about) and I'll fix it tomorrow as it's quite late here and I'm almost sleeping at the keyboard. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-12Deselect dives that are no longer shown as the dive list is filteredGravatar Dirk Hohndel
This cleans up the way we ensure that all dives are handled as the dive list is filtered. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-18Planner: assign a dive number if the right number seems obviousGravatar Dirk Hohndel
Use the same logic as we do for newly added dives. As a side effect this patch appears to fix the issues with getting the newly planned dive selected. Fixes #692 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-11Rename dive gas function and defines for clarityGravatar Anton Lundin
This renames the dive gas functions to not talk about just nitrox, and to instead talk about gas. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24Dive list: move trip merging logic into divelist.cGravatar Dirk Hohndel
This also fixes a couple of issues with the existing code: - removes a memory leak - treats null and "" the same Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24Dive list: move trip selection / deselection logic to divelist.cGravatar Dirk Hohndel
This is core logic, not UI code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24Add some helper functionsGravatar Dirk Hohndel
First step towards getting the "add to trip" logic in the divelist context menu to be consistent and correct. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11Put include guard to every headerGravatar Boris Barbulovski
* ensure include guard to every header * comment endif guard block Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Fix incorrect handling of autogrouped tripsGravatar Dirk Hohndel
When toggling autogroup in the menu we ended up setting the NO_TRIP flag for dives that were removed from a trip that was created by autogroup. So toggling things on and off and on again meant no more auto grouping. Fixes #337 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-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-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-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-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-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-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-06Avoid redefinition of typedef ‘bool’Gravatar Henrik Brautaset Aronsen
The compiler on MacOSX wouldn't build Subsurface when bool was redefined. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> 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-24MSVC is c89Gravatar Dirk Hohndel
In case someone wants to compile this with an outdated C compiler... 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-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-15Remove second dive_trip_list definition and douplicate helper functionGravatar Dirk Hohndel
dive_trip_list is simply a global variable, declared in dive.h. The clear_trip_indexes() helper is purely logic and was moved to divetrip.c - but then not deleted in divetrip-gtk.c Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-15Remove second dive_trip_list definition and douplicate helper functionGravatar Dirk Hohndel
dive_trip_list is simply a global variable, declared in dive.h. The clear_trip_indexes() helper is purely logic and was moved to divetrip.c - but then not deleted in divetrip-gtk.c Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-10Add missing divelogs check for LIBZIP and XSLTGravatar Henrik Brautaset Aronsen
I forgot that in commit 5f03a6f. Oops. Reported-by: Ďoďo <dodo.sk@gmail.com> Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-09Add menu entry for divelogs.de uploadGravatar Henrik Brautaset Aronsen
The menu entry for upload to divelogs.de was missing. Also renamed the divelogs context menu entry to something less generic. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> 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-04-01Have some C++ file in the projectGravatar Alberto Mardegan
Rename gtk-gui.c to qt-gui.cpp, and make the necessary changes so that the project still builds. Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
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-02-19Obviate the need for explicit 'remember_tree_state/restore_tree_state' callsGravatar Linus Torvalds
Instead, just keep track of the expanded state of trips as we get the gtk callbacks for the state changes (which we need to track anyway for the selection logic), and automatically restore the state whenever we re-create the divelist. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-13Correctly show the planned dive in the divelistGravatar Dirk Hohndel
Previously we would simply show the first dive in the divelist - which worked fine in the default sort by trip setting and assuming that there are no dives from the future in the divelist. With this commit we actually find the correct dive in the divelist and select it instead. If you sort by depth you will see the dive move around in the divelist, but it will stay selected and visible in the profile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Display dive profile of the dive we plan, as we plan itGravatar Dirk Hohndel
As the user enters data into the entry fields, that data is validated and as soon as there is enough data we start constructing a dive profile, including the final ascent to the surface, including required deco stops, etc. This commit still has some serious issues. - when data is input that doesn't validate, we just print a warning to stdout - instead we need to change the backgroundcolor of the input field or something. - when we switch to the last dive in order to show the profile we don't actually search for the last dive - we just show the first one in the tree. This works for the default sort order but is of course wrong otherwise I'm sure there are many other bugs, but I want to push it out where it is right now for others to be able to take a look. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-04First stab at simplistic dive planningGravatar Dirk Hohndel
This comes with absolutely no gui - so the plan literally needs to be compiled into Subsurface. Not exactly a feature, but this allowed me to focus on the planning part instead of spending time on tedious UI work. A new menu "Planner" with entry "Test Planner" calls into the hard-coded function in planner.c. There a simple dive plan can be constructed with calls to plan_add_segment(&diveplan, duration, depth at the end, fO2, pO2) Calling plan(&diveplan) does the deco calculations and creates deco stops that keep us below the ceiling (with the GFlow/high values currently configured). The stop levels used are defined at the top of planner.c in the stoplevels array - there is no need to do the traditional multiples of 3m or anything like that. The dive including the ascents and deco stops all the way to the surface is completed and then added as simulated dive to the end of the divelist (I guess we could automatically select it later) and can be viewed. This is crude but shows the direction we can go with this. Envision a nice UI that allows you to simply enter the segments and pick the desired stops. What is missing is the ability to give the algorithm additional gases that it can use during the deco phase - right now it simply keeps using the last gas used in the diveplan. All that said, there are clear bugs here - and sadly they seem to be in the deco calculations, as with the example given the ceiling that is calculated makes no sense. When displayed in smooth mode it has very strange jumps up and down that I wouldn't expect. For example with GF 35/75 (the default) the deco ceiling when looking at the simulated dive jumps from 16m back up to 13m around 14:10 into the dive. That seems very odd. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Consider previous dives when calculating decoGravatar Dirk Hohndel
This also initializes the N2 tissue saturations to correct numbers (setting them to zero was clearly silly). With this commit we walk back in the dive_table until we find a surface intervall that's longer than 48h. Or a dive that comes after the last one we looked at; that would indicate that this is a divelist that contains dives from multiple divers or dives that for other reasons are not ordered. In a sane environment one would assume that the dives that need to be taken into account when doing deco calculations are organized as one trip in the XML file and so this logic should work. One major downside of the current implementation is that we recalculate everything whenever the plot_info is recreated - which happens quite frequently, for example when resizing the window or even when we go into loup mode. While this isn't all that compute intensive, this is an utter waste and we should at least cache the saturation inherited from previous dives (and clear that number when the selected dive changes). We don't want to cache all of it as the recreation of the plot_info may be triggered by the user changing equipment (and most importantly, gasmix) information. In that case the deco data for this dive does indeed have to be recreated. But without changing the current dive the saturation after the last surface intervall should stay the same. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01First step towards grabbing keys and handling them ourselvesGravatar Dirk Hohndel
This commit steals the cursor up and down keys away from gtk so regardless where gtk thinks the focus may be, we can still use the keys to change between dives. In the current UI design where all editing happens in separate windows this works as expected, as we only grab the keys for the main window. If we manage to re-enable in-place editing then we need to make sure that this doesn't cause problems (as gtk uses up/down for the ability to change drop down selections in combo boxes or values in spin buttons. So we must make sure that we stop stealing these keys once we start editing something (in which case simply switching to the next/prev dive wouldn't be a good thing, anyway). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-21Make sure there are no invisible selected dives after import / downloadGravatar Dirk Hohndel
Prior to this commit, gtk often decided to collapse the trip with the selected dive after the user imported or downloaded additional dives. Since Subsurface tracks dives as being selected even after gtk collapses a trip (which clears all selection state as far as gtk is concerned) this could lead to the strange situation that the user could click on a new dive to select it without unselecting the already selected dive - and suddenly edit or delete did things that were entirely unwanted. With this change we explicitly save and then restore the tree state around import and download operations. This ensures that the same dive(s) stay selected and trips stay expanded and therefore avoids the issues described here. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-02Add autogen menu commandGravatar Dirk Hohndel
This adds the ability to auto create trips from the menu. It's a toggle entry (and while at it, we made the zoom toggle a toggle entry as well). We can therfore switch back and forth between auto generated trips. There is one bug. Assume you have no trips. You manually create a trip from some dives out of a group of trips that autogen would turn into a trip. Now you turn on autogen and this trip gets expanded with all the dives that would normally be grouped together. If you turn off autogen again, all those dives are still part of the remaining (initially manually created) trip. Working around this issue seemed a lot more work than the likelihood of anyone running into it seemed worth. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-13Make sure SAC and OTU get recalculated after cylinder info was changedGravatar Dirk Hohndel
Also fixed minor coding style issues (prevent useless code from being executed). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-27Add preference option to chose if SAC and/or OTU should be in divelistGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>