summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-11 10:26:22 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-11 10:26:22 -0700
commitfbd00c6b0da55b4c7add823c80e3d4afaf452544 (patch)
tree29bbc4808b0ee0ba25716a5580c6d04304137c5d /qt-ui/profile
parent6c9aaf406ad4dd7e5eb208a376def396a96a69d6 (diff)
downloadsubsurface-fbd00c6b0da55b4c7add823c80e3d4afaf452544.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp13
1 files changed, 10 insertions, 3 deletions
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 <QPen>
#include <QPainter>
@@ -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<ProfileWidget2 *>(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;
+ }
+ }
}
}