Commit graph

271 commits

Author SHA1 Message Date
Tomaz Canabrava
16d0a47853 Fixed the regression of selection not being stored from table to tree
This fixes the regression that I caused in the last commit,
where the selection was being correctly reestored from tree-to-table,
but it was incorrectly being restored from table-to-tree.

I also added a bit of speedup on the view while changing columns.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-29 16:46:27 -03:00
Tomaz Canabrava
9cc04c1ca6 More work on bug 111, Sorting works as it should.
Sorting is now working as it should, changing
from table to tree, keeping the selection from
table to tree ( but there's a regression on
tree to table conversion, I'll try to fix it
in the following commit. ).

this commit also cleans a lot of boilerplate
code that I wrote to bypass a graphics bug,
that I seem to have correctly fixed in this
version.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-29 14:03:36 -03:00
Tomaz Canabrava
f46a2d56bc Reimplement the Sort method to change from Tree / List, and remember selection.
Things are working as they should, but I hit on -probably- a Qt bug
that makes painting on the table view a bit weird ( it only updates
the painting by moving the mouse around ). I'll try to fake the
mouse movements in a couple of commits after this one.
There's also a few columns that are not being correctly sorted,
probably something to do with the SortRole.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-29 11:51:33 -03:00
Linus Torvalds
bb77f5a44e Add a "sort role" for sorting the dive list
By default, sorting is done by the display role, but then we end up
sorting by the string we display, which is almost always the wrong thing.

So this adds a new "SORT_ROLE" that is used for sorting, and then the
data lookup can return the raw data we want to sort by.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29 20:10:20 +09:00
Dirk Hohndel
8df20f4149 Merge branch 'bug111' of https://github.com/tcanabrava/subsurface 2013-05-29 19:55:24 +09:00
Sergey Starosek
4371a4a298 Fix message widget visibility.
Hide message widget when closing dive with no GPS coordinates.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29 19:24:20 +09:00
Sergey Starosek
823e870765 Fix default zooming.
Set default zoom level only when at least one dive selected
and user have not changed it.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29 19:23:07 +09:00
Dirk Hohndel
da52ff56b2 Correct the ceiling preference handling
Added the red dc ceiling as preference option.
Hooked them all up together so the sub-preferences are enabled when the
master preference is set (for 3m and red ceiling).
Use the options in the profile plotting functions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29 15:32:31 +09:00
Dirk Hohndel
c78d0ad51b Correctly enable partial pressure threshold entry in preferences
The initial state needs to reflect the value of the checkbox. Once the
dialog is run, there is a signal/slot connection in the .ui file that
keeps things in sync.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29 14:58:22 +09:00
Dirk Hohndel
4f53ad736d Connect preferences to the rest of the code
The biggest problem here was that bool has different sizes in C and C++
code. So using this in a structure shared between the two sides wasn't a
smart idea.

Instead I went with 'short', but that caused problems with Qt being to
smart for its own good and not doing the right thing when dealing with
'boolean' settings and a short value. This may be something in the way I
implemented things (as I doubt that something this fundamental would be
broken) but the workaround implemented here (explicitly using 0 or 1
depending on the value of the boolean) seems to work.

I also decided to get rid of the confusion of where gflow/gfhigh are
floating point (0..1) and when they are integers (0..100). We now use
integers anywhere outside of deco.c.

I also applied some serious spelling corrections to the preferences
dialog's ui file.

Finally, this enables the code that selects which partial pressure graph
to show.

Still to do: font size, metric/imperial logic

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29 12:59:46 +09:00
Tomaz Canabrava
5a994b08f6 Saves the selection to select it later.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-28 17:46:40 -03:00
Tomaz Canabrava
4019fdaa24 Switch between Tree / list on column - click.
This patch adds support for switching Tree / List
while clicking on a column header. This triggers
a sad-painting bug on the list - I guess I'll have
to fix it too. I'd apreciate some help on it, tougth.
next: keep the selection.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-28 17:07:43 -03:00
Tomaz Canabrava
c6f84de37c Adds the code to make the dive list behave like tree or list
This code adds the possibility to make the DiveList behave
like a Tree or a List, depending on what layout is set.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-28 16:56:58 -03:00
Dirk Hohndel
8394828806 Fix the positioning of text in the dive profile
This had been bugging me for a while - the label texts were all not
quite where I expected them to be. I think this looks much better now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-28 09:57:49 -07:00
Dirk Hohndel
b947cc924f Hook up most of the Preferences dialog
The imperial/metric super setting doesn't have any effect. But changing
the individual units now works and is tracked. And causes the display to
change after clicking "OK" (but not yet when clicking "Apply").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-26 11:33:45 -07:00
Dirk Hohndel
96f74d9939 Repair the saving and loading of units
This way it should work...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-26 10:49:05 -07:00
Dirk Hohndel
43892e36fd Fix colum visibility selection in the divelist
Several changes:
- split the reload of the DiveListView from the reload of the header
- don't include the column title in the name of the setting; the title
  will change depending on the units and localization chosen by the user
- rename the slot that toggles visibility to make the code more readable
- use setCollumHidden() method to simplify the code
- don't save the width of hidden columns (as they would be saved as zero
  width and can then no longer be enabled)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-26 10:16:01 -07:00
Dirk Hohndel
2896dbdaf1 Apply some CSS goodness to the Cylinders widget
Alternating color and some hover highlighting to make things prettier.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-26 10:05:41 -07:00
Dirk Hohndel
a8cdc30dbf We had an extra column in the model for the dive list
It doesn't appear to be used anywhere, but it shows up in the UI and
confuses things.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 20:16:16 -07:00
Dirk Hohndel
81e27b6db9 Try to make the equipment tab more compact
My attempts to actually set the width of the columns with the
SizeHintRole all failed - so I gave up on that and am forcing things to
work by making the texts in the header somewhat longer and then resizing
to that. Definitely not what I wanted to do - but that plus reducing the
font size gives us a much more reasonable / compact look.

I really hope that someone else can explain to me how to get the
SizeHintRole to affect the width (and not just the height - that part
worked just fine) of a the cells in a column. Then we can replace this
hack by a much better solution (that won't fail if the translated strings
look different).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 20:07:36 -07:00
Dirk Hohndel
4409d61f7c Set a pleasant zoom level to start out with
If the user very quickly switches between dives the zoom level sometimes
gets reset to be much more "zoomed out" (basically if you change dives
before Marble had time to zoom all the way in to the previous dive it will
keep whatever was the last zoom level of the animation - I'd consider that
a Marble bug).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 11:13:15 -07:00
Dirk Hohndel
92ee374494 Find Google maps in Subsurface's source tree
This way the user doesn't need to move the two folders googlemaps and
googlesat around in the filesystem.

This only works if Subsurface is started from the build directory - it
doesn't work when Subsurface is installed (and it doesn't at all address
the need to install these files and bundle them as well).

I'd consider this a hack to show how the real solution should work.

There is one more part of this that is a hack: Marble no longer searches
its default data directory; the path we set replaces the Marble system
search path. Sadly, Marble doesn't support paths the way Unix thinks of
them with multiple directories, separated by ':'. So this means that
Marble no longer finds any of its default icons. For most of them that
seems fine as I don't think lacking the icons for "manned_landing",
"robotic_rover", "unmanned_hard_landing" or the various types of places of
worship that Marble supports is necessarily a big issues for Subsurface,
but at least the default_location icon seemed important. And since we now
need to carry our own, I replaced the boring circle with a tiny dive flag.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 08:58:37 -07:00
Sergey Starosek
dbb84188c2 Fix GPS coordinates rounding.
Better round the coordinates.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 08:18:13 -07:00
Dirk Hohndel
fe66fe5ff6 If we disable the compass, we don't need to place it, either
Just completing commit f1a4edc5497d ("Don't show the compass").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 08:18:06 -07:00
Henrik Brautaset Aronsen
bf7d61e74e Don't show the compass
North is always up anyway.  At least that's the way we've done it so far.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 08:18:01 -07:00
Dirk Hohndel
5ca3c11e60 Correct the code to enter dive locations
The existing code converted the lat/lon to int before multiplying with
1,000,000 (in order to create udeg). Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 08:17:56 -07:00
Henrik Brautaset Aronsen
5d05bb1207 Avoid marble widget resize when switching dives
The "no dive location" message box was displayed above the marble
widget, which made the layout splitter move horizontally.

Made the message box as an overlay on the map instead.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-25 08:17:14 -07:00
Dirk Hohndel
884e1c3379 Merge branch 'prefsDialog' of https://github.com/tcanabrava/subsurface 2013-05-24 12:30:29 -07:00
Tomaz Canabrava
efb7f109e8 Added support for a preliminary Preferences Dialog
Dirk asked me to try to make it more modern, so I
used as a base, the Firefox preferences. currently
it saves / loads the preferences, and also smits
a signal 'preferencesChanged' that should be connected
to anything that uses preferenes, via the PreferencesDialog::intance()
object. In the future, I plan to make it have a signal / slot for each
member that changes.

I also moved the icons to a new folder this time, because the
amount of icons is now more than just two, and it was
becoming messy.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-24 15:19:48 -03:00
Dirk Hohndel
5926f9d4df Merge branch 'googleEarth' of https://github.com/tcanabrava/subsurface 2013-05-24 07:16:37 -07:00
Tomaz Canabrava
dfa59f9878 Trying the googlemaps integration 2013-05-24 11:07:59 -03:00
Alberto Mardegan
5e0a3cdad8 Fix usage of temporary QByteArrays
This commit fixes three different things:
 - a memory leak in WeightModel::setData()
 - getSetting() calling strdup() on a QByteArray
 - a possible usage of memory after deallocation

Here's an explanation of the last issue (taken from the mailing list, slightly
adapted):

toByteArray(), as well as others "toSomething()" methods, returns
a new object which the compiler allocates on the stack.  The compiler
will consider it a temporary data, and destroy it on the next line.  So,
when one does

	char *text= value.toByteArray().data(); // line 1
	if (strcmp(description, text)) {        // line 2

the compiler creates a QByteArray on line 1, calls ::data() on it, which
returns a valid char *, and assigns its value to "text".  So far, so
good.  But before jumping to line 2, the compiler destroys the temporary
QByteArray, and this will in turn invoke the QByteArray destructor,
which will destroy the internal data. The result is that on line 2,
"text" will point to some memory which has already been freed.

One solution is to store a copy of the temporary QByteArray into a local
variable: the compiler will still destroy the temporary QByteArray it created,
but (thanks to the reference-counted data sharing built in QByteArray) now the
destructor will see that the data is referenced by another instance of
QByteArray (the local variable "ba") and will not free the internal data.
In this way, the internal data will be available until the local variable is
destroyed, which will happen at the end of the {} block where it is defined.

Please note that when one uses the data in the same line, one doesn't need to
worry about this issue. In fact,

  text = strdup(value.toString().toUtf8().data());

works just fine.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-24 06:18:27 -07:00
Henrik Brautaset Aronsen
57e7c3f5d0 Improve wording in askSaveChanges()
Don't Save/Cancel/Save is less ambiguous than OK/Cancel/Save. Also
being slightly more verbose when creating the QMessageBox.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-24 06:16:10 -07:00
Henrik Brautaset Aronsen
6fa670e612 Improve wording on buttons when editing a dive
Use the more familiar Save/Undo instead of OK/reset

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-24 06:15:28 -07:00
Dirk Hohndel
90a24255b2 Correctly add new weight / cylinder types, even when hitting 'tab'
We now detect if a weight / cylinder with this description exists and if
not add it on the fly. We also remember the additional values (weight and
size / workingpressure) for new entries and take the values for these
fields into account when autocompleting.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-23 23:26:17 -07:00
Dirk Hohndel
01a3bd2cc6 Add weightsystem delegate to enable editing of weightsystem
This is very much analogous to the way cylinders are implemented.
That means that just like with cylinders, if the user enters a new type
and hits 'tab' before hitting 'enter', Subsurface will crash.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-23 21:36:33 -07:00
Dirk Hohndel
ecbcd4db47 Enable the weightsystem info and move the declarations to dive.h
Having the tank_info declared in models.cpp seemed unintuitive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-23 21:33:19 -07:00
Dirk Hohndel
8d359f8e57 Remove obsolete slots
The .ui components were removed in commit 0c7a575f7b3b ("Rework on the
Equipment tab to make it look more Modern.") but the "automagic" slots
were still here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-23 18:35:04 -07:00
Dirk Hohndel
d273694954 Allow the CylindersModel delegate to pass data in without unit conversions
With this we should have tank editing mostly done.

See #122

(it's not quite fixed, we need the equivalent code for weight systems)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-23 13:31:46 -07:00
Tomaz Canabrava
87d3cd5234 Also changes the size and working pressure of the cylinders
this is more a 'Well, this is how we do it' than an actuall
good commit. I'm probably using the wrong conversion paradigm
( none ) to convert the data from psi / bar and such, it
changes the model with wrong data.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-23 15:59:12 -03:00
Tomaz Canabrava
babbfa9204 Added support for Completing on the Cylinder Type delegate
I had to immprove the TankInfoModel with two new methods,
insertRows and setData, because the delegate used this
model to show what kind of Tanks we are offering.
Since the user can enter a new type of Tank, it's important
to add this tank to all lists using the delegates.

I Also added two new methods on the delegate itself,
to correctly shows the data, and set the data on the
model. This also will help dirk with a working example
on how to edit things while using a delegate.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-23 15:33:20 -03:00
Dirk Hohndel
c917a99eb2 Implement default dive computer and device
The data is saved in the settings and the correct dive computer (vendor
and product) and device are picked when the download dialog is openend.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 23:24:33 -07:00
Dirk Hohndel
115e5e5fbc The never ending, futile fight for whitespace consistency
I just need to write a tool that does this...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 21:31:45 -07:00
Dirk Hohndel
7757363953 Re-enable dive computer selectiom
This had been disabled by some redraw optimizations in commit
81406b80c6ec ("Fix loading a second dive, after the first file was
loaded."). We need to redraw the plot not only if the dive changed but
also if the selected divecomputer changed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 20:59:50 -07:00
Dirk Hohndel
33135e37a5 Start editing Dive Notes when clicking on Rating or Visibility
Those widgets respond to MouseButtonPress and not FocusIn.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 20:00:26 -07:00
Dirk Hohndel
a5b14304f2 Merge branch 'fixResizeEvent' of https://github.com/tcanabrava/subsurface 2013-05-22 19:51:00 -07:00
Dirk Hohndel
7bf07b890a Small fixes to the model
Prevent a crash when no cylinder type description is set.

Correctly calculate the cylinder volume.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 16:22:21 -07:00
Dirk Hohndel
76903849de Get the math right for cylinder model setData function
This is a fun one.

We only want to mark the divelist changed if the user actually changed
something. So we try really hard to compare what was entered with what was
there and only if it is different do we overwrite existing values and
record this as a change to the divelist.

An additional challenge here is the fact that the user needs to enter a
working pressure before they can enter a size (when in cuft mode). That is
not really intuitive. We work around this by assuming working pressure is
3000psi if a size is given in cuft - but then if the user changes the
working pressure, that changes the volume. Now going back and changing the
volume again does the trick. Or enter the working pressure FIRST and then
the volume...

This also changes the incorrect MAXPRESSURE to WORKINGPRESSURE and uses
the text WorkPress in English (Gtk code used MaxPress which was simply
wrong - this is just the design pressure or working pressure, not some
hard maximum. In fact, people quite commonly "overfill" these tanks.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 14:51:41 -07:00
Tomaz Canabrava
fac8868903 Fixed update the plot as we resize the view.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-22 16:21:07 -03:00
Dirk Hohndel
63b6f7d5a2 Merge branch 'comboBoxDelegate' of https://github.com/tcanabrava/subsurface 2013-05-22 12:14:06 -07:00