Commit graph

174 commits

Author SHA1 Message Date
Dirk Hohndel
0d1da0563b Random whitespace update
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-17 15:39:49 -07:00
Tomaz Canabrava
f1e7c12e8a Correctly filter dives. (trips are always shown)
This patch correctly filter dives based on tags, but it will
also keep showing all the empty trips.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-17 15:28:37 -07:00
Dirk Hohndel
dba3aa12a3 Small whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-26 21:30:54 -07:00
Dirk Hohndel
75650bd65f DiveList: don't save default column width
This is an elegant way around our problem with people who have the
horrible old "100px" column width in their settings. The first time they
run Subsurface after this fix things won't get better, but the offending
keys will be deleted at exit. And the second time they run, they'll get
the much more sensible new default widths.

Thanks to Thiago for this idea.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-26 14:17:15 -07:00
Dirk Hohndel
438fe5dbde Divelist: Use more sensible default column widths
Having 100px wide columns was simplistic and stupid. It was never intended
to stay that way.

See #712

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-22 15:03:13 -07:00
Dirk Hohndel
4a04fc2a1b Fix selection logic when manually adding a dive
This was an interesting bug. When adding a dive that would end up in the
middle of the dive list, the newest dive in the dive list would end up
marked in the dive structure as selected - even though it wasn't
visualized as selected by Qt. Bad things happen if the user then made
changes to that dive without selecting something else first, for example
by either editing the dive or doing things to it like removing it from or
adding it to a trip. The same operation would also be applied to the
newest dive in the dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-21 17:58:15 -07:00
Dirk Hohndel
512c42e38a Dive list: seriously simplify the "add to trip" code
The existing code seemed way complicated, made way too many assumptions
and apparently was broken in certain cases.

This code seems very simple, looks correct and should fail gracefully
(i.e. simply do nothing) if things get confused.

Fixes #706

(I hope)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-21 14:20:03 -05:00
Anton Lundin
619c1b3ec9 Rename the model column from NITROX to GAS
The column isn't just about NITROX, there might be air and trimix in
there too.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-11 08:41:36 -07:00
Tomaz Canabrava
7295c8c6ec Do not recreate all the dive just because a picture was added.
If we add a picture to the dive, this will not change anything
else, so there's no need to recalculate the profile_plot info.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-04 10:38:00 -07:00
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
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
402198871b divelistview capitalisation consitency
affects mainly capitalisation on the dive list context menu

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 07:05:59 -07:00
Dirk Hohndel
c7e8042fbd Picture handling: make sure pictures are shown after they were added
We need to first replot() to get displayed_dive updated, then call
refreshDisplay() so the picture model gets repopulated which triggers the
pictures to show up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-08 12:55:54 -07:00
Tomaz Canabrava
f6d133d742 Fix crash when trying to add a dive or plan when a filter is active.
The planner used the selected dive on the dive list, and
when there's a filtering in action it can be in a state where
there's no dive selected.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26 15:49:19 -07:00
Tomaz Canabrava
f53b5c4d3f Fix linked list corruption, move code to C.
The picture list is a single linked list where the pictures have a node to
their next element. When adding the same picture to two dives, things got
way way wrong and crashes were appearing.

This will replicate the information (filename, latitude and longitude) for
each dive that has the picture, BUT it still tries to save as much as
possible on the actual pixmap.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 16:39:06 -07:00
Tomaz Canabrava
d95d1735b5 Break picture handling code from C++ to C.
This commit breaks the loading of images that were done in the divelist
into smaller bits. A bit of code refactor was done in order to correct the
placement of a few methods.

ShiftTimesDialog::EpochFromExiv got moved to Exif::epoch dive_add_picture
is now used instead of add_event picture_load_exif_data got implemented
using the old listview code.  dive_set_geodata_from_picture got
implemented using the old listview code.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 23:59:29 -07:00
Tomaz Canabrava
1556b723a2 Do not replot for each picture added to dive.
Instead wait until all pictures have been set and plot that.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:44:12 -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
fa705a5bc9 Dive list: use helper function when restoring selection
Looping over the individual dives will be very slow if there are many of
them, as the profile will try to render each of them in succession.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 13:10:33 -07:00
Dirk Hohndel
2f8f632cf6 Minor cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 10:16:53 -07:00
Dirk Hohndel
d1366257f0 Dive list: make saving / restoring column widths actually work
It's a testament to how much I mess around with things that I hadn't
noticed that saving the column width doesn't actually work. Or actually,
saving them worked, loading them back failed as it was done too early and
the setColumnWidth() calls had no effect - and so the next time we quit
subsurface, the default width of 100 was written over all the saved
values.

This seems like an incredible hack but it has the advantage of actually
working. I look forward to someone with better insides into the inner
workings of Qt to properly fix this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-25 07:30:50 -07:00
Dirk Hohndel
c29109744e Dive list: don't reset column width when reloading
We set the column width in the dive list widget when we create that
widget, based on what is in the settings. And we save the current column
width back to the settings when we destroy that widget (so if Subsurface
is shut down correctly and Qt actually gets to run the destructor but not
when someone kills the program).

That means that if we recreate the dive list at any point while Subsurface
is running (and we do that a lot when you manipulate your dive list in any
way shape or form), any changes to the column widths are lost.
DiveListView::reload() explicitly calls setupUi() which reads the column
widths back from the settings - but changes made to the columns aren't
saved to the settings until we destroy the widget...

I see no reason why reload() should call setupUi(), so I'm removing that
call. Let's hope this doesn't break anything else.

Fixes #518

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-25 07:03:38 -07:00
Dirk Hohndel
a85023a661 Dive list: remember the current sort colum
Silly bug. We never actually remembered our current sort column when
changing the sort order.

See #518

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-25 06:19:05 -07:00
Tomaz Canabrava
81c84d02ed Speed up the multi dive selection
Dirk's code in commit a3d300ca91 ("Correctly implement multi dive
selection") had a major flaw - it kept redrawing the selected dives
one after another. Not what we need. So this fixes this up so that it
doesn't take more than a sec to select all the dives that are on the same
part of the click on the globe. I've achieved this by creating a boolean '
dontEmitDiveChanged and sending the signal only if this flag is false.

The reason that we can't simply remove the emit from the selectionChanged
is because the selectionChanged is what we have when we click on the
diveList, if we removed this from there, nothing will happen upon
selection.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 21:09:11 -07:00
Dirk Hohndel
a3d300ca91 Correctly implement multi dive selection
The old code had several issues. It broke the synchronization between
dive->select and Qt selected status and worse, it would partially unselect
previously selected dives when called.

This patch, however, causes the selection via the map to be glacially slow
because it forces a redraw of every single selected profile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 21:03:53 -07:00
Dirk Hohndel
e4b8cf89a1 Dive list: move trip merging logic into divelist.c
This also fixes a couple of issues with the existing code:
- removes a memory leak
- treats null and "" the same

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 14:03:36 -07:00
Dirk Hohndel
10e5675151 Dive list: work around odd problem with selections
According to the documentation clearSelection() should emit
selectionChanged() - but I can verify in the debugger that sometimes this
doesn't appear to happen - consequently our notion of what's selected gets
confused.

To work around this, after calling clearSelection() we simply manuall
deselect all dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 13:58:13 -07:00
Dirk Hohndel
dbb86374e0 Dive list: move trip selection / deselection logic to divelist.c
This is core logic, not UI code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 13:19:05 -07:00
Dirk Hohndel
032ea24191 Dive list: more consistent handling of "add to trip"
When multiple dives are selected, we need to be smarter about when to show
"add to trip immediately above" or "... below". This code is quite
readable, I think, and does the trick.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 10:28:11 -07:00
Dirk Hohndel
ba1c4fcec1 Add some helper functions
First step towards getting the "add to trip" logic in the divelist context
menu to be consistent and correct.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 08:27:42 -07:00
Dirk Hohndel
2a88a72f1a Remove export and save as from dive list context menu
The context menu is getting way too big and confusing. This is now much
more cleanly done from the File->Export dialog.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:52:16 -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
Miika Turkia
7dc642860d Implementing export dialog
As our menus are getting many export entries, it is better to create a
single export dialog where user is able to select the export type and
whether to export selected dives or all of them. This should also be
more intuitive than the current way when export from file menu export
all dives and right click menu on divelist exports only selected dives.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-21 03:31:43 +09:00
Anton Lundin
05d9cc409c Migrate code to for_each_dive and for_each_dc
[Dirk Hohndel: this overlapped with my commit 09e7c61fee ("Consistently
	       use for_each_dive (and use it correctly)") so I took the
	       pieces that I had missed]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 11:51:40 +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
b303f217a9 Dive list: add context menu function to renumber dive(s)
No attempt is made to ensure that what the user does is sane. So this can
result in duplicate numbers, non-consecutive numbers, non-monotonous
numbers, whatever floats the users boat.

You can renumber a single dive or all selected dives (with a starting
number given that is applied to the oldest selected dive and then for each
newer selected dive that number is incremented by one).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 06:11:32 +09:00
Dirk Hohndel
5e3f7ba22f Fix selection after downloading dives from the dive computer
If we successfully download dives, the old selection should be cleared and
the one of the newly downloaded dives should be selected. I decided to
pick the last dive downloaded, which for most dive computers (but for
example not for the Uemis SDA) will be the first or earliest of the dives.

That seems much more intuitive than keeping the previous selection around.

Of course this is harder than it should be because of the way we track
selections and because we need a consistent dive list model in order to
change the selection.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19 20:12:59 +09:00
Tomaz Canabrava
6ab05563b3 Move DiveList related methods/classes to own file.
The DiveList classes were a partial mess (and some of it is still in a
messy state). The classes that deal with it where done in 'qtHelpers.h',
the extern global variable in dive.h, a few methods here and there. This
concentrates most - but not all - functions in their own file. The reason
for that is to make the new developer faster when looking for things: if
it's a divecomputer related method, it should be in a single file, not
scattered around.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13 09:20:28 +09:00
Thiago Macieira
497d6e3e6c Fix crash on dereferencing dangling pointers
QList::first() returns a reference to an item, but that list was a
temporary. The list gets destroyed at the end of the statement (the
semi-colon), so we ended up keeping a reference to freed data (i.e., a
dangling pointer)

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 21:52:56 -07:00
Robert C. Helling
7bcb85dd54 Add images to all dive computers and refresh profile
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 08:16:16 -07:00
Linus Torvalds
4f20bb9fb2 When scrolling to dive, scroll to trip first
The behavior at startup is actually very annoying: we select the latest
dive, and expand the trip it is in, but since we use "scrollTo()" on
just the dive, and it's not initially visible, the startup will make the
first dive be at the top of the list view.

Which means that the actual _trip_ detail is not visible at all, since
it will have been scrolled off the list view entirely.

Fix this by first scrolling to the trip, and only then scrolling to the
actual dive (using the default "EnsureVisible" policy).  Obviously, if
it's a trip with lots of dives, scrolling to the dive may end up
scrolling away from the trip header again, but at least that never
happens at startup, and at that point you have to scroll away from the
trip just to show the dive.

Do this same dance when changing the dive selection (mainly noticeable
when picking dives on the globe view).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-28 12:47:15 -07:00
Miika Turkia
28f4e9b10e Add exporting selected dives into CSV file
This adds option to export selected dives into a CSV file to the right
click menu on dive list.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-26 17:24:12 -07:00
Miika Turkia
f6be4ccf22 Add GUI support for exporting in CSV format
This patch adds an item to File menu to export all dives in CSV format.
Naturally this includes also the code to perform the export.

Fixes #434

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-26 17:20:32 -07:00
Miika Turkia
85a3f10508 Use proper export text instead of save
When exporting UDDF logs the file name selection dialog should talk
about export, not save. This patch changes that text

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-26 17:16:58 -07:00
Tomaz Canabrava
f14c14c383 Mark a lot of TODO's where I think it should be moved to C code.
This marks a lot of todo's where I think there's core stuff being mangled
on the interface - we should remove this from the interface to make
testing and maintenability easier.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 08:33:51 -07:00
Anton Lundin
5cec965cb7 Make divelist header corrections Mac specific
The +10 pixels fix was introduced to fix some layout issue on Mac ways
back, but it breaks things on Android. This makes sure this only gets
applied when build for mac.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-02 12:44:49 -07:00
Anton Lundin
519f45416f Enable posibility to add dives to trip below
When I'm on a dive trip i usually download dives multiple times to start
logging them while i still remember them. When i have already created a
trip and downloads new dives they needs to be able to be added to the
already existing trip, without relying on autogroup.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20 09:40:28 -07: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
Dirk Hohndel
240e269f19 Code cleanup
We called the helper functions way too often.
Whitespace / coding style adjustments.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 20:34:09 -08:00