mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
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 <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
555ca8245d
commit
563c39b822
2 changed files with 10 additions and 14 deletions
|
@ -192,7 +192,7 @@ DiveTemperatureItem::DiveTemperatureItem()
|
|||
void DiveTemperatureItem::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;
|
||||
|
||||
qDeleteAll(texts);
|
||||
|
|
|
@ -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<dive*> 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();
|
||||
|
|
Loading…
Add table
Reference in a new issue