aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2014-05-20Migrate code to for_each_dive and for_each_dcGravatar Anton Lundin
[Dirk Hohndel: this overlapped with my commit 09e7c61feeea ("Consistently use for_each_dive (and use it correctly)") so I took the pieces that I had missed] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20Fix building with NO_MARBLE prepareForGetDiveCoordinatesGravatar Anton Lundin
Commit fb82da58a2 ("Globe: assume that we are looking at the current_dive") changed the prototype for GlobeGPS::prepareForGetDiveCoordinates. This patches the dummy in NO_MARBLE. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20Fix building with NO_MARBLE, centerOnCurrentDiveGravatar Anton Lundin
Commit 2bc76beb65 ("Globe: we always center on the current dive") changed GlobeGPS::centerOn to GlobeGPS::centerOnCurrentDive. This patches the dummy in NO_MARBLE, too. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20Consistently use for_each_dive (and use it correctly)Gravatar Dirk Hohndel
The way the macro is written there is no need to test the dive against NULL before dereferencing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20Dive list: add context menu function to renumber dive(s)Gravatar Dirk Hohndel
No attempt is made to ensure that what the user does is sane. So this can result in duplicate numbers, non-consecutive numbers, non-monotonous numbers, whatever floats the users boat. You can renumber a single dive or all selected dives (with a starting number given that is applied to the oldest selected dive and then for each newer selected dive that number is incremented by one). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Remove unused variablesGravatar Dirk Hohndel
These were leftover in commit 90638180d21a ("Use the used flag on cylinders in get_dive_gas"). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Add ability to make a dive computer the first dive computer of a diveGravatar Dirk Hohndel
If a dive has multiple dive computers we enable a special context menu when the user right-clicks on the dive computer name AND is not already showing the first dive computer. In that case we offer to make the currently shown dive computer the first one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Show the dive computer number (if a dive has more than one)Gravatar Dirk Hohndel
For most users this is no change at all. For the few who download from multiple dive computers this now shows them which of them is the primary dive computer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Make the code easier to readGravatar Dirk Hohndel
This uses the new helper function from commit fc4f133f19d0 ("Add new helper function that looks up the index of a dive by its uniq ID") to make the logic implemented in commit 122593a63a46 ("Fix selection after downloading dives from the dive computer") much saner to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Add new helper function that looks up the index of a dive by its uniq IDGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Fix selection after downloading dives from the dive computerGravatar Dirk Hohndel
If we successfully download dives, the old selection should be cleared and the one of the newly downloaded dives should be selected. I decided to pick the last dive downloaded, which for most dive computers (but for example not for the Uemis SDA) will be the first or earliest of the dives. That seems much more intuitive than keeping the previous selection around. Of course this is harder than it should be because of the way we track selections and because we need a consistent dive list model in order to change the selection. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Assign the uniq dive ID the moment a dive is allocatedGravatar Dirk Hohndel
Previously we only did this when we did fixup_dive(), but that way we can't reference dives "early" in their life cycle (e.g., right after they got downloaded). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Change get_dive_by_diveid to get_dive_by_uniq_idGravatar Dirk Hohndel
The original name was a really bad choice as we have a 'diveid' as part of struct divecomputer - and that is not the diveid that is being used here. Instead we use the 'id' member of struct dive which holds the "unique ID" for this dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Download from dive computer: Fix the broken selection of devicesGravatar Dirk Hohndel
The old code was completely bogus - it's confused about what the variable 'i' is counting. This also let's us select the Uemis mount point by default if that's the only valid "device" that we found. Compile tested on Windows, untested on Mac. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Divecomputer download: try to offer only those devices that make senseGravatar Dirk Hohndel
If the user selects a Uemis divecomputer, don't show serial devices. If the user selects a serial divecomputer, don't show the Uemis filesystem. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-18Improve the tag widget to allow us to tab to the next fieldGravatar Dirk Hohndel
If the last key that went in ended a tag and the next key is a tab - deliver that to the TabWidget instead so we can navigate between input fields. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14git save: add list of dive computers to the commit messageGravatar Linus Torvalds
This makes it much more obvious what is going on when you save in between importing multiple dive computers, since the last dive description otherwise stays the same. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14git load: initialize dive computer timestamp and duration from diveGravatar Linus Torvalds
We don't save the dive computer timestamp and duration if they match the dive timestamp and duration. But that means that on loading, we need to default the dive computer time/duration to the dive one. If they differ, the loading of the divecomputer file will then override the default timestamp/duration. This mainly matters if a later dive merge then changes the timestamp of the dive: the dive computer timestamp needs to have been set correctly and not change. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14Mark new dives "downloaded" when importing new divesGravatar Linus Torvalds
We used to do this just for dive computer downloads, but we should do it for all imports, so that merging new import data always does the expected thing: any new dive computers will be added to the end of the list of preexisting dives, rather than the other way around. (Of course, if you set the "prefer downloaded" flag, that reverses this logic, and makes the newly imported dive computer data be the primary dive computer. That flag is currently only exported for dive computer downloads, not for imports). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14Don't merge divecomputers if we know they are differentGravatar Dirk Hohndel
When merging dives, if we know for sure that the dive computers are different, don't merge them into one (by interleaving the data), but instead keep both as separate dive computers in the same dive. This fixes a bug when due to a faulty download the same dive from two dive computers looks quite different. They don't get merged automatically (which is fine - they are quite different), but when manually merging them, we of course want one dive with two dive computers, not one dive with one merged dive computer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14git save: don't crash if the last dive isn't in a tripGravatar Linus Torvalds
The git save tries to generate a nice commit message based on the most recent dive, but stupidly didn't check whether that dive was in a trip or not, and unconditionally used the trip pointer to see if there was a trip location. Which works well enough if you always generate trips, but is an unmitigated disaster otherwise. Oops. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14Do not use default filename as default for "Save as"Gravatar Dirk Hohndel
This may sound counterintuitive but it actually makes sense. If you have a default filename that's the name of you "normal working file". If you want "Save as" something, that by definition is NOT your normal working file but a subset or an experiment or something. And you most definitely do NOT want to overwrite your default file with that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Do not check for null before free.Gravatar Tomaz Canabrava
C specs says that we can safelly free a NULL pointer, so there's no reason to check if it's null before freeing it. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Rename getDiveById to get_dive_by_id to keep current c code organized.Gravatar Tomaz Canabrava
This commit renames getDiveById to get_dive_by_id, and it also removes the Q_ASSERTS and if(!dive) return that the callers of this function were calling. If it has a Q_ASSERT this means that the dive must exist, so checking for nullness was bogus too. I've changed the assert (done in a silly C-Way. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13rename 'get_dive_by_diveid' to 'get_dive_by_uemis_diveid'Gravatar Tomaz Canabrava
A bit longer, but we had a function named get_dive_by_diveid and another one named getDiveByDiveid that did completely different things, it was too easy to hit the wrong one.. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Move DiveList related methods/classes to own file.Gravatar Tomaz Canabrava
The DiveList classes were a partial mess (and some of it is still in a messy state). The classes that deal with it where done in 'qtHelpers.h', the extern global variable in dive.h, a few methods here and there. This concentrates most - but not all - functions in their own file. The reason for that is to make the new developer faster when looking for things: if it's a divecomputer related method, it should be in a single file, not scattered around. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Move printGpsCoords from MainTab to QtHelperGravatar Tomaz Canabrava
Last time I touched this I got a scream from dirk, but then I looked at the code again and the problem that I faced was that I broke translations in a sad way, well, now I broke it again. However, this method shouldn't belong to MainTab ( because of that thingy that I said before and also many others: Separate the logic of your application from the UI specific code ) This generates a string that's going to be used on the Interface, it doesn't display it on the interface. Move it down below makes it easier to test ( I don't need to create an Widget and worry about the parent-relationship with the mainwindow just to test this function, for instance. ) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-12Don't use locale for git save formatGravatar Linus Torvalds
I stupidly used "weekday()" without realizing we localize it. And we really don't want to make save formats be localized (we don't localize decimal numbers etc either). This fixes the git save format to just use a hardcoded weekday list. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-12Fix git loading of odd localesGravatar Linus Torvalds
This should make git loading be able to load git saves with arbitrary weekday names. Even strange German ones. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-12Uemis downloader: fix corner caseGravatar Dirk Hohndel
When we first get an invalid dive info and then, once we decremented the offset, get a valid one but for the wrong dive and then try to calculate the correct offset, we need to keep the existing offset in mind. What a horrid design. Thanks, UEMIS. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11Documentation spelling errorsGravatar Jeremiah Mahler
A general review of the documentation has found more spelling errors. Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11Prefix a method with 'dive_' because it should work only with divesGravatar Tomaz Canabrava
I'll probably add prefixes to functions to make it easier to find method via autocomplete from the grep or interface helpers, do you wanna know all the functions that works with a dive? ask for the completion for dive_, do you wanna know all the functions that works with a divelist? ask for the completions on divelist_ or run grep -rIs divelist_ on the header files. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11use for_each_dive instead of hand-written loop.Gravatar Tomaz Canabrava
It's easyer to make a mistake in the loop insteaf of using the currently correct one that's already written Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11When creating methods that pass QString, use const QString&Gravatar Tomaz Canabrava
This removes unecessary creation and destruction of the object making the code shine a bit more and be more fluffy. :) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11'Class' string is unecessary when using a Container.Gravatar Tomaz Canabrava
pretty self explanatory, the 'class' keyword is unecessary when defining things inside a Container, be it a QList, QVector, QMap, QHahs or anything else. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11Simplify code.Gravatar Tomaz Canabrava
this is not necessary when you don't have a variable that has the exact same name as the 'this->variable' name, also, there's no need to check if a QString is empty before trying to use the == on them. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11Correct the usage of std::string and QStringGravatar Tomaz Canabrava
QStrings shouldn't be == "" to check for empty string, use .isEmpty() QStrings shouldn't be != "" to check for non empty, use .size() std::string shouldn't be cleared with = "", use .clear() Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11Remove old defines.Gravatar Tomaz Canabrava
Those were from the ancient Gtk times where we hardcoded the white stars and black stars as font glyphs instead of drawing them. get rid of it. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11Move unit related code to units.hGravatar Tomaz Canabrava
The units are used everywhere in the application, we don't really need to include "dive.h" to be able to use unit conversion, so I changed them to a new file. There is still a lot of non-dive stuff in dive.h / c, I'll try to move more later. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-10CodingStyle "to" "too" typoGravatar Jeremiah Mahler
Small typo in CodingStyle. ".. in this file to." should be "... in this file too." Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08When starting the planner, copy cylinders from currently selected dive.Gravatar Robert C. Helling
This way, the user can save dives containing sets of "standard cylinders". Selecting one of those prepopulates the gas list for the planner. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Use the used flag on cylinders in get_dive_gasGravatar Anton Lundin
Now when we have a used flag on every cylinder that are set in mark_used_tanks we can use it here. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Use enum name instead of its int value.Gravatar Anton Lundin
SAMPLE_EVENT_GASCHANGE2 is the libdivecomputer name of the event. Compare with that instead of its int value. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Remove unnecessary include from dive.cGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Fix building with NO_MARBLE after prototype changeGravatar Anton Lundin
4243fcb915 ("Dont set coordinates when two or more dives are selected") Changed how the prototypes in GlobeGPS looks. This aligns NO_MARBLE version of GlobeGPS with that. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Offer to discard the plan when Quit is triggered in planner.Gravatar Robert C. Helling
Upon pressing Ctrl-Q or the window close button a modal dialog was shown to remind the user that the planned dive is not saved. This patch triggers the "cancel plan" action before trying to quit. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: show gas for the NEXT segmentGravatar Robert C. Helling
For deco stops show the gas of the next segment in the table. In recalculation remove old deco stops earlier. In struct diveplan, the items are "segments" with a beginning, a duration, and a gas. In contrast, the UI of the planner uses "waypoints" which are the boundaries between segments. It is conventional at least for deco stops to display the gas of the _next_ segment in the runtime table (i.e. the gas possibly to be switched to). Furthermore, in addStop, the old deco stops have to be removed earlier as otherwise a new waypoint later than a previous generated gas switch inherits the gas of the old switch. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Add waipoints when changing ascend rate in plannerGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Implement ascend rate according to GUE standard proceduresGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Change when we recalculate decoGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>