aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-23 15:35:32 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-23 21:11:14 -0800
commit2c2d3351ac3718c13adab88c9b9b9f73ab17aced (patch)
tree110326fd6d80a8dda75dc0061fd1b509293a8eb6 /qt-ui/profile
parent2f0b778f92f9c604535851201090f22e54c20f9a (diff)
downloadsubsurface-2c2d3351ac3718c13adab88c9b9b9f73ab17aced.tar.gz
Move the creation of the Gas Pressure item to the constructor
This makes the Gas Pressure Item a 'cached' item, when the dive changes, the item will regenerate the drawing based on it's model. 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, 10 insertions, 14 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 0768f38f6..c2c95bd89 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -258,7 +258,7 @@ void DiveTemperatureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte
void DiveGasPressureItem::modelDataChanged()
{
// We don't have enougth data to calculate things, quit.
- if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1)
+ if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1 || dataModel->rowCount() == 0)
return;
int last_index = -1;
int lift_pen = false;
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 3aa1acdae..e21af21bd 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -137,6 +137,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
scene()->addItem(tissueItem);
}
+ gasPressureItem = new DiveGasPressureItem();
+ gasPressureItem->setHorizontalAxis(timeAxis);
+ gasPressureItem->setVerticalAxis(cylinderPressureAxis);
+ gasPressureItem->setModel(dataModel);
+ gasPressureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE);
+ gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
+ gasPressureItem->setZValue(1);
+ scene()->addItem(gasPressureItem);
+
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
@@ -381,19 +390,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
temperatureItem->setZValue(1);
scene()->addItem(temperatureItem);
- if(gasPressureItem){
- scene()->removeItem(gasPressureItem);
- delete gasPressureItem;
- }
- gasPressureItem = new DiveGasPressureItem();
- gasPressureItem->setHorizontalAxis(timeAxis);
- gasPressureItem->setVerticalAxis(cylinderPressureAxis);
- gasPressureItem->setModel(dataModel);
- gasPressureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE);
- gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
- gasPressureItem->setZValue(1);
- scene()->addItem(gasPressureItem);
-
diveComputerText->setText(currentdc->model);
diveComputerText->animateMoveTo(1 , sceneRect().height());
emit startProfileState();