From 563c39b8221ac2e3730c9f51a0e890b42af8ca78 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 23 Jan 2014 15:44:12 -0200 Subject: Moved the temperature item as a 'Cache' This patch moves the temperature item as a cache that will be updated as the model updates, instead of deleting / recreating it everytime the dive changes. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'qt-ui/profile/profilewidget2.cpp') diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index e21af21bd..2f607590b 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -146,6 +146,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : gasPressureItem->setZValue(1); scene()->addItem(gasPressureItem); + temperatureItem = new DiveTemperatureItem(); + temperatureItem->setHorizontalAxis(timeAxis); + temperatureItem->setVerticalAxis(temperatureAxis); + temperatureItem->setModel(dataModel); + temperatureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE); + temperatureItem->setHorizontalDataColumn(DivePlotDataModel::TIME); + temperatureItem->setZValue(1); + scene()->addItem(temperatureItem); + background->setFlag(QGraphicsItem::ItemIgnoresTransformations); //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; @@ -377,19 +386,6 @@ void ProfileWidget2::plotDives(QList dives) event = event->next; } - if(temperatureItem){ - scene()->removeItem(temperatureItem); - delete temperatureItem; - } - temperatureItem = new DiveTemperatureItem(); - temperatureItem->setHorizontalAxis(timeAxis); - temperatureItem->setVerticalAxis(temperatureAxis); - temperatureItem->setModel(dataModel); - temperatureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE); - temperatureItem->setHorizontalDataColumn(DivePlotDataModel::TIME); - temperatureItem->setZValue(1); - scene()->addItem(temperatureItem); - diveComputerText->setText(currentdc->model); diveComputerText->animateMoveTo(1 , sceneRect().height()); emit startProfileState(); -- cgit v1.2.3-70-g09d2