Don't recreate the tissues, but instead, reshape them.

This patch makes the Tissues be used as a 'cache', it will not
be deleted untill the program closes, but whenever a new dive is
selected, the old drawings of the tissues will be regenerated,

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-23 15:02:12 -02:00 committed by Dirk Hohndel
parent 803623042c
commit 2f0b778f92

View file

@ -125,6 +125,18 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
diveCeiling->setZValue(1);
scene()->addItem(diveCeiling);
for(int i = 0; i < 16; i++){
DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue();
tissueItem->setHorizontalAxis(timeAxis);
tissueItem->setVerticalAxis(profileYAxis);
tissueItem->setModel(dataModel);
tissueItem->setVerticalDataColumn(DivePlotDataModel::TISSUE_1 + i);
tissueItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
tissueItem->setZValue(1);
allTissues.append(tissueItem);
scene()->addItem(tissueItem);
}
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
@ -384,21 +396,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
diveComputerText->setText(currentdc->model);
diveComputerText->animateMoveTo(1 , sceneRect().height());
qDeleteAll(allTissues);
allTissues.clear();
for(int i = 0; i < 16; i++){
DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue();
tissueItem->setHorizontalAxis(timeAxis);
tissueItem->setVerticalAxis(profileYAxis);
tissueItem->setModel(dataModel);
tissueItem->setVerticalDataColumn(DivePlotDataModel::TISSUE_1 + i);
tissueItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
tissueItem->setZValue(1);
allTissues.append(tissueItem);
scene()->addItem(tissueItem);
}
emit startProfileState();
}