aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-22 18:25:35 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-22 13:16:31 -0800
commitf8a4f8de8159bb60235af170d2acb603ec40ccad (patch)
treee03da0dd9782ca35cc0577783dbca22e8bb144fe /qt-ui/profile
parent629a1ea0f983b38ead21883d87eabd9cda16c9ad (diff)
downloadsubsurface-f8a4f8de8159bb60235af170d2acb603ec40ccad.tar.gz
Do not delete / new object that can be cached.
This way we will always have this object on screen, and as soon as the model changes, it's contents will change. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp2
-rw-r--r--qt-ui/profile/profilewidget2.cpp22
2 files changed, 11 insertions, 13 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 5599b7eaf..e740640e2 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -367,6 +367,8 @@ void DiveCalculatedCeiling::modelDataChanged()
AbstractProfilePolygonItem::modelDataChanged();
// Add 2 points to close the polygon.
QPolygonF poly = polygon();
+ if (poly.isEmpty())
+ return;
QPointF p1 = poly.first();
QPointF p2 = poly.last();
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index faeed2065..fd579a5c4 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -116,6 +116,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
reportedCeiling->setZValue(1);
scene()->addItem(reportedCeiling);
+ diveCeiling = new DiveCalculatedCeiling();
+ diveCeiling->setHorizontalAxis(timeAxis);
+ diveCeiling->setVerticalAxis(profileYAxis);
+ diveCeiling->setModel(dataModel);
+ diveCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
+ diveCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
+ diveCeiling->setZValue(1);
+ scene()->addItem(diveCeiling);
+
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
@@ -373,19 +382,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
gasPressureItem->setZValue(1);
scene()->addItem(gasPressureItem);
- if(diveCeiling){
- scene()->removeItem(diveCeiling);
- delete diveCeiling;
- }
- diveCeiling = new DiveCalculatedCeiling();
- diveCeiling->setHorizontalAxis(timeAxis);
- diveCeiling->setVerticalAxis(profileYAxis);
- diveCeiling->setModel(dataModel);
- diveCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
- diveCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
- diveCeiling->setZValue(1);
- scene()->addItem(diveCeiling);
-
diveComputerText->setText(currentdc->model);
diveComputerText->animateMoveTo(1 , sceneRect().height());