aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
AgeCommit message (Collapse)Author
2014-07-16Pick the correct timezoneoffset for the day in questionGravatar Dirk Hohndel
Calculating the timezoneoffset for the current date really makes no sense whatsoever when displaying a time that isn't "now". Fixes #605 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Desselects the trip before dive add / plan, and reselects it on cancelGravatar Tomaz Canabrava
When we had a trip selected, we ignored that and simply called the DiveAdd functions, but the mainTab code that deal with selections to show one or more dives or trips asked how many trips were selected to the DiveList, and since a trip was selected things go kabum. Fixes #606 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Fix saving and storing the dive plan notes when there's html on itGravatar Tomaz Canabrava
We save an HTML table-based plan, so we need to get the text as html, not plaintext. Fixes #634 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Date picker l10n for profile and plannerGravatar Sergey Starosek
- set application-wide locale from preferences - use custom date format for display Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16More strings to translate for statistics tabGravatar Sergey Starosek
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Correctly track the 'changed' status of the equipment widgetsGravatar Dirk Hohndel
updateDive() cannot reset the changed status - this is called while the dive is edited. Instead this status is reset when the user either accepts or rejects the changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Dive equipment edit - fix logic for applying changesGravatar Dirk Hohndel
We keep getting this wrong. First you check all selected dives that are not the current dive, make sure the equipment was the same before the edit and then apply the changes. Then, when you are done with ALL of them, then you change the current dive. Otherwise you cannot compare to the 'before' state anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Remove uneeded functionGravatar Tomaz Canabrava
This method was being unused, rip it off. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Do not create a backup for Q_FOREACH containerGravatar Tomaz Canabrava
Q_FOREACH will expand and already creates a copy of the contained container, so this is just a waste of cpu cycles and also increases a tiny bit the memory consumption. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11misc capitalisation and spellingGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Prefer "temp." vs "temp" and sometimes "temperature"Gravatar Tim Wootton
For consitency in the UI There are plenty more of these to find, and once in a while "Temperature" looks more apropriate, like in a title, but most of the time "temp." works best. Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10maintab capitalisation consistencyGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Add helper functions to ensure we have sane tag listsGravatar Dirk Hohndel
There should never be empty or duplicate tags on those lists. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Complete GPS coordinates on location focusout.Gravatar Gaetan Bisson
Introduce on_location_editingFinished() and move the GPS coordinates completion logic there. This simplifies acceptChanges(), but replaces the clever code for multidive completion by something a little more straightforward. Note the call to on_location_editingFinished() from acceptChanges(); without it, completion only happens *after* the dive has been saved. [Dirk Hohndel: trivial merge, minor changes for consistency] Signed-off-by: Gaetan Bisson <bisson@archlinux.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Put a copy of the tags in the displayed dive upon save.Gravatar Tomaz Canabrava
I don't think this is the right approach, but it makes things work. The reason that it was not working before it's because upon save we are not copying the edited dive against the displayed dive for some reason, and I didn't find the place that should deal with that. This fixes one of the various issues around tags, but others remain. Fixes #587 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Correctly save the tags on the dive.Gravatar Tomaz Canabrava
Very good patch, lots of removed lines. :) Only try to add the tags when user accepts, discards the test to see if the tags were changed or not, delete the old list and copy the new one always. only bug that's appearing now: taglist is still empty after save we need to reselect the dive to make it appear, fixing that on the next patch. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Remove if to save or not save the tags.Gravatar Tomaz Canabrava
The way that we work with tags is a bit weird, we have a global tag_list pointer and every dive copy the tags from there. the problem is that the tags_changed() function looks at those two places ( the global and the dive-local lists ) to see if something was changed, but we shouldn't add anything at the global taglist untill a tag is really added, so that function is bogus. The correct way to check if something changed is to check all the strings in tags against the strings in the QLineEdit and see if they are the same, then we can add things to the tag_list. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-08make GPS coordinates autofilling really workGravatar Gaetan Bisson
Move the gpsHasChanged() call on selected dive when coordinates have changed *before* autofilling, otherwise it erases the autofilled values. Also update displayed_dive when autofilling, otherwise values are stored but not displayed immediately after saving. Signed-off-by: Gaetan Bisson <bisson@archlinux.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-06UI restructure: cleanup the code when canceling an editGravatar Dirk Hohndel
This was way too complicated because we used to edit a "live" dive that was on the dive list. All we really need to do is systematically make sure that all the widgets are in the correct state. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-05Show the gas mixing information only when neededGravatar Miika Turkia
Recreational divers, especially ones diving with air, do not need to be shown that their gas can be mixed with 0 liters of O2 and He. And similarly Nitrox diver does not need to know about 0 liters of He. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04Add dive: don't throw away the pressure data enteredGravatar Dirk Hohndel
Previously we were trying to get rid of the tracked gas pressures that were added when using the plan infrastructure to create a dive. Now that this isn't the case anymore we can stop doing that which magically makes setting start and end pressure while adding a dive work as expected. Fixes #582 Fixes #553 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03Small cleanupsGravatar Dirk Hohndel
Add commented out options to subsurface.pro that enable debuging the planner. Remove obsolete comment. Clean up the selection tracking. Force the re-sort of the divelist inside the reload instead of explicitly calling it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03Autofill GPS coordinates for added dives.Gravatar Gaetan Bisson
Prior to commit 95cb4e, when a new dive was added with the same location name as a previous dive, the GPS coordinates for that new dive would be automatically set to that of the matching previous dive. This restores this feature, by duplicating code further down qt-ui/maintab.cpp that handles the case where multiple dives are modified at once. Signed-off-by: Gaetan Bisson <bisson@archlinux.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: use displayed_dive for add dive and plan diveGravatar Dirk Hohndel
This gets rid of the stagingDive and stops the constant adding and removing of dives from the divelist (that was an INSANE design, seriously). When adding or planning a dive all work is now done in the dedicated displayed_dive. Add dive mostly works - when the user clicks save the dive is added to the dive list and selected. Plan dive is mostly untested. It passed trivial "start planner, save" testing so it's not entirely broken, but I'm sure there's more work to be done there. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: get rid of "current" pointer in cylinders and weightsGravatar Dirk Hohndel
Instead always display the display_dive. Now the only thing left to slay is the stagingDive... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: only switch to edit mode if user made changeGravatar Dirk Hohndel
With this patch a simple click into the main tab does not start editing mode. Only once a value is modified do we show the message box and disable the other widgets. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: track if any data was modifiedGravatar Dirk Hohndel
Instead of comparing the dive structures (which doesn't work since the strings are actually copies), track if the user made changes. Cylinders and weights still need to be compared as they are handled in different widgets. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: improve memory handling in maintabGravatar Dirk Hohndel
Free strings before overwriting them. Use copy_dive() instead of just copying the dive structure. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: updateDiveInfo displays displayed_diveGravatar Dirk Hohndel
Instead of passing in a divenr of -1 to make it clear things this changes things to use an options "clear" flag. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: updateDiveInfo shows the selected dive by defaultGravatar Dirk Hohndel
So don't be redundant. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-02UI restructure: use a global variable to hold the dive we show / editGravatar Dirk Hohndel
There is massive confusion about what we display when and where and which dive structure (or pointer to a dive structure) contains which information at which stage. This is the first step towards restructuring all of this. This creates a global variable displayed_dive which at any point in time should be what is displayed on screen (both in the profile and in the maintab). It removes the editedDive concept from MainTab. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-01Add dive: remove cylinder pressures from samplesGravatar Dirk Hohndel
These cylinder pressures are actually just artefacts of the way we track gas consumption in the code shared between planner and add dive. We don't want them in the actual dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-01Equipment edit: for some reason we need a local copy of indexGravatar Dirk Hohndel
Calling enableEdition appears to corrupt the index that is passed into this slot. This doesn't fix the problem that we can't edit the cylinder start and end pressure of a manually added dive, but at least we no longer try to edit and invalid index. See #582 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-29Calculate approx gas bill on divesGravatar Anton Lundin
This uses a bit of naive gas computations to figure out how much of different base gases you used up on the dives the statistics is done for. It's quite useful to get a minimum line about how big your gas bill is going to be after a dive trip. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-28Fix crash when cancelling a trip editGravatar Dirk Hohndel
We were comparing the wrong data and freeing things that shouldn't be freed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-27Start external viewer on photo double-clickGravatar Sergey Starosek
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26Correctly use our "localtime"Gravatar Dirk Hohndel
We use time stamps without timezone, so we need to correct for the current time zone offset before showing dates and times in time zone aware widgets. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26Fixed changing dates with the new date widget.Gravatar Tomaz Canabrava
The maintab was connecting with an invalid slot on the new date widget, QDateTime instead of QDate Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26Added code for TimeEditGravatar Tomaz Canabrava
This makes the TimeEdit work again. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26Headers cleanup.Gravatar Tomaz Canabrava
Too much noise on the headers, this commit remove uneeded headers when they are uneeded. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-20Added the new Date Widget on the MainTab.Gravatar Tomaz Canabrava
the new date widget still needs a bit of work, but the design is working already. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-20Simplify codeGravatar Tomaz Canabrava
If a class inherits QObject, it doesn't needs to call QObject::tr for the tr function. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-12Don't copy the current dive ontop of editedDive after edit has startedGravatar Dirk Hohndel
If you switch to edit mode by making a change to cylinders or weights, then the data in the editedDive was changed and afterwards the current dive was once again copied into the editedDive - even though we already did that earlier when setting up the display. Fixes #539 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10Remove unused variableGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10Improve statistic on used gasGravatar Dirk Hohndel
This raises the maximum number of gas mixes listed to 20 and also changes the layout / design of the stats tab to make it much more attractive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09Add gas consumption statistic for selected divesGravatar Dirk Hohndel
We already did a list of gases and volume consumed for the selected dive on the Dive Info tab, but did not provide that same data on the Stats tab for all the selected dives. I arbitrary limited this to eight gases (as the list can get quite long when you select a lot of dives). The gases are sorted by volume consumed. Fixes #535 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09Don't show the average depth for the selected divesGravatar Dirk Hohndel
Being shown between the deepest and shallowest dive's max depth it confuses a lot of people - the average depth is frequently less than the shallowest of the dives, so at first glance it looks like the "average" is less than the "minimum". So having three numbers grouped like this that use different algorithms is just distracting. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09Dive edit: do a better job noticing when the coordinates were changedGravatar Dirk Hohndel
Previously the code could get confused by edits (including trivial things like deleting the coordinates). It seems much more reliable to simply compare the coordinates of the edited dive with the ones in the current dive before the edits. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Dive edit: avoid memory leaksGravatar Dirk Hohndel
If we edit any of these fields, we create new strings via strdup (or a fresh tag_list). So if the edits are rejected, free all that memory. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Dive edit: don't free the taglist of the master diveGravatar Dirk Hohndel
We do all of our edits on a copy of the dive - but the tag_list points to the tag_list of the master dive (based on how we create that copy of the master dive). So only free the tag_list if it is already different from the master dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>