From fbd00c6b0da55b4c7add823c80e3d4afaf452544 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 11 Jul 2014 10:26:22 -0700 Subject: Planner: add event that explains when planner turns red I don't know why the plot_info was walked backwards - for our purposes walking forward needs to make a lot more sense. And the event nicely goes away when the diveplan gets modified and the displayed_dive gets reset. Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveprofileitem.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 78a87ade2..cc4989d33 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -9,6 +9,7 @@ #include "preferences.h" #include "helpers.h" #include "diveplanner.h" +#include "libdivecomputer/parser.h" #include #include @@ -151,6 +152,7 @@ int DiveProfileItem::maxCeiling(int row) void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { + bool eventAdded = false; if (!shouldCalculateStuff(topLeft, bottomRight)) return; @@ -164,12 +166,17 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI int currState = qobject_cast(scene()->views().first())->currentState; if (currState == ProfileWidget2::PLAN) { - plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1; - for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) { + plot_data *entry = dataModel->data().entry; + for (int i = 0; i < dataModel->rowCount(); i++, entry++) { int max = maxCeiling(i); // Don't scream if we violate the ceiling by a few cm - if (entry->depth < max - 100) + if (entry->depth < max - 100) { profileColor = QColor(Qt::red); + if (!eventAdded) { + add_event(&displayed_dive.dc, entry->sec, SAMPLE_EVENT_CEILING, -1, max / 1000, "planned waypoint above ceiling"); + eventAdded = true; + } + } } } -- cgit v1.2.3-70-g09d2