Commit graph

100 commits

Author SHA1 Message Date
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
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
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
Dirk Hohndel
ee8f7de4e7 Add missing return statement
We act on the event but don't consume it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-27 16:05:24 -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
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
09f2d3b35d Dive site rewrite: fill and change the current dive site
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
09172ddfa4 Change the name of the dive site on the globe
The name of the dive site on the globe wasn't being
updated when we changed the name of it in the dive
management dialog.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-07 08:04:37 -07:00
Tomaz Canabrava
111968776f Reset the current dive site when we reject it
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-07 08:04:37 -07:00
Tomaz Canabrava
ed20b004a8 Always fill the fields in LocationInformation edit widget.
If the current_dive was the same as the dive send to
the LocationInformation widget, we would do nothing,
wich is wrong because we could have filled the information
on an add_dive_site action and then cancelled it, so the
info will stay there until we change it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-07 08:04:37 -07:00
Tomaz Canabrava
203c3e3077 Fix acceptChanges for add mode
We didn't save the uuid of the newly created dive site on the affected
dive.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:45:26 -07:00
Tomaz Canabrava
8ff7826302 Fix reject changes for add/edit
Reject changes was correct only for Edit, but not for Add. When in add
mode we need to retrieve the old dive site, and when in edit mode we
should do nothing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:44:49 -07:00
Tomaz Canabrava
af22ebf3f1 Do not set the state of the application from here.
The mainwindow should manage the mainwindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:44:32 -07:00
Tomaz Canabrava
484fdee6fb Fire signals for edit and filtering
Edit will always fire,
Filtering only if the dive site already exists.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:43:53 -07:00
Tomaz Canabrava
6a09062065 Only filter by divesite if the divesite exists
And not when we are adding a new dive site.
Also, remove hide button call.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:43:30 -07:00
Tomaz Canabrava
db333226d9 Reset state: have a correct dive site being displayed
I'm not sure if this is the right approach, but it seems to work: when we
reset the state of the widget, we try to get the current dive site from
the current dive, and set it.

This way it will work for the globe later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:43:07 -07:00
Tomaz Canabrava
3561d34745 Current dive site has nothing to do with enableEdition
It will be set later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:42:40 -07:00
Tomaz Canabrava
9c34f196fa Fix the message buttons in dive_site_edit
Some button management operations where unnecessary.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:42:00 -07:00
Tomaz Canabrava
612b068e33 Different states for edit / add dive site
When we start the dive site edit dialog, either for add or for edit, we
don't save the state, so the reject state didn't know what to do with the
dive site.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:36:42 -07:00
Tomaz Canabrava
6cd85d9b73 Simplify model handling and crashes fixes
So, there's only one crash left (that I put a big TODO: on the maintab.cpp
about) and I'll fix it tomorrow as it's quite late here and I'm almost
sleeping at the keyboard.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:36:48 -07:00
Tomaz Canabrava
ee9746c622 Remove unused method
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:36:36 -07:00
Tomaz Canabrava
9dc32de878 Remove Combobox from LocationManagement
I tought about it a bit, and the combobox of the location management was a
bit overkill - we already have another combobox to select the divesite and
also the plus button to add one.

If the user wanna edit the current divesite, he can go to menu and edit it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:35:50 -07:00
Tomaz Canabrava
a9ba98942c Correctly change the dive_site name
Correctly change and update the dive_site, updating the name on the
combobox or other attached views.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:31:16 -07:00
Tomaz Canabrava
b8092c07a4 Create a new DiveSite when user clicks on add
Also reorganized a bit of the code, and renamed a few misleading methods.

[Dirk Hohndel: remove some C++11 code]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 13:24:37 -07:00
Tomaz Canabrava
6d9206150a Organize the dive_sites alphabetically
run std::sort on the dive_site list inside of the model.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31 16:02:35 -07:00
Tomaz Canabrava
8b96179d59 Fix crash when cancelling divesite edit with empty divesite
Only happens if you dont't have any divesites in your list, but either
way, it could happen.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31 16:00:51 -07:00
Tomaz Canabrava
ac6a7ab24e Update DiveLocationModel when thread finishes
This patch updates the DiveLocationModel when the
GeoLoockupInformationThread finishes, and also selects
the correct index for the displayed dive.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29 20:59:11 -07:00
Tomaz Canabrava
266e309962 LocationInformationModel moved to qt-models
I forgot about this one, and we are going to use it
in the mobile version too.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29 20:58:48 -07:00
Dirk Hohndel
17b7bdfd2e Fix crash when rejecting dive site changes
Emitting the stopFilterDiveSite signal caused us to clean up the UI which
reset currentDs to NULL if this was a new dive site...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-27 07:53:14 -07:00
Dirk Hohndel
d6e32b02f6 Start editing new site regardless what the user does first
It doesn't matter if we first enter coordinates, name, description or
notes. If there is no currentDs we need to handle that gracefully.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-27 06:36:19 -07:00
Dirk Hohndel
bfee0a13f0 Dive site management: make sure currentDs is valid
When double clicking on the globe on a dive with no dive site we did
almost the right thing - except that we didn't create a dive site.

Not 100% sure this is the right place to do this, but it seems to work and
prevents the crash.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-27 06:31:34 -07:00
Tomaz Canabrava
ffffccee93 Filter out the dives that are not at dive_site.
Untested code to filter out dives that are not at the active dive_site.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-26 21:48:45 -07:00
Tomaz Canabrava
785051c9dd Only repopulate model when needed.
The old way we set the location and *then* updated the model, so the very
first location that we tried to show was empty.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-26 21:47:55 -07:00
Tomaz Canabrava
b7ec57bdef Show the correct dive_site on the manage combobox
When triggering the dive_site management, we need to get the uuid that was
send to us and set it as the current dive_site on the combobox, the dialog
can fill all required info for us.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-26 21:47:21 -07:00
Tomaz Canabrava
609688b489 Do not create a new dive site when curr is invalid
We will however create a new dive site when the user clicks on the add
button - creating it here would led to strange behavior.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-26 21:47:02 -07:00
Tomaz Canabrava
562ee7410c Don't setLocationId when accept/reject changes
setLocationId will filter the dives, so ignore the visual changes when
accepting / rejecting, it will only be triggered again when we are showing
this dialog again.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-26 21:46:29 -07:00
Dirk Hohndel
e201f0f2b1 Location management: reflect changes to a location's name
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-22 12:29:47 -07:00
Dirk Hohndel
d4b5854f82 Location management: reflect changes to the coordinates on the map
This is a bit aggressive as it changes the globe with every single
character that's entered, but it's better than what we had before.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-22 12:29:39 -07:00
Dirk Hohndel
b342730ec9 Location management: actually parse the GPS coordinates
We still don't respond correctly to a user changing them (i.e., the map
doesn't change), but at least once they change the dive to a different
dive and back to this one things get done correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-22 11:56:03 -07:00
Dirk Hohndel
c11bbe4f38 Fix easily reproduced crash
Open dive file. Click Location-manage. Pick a site. Click close. Click
Location-manage again. BOOM.
This seems to make sense, but since not a lot of the code is hooked up
yet, I'm not sure this is what we want in the end. But for now it prevents
an easily reproduced crash.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-17 14:05:24 -07:00
Tomaz Canabrava
10a0a252c8 Update the dive location when showing the dialog
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-17 13:54:08 -07:00
Tomaz Canabrava
0c33d585ea Implement the row count for location information
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-17 13:52:23 -07:00
Tomaz Canabrava
3235dd842e Implement the data method for location information
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-17 13:52:23 -07:00
Tomaz Canabrava
8115855428 Start the model for location information.
And implement the reset method.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-17 13:52:19 -07:00
Tomaz Canabrava
5eb572b9c6 Move Locationinformation to its own file.
The SimpleWidgets file was getting too big, and location information will
also need a new model - a good way to do not mix everything is to put
things in a new file.

[Dirk Hohndel: added missing include of stdint.h]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-17 13:51:13 -07:00