From d27b6b26880de6ddc81302fe41b0ec1423943a2d 2016-04-08 21:42:25 From: Liang Qi Date: 2016-04-08 21:42:25 Subject: [PATCH] Merge remote-tracking branch 'origin/5.7' into dev Change-Id: I3f2ec8fb552bbed786cb0f7f5a0433d2d15f1931 --- diff --git a/dist/changes-2.1.1 b/dist/changes-2.1.1 new file mode 100644 index 0000000..caa3b1a --- /dev/null +++ b/dist/changes-2.1.1 @@ -0,0 +1,8 @@ +Qt Charts 2.1.1 + +Fixed issues +------------ +- Fixed crash with empty BarSet values +- Fixed model resetting with model mapper +- Fixed crash when axis range is infinite +- Fixed clearing the chart title diff --git a/src/charts/areachart/qareaseries.h b/src/charts/areachart/qareaseries.h index f036948..0d05ca5 100644 --- a/src/charts/areachart/qareaseries.h +++ b/src/charts/areachart/qareaseries.h @@ -53,8 +53,8 @@ class QT_CHARTS_EXPORT QAreaSeries : public QAbstractSeries Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged) public: - explicit QAreaSeries(QObject *parent = 0); - explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); + explicit QAreaSeries(QObject *parent = Q_NULLPTR); + explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = Q_NULLPTR); ~QAreaSeries(); public: diff --git a/src/charts/axis/barcategoryaxis/qbarcategoryaxis.h b/src/charts/axis/barcategoryaxis/qbarcategoryaxis.h index ba8045d..15ff9ee 100644 --- a/src/charts/axis/barcategoryaxis/qbarcategoryaxis.h +++ b/src/charts/axis/barcategoryaxis/qbarcategoryaxis.h @@ -45,11 +45,11 @@ class QT_CHARTS_EXPORT QBarCategoryAxis : public QAbstractAxis Q_PROPERTY(int count READ count NOTIFY countChanged) public: - explicit QBarCategoryAxis(QObject *parent = 0); + explicit QBarCategoryAxis(QObject *parent = Q_NULLPTR); ~QBarCategoryAxis(); protected: - QBarCategoryAxis(QBarCategoryAxisPrivate &d, QObject *parent = 0); + QBarCategoryAxis(QBarCategoryAxisPrivate &d, QObject *parent = Q_NULLPTR); public: AxisType type() const; diff --git a/src/charts/axis/categoryaxis/qcategoryaxis.h b/src/charts/axis/categoryaxis/qcategoryaxis.h index cfd05a6..eac9b4c 100644 --- a/src/charts/axis/categoryaxis/qcategoryaxis.h +++ b/src/charts/axis/categoryaxis/qcategoryaxis.h @@ -53,11 +53,11 @@ public: AxisLabelsPositionOnValue = 0x1 }; - explicit QCategoryAxis(QObject *parent = 0); + explicit QCategoryAxis(QObject *parent = Q_NULLPTR); ~QCategoryAxis(); protected: - QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent = 0); + QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent = Q_NULLPTR); public: AxisType type() const; diff --git a/src/charts/axis/datetimeaxis/qdatetimeaxis.h b/src/charts/axis/datetimeaxis/qdatetimeaxis.h index 19a3e8a..142ac7e 100644 --- a/src/charts/axis/datetimeaxis/qdatetimeaxis.h +++ b/src/charts/axis/datetimeaxis/qdatetimeaxis.h @@ -49,11 +49,11 @@ class QT_CHARTS_EXPORT QDateTimeAxis : public QAbstractAxis Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged) public: - explicit QDateTimeAxis(QObject *parent = 0); + explicit QDateTimeAxis(QObject *parent = Q_NULLPTR); ~QDateTimeAxis(); protected: - QDateTimeAxis(QDateTimeAxisPrivate &d, QObject *parent = 0); + QDateTimeAxis(QDateTimeAxisPrivate &d, QObject *parent = Q_NULLPTR); public: AxisType type() const; diff --git a/src/charts/axis/logvalueaxis/qlogvalueaxis.h b/src/charts/axis/logvalueaxis/qlogvalueaxis.h index d8bb2a4..3d8fd84 100644 --- a/src/charts/axis/logvalueaxis/qlogvalueaxis.h +++ b/src/charts/axis/logvalueaxis/qlogvalueaxis.h @@ -49,11 +49,11 @@ class QT_CHARTS_EXPORT QLogValueAxis : public QAbstractAxis Q_PROPERTY(qreal base READ base WRITE setBase NOTIFY baseChanged) public: - explicit QLogValueAxis(QObject *parent = 0); + explicit QLogValueAxis(QObject *parent = Q_NULLPTR); ~QLogValueAxis(); protected: - QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent = 0); + QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent = Q_NULLPTR); public: AxisType type() const; diff --git a/src/charts/axis/qabstractaxis.h b/src/charts/axis/qabstractaxis.h index fd2638e..8158f27 100644 --- a/src/charts/axis/qabstractaxis.h +++ b/src/charts/axis/qabstractaxis.h @@ -92,7 +92,7 @@ public: Q_DECLARE_FLAGS(AxisTypes, AxisType) protected: - explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0); + explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = Q_NULLPTR); public: ~QAbstractAxis(); diff --git a/src/charts/axis/valueaxis/qvalueaxis.cpp b/src/charts/axis/valueaxis/qvalueaxis.cpp index 7f97163..bf7e9ba 100644 --- a/src/charts/axis/valueaxis/qvalueaxis.cpp +++ b/src/charts/axis/valueaxis/qvalueaxis.cpp @@ -37,7 +37,7 @@ #include #include #include - +#include QT_CHARTS_BEGIN_NAMESPACE /*! @@ -390,6 +390,12 @@ void QValueAxisPrivate::setRange(qreal min, qreal max) if (min > max) return; + if (!isValidValue(min, max)) { + qWarning() << "Attempting to set invalid range for value axis: [" + << min << " - " << max << "]"; + return; + } + bool changeMin = false; if (m_min == 0 || min == 0) changeMin = !qFuzzyCompare(1 + m_min, 1 + min); diff --git a/src/charts/axis/valueaxis/qvalueaxis.h b/src/charts/axis/valueaxis/qvalueaxis.h index b9460c1..2a53df0 100644 --- a/src/charts/axis/valueaxis/qvalueaxis.h +++ b/src/charts/axis/valueaxis/qvalueaxis.h @@ -46,11 +46,11 @@ class QT_CHARTS_EXPORT QValueAxis : public QAbstractAxis Q_PROPERTY(int minorTickCount READ minorTickCount WRITE setMinorTickCount NOTIFY minorTickCountChanged) public: - explicit QValueAxis(QObject *parent = 0); + explicit QValueAxis(QObject *parent = Q_NULLPTR); ~QValueAxis(); protected: - QValueAxis(QValueAxisPrivate &d, QObject *parent = 0); + QValueAxis(QValueAxisPrivate &d, QObject *parent = Q_NULLPTR); public: AxisType type() const; diff --git a/src/charts/barchart/horizontal/bar/qhorizontalbarseries.h b/src/charts/barchart/horizontal/bar/qhorizontalbarseries.h index 3a7316a..104093d 100644 --- a/src/charts/barchart/horizontal/bar/qhorizontalbarseries.h +++ b/src/charts/barchart/horizontal/bar/qhorizontalbarseries.h @@ -40,7 +40,7 @@ class QT_CHARTS_EXPORT QHorizontalBarSeries : public QAbstractBarSeries { Q_OBJECT public: - explicit QHorizontalBarSeries(QObject *parent = 0); + explicit QHorizontalBarSeries(QObject *parent = Q_NULLPTR); ~QHorizontalBarSeries(); QAbstractSeries::SeriesType type() const; diff --git a/src/charts/barchart/horizontal/percent/qhorizontalpercentbarseries.h b/src/charts/barchart/horizontal/percent/qhorizontalpercentbarseries.h index 0b37d7b..6c2928b 100644 --- a/src/charts/barchart/horizontal/percent/qhorizontalpercentbarseries.h +++ b/src/charts/barchart/horizontal/percent/qhorizontalpercentbarseries.h @@ -40,7 +40,7 @@ class QT_CHARTS_EXPORT QHorizontalPercentBarSeries : public QAbstractBarSeries { Q_OBJECT public: - explicit QHorizontalPercentBarSeries(QObject *parent = 0); + explicit QHorizontalPercentBarSeries(QObject *parent = Q_NULLPTR); ~QHorizontalPercentBarSeries(); QAbstractSeries::SeriesType type() const; diff --git a/src/charts/barchart/horizontal/stacked/qhorizontalstackedbarseries.h b/src/charts/barchart/horizontal/stacked/qhorizontalstackedbarseries.h index eb32a77..3c2711d 100644 --- a/src/charts/barchart/horizontal/stacked/qhorizontalstackedbarseries.h +++ b/src/charts/barchart/horizontal/stacked/qhorizontalstackedbarseries.h @@ -40,7 +40,7 @@ class QT_CHARTS_EXPORT QHorizontalStackedBarSeries : public QAbstractBarSeries { Q_OBJECT public: - explicit QHorizontalStackedBarSeries(QObject *parent = 0); + explicit QHorizontalStackedBarSeries(QObject *parent = Q_NULLPTR); ~QHorizontalStackedBarSeries(); QAbstractSeries::SeriesType type() const; diff --git a/src/charts/barchart/qabstractbarseries.h b/src/charts/barchart/qabstractbarseries.h index 2522659..3bff84a 100644 --- a/src/charts/barchart/qabstractbarseries.h +++ b/src/charts/barchart/qabstractbarseries.h @@ -86,7 +86,7 @@ public: QAbstractBarSeries::LabelsPosition labelsPosition() const; protected: - explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = 0); + explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = Q_NULLPTR); Q_SIGNALS: void clicked(int index, QBarSet *barset); diff --git a/src/charts/barchart/qbarmodelmapper.cpp b/src/charts/barchart/qbarmodelmapper.cpp index b1f29a7..500429f 100644 --- a/src/charts/barchart/qbarmodelmapper.cpp +++ b/src/charts/barchart/qbarmodelmapper.cpp @@ -60,6 +60,7 @@ void QBarModelMapper::setModel(QAbstractItemModel *model) d->m_model = model; d->initializeBarFromModel(); // connect signals from the model + connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializeBarFromModel())); connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); diff --git a/src/charts/barchart/qbarmodelmapper.h b/src/charts/barchart/qbarmodelmapper.h index 57d4c9f..1118fd2 100644 --- a/src/charts/barchart/qbarmodelmapper.h +++ b/src/charts/barchart/qbarmodelmapper.h @@ -47,7 +47,7 @@ class QT_CHARTS_EXPORT QBarModelMapper : public QObject Q_OBJECT protected: - explicit QBarModelMapper(QObject *parent = 0); + explicit QBarModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/barchart/qbarset.h b/src/charts/barchart/qbarset.h index b312f47..0859bff 100644 --- a/src/charts/barchart/qbarset.h +++ b/src/charts/barchart/qbarset.h @@ -51,7 +51,7 @@ class QT_CHARTS_EXPORT QBarSet : public QObject Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) public: - explicit QBarSet(const QString label, QObject *parent = 0); + explicit QBarSet(const QString label, QObject *parent = Q_NULLPTR); virtual ~QBarSet(); void setLabel(const QString label); diff --git a/src/charts/barchart/qhbarmodelmapper.h b/src/charts/barchart/qhbarmodelmapper.h index 36947b2..8063a81 100644 --- a/src/charts/barchart/qhbarmodelmapper.h +++ b/src/charts/barchart/qhbarmodelmapper.h @@ -45,7 +45,7 @@ class QT_CHARTS_EXPORT QHBarModelMapper : public QBarModelMapper Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) public: - explicit QHBarModelMapper(QObject *parent = 0); + explicit QHBarModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/barchart/qvbarmodelmapper.h b/src/charts/barchart/qvbarmodelmapper.h index 7f432e4..a4e8ae3 100644 --- a/src/charts/barchart/qvbarmodelmapper.h +++ b/src/charts/barchart/qvbarmodelmapper.h @@ -45,7 +45,7 @@ class QT_CHARTS_EXPORT QVBarModelMapper : public QBarModelMapper Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) public: - explicit QVBarModelMapper(QObject *parent = 0); + explicit QVBarModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/barchart/vertical/bar/qbarseries.h b/src/charts/barchart/vertical/bar/qbarseries.h index 0004a2c..95d9ae2 100644 --- a/src/charts/barchart/vertical/bar/qbarseries.h +++ b/src/charts/barchart/vertical/bar/qbarseries.h @@ -40,7 +40,7 @@ class QT_CHARTS_EXPORT QBarSeries : public QAbstractBarSeries { Q_OBJECT public: - explicit QBarSeries(QObject *parent = 0); + explicit QBarSeries(QObject *parent = Q_NULLPTR); ~QBarSeries(); QAbstractSeries::SeriesType type() const; diff --git a/src/charts/barchart/vertical/percent/qpercentbarseries.h b/src/charts/barchart/vertical/percent/qpercentbarseries.h index bc2b7b6..ee4796c 100644 --- a/src/charts/barchart/vertical/percent/qpercentbarseries.h +++ b/src/charts/barchart/vertical/percent/qpercentbarseries.h @@ -41,7 +41,7 @@ class QT_CHARTS_EXPORT QPercentBarSeries : public QAbstractBarSeries { Q_OBJECT public: - explicit QPercentBarSeries(QObject *parent = 0); + explicit QPercentBarSeries(QObject *parent = Q_NULLPTR); ~QPercentBarSeries(); QAbstractSeries::SeriesType type() const; diff --git a/src/charts/barchart/vertical/stacked/qstackedbarseries.h b/src/charts/barchart/vertical/stacked/qstackedbarseries.h index 88392d9..d3efa99 100644 --- a/src/charts/barchart/vertical/stacked/qstackedbarseries.h +++ b/src/charts/barchart/vertical/stacked/qstackedbarseries.h @@ -41,7 +41,7 @@ class QT_CHARTS_EXPORT QStackedBarSeries : public QAbstractBarSeries { Q_OBJECT public: - explicit QStackedBarSeries(QObject *parent = 0); + explicit QStackedBarSeries(QObject *parent = Q_NULLPTR); ~QStackedBarSeries(); QAbstractSeries::SeriesType type() const; diff --git a/src/charts/boxplotchart/qboxplotmodelmapper.cpp b/src/charts/boxplotchart/qboxplotmodelmapper.cpp index 176f241..2dcd19f 100644 --- a/src/charts/boxplotchart/qboxplotmodelmapper.cpp +++ b/src/charts/boxplotchart/qboxplotmodelmapper.cpp @@ -60,6 +60,7 @@ void QBoxPlotModelMapper::setModel(QAbstractItemModel *model) d->m_model = model; d->initializeBoxFromModel(); // connect signals from the model + connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializeBoxFromModel())); connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); diff --git a/src/charts/boxplotchart/qboxplotmodelmapper.h b/src/charts/boxplotchart/qboxplotmodelmapper.h index 4e371f1..a48a69a 100644 --- a/src/charts/boxplotchart/qboxplotmodelmapper.h +++ b/src/charts/boxplotchart/qboxplotmodelmapper.h @@ -47,7 +47,7 @@ class QT_CHARTS_EXPORT QBoxPlotModelMapper : public QObject Q_OBJECT protected: - explicit QBoxPlotModelMapper(QObject *parent = 0); + explicit QBoxPlotModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/boxplotchart/qboxplotseries.h b/src/charts/boxplotchart/qboxplotseries.h index b3473f6..f86e1a8 100644 --- a/src/charts/boxplotchart/qboxplotseries.h +++ b/src/charts/boxplotchart/qboxplotseries.h @@ -47,7 +47,7 @@ class QT_CHARTS_EXPORT QBoxPlotSeries : public QAbstractSeries Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) Q_PROPERTY(int count READ count NOTIFY countChanged REVISION 1) public: - explicit QBoxPlotSeries(QObject *parent = 0); + explicit QBoxPlotSeries(QObject *parent = Q_NULLPTR); ~QBoxPlotSeries(); bool append(QBoxSet *box); diff --git a/src/charts/boxplotchart/qboxset.h b/src/charts/boxplotchart/qboxset.h index 98fccfd..84a4ebf 100644 --- a/src/charts/boxplotchart/qboxset.h +++ b/src/charts/boxplotchart/qboxset.h @@ -54,8 +54,8 @@ public: }; public: - explicit QBoxSet(const QString label = QString(), QObject *parent = 0); - explicit QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label = QString(), QObject *parent = 0); + explicit QBoxSet(const QString label = QString(), QObject *parent = Q_NULLPTR); + explicit QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label = QString(), QObject *parent = Q_NULLPTR); virtual ~QBoxSet(); void append(const qreal value); diff --git a/src/charts/boxplotchart/qvboxplotmodelmapper.h b/src/charts/boxplotchart/qvboxplotmodelmapper.h index c256ed0..b150889 100644 --- a/src/charts/boxplotchart/qvboxplotmodelmapper.h +++ b/src/charts/boxplotchart/qvboxplotmodelmapper.h @@ -45,7 +45,7 @@ class QT_CHARTS_EXPORT QVBoxPlotModelMapper : public QBoxPlotModelMapper Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) public: - explicit QVBoxPlotModelMapper(QObject *parent = 0); + explicit QVBoxPlotModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/charttitle.cpp b/src/charts/charttitle.cpp index fda5512..8f4c00d 100644 --- a/src/charts/charttitle.cpp +++ b/src/charts/charttitle.cpp @@ -60,10 +60,15 @@ QString ChartTitle::text() const void ChartTitle::setGeometry(const QRectF &rect) { QRectF truncatedRect; - QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0), - rect.width(), rect.height(), - truncatedRect)); - QGraphicsTextItem::setTextWidth(truncatedRect.width()); + if (m_text.isEmpty()) { + QGraphicsTextItem::setHtml(m_text); + QGraphicsTextItem::setTextWidth(0.0); + } else { + QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0), + rect.width(), rect.height(), + truncatedRect)); + QGraphicsTextItem::setTextWidth(truncatedRect.width()); + } setPos(rect.topLeft()); } diff --git a/src/charts/layout/abstractchartlayout.cpp b/src/charts/layout/abstractchartlayout.cpp index bfafd08..46689ca 100644 --- a/src/charts/layout/abstractchartlayout.cpp +++ b/src/charts/layout/abstractchartlayout.cpp @@ -65,7 +65,7 @@ void AbstractChartLayout::setGeometry(const QRectF &rect) contentGeometry = calculateContentGeometry(contentGeometry); - if (title && title->isVisible() && !title->text().isEmpty()) + if (title && title->isVisible()) contentGeometry = calculateTitleGeometry(contentGeometry, title); if (legend->isAttachedToChart() && legend->isVisible()) @@ -167,11 +167,15 @@ QRectF AbstractChartLayout::calculateLegendMinimum(const QRectF &geometry, QLege QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const { title->setGeometry(geometry); - // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases - QPointF center((geometry.center() - title->boundingRect().center()).toPoint()); - - title->setPos(center.x(), title->pos().y()); - return geometry.adjusted(0, title->boundingRect().height()+1, 0, 0); + if (title->text().isEmpty()) { + return geometry; + } else { + // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases + QPointF center((geometry.center() - title->boundingRect().center()).toPoint()); + + title->setPos(center.x(), title->pos().y()); + return geometry.adjusted(0, title->boundingRect().height() + 1, 0, 0); + } } QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const diff --git a/src/charts/legend/qarealegendmarker.h b/src/charts/legend/qarealegendmarker.h index bcf5666..e754158 100644 --- a/src/charts/legend/qarealegendmarker.h +++ b/src/charts/legend/qarealegendmarker.h @@ -43,7 +43,7 @@ class QT_CHARTS_EXPORT QAreaLegendMarker : public QLegendMarker Q_OBJECT public: - explicit QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent = 0); + explicit QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR); virtual ~QAreaLegendMarker(); virtual LegendMarkerType type() { return LegendMarkerTypeArea; } @@ -52,7 +52,7 @@ public: virtual QAreaSeries* series(); protected: - QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent = 0); + QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); private: Q_DECLARE_PRIVATE(QAreaLegendMarker) diff --git a/src/charts/legend/qbarlegendmarker.h b/src/charts/legend/qbarlegendmarker.h index 351987e..127d3f8 100644 --- a/src/charts/legend/qbarlegendmarker.h +++ b/src/charts/legend/qbarlegendmarker.h @@ -43,7 +43,7 @@ class QT_CHARTS_EXPORT QBarLegendMarker : public QLegendMarker { Q_OBJECT public: - explicit QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent = 0); + explicit QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent = Q_NULLPTR); virtual ~QBarLegendMarker(); virtual LegendMarkerType type() { return LegendMarkerTypeBar; } @@ -53,7 +53,7 @@ public: QBarSet* barset(); protected: - QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent = 0); + QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); private: Q_DECLARE_PRIVATE(QBarLegendMarker) diff --git a/src/charts/legend/qboxplotlegendmarker.h b/src/charts/legend/qboxplotlegendmarker.h index 25891db..2f97732 100644 --- a/src/charts/legend/qboxplotlegendmarker.h +++ b/src/charts/legend/qboxplotlegendmarker.h @@ -43,7 +43,7 @@ class QT_CHARTS_EXPORT QBoxPlotLegendMarker : public QLegendMarker Q_OBJECT public: - explicit QBoxPlotLegendMarker(QBoxPlotSeries *series, QLegend *legend, QObject *parent = 0); + explicit QBoxPlotLegendMarker(QBoxPlotSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR); virtual ~QBoxPlotLegendMarker(); virtual LegendMarkerType type() { return LegendMarkerTypeBoxPlot; } @@ -52,7 +52,7 @@ public: virtual QBoxPlotSeries* series(); protected: - QBoxPlotLegendMarker(QBoxPlotLegendMarkerPrivate &d, QObject *parent = 0); + QBoxPlotLegendMarker(QBoxPlotLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); private: Q_DECLARE_PRIVATE(QBoxPlotLegendMarker) diff --git a/src/charts/legend/qlegend.h b/src/charts/legend/qlegend.h index 8825af4..cafbefb 100644 --- a/src/charts/legend/qlegend.h +++ b/src/charts/legend/qlegend.h @@ -60,7 +60,7 @@ private: public: ~QLegend(); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR); void setBrush(const QBrush &brush); QBrush brush() const; @@ -90,7 +90,7 @@ public: void setBackgroundVisible(bool visible = true); bool isBackgroundVisible() const; - QList markers(QAbstractSeries *series = 0) const; + QList markers(QAbstractSeries *series = Q_NULLPTR) const; bool reverseMarkers(); void setReverseMarkers(bool reverseMarkers = true); diff --git a/src/charts/legend/qlegendmarker.h b/src/charts/legend/qlegendmarker.h index 64ca316..142b7e4 100644 --- a/src/charts/legend/qlegendmarker.h +++ b/src/charts/legend/qlegendmarker.h @@ -98,7 +98,7 @@ Q_SIGNALS: void visibleChanged(); protected: - explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = 0); + explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); QScopedPointer d_ptr; friend class QLegendPrivate; diff --git a/src/charts/legend/qpielegendmarker.h b/src/charts/legend/qpielegendmarker.h index 2626288..233f555 100644 --- a/src/charts/legend/qpielegendmarker.h +++ b/src/charts/legend/qpielegendmarker.h @@ -44,7 +44,7 @@ class QT_CHARTS_EXPORT QPieLegendMarker : public QLegendMarker Q_OBJECT public: - explicit QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent = 0); + explicit QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent = Q_NULLPTR); virtual ~QPieLegendMarker(); virtual LegendMarkerType type() { return LegendMarkerTypePie; } @@ -54,7 +54,7 @@ public: QPieSlice* slice(); protected: - QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = 0); + QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); private: Q_DECLARE_PRIVATE(QPieLegendMarker) diff --git a/src/charts/legend/qxylegendmarker.h b/src/charts/legend/qxylegendmarker.h index 3106b48..0c45230 100644 --- a/src/charts/legend/qxylegendmarker.h +++ b/src/charts/legend/qxylegendmarker.h @@ -42,7 +42,7 @@ class QT_CHARTS_EXPORT QXYLegendMarker : public QLegendMarker { Q_OBJECT public: - explicit QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent = 0); + explicit QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR); virtual ~QXYLegendMarker(); virtual LegendMarkerType type() { return LegendMarkerTypeXY; } @@ -51,7 +51,7 @@ public: virtual QXYSeries* series(); protected: - QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent = 0); + QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); private: Q_DECLARE_PRIVATE(QXYLegendMarker) diff --git a/src/charts/linechart/qlineseries.h b/src/charts/linechart/qlineseries.h index 06062e7..ef69424 100644 --- a/src/charts/linechart/qlineseries.h +++ b/src/charts/linechart/qlineseries.h @@ -43,12 +43,12 @@ class QT_CHARTS_EXPORT QLineSeries : public QXYSeries Q_OBJECT public: - explicit QLineSeries(QObject *parent = 0); + explicit QLineSeries(QObject *parent = Q_NULLPTR); ~QLineSeries(); QAbstractSeries::SeriesType type() const; protected: - QLineSeries(QLineSeriesPrivate &d, QObject *parent = 0); + QLineSeries(QLineSeriesPrivate &d, QObject *parent = Q_NULLPTR); private: Q_DECLARE_PRIVATE(QLineSeries) diff --git a/src/charts/piechart/qhpiemodelmapper.h b/src/charts/piechart/qhpiemodelmapper.h index 0819616..6857e64 100644 --- a/src/charts/piechart/qhpiemodelmapper.h +++ b/src/charts/piechart/qhpiemodelmapper.h @@ -45,7 +45,7 @@ class QT_CHARTS_EXPORT QHPieModelMapper : public QPieModelMapper Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) public: - explicit QHPieModelMapper(QObject *parent = 0); + explicit QHPieModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/piechart/qpiemodelmapper.cpp b/src/charts/piechart/qpiemodelmapper.cpp index 07e678e..132c2cd 100644 --- a/src/charts/piechart/qpiemodelmapper.cpp +++ b/src/charts/piechart/qpiemodelmapper.cpp @@ -60,6 +60,7 @@ void QPieModelMapper::setModel(QAbstractItemModel *model) d->m_model = model; d->initializePieFromModel(); // connect signals from the model + connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializePieFromModel())); connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); diff --git a/src/charts/piechart/qpiemodelmapper.h b/src/charts/piechart/qpiemodelmapper.h index 3ccaa91..b6d0c68 100644 --- a/src/charts/piechart/qpiemodelmapper.h +++ b/src/charts/piechart/qpiemodelmapper.h @@ -47,7 +47,7 @@ class QT_CHARTS_EXPORT QPieModelMapper : public QObject Q_OBJECT protected: - explicit QPieModelMapper(QObject *parent = 0); + explicit QPieModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/piechart/qpieseries.h b/src/charts/piechart/qpieseries.h index d7d276b..1eabb6a 100644 --- a/src/charts/piechart/qpieseries.h +++ b/src/charts/piechart/qpieseries.h @@ -49,7 +49,7 @@ class QT_CHARTS_EXPORT QPieSeries : public QAbstractSeries Q_PROPERTY(qreal holeSize READ holeSize WRITE setHoleSize) public: - explicit QPieSeries(QObject *parent = 0); + explicit QPieSeries(QObject *parent = Q_NULLPTR); virtual ~QPieSeries(); QAbstractSeries::SeriesType type() const; diff --git a/src/charts/piechart/qpieslice.h b/src/charts/piechart/qpieslice.h index ae75c75..e305bd6 100644 --- a/src/charts/piechart/qpieslice.h +++ b/src/charts/piechart/qpieslice.h @@ -72,8 +72,8 @@ public: }; public: - explicit QPieSlice(QObject *parent = 0); - QPieSlice(QString label, qreal value, QObject *parent = 0); + explicit QPieSlice(QObject *parent = Q_NULLPTR); + QPieSlice(QString label, qreal value, QObject *parent = Q_NULLPTR); virtual ~QPieSlice(); void setLabel(QString label); diff --git a/src/charts/piechart/qvpiemodelmapper.h b/src/charts/piechart/qvpiemodelmapper.h index 0d1157b..5532924 100644 --- a/src/charts/piechart/qvpiemodelmapper.h +++ b/src/charts/piechart/qvpiemodelmapper.h @@ -45,7 +45,7 @@ class QT_CHARTS_EXPORT QVPieModelMapper : public QPieModelMapper Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) public: - explicit QVPieModelMapper(QObject *parent = 0); + explicit QVPieModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/qabstractseries.h b/src/charts/qabstractseries.h index 354c5ed..8fedf5c 100644 --- a/src/charts/qabstractseries.h +++ b/src/charts/qabstractseries.h @@ -67,7 +67,7 @@ public: }; protected: - QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = 0); + QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = Q_NULLPTR); public: ~QAbstractSeries(); diff --git a/src/charts/qchart.h b/src/charts/qchart.h index b2c2a48..40b53a8 100644 --- a/src/charts/qchart.h +++ b/src/charts/qchart.h @@ -96,7 +96,7 @@ public: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) public: - explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + explicit QChart(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags()); ~QChart(); void addSeries(QAbstractSeries *series); @@ -105,15 +105,15 @@ public: QList series() const; // *** deprecated *** - void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); - void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); - QAbstractAxis *axisX(QAbstractSeries *series = 0) const; - QAbstractAxis *axisY(QAbstractSeries *series = 0) const; + void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR); + void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR); + QAbstractAxis *axisX(QAbstractSeries *series = Q_NULLPTR) const; + QAbstractAxis *axisY(QAbstractSeries *series = Q_NULLPTR) const; // ****************** void addAxis(QAbstractAxis *axis, Qt::Alignment alignment); void removeAxis(QAbstractAxis *axis); - QList axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = 0) const; + QList axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = Q_NULLPTR) const; void createDefaultAxes(); @@ -173,8 +173,8 @@ public: void setLocale(const QLocale &locale); QLocale locale() const; - QPointF mapToValue(const QPointF &position, QAbstractSeries *series = 0); - QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = 0); + QPointF mapToValue(const QPointF &position, QAbstractSeries *series = Q_NULLPTR); + QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = Q_NULLPTR); ChartType chartType() const; diff --git a/src/charts/qchartview.h b/src/charts/qchartview.h index a3c7f03..84b269f 100644 --- a/src/charts/qchartview.h +++ b/src/charts/qchartview.h @@ -59,8 +59,8 @@ public: Q_DECLARE_FLAGS(RubberBands, RubberBand) - explicit QChartView(QWidget *parent = 0); - explicit QChartView(QChart *chart, QWidget *parent = 0); + explicit QChartView(QWidget *parent = Q_NULLPTR); + explicit QChartView(QChart *chart, QWidget *parent = Q_NULLPTR); ~QChartView(); void setRubberBand(const RubberBands &rubberBands); diff --git a/src/charts/qpolarchart.h b/src/charts/qpolarchart.h index ec78555..067363c 100644 --- a/src/charts/qpolarchart.h +++ b/src/charts/qpolarchart.h @@ -51,12 +51,12 @@ public: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation) public: - explicit QPolarChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + explicit QPolarChart(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags()); ~QPolarChart(); void addAxis(QAbstractAxis *axis, PolarOrientation polarOrientation); - QList axes(PolarOrientations polarOrientation = PolarOrientations(PolarOrientationRadial | PolarOrientationAngular), QAbstractSeries *series = 0) const; + QList axes(PolarOrientations polarOrientation = PolarOrientations(PolarOrientationRadial | PolarOrientationAngular), QAbstractSeries *series = Q_NULLPTR) const; static PolarOrientation axisPolarOrientation(QAbstractAxis *axis); diff --git a/src/charts/scatterchart/qscatterseries.h b/src/charts/scatterchart/qscatterseries.h index 95e17ef..74e44e3 100644 --- a/src/charts/scatterchart/qscatterseries.h +++ b/src/charts/scatterchart/qscatterseries.h @@ -54,7 +54,7 @@ public: }; public: - explicit QScatterSeries(QObject *parent = 0); + explicit QScatterSeries(QObject *parent = Q_NULLPTR); ~QScatterSeries(); QAbstractSeries::SeriesType type() const; void setPen(const QPen &pen); diff --git a/src/charts/splinechart/qsplineseries.h b/src/charts/splinechart/qsplineseries.h index e734a59..41059e3 100644 --- a/src/charts/splinechart/qsplineseries.h +++ b/src/charts/splinechart/qsplineseries.h @@ -45,7 +45,7 @@ class QT_CHARTS_EXPORT QSplineSeries : public QLineSeries Q_OBJECT public: - explicit QSplineSeries(QObject *parent = 0); + explicit QSplineSeries(QObject *parent = Q_NULLPTR); ~QSplineSeries(); QAbstractSeries::SeriesType type() const; diff --git a/src/charts/xychart/qhxymodelmapper.h b/src/charts/xychart/qhxymodelmapper.h index 9544adc..677517c 100644 --- a/src/charts/xychart/qhxymodelmapper.h +++ b/src/charts/xychart/qhxymodelmapper.h @@ -45,7 +45,7 @@ class QT_CHARTS_EXPORT QHXYModelMapper : public QXYModelMapper Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) public: - explicit QHXYModelMapper(QObject *parent = 0); + explicit QHXYModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/xychart/qvxymodelmapper.h b/src/charts/xychart/qvxymodelmapper.h index 95b61d9..922121b 100644 --- a/src/charts/xychart/qvxymodelmapper.h +++ b/src/charts/xychart/qvxymodelmapper.h @@ -45,7 +45,7 @@ class QT_CHARTS_EXPORT QVXYModelMapper : public QXYModelMapper Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) public: - explicit QVXYModelMapper(QObject *parent = 0); + explicit QVXYModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/xychart/qxymodelmapper.h b/src/charts/xychart/qxymodelmapper.h index 30a5141..64b0aea 100644 --- a/src/charts/xychart/qxymodelmapper.h +++ b/src/charts/xychart/qxymodelmapper.h @@ -47,7 +47,7 @@ class QT_CHARTS_EXPORT QXYModelMapper : public QObject Q_OBJECT protected: - explicit QXYModelMapper(QObject *parent = 0); + explicit QXYModelMapper(QObject *parent = Q_NULLPTR); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); diff --git a/src/charts/xychart/qxyseries.h b/src/charts/xychart/qxyseries.h index 5838e71..11c87b5 100644 --- a/src/charts/xychart/qxyseries.h +++ b/src/charts/xychart/qxyseries.h @@ -56,7 +56,7 @@ class QT_CHARTS_EXPORT QXYSeries : public QAbstractSeries Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged) protected: - explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = 0); + explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = Q_NULLPTR); public: ~QXYSeries(); diff --git a/src/chartsqml2/declarativebarseries.cpp b/src/chartsqml2/declarativebarseries.cpp index cab5214..70fbcf3 100644 --- a/src/chartsqml2/declarativebarseries.cpp +++ b/src/chartsqml2/declarativebarseries.cpp @@ -77,7 +77,7 @@ void DeclarativeBarSet::setValues(QVariantList values) while (count()) remove(count() - 1); - if (values.at(0).canConvert(QVariant::Point)) { + if (values.count() > 0 && values.at(0).canConvert(QVariant::Point)) { // Create list of values for appending if the first item is Qt.point int maxValue = 0; for (int i = 0; i < values.count(); i++) { diff --git a/src/chartsqml2/declarativechart.cpp b/src/chartsqml2/declarativechart.cpp index 596c138..ec5e83a 100644 --- a/src/chartsqml2/declarativechart.cpp +++ b/src/chartsqml2/declarativechart.cpp @@ -520,14 +520,16 @@ QSGNode *DeclarativeChart::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdateP if (!node) { node = new DeclarativeChartNode(window()); - connect(window(), &QQuickWindow::beforeRendering, - node->glRenderNode(), &DeclarativeRenderNode::render); + if (node->glRenderNode()) { + connect(window(), &QQuickWindow::beforeRendering, + node->glRenderNode(), &DeclarativeRenderNode::render); + } } const QRectF &bRect = boundingRect(); // Update GL data - if (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty()) { + if (node->glRenderNode() && (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty())) { const QRectF &plotArea = m_chart->plotArea(); const QSizeF &chartAreaSize = m_chart->size(); diff --git a/src/chartsqml2/declarativechartnode.cpp b/src/chartsqml2/declarativechartnode.cpp index de0eb3c..3742b8c 100644 --- a/src/chartsqml2/declarativechartnode.cpp +++ b/src/chartsqml2/declarativechartnode.cpp @@ -47,27 +47,27 @@ DeclarativeChartNode::DeclarativeChartNode(QQuickWindow *window) : m_textureSize(1, 1), m_glRenderNode(0) { - initializeOpenGLFunctions(); - // Our texture node must have a texture, so use a default one pixel texture - GLuint defaultTexture = 0; - glGenTextures(1, &defaultTexture); - glBindTexture(GL_TEXTURE_2D, defaultTexture); - uchar buf[4] = { 0, 0, 0, 0 }; - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &buf); - + QImage dummyImage(QSize(1, 1), QImage::Format_ARGB32); + uchar *imageData = dummyImage.bits(); + imageData[0] = 0; + imageData[1] = 0; + imageData[2] = 0; + imageData[3] = 0; QQuickWindow::CreateTextureOptions defaultTextureOptions = QQuickWindow::CreateTextureOptions( QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture); - m_texture = m_window->createTextureFromId(defaultTexture, QSize(1, 1), defaultTextureOptions); + m_texture = m_window->createTextureFromImage(dummyImage, defaultTextureOptions); setTexture(m_texture); setFiltering(QSGTexture::Linear); - // Create child node for rendering GL graphics - m_glRenderNode = new DeclarativeRenderNode(m_window); - m_glRenderNode->setFlag(OwnedByParent); - appendChildNode(m_glRenderNode); - m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default + if (QOpenGLContext::currentContext()) { + // Create child node for rendering GL graphics + m_glRenderNode = new DeclarativeRenderNode(m_window); + m_glRenderNode->setFlag(OwnedByParent); + appendChildNode(m_glRenderNode); + m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default + } } DeclarativeChartNode::~DeclarativeChartNode() diff --git a/tests/manual/chartwidgettest/mainwidget.cpp b/tests/manual/chartwidgettest/mainwidget.cpp index 062e04f..79530bb 100644 --- a/tests/manual/chartwidgettest/mainwidget.cpp +++ b/tests/manual/chartwidgettest/mainwidget.cpp @@ -216,9 +216,9 @@ QList MainWidget::generateTestData(int columnCount, int rowCount, QStr QList newColumn; for (int i(0); i < rowCount; i++) { if (dataCharacteristics == "Sin") { - newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100)); + newColumn.append(std::abs(sin(3.14159265358979 / 50 * i) * 100)); } else if (dataCharacteristics == "Sin + random") { - newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); + newColumn.append(std::abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); } else if (dataCharacteristics == "Random") { newColumn.append(rand() % 10 + (qreal) rand() / (qreal) RAND_MAX); } else if (dataCharacteristics == "Linear") {