Commit graph

60 commits

Author SHA1 Message Date
Linus Torvalds
a7e1e7fee1 Pass the whole 'device_data_t' to the uemis downloader
Not only does it make it look more like the libdivecomputer downloaders,
but the uemis downloader needs it in order to support all the flags we
have.  Notably "download into private trip".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 07:34:46 -04:00
Linus Torvalds
5b14ed16ac Add "download into private trip" dialog checkmark
This adds a checkbox for the divecomputer download dialog that allows you
to tell the download to put the newly downloaded dives into a trip of
their own. That in turn will disable the dive merging with any existing
dives, which means that you will not mix up your newly downloaded dives
with any old dives.

That, in turn, is very convenient of you know that some of the dives were
done by other divers (or from testing that happened during servicing etc),
or the dive dates etc were wrong because the dive computer date had reset
due to battery changes etc.

Once you have all the dives in a private trip of their own, you can then
fix them up (delete dives you don't want to merge etc), and then after all
the data is ok you might want to merge the cleaned-up results with
previous trips etc, and then manually ask subsurface to merge the dives or
whatever.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-14 22:40:14 -06:00
Dirk Hohndel
95dbfc22ac Try to avoid inconsistent selection state after divecomputer download
I cannot reproduce the problem, but adding one more call to
unselectDives() should ensure that all dives are marked as not selected
before selecting the last dive that was downloaded.

See #620

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-14 21:44:57 -07:00
Anton Lundin
d14a531510 Rework slot to quiet down Qt5 warning
Qt5 got confused about this slot. This does the same as previously but
gets Qt5 happy.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 06:25:00 -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
Dirk Hohndel
eaa4e5948a Make the code easier to read
This uses the new helper function from commit fc4f133f19d0 ("Add new
helper function that looks up the index of a dive by its uniq ID") to make
the logic implemented in commit 122593a63a46 ("Fix selection after
downloading dives from the dive computer") much saner to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19 20:12:59 +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
Dirk Hohndel
c4899aa8f1 Download from dive computer: Fix the broken selection of devices
The old code was completely bogus - it's confused about what the variable
'i' is counting.

This also let's us select the Uemis mount point by default if that's the
only valid "device" that we found.

Compile tested on Windows, untested on Mac.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19 20:12:58 +09:00
Dirk Hohndel
047032ee46 Divecomputer download: try to offer only those devices that make sense
If the user selects a Uemis divecomputer, don't show serial devices.
If the user selects a serial divecomputer, don't show the Uemis
filesystem.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19 20:12:55 +09:00
Tomaz Canabrava
c86d055db7 Do not check for null before free.
C specs says that we can safelly free a NULL pointer, so there's no reason
to check if it's null before freeing it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13 09:26:50 +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
Dirk Hohndel
6763b93619 Remove spurious debug printout
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:58 -07:00
Dirk Hohndel
0ce59e5205 Even if there is progress text, still set the progress bar percentage
I don't understand why we wouldn't set the percentage if we displayed text
there as well. This looks much better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 12:17:24 -07:00
Dirk Hohndel
155eac11d2 Ctrl-W and -Q support for GPS, divelogs.de, divecomputer and CVS import
Getting closer to consistent behavior.

See #489

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-25 10:47:44 -07:00
Tomaz Canabrava
6fe692bde6 Fix 'cancelling divecomputer download'
When a download is canceled, discard the partially downloaded dives.

Fixes #341

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-25 07:19:18 -07: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
Danilo Cesar Lemes de Paula
6801c68c2d reseting progress_bar_text for new downloads
if the user tries to redownload something from its dive computer
the interface will be stuck since progress_bar_text won't be empty in
the second run.

Even if I don't really like this idea of that value being changed by
downloadfromdivecomputer.cpp and libdivecomputer.c, that value needs to
be reset by someone.

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-26 09:00:19 -08:00
Danilo Cesar Lemes de Paula
ed12902746 disable buttons while downloading
Simple patch to enable/disable extra buttons while downloading.
The UI should be blocked during the download.

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-26 09:00:19 -08:00
Dirk Hohndel
48c4c21b9f Implement the '...' search button for Uemis dive computers
Right now the search button isn't connected for any device (clearly an
oversight). At least for the Uemis I think I have a sane implementation of
what that should do.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-18 17:20:35 -08:00
Dirk Hohndel
31aa93857a Initialize device_data_t data
If the user never clicks on the log and dump checkboxes (and that's what
we expect to be the case by default), then the log / dump flags (and
filenames) were never initialized.

I am reasonably certain this will close the following three bugs, that all
show the same symptom: they behave as if libdivecomputer dump was set,
even if it wasn't.

Fixes: #426
Fixes: #431
Fixes: #435

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 06:31:50 -08:00
Boris Barbulovski
c86822c2f4 Replace mainWindow() with MainWindow::instance()
C++ style of accessing single instance class object.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 11:42:59 -08:00
Dirk Hohndel
4f522d79d8 Don't shadow object members like this
If you need to use this->error to distinguish the local variable from the
object membe that should be a hint that maybe you didn't pick the best
name for the local variable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 05:51:25 -08:00
Boris Barbulovski
18207c9189 downloadfromdivecomputer.cpp improvements
* Add missing variable members to the initializer lists.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:07 -08:00
Boris Barbulovski
449c6fc6f2 DownloadFromDCWidget class cleanup
Remove static DownloadFromDCWidget::instance() method

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 08:17:08 -08:00
Dirk Hohndel
303badd5ce Detect errors while downloading from libdivecomputer
Show them in the progress bar and offer to retry.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-27 12:47:40 -08:00
Dirk Hohndel
a27f67c026 Whitespace and coding style updates
Another futile attempt to cleanup the code and make coding style and
whitespace consistent. I tried to add a file that describes the key points
of our coding style. I have no illusions that this will help the least
bit...

This commit should ONLY change whitespace

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 11:50:56 +07:00
Anton Lundin
7e9582631d Convert to TRUE/FALSE to stdbools true/false
I had problems with this one on Qt5.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15 15:52:31 +07:00
Dirk Hohndel
3ce5520b9c Sort the list of dive computer vendors in the download dialog
This makes so much more sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-14 21:05:41 +07:00
Lubomir I. Ivanov
a32462c26b DownloadFromDCWidget: prevent possible leaks for log/dump files
If the 'logfile_name' and 'dumpfile_name' were NULL we can simply
strdup() them with a new value, but if there was a previous value
we need to free() first.

C99 6.7.8 allows us to keep said variables without the
explicit NULL initialiazation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 05:53:26 +08:00
Dirk Hohndel
a35a28ab38 Fix warning about initialization ordering
I cannot tell what the potential impact of this might be, but the fix is
trivial.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-27 11:07:59 -08:00
Benjamin
31854f50a4 Disable DC device node if it is not needed
This patch disables/enables the DC device node based on what type of
transport the selected DC uses. The only time the device node field is
used is if the selected DC uses a serial transport type. IrDA and USB type
transports do not use the device node.

Signed-off-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-27 11:04:35 -08:00
Dirk Hohndel
5fca06c9e6 Display warning that dives won't be downloaded when enabling libdc dump
The warning is only shown once per session.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-26 09:18:57 -08:00
Dirk Hohndel
d42cc5a40c Enable libdivecomputer log or dump from the UI
Pick filenames for these functions as they are selected.
Use the windows-safe fopen function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 16:26:00 -08:00
Dirk Hohndel
0e3a24c3c0 Reset libdivecomuter import canceled state
Once the process got cancelled once we never reset the flag.

Fixes #82

Initial-fix-by: Jef Driesen
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-10 08:09:42 +01:00
Dirk Hohndel
50a1ed8d6e When the user cancels a download, reject already downloaded dives
This seems like the more logical behavior, anyway. Cancel means you didn't
want the result...

Fixes #341

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08 06:33:46 +01:00
Thiago Macieira
b22f1da59e Fix all leak-at-exit from singletons in Subsurface
Subsurface creates a lot of singleton instances on demand, but nothing
ever deleted them. Since they are singletons, these memory allocations
are technically not leaks. However, they clutter the output in valgrind
and other memory analysers, hiding the real issues.

The solution is to delete these items at exit. For the models and for
gettextFromC, the solution is to use a QScopedPointer, which will delete
its payload when it gets destroyed. For the dialogs and other widgets,
we can't do that: they need to be deleted before QApplication exits, so
we just set the parent in all of them to the main window.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 09:28:42 -08:00
Dirk Hohndel
995192c5fb Work around QMessageBox not showing its title on Mac
This is a bit hacky and simply adds the title to the message text when
compiling on a Mac, but hopefully this will be enough.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-21 04:23:10 -08:00
Dirk Hohndel
1646517d28 After done with the DC download dialog, ensure it's in its original state
So in case the OK button was relabeled to 'Retry', relabel it back to OK.
Also, 'Retry' should be capitalized.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09 15:58:57 +09:00
Dirk Hohndel
252caeea1c Fix stupid editing error
Don't do "obvious cleanups" at 4 in the morning when you can't sleep because
of emotionally draining issues outside of your control... and if you do,
at least compile test them.

This was introduced by me in commit 2f9f46cb0253 ("Random white space
cleanup").

Sorry.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 10:25:53 -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
Thiago Macieira
8e81d3f100 Make the classes generated by uic be real members of our classes
This means we don't have to new/delete them, which is a waste of
overhead.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 12:13:48 -07:00
Thiago Macieira
f0f76056ac Include the ui_*.h headers in the main headers.
This means we can also remove the forward declarations.

This is the first step in removing the memory allocation for the ui
sub-classes. Without the second step, this commit is just making the
compilation time increase for no good reason :-)

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 12:13:15 -07:00
Danilo Cesar Lemes de Paula
608209fff2 move process_dives to the mainthread
Avoids a race condition.

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
2013-09-17 18:46:02 -03:00
Danilo Cesar Lemes de Paula
a8d33f80b0 implement device probe in C
It's an attempt to build auto-completion for the dive-computers
based on unpublished code inside libdivecomputer[1]

[1] -
http://git.libdivecomputer.org/?p=libdivecomputer.git;a=commitdiff;h=d44053a99435fb9fc1f408fb3f1629a54c938afc

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
2013-09-16 22:40:47 -03:00
Danilo Cesar Lemes de Paula
3f8e183008 improve DownloadDialog's error handling
shows an error message when libdivecomputer returns
an error.

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
2013-09-10 14:45:25 -03:00
Danilo Cesar Lemes de Paula
59da382613 improve DownloadDialog UI control
* Removes the InterfaceThread
  which is basically an unecessary proxy between the MainThread and
  the DownloadThread.

* Use a state machine to control the DownloadWidget UI logic.

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
2013-09-10 14:45:25 -03:00
Danilo Cesar Lemes de Paula
ab649e21ba fix DownloadDialog behavior
The DownloadDialog behavior was broken in a way it allows the user
to make changes on the dialog while the download is happening.

Also, clicking on "Cancel" breaks/hangs the UI sometimes, as libdivingcomputer
doesn't always cancels the download right away. That's a bug that
still needs to be fixed.

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
2013-08-29 19:20:34 -03:00
Lubomir I. Ivanov
fb4dcbc685 A couple of dialog modality considerations
While most dialogs can be open and the main application window
can still be accessed, certain should possibly be modal
in these terms.

This patch proposes the download from webservice and DC dialogs
to lock the main application window until they are closed, with
the consideration of preventing eventual unexpected behavior
in the divelist if both dialogs are active at the same time.

To solve that QtDialog::exec() is used instead of
QtWidget::show().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-28 20:24:14 +08:00
Lubomir I. Ivanov
880b8394d2 Close child windows and dialogs with main window
Most child windows should be closed with the main application
window otherwise if left open and if making specific
modifictions could potentially cause a SIGSEGV.

To solve that we mark all custom windows/dialogs with
the Qt::WA_QuitOnClose attribute on instance creation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-28 20:23:59 +08:00