Commit graph

4309 commits

Author SHA1 Message Date
Tomaz Canabrava
bf4144a012 Removed the 'Unused Tanks' from the toolbar.
Just removed the unused tanks from the toolbar,
since it's just a removal of something on the ui
related code, it's good to see how much verbose
the xml to generate the UI is.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 21:50:05 -08:00
Dirk Hohndel
59f60f39f6 Updated user manual html file
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:41:36 -08:00
Willem Ferguson
6496f4eb61 User manual: grammar and stylistic revision
This commit was jointly authored by Pedro Neves and Willem Ferguson.
Pedro added a FAQ section to the manual. Many long lines of text were
broken into shorter lines.

Signed-off-by: Willem Ferguson <willem@willem-Precision-M4700.(none)>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:38:06 -08:00
Dirk Hohndel
f26896da1b Automated whitespace / coding style correction
First attempt to use the tools on one of our source files.
So far so good. Not perfect, but a HUGE improvement.

Most importantly it effortlessly fixed the Allman style braces introduced
in commit 51220f26ef ("Add recent files to main menu.").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:12:17 -08:00
Dirk Hohndel
ebac81b784 Fine tuning of the whitespace / coding style post processing
The struct / class regex was way too relaxed.
Having the parent class on the same line usually looks better.
clang-format appears to do something odd with continuation strings - even
with UseTab: Always it indents those with four spaces.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:10:21 -08:00
Boris Barbulovski
51220f26ef Add recent files to main menu.
Add(up to four) recent files to File main menu.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:05:05 -08:00
Dirk Hohndel
933d44083e Add a simplistic tool to clean up whitespace
This hasn't been tested enought, but it seems to get really close.

It assumes that clang-format is in your patch.

Run

perl scripys/whitespace.pl FILENAME

and you'll get a diff of what it things is wrong with that file.
If you like what you see, simply pipe the output into patch -p0

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 22:33:01 -08:00
Linus Torvalds
23baf20f56 Use "rint()" instead of rounding manually with "+ 0.5"
rint() is "round to nearest integer", and does a better job than +0.5
(followed by the implicit truncation inherent in integer casting).  We
already used 'rint()' for values that could be negative (where +0.5 is
actively wrong), let's just make it consistent.

Of course, as is usual for the messy C math functions, it depends on the
current rounding mode.  But the default round-to-nearest is what we want
and use, and the functions that explicitly always round to nearest
aren't standard enough to worry about.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:49 -08:00
Linus Torvalds
7ae05b4f71 Fix default value for missing surface pressure from divecomputer
We should *not* default to the incorrect "1 bar".  Instead, we should
leave the resuling pressure at 0 mbar, which leaves visual entries empty
and uses the default surface pressure for calculations.

Reported-by: Pedro Neves <nevesdiver@gmail.com>
Cc: Patrick Valsecchi <patrick@thus.ch>
Cc: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:46 -08:00
Dirk Hohndel
730e0295c9 Ensure the correct parent is used in the dialog
This way the dialog is centered and the main window gets dimmed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 13:25:23 -08:00
Dirk Hohndel
af5ad2033d Don't redeclare variables of the same name
This isn't broken, but it's confusing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 13:24:40 -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
Tomaz Canabrava
cc37d2e94a Make the mean depth line follow the size of the axis.
When we move, shrink or expand the depth axis, the
meandepth should also change it's position. this
patch adds that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:33:14 -08:00
Tomaz Canabrava
0333de426f Hide the extra axis labels on release mode, show on debug mode.
The extra axis labels on the Temperature and Cylinder Pressure
graphs are not wanted in release mode as they create a lot of visual
clutter, but they are useful to have in debug mode since we can then
better understand what went wrong.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:31:24 -08:00
Tomaz Canabrava
8041a2ed85 Added cylinder pressure shrinking on show/hide partial pressure.
Same as the last commit, but for cylinder pressure. Another bug
was spotted, where the mean depth line does not move to the correct
location after a axis-size-changed - fixing that on next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:30:45 -08:00
Tomaz Canabrava
49642cacbc Shrink temperature axis when partial pressures are shown.
This patch adds shrinking of the Temperature axis when partial
pressures are shown. This adds an unwanted side effect however,
the axis started showing it's values - and we didn't do that on
the gtk version or on the old profile. While this is good for
debugging, it's not wanted for the software if it's on release
mode. I'll fix that in due time.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:29:57 -08:00
Tomaz Canabrava
b08c38da33 Animate transition between show / hide partial pressure graphs
When the user checked the option to show or hide the partial
presure graph the size of the profile graph was kept the same;
usually I do those changes on the objects themselves, on the
settingsChanged method, but since the calculation of the
size of the profile was done on the ProfileView class for
consistency with the other objects, I had to change it there
too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:08:46 -08:00
Dirk Hohndel
5ca13b0024 Correctly track parent of print dialog
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 06:26:25 -08:00
Dirk Hohndel
6332976c3d Whitespace and dead code cleanup
The coding style for switch isn't the prettiest, but let's at least keep
things consistent.

Also, those ugly break statements never got reached, anyway.

And there was no need to re-declare and re-generate currentString.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 06:22:10 -08:00
Dirk Hohndel
9c9867dec5 More variable scope confusions
Don't have nested loops with the same loop variable. Really. Even if it is
legal C++.
And don't declare local variables more than once. This will only cause
issues later.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 06:07:32 -08:00
Dirk Hohndel
6bff18e56a Make sure the about dialog is correctly centered
Otherwise, why pass in the parent to begin with?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 06:06:13 -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
Dirk Hohndel
11559f1704 Don't reuse a variable name with a different type inside the same function
Since the variable was inside of an inner scope this was technically legal,
but it's just too annoying for words.
(The diff in the commit doesn't make this obvious, but outside the for
loop in the same function there is a divedatapoint *dp, so we had a
pointer to divedatapoint and a divedatapoint with the same name...)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 05:43:31 -08:00
Dirk Hohndel
ffc61e1357 Don't use current_dive instead of the argument to the function
I could have gone either way - the other alternative would have been to
remove the argument to the function. But since current_dive is a macro
and since the semantic of the function make sense with the argument being
passed in, it seemed better to just not use current_dive in the function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 05:37:18 -08:00
Dirk Hohndel
4e6a0c8503 Remove external declaration of non-existant global variable
Just to slightly reduce possible confusion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 05:35:30 -08:00
Dirk Hohndel
48e9257de4 Fix variable scope issue
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 14:08:17 -08:00
Linus Torvalds
e58f54cac1 Fix ATM-vs-bar confusion
SAC should be calculated in relationship to surface pressure, not "1 bar".

I also realize that we have a few other cases where we do the same
mistake: the partial pressure calculations do things like

    po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive);

which is wrong as well - the partial pressure is also relative to
standard atmospheric pressures.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 14:05:54 -08:00
Dirk Hohndel
92bbed3304 Take the on-canvas position into account for DiveCartesianAxis::valueAt()
We did this right for posAtValue(), but not for the inverse.

Fixes #438

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:37:09 -08:00
Boris Barbulovski
ccb1c33d02 Put include guard to every header
* ensure include guard to every header
* comment endif guard block

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:37:01 -08:00
Boris Barbulovski
a3d82bf9b1 Update #include statement for QStringListModel
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:53 -08:00
Boris Barbulovski
507a929a27 Migrate MainTab models(QStringListModel)
Migrate MainTab models
  from static xxxCompletioModel::instance()
  to private MainTab variable members.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:45 -08:00
Willem Ferguson
af8c44fa22 User manual: small updates
The section on the main menu descriptions has been changed a little bit to
reflect the current menu structure.

The section dealing with exprt from other dive software has been changed
to appear more user friendly, with three new icons.

Signed-off-by: Willem Ferguson <willem@willem-Precision-M4700.(none)>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:37 -08:00
Patrick Majewski
936ac958ed Handle cancel in PreferencesDialog::on_chooseFile_clicked
If I click in the Preferences Dialog on the 3 dots to choose a default
file to load and cancel the opening FileDialog an empty string is returned
and set to the coresponding QLineEdit.

The new behavior (and mostly expected) is to update the QLineEdit only
if there is a filename returned from QFileDialog.

Signed-off-by: Patrick Majewski <dive@patrick-majewski.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:28 -08:00
Dirk Hohndel
b839cd4cb0 More renaming
I don't even know what a partial gas might be...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:11 -08:00
Dirk Hohndel
9bd77b51f5 Give the widget for the new profile a better name
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:03 -08:00
Dirk Hohndel
d1c4bcf570 New profile: enable switching between dive computers
This was mostly in place, just needed to be hooked up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:35:54 -08:00
Dirk Hohndel
73d6057424 Minor cleanup
Remove obsolete header and unused variable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:35:47 -08:00
Dirk Hohndel
6ea6a4305c Use our macro for FP comparisons
I think that catches all the ones we missed (thanks clang -Wfloat-equal).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:35:40 -08:00
Dirk Hohndel
2bd2df0349 Fix bug in logic expression
Yes, the old code made perfect sense when you read it - except the C++
compiler turned it into something quite different from what was intended.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:34:42 -08:00
Dirk Hohndel
d49acdb3c0 Clean up include files
They should have a newline at the end.
Forward declarations of classes should be 'class'.
Function / method definitions don't end on a ';'
Remove obsolete QStateMachine forward reference.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:34:34 -08:00
Dirk Hohndel
829473ddc6 Don't repopulate the model if the dive didn't change
plotDives takes a list of dives (for future use) but currently only looks
at the first dive in this list. With that semantic in mind we can save
ourselves some work if we first check if this is the same dive we are
already showing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 16:32:10 -08:00
Dirk Hohndel
ba6713f0d8 Clean up the setDive function
* This should never be called with a NULL dive.
* The dc variable was set then never used.
* We now have a unique id for each dive, but we can't simply not
  repopulate the model in setDive as the old comment might make you
  consider, as otherwise the dataModel will reference already freed data
  in pInfo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 16:27:05 -08:00
Dirk Hohndel
74c75938bf Set up the dive that was passed in as first dive
We carefully extracted the first dive passed in with the QList, but then
always used current_dive. That's silly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 15:12:01 -08:00
Lubomir I. Ivanov
4b21e2f9a3 Profile2: Prevent another crash if no dives are present
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 14:33:44 -08:00
Tomaz Canabrava
691fbabb7a Do not add the items to the scene twice.
Those items have parent(), which means that when the parent has a scene,
they are automatically added and removed from the scene.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 09:58:42 -08:00
Tomaz Canabrava
bb71707321 Fixed item visibility on emptyState after being on profileState.
Background was not correctly back to it's original position
and a few other items kept their visibility when it shouldn't.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 09:57:45 -08:00
Tomaz Canabrava
cafc7e4b13 Clear the data when the model resets.
This patch does a few things:
1 - reset the model when user closes the dive file
2 - connects the 'rowsAboutToBeRemoved' in a way that the graphics can
    remove their polygons too
3 - adds a 'clear' virtual method so items that don't follow the rules can
    clean themseves up.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 09:57:04 -08:00
Dirk Hohndel
2f2c9e371c Don't ignore the return values from readfile and EXIF parser
If readfile fails it already frees its buffer.
If the parsing failed we shouldn't use the data in the structure.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 08:20:53 -08:00
Danilo Cesar Lemes de Paula
31c45b8c4c Enable the dive planning under a compile flag
Allow subsurface to show the dive planner in case a compile flag is given.

qmake CONFIG+=planner

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 08:08:20 -08:00
Boris Barbulovski
772c9fb0b1 Fix calloc parameter order.
* Set correct calloc parameters order(num, size)

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:56:09 -08:00