In commit beb4ed38f264 ("Add a "sort role" for sorting the dive list")
Linus forgot to add a case for the rating value.
Now all columns sort correctly.
With this I think we can close the bug...
Fixes#111
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Tomaz convinced me (with help from Linus) that it might be a good idea
to go with the compacter "single line" case statements in some specific
instances where this makes the code much more compact and easier to
read.
While doing that I changed Linus' code to do 'retVal = ...; break;'
instead of just 'return ...;' - this is more consistent and makes
debugging a little easier.
And while doing all that, I also cleaned up divelistview.cpp a little bit.
And removed an unused variable.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>