aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2016-08-27Settings update: Add "Dive Computer" settings to SettingsObjectWrapperGravatar Tomaz Canabrava
For some reason, the dive computer settings weren't in the settings prefs. This moves it, makes the boilerplate on Settings ObjectWrapper and make things compile. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27Settings update: Add UpdateManagerSettings to SettingsObjectWrapperGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27Settings update: Clean up save user id localGravatar Tomaz Canabrava
So, prefs.save_userid_local is being set outside of a preferences set (it's set to true and false while loading the files via xml or git) and because of that I had to bypass a few method calls. When something triggers a preferences change, the application will be notified that the preferences changed, thing that I couldn't do while reading the xml or git because that should be local-only. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-16Hide compile time warningGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-14Fill in divecomputer serial number and firmware version on loadingGravatar Linus Torvalds
We have the serial number and firmware version fields in "struct divecomputer", but we don't actually fill them in when loading the data from git or xml, because we save all that information in the separate device table instead. But in order to always have the serial number associated with a device, let's make sure to fill those fields in. It won't hurt, and this way we have the information available whether we just loaded the dive from a file, or imported it from the dive computer. One less semantic difference to worry about. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-14Fix cloud storage authentication attempt countingGravatar Linus Torvalds
The authentication count was a static counter in the authentication callback, which gets incremented until we consider the authentication to have failed. The problem with that is that it doesn't get incremented for just _one_ authentication operation, it gets incremented each time you try to load or save, so eventually the code considers authentication to have failed even if nothing ever went wrong. This fixes it by making it static to the whole git-access file, and have each operation clear it before starting a new remote access. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10Add HP117 to the cylinder listGravatar Brian Weber
Reported-by: Brian Weber Signed-off-by: weber311@gmail.com Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10Include full year for trip on divelistGravatar Miika Turkia
Having only the last 2 digits of the year is somewhat confusing as one can easily think that to be the day. Thus it is more clear to use full year for the trip header. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10Replace the "stop" symbol in deco planGravatar Robert C. Helling
Windows Server 2008 seems to be missing the heavy dash in Courier New. This replaces the symbol by an ordinary dash. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10Copy salinity and ambient pressure from diveplan to diveGravatar Robert C. Helling
... otherwise it does not get saved. Fixes #967 Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10Unify handling of QDateTime time zone informationGravatar Robert C. Helling
Subsurface uses "local time" which in particular means we never display time zone information to the user. The user (and our file format) only sees times like 5pm or 17:00. A better name than local time (which could mean "local at the dive spot) would be "watch time", the time displayed by the diver's watch when she entered the water. Internally, we store times as time_t, seconds since Jan 1 1970 0:00 UTC. Our convention for conversion between 5pm and time_t as always been to treat 5pm as if it were UTC. Then confusion arose since Qt's QDateTime (which is tied to UI elements like QTimeEdit and similar) is time zone aware and by default assumes the system time zone. So when we set a QDateTime to 5pm and then later convert it to time_t we have to take care about the difference between UTC and the system time zone. This patch unifies our solution to this problem: With it, we set all QDateTime's time zone to UTC. This means we don't have to correct for a time zone anymore when converting to time_t (note, however, the signedness issue: Qt's idea of time_t is broken since it assumes it to be unsigned thus not allowing for dates before 1970. Better use the millisecont variants). We only need to be careful about time zones when using the current time. With this convention, when assigning the current time to a QDateTime, we need to shift for the time zone since its value in UTC should actually be the watch time of the user who is most likely used to the system time zone. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10Adds Cylinder helper class for cylinder info access in grantlee templatesGravatar Tim Wootton
to allow grantlee to access individual fields of the cylinder_t struct rather than a string representation of the whole cylinder info using a grantlee structure like this one: <table class="table_class"> <tr> <td>Cylinder</td> <td>Start press.</td> <td>End press.</td> <td>Gas mix</td> </tr> {% for cylinderObject in dive.cylinderObjects %} <tr> <td>{{ cylinderObject.description }}</td> <td>{{ cylinderObject.startPressure }}</td> <td>{{ cylinderObject.endPressure }}</td> <td>{{ cylinderObject.gasMix }}</td> </tr> {% endfor %} </table> Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-30Send the appropriate signal when gitLocalOnly changesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-24Add new helper for case insensitive string comparisonGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Allow the user to give longer cloud timeout on the command lineGravatar Dirk Hohndel
When stuck in areas with really bad internet 5 seconds may not be enough, but making the timeout longer in general seems the wrong way to go. So keep the default 5 seconds but allow the user to override that with subsurface --cloud-timeout=NN Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Use preferences object to correctly store cloud statusGravatar Dirk Hohndel
There are a lot more places all over Subsurface where this needs to be cleaned up. The converstion of the preferences system has been a complete mess. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Only add non-blank cylinder strings to the cylinder listGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Remove unnecessary DivePlannerPointsModel functions and variablesGravatar Rick Walsh
Commit b1ed04a means that DivePlannerPointsModel::rememberTanks() and related functions and variables are no longer required Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Only add non-blank weights to the weight listGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Let cns and otu return ints rather than QStringsGravatar Tim Wootton
This way they display correctly when accessed from grantlee template Fixes #1085 Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Adds missing visibility to DiveObjectHelper, so it too can be used in print ↵Gravatar Tim Wootton
templates. Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21Add support for SAMPLE_EVENT_STRING event typeGravatar Linus Torvalds
Instead of having fixed numbers and trying to translate them into strings, a dive computer could just give us the string directly. Like the new EON Steel backend does. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21Properly pick cylinder use when merging divesGravatar Linus Torvalds
The cylinder use field was not merged when dives were merged. This is normally not noticeable, since hopefully the cylinder use should be the same anyway, but when re-downloading the dives from the EON Steel after updating it to also get cylinder use data, the dive merging threw the data away again since the original dive lacked it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21Get the cylinder use data from libdivecomputer if providedGravatar Linus Torvalds
This uses the extended tank type information to fill in the cylinder use (OC gas, CC Diluent or CC O2) from libdivecomputer when available. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21Add proper line ending for unit line in git save formatGravatar Linus Torvalds
The imperial and metric unit formats already had this, but the personalized one missed the newline at the end. It shouldn't really matter, since it's the last line of the file, but it is not right. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-18Show SAC rate when using the rulerGravatar Dirk Hohndel
This way it's really easy to see the SAC rate during a segment of a dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-17Stay offline if the cloud server is unreachableGravatar Dirk Hohndel
It makes no sense to keep trying. Maybe we need a UI to force it online again, but for now this works much better when using cloud storage while actually offline. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Fixup: don't capitalise best_HeGravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Planner: automate calculation of best mix for max depthGravatar Rick Walsh
Add option to calculate the best mix portion of O2 and He for the dive's max depth if the user enters * in the MOD and MND cylinder fields. Gas portions are automatically recalculated if the max depth of the dive changes. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Validate O2 in best mixGravatar Rick Walsh
We can't have >100% O2 Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Add function to calculate gas maximum narcotic depthGravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Have divedatapoint store cylinder id instead of gasmixGravatar Rick Walsh
Determining the correct cylinder index from a known gas mix can be complicated, but it is trivial to look up the gasmix from the cylinder_t structure. It makes sense to remember which cylinder is being used. This simplifies handling changing a cylinder's gas mix, either directly by the user, or indirectly in the planner. It also permits tracking of multiple cylinders of the same mix, e.g. independent twins / sidemount. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-23Support libgit2 api 0.24Gravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-20Avoid unused argument warningsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-20Preferentially use existing device ID when setting serial numberGravatar Linus Torvalds
We have two different models for setting the deviceid associated with a dive computer: either take the value from the libdivecomputer 'devinfo' field (from the DC_EVENT_DEVINFO event), or generate the device ID by just hashing the serial number string. The one thing we do *not* want to have, is to use both methods, so that the same device generates different device IDs. Because then we'll think we have two different dive computers even though they are one and the same. Usually, this is not an issue, because libdivecomputer either sends the DEVINFO event or gives us the serial number string, and we'll always just pick one or the other. However, in the case of at least the Suunto EON Steel, I intentionally did *not* send the DC_EVENT_DEVINFO event, because it gives no useful information. We used the serial number string to generate a device ID, and everything was fine. However, in commit d40cdb4755ee ("Add the devinfo event") in the libdivecomputer tree, Jeff started generating those DC_EVENT_DEVINFO events for the EON Steel too, and suddenly subsurface would start using a device ID based on that instead. The situation is inherently ambiguous - for the EON Steel, we want to use the hash of the serial number (because that is what we've historically done), but other dive computers might want to use the DEVINFO data (because that is what _those_ backends have historically done, even if they might also implement the new serial string model). This commit makes subsurface resolve this ambiguity by simply preferring whatever previous device ID it has associated with that particular serial number string. If you have no previous device IDs, it doesn't matter which one you pick. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-14Grr. Fix. Typo.Gravatar Dirk Hohndel
I never push things without compile testing. Never. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-14Only setpoint changes with non-zero SP indicate a CCR diveGravatar Robert C. Helling
There might be some spurious setpoint changes at t=0 without an actual value (I have no idea where those come from). In any case, those do not indicate that the dive is a CCR dive. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-11Remove unused variableGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-11Fix logic for presaturationGravatar Robert C. Helling
There were two problems in the calculation of tissue pre- saturation from previous dives: We added the surface interval after the dive rather than before and when also took dives into accout that were in the future of the dive considerd. Reported-by: Timothy Massey Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-01Make sure all dive computer events are represented in the plot_info dataGravatar Linus Torvalds
We could create a plot_info data that didn't contain all the time slots for the events fromt he dive computer, which would terminally confuse the plotting of the event profile widgets because it couldn't match up the event with the dive plot data model. So for example, in DiveEventItem::recalculatePos(), when the code tries to figure out the spot in the data model, it could fail, and then try to hide the event (because without the data model information it doesn't know where it should go). But that hiding would then not match the logic in DiveEventItem::shouldBeHidden(), and the event would end up being shown in the upper left-hand corner of the profile after all. The reason the plot_info data wouldn't contain the time slots is that the slots are allocated primarily for the sample data, and then the events would be added in between sample data in populate_plot_entries(). But since we'd only add the event pointer *between* samples, that would mean that events after the last samples would not get plot-info points allocated to them. That issue was exacerbated by how we also truncate uninteresting samples at the end when some dive computers end up giving a long stream (possibly several minutes) of "at the surface" events before they finally turn off logging. This makes sure that we take the event timestamps into account for the "maxtime" calculation, and also that we finish populating the plot_info data with any final event timestamps. Now all the events will have a matching plot_info entry. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-01Don't ignore surface events in xml parsingGravatar Linus Torvalds
I missed the fact that not only did we skip importing surface events from the dive computer, we had also made our xml parser ignore them when loading an xml file. All part of our historical "let's ignore surface events because dive computers are being very annoying about it". Signed-off-by: Linus Torvalds <torvalds@linux-foundtion.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-31Don't ignore surface events from libdivecomputerGravatar Linus Torvalds
There are cases where we actually want to keep them, as exemplified by this situation from Richard Yorke: "I have just come across a situation when ignoring the surface marker is a disadvantage. I have just had a problem with my BC feed seeping, slowly filling my BC and as I control my buoyancy on the bottom using the air in my drysuit, I did not notice, so that when I came to ascend the expanding air in my BC caused a loss of control. Fortunately not from a great depth and no untoward consequences. However, the Subsurface profile only shows me rising to 4m and descending to 5.5m for my safety stop. However I actually broke the surface and descented to 5.5 but the frequency of recording depth was not fast enough to show this as it was so brief" so remove the code that ignores the surface events entirely. I think we'll have to come up with some smarter filtering model for showing them, but that is predicated on getting these events to come through in the first place. Reported-by: Richard Yorke <yorke.richard@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-31Make 'clear_dive()' free the primary dive computer data properlyGravatar Linus Torvalds
Our primary dive computer really is special, not just because it's the first one: it's directly embedded in the "struct dive", and so if you just walk the divecomputer list, you'll miss it, because it's not _on_ the list, it is the very head _of_ the list. We had that bug in copy_dive(), and it turns out we have it in clear_dive() too: clear_dive() would free all the dive computers on the list, but not the actual primary one. This is a minor memory leak, no more, so it's not exactly critial, but let's just do it right. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28Add some gas mix validation to the plannerGravatar Rick Walsh
A few basic rules for gas validation: We can't have <0%, or >100% of either O2 or He O2 + He must not be >100% Switch depth can't be <0% This places limits on user-input values Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28Shearwater import model name for Petrel and PredatorGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28Set model on Shearwater importGravatar Miika Turkia
For starters, let's just state that this dive was downloaded from Shearwater. However, once we have information how model numbers map to names, we can use that info for the models we know about. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28Use serial as device ID on Shearwater importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21fixup: Don't confuse EAD and ENDGravatar Rick Walsh
The previous patch (Planner: add best mix EAD preference) used the term EAD (equivalent air depth) in variable names and strings, when it should have been END (equivalent narcotic depth). They're not the same thing and shouldn't be confused. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21Planner: add best mix EAD preferenceGravatar Rick Walsh
Add best mix EAD preference and UI, along with a tooltip describing what it does Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21Add functions to calculate best mixGravatar Rick Walsh
Best mix O2 calculated based on planner Bottom O2 preference Best mix He calculated based on EAD of 30m (should be made user-configurable) Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>