Commit graph

94 commits

Author SHA1 Message Date
Dirk Hohndel
33f7c6bb28 Clear selected trips after restoring selection
The rememberSelection() / restoreSelection() functions ONLY handle
selected dives, not selected trips. This is a bit of a misfeature, but
because of that we need to make sure we clear our notion of selected trips
when we use restoreSelection()

Fixes #285

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 06:05:43 -08:00
Robert Helling
4966336e1d Shift times of selected dives
This patch adds the possibility to shift the times of all selected dives
by a fixed amount to correct for time zone problems or mis-set dive
computer clocks.

Select the dives and right click in the dive list.

[Dirk Hohndel: added .ui file to FORMS and fixed some whitespace damage]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 10:03:45 -08:00
Dirk Hohndel
a2d6bd5c1d Add "add dive(s) to trip above" feature
This honors the sort order of the dive list when figuring which trip is
"above". It works both on a single dive or all selected dives.

This also fixes a couple other cases where the dive list selection and
trip display could get messed up.

Fixes #287

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-17 15:36:57 -08:00
Dirk Hohndel
7a6ff7a53c Fix a couple of problems with dive merging
- Dive list no longer has messed up trip entries
- Dive list is now correctly marked as modified after trips are merged
- When data file is closed, the list of selected trips is cleared which
  avoids a potential crash when loading a new data file

Fixes #286

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-17 14:41:12 -08:00
Tomaz Canabrava
612c5713b4 Fix crash when entering a dive via dive-add on a empty table.
We were selecting garbage, not anymore.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16 20:33:21 -08:00
Linus Torvalds
7e9a7b6223 Fix dive merging
This limits merging dives to dives that have at most half an hour of
surface time between them. That "half hour" is kind of a random thing
to pick, but it's not horribly horribly wrong.

It also changes the semantics of "merge selected dives" to something
that actually works pretty well: you can select a whole range of
dives, and it will merge only the ones that makes sense to merge. I
tested it, and it's reasonable. I could select all my dives from one
dive trip, and then do "Merge selected dives", and it did the right
thing (Dirk: I selected the florida trip, and it merged the aborted
"missed the trench" dive with the _actual_ "trench" dive).

I'm _slightly_ hesitant about this in the sense that maybe some crazy
person actually would want to merge dives with more than half an hour
of surface time between them, but it really doesn't seem to make much
sense.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16 20:31:35 -08:00
Tomaz Canabrava
314cf4c628 Removed duplicated method.
This patch removes a duplicated method: get_divenr and
get_index_for_dive. The two are exactly the same  ( if my
c is not broken, but I may be broken since I'm working like
crazy for almost 30h nonstop. ), so please take a good look
before applying this one.

[Dirk Hohndel: Tomaz took the slightly broken of the two implementations,
               so I switched that out for the correct one]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16 20:27:54 -08:00
Tomaz Canabrava
4f1cae7a2f Expand the trip of the newly selected dive.
I hit this bug on deleting dives and the newly selected
one got inside a trip, that wasn't expanded. anyway, easy one.
:)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16 20:23:33 -08:00
Tomaz Canabrava
8476ea5ea8 Selects the dive before the deleted ones.
This patch makes a selection just after the dives that got deleted,
or nothing if the list is empty.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16 20:23:22 -08:00
Tomaz Canabrava
73cd8f3e56 Do not break Dive Headings on trip mode when a delete dive is done.
When the dive is deleted, we force a recreation of the dive list,
this is done because we were broken by design on the first transition
to the Qt infrastructure - one thing to change for 4.1, but no time
for 4.0.

We forgot to ask the headers to 'please, span more than one row,
please' when we recreate the model. easy =)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16 20:19:55 -08:00
Tomaz Canabrava
4f9526ef81 Fix wrong handling of Dive Table, and revert some wrong changes.
This patch just reverts some wrong changes that I'v done on a
past commit ( sorry ) and correctly handles the selectDive,
by using a IDX instead of the dive pointer, as dirk told me
it's extremely error-prone since the pointer can change.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16 20:19:55 -08:00
Tomaz Canabrava
8827ea6f5d This moves the removal code to the model.
It's very important when programming via Model/View, in gtk or qt,
to not mess with the model data outside of the model. We were
deleting stuff that the model controlled outside of the model, so
it thought that there was still data there. This fixes the deletion
part, but there are also lots of other parts that I'll tackle in
the next commits.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 15:13:53 -08:00
Tomaz Canabrava
bae41ddafb Maintain opened the trips of the selected dive.
In various occasions the branches of selected dives
got collapsed because I'm dummy boy and didn't programmed
the logic correctly.

This one correctly works for the few cases that I'v tried,
I'm verifying if the current selected index is a trip or
a dive, and asking to expand it.

The expanded state is lost because we delete and recreate
the model ( and we do that because we can switch between
tree and table model ).

Now I think we correctly track the cornercases.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 11:14:46 -08:00
Tomaz Canabrava
1e63579cc6 Fix the sentense 'collapse' to 'collapse others' and scroll to it.
This patch changes the string 'collapse' to a more meaningfull
'collapse others', it also scrolls the view to the first selec
ted index, since after collapsing the others, things could be
in the wrong position.,

Fixes #233

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 11:13:31 -08:00
Dirk Hohndel
6bf12bde03 Make more context menu functions act on all selected dives
Remove from trip and delete both should deal with all selected dives.

Fixes #247

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 14:21:20 +09:00
Thiago Macieira
711f2ddf8c Avoid std::string: QByteArray is enough and already compiled in
No need to add more code to Subsurface by bringing in std::string too.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 13:19:58 +09:00
Dirk Hohndel
5961579cda Manually add trips from dive list context menu
We had all the logic, we were just lacking the UI.

Fixes #243

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 11:32:19 +09:00
Dirk Hohndel
2c57568d56 Fix potential crash when merging trips
strdup doesn't like to be passed a NULL pointer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 11:31:35 +09:00
Tomaz Canabrava
77a1ef9ebe Expand the trip of the first selected dive.
I probably broke this a while ago, as I was not using the big
dirk dive file to test ( just using some random files over the
test folder. )

Now it's working as it should.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 21:26:33 +09:00
Tomaz Canabrava
37e7984e15 Fix Last Column adding a horizontal Scroll on the Dive List.
Fixes the last column adding a horizontal scroll on the dive list,
since we have the hability to show / hide columns, I had to create
a helper method to discover what is the last column and set the
size of it very small so no scroll is created.

Also, I'v set the setStrechLastSection to true. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 21:24:48 +09:00
Dirk Hohndel
dfd17c7a7f Maintain the selection when aborting "dive add"
We remember what was selected before and restore it. Maybe there's a more
"Qt way" of doing this, but my implementation appears to work :-)

Also remove unconditional debug output that snuck into an earlier commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 17:58:14 +09:00
Miika Turkia
a93b6011f1 Add file naming dialog for save as
When right clicking a dive on the divelist a dialog for selecting a dive
was opened. However, Save As requires a getSaveFileName dialog so that
user can give a new file name as well as selecting an old file to
overwrite.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 07:17:26 +09:00
Dirk Hohndel
25e432e1d1 When selection gets confused, don't try to select non-existing dive
While the argument could be made that this is just a symptom of Subsurface
getting very confused about the selection (which it still gets at times -
most likely we are calling select_dive() instead of selectDive()  (or the
corresponding deselect functions) in places where we shouldn't), but
either way, we should not crash.

Fixes #220

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 13:59:02 +09:00
Dirk Hohndel
f41651439c Mark divelist changed when deleting a dive
Fixes #232

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11 05:57:43 +09:00
Tomaz Canabrava
d3fe3494fe Save / Restore the Tree after organizing by other columns.
This patch saves and restores the state of the TreeView after the user
clicks on another columns that will make the tree disappear. All of the
branche states are saved, this way the expanded nodes will be restored
when the user gets back to tree mode.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09 15:33:55 +09:00
Tomaz Canabrava
38287a1c1e Save the status of the tree before trying to reset the display.
This is a try: when the user changes the orientation on the columns
by clicking on the title of them and organizing by something that's
not the number, we lost track of the opened branches. this commit
doesn't fix that, but it fixes a possible similar issue.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-11-09 15:33:34 +09:00
Tomaz Canabrava
7dbf76384f Moved the code that handles DiveList column sizes to its correct file.
I got a bit lost trying to find the code that handled DiveList columns
today, so I thought it was better to move it to its file, after all we
do have a divelistview.h :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09 15:32:37 +09:00
Dirk Hohndel
e90f5c28df Fix dive merging
When merging dives, the indices of the following dives change - so we need
to adjust the variable used in the for_each loop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-05 15:44:16 +09:00
Dirk Hohndel
01d515b5d8 Remember the column we are sorting by
A call to DiveListView::reload always reset our sortcolumn to be 0.
Instead we are tracking the correct sort column and sort direction.

This also removes an obsolete private member that was unused.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-05 14:23:37 +09:00
Miika Turkia
3e48511318 Export dives in UDDF format
Implement exporting in UDDF format as was done in Gtk version. File menu
exports all the dives, right click on selection exports the selected
ones.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-20 15:26:02 +02:00
Dirk Hohndel
75a004d44a Some adjustments to "save as"
The popup menu entries should be all lowercase.
Also we should handle this the same as regular save and open when it comes
to remembering the last path.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17 20:26:38 -07:00
Tomaz Canabrava
ed28628449 Added 'Save As' option on the dive list menu.
This adds the 'Save As' option on the dive list,
very straigth forward, just simple and beauty.
tested and working.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17 20:19:50 -07:00
Dirk Hohndel
6ccb541f1d Random white space cleanup
Because I can.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 04:37:31 -07:00
Tomaz Canabrava
1b9a4f2bf8 Good deal of whitespace fixes and code cleanup.
I just went thru all of subsurface code removing
some whitespaces issues and trying to make the
code prettyer, I also removed a few QString issues.d

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-11 10:21:04 -03:00
Tomaz Canabrava
3c97cc5b6a Fix showing all columns by default on first run.
Some columns are a nice addition, but not a must have,
and thus are hidden-by-default, uncluttering the user interface.

This was discussed with a few designers before writting the code,
and also discussed with dirk on irc.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-04 14:28:49 -03:00
Patrick Valsecchi
f02b5e5d90 Fix weight adding in the Qt UI & fix the header height for tables
Fixes #203

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-01 09:49:41 -07:00
Dirk Hohndel
446ab45858 Only offer to merge dives if they are consecutive in the divelist
You cannot merge dives if there is another, unselected dive "between"
them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-24 03:42:40 -07:00
Dirk Hohndel
2d40172d78 Much easier way to detect if more than one dive is selected
Instead of getting data from Qt just use our internal notion of the number
of selected dive to decide if more than one dive is selected (and
therefore if we need to show the 'merge dives' option in the context
menu).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-24 03:02:02 -07:00
Dirk Hohndel
be418458db Add "merge selected dives" to dive list popup menu
This is fairly straight forward. What I dislike is the check for the magic
number of "14 indeces". I'm sure there's a better way to tell if more than
one dive is selected...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-23 21:57:28 -07:00
Dirk Hohndel
dba16202c4 Correctly handle empty dive list after delete
Things need to be cleared out and disabled. But fixing this bug leaves
another issue - while the newly selected dive after a delete acts as if it
was selected, it doesn't show up as selected in the dive list.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-22 22:24:28 -07:00
Tomaz Canabrava
cbbc7d99ea Fix for double-rendering, double selection and other annoyances.
This patch fixes a thing that I run into when trying to implement
the multi-edition system. Whenever a dive was selected, via mouse
or keyboard, it had two stages: first, it would select the previous
and the current ( and thus, render the profile of the current) and
then whould release the previous and select the current again ( and
thus, rerendering the profile again, plus a few other things. )
With the multi-edition system this caused a more severe bug, since
the edition of the dives is directly applied as soon as the text fields
changes, as soon as we selected any dive on the list, the 'before' dive
would be modified by the 'current'. This patch fixes this - but since it's
just a 'code removal' patch, this can led to bad things in the future,
I tested it quite a bit, but didn't found anything, no regression.
*fingers crossed.*

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-16 12:31:09 -03:00
Linus Torvalds
5ce5b05521 Qt: Implement trip merging logic
So during my Maui trip, I had a short hiatus in diving, causing
subsurface to start a new trip for the last day of diving.  I could have
just started the old gtk branch to fix it up, but decided that I might
as well try to implement the "merge trip" logic in the Qt branch instead.

This is the end result of that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 23:00:12 -07:00
Tomaz Canabrava
ae68ae38bb Changed a lot of code to reduce boilerplate on models in the future.
So, I changed a lot of code to reduce boilerplate on models in the
future. Currently we do not have a lot of models, but this can increase
quite rapdly. There's a second TreeModel in the works, the Yearly
Statistics, this patch will save around 250 LOC for this new model,
and more and more models will give us a greater saving.

Iwll do that for the table models in the future too - I did the tree
models now because they are the most complex case and I didn't wanted
to create a second tree model without this.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-17 18:59:50 -03:00
Dirk Hohndel
a960cd2d45 Show & edit trip location and notes when exactly one trip is selected
While we still show the selected_dive in the profile and use it for Dive
Info and Equipment, in the Dive Notes tab we now show the trip location
and trip notes (and none of the other fields), if the user directly
selects a whole trip by clicking on the trip header.

This clever reuse of the widget now allows trip location and notes to be
edited in place.

As a side note: the Gtk version has long allowed the user to edit the
trip location and trip notes, but nowhere did it ever SHOW the trip
notes... so this is more than just feature parity...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-14 09:20:20 -07:00
Dirk Hohndel
8669de63e1 Don't offer "delete dive" context menu for trip
If we are not on a dive we shouldn't try to delete it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-14 07:13:06 -07:00
Dirk Hohndel
d8c5f366c8 First deselect, then select
For reasons I still don't understand, sometimes (but not always) when
clicking on a trip header we appear to get a select notification for the
trip and at the same time deselect notifications for every dive in the
trip. This seems wrong but I can't seem to figure out why it happens -
and of course it causes us to have a mixed up interpretation of what is
selected in our internal selection tracking.

Simply acting on the new selection after the newly deselected items are
handled appears to fix the issue, but I do worry about this change.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-14 06:17:38 -07:00
Tomaz Canabrava
ab0213f28e Implements the DiveList to behave like Linus Explained.
Implements the divelist to behave like linus explained,
essentially, it filters the layoutChanges of the model,
greps for trips, and for each trip that it finds, it set
the 'firstColumnSpanned' property, to make the column
to have the size of the whole table. e

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-12 14:14:25 -03:00
Helio Chissini de Castro
4b0c053e48 Ticket 127 - Repopulate context menu on preferences change
Ticket 127 mention that context menu is fixed on imperial mode, which is
partial true. Context menu only not have the changes on header model updated
when preferences are chenges during execution. Hard to note because if
program is closed and opened again, the context is initialized properly.
Since actions aren't bound to the header model, we need iteract of current
items and change the title.

Signed-off-by: Helio Chissini de Castro <helio@kde.org>
2013-06-09 20:09:39 -03:00
Thiago Macieira
1ee38b4e5e Use the official QItemSelectionModel::SelectionFlags
It's a typedef to the QFlags<QItemSelectionModel::SelectionFlag>.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-08 07:12:08 -07:00
Linus Torvalds
00d5ab1bdc Make a map ctrl-click toggle the selection state
This way the map selection works like normal selections do.  Except we
don't do "ranged" selections (shift-click) for fairly obvious reasons.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-07 21:39:52 -07:00