diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-27 15:14:42 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-27 09:15:28 -0800 |
commit | c99089e1fa3b7eaccf3a49ea35bae0dacad04060 (patch) | |
tree | 49b6491b19ca1bd2feb9dbb245cc4269626add0a /qt-ui/profile/diveprofileitem.cpp | |
parent | a57f950b302cdd54e9a71736aaa9e761070ece41 (diff) | |
download | subsurface-c99089e1fa3b7eaccf3a49ea35bae0dacad04060.tar.gz |
Add settings awareness for the PP graph
This commit is rather big, and I forgot to cut it in pieces.
The first part creates a new 'calculate_gas_information' that will not
fill the profile_info->maxpp member ( that should be removed from it as
soon as the new dialog is finished ). The reason for that is that all of
the profile data will be calculated and the graph needs to update
dynamically, so whenever the settings changes, I ask for the model which
is the biggest graph and replot only the ones we need.
The second part adds a new animation function 'animdelete' to fade-out and
delete the item when it's done. the old function 'hide' did just that but
a hide shouldn't delete anything.
The third part is preferenes awareness for the PP graphs. I created two
new functions that receive the settings key for visibility and use the
QSettings to show / hide them. This also works quite well for the axis;
if no graph is visible, the axis will also hide itself.
The fourth part is colors. The pp graphs now have the correct colors.
And a bit of code cleanup too.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/diveprofileitem.cpp')
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 15944e990..b7682f9df 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -30,6 +30,7 @@ void AbstractProfilePolygonItem::preferencesChanged() void AbstractProfilePolygonItem::setHorizontalAxis(DiveCartesianAxis* horizontal) { hAxis = horizontal; + connect(hAxis, SIGNAL(sizeChanged()), this, SLOT(modelDataChanged())); modelDataChanged(); } @@ -43,13 +44,14 @@ 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(); } void AbstractProfilePolygonItem::setVerticalAxis(DiveCartesianAxis* vertical) { vAxis = vertical; + connect(vAxis, SIGNAL(sizeChanged()), this, SLOT(modelDataChanged())); + connect(vAxis, SIGNAL(maxChanged()), this, SLOT(modelDataChanged())); modelDataChanged(); } @@ -258,7 +260,6 @@ void DiveTemperatureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte painter->drawPolyline(polygon()); } - void DiveGasPressureItem::modelDataChanged() { // We don't have enougth data to calculate things, quit. @@ -484,7 +485,6 @@ void PartialPressureGasItem::modelDataChanged() QSettings s; s.beginGroup("TecDetails"); double threshould = s.value(threshouldKey).toDouble(); - for(int i = 0; i < dataModel->rowCount(); i++, entry++){ double value = dataModel->index(i, vDataColumn).data().toDouble(); int time = dataModel->index(i, hDataColumn).data().toInt(); @@ -493,17 +493,17 @@ void PartialPressureGasItem::modelDataChanged() if (value >= threshould) alertPoly.push_back(point); } - setPolygon(poly); /* createPPLegend(trUtf8("pN" UTF8_SUBSCRIPT_2),getColor(PN2), legendPos); */ } + void PartialPressureGasItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) -{//TODO: fix the colors. - painter->setPen(getColor(PN2)); +{ + painter->setPen(normalColor); painter->drawPolyline(polygon()); - painter->setPen(getColor(PN2_ALERT)); + painter->setPen(alertColor); painter->drawPolyline(alertPoly); } @@ -514,10 +514,22 @@ void PartialPressureGasItem::setThreshouldSettingsKey(const QString& threshouldS PartialPressureGasItem::PartialPressureGasItem() { - } void PartialPressureGasItem::preferencesChanged() { - AbstractProfilePolygonItem::preferencesChanged(); + QSettings s; + s.beginGroup("TecDetails"); + setVisible( s.value(visibilityKey).toBool() ); +} + +void PartialPressureGasItem::setVisibilitySettingsKey(const QString& key) +{ + visibilityKey = key; +} + +void PartialPressureGasItem::setColors(const QColor& normal, const QColor& alert) +{ + normalColor = normal; + alertColor = alert; } |