Move profile item to be used as cache.

the profile item should also use the model to know when to
change something, this makes it happen.

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 16:03:19 -02:00 committed by Dirk Hohndel
parent 563c39b822
commit 43cf4fb984
2 changed files with 12 additions and 14 deletions

View file

@ -107,6 +107,9 @@ void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
void DiveProfileItem::modelDataChanged() void DiveProfileItem::modelDataChanged()
{ {
if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1 || dataModel->rowCount() == 0)
return;
AbstractProfilePolygonItem::modelDataChanged(); AbstractProfilePolygonItem::modelDataChanged();
if (polygon().isEmpty()) if (polygon().isEmpty())
return; return;

View file

@ -155,6 +155,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
temperatureItem->setZValue(1); temperatureItem->setZValue(1);
scene()->addItem(temperatureItem); scene()->addItem(temperatureItem);
diveProfileItem = new DiveProfileItem();
diveProfileItem->setHorizontalAxis(timeAxis);
diveProfileItem->setVerticalAxis(profileYAxis);
diveProfileItem->setModel(dataModel);
diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH);
diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
diveProfileItem->setZValue(0);
scene()->addItem(diveProfileItem);
background->setFlag(QGraphicsItem::ItemIgnoresTransformations); background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
@ -356,20 +365,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth)); meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth));
dataModel->setDive(current_dive, pInfo); dataModel->setDive(current_dive, pInfo);
if (diveProfileItem) {
//diveProfileItem->animateDelete();
scene()->removeItem(diveProfileItem);
delete diveProfileItem;
}
diveProfileItem = new DiveProfileItem();
diveProfileItem->setHorizontalAxis(timeAxis);
diveProfileItem->setVerticalAxis(profileYAxis);
diveProfileItem->setModel(dataModel);
diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH);
diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
diveProfileItem->setZValue(0);
scene()->addItem(diveProfileItem);
qDeleteAll(eventItems); qDeleteAll(eventItems);
eventItems.clear(); eventItems.clear();