Commit graph

1200 commits

Author SHA1 Message Date
Tomaz Canabrava
1a933e7e19 Don't use QList if sizeof(item) > void*.
QList is optimized for storing pointer-sized items, thus
a QVector is the better choice for everything else.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:24:11 -08:00
Tomaz Canabrava
5e446fd258 removed unused files.
Thise files dates back from the beginning of the Qt port and
were never used anyway...

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:24:11 -08:00
Tomaz Canabrava
8da5a8649b Don't check if pointer is valid before deleting it.
deleting a null pointer is valid, so we just delete it
instead of checking if it exists.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:24:11 -08:00
Tomaz Canabrava
2874070870 Code cleanup. Don't use if ( true ) set (false).
Code cleanup, don't use if ( thing() ) set false,
but set !thing() instead.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:24:11 -08:00
Tomaz Canabrava
231fd2e6e0 Fix subsurface on dark themes.
This patch fixes my last annoyances with dark themes
on subsurface. It changes the background color of the
edited info tab to a darker yellow if the theme is
dark, and a light yellow if the theme is light.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:23:10 -08:00
Tomaz Canabrava
10519bcc50 silly whitespace fix.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:23:10 -08:00
Tomaz Canabrava
6925d13aa4 Rework foreach for a faster iteration.
The old code used a QString instead of a const QString&, wich
mean that each foreach step the string was copied.
added a break on the if-found-true to stop the foreach, since
we already found it.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:23:10 -08:00
Miika Turkia
e0bdf45539 Allow selecting all files on CSV import
This allows user to view any file on CSV import dialog, not only the
ones ending with .csv. Of course, the default still shows only the .csv
files and user needs to change the filter to view the rest.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:06:29 -08:00
Dirk Hohndel
9405895285 Improve GPS string handling
This adds support for two more GPS coordinate formats and also fixes a
couple of issues with the previous implementation.

We used to only support full degrees and decimal minutes. We now also
support fully decimal and degrees, minutes and decimal seconds.

The previous implementation would color the input field red if either it
couldn't parse the string, or if it was able to parse it but it was the
same as the previous location. That's misleading.

The previous implementation also changed all gps coordinates to the new
coordinates in a multi-dive edit - instead of just changing the ones that
are the same as the master dive.

Fixes #387

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-23 14:59:38 -08:00
Dirk Hohndel
5c3ed901b5 Remove pointless code
Why calculate the number of entries in the zip downloaded from Divelogs.De
if you don't do anything with that number?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:06 -08:00
Dirk Hohndel
0421a161b4 Silence a few warnings
None of these are actual bugs. But none of the fixes are harmful, either.
And much as I hate adding the 'default' clauses, I'd rather not have the
build output cluttered by invalid warnings.

The exception is the fix in divelistview.cpp - while I don't think it is
possible for this function to be called with no dive selected,
initializing pd to NULL is cheap insurance in case that does happen for
some weird reason.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:06 -08:00
Dirk Hohndel
4ab58d6b47 Use M_OR_FT macro instead of switch statement
This is easier to read and also avoids an incorrect gcc warning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:06 -08:00
Tomaz Canabrava
f0da41c937 Added Keyboard Navigation for the Star Widget
Keys up and down to increase / decrease stars
and also fixed focus policy for it.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Thiago Macieira
3e3fff262e Don't use an array where none are necessary
We don't need to keep the array of zip_source structs. We just need the
latest we created so we can add to the zip file.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Thiago Macieira
64f24234ab Move the variable initialisations closer to use and add blanks
Makes the code easier to read, IMHO.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Thiago Macieira
de47937dd1 Get more descriptive error messages when uploading to divelogs.de
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Thiago Macieira
d36e4555da Move the divelogs.de preparation function into the C++ class
This is so we can mark the error messages for translation.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Thiago Macieira
b654bcdd7a Generate the file name for the dive log upload in the caller
This is a cleaner approach, according to the discussion in the mailing
list. It is also better because we can use QTemporaryDir in Qt 5.
Finally, it avoids having to remember to free it at every point.s

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Thiago Macieira
8eb6dfdb02 Use QFile::{encode,decode}Name for file names
And make them use UTF-8 on Windows instead of the local 8 bit encoding.
This will also get us the proper NFD encoding on OS X.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Thiago Macieira
dbdf50d03c Fix compilation with libzip < 0.10
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Anton Lundin
a84826090a Planner: don't abort when saving a dive
The fix for dereferencing a null pointer from me was a bad fix that
broke the possibility of saving a planned dive as a dive.

This is a better fix to not dereference a null pointer and be able to
save the plan again.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Tomaz Canabrava
029522880f When saving / canceling edition, focus back to the Dive List
When saving / canceling the edition, focus was still being kept on the
current selected widget. not good. :) this patch makes the DiveList
keep the focus after a edit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Tomaz Canabrava
29a19e2e84 Fix the cursor problem on the TagWidget
The problem was the Focus Prevention system on the
EventFilter. Instead of that we can pass the setFocusPolicy (
strongFocus ) that ignores the mousewheel. simpler and cleaner.

Fixes #376

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Tomaz Canabrava
890d60ff9e Simplify the code by removing a few options from the if.
There was some options on the 'if' that didn't
really belonged there, so I create a if before those
to quit earlier if the condition is true.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:04 -08:00
Tomaz Canabrava
bffceb18e7 Do not New / Delete the item, use the Stack.
This should be somewhat faster, and the code is cleaner.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:04 -08:00
Tomaz Canabrava
2ead1ebe08 Removed obsolete code.
The QPainter::hightQualityAntiAliasing is ignored by Qt,
the docs says we should use QPainter::AntiAliasing.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:04 -08:00
Tomaz Canabrava
bdd1b3b546 Make it possible to use the Tag System in dark themes
The color used on the bright theme was cyan, and it's too bright when the
font is also white.

This patch uses the HSL information of the color to determine if the text
color is light or dark, and adjusting the background color for that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:04 -08:00
Tomaz Canabrava
9e57dd4826 Code cleanup: QPair<int, int> -> qMakePair
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:04 -08:00
Lubomir I. Ivanov
86ed014339 Fix an unused variable warning
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-19 07:28:26 -08:00
Lubomir I. Ivanov
1bb7ab30c6 Files: prefer toUtf8() over toLocal8Bit()
We may want to use toUtf8() for win32 considerations.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-19 07:28:25 -08:00
Lubomir I. Ivanov
69ed0d8393 Fix a missing parentheses warning
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-19 07:28:24 -08:00
Tim Wootton
ecc33e6375 Adds unhide to profile menu context menu
Unhide menu is only shown when hidden events exist.
Also updates relavent manual section.

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-18 14:07:41 -08:00
Tomaz Canabrava
77c2c4c5ad Make default font setting actually work
We were asking the widget.font() which returned the font that the
QFontSelector uses to display it's contents, instead of using
currentFont() that's the correctly selected font. duh. :))

Fixes #368
Fixes #375

(for #375 the solution is to select a different font that a) looks better
and b) has the missing characters)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-18 13:38:40 -08:00
Tomaz Canabrava
2f05934936 Whitespace fix
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-18 13:38:24 -08:00
Dirk Hohndel
33668ffd35 Don't enter edit profile mode when already editing the dive
This is not the ideal solution. Ideally we might want to simply enter the
profile edit mode if we edit a dive that was manually added. But right now
the code contains lots of assumptions about being in one mode or the other
and as we are redoing the profile / planner classes for 4.1 anyway, I'd
rather err on the safe side for 4.0.1

Fixes #374

(well, it fixes the second bug reported in 374 which is quite different
from the original bug)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-17 06:45:31 -08:00
Dirk Hohndel
fe88a2a476 Don't quit while dive is edited
If the user edits a dive and then quits we try to ask them to finish
editing, first. If the user did this by either clicking the little 'x'
in the window decoration or by hitting Alt-F4 (or similar), we didn't
have that question (only the 'save changes' question in case the dive list
had already been modified.

Fixes #374

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-16 16:37:44 -08:00
Michael Andreen
5f12660870 Use UTF-8 for text strings.
Fixes #371

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-16 16:14:50 -08:00
Dirk Hohndel
5c2ded5840 Disable https on Windows for 4.0
We appear to be missing the correct dll. I'm out of time trying to track
this down, so I just switched Subsurface to access divelogs.de via http on
Windwos.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-15 14:24:30 -08:00
Dirk Hohndel
4b98efb39c When editing multiple dives, only copy the cylinder type
Previously we would overwrite the gasmix as well as start and end
pressure even when editing multiple dives, which clearly is wrong.

Fixes #364

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-14 09:32:24 -08:00
Dirk Hohndel
d117becad8 Improve MainTab behavior when using the scroll wheel
This gets the behavior close to what we really want.
- scroll wheel no longer enters edit mode when over the tabWidget
- scroll wheel doesn't modify dateTimeEdit, nor does it enter edit mode
- scroll wheel still scrolls both the notes and the full widget

The only oddity is that when clicking on either the dateTimeEdit or the
tabWidget we don't immediately turn on the 'being edited' warning (as we
do for all the other widgets). For those two widgets the user has to press
a key before edit mode starts.

I think this Fixes #176

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Ideas-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-13 21:18:54 -08:00
Lubomir I. Ivanov
92476c76f3 prepare_dives_for_divelogs(): remove unused variable 'doc'
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-13 07:42:39 -08:00
Dirk Hohndel
719b732230 Fix incorrect handling of autogrouped trips
When toggling autogroup in the menu we ended up setting the NO_TRIP flag
for dives that were removed from a trip that was created by autogroup. So
toggling things on and off and on again meant no more auto grouping.

Fixes #337

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 15:03:25 -08:00
Dirk Hohndel
76251c27da Fix the logic when to display the "language changed" warning
If the user had never set up the language selection they could end up
getting the "language changed, restart required" warning even if they
didn't touch the language setting at all.

This fixes that issue by assuming that UseSystemLanguage is true if the
setting is undefined and only comparing the selected language if that
selection actually matters (i.e., UseSystemLanguage is false).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 06:44:09 +01:00
Thiago Macieira
0f3928f315 Don't check if a file exists right before trying to open it
The open call will tell us what we need to know. Obviously we can't open
a file that doesn't exist. This saves us one stat() or Windows
equivalent.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:37:24 +01:00
Thiago Macieira
841bdf3462 Make the streamsize variable actually int
Casting a pointer to a size_t variable to a pointer to int is wrong on
big endian machines. Not that I expect anyone to compile Subsurface 4
for Mac on PowerPC 64-bit, but just in case... Who knows, we may have
some Solaris-on-UltraSPARC or AIX-on-POWER6 users.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:37:07 +01:00
Thiago Macieira
0a57befb69 Don't call strlen() on something we already know the size of
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:36:36 +01:00
Thiago Macieira
cb39bb5e9c Don't leak the zip structure in case of error
This also erases the zip file that we created

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:36:16 +01:00
Thiago Macieira
b3d59cb890 Don't leak the buffer or temporary file used to save the dive
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:35:46 +01:00
Thiago Macieira
04ec3cf31f Hoist the getting of the XSLT style-sheet out of the loop
We don't need to get it for every file, since it's the same. This also
avoids leaking temporary files and memory if the stylesheet cannot be
found.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:35:37 +01:00
Thiago Macieira
a17880ca02 Make the errPrefix a static variable
No need to allocate memory for something that will show in debugging
only. Besides, qDebug() of a QString adds quotes around it, which we
can do without.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:34:54 +01:00