Commit graph

269 commits

Author SHA1 Message Date
Anton Lundin
198199adae Remove printing when building for Android
Qt for Android doesn't support printing.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:42:07 -07:00
Anton Lundin
605cff32a5 Remove usermanual when building for Android
Our usermanual is based on webkit, and thats not supported in Qt for
Android. We should probably replace it with a Android native webview
somehow.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:41:52 -07:00
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
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
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
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
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
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
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
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
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
Tomaz Canabrava
ac9a23ef3b Remove the old profile from the main screen of Subsurface
This patch partially removes the code for the old profile from
Subsurface. It removes the use of the old profile on the mainwindow,
but keeping the code in the tree for now.

A bit of code-cleanup also entered this commit because I had to change
every instance of the code that used the old profile.

Now to the real code-cleanup

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 08:54:20 -08:00
Dirk Hohndel
f693bbd7a0 Don't use error after free
We need to reset the error pointer to NULL for this to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 22:11:24 -08:00
Dirk Hohndel
7c535452f9 Whitespace cleanup
Minor change to the perl postprocessing script and resulting changes to
the affected source files.

This deals with two issues:
- "foreach"-like structures were not always treated correctly
- some longer calculations that ended on "+ constant" were reformatted in
  a rather unatractive manner

In one source file (divelist.c) I ended up adding braces to the sources...
trying to cascade the indentation further down without having the block
there seemed a lot more trouble than it's worth.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 13:29:22 -08:00
Anton Lundin
909cfe7135 Set the prefs-value alongside the button status
Previous code just set the button-"status" based on what we stored on
the settings. This sets the corresponding value in our prefs-struct.

This fixes the same issue as in 63f7f3, without the side effect of
magically hiding the mean depth line.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-02 13:42:07 -08:00
Anton Lundin
3df506b081 Spelling fix, Its called Ndl
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-02 11:16:38 -08:00
Dirk Hohndel
d29d0e7a5d Revert "Switch profile button events, clicked to toggled"
This reverts commit 63f7f37e46.

For odd reasons this appears to make the mean depth line disappear. This
will require some further analysis, but for now I'll just revert it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-02 10:37:07 -08:00
Joshua Wambua
9cd3d61c11 Remove failed parses from recent files menu
This patch will remove all files that fail to parse from the recent
files menu.

Signed-off-by: Joshua Wambua <joshua@megvel.me.ke>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-28 07:51:41 -08:00
Anton Lundin
63f7f37e46 Switch profile button events, clicked to toggled
This is needed so the underlaying struct preferences prefs, will be
updated when we set the buttons to there previous state after we
loaded the settings.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 18:55:54 -08:00
Tomaz Canabrava
8c56b2f45e Store zoomed plot in preferences
This patch makes the 'Zoomed Plot' a preference that can be stored and
retrieved, this way if the user sets the plot to be 'zoomed', this
information will persist even if they closed or opened subsurface again.

Also, added the 'Scale' button on the new profile, but didn't did the glue
code yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 10:48:35 -08:00
Giuseppe 'ferdy' Miceli
69bf64793c Adding a polite "Please" in front of the warning message.
Signed-off-by: Giuseppe 'ferdy' Miceli <ferdy@ferdy.it>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-26 08:02:38 -08:00
Thiago Macieira
756abc0341 Add an assertion to prevent MainWindow from being recreated
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-18 16:49:04 -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
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
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
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
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
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
b88958ded5 mainwindow.cpp improvements
* Add missing variable members to the initializer lists.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:07 -08:00
Boris Barbulovski
9eb47602dd Cleanup SubsurfaceWebServices class
* Remove statuic SubsurfaceWebServices::instance() member.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:04:37 -08:00
Boris Barbulovski
449c6fc6f2 DownloadFromDCWidget class cleanup
Remove static DownloadFromDCWidget::instance() method

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 08:17:08 -08:00
Boris Barbulovski
02e9a6d07b PrintDialog class cleanup.
* Remove static PrintDialog::instance() method
* Remove void PrintDialog::runDialog() method
* construct/destruct print dialog on demand

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 08:15:42 -08:00
Boris Barbulovski
3161114106 SubsurfaceAbout class cleanup.
Main change is that now SubsurfaceAbout doesn't have instance object, but
it constructs and destructs dynamically.

 * Remove the static SubsurfaceAbout::instance() class member
 * construct/destruct about dialog on demand
 * Other small aboutbox cleanups.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
ACK-ed-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 08:00:27 -08:00
Tomaz Canabrava
2322fdfc42 Load options as soon as the progrm starts
Populate the status of the profile tool box as soon as the program
starts.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 11:32:11 -08:00
Tomaz Canabrava
185b7a454a Save the old pref system when changing the new one
Since we have now a mix of old / new prefs, remember
to change both when we alter something.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 11:31:44 -08:00
Tomaz Canabrava
96e35e542c Move save of preferences to the preferences dialog.
I had a few very strange bugs regarding to preferences (like clicking on
apply twice so things worked), because the code that moved from
"QSettings" to 'Internal Settings Struct' was being triggered on the
mainwindow, *after* the settingsChanged signal was emmited. This should
fix the problem.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 11:30:57 -08:00
Tomaz Canabrava
c84ef319a2 Create a toolbox on the left side of the new profile
For quick acess of preferences the show / hide stuff from the Settings
dialog is now in that toolbox and in the future we can put a few more,
like 'Show Notifications Panel' and 'Enable Legend'

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:34:05 -08:00
Tomaz Canabrava
793879b6fa The plot-profile method was being called too many times.
There was a bug in the old implementation where we needed to
trigger a repaint of the profile almost everywhere. this isn't
needed anymore on the new one, so do not use the same method
that will be killed when I finish this.e

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:16:35 +07:00
Boris Barbulovski
6cc65f5e1c Fix some memory leaks.
Memory leaks were caused by broken parent/child relations.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:15:47 +07: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
Tomaz Canabrava
52064d9e02 Added debug code to help understand the Profile
This commit adds a QTableView if built in debug mode. This is very userful
to understand the Profile that will be drawn by the graphics classes and
fix the possible errors.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:31 +07:00
Tomaz Canabrava
90fc7a23f2 Pass the current selected dive to the new Profile Widget.
This call just passes the selected dive to the new profile widget. No
drawing is performed, I still have to setup the constructors and the rest
of the initialization of the new Profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:30 +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
Anton Lundin
abfd86af59 Remove unused import
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15 15:49:46 +07:00