Commit graph

1638 commits

Author SHA1 Message Date
Anton Lundin
770bf9afba Introduce NO_MARBLE define, make GlobeGPS a dummy
Some users have requested a way to build subsurface without marble.

This hides all traces in the ui and creates a GlobeGPS-dummy thats
just a QLabel saying that marble is disabled, in case its shown
somehow. The dummy is there so we can just ignore the fact that marble
is disabled in the rest of the code.

Fixes #394

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:40:06 -07:00
Alberto Corona
027ffc41bb simplewidgets: Include stdint for cross compatability
Not including stdint leaves 'int64_t when' without a type and undefined when
compiling for Windows with mingw

Signed-off-by: Alberto Corona <albcoron@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-25 11:19:56 -07:00
Jan Mulder
fe2ad15603 Redraw profile when manipulating cylinders
Manipulating cylinders, especially changing the exact gas content (o2,
he), changes the pp02, ppHe graphs. This patch simply replots the profile
in case of cylinder change at time of saving.

Signed-off-by: Jan Mulder <jlmulder@planet.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-25 07:53:37 -07:00
Anton Lundin
fc13361079 Don't crash if we try to save a empty plan
Just treat it as a cancel instead.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-23 17:24:42 -07:00
Anton Lundin
8bc2ad1473 Enable parts of planner based on define
In bf205726 DEPTH/Switch at was disabled by commenting out that code.
This puts it back behind ifdefs

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-23 17:24:40 -07:00
Yosef Hamza
d4a1932276 Divemaster and Buddy fields auto-completion are not saved
The added characters by auto-completion "for the last item"
isn't saved when using Return to save it "works well with
tab"

Fixes #469

Signed-off-by: Yousef Hamza <jo.adama.93@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-23 17:20:03 -07:00
Anton Lundin
9cfc585563 Fix system default font handling
We didn't care about system default fonts and sizes, we just used the Qt
default font.

Due to how QFont is constructed, there was need to split font and font
size.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-21 21:30:39 -07:00
Jan Mulder
41209005c9 Make pp graphs visible at startup according to settings
Changeset a90818671 introduces a small inconvenience. The pp graphs at
startup are not shown according to the visibility settings. Requiring to
toggle the icons to show the desired pp graph.

Trivial fix.

Signed-off-by: Jan Mulder <jlmulder@planet.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-21 21:29:22 -07:00
Gehad
8ca4437624 Add current time and adjusted time to gui when adjusting dive's timestamp
This patch adds the current dive time and the adjusted time to the time
shift window. I added a function to dive.c to get the timestamp of the
first selected dive.

This will view the time of the first selected dive only even when multi
dives are selected but it does change the times for multiple dives
properly.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-21 21:26:09 -07:00
Gehad
cc2369c5f9 Make esc-key discard the new tag selection
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20 09:54:58 -07:00
Hugle
2ca6009dfa Removed Duplicate Includes
Signed-off-by: Hugle <wulong@comp.nus.edu.sg>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20 09:52:24 -07:00
Tomaz Canabrava
320071ac15 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>
2014-03-20 09:49:33 -07:00
Tomaz Canabrava
6ee3a6da52 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>
2014-03-20 09:49:05 -07:00
Tomaz Canabrava
dfaa302383 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>
2014-03-20 09:48:34 -07:00
Tomaz Canabrava
5b497b5655 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>
2014-03-20 09:48:19 -07:00
Tomaz Canabrava
ec2ea7ec3a 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>
2014-03-20 09:48:10 -07:00
Tomaz Canabrava
30770f5d85 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>
2014-03-20 09:47:57 -07:00
Tomaz Canabrava
3d83c48c49 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>
2014-03-20 09:47:43 -07:00
Anton Lundin
519f45416f 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>
2014-03-20 09:40:28 -07:00
Linus Torvalds
a29c4ddba3 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>
2014-03-19 14:32:27 -07:00
Lubomir I. Ivanov
71f2fd91b5 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>
2014-03-19 09:37:12 -07:00
Gehad
fdf6f3cd4e 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>
2014-03-19 09:33:59 -07:00
Gehad
f2238300ef 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>
2014-03-19 09:27:04 -07:00
Lubomir I. Ivanov
6d6721dc9b 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>
2014-03-18 11:56:06 -07:00
Hugle
a908186716 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>
2014-03-18 11:49:57 -07:00
Anton Lundin
17a675367d 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>
2014-03-17 20:37:41 -07:00
Anton Lundin
f8d30ae528 Make dc_number defined when using it
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-17 20:37:38 -07:00
Anton Lundin
0a762334e2 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>
2014-03-17 20:37:33 -07:00
Linus Torvalds
37794e2e23 Be more careful about dive computer selection
The selection logic was a bit random: some places would return NULL if
the dive computer index was out of range, others would return the
primary dive computer, and actually moving between dive computers would
just blindly increment and decrement the number.

This always selects the primary computer if the index is out of bounds,
and makes sure we stay in bound when switching beteen dive computers
(but switching between dives can then turn an in-bound number into an
out-of-bounds one)

Fixes #464

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-17 10:53:49 -07:00
Dirk Hohndel
60ceb8ebc1 Silly change to a comment
I had intended to amend the previous commit with this before pushing it
out. This changes the comment that pointed out the bug that the previous
commit fixed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-17 10:53:12 -07:00
Dirk Hohndel
33b1b0ed9d New profile: fix event hiding logic
Turns out we unconditionally set all events as visible when redrawing the
dive - even with a comment that this should take into account if the event
is visible. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-16 15:11:35 -07:00
Dirk Hohndel
401aa210ff New profile: add event manipulation to context menu
This got lost when we switched to the new profile.
Remove event works. Hide events does call hide() on the DiveEventItem but
for some reason it stays visible. I'll hope for one of the more
experienced Qt people to fix that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 21:12:34 -07:00
Dirk Hohndel
cb41f34826 Don't put cylinder widget in edit mode if deletion of cylinder failed
If the user tries to delete a cylinder that is in use and that action is
rejected, the cylinder widget (and the whole dive) should not be put into
edit mode. After all, nothing changed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 15:38:10 -07:00
Dirk Hohndel
36ba353450 Correctly check if tank is in use
We always checked if the tank was in use by the planner / dive editor -
even if we were not in dive edit mode.

With this patch, when not in dive edit mode, we check our cylinder "used"
flag instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 14:56:32 -07:00
Jan Mulder
aa0cd792bb Bugfix: generalize pp graphs to allow for multi over-threshold periods
Especially in O2 decompression parts of a dive, the pp02 is typically very
close to the threshold value (normally 1.60 bar). The old implementation
of the pp profile graphs assumes that there is exacty 1 consecutive set of
samples that needs to be in the "warning color". This results in an
erroneous display of the mentioned graphs, connecting multiple episodes of
too high pp with bogus lines in between.

This fix generalizes the pp graph logic to allow for multiple segments of
high pp, each to been drawn seperately in the "warning color".

Signed-off-by: Jan Mulder <jlmulder@planet.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 12:07:34 -07:00
Dirk Hohndel
8650a6ef6c Make "save changes" dialog modal
This definitely seems to be a good candidate for a modal dialog.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14 16:01:09 -07:00
Linus Torvalds
609715ab69 Convert other users of showError() to the new world order
The "report_error()" interface is a lot simpler, although some of the
C++ code uses QStrings which make them a bit annoying, especially for
the varargs model.  Still, even with the explicit conversion to UTF8 and
"char *", the report_error() model is much nicer.

This also just makes refreshDisplay() do the error reporting in the UI
automatically, so a number of error paths don't even have to worry.  And
the multi-line model of error reporting means that it all automatically
does the right thing, and reports errors for each file rather than just
for the last file that failed to open.

So this removes closer to a hundred lines of cruft, while being a
simpler interface and doing better error reporting.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14 12:36:06 -07:00
Linus Torvalds
ec33a95ad0 show the error string in the GUI rather than stderr
This makes the error string just be an internal "membuffer", which the
GUI can fetch and show when errors occur.  The error string keeps
accumulating until somebody retrieves it with "get_error_string()".

This should make any write errors actually show up to the user.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14 10:49:56 -07:00
Linus Torvalds
b5d0cfd557 propagate save errors further, don't mark divelist unchanged
This at least avoids marking the dive list as unchanged on a failed
write, and propagates the error further up the stack.

We still don't show the error string in the GUI, though.  I'll start
doing that next, I think.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14 10:49:53 -07:00
Linus Torvalds
3fe0019bc2 git object format: make sure parenthood isn't lost when saving
This makes subsurface remember the git source commit of the dive data.

If you save to an existing branch, subsurface will now complain and
refuse to save if you try to save if the existing branch is not related
to the original source.  That would destroy the history of the dive
data, which in turn would make it impossible to do sane merging of the
data.

If you save to a new branch, it will see if the previous parent commit
is known in the repository you are saving to, and will save parenthood
information if so.  Otherwise it will save it as a new parentless commit
("root commit" in git parlance).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-13 20:48:31 -07:00
Dirk Hohndel
ae2f18678d New profile: fix Information overlay location
By simply storing the coordinates based on the scene (instead of trying to
map them to real coordinates) the overlay position is correctly restored.

Also remove the redundant positioning before readPos is called.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-13 10:28:15 -07:00
Lubomir I. Ivanov
5b3dab719e MainWindow: maintain one window instance of the yearly statistics
This is a bit tricky because we are using a plain widget for
a window and don't have a class for it (req. more source files).
Also for the table model to update we need to create a new
YearlyStatisticsModel instance each time. At least, in that regard
we can re-create the model each time refreshDisplay() is called.

This patch adds a couple of private variables that are used
to manage the memory of the yearly statistics model and window
and also close that same window on MainWindow::closeEvent().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-12 12:12:13 -07:00
Lubomir I. Ivanov
4abe9d5c8b Profile2: place the ruler and tooltip on top (Z order)
The topmost Z order of items in the profile should be:
- background (poster / logo)
- toolTipItem
- rulerItem
...

This mostly fixes the ruler being under other elements.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-12 11:25:23 -07:00
Lubomir I. Ivanov
f2bfc72648 Ruler: change how the ruler text drawing works
A couple of problems with the ruler:
- the rotated text doesn't look very well at all and interpolation doesn't
  help it much
- measuring towards the right most part of the profile makes the text go
  out of the screen

To solve these issues and attempt to improve the ruler this patch does the
following:
- place the text at the bottom of the lowest of the start and end points.
  this way the line will never intersect with the text
- clamp the x position, so that the text doesn't ever leave the screen
  horizontally
- place a white background behind the text so that it will cover text and
  graphics under the ruler item

(TODO: place the ruler on top of everything else)

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-12 11:24:20 -07:00
Lubomir I. Ivanov
7ee1884f6e Make some dialogs modal to MainWindow
For most dialogs it would be much safer to make them Qt::WindowModal to
the parent (MainWindow).
For now we are not doing this for the preferences dialog as there are
situations where the user might want to be able to move it around and even
interact with the main window.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-12 10:14:17 -07:00
Tomaz Canabrava
9cc942376e Only anim if not first dive when openning subsurface with a divelog.
The animation appeared when the user started subsurface with a default
file, wich was a little annoying since it didn't had a 'from' position
to go and it was also increasing it's size on some window managers
that do subtle windows animations when a program starts. This patch
treats the first dive opened when the program loads with a divelog pa
rameter differently as the following ones storing the velocity value
on a temporary, and reassigning it later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-11 17:42:42 -07:00
Tomaz Canabrava
751c76a578 Support save / load for the Animation Speed on the Preferences
User can now fine-tune the animation speed on the preferences,
a value of zero disables it completely.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-11 17:41:41 -07:00
Tomaz Canabrava
9f37bac07a Support Animation Speed via Settings.
This is very userfull for a ( yet to be implemented )
preference dialog about the animation speed, so the
user can enable / disable the animations or make it a bit
faster for it's taste.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-11 17:41:41 -07:00
Lubomir I. Ivanov
466f160c01 Profile2: provide means to disable the tool buttons
Once the poster is displayed when there are no dives in the list,
we may also want to disable the QToolButtons (PO2, SAC, etc..),
until a new dive is loaded and the profile is redrawn.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-11 11:30:31 -07:00
Lubomir I. Ivanov
b382228b7d MainWindow: close all windows once we close the main one
This is useful if we have more non-modal windows and we want
them simply to close with the main one without explicitly
creating class member variables to point to such instances.

A practical example would be the debug window created in
ProfileWidget2() (diveDepthTableView) which holds
the depth profile values.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-11 11:25:46 -07:00