diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-07-17 20:18:14 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-18 10:14:27 -0700 |
commit | d3c0a723b82337fcf2bd0e129d3a6855c90e4825 (patch) | |
tree | 067372639fc6f17fdd82717de2efc6a581725106 /qt-ui | |
parent | 774a785a99c8ec2910c346de0ad40eb65f1948f6 (diff) | |
download | subsurface-d3c0a723b82337fcf2bd0e129d3a6855c90e4825.tar.gz |
Save / Restore the QPainter before operations.
I don't know if this fixes anything, but it is asked of us to
do that by the Qt docs.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/modeldelegates.cpp | 2 | ||||
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index c0b0f4dda..b11c4614d 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -353,6 +353,7 @@ void ProfilePrintDelegate::paint(QPainter *painter, const QStyleOptionViewItem & const int row = index.row(); const int col = index.column(); + painter->save(); // grid color painter->setPen(QPen(QColor(0xff999999))); // horizontal lines @@ -366,6 +367,7 @@ void ProfilePrintDelegate::paint(QPainter *painter, const QStyleOptionViewItem & if (col == 4 || (col == 0 && row > 5)) painter->drawLine(rect.topRight(), rect.bottomRight()); } + painter->restore(); QStyledItemDelegate::paint(painter, option, index); } diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 1c8a13fb5..cb5cec58b 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -120,6 +120,7 @@ void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o if (polygon().isEmpty()) return; + painter->save(); // This paints the Polygon + Background. I'm setting the pen to QPen() so we don't get a black line here, // after all we need to plot the correct velocities colors later. setPen(Qt::NoPen); @@ -138,6 +139,7 @@ void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o painter->setPen(pen); painter->drawLine(poly[i - 1], poly[i]); } + painter->restore(); } int DiveProfileItem::maxCeiling(int row) @@ -325,8 +327,10 @@ void DiveHeartrateItem::paint(QPainter *painter, const QStyleOptionGraphicsItem { if (polygon().isEmpty()) return; + painter->save(); painter->setPen(pen()); painter->drawPolyline(polygon()); + painter->restore(); } void DiveHeartrateItem::settingsChanged() @@ -421,8 +425,10 @@ void DiveTemperatureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte { if (polygon().isEmpty()) return; + painter->save(); painter->setPen(pen()); painter->drawPolyline(polygon()); + painter->restore(); } void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) @@ -516,6 +522,7 @@ void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte QPen pen; pen.setCosmetic(true); pen.setWidth(2); + painter->save(); struct plot_data *entry = dataModel->data().entry; Q_FOREACH (const QPolygonF &poly, polygons) { for (int i = 1, count = poly.count(); i < count; i++, entry++) { @@ -524,6 +531,7 @@ void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte painter->drawLine(poly[i - 1], poly[i]); } } + painter->restore(); } DiveCalculatedCeiling::DiveCalculatedCeiling() : is3mIncrement(false), gradientFactor(new DiveTextItem(this)) @@ -711,6 +719,7 @@ void PartialPressureGasItem::modelDataChanged(const QModelIndex &topLeft, const void PartialPressureGasItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { const qreal pWidth = 0.0; + painter->save(); painter->setPen(QPen(normalColor, pWidth)); painter->drawPolyline(polygon()); @@ -718,6 +727,7 @@ void PartialPressureGasItem::paint(QPainter *painter, const QStyleOptionGraphics painter->setPen(QPen(alertColor, pWidth)); Q_FOREACH (const QPolygonF &poly, alertPolygons) painter->drawPolyline(poly); + painter->restore(); } void PartialPressureGasItem::setThreshouldSettingsKey(const QString &threshouldSettingsKey) |