mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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:
parent
bc7b221498
commit
629a1ea0f9
2 changed files with 14 additions and 17 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
AbstractProfilePolygonItem::AbstractProfilePolygonItem(): QObject(), QGraphicsPolygonItem(),
|
AbstractProfilePolygonItem::AbstractProfilePolygonItem(): QObject(), QGraphicsPolygonItem(),
|
||||||
hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1)
|
hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1)
|
||||||
|
@ -42,6 +43,7 @@ void AbstractProfilePolygonItem::setModel(DivePlotDataModel* model)
|
||||||
{
|
{
|
||||||
dataModel = model;
|
dataModel = model;
|
||||||
connect(dataModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelDataChanged()));
|
connect(dataModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelDataChanged()));
|
||||||
|
connect(dataModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelDataChanged()));
|
||||||
modelDataChanged();
|
modelDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,11 +415,9 @@ void DiveReportedCeiling::modelDataChanged()
|
||||||
|
|
||||||
void DiveReportedCeiling::preferencesChanged()
|
void DiveReportedCeiling::preferencesChanged()
|
||||||
{
|
{
|
||||||
if (prefs.profile_dc_ceiling) {
|
QSettings s;
|
||||||
setVisible(prefs.profile_red_ceiling);
|
s.beginGroup("TecDetails");
|
||||||
} else {
|
setVisible(s.value("redceiling").toBool());
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveReportedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
void DiveReportedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
|
|
@ -107,6 +107,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
||||||
scene()->addItem(item);
|
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);
|
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||||
|
|
||||||
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
|
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
|
||||||
|
@ -394,18 +403,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
|
||||||
scene()->addItem(tissueItem);
|
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();
|
emit startProfileState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue