Add forward declaration of QSettings

Its needed for Qt5

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make dc_number defined when using it

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Translate using tr() to be Qt5-compatible

There are no utf8 in those strings, and we can translate them as
everything else with tr() instead.
QApplication::UnicodeUTF8-part is deprecated and removed in Qt5.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Don't devide by 0 if fO2 is 100%

Fixes #465

Initial-patch-by: Anton Lundin <glance@acc.umu.se>
Better-idea-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Clear PN2 PO2 PHE GasItem

After the dive log has been closed, the ProfileWidget2 does not clear
the pn2 po2 and ph2 gas line.

This patch cleared the three lines after dive log closed.

Acked-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Hugle <wulong@comp.nus.edu.sg>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Profile2: use unsigned int for the divecomputer number

display.h: dc_number is unsigned int, thus a couple of warnings
may pop-out.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Link to marbledata when building out of tree

When building and running subsurface out of tree, marbledata was
inaccessible to subsurface.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Saving edits requires to move focus first

After editing values in cylinders or weights hitting save will not save
the changes to save the edit one must move the focus to a different
field first this is fixed by losing the focus before saving the changes

Fixes #412

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make Up/Down arrows work with tags

When using Up/Down arrows to scroll the tag list it always selected the
first item in the list and doesn't scroll.

Fixes #468

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Profile2: fix widths on some lines for Qt5

Qt5 uses different widths for some of the poly. lines
in the profile. Setting an explicit value fixes that.

Tested-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Main: separate the QApplication and UI creation

When some arguments like --help and --version are passed to the
executable, we don't need to create the UI at all.

This patch separates the QApplication creation which is at first
only needed to parse the arguments and then if exit() is not
called from subsurfacestartup.c, we can call some of the
"init" methods such as setup_system_prefs(), fill_profile_color()
etc.

At this point init_ui() can be called which no longer needs
to accept the command line argument list.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
git object store: make it possible to work with checked-out git branches

This makes the git object save logic also check out the changes in the
working tree and index if the branch we save to is checked out.  It used
to be that we would just update the object store (and the branch ref, of
course), but leave any checked-out state untouched.

Note that if the working directory is dirty (ie you have made changes by
hand and not committed them), the checkout will skip any dirty files and
report it as a warning to the user.  However, the save still succeeds
(since the _real_ save goes to the backing store).

NOTE NOTE NOTE! Both loading and saving very fundamentally work on the
git object store level, and if you are working with a checked-out branch
and make modifications to the working tree, saving will not touch those
dirty files (so that you can try to recover your edits manually in the
working tree), but it's worth pointing out that subsufrace loading state
will totally ignore the working tree.

So the only way to make subsurface *see* your changes is to commit them.
Having edited state checked out in the working tree will only confuse
you when subsurface first ignores it on reading, and then refuses to
touch the checked-out state on writing.

Put another way: working with a checked-out branch is now _possible_,
but you need to be aware of the limitations.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Code Cleanup

The offending code is line-by-line equal to the completion highlited
method, so why make it duplicated? Call that method instead.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Do not copy strings when you don't need it.

This patch removed the use of copy-constructors on the QString to use the
const-references. Even knowing that the QString is a refcounted class,
let's not get that bad habit.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
QString starts empty, do not set "" as empty string.

Let's not be evil by creating "" as empty strings inside of the code,
really.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Don't create then set, do both at the same time.

When we create, then set the value of a variable, we are wasting cycles
and making the code more verbose.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make ruler respect dive depth.

The only place on the code that the y() position didn't accompanied the
dive-depth was this one, so let's see if this patch fixes it.

See #455

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove a bit of space from the Axis and its labels.

This should make the layout work better on smaller screens.

Fixes #458

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Better handling of keyboard on the inline edition on equipment

The handling of keyboard is broken on Qt inside QComboBoxes.
I'm trying ( and losing ) to make it less broken. This patch makes the
code work reasonably well if you press Key_down or Key_up after having
displayed the filter popup, which is different from the combobox popup for
some reason.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>