Commit graph

479 commits

Author SHA1 Message Date
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
Dirk Hohndel
d966fd2606 Trigger reverse geo lookup by pressing the button
This may not be the best UI, but for now it works.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 06:50:50 -07:00
Dirk Hohndel
92722adeba Notes pane: don't show taxonomy info for trip location
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 06:50:50 -07:00
Dirk Hohndel
80f26912b0 Notes pane: move the location taxonomy to a better spot
And display it smaller, marked as "tags".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 06:50:50 -07:00
Tomaz Canabrava
4059f5d995 Correctly display the data on the delegate
A bit more complex than I tought it would be (and a ton of trial
and error to find the right spot on the delegate to draw stuff)
this delegate follows the current style (so it should be okaish
on a dark and on a light theme)

This is supposed to work on a QCompleter, but it doesn't (I really don't
know why, so maybe I'll remove that completer. sigh.)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 19:25:14 -07:00
Tomaz Canabrava
1b8f7f53f2 Added again a QCompleter to show the possibilities
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 19:23:01 -07:00
Tomaz Canabrava
324b6182aa Remove location completion model
This is a functional but hard to expand model for the dive sites.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 18:54:19 -07:00
Dirk Hohndel
3055f4ac22 Geo taxonomy: show the chosen taxonomy entries in the notes pane
This isn't perfect - I'd like to have them show behind the word Location
instead as what we have now creates movement in the position of the fields
on the screen which I think is distracting.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 12:38:40 -07:00
Dirk Hohndel
65babff6bc Dive site rewrite: be smarter when dealing with auto created sites
If we download dive site locations from the companion app we can be
slightly smarter if the user overwrite the location feel on the Notes tab.
We can be pretty sure that they wanted to keep the GPS location and just
correct the dive site name (or possibly assign that location to an
existing dive site).

This tries to accomplish that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-27 23:19:49 -07:00
Dirk Hohndel
485df96cf6 Dive site rewrite: mark location field as soon as editing starts
Don't wait until the user switches focus to a different part of the tab to
mark the location field.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-27 06:53:11 -07:00
Dirk Hohndel
0afe07d021 Dive site rewrite: make trip location edit work
Don't erase the trip information after the user started editing it.

Don't act as if a dive was edited - it's trip information we are
modifying.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:23 -07:00
Dirk Hohndel
89599b81ac Dive site rewrite: clearing the location field means no dive site
If the user wants to remove the dive site from a dive they need to be able
to do that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:23 -07:00
Tomaz Canabrava
dee59e5334 Dive site rewrite: fix adding a new dive and chaning notes / description
I had to create an event filter to deal with the missing callbacks from
QPlainTextEdit (it doesn't support editingFinished()).

Also we need to manually create a dive site on a newly added dive if the
user entered one.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:23 -07:00
Tomaz Canabrava
fd31e7792e Dive site rewrite: change the default sizes of the dialog
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:23 -07:00
Tomaz Canabrava
4426cf706f Dive site rewrite: do not use Qt Model Match
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:23 -07:00
Tomaz Canabrava
7763b95e5f Dive site rewrite: fix potential crash
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:23 -07:00
Tomaz Canabrava
1fd4e55240 Dive site rewrite: copy the changed dive site to the original
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
78293f5078 Dive site rewrite: create a dive site if string doesn't exist
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
50bd467723 Dive site rewrite: mark location as changed when a dive site changes
Not sure this is the best approach.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
73eceacaed Dive site rewrite: better member name
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
05c5bf0919 Dive site rewrite: try to fix a crash
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
2fec1a88de Dive site rewrite: copy the current dive to the displayed dive
This way we can actually edit something.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
6afd9161e8 Dive site rewrite: correctly position the edit site widget
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
32928b3880 Dive site rewrite: create a dive site edit dialog without borders
Plan is to make it pretty later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
3435d13509 Dive site rewrite: add the taxonomy labels for the dive sites
This doesn't work yet because we don't get the taxonomy from the geo
referencing services yet - but it's ready to be populated.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:14 -07:00
Tomaz Canabrava
e28af7c639 Dive site rewrite: use a QCompleter to show the list of dive sites
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:49:59 -07:00
Tomaz Canabrava
8bd9fb161a Dive site rewrite: location edit on notes tab is again a LineEdit
Hopefully we now have the UI semantics figured out.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:49:46 -07:00
Dirk Hohndel
f5726c3d18 Fix a number of resource leaks
Free memory returned from parse_mkvi_value()
Free memory returned from printGPSCoords()
Free memory allocated in added_list and removed_list
Free memory allocated when adding suffix to dive site name
Free memory allocated in cache_deco_state()
Free memory allocated in build_filename()
Free memory allocated in get_utf8()
Free memory allocated in alloc_dive()
Free memory allocated as cache but never used

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:13:32 -07:00
Dirk Hohndel
ccc9d80015 Remove all the no longer necessary code that aborts read of first V2 file
This was a poorly implemented hack when we executed the reverse geo lookup
in the main thread and opening a V2 file could take a very long time. We
need to do the "Welcome" message quite differently.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16 14:41:56 -07:00