This should fix the infinite recursion on OSX and also clean a lot of
code, which is also very nice. <3
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is step one of many to use gasmix instead of int o2/he.
Right now some of these changes look ridiculous because after changing a
few lines we immediately go back to o2 = get_o2(gas). The reason is that I
wanted to convert a hand full of functions at a time. So in this commit I
only change validate_gas(), get_gas_from_events() and get_gasidx() to use
a struct gasmix instead of int o2, int he.
This state builds and survived some mild testing. Let's continue on top of
that.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We should never pass permille values around as integers. And we shouldn't
have to decode the stupid value in more than one place.
This doesn't tackle all the places where we access O2 and He "too early"
and should instead keep passing around a gaxmix. But it's a first step.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Staring at the stack trace it seems that it gets into an infinite
recursion when trying to recalculate after being alerted to a change on
the ruler. I cannot recreate this here (not on Linux, not on Mac), but
here's a random attempt to prevent the issue: simply refuse to recalculate
the ruler while in Add or Plan mode.
Crude, but might show us if this really is the issue. Otherwise it's easy
enough to revert this change. The qDebug() in there should tell us if
people on a Mac do indeed see this even without moving the ruler around in
Add or Plan mode.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We need to create them, even if we don't display ( only because it
was a pain to correctly track them from the model ) - so, hide them
if it's not entered by mouse, but a deco one.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When switching from PLAN or ADD mode to PROFILE, we
kept the dive handlers visible, not anymore.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make the infobox invisible in planner (it really doesn't provide a lot of
useful info while planning a dive and more likely gets in the way).
Make the calculated ceiling always visible in planner and add mode.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
for some reason the next selected dive is NULL after cancelling the
plan. I'm investigating.
This patch fixes the show of the empty profile and it also untangles
some parts of the code, keeping the mainwindow where it should belong
: the mainwindow.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch paints the dive red if the user is breaking ceiling
on the planner - it's quite fast, it analizes the depth over the
max(tissue_1 .. tissue_16) and changes the color of the profile.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes the movements from the lines when added / removed
SO much better.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Added a flag to only recalculate the axis when needed.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is working in the wrong way, mostly because I'm setting the
plannermodel to ADD state ( and the planner graphic to the
correct PLAN state ), but I don't know why - when on PLAN state
on the model, things just don't work.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This correctly enables the planner on the new profile,
but it doesn't triggers the correct paint on the canvas.
[Dirk Hohndel: remove other remnants of the disabled planner as well]
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Only a tiny bit of poke around the contextMenuEvent - the events
of the planner are dealt by the QGraphicsItem, and this makes the
logic pretty easy to follow. :)
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
[Dirk Hohndel: combined two commits into one and cleaned up some
whitespace issues]
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The code removed was already ported to the New Profile.
We managed to clean quite a bit. huhhy
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch makes mouse dragging work as it should, a tiny
bit different than the old version, but I think it's a better
way. What's missing: Keyboard actions.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The QGraphicsView system moves every selected item when the user
clicks and drags one. This patch makes a cache of all selected
items and removes the selection on them. When the user stops dragging
the Notification, the selection is restored.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit makes the planner actually work. There ar still
a few edges, but oh, joy - the new Profile gave a very unexpected
and nice addition to it - Grab the last handler of the initial
dive, and move it to the right, or get any handler, and move it
to the bottom to see what I mean.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
But it doesn't move the handlers yet, and when you confirm it you also
must click on the dive to select it or the profile will show garbage.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This code adds the disconnections of temporaries. A temporary connection
is a connection that should be active only on a certain state, and we need
to clean that for the new state that will enter after.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Those two functions are important and necessary for the Planner, they
create and remove the little balls that act as handlers so the profile
can be edited with the mouse.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch adds a signal to MainTab, that should be removed from there
when we finish the rework on the edit part, to go to the edit classes,
but in the meantime, let's keep it there.
The signal is connected to the ProfileWidget in a way that the end of the
edit will also trigger the profile to go back to ProfileState (show the
dive, if there's any) or empty Profile (if there's none).
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is highly broken in many ways - but it's the right first step.
I ported two of the most important methods from the old profile and now if
you are in add dive mode, double clicking on the new profile will
correctly add a handler on the planned dive. To see and move the handler
around, however, you need to activate the old planner.
Next step: add the handlers on the new profile.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The code checked if dest and source existed before trying to call an
method on them, but dest and source are created on the constructor,
and thus, the if is dummy.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As with any other graphics object, the settings for the ruler
should be managed by the ruler, clearing up the Profile logic
and making the code easier to read.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We used both preferencesChanged and settingsChanged in different
methods and classes to mean the same thing, this adds consistency.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The list of preferences that should trigger a full repaint are at the top
of this method, *if* this introduces a bug it is because some of the
preferences are not being correctly triaged yet and that needs to be
fixed. Regardless of that, now the profile will only enable / disable
the *ruler* instead of replotting everything.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The QSettings is a bit bloated on its use, so we are trying to narrow
down the amount of calls to it. We have a preferences struct, use that
instead.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
By moving the Hide/Show of the ruler to an internal method, we gain a bit
of codecleanuperism by removing a lot of unnecessary calls to their dest
and source drag-handlers.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The logic of removing the event was in the UI, and this makes
the code harder to test because we need to take into account
also the events that the interface is receiving, instead of
only relying on the algorithm to test.
so, now it lives in dive.h/.c and a unittest is easyer to make.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code replotted the whole dive, while what we really wanted was to
show the events. so just ->show() them.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The 'Hide Similar Events' function asked the Profile to replot eveything,
only because some events were hidden from the interface. Instead of that
we can simply hide the events since the graph will be the same.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If a dive has multiple dive computers we enable a special context menu
when the user right-clicks on the dive computer name AND is not already
showing the first dive computer. In that case we offer to make the
currently shown dive computer the first one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For most users this is no change at all. For the few who download from
multiple dive computers this now shows them which of them is the primary
dive computer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The original name was a really bad choice as we have a 'diveid' as part of
struct divecomputer - and that is not the diveid that is being used here.
Instead we use the 'id' member of struct dive which holds the "unique ID"
for this dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit renames getDiveById to get_dive_by_id, and it also removes the
Q_ASSERTS and if(!dive) return that the callers of this function were
calling. If it has a Q_ASSERT this means that the dive must exist,
so checking for nullness was bogus too. I've changed the assert (done
in a silly C-Way.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Same problem as the previous commit: toStdString() returns a temporary,
and c_str() will return a pointer to internal data, freed at the end of
the statement. So get the pointer to be strcpy'ed in the same statement.
Changed to toUtf8() to be more explicit about the encoding and to avoid
std::string
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I we are showing a calculated ceiling, then we have to replot the profile
after a preferences change as the gradient factors could have changed
which might change a calculated ceiling.
Also use the rulergraph preference instead of checking the settings
directly.
Fixes#511
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In commit bcdd6192fe ("Show translated event names in tooltip") I was
too aggressive in replacing the checking for event names with checking for
event types. It turns out that we are abusing an existing event type in
the planner (and use a different event name to mark the difference). By
just checking for the type this now caused incorrect information to be
displayed in the info box (a simply "PO2 warning" on a Suunto D9 could
turn into a "Bailing out to OC" notice).
The correct fix is to get our own range of SAMPLE_EVENT_xxx numbers from
libdivecomputer. Once we have those, we can do this the right way. For now
we just fall back to also checking the event name (which is what I wanted
to get away from so translated names don't trip us up).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The "is_air()" test works when we have the gases in permille, but not in
percent. In that case we can just check for He == 0 and O2 == 21.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order for this to work we need to compare against the event type
instead of the event name - which makes much more sense to do, anyway.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Having all the grid lines in the same color made things visually
confusing. To clean this up a little make the heartrate lines a light gray
color.
Fixes#484
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-Renaming prefs members for consistency.
-Changing references of QSettings to the prefs structure instead.
-Removing unused functions in pref.h were left over from an old version.
-Changing the data-type of bool members to short for consistency with other members.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>