Simplify the code for the reported ceiling.

The reported ceiling now behaves better by not being deleted / recreated,
instead it uses the same object and connects to the model to know when to
regenerate its plot.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-01-22 17:54:24 -02:00 committed by Dirk Hohndel
parent bc7b221498
commit 629a1ea0f9
2 changed files with 14 additions and 17 deletions

View file

@ -107,6 +107,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
scene()->addItem(item);
}
reportedCeiling = new DiveReportedCeiling();
reportedCeiling->setHorizontalAxis(timeAxis);
reportedCeiling->setVerticalAxis(profileYAxis);
reportedCeiling->setModel(dataModel);
reportedCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
reportedCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
reportedCeiling->setZValue(1);
scene()->addItem(reportedCeiling);
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
@ -394,18 +403,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
scene()->addItem(tissueItem);
}
if(reportedCeiling){
scene()->removeItem(reportedCeiling);
delete reportedCeiling;
}
reportedCeiling = new DiveReportedCeiling();
reportedCeiling->setHorizontalAxis(timeAxis);
reportedCeiling->setVerticalAxis(profileYAxis);
reportedCeiling->setModel(dataModel);
reportedCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
reportedCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
reportedCeiling->setZValue(1);
scene()->addItem(reportedCeiling);
emit startProfileState();
}