Commit graph

413 commits

Author SHA1 Message Date
Tomaz Canabrava
f6f2c4e929 Only repopulate the dive info once ( we were repopulating 4 times )
This makes the screen repopulate itself after a dive change only
one time instead of the old 4. we were repopulateing when we
removed the actual selection to reset the old selection previously
stored, sigh.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-23 08:10:10 -07:00
Tomaz Canabrava
99922722d2 Only use HTML if the text has a <table>
The text we generate for the diveplan has a table inside, and
we must use HTML only for the dive plan. so I treat all text
as HTML, look for a table item, if it doesn't have, I treat
it as Simple text and set it on the notes. Works and makes
linus loves me again.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-23 08:09:58 -07:00
Dirk Hohndel
b3e662a895 Pick the correct timezoneoffset for the day in question
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-16 20:24:56 -07:00
Tomaz Canabrava
bebcbfe92a Desselects the trip before dive add / plan, and reselects it on cancel
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-16 16:08:22 -07:00
Tomaz Canabrava
bf7fc97b50 Fix saving and storing the dive plan notes when there's html on it
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-16 15:51:13 -07:00
Sergey Starosek
14cc59898a Date picker l10n for profile and planner
- 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-16 13:58:06 -07:00
Sergey Starosek
dcca755343 More strings to translate for statistics tab
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 13:26:41 -07:00
Dirk Hohndel
0cf55d7e39 Correctly track the 'changed' status of the equipment widgets
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-15 20:36:25 -07:00
Dirk Hohndel
327ea3aca4 Dive equipment edit - fix logic for applying changes
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-15 20:29:14 -07:00
Tomaz Canabrava
4c8e9615e4 Remove uneeded function
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-15 17:05:46 -07:00
Tomaz Canabrava
d993684fec Do not create a backup for Q_FOREACH container
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-15 16:55:10 -07:00
Tim Wootton
3a16a64616 misc capitalisation and spelling
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 07:06:26 -07:00
Tim Wootton
8940f29ead Prefer "temp." vs "temp" and sometimes "temperature"
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-10 16:30:56 -07:00
Tim Wootton
5c5168cf17 maintab capitalisation consistency
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 16:26:30 -07:00
Dirk Hohndel
a8a8bcd86a Add helper functions to ensure we have sane tag lists
There should never be empty or duplicate tags on those lists.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 09:42:28 -07:00
Gaetan Bisson
35121e1147 Complete GPS coordinates on location focusout.
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-09 09:40:44 -07:00
Tomaz Canabrava
6480a91756 Put a copy of the tags in the displayed dive upon save.
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-09 08:53:06 -07:00
Tomaz Canabrava
dbc33cb81a Correctly save the tags on the dive.
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-09 08:34:00 -07:00
Tomaz Canabrava
0054304cc8 Remove if to save or not save the tags.
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-09 08:33:21 -07:00
Gaetan Bisson
c054b18b70 make GPS coordinates autofilling really work
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-08 10:02:17 -07:00
Dirk Hohndel
cd5b2a372f UI restructure: cleanup the code when canceling an edit
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-06 12:50:30 -07:00
Miika Turkia
0c24d7d6bd Show the gas mixing information only when needed
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-05 22:55:52 -07:00
Dirk Hohndel
aafd918169 Add dive: don't throw away the pressure data entered
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-04 11:48:02 -07:00
Dirk Hohndel
da911993f1 Small cleanups
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-03 21:05:08 -07:00
Gaetan Bisson
6a57ce5c6b Autofill GPS coordinates for added dives.
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-03 17:59:09 -07:00
Dirk Hohndel
611bae3441 UI restructure: use displayed_dive for add dive and plan dive
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-03 14:45:01 -07:00
Dirk Hohndel
6b1b2bc919 UI restructure: get rid of "current" pointer in cylinders and weights
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-03 09:37:55 -07:00
Dirk Hohndel
a86aca0378 UI restructure: only switch to edit mode if user made change
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-03 09:37:55 -07:00
Dirk Hohndel
66870add77 UI restructure: track if any data was modified
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-03 09:37:55 -07:00
Dirk Hohndel
20d9fafd7c UI restructure: improve memory handling in maintab
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-03 09:37:55 -07:00
Dirk Hohndel
56501dda1e UI restructure: updateDiveInfo displays displayed_dive
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-03 09:37:55 -07:00
Dirk Hohndel
635a7ab771 UI restructure: updateDiveInfo shows the selected dive by default
So don't be redundant.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 09:37:55 -07:00
Dirk Hohndel
a221a6e9f5 UI restructure: use a global variable to hold the dive we show / edit
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-02 11:56:36 -07:00
Dirk Hohndel
81f8ed901f Add dive: remove cylinder pressures from samples
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-01 10:28:42 -07:00
Dirk Hohndel
8bd16a7808 Equipment edit: for some reason we need a local copy of index
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-07-01 10:18:21 -07:00
Anton Lundin
b2288e1e3d Calculate approx gas bill on dives
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-29 17:15:09 -07:00
Dirk Hohndel
3ef490fe11 Fix crash when cancelling a trip edit
We were comparing the wrong data and freeing things that shouldn't be
freed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-28 13:42:38 -07:00
Sergey Starosek
e88f37d327 Start external viewer on photo double-click
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-27 06:56:21 -07:00
Dirk Hohndel
a925e677f1 Correctly use our "localtime"
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-26 16:05:48 -07:00
Tomaz Canabrava
81fd56b16f Fixed changing dates with the new date widget.
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-26 15:48:49 -07:00
Tomaz Canabrava
1e2349e794 Added code for TimeEdit
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-26 15:48:33 -07:00
Tomaz Canabrava
89816f64c2 Headers cleanup.
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-26 15:47:02 -07:00
Tomaz Canabrava
0223ebf510 Added the new Date Widget on the MainTab.
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-20 15:41:42 -07:00
Tomaz Canabrava
867d9f1391 Simplify code
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-20 15:41:35 -07:00
Dirk Hohndel
a4050c2a71 Don't copy the current dive ontop of editedDive after edit has started
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-12 13:34:57 -07:00
Dirk Hohndel
f54849987e Remove unused variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 13:18:16 -07:00
Dirk Hohndel
e6fe4760a0 Improve statistic on used gas
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-10 11:45:20 -07:00
Dirk Hohndel
8a0d852a7c Add gas consumption statistic for selected dives
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-09 22:48:21 -07:00
Dirk Hohndel
0102604645 Don't show the average depth for the selected dives
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-09 20:32:44 -07:00
Dirk Hohndel
95cb4e85ee Dive edit: do a better job noticing when the coordinates were changed
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-09 10:55:56 -07:00
Dirk Hohndel
37910751a0 Dive edit: avoid memory leaks
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-03 18:12:24 -07:00
Dirk Hohndel
c5437c7499 Dive edit: don't free the taglist of the master dive
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>
2014-06-03 18:04:39 -07:00
Dirk Hohndel
a12b10c008 Ask before discarding edits
This is equivalent to what we do for the planner.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 18:01:00 -07:00
Tomaz Canabrava
eb24d90c8e Add a static 'instance()' member for the Photos model.
This will make referencing it from  a few places more easy.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 16:40:01 -07:00
Dirk Hohndel
fafaf0eef0 Cancel dive edit when escape key is pressed
Also seems intuitive. What's odd is that in the Planner you get a
confirmation dialog while here you don't. We should be consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 15:31:21 -07:00
Tomaz Canabrava
3595ad0294 Make the new picture widget display the pictures.
Small changes in the model to display the pictures of the dives.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 00:05:24 -07:00
Dirk Hohndel
eb9d6d0f94 Rewrite dive edit logic
The existing code took an odd approach. It tried to change all selected
dives whenever the user edited a field, and kept all this backup data in
case the user rejected the edits.

This code takes the opposite approach. Only edit a copy of the selected
dive and then when the user accepts it, edit all the dives and when the
user rejects the edit simply redraw the screen (as all the "real" data is
still unchanged).

This not only saves quite a bit of code, it should be much easier to get
correct.

Admitedly this code will need quite a bit more testing to make sure it
works as intended, but as far as I can tell it already gets more scenarios
right than the previous implementation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 23:38:36 -07:00
Tim Wootton
d825d689dd Override the MinMaxAvgWidget tool tips for the depth instance.
Add new methods to the MinMaxAvgWidget class to allow us to override the
default tooltips of its min and max icons, and then uses these methods to
make the tooltips for the Stats tab Depth instance more descriptive.

See #521

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 20:20:17 -07:00
Tomaz Canabrava
b601db30ad Fix edition of manually added dives.
This patch correctly sets the state of the planner to "NOTHING"
after trying to edit a manually added dive.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 17:06:27 -07:00
Tomaz Canabrava
c3306c39f1 Fix crash on adding / removing a dives from add menu
This patch removes some inconsistencies that were happening on the add
dive / cancel actions. a bit of legacy code from the old system was still
in, which made things quite...  EXPLOSIVE.

This fixes restoring the selection only if we have a selection and not
deleting the temporary dive twice.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 17:03:47 -07:00
Dirk Hohndel
b08969ac33 Dive add: fix crash when canceling
We need to reset the editMode right away, otherwise all the changes to the
input field (when resetting the data after the user cancels) will cause
Subsurface to crash as current_dive will temporarily be NULL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 20:31:18 -07:00
Dirk Hohndel
f2ecb6d0eb Fix manually adding dive
I'm sure canceling the plan when saving an added dive made sense at some
point for some reason. Right now it makes things crash, so let's not do
it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 16:12:09 -07:00
Dirk Hohndel
b9e9eeb441 No need to separately enable and switch focus to the dive list
RefreshDisplay() does this for us.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:48:38 -07:00
Dirk Hohndel
0d58cfb641 Planner: don't try to update the MainTab dive info while in plan mode
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 15:18:15 -07:00
Tomaz Canabrava
feff22c222 Planner: Re-enable using the new profile.
This correctly enables the planner on the new profile,
but it doesn't triggers the correct paint on the canvas.

[Dirk Hohndel: remove other remnants of the disabled planner as well]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:17:32 -07:00
Dirk Hohndel
5ba573240f Gratuitous whitespace changes
I keep trying to get to consistenct.
Completely hopeless.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 11:40:22 -07:00
Tomaz Canabrava
fe1df6b1cc Back to profile or empty state when finishing addition.
This patch adds a signal to MainTab, that should be removed from there
when we finish the rework on the edit part, to go to the edit classes,
but in the meantime, let's keep it there.

The signal is connected to the ProfileWidget in a way that the end of the
edit will also trigger the profile to go back to ProfileState (show the
dive, if there's any) or empty Profile (if there's none).

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 09:12:32 +09:00
Dirk Hohndel
09e7c61fee Consistently use for_each_dive (and use it correctly)
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-20 06:37:19 +09:00
Dirk Hohndel
6d42a99e7f Improve the tag widget to allow us to tab to the next field
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-18 14:32:15 +09:00
Tomaz Canabrava
2b06e4be67 Move printGpsCoords from MainTab to QtHelper
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-13 09:16:11 +09:00
Anton Lundin
b5cc387f03 Apply the edit of trip locations
This re-adds this code that got removed in a209dfbfd5 ("Multi dive
edit: don't change location texts until user saves the change")

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:18:59 -07:00
Anton Lundin
b59a106251 Only mark location changed when in edit mode
Otherwise the code loading a dive into the field would mark it as
changed.

This re-adds this code that got removed in a209dfbfd5 ("Multi dive
edit: don't change location texts until user saves the change")

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:18:53 -07:00
Dirk Hohndel
94937d2ad9 Improve the color coding when editing coordinates
This still gets it wrong (i.e. marks things as edited when they are not or
not edited when they are) but at least they are no longer incorrectly
marked as incorrectly parsed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:58 -07:00
Dirk Hohndel
0a6c16f35a Hack around a translation issue
I cannot figure out how to get the hemisphere letters translated correctly
in qthelper.cpp. Short term hack for now - someone who understands how
this is supposed to work really needs to take a look.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:58 -07:00
Dirk Hohndel
fb82da58a2 Globe: assume that we are looking at the current_dive
As in commit 3870bdafee53 ("Globe: we always center on the current dive")
passing in a specific dive here makes no sense - it's always about the
current dive.

Fixes #513

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:58 -07:00
Dirk Hohndel
2bc76beb65 Globe: we always center on the current dive
Simplify the API (we'll take advantage of this in the next commit).
We always center the globe on the current dive, so no point in passing
that dive in.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:47 -07:00
Dirk Hohndel
a209dfbfd5 Multi dive edit: don't change location texts until user saves the change
If we keep updating the location text of all selected dives we can lose
the status of which dives had the same text of the original dive and which
did not (this happens if the location we are adding is identical to a
selected location but adds text to the end of it).

Now we only edit the other dives after we accepted the change.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 13:15:33 -07:00
Dirk Hohndel
0c836ebc47 Simplify string comparison
This is based on Linus' idea on the mailing list.
Treat NULL strings and empty strings as identical.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06 14:15:59 -07:00
Dirk Hohndel
024420a60d More multi-edit fixes
This time for values that aren't simply text.
For normal integers this is rather straight forward. For the 'when'
timestamp we simply assume that this is a shift in time.

What is still missing is consistent handling of the three fields that are
implemented as tags: tags, buddy and divemaster. We have special code for
tags that makes no sense in a multi-edit scenario. And we treat divemaster
and buddy as a single string - which kinda works but treats "Bill, Joe"
and "Joe, Bill" as different.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06 13:59:06 -07:00
Dirk Hohndel
bcf973190c Only change identical fields when editing multiple dives
This was broken when porting to Qt - we used to do this correctly in the
Gtk version.

When editing multiple dives we show the current dive to the user and allow
them to edit that and then apply those edits to all selected dives. The
way this is SUPPOSED to work is that we only change those selected dives
that had the same value for the edited field as the current_dive had for
that field.

Let's say you select ten dives. The current dive shows divemaster Joe. You
change that to divemaster Jim. Then only the selected dives that had
divemaster Joe should change to Jim. All other dives should stay
unchanged.

This seems to implement that logic.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06 11:13:24 -07:00
Dirk Hohndel
217c82f6c4 Change EDIT_SELECTED_DIVES macro
The way this is implemented is broken in several ways.
This fixes the first issue.
For the invocations where we are in the 'WHAT' checking to see if the
value we are changing in the selected dive was previously the same as in
the current dive (which is the one shown to the user for editing), then we
need to make sure we change the current dive last, otherwise the
comparison will fail.

Of course, right now we only do this check for gps location, which is a
massive bug as far as I am concerned.

Fixes #515

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06 09:58:27 -07:00
Dirk Hohndel
3364e5b490 Re-center on current dive if dive edit is canceled
If the user changes the coordinates for a dive but then cancels the dive
edit, the globe would stay at the location that was temporarily set and
not rotate back to the still active coordinates.

This fixes it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 21:26:18 -07:00
Tomaz Canabrava
4243fcb915 Dont set coordinates when two or more dives are selected
If a trip is selected (or for other reasons more than one dive), this
would change the GPS coordinates of the whole selection which almost
certainly isn't what the user wanted.
Instead, only allow changes of the coordinates on the globe if exactly one
dive is selected.

[Dirk Hohndel: massively rewritten and extended - but I didn't want to
               simply "steal" the commit from Tomaz...
	       This now maintains the "zoom out mode" for dives without
	       GPS coordinates and deals with edits of multiple dives that
	       are initiated the "normal way" by starting to edit other
	       data as well.]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 15:23:33 -07:00
Dirk Hohndel
dad3c5d9db Only auto-fill coordinates for non-empty location strings
When editing the location string we try to be smart and automatically add
the correct coordinates (assuming we have a location of this name already
in the dive list). So if you return to the same dive spot you'll get the
correct coordinates by default. But this creates bogus result if we allow
an empty location to be matched, as it makes no sense to assume that all
dives without a location name were at the same coordinates.

Fixes #498

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-28 09:34:27 -07:00
Yosef Hamza
3027701a14 Correctly edit air/water temp in dive struct
When changing the values of air/water temp after the first time and save,
it will be reset the intial value.
This is fixed by removing the "select_dc" (which makes the change to the
dive struct instead).

Fixes #457

Signed-off-by: Yousef Hamza <jo.adama.93@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 17:51:22 -07:00
Yosef Hamza
ad9eb73d73 Mark Air/Water temp field red for wrong input.
As a warining for the user mark the field red.
If the user inputs invalid input that will be ignored
while parsing.
But with adding a one character error margin to prevent it from toggling
between Red and Yellow while editing existing values, for example "After
Deleting unit and last number after '.'"

Signed-off-by: Yousef Hamza <jo.adam.93@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-14 05:16:31 -07:00
Lakshman
ecc8c1d995 Remove check option to show units in text label
Currently the feature to show temperature units while adding dive is
provided through checkbox in preferences->units section. This patch
disables this checkbox and always enables this feature.

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-05 13:27:53 -07:00
Dirk Hohndel
3485c6c260 Correctly handle dive selection after editing dives
It's a tricky problem as we need to remember this across a divelist sort
(as the user might have edited the date / time). The old code made not one
but two incorrect assumptions.
a) it assumed that the added or edited (but previously manually added)
dive was the last one in the dive list (clearly wrong when adding a dive
that has an earlier date)
b) it ignored the fact that refreshDisplay() would select the top dive in
the list if no dive was selected

This patch addresses both of them and makes the code easier to understand.

Fixes #480

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-03 10:26:48 -07:00
Lakshman
df7d7d4981 Fix redundant spaces in info panel
Remove redundant spaces from dive master and buddy list fields.
Ticket also mentions about similar space behaviour in tag field, which I
couldn't reproduce.

Fixes #476

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:58:23 -07:00
Jan Mulder
fe2ad15603 Redraw profile when manipulating cylinders
Manipulating cylinders, especially changing the exact gas content (o2,
he), changes the pp02, ppHe graphs. This patch simply replots the profile
in case of cylinder change at time of saving.

Signed-off-by: Jan Mulder <jlmulder@planet.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-25 07:53:37 -07:00
Anton Lundin
8bc2ad1473 Enable parts of planner based on define
In bf205726 DEPTH/Switch at was disabled by commenting out that code.
This puts it back behind ifdefs

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-23 17:24:40 -07:00
Gehad
f2238300ef Saving edits requires to move focus first
After editing values in cylinders or weights hitting save will not save
the changes to save the edit one must move the focus to a different
field first this is fixed by losing the focus before saving the changes

Fixes #412

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-19 09:27:04 -07:00
Anton Lundin
17a675367d Translate using tr() to be Qt5-compatible
There are no utf8 in those strings, and we can translate them as
everything else with tr() instead.
QApplication::UnicodeUTF8-part is deprecated and removed in Qt5.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-17 20:37:41 -07:00
Linus Torvalds
37794e2e23 Be more careful about dive computer selection
The selection logic was a bit random: some places would return NULL if
the dive computer index was out of range, others would return the
primary dive computer, and actually moving between dive computers would
just blindly increment and decrement the number.

This always selects the primary computer if the index is out of bounds,
and makes sure we stay in bound when switching beteen dive computers
(but switching between dives can then turn an in-bound number into an
out-of-bounds one)

Fixes #464

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-17 10:53:49 -07:00
Dirk Hohndel
cb41f34826 Don't put cylinder widget in edit mode if deletion of cylinder failed
If the user tries to delete a cylinder that is in use and that action is
rejected, the cylinder widget (and the whole dive) should not be put into
edit mode. After all, nothing changed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 15:38:10 -07:00
Lakshman
6e4466aa0a Show temperature units in the label when editing dive
Currently when user wants to add a new dive information,
the ways to know what unit system is being used are

 - Through preferences panel.
 - Save the dive information, which displays units in
   the text field.

This patch provides an option to the user to show current
unit system by displaying the unit on the side of the label
when the user is editing the fields.

This feature can be enabled or disabled by using the new
checkbox option i.e. `Show units in text labels` included
in `preferences->units` section.

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-10 21:10:27 -07:00
Linus Torvalds
eb47b2a8d8 Get rid of crazy empty tag_list element at the start
So this is totally unrelated to the git repository format, except for
the fact that I noticed it while writing the git saving code.

The subsurface divetag list handling is being stupid, and has a
initial dummy entry at the head of the list for no good reason.

I say "no good reason", because there *is* a reason for it: it allows
code to avoid the special case of empty list and adding entries to
before the first entry etc etc.  But that reason is a really *bad*
reason, because it's valid only because people don't understand basic
list manipulation and pointers to pointers.

So get rid of the dummy element, and do things right instead - by
passing a *pointer* to the list, instead of the list. And then when
traversing the list and looking for a place to insert things, don't go
to the next entry - just update the "pointer to pointer" to point to
the address of the next entry. Each entry in a C linked list is no
different than the list itself, so you can use the pointer to the
pointer to the next entry as a pointer to the list.

This is a pet peeve of mine. The real beauty of pointers can never be
understood unless you understand the indirection they allow. People
who grew up with Pascal and were corrupted by that mindset are
mentally stunted. Niklaus Wirth has a lot to answer for!

But never fear. You too can overcome that mental limitation, it just
needs some brain exercise. Reading this patch may help. In particular,
contemplate the new "taglist_add_divetag()".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-10 11:36:17 -07:00
Tomaz Canabrava
24c5b2e3c1 Code Cleanup ( that fix 2 bugs )
This code cleanup fixes the two issues that I raised on
my last e-mail. hurrah.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 08:50:54 -07:00
Tomaz Canabrava
ac9a23ef3b Remove the old profile from the main screen of Subsurface
This patch partially removes the code for the old profile from
Subsurface. It removes the use of the old profile on the mainwindow,
but keeping the code in the tree for now.

A bit of code-cleanup also entered this commit because I had to change
every instance of the code that used the old profile.

Now to the real code-cleanup

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 08:54:20 -08:00
Dirk Hohndel
7c535452f9 Whitespace cleanup
Minor change to the perl postprocessing script and resulting changes to
the affected source files.

This deals with two issues:
- "foreach"-like structures were not always treated correctly
- some longer calculations that ended on "+ constant" were reformatted in
  a rather unatractive manner

In one source file (divelist.c) I ended up adding braces to the sources...
trying to cascade the indentation further down without having the block
there seemed a lot more trouble than it's worth.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 13:29:22 -08:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
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-27 20:09:57 -08:00
Miika Turkia
78c68518f8 Clear edit mode for manually added dives
Edit mode must be cleared for manually added dives as well when one hits
cancel or save.

Fixes #437

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-20 09:22:43 -08:00
Boris Barbulovski
c86822c2f4 Replace mainWindow() with MainWindow::instance()
C++ style of accessing single instance class object.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 11:42:59 -08:00
Dirk Hohndel
9c9867dec5 More variable scope confusions
Don't have nested loops with the same loop variable. Really. Even if it is
legal C++.
And don't declare local variables more than once. This will only cause
issues later.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 06:07:32 -08:00
Linus Torvalds
e58f54cac1 Fix ATM-vs-bar confusion
SAC should be calculated in relationship to surface pressure, not "1 bar".

I also realize that we have a few other cases where we do the same
mistake: the partial pressure calculations do things like

    po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive);

which is wrong as well - the partial pressure is also relative to
standard atmospheric pressures.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 14:05:54 -08:00
Boris Barbulovski
507a929a27 Migrate MainTab models(QStringListModel)
Migrate MainTab models
  from static xxxCompletioModel::instance()
  to private MainTab variable members.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:45 -08:00
Boris Barbulovski
359ea75516 maintab.cpp improvements.
* Initialize(lazy) MainTab::multiEditEquipmentPlaceholder struct

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:07 -08:00
Dirk Hohndel
bf20572630 Disable the switching depth column for cylinders
Since the planner is disabled this column isn't needed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-26 07:37:11 -08:00
Robert Helling
f22428b345 Allow manually added dives to have their location changed
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-22 08:35:57 -08:00
Sergey Starosek
6a58712270 Enter dive edit mode on divemaster field focus
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 13:57:40 -08:00
Sergey Starosek
b8c746d975 Expand tags approach to divemaster field
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 13:57:40 -08:00
Sergey Starosek
c8807c2ad2 Use focus policy setting from widget constructor
Since we use tags widget for several input fields (tags, buddy,
divemaster), it makes sense to keep focus policy setting in one place.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 13:56:11 -08:00
Sergey Starosek
ec1088f2cc Ignore mouse wheel events on tags widget
This prevents tags widgets (dive tags and buddy) from grabbing
focus on mouse wheel events but allows entering dive edit mode
on mouse click.

It was attempted earlier by Dirk (commit d117beca), but edit mode
did not work properly.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 13:56:06 -08:00
Sergey Starosek
d9c23bb622 Remove duplicate method call
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 05:56:45 +07:00
Boris Barbulovski
6cc65f5e1c Fix some memory leaks.
Memory leaks were caused by broken parent/child relations.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:15:47 +07:00
Dirk Hohndel
a27f67c026 Whitespace and coding style updates
Another futile attempt to cleanup the code and make coding style and
whitespace consistent. I tried to add a file that describes the key points
of our coding style. I have no illusions that this will help the least
bit...

This commit should ONLY change whitespace

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 11:50:56 +07:00
Sergey Starosek
dca59f06d7 Enter dive edit mode on buddy field focus
Seems it's related to bug #390. Not sure whether this fix is correct.

See #390

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:34:45 +07:00
Sergey Starosek
88f3df5c79 Extend tags model to Buddy field
This doesn't change storage format. Instead it  parses buddy strings and
converts them to string list which is supplied to tags widget.

This feature  was requested in ticket #311

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:12:56 +07:00
Anton Lundin
1c0c516b42 Don't downgrade tags to Ascii
Use Utf8 everywhere, and toAscii is depricated in Qt5

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15 15:52:45 +07:00
Anton Lundin
7e9582631d Convert to TRUE/FALSE to stdbools true/false
I had problems with this one on Qt5.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15 15:52:31 +07:00
Tomaz Canabrava
ddecc3b56a Add CaseInsensitivity to all of the completers.
Just one of the completers had Qt::CaseInsentitive set,
setting for all of them.

Fixes #400

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 06:19:04 +08:00
Lubomir I. Ivanov
a30a0910b4 Maintab: prevent a segfault in the 'Equipment' tab
When a dive contains no cylinders, clicking the '+'
button could SIGSEGV if current_dive->dc.model is NULL.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 10:56:29 -08:00
Tim Wootton
65eb86f854 MainTab location coordinates displayed in ISO6709 format
changes the location coordinates display in the main tab
 to use ISO6709(2008) Annex D suggested format.

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 09:18:45 -08:00
Dirk Hohndel
9bff4eda35 Clear equipment tab for trips display
And prevent the user from editing equipment in trip edit mode (those edits
are both meaningless and of course will be ignored once we save the
changes to the trip).

Also moved some code for setting up tanks, weights, tags, etc, into the
"this is not a trip-edit" part of the updateDiveInfo() function.

Fixes #392

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-27 17:31:23 -08:00
Dirk Hohndel
74faca5d43 Handle editing a manually added dive consistently
Regardless of whether the user clicks in the info tab, makes a change to
equipment or starts by editing the profile (i.e., clicking on the little
penguin), we should get into the same state and behave the same way.

This means that when editing a manually added dive we are always in
editMode == MANUALLY_ADDED_DIVE - and editMode == DIVE means we are
editing a dive that came from another source.

Fixes #379

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-27 17:12:38 -08:00
Dirk Hohndel
3fb3bd60b6 Don't reset panels while editing a dive
MANUALLY_ADDED_DIVE is a different flavor of ADD mode (in both cases we
are in "planner mode"), so bail out for that as well.

See #379

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-25 13:06:29 -08:00
Tomaz Canabrava
231fd2e6e0 Fix subsurface on dark themes.
This patch fixes my last annoyances with dark themes
on subsurface. It changes the background color of the
edited info tab to a darker yellow if the theme is
dark, and a light yellow if the theme is light.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:23:10 -08:00
Dirk Hohndel
9405895285 Improve GPS string handling
This adds support for two more GPS coordinate formats and also fixes a
couple of issues with the previous implementation.

We used to only support full degrees and decimal minutes. We now also
support fully decimal and degrees, minutes and decimal seconds.

The previous implementation would color the input field red if either it
couldn't parse the string, or if it was able to parse it but it was the
same as the previous location. That's misleading.

The previous implementation also changed all gps coordinates to the new
coordinates in a multi-dive edit - instead of just changing the ones that
are the same as the master dive.

Fixes #387

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-23 14:59:38 -08:00
Tomaz Canabrava
029522880f When saving / canceling edition, focus back to the Dive List
When saving / canceling the edition, focus was still being kept on the
current selected widget. not good. :) this patch makes the DiveList
keep the focus after a edit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Tomaz Canabrava
29a19e2e84 Fix the cursor problem on the TagWidget
The problem was the Focus Prevention system on the
EventFilter. Instead of that we can pass the setFocusPolicy (
strongFocus ) that ignores the mousewheel. simpler and cleaner.

Fixes #376

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Tomaz Canabrava
890d60ff9e Simplify the code by removing a few options from the if.
There was some options on the 'if' that didn't
really belonged there, so I create a if before those
to quit earlier if the condition is true.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:04 -08:00
Lubomir I. Ivanov
69ed0d8393 Fix a missing parentheses warning
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-19 07:28:24 -08:00
Michael Andreen
5f12660870 Use UTF-8 for text strings.
Fixes #371

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-16 16:14:50 -08:00
Dirk Hohndel
4b98efb39c When editing multiple dives, only copy the cylinder type
Previously we would overwrite the gasmix as well as start and end
pressure even when editing multiple dives, which clearly is wrong.

Fixes #364

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-14 09:32:24 -08:00
Dirk Hohndel
d117becad8 Improve MainTab behavior when using the scroll wheel
This gets the behavior close to what we really want.
- scroll wheel no longer enters edit mode when over the tabWidget
- scroll wheel doesn't modify dateTimeEdit, nor does it enter edit mode
- scroll wheel still scrolls both the notes and the full widget

The only oddity is that when clicking on either the dateTimeEdit or the
tabWidget we don't immediately turn on the 'being edited' warning (as we
do for all the other widgets). For those two widgets the user has to press
a key before edit mode starts.

I think this Fixes #176

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Ideas-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-13 21:18:54 -08:00
Tomaz Canabrava
5ac29bbe74 Save and reestore scrollbar position on editing the items.
Save and restore scrollbar position on editing the dives.
I think this is not the best place for it, but I'll leave
it here for a while untill I find a better place.

Fixes: #343
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:26:39 +01:00
Dirk Hohndel
e5561d7668 Fix selection tracking bug
When trying to remember a newly manually created dive across the
sort_table() call I abused the dive->selected flag and didn't clear it out
afterwards (most likely thinking "hey, I'm calling selectDive() on this
anyway").

This caused the UI code to correctly mark the dive as selected, but when
it called down to the C code to keep the internal data structures in sync,
that code didn't update amount_selected as it thought this dive had
already been selected. And that caused other parts of the code to get
confused, which manifested for example in the failed upload to
divelogs.de.

So this clears out the flag after abusing it to remember a dive. Maybe we
should add a 'remembered' flag instead, but for now this fixes the issue.

Fixes #351

Initial-fix-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-10 06:25:30 +01:00
Anton Lundin
a3f3e85246 Use implicit zero initialize for the whole array.
Clang yelled about it, and it looks prettier. It also felt kinda strange
to explicit initialize the first element to zero and the rest to zero
implicit.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09 22:47:12 +01:00
Dirk Hohndel
b144e64b9b Fix typo in color
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07 08:13:55 -08:00
Tomaz Canabrava
66716b5297 Make Gnome3 be bearable
The layout of Subsurface on Gnome 3 had a few flaws, since Qt and Gtk
are not really compatible. This implements a CSS that makes the use
of Gnome 3 more pleasant to the eyes.

Fixes #318

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-04 12:41:07 -08:00
Tomaz Canabrava
9190c97a3c Attempt to fix the 'click goes to 0,0' thing on the globe.
This patch attempts to fix the 'click goes to 0,0' bug on the
globe. it moves a bit of code around and I particulary don't
like the way that we are dealing with 'EditMode', I think I'll
refactor that for 4.1. We are alredy dealing with a bunch
of states, maybe a State Machine will help on removing code-complexity.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03 18:48:17 -08:00
Tomaz Canabrava
d128b74a8a Select the newly added dive after adding it.
Selects the newly added dive after adding it, it uses a
rather ugly hack that forced a unselected dive to be
marked as 'selected' so we can remember what was the
newly added dive, and select it after.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03 18:48:17 -08:00
Dirk Hohndel
25bfcf5f6d Don't call fixup_dive when editing a trip
When editing a trip the key for the notesBackup is NULL. Don't call
fixup_dive() on that...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03 15:17:38 -08:00
Henrik Brautaset Aronsen
b1febf17b1 Make sure the save/cancel message is always shown
An addition to the "Move dive notes edit message above the
scrollable widget" commit:  Make sure the save/cancel message is
always displayed on top, regardless of which tab is selected.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03 13:01:16 -08:00
Dirk Hohndel
a529285e9e Make dive edit message box tex more concise
commit 3c064d5857 ("Make the message when editing a dive fit better")
kinda fixed the wrong problem. A better solution was suggested - just drop
the instructions regarding Cancel / Safe. It's quite obvious what to do
mow that the buttons are part of the message.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-02 15:48:01 -08:00
Dirk Hohndel
3c064d5857 Make the message when editing a dive fit better
This should keep the message widget visible without horizontal scroll bar,
even on fairly small screens.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-02 09:55:18 -08:00
Tomaz Canabrava
7ce12f1e8b Removed The button box from mainwindow, buttons are now on the message.
The button box on the bottom of the window made it a bit cluttered
on small screens, this patch uses the window of the MessageWidget
to show the butons - this way less space is used and things are better
spaced on screen.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-02 09:55:04 -08:00
Tomaz Canabrava
d26f109fba Fixes Setting the dive-location via the map.
This patch adds a context menu to set the dive location
via the globe, being the dive with a coordinate or not.

It also fixes setting the dive location on edit mode.

Fixes: #315

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-02 09:44:55 -08:00
Dirk Hohndel
502a514e91 Reflect air and water temperature changes in dive info
When editing air or water temperature, you are actually editing the
information in the active divecomputer structure. But the Dive Info shows
the summary data created from the temperature data in all dive computers.
For most people who will only ever have one divecomputer per dive this may
seem like an artificial distinction, but it's very important if you track
more than one computer.

So in order to have an edit reflected in what's shown, we must redo the
"summary creation" for data from the different divecomputers into the
summary fields of the dive.

Fixes #313

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-01 20:17:17 -08:00
Henrik Brautaset Aronsen
51d298c8d5 Separate text labels for air and water temperatures
The "air / water Temperatures" label didn't look to good.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 07:18:39 -08:00