diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-22 17:54:24 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-22 13:13:20 -0800 |
commit | 629a1ea0f983b38ead21883d87eabd9cda16c9ad (patch) | |
tree | 3559eb907ab49d56acc4dbe35b9231c3f42016da /qt-ui/profile | |
parent | bc7b221498e6f07c26fd8455f9992657f0a1a162 (diff) | |
download | subsurface-629a1ea0f983b38ead21883d87eabd9cda16c9ad.tar.gz |
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>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 10 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 21 |
2 files changed, 14 insertions, 17 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 1c49b7eee..5599b7eaf 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -15,6 +15,7 @@ #include <QDebug> #include <QApplication> #include <QGraphicsItem> +#include <QSettings> AbstractProfilePolygonItem::AbstractProfilePolygonItem(): QObject(), QGraphicsPolygonItem(), hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1) @@ -42,6 +43,7 @@ void AbstractProfilePolygonItem::setModel(DivePlotDataModel* model) { dataModel = model; connect(dataModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelDataChanged())); + connect(dataModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelDataChanged())); modelDataChanged(); } @@ -413,11 +415,9 @@ void DiveReportedCeiling::modelDataChanged() void DiveReportedCeiling::preferencesChanged() { - if (prefs.profile_dc_ceiling) { - setVisible(prefs.profile_red_ceiling); - } else { - setVisible(false); - } + QSettings s; + s.beginGroup("TecDetails"); + setVisible(s.value("redceiling").toBool()); } void DiveReportedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 9fc64a0c1..faeed2065 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -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(); } |