Commit graph

507 commits

Author SHA1 Message Date
Dirk Hohndel
d85a448ee8 Dive edit: if the user didn't pick a dive site, don't mess with it
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 20:03:53 -07:00
Dirk Hohndel
6ee2a44235 Merge branch 'NewLocationEditDropdown' 2015-09-23 14:18:40 -07:00
Tomaz Canabrava
483320a0c0 Disable edit dive site if already in edit mode
If user selected a new dive site (a dive site that doesn't
exists yet, to be created) and clicked in edit it would edit
the *old* dive site. this is not optimal, but since it
removes a severe regression it will be like this (I won't
change it till 5.0) for a while, until I have time to
actually code something not messy for that.

The current dive location management is *much* nicer than
the old one, code-wise. No more magic numbers, magic codepaths,
magic constants, qt black magic. It's straigth-forward code
simple to follow, simple to edit.

This was something I was actually postponing for 5.0 but I
managed to get a boost of subsurface time at work.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:50 -07:00
Tomaz Canabrava
7426f18a96 Handles Dive Selection gracefully
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:50 -07:00
Tomaz Canabrava
ffae64ded7 Code cleanup
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:50 -07:00
Tomaz Canabrava
1e88982d6f Much simpler code to set the dive site
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:50 -07:00
Tomaz Canabrava
fec33cee93 Don't crash on new dive site
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:49 -07:00
Tomaz Canabrava
cc6967b53c Set the correct dive site uuid
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:49 -07:00
Tomaz Canabrava
5b3d52acec Correctly fix the popup position
When the message to 'This dive site is being edited' was
being show while the popup to choose the dive site, the
line edit was being covered. now it correctly moves to
the correct place.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:49 -07:00
Tomaz Canabrava
d586970f31 Removed a ton of dead code
Unused dead code / hack for the old QCompleter

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:49 -07:00
Tomaz Canabrava
e4c0ee32cd Handle palette change for dive site selection
If you select a dive site with a different uuid than your
current dive.dive_site_uuid, you should get a different
pallete to state clearly that something changed.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:23 -07:00
Tomaz Canabrava
8c9a4ecd4b Stabilize the location model/proxy model
Since I removed the old location edit from the UI, I also need to
remove a bit of code from the UI that was calling it.

fix a few crashes regarding the old location edit.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:15:19 -07:00
Tomaz Canabrava
be6e190bd2 Skeleton of the new LocationCombobox
This is the bare minimum skeleton of the new completer for the dive site
management. Nothing works, yet, nothing is hoocked up, yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 14:07:07 -07:00
Dirk Hohndel
a30e78140f Hide a couple of debugging messages
They are useful to show when trying to figure out what's going on, so just
move them behind a check for verbose.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23 12:20:21 -07:00
Tomaz Canabrava
d59e89e569 Make Facebook more user friendly
The current way that facebook works is terrible: it's scattered
around tons of files ( at least 4 different files and classes )
this moves things around a bit, add a disconnect button that
was missing, cleans tons of code and fix inconsistencies.

I will also redo this part for 5.0, but it's too late for 4.5

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-16 21:16:58 -07:00
Dirk Hohndel
c41810e5a5 When editing a manually added dive, correctly update max depth
The fixup_dive() function assumes that values that are set already in the
divecomputer and dive structures come from a reliable source - sometimes
dive computers are able to track a maximum depth continuously, so that
value can be larger than the deepest sample and we need to honor that.

But in the case of a manually added dive, the samples define the dive. So
in this case we need to reset the values that were calculated when the
dive was first added so that the user can then edit the dive and reduce
the maximum depth reached in the profile and have that reflected in the
dive list.

Fixes #926

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-11 10:54:05 -07:00
Sander Kleijwegt
d22a135343 Fix edit & show of divesites for new and existing dives.
The UI detects when it should refresh the loction after the
user finished editting a divesite. Creating and editting
divesites is now working even when the current dive is not
saved yet.

Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-29 20:10:32 -07:00
Sander Kleijwegt
9770369889 Always show the dive site edit button
Update the tooltip and enable only when there is a divesite selected

Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-28 16:16:05 -07:00
Sander Kleijwegt
67abcd0c2c Fix mouse clicks on divesite completer.
Use clicked instead of activated signal on the completerList to
handle the selection of a divesite.

Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-28 16:15:25 -07:00
Tomaz Canabrava
b8a09ca520 Keep the dive list disabled if editing a dive
When, in a dive edit mode user entered a dive site
and went to dive site edit mode then finished the ds
edit, the app would lose the disabled property of the
dive list, making it possible to select a new dive
when we where editing another one, complete mess.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 18:00:26 -07:00
Tomaz Canabrava
fc6d819616 Create a new dive site and edit it automatically
If the user clicks on the first or second option of the drop
down list, subsurface will move him to the dive site edit panel
automatically, since it's a new dive site and there's no information
about it yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 18:00:15 -07:00
Tomaz Canabrava
0ba832ef12 Move dive site list to its correct position
When we are in display dive mode, and then edit the
location text edit, going to edit dive mode, the location
text edit will be moved a bit below of it's original position
but the Dive Site List would be already opened, and stuck
on it's original position, covering the dive list.
This patch fixes that.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 17:59:25 -07:00
Tomaz Canabrava
03702edf87 Get taxonomy from edit dive site widget
Moved the get taxonomy button from the maintab to the edit dive site
widget.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 17:58:59 -07:00
Tomaz Canabrava
aaa70ff56e Turn the get taxonomy button into a manage dive site button
The get taxonomy button will be inside the manage dive site interface.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 17:58:46 -07:00
Dirk Hohndel
e03b553e80 Make created dive site uuid deterministic
Having random uuids seemed like a good idea, but there are several
situations where they really cause problems. One is merging dive file
imports from V2 logfiles. Another is testing such imports.

Instead of making the uuid random we now hash the name and add the
timestamp of the first dive associated with this dive site to the hash
(first in this context is "first encountered" with no guarantee that it is
the chronologically first). This way V2 imports create deterministic uuids
but uuid conflicts are still extremely unlikely, even if the user has
multiple dive sites with the same name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:48 -07:00
Robert C. Helling
260ea879e5 Make debugging cleaner
Don't try to connect the globe when NOMARBLE is active.

Check exisistance before trying to open an image file.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-03 22:19:36 -07:00
Tomaz Canabrava
7efa924067 Transform GlobeGPS in a static instance() class
This is needed to start easing the transition from the completely
wrong and bogus MainWindow::instance()->globe() calls. this is still
wrong, but with it I removed one level of indirection.
I did that now because I wanted to not taint the location management
when I use it to deal with the globe.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-31 10:28:17 -07:00
Tomaz Canabrava
9130ff8a97 Correctly update the dive when the user edits dive_site
We didn't correctly update the dive site as soon as the
dive_site edit finished, and this time we are actually
correctly updating things using signals instead of calling
the mainwindow for everything.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-31 10:27:16 -07:00
Tomaz Canabrava
0a473b3a2a Fix mouse interaction with the Location List
paint methods should be used only to paint, not to trigger other
widget behaviours ( we could got ourselves into a bad recursion
bug from that ). Also, enabled mouse tracking to correctly track
the mouse movement inside the widget.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-16 18:34:22 -07:00
Dirk Hohndel
076f86202a Change API signature to act on dive_site, not uuid
This way in the future we can pass in a pointer to a dive site that isn't
linked in our dive site list yet (i.e., while we are editing).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-16 12:41:04 -07:00
Dirk Hohndel
45392615cd Dive edit: handle dive sites more sanely while editing
While we edit things, displayed_dive_site is the authoratative source of
data that should be displayed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-16 10:43:37 -07:00
Dirk Hohndel
0f906dad6f Don't reset editMode when refreshing the display
Just because we want to update the latest information on the Notes tab
doesn't mean we are done editing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-16 10:42:56 -07:00
Dirk Hohndel
9a5ac0d3ac Just call the member function
This code was embarrassingly indirect. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-16 09:52:24 -07:00
Dirk Hohndel
22c83af6ad Dive site handling: make sure the data in displayed_dive is updated
After an edit when the dive is redisplayed we are not copying the data
from current dive back over displayed dive (as the reasonable assumption
is that we just edited the displayed dive and copied the information into
the current dive)- so make sure that after the dive site handling the
displayed dive does in fact have the correct dive site information.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-16 06:40:16 -07:00
Dirk Hohndel
874d3c4799 Dive site handling: special case for auto generated dives
When we download GPS data from the webservice we can end up with dive
sites that are simply a place holder for the the GPS fix. If we replace
the name of one of those sites we should just delete the site (assuming it
isn't used in another dive, which is unlikely but theoretically possible).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-15 21:27:49 -07:00
Dirk Hohndel
542e04266d Dive site handling: correctly handle the different scenarios
- do not create dive sites unless the user has accepted the changes
- all modification are tracked in the displayed_dive_site
- when the user accepts the changes, the real dive site list (and the
  selected dives) are updated according to what is in the
  displayed_dive_site

This adds quite verbose debugging messages and disables a section of code
that has a special case for data created by the Subsurface web service.
This code needs some re-thinking and should eventually go away.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-15 15:44:15 -07:00
Tomaz Canabrava
536469107d Fix selecting the first index
The way a QCompleter works is that it grabs whatever
data it has in the completerRole and sets it back on
the line edit.

I Bypassed the QCompleter delegate to show something
other than the completerRole (so, for instance, if you
write 'B', you could get 'Blue Hole' as the returned text,
but in fact the QCompleter has the 'B' as internal string
(because of the weird - and wrong way in which we are
dealing with completion - trying to complete for something
that's not inside the model yet).

So I hooked up a signal that will listen to the complete's
index, and if it's the first row() it's surely the special
case - then we bypass QCompleter return string and use
our own.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-14 15:22:00 -07:00
Tomaz Canabrava
cd3f10d5ad Offer an option to just complete the text
Make the kids fight no more.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-14 14:54:01 -07:00
Tomaz Canabrava
9510f40db4 Remove quick edit dive site widget
Voted down by common consent.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-14 14:44:39 -07:00
Tomaz Canabrava
49ab30ae8b Change Location Management to make Linus Happy
Do not overwrite a dive site if the name is the same
as any other dive site,  create a new one and duplicate
the information.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13 16:06:05 -07:00
Tomaz Canabrava
1a68e7985b Move code that handles location to a sane place
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13 15:44:16 -07:00
Tomaz Canabrava
c658f2878b Select right divesite on click
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13 15:43:03 -07:00
Tomaz Canabrava
3b2a02dffa Get the selected dive site from the list
Hooked up an eventFilter on the QListView that displays our dive sites so
it would filter the keys enter and space, storing the current dive_site
uuid when that happens.

Also it stores the uuid on clicks.

Now we need to get that information when processing acceptedChanges() and
check if the uuid stored there == displayed_dive_site.uuid and also if
text != displayed_dive_site.name, because if the user didn't click on
anything but only wrote stuff on the LineEdit no dive site would be
selected and so uuid == displayed_dive_site.uuid (wich would mean 'no
changes')

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13 15:41:16 -07:00
Anton Lundin
e16b116297 Teach divemode editing about multiple dc's
This teaches the edit divemode about the fact that we can have multiple
dc's with different divemodes. The previous code always just edited the
first dc.

This was reported by Ian Pitt in:
https://groups.google.com/forum/#!category-topic/subsurface-divelog/4Zf47KS4Ifk

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-09 06:29:59 -07:00
Tomaz Canabrava
eff22c28db Show the correct delegate on the completer
For some reason the completer wouldn't show the delegate if the line order
of the code was different.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-08 07:49:29 -07:00
Robert C. Helling
e864c365c7 Correct logic
At least my compiler warns about ! binding stronger than == and
thus comparing a bool to an int. I guess this is what was meant.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 15:54:20 -07:00
Dirk Hohndel
898d82e647 Notes pane: don't show empty taxonomy tags
No point in searching for the right tag if the user picked no taxonomy to
be shown. And no point in showing an empty value, either.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 10:23:16 -07:00
Dirk Hohndel
bc8c54f1ee Rename enum values for taxonomy
This avoids confusion and namespace collisions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 10:22:31 -07:00
Dirk Hohndel
f554c2d16c Merge branch 'taxonomy' 2015-07-02 07:03:03 -07:00
Dirk Hohndel
0a0a6f07d5 Remove a few more debug messages
Yes, I could go back and try to fix the earlier commits.
This is easier.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 06:59:08 -07:00