Use QStringList::contains instead of iterating the list.
Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code used a QString instead of a const QString&, wich
mean that each foreach step the string was copied.
added a break on the if-found-true to stop the foreach, since
we already found it.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch attempts to fix the 'click goes to 0,0' bug on the
globe. it moves a bit of code around and I particulary don't
like the way that we are dealing with 'EditMode', I think I'll
refactor that for 4.1. We are alredy dealing with a bunch
of states, maybe a State Machine will help on removing code-complexity.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the 'mouseClicked' didn't get any dives at the click-geolocation,
ignore it and do not try to select an empty selection. this was
causing a lot of issues when map-navigation.
Also, good deal of code cleanup.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This piece of code didn't need to be on the for-loop, so
let's remove it out of it.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code ( slow++ ) ignored that each new dive-selection
we recreated all information on the profile window, so this
version ( a lot more verbose, I know. ) will ignore all dives
that are being selected and will only send the 'dive was selected'
information in the last line of the algorithm, instead of calling
it for each dive on the list of 'to be selected' dives.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch adds a context menu to set the dive location
via the globe, being the dive with a coordinate or not.
It also fixes setting the dive location on edit mode.
Fixes: #315
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Simply clear the edited dive (regardless of whether it's set) and hide the
message if visible. The previous code was a little too convoluted...
Fixes#305
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We need the marble data to go into a subdirectory of /usr/share/subsurface
and we need to search for both data and marbledata when trying to find the
theme.
Fixes#310
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The fix for 'double click on the map shouldn't zoom' had broken the
selection of the current location for the selected dive, this patch
fixes that.
See #291
Signed-off-by: Vinicius Machado <vsmachado@gmail.com>
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Later we spacifically enable the scale, but Dirk asked me to
use the bare minimum of marble.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Marble is a weird piece of Qt software, it seems that it wasn't
thought of being a library when first written. Most of its features
are not achieved by subclassing && overriding one of Qt default methods,
instead we need to eventFilter for almost everything ( which is a pain,
and a bit error prone - see our combo box delegate *puke*. )
This one's ready, only one thing though - if we want to implement
our own context menu, we will need to use the eventFilter, and not
the contextMenuEvent.
Fixes#291
[Dirk Hohndel: this does not disable the context menu for me...]
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When modifying or adding a dive location on the globe widget while in dive
edit or dive add mode, we now show the modified / new location right away
on the globe (assuming a location name has been given). This makes it much
easier to manually reposition a dive location.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we are editing or adding a dive, the globe widget needs to act
differently. Instead of directly changing the lat/lon of selected dives,
it needs populate the coordinate text field as if this information was
entered by the user (effectively all it is is a way to more conveniently
enter coordinates).
As a side effect, this also allows us to change the location once it has
been added (you just need to go into dive edit mode to do so).
There is one weird issue that occasionally (and I can't quite reproduce
this) I get lat/lon very close to 0/0 (as if the globe widget was centered
on 0/0 and not on whatever it is actually showing). That still needs to be
addressed.
Fixes#239Fixes#131
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch makes it possible to set the coordinates on the map for
all selected dives. Note however that after a coordinate is set,
user cannot edit it unless he multi-edit it with a dive that doesn't
have coordinate's set. this is just because it's missing a 'edit coords'
button.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch just reverts some wrong changes that I'v done on a
past commit ( sorry ) and correctly handles the selectDive,
by using a IDX instead of the dive pointer, as dirk told me
it's extremely error-prone since the pointer can change.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This caused us to get royally confused when manually adding a dive and
trying to set the location through the marble widget.
Fixes # 229
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Marble had a bug on the way it treats zoom level, there's
no way for it to find out if it's user-input or algorithm input
and when a user clicks on a dive, it spins and centers on it,
but if the user clicks on another dive when it's still spinning,
it will get the zoom in the actual state ( spinning, usually zoom
is far away from the first position ) and continue the spin to the
other position.
This patch works by saving the first location and triggering a
helper function with a timer that will only update the zoom level
if the timer is not active ( and thus, will not get the bugged
zoom state set by the animation. ).
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I just went thru all of subsurface code removing
some whitespaces issues and trying to make the
code prettyer, I also removed a few QString issues.d
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This patch fixes the display of subsurface in smaller
screens by creating ScrollArea containers that are
now englobbing each of the Tab-pages and the Planner
Widget. Some of those widgets were pretty big by the
amount of things on it and it was too big for small
( 14" and 15" ) screens.
This seems to fix it, and looks good both on Gtk+ and
Oxygen styles.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
1) Make a call mark_divelist_changed(TRUE) when the user adds new
cylinder or weight entries.
2) Call mark_divelist_changed(FALSE) in
MainWindow::on_actionClose_triggered() so that each time after
a file is closed or a new one is created it does not ask immediately
the user for a save confirmation for the blank file/divelist.
3) Call mark_divelist_changed(TRUE) once a dive's geo location
has changed in GlobeGPS::changeDiveGeoPosition().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way the map selection works like normal selections do. Except we
don't do "ranged" selections (shift-click) for fairly obvious reasons.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I guess we should support de-selecting dives this way too, but right now
the interfaces only do selection.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We'll want to enhance this: better logic for which dives are near the
selection, and it's probably best to have a "control-click" that adds
the dives to the selection rather than deselecting all the old ones.
But it's already useful.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Not showing them at all was a little too blunt of an instrument. There
likely are dive spots with the same name at different resorts. And even
at the same resort you could have multiple morings for the same dive
site.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Things got broken. Again. We no longer kept track of the selected dives in
our structures which broke statistics.
This attempts to fix that, but appears to still have a bug when selecting
trips. Sometimes this results in 0 dives being selected according to our
data structures, while Qt happily shows all dives of the trip as seected.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds a helper function to determine the Subsurface data directory
(are we running from build directory? installed on Linux? installed on
Mac? - still need to add support for Windows). This same function is
then used by both the setup for Marble and for the help browser.
This assumes that the user-manual.html file has actually been built and
installed (which we don't do by default with the current Makefile).
Right now there are rendering issues with our manual in the help browser
widget - I'm sure this can be fixed...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Following Dirk's commit ae2c132, add support for custom google sat
data in a MacOSX app bundle
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
First try if Google Sat is already installed as a provider (and just use
it if it is). Then use the executable path to make an educated guess where
these files might be found as part of Subsurface.
We now install the necessary directory tree under
$(DESTDIR)/usr/share/subsurface/marbledata
Still far from perfect - but this should work at least on Linux. MacOS
will need a different modifier for the path and Windows I haven't even
thought about, yet.
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>
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>
This addresses two issues:
- the kMessageWidget did not word wrap, so if it was wider then the Globe
widget the Globe would expand (and divelist shrink) when the user
switched from a dive with location to a dive without location
- the code was also too aggressive removing and redrawing the message
widget when switching from dive to dive. with this change we only hide
the widget if the next dive has a location (and only show it if it isn't
shown already). We also hide the message if no dive is selected.
Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a major hack. Debian appears to be missing a necessary header file
for Marble to work correctly. We include this header file for now and hack
the Configure process to recognize that we are on Debian and force using
our local copy of the header file in that case.
This may be needed on Ubuntu as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Borrowed the code from KMessageWidget from Aurelian Gateau, Kdelibs,
to better show passive information and notifications. instead of a
popup blowing in the user's face, a nice, animated and well designed
widget will gracefully fade-in, show the notes, and fade out when
not needed anymore.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Added the possibility to change the coordinates of a dive.
it's too intrusive in the moment, but it was a proof
of concept. so I'll commit as is and try to find a better
way to warn the user what's going on in the future, using
something less terrible than a popup exploding in his face.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
The marble widget now shows the dive locations
and also will center on the dive that the user clicked
in the dive list.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Adds preliminary support for marble widget, alongside with the
dive list. my idea is to let the view stay there at the left of the
dive list since we got a lot of unused space and a globe is something
nice to have - so you can look around where did you dived, the
dives near the one that's currectly selected, and so on.
I'm not using OpenStreetMaps right now, but a good thing about
marble is that it is skinnable - so for instance, a dive school
could present a dive lesson using subsurface with a globe from the
1600, to make it feel like 'history'.
This version will only compile to Qt4.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>