Commit graph

36 commits

Author SHA1 Message Date
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
Dirk Hohndel
48ba01b807 Enable downloads from the UEMIS Zurich
This behaves somewhat differently from the Gtk version - still needs
more investigation. But at least now it's hooked in.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-24 15:14:07 -07:00
Linus Torvalds
6fd1e32452 Properly initialize device_data_t when downloading
The old gtk branch started out with device_data_t explicitly cleared,
but the Qt version never did that.  And we actually depend on the
deviceid in particular being initialized to zero (and then we fill in
the details in the divecomputer download callbacks)

Not properly initializing it meant that we ended up with random
deviceid's that got added to the divecomputer device lists, and then
saved to the XML file without actually matching the data in the dive
computers in the actual *dives*.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-16 21:17:35 -07:00
Dirk Hohndel
2a4d981d09 Fixed running the Download dialog multiple times
We never reset the 'downloading' variable.

Solved-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-30 18:21:08 +09:00
Dirk Hohndel
f32e86eb32 Hook up the Download dialog
The download already worked, but we didn't display the new dives. This
introduces a new slot for MainWindow that updates what is displayed in
Subsurface after files were imported.

With this change we can successfully download ONCE - but when trying to
download a second dive the dialog doesn't appear to get refreshed the
right way - the OK button doesn't appear to work anymore (Cancel however
does).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-30 18:02:29 +09:00
Dirk Hohndel
c917a99eb2 Implement default dive computer and device
The data is saved in the settings and the correct dive computer (vendor
and product) and device are picked when the download dialog is openend.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 23:24:33 -07:00
Dirk Hohndel
115e5e5fbc The never ending, futile fight for whitespace consistency
I just need to write a tool that does this...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 21:31:45 -07:00
Dirk Hohndel
246fbd0333 Implement rudimentary divecomputer download
Small changes to the names of elements the divecomputer download UI and
very simplistic first stab at populating the device_data_t structure.

This is lacking lots of things
- it should remember the last vendor / product used
- it should figure out which device (mount point) to offer
- it needs proper error handling

But it's a step in the right direction.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-20 21:55:56 -07:00
Tomaz Canabrava
f4acbb02e4 Populate the Vendor && Dive computer information.
This uses the QStringListModel to populate the items
of the QComboBoxes. I used a QHash to hold every Computer
of a particular Vendor. so, products[vendor] gives me
the full list of products from each vendor.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-20 17:58:06 -03:00
Tomaz Canabrava
a542b25bde Added code to cancel the thread.
I think it's self explanatory - When user clicks on
'Cancel', the interface will wait for the trhead to quit
then will close itself.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-20 17:02:17 -03:00
Tomaz Canabrava
c7a5d0490f Skeleton code for a non-blocking UI thread for downloading dives from the DC
This is the skeleton code for a non-blocking ui-thread
It already creates the first-thread ( 'do not block the ui' )
and the second thread ('download from the dive computer')
We can in the future merge both in the same place - I didn't
want to do that now because the download function is written
in the libdivecomputer.c code, and I cant just transform that
to a QThread and use signals, so I used two threads for that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-20 16:43:33 -03:00