aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp3
-rw-r--r--qt-ui/profile/profilewidget2.cpp23
2 files changed, 12 insertions, 14 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index f00fff688..774938c95 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -107,6 +107,9 @@ void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
void DiveProfileItem::modelDataChanged()
{
+ if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1 || dataModel->rowCount() == 0)
+ return;
+
AbstractProfilePolygonItem::modelDataChanged();
if (polygon().isEmpty())
return;
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 2f607590b..2f7505d22 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -155,6 +155,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
temperatureItem->setZValue(1);
scene()->addItem(temperatureItem);
+ diveProfileItem = new DiveProfileItem();
+ diveProfileItem->setHorizontalAxis(timeAxis);
+ diveProfileItem->setVerticalAxis(profileYAxis);
+ diveProfileItem->setModel(dataModel);
+ diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH);
+ diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
+ diveProfileItem->setZValue(0);
+ scene()->addItem(diveProfileItem);
+
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
@@ -356,20 +365,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth));
dataModel->setDive(current_dive, pInfo);
- if (diveProfileItem) {
- //diveProfileItem->animateDelete();
- scene()->removeItem(diveProfileItem);
- delete diveProfileItem;
- }
- diveProfileItem = new DiveProfileItem();
- diveProfileItem->setHorizontalAxis(timeAxis);
- diveProfileItem->setVerticalAxis(profileYAxis);
- diveProfileItem->setModel(dataModel);
- diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH);
- diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
- diveProfileItem->setZValue(0);
- scene()->addItem(diveProfileItem);
-
qDeleteAll(eventItems);
eventItems.clear();