diff --git a/src/areachart/qareaseries.cpp b/src/areachart/qareaseries.cpp index 13af5a1..4d21caf 100644 --- a/src/areachart/qareaseries.cpp +++ b/src/areachart/qareaseries.cpp @@ -249,10 +249,13 @@ void QAreaSeries::setPen(const QPen &pen) } } -QPen QAreaSeries::pen() const +QPen QAreaSeries::pen() const { Q_D(const QAreaSeries); - return d->m_pen; + if (d->m_pen == QChartPrivate::defaultPen()) + return QPen(); + else + return d->m_pen; } /*! @@ -273,7 +276,10 @@ void QAreaSeries::setBrush(const QBrush &brush) QBrush QAreaSeries::brush() const { Q_D(const QAreaSeries); - return d->m_brush; + if (d->m_brush == QChartPrivate::defaultBrush()) + return QBrush(); + else + return d->m_brush; } void QAreaSeries::setColor(const QColor &color) diff --git a/src/axis/qabstractaxis.cpp b/src/axis/qabstractaxis.cpp index 9afbe7e..e2dc872 100644 --- a/src/axis/qabstractaxis.cpp +++ b/src/axis/qabstractaxis.cpp @@ -458,7 +458,10 @@ void QAbstractAxis::setLinePen(const QPen &pen) */ QPen QAbstractAxis::linePen() const { - return d_ptr->m_axisPen; + if (d_ptr->m_axisPen == QChartPrivate::defaultPen()) + return QPen(); + else + return d_ptr->m_axisPen; } //TODO: remove me 2.0 @@ -474,7 +477,7 @@ void QAbstractAxis::setLinePenColor(QColor color) QColor QAbstractAxis::linePenColor() const { - return d_ptr->m_axisPen.color(); + return linePen().color(); } /*! @@ -522,7 +525,10 @@ void QAbstractAxis::setGridLinePen(const QPen &pen) */ QPen QAbstractAxis::gridLinePen() const { - return d_ptr->m_gridLinePen; + if (d_ptr->m_gridLinePen == QChartPrivate::defaultPen()) + return QPen(); + else + return d_ptr->m_gridLinePen; } void QAbstractAxis::setLabelsVisible(bool visible) @@ -554,7 +560,10 @@ void QAbstractAxis::setLabelsPen(const QPen &pen) */ QPen QAbstractAxis::labelsPen() const { - return d_ptr->m_labelsPen; + if (d_ptr->m_labelsPen == QChartPrivate::defaultPen()) + return QPen(); + else + return d_ptr->m_labelsPen; } /*! @@ -573,7 +582,10 @@ void QAbstractAxis::setLabelsBrush(const QBrush &brush) */ QBrush QAbstractAxis::labelsBrush() const { - return d_ptr->m_labelsBrush; + if (d_ptr->m_labelsBrush == QChartPrivate::defaultBrush()) + return QBrush(); + else + return d_ptr->m_labelsBrush; } /*! @@ -592,7 +604,10 @@ void QAbstractAxis::setLabelsFont(const QFont &font) */ QFont QAbstractAxis::labelsFont() const { - return d_ptr->m_labelsFont; + if (d_ptr->m_labelsFont == QChartPrivate::defaultFont()) + return QFont(); + else + return d_ptr->m_labelsFont; } void QAbstractAxis::setLabelsAngle(int angle) @@ -620,7 +635,7 @@ void QAbstractAxis::setLabelsColor(QColor color) QColor QAbstractAxis::labelsColor() const { - return d_ptr->m_labelsBrush.color(); + return labelsBrush().color(); } void QAbstractAxis::setTitleVisible(bool visible) @@ -652,7 +667,10 @@ void QAbstractAxis::setTitlePen(const QPen &pen) */ QPen QAbstractAxis::titlePen() const { - return d_ptr->m_titlePen; + if (d_ptr->m_titlePen == QChartPrivate::defaultPen()) + return QPen(); + else + return d_ptr->m_titlePen; } /*! @@ -669,9 +687,12 @@ void QAbstractAxis::setTitleBrush(const QBrush &brush) /*! Returns brush used to draw title. */ -QBrush QAbstractAxis::titleBrush() const +QBrush QAbstractAxis::titleBrush() const { - return d_ptr->m_titleBrush; + if (d_ptr->m_titleBrush == QChartPrivate::defaultBrush()) + return QBrush(); + else + return d_ptr->m_titleBrush; } /*! @@ -690,7 +711,10 @@ void QAbstractAxis::setTitleFont(const QFont &font) */ QFont QAbstractAxis::titleFont() const { - return d_ptr->m_titleFont; + if (d_ptr->m_titleFont == QChartPrivate::defaultFont()) + return QFont(); + else + return d_ptr->m_titleFont; } void QAbstractAxis::setTitleText(const QString &title) @@ -736,7 +760,10 @@ void QAbstractAxis::setShadesPen(const QPen &pen) */ QPen QAbstractAxis::shadesPen() const { - return d_ptr->m_shadesPen; + if (d_ptr->m_shadesPen == QChartPrivate::defaultPen()) + return QPen(); + else + return d_ptr->m_shadesPen; } /*! @@ -755,7 +782,10 @@ void QAbstractAxis::setShadesBrush(const QBrush &brush) */ QBrush QAbstractAxis::shadesBrush() const { - return d_ptr->m_shadesBrush; + if (d_ptr->m_shadesBrush == QChartPrivate::defaultBrush()) + return QBrush(Qt::SolidPattern); + else + return d_ptr->m_shadesBrush; } void QAbstractAxis::setShadesColor(QColor color) @@ -770,7 +800,7 @@ void QAbstractAxis::setShadesColor(QColor color) QColor QAbstractAxis::shadesColor() const { - return d_ptr->m_shadesBrush.color(); + return shadesBrush().color(); } void QAbstractAxis::setShadesBorderColor(QColor color) @@ -785,7 +815,7 @@ void QAbstractAxis::setShadesBorderColor(QColor color) QColor QAbstractAxis::shadesBorderColor() const { - return d_ptr->m_shadesPen.color(); + return shadesPen().color(); } diff --git a/src/barchart/qabstractbarseries.cpp b/src/barchart/qabstractbarseries.cpp index b9b026e..7fedd09 100644 --- a/src/barchart/qabstractbarseries.cpp +++ b/src/barchart/qabstractbarseries.cpp @@ -862,19 +862,19 @@ void QAbstractBarSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bo takeAtPos += step; takeAtPos -= (int) takeAtPos; } - if (forced || QChartPrivate::defaultBrush() == m_barSets.at(i)->brush()) + if (forced || QChartPrivate::defaultBrush() == m_barSets.at(i)->d_ptr->m_brush) m_barSets.at(i)->setBrush(ChartThemeManager::colorAt(gradients.at(colorIndex), takeAtPos)); // Pick label color from the opposite end of the gradient. // 0.3 as a boundary seems to work well. - if (forced || QChartPrivate::defaultBrush() == m_barSets.at(i)->labelBrush()) { + if (forced || QChartPrivate::defaultBrush() == m_barSets.at(i)->d_ptr->m_labelBrush) { if (takeAtPos < 0.3) m_barSets.at(i)->setLabelBrush(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 1)); else m_barSets.at(i)->setLabelBrush(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0)); } - if (forced || QChartPrivate::defaultPen() == m_barSets.at(i)->pen()) { + if (forced || QChartPrivate::defaultPen() == m_barSets.at(i)->d_ptr->m_pen) { QColor c = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0); m_barSets.at(i)->setPen(c); } diff --git a/src/barchart/qabstractbarseries.h b/src/barchart/qabstractbarseries.h index bd49f46..2370b26 100644 --- a/src/barchart/qabstractbarseries.h +++ b/src/barchart/qabstractbarseries.h @@ -76,6 +76,7 @@ protected: friend class HorizontalBarChartItem; friend class HorizontalStackedBarChartItem; friend class HorizontalPercentBarChartItem; + friend class BarSet; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/qbarset.cpp b/src/barchart/qbarset.cpp index 1ddd889..868e481 100644 --- a/src/barchart/qbarset.cpp +++ b/src/barchart/qbarset.cpp @@ -406,7 +406,10 @@ void QBarSet::setPen(const QPen &pen) */ QPen QBarSet::pen() const { - return d_ptr->m_pen; + if (d_ptr->m_pen == QChartPrivate::defaultPen()) + return QPen(); + else + return d_ptr->m_pen; } /*! @@ -426,7 +429,10 @@ void QBarSet::setBrush(const QBrush &brush) */ QBrush QBarSet::brush() const { - return d_ptr->m_brush; + if (d_ptr->m_brush == QChartPrivate::defaultBrush()) + return QBrush(); + else + return d_ptr->m_brush; } /*! @@ -446,7 +452,10 @@ void QBarSet::setLabelBrush(const QBrush &brush) */ QBrush QBarSet::labelBrush() const { - return d_ptr->m_labelBrush; + if (d_ptr->m_labelBrush == QChartPrivate::defaultBrush()) + return QBrush(); + else + return d_ptr->m_labelBrush; } /*! diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp index 0eb4490..be43148 100644 --- a/src/xychart/qxyseries.cpp +++ b/src/xychart/qxyseries.cpp @@ -432,7 +432,10 @@ void QXYSeries::setPen(const QPen &pen) QPen QXYSeries::pen() const { Q_D(const QXYSeries); - return d->m_pen; + if (d->m_pen == QChartPrivate::defaultPen()) + return QPen(); + else + return d->m_pen; } /*! @@ -452,7 +455,10 @@ void QXYSeries::setBrush(const QBrush &brush) QBrush QXYSeries::brush() const { Q_D(const QXYSeries); - return d->m_brush; + if (d->m_brush == QChartPrivate::defaultBrush()) + return QBrush(); + else + return d->m_brush; } void QXYSeries::setColor(const QColor &color) diff --git a/tests/auto/qbarset/tst_qbarset.cpp b/tests/auto/qbarset/tst_qbarset.cpp index 794df99..358e5fb 100644 --- a/tests/auto/qbarset/tst_qbarset.cpp +++ b/tests/auto/qbarset/tst_qbarset.cpp @@ -476,7 +476,7 @@ void tst_QBarSet::customize() series->append(set2); QVERIFY(set1->brush() == brush); // Should be customized - QVERIFY(set2->brush() != QBrush()); // Should be decorated by theme + QVERIFY(set2->brush() == QBrush()); // Setting empty brush doesn't reset to theme brush // Remove sets from series series->take(set1); @@ -490,8 +490,8 @@ void tst_QBarSet::customize() series->append(set1); series->append(set2); - QVERIFY(set1->labelBrush() == brush); // Should be customized - QVERIFY(set2->labelBrush() != QBrush()); // Should be decorated by theme + QVERIFY(set1->labelBrush() == brush); // Should be customized + QVERIFY(set2->labelBrush() == QBrush()); // Setting empty brush doesn't reset to theme brush // Test label font // Note: QFont empty constructor creates font with application's default font, so the font may or may not be the