##// END OF EJS Templates
Merge remote-tracking branch 'origin/5.6' into 5.7...
Liang Qi -
r2878:97bb01ce5d85 merge
parent child
Show More
@@ -0,0 +1,8
1 Qt Charts 2.1.1
2
3 Fixed issues
4 ------------
5 - Fixed crash with empty BarSet values
6 - Fixed model resetting with model mapper
7 - Fixed crash when axis range is infinite
8 - Fixed clearing the chart title
@@ -53,8 +53,8 class QT_CHARTS_EXPORT QAreaSeries : public QAbstractSeries
53 53 Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged)
54 54
55 55 public:
56 explicit QAreaSeries(QObject *parent = 0);
57 explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
56 explicit QAreaSeries(QObject *parent = Q_NULLPTR);
57 explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = Q_NULLPTR);
58 58 ~QAreaSeries();
59 59
60 60 public:
@@ -45,11 +45,11 class QT_CHARTS_EXPORT QBarCategoryAxis : public QAbstractAxis
45 45 Q_PROPERTY(int count READ count NOTIFY countChanged)
46 46
47 47 public:
48 explicit QBarCategoryAxis(QObject *parent = 0);
48 explicit QBarCategoryAxis(QObject *parent = Q_NULLPTR);
49 49 ~QBarCategoryAxis();
50 50
51 51 protected:
52 QBarCategoryAxis(QBarCategoryAxisPrivate &d, QObject *parent = 0);
52 QBarCategoryAxis(QBarCategoryAxisPrivate &d, QObject *parent = Q_NULLPTR);
53 53
54 54 public:
55 55 AxisType type() const;
@@ -53,11 +53,11 public:
53 53 AxisLabelsPositionOnValue = 0x1
54 54 };
55 55
56 explicit QCategoryAxis(QObject *parent = 0);
56 explicit QCategoryAxis(QObject *parent = Q_NULLPTR);
57 57 ~QCategoryAxis();
58 58
59 59 protected:
60 QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent = 0);
60 QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent = Q_NULLPTR);
61 61
62 62 public:
63 63 AxisType type() const;
@@ -49,11 +49,11 class QT_CHARTS_EXPORT QDateTimeAxis : public QAbstractAxis
49 49 Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged)
50 50
51 51 public:
52 explicit QDateTimeAxis(QObject *parent = 0);
52 explicit QDateTimeAxis(QObject *parent = Q_NULLPTR);
53 53 ~QDateTimeAxis();
54 54
55 55 protected:
56 QDateTimeAxis(QDateTimeAxisPrivate &d, QObject *parent = 0);
56 QDateTimeAxis(QDateTimeAxisPrivate &d, QObject *parent = Q_NULLPTR);
57 57
58 58 public:
59 59 AxisType type() const;
@@ -49,11 +49,11 class QT_CHARTS_EXPORT QLogValueAxis : public QAbstractAxis
49 49 Q_PROPERTY(qreal base READ base WRITE setBase NOTIFY baseChanged)
50 50
51 51 public:
52 explicit QLogValueAxis(QObject *parent = 0);
52 explicit QLogValueAxis(QObject *parent = Q_NULLPTR);
53 53 ~QLogValueAxis();
54 54
55 55 protected:
56 QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent = 0);
56 QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent = Q_NULLPTR);
57 57
58 58 public:
59 59 AxisType type() const;
@@ -92,7 +92,7 public:
92 92 Q_DECLARE_FLAGS(AxisTypes, AxisType)
93 93
94 94 protected:
95 explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0);
95 explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = Q_NULLPTR);
96 96
97 97 public:
98 98 ~QAbstractAxis();
@@ -37,7 +37,7
37 37 #include <private/chartdataset_p.h>
38 38 #include <private/chartpresenter_p.h>
39 39 #include <private/charttheme_p.h>
40
40 #include <private/charthelpers_p.h>
41 41
42 42 QT_CHARTS_BEGIN_NAMESPACE
43 43 /*!
@@ -390,6 +390,12 void QValueAxisPrivate::setRange(qreal min, qreal max)
390 390 if (min > max)
391 391 return;
392 392
393 if (!isValidValue(min, max)) {
394 qWarning() << "Attempting to set invalid range for value axis: ["
395 << min << " - " << max << "]";
396 return;
397 }
398
393 399 bool changeMin = false;
394 400 if (m_min == 0 || min == 0)
395 401 changeMin = !qFuzzyCompare(1 + m_min, 1 + min);
@@ -46,11 +46,11 class QT_CHARTS_EXPORT QValueAxis : public QAbstractAxis
46 46 Q_PROPERTY(int minorTickCount READ minorTickCount WRITE setMinorTickCount NOTIFY minorTickCountChanged)
47 47
48 48 public:
49 explicit QValueAxis(QObject *parent = 0);
49 explicit QValueAxis(QObject *parent = Q_NULLPTR);
50 50 ~QValueAxis();
51 51
52 52 protected:
53 QValueAxis(QValueAxisPrivate &d, QObject *parent = 0);
53 QValueAxis(QValueAxisPrivate &d, QObject *parent = Q_NULLPTR);
54 54
55 55 public:
56 56 AxisType type() const;
@@ -40,7 +40,7 class QT_CHARTS_EXPORT QHorizontalBarSeries : public QAbstractBarSeries
40 40 {
41 41 Q_OBJECT
42 42 public:
43 explicit QHorizontalBarSeries(QObject *parent = 0);
43 explicit QHorizontalBarSeries(QObject *parent = Q_NULLPTR);
44 44 ~QHorizontalBarSeries();
45 45 QAbstractSeries::SeriesType type() const;
46 46
@@ -40,7 +40,7 class QT_CHARTS_EXPORT QHorizontalPercentBarSeries : public QAbstractBarSeries
40 40 {
41 41 Q_OBJECT
42 42 public:
43 explicit QHorizontalPercentBarSeries(QObject *parent = 0);
43 explicit QHorizontalPercentBarSeries(QObject *parent = Q_NULLPTR);
44 44 ~QHorizontalPercentBarSeries();
45 45 QAbstractSeries::SeriesType type() const;
46 46
@@ -40,7 +40,7 class QT_CHARTS_EXPORT QHorizontalStackedBarSeries : public QAbstractBarSeries
40 40 {
41 41 Q_OBJECT
42 42 public:
43 explicit QHorizontalStackedBarSeries(QObject *parent = 0);
43 explicit QHorizontalStackedBarSeries(QObject *parent = Q_NULLPTR);
44 44 ~QHorizontalStackedBarSeries();
45 45 QAbstractSeries::SeriesType type() const;
46 46
@@ -86,7 +86,7 public:
86 86 QAbstractBarSeries::LabelsPosition labelsPosition() const;
87 87
88 88 protected:
89 explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = 0);
89 explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = Q_NULLPTR);
90 90
91 91 Q_SIGNALS:
92 92 void clicked(int index, QBarSet *barset);
@@ -60,6 +60,7 void QBarModelMapper::setModel(QAbstractItemModel *model)
60 60 d->m_model = model;
61 61 d->initializeBarFromModel();
62 62 // connect signals from the model
63 connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializeBarFromModel()));
63 64 connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
64 65 connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int)));
65 66 connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int)));
@@ -47,7 +47,7 class QT_CHARTS_EXPORT QBarModelMapper : public QObject
47 47 Q_OBJECT
48 48
49 49 protected:
50 explicit QBarModelMapper(QObject *parent = 0);
50 explicit QBarModelMapper(QObject *parent = Q_NULLPTR);
51 51
52 52 QAbstractItemModel *model() const;
53 53 void setModel(QAbstractItemModel *model);
@@ -51,7 +51,7 class QT_CHARTS_EXPORT QBarSet : public QObject
51 51 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
52 52
53 53 public:
54 explicit QBarSet(const QString label, QObject *parent = 0);
54 explicit QBarSet(const QString label, QObject *parent = Q_NULLPTR);
55 55 virtual ~QBarSet();
56 56
57 57 void setLabel(const QString label);
@@ -45,7 +45,7 class QT_CHARTS_EXPORT QHBarModelMapper : public QBarModelMapper
45 45 Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
46 46
47 47 public:
48 explicit QHBarModelMapper(QObject *parent = 0);
48 explicit QHBarModelMapper(QObject *parent = Q_NULLPTR);
49 49
50 50 QAbstractItemModel *model() const;
51 51 void setModel(QAbstractItemModel *model);
@@ -45,7 +45,7 class QT_CHARTS_EXPORT QVBarModelMapper : public QBarModelMapper
45 45 Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
46 46
47 47 public:
48 explicit QVBarModelMapper(QObject *parent = 0);
48 explicit QVBarModelMapper(QObject *parent = Q_NULLPTR);
49 49
50 50 QAbstractItemModel *model() const;
51 51 void setModel(QAbstractItemModel *model);
@@ -40,7 +40,7 class QT_CHARTS_EXPORT QBarSeries : public QAbstractBarSeries
40 40 {
41 41 Q_OBJECT
42 42 public:
43 explicit QBarSeries(QObject *parent = 0);
43 explicit QBarSeries(QObject *parent = Q_NULLPTR);
44 44 ~QBarSeries();
45 45 QAbstractSeries::SeriesType type() const;
46 46
@@ -41,7 +41,7 class QT_CHARTS_EXPORT QPercentBarSeries : public QAbstractBarSeries
41 41 {
42 42 Q_OBJECT
43 43 public:
44 explicit QPercentBarSeries(QObject *parent = 0);
44 explicit QPercentBarSeries(QObject *parent = Q_NULLPTR);
45 45 ~QPercentBarSeries();
46 46 QAbstractSeries::SeriesType type() const;
47 47
@@ -41,7 +41,7 class QT_CHARTS_EXPORT QStackedBarSeries : public QAbstractBarSeries
41 41 {
42 42 Q_OBJECT
43 43 public:
44 explicit QStackedBarSeries(QObject *parent = 0);
44 explicit QStackedBarSeries(QObject *parent = Q_NULLPTR);
45 45 ~QStackedBarSeries();
46 46 QAbstractSeries::SeriesType type() const;
47 47
@@ -60,6 +60,7 void QBoxPlotModelMapper::setModel(QAbstractItemModel *model)
60 60 d->m_model = model;
61 61 d->initializeBoxFromModel();
62 62 // connect signals from the model
63 connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializeBoxFromModel()));
63 64 connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
64 65 connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int)));
65 66 connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int)));
@@ -47,7 +47,7 class QT_CHARTS_EXPORT QBoxPlotModelMapper : public QObject
47 47 Q_OBJECT
48 48
49 49 protected:
50 explicit QBoxPlotModelMapper(QObject *parent = 0);
50 explicit QBoxPlotModelMapper(QObject *parent = Q_NULLPTR);
51 51
52 52 QAbstractItemModel *model() const;
53 53 void setModel(QAbstractItemModel *model);
@@ -47,7 +47,7 class QT_CHARTS_EXPORT QBoxPlotSeries : public QAbstractSeries
47 47 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
48 48 Q_PROPERTY(int count READ count NOTIFY countChanged REVISION 1)
49 49 public:
50 explicit QBoxPlotSeries(QObject *parent = 0);
50 explicit QBoxPlotSeries(QObject *parent = Q_NULLPTR);
51 51 ~QBoxPlotSeries();
52 52
53 53 bool append(QBoxSet *box);
@@ -54,8 +54,8 public:
54 54 };
55 55
56 56 public:
57 explicit QBoxSet(const QString label = QString(), QObject *parent = 0);
58 explicit QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label = QString(), QObject *parent = 0);
57 explicit QBoxSet(const QString label = QString(), QObject *parent = Q_NULLPTR);
58 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);
59 59 virtual ~QBoxSet();
60 60
61 61 void append(const qreal value);
@@ -45,7 +45,7 class QT_CHARTS_EXPORT QVBoxPlotModelMapper : public QBoxPlotModelMapper
45 45 Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
46 46
47 47 public:
48 explicit QVBoxPlotModelMapper(QObject *parent = 0);
48 explicit QVBoxPlotModelMapper(QObject *parent = Q_NULLPTR);
49 49
50 50 QAbstractItemModel *model() const;
51 51 void setModel(QAbstractItemModel *model);
@@ -60,10 +60,15 QString ChartTitle::text() const
60 60 void ChartTitle::setGeometry(const QRectF &rect)
61 61 {
62 62 QRectF truncatedRect;
63 QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0),
64 rect.width(), rect.height(),
65 truncatedRect));
66 QGraphicsTextItem::setTextWidth(truncatedRect.width());
63 if (m_text.isEmpty()) {
64 QGraphicsTextItem::setHtml(m_text);
65 QGraphicsTextItem::setTextWidth(0.0);
66 } else {
67 QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0),
68 rect.width(), rect.height(),
69 truncatedRect));
70 QGraphicsTextItem::setTextWidth(truncatedRect.width());
71 }
67 72 setPos(rect.topLeft());
68 73 }
69 74
@@ -65,7 +65,7 void AbstractChartLayout::setGeometry(const QRectF &rect)
65 65
66 66 contentGeometry = calculateContentGeometry(contentGeometry);
67 67
68 if (title && title->isVisible() && !title->text().isEmpty())
68 if (title && title->isVisible())
69 69 contentGeometry = calculateTitleGeometry(contentGeometry, title);
70 70
71 71 if (legend->isAttachedToChart() && legend->isVisible())
@@ -167,11 +167,15 QRectF AbstractChartLayout::calculateLegendMinimum(const QRectF &geometry, QLege
167 167 QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const
168 168 {
169 169 title->setGeometry(geometry);
170 // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases
171 QPointF center((geometry.center() - title->boundingRect().center()).toPoint());
172
173 title->setPos(center.x(), title->pos().y());
174 return geometry.adjusted(0, title->boundingRect().height()+1, 0, 0);
170 if (title->text().isEmpty()) {
171 return geometry;
172 } else {
173 // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases
174 QPointF center((geometry.center() - title->boundingRect().center()).toPoint());
175
176 title->setPos(center.x(), title->pos().y());
177 return geometry.adjusted(0, title->boundingRect().height() + 1, 0, 0);
178 }
175 179 }
176 180
177 181 QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const
@@ -43,7 +43,7 class QT_CHARTS_EXPORT QAreaLegendMarker : public QLegendMarker
43 43 Q_OBJECT
44 44
45 45 public:
46 explicit QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent = 0);
46 explicit QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR);
47 47 virtual ~QAreaLegendMarker();
48 48
49 49 virtual LegendMarkerType type() { return LegendMarkerTypeArea; }
@@ -52,7 +52,7 public:
52 52 virtual QAreaSeries* series();
53 53
54 54 protected:
55 QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent = 0);
55 QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR);
56 56
57 57 private:
58 58 Q_DECLARE_PRIVATE(QAreaLegendMarker)
@@ -43,7 +43,7 class QT_CHARTS_EXPORT QBarLegendMarker : public QLegendMarker
43 43 {
44 44 Q_OBJECT
45 45 public:
46 explicit QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent = 0);
46 explicit QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent = Q_NULLPTR);
47 47 virtual ~QBarLegendMarker();
48 48
49 49 virtual LegendMarkerType type() { return LegendMarkerTypeBar; }
@@ -53,7 +53,7 public:
53 53 QBarSet* barset();
54 54
55 55 protected:
56 QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent = 0);
56 QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR);
57 57
58 58 private:
59 59 Q_DECLARE_PRIVATE(QBarLegendMarker)
@@ -43,7 +43,7 class QT_CHARTS_EXPORT QBoxPlotLegendMarker : public QLegendMarker
43 43 Q_OBJECT
44 44
45 45 public:
46 explicit QBoxPlotLegendMarker(QBoxPlotSeries *series, QLegend *legend, QObject *parent = 0);
46 explicit QBoxPlotLegendMarker(QBoxPlotSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR);
47 47 virtual ~QBoxPlotLegendMarker();
48 48
49 49 virtual LegendMarkerType type() { return LegendMarkerTypeBoxPlot; }
@@ -52,7 +52,7 public:
52 52 virtual QBoxPlotSeries* series();
53 53
54 54 protected:
55 QBoxPlotLegendMarker(QBoxPlotLegendMarkerPrivate &d, QObject *parent = 0);
55 QBoxPlotLegendMarker(QBoxPlotLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR);
56 56
57 57 private:
58 58 Q_DECLARE_PRIVATE(QBoxPlotLegendMarker)
@@ -60,7 +60,7 private:
60 60 public:
61 61 ~QLegend();
62 62
63 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
63 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR);
64 64
65 65 void setBrush(const QBrush &brush);
66 66 QBrush brush() const;
@@ -90,7 +90,7 public:
90 90 void setBackgroundVisible(bool visible = true);
91 91 bool isBackgroundVisible() const;
92 92
93 QList <QLegendMarker*> markers(QAbstractSeries *series = 0) const;
93 QList <QLegendMarker*> markers(QAbstractSeries *series = Q_NULLPTR) const;
94 94
95 95 bool reverseMarkers();
96 96 void setReverseMarkers(bool reverseMarkers = true);
@@ -98,7 +98,7 Q_SIGNALS:
98 98 void visibleChanged();
99 99
100 100 protected:
101 explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = 0);
101 explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR);
102 102
103 103 QScopedPointer<QLegendMarkerPrivate> d_ptr;
104 104 friend class QLegendPrivate;
@@ -44,7 +44,7 class QT_CHARTS_EXPORT QPieLegendMarker : public QLegendMarker
44 44 Q_OBJECT
45 45
46 46 public:
47 explicit QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent = 0);
47 explicit QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent = Q_NULLPTR);
48 48 virtual ~QPieLegendMarker();
49 49
50 50 virtual LegendMarkerType type() { return LegendMarkerTypePie; }
@@ -54,7 +54,7 public:
54 54 QPieSlice* slice();
55 55
56 56 protected:
57 QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = 0);
57 QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR);
58 58
59 59 private:
60 60 Q_DECLARE_PRIVATE(QPieLegendMarker)
@@ -42,7 +42,7 class QT_CHARTS_EXPORT QXYLegendMarker : public QLegendMarker
42 42 {
43 43 Q_OBJECT
44 44 public:
45 explicit QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent = 0);
45 explicit QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR);
46 46 virtual ~QXYLegendMarker();
47 47
48 48 virtual LegendMarkerType type() { return LegendMarkerTypeXY; }
@@ -51,7 +51,7 public:
51 51 virtual QXYSeries* series();
52 52
53 53 protected:
54 QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent = 0);
54 QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR);
55 55
56 56 private:
57 57 Q_DECLARE_PRIVATE(QXYLegendMarker)
@@ -43,12 +43,12 class QT_CHARTS_EXPORT QLineSeries : public QXYSeries
43 43 Q_OBJECT
44 44
45 45 public:
46 explicit QLineSeries(QObject *parent = 0);
46 explicit QLineSeries(QObject *parent = Q_NULLPTR);
47 47 ~QLineSeries();
48 48 QAbstractSeries::SeriesType type() const;
49 49
50 50 protected:
51 QLineSeries(QLineSeriesPrivate &d, QObject *parent = 0);
51 QLineSeries(QLineSeriesPrivate &d, QObject *parent = Q_NULLPTR);
52 52
53 53 private:
54 54 Q_DECLARE_PRIVATE(QLineSeries)
@@ -45,7 +45,7 class QT_CHARTS_EXPORT QHPieModelMapper : public QPieModelMapper
45 45 Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
46 46
47 47 public:
48 explicit QHPieModelMapper(QObject *parent = 0);
48 explicit QHPieModelMapper(QObject *parent = Q_NULLPTR);
49 49
50 50 QAbstractItemModel *model() const;
51 51 void setModel(QAbstractItemModel *model);
@@ -60,6 +60,7 void QPieModelMapper::setModel(QAbstractItemModel *model)
60 60 d->m_model = model;
61 61 d->initializePieFromModel();
62 62 // connect signals from the model
63 connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializePieFromModel()));
63 64 connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
64 65 connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int)));
65 66 connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
@@ -47,7 +47,7 class QT_CHARTS_EXPORT QPieModelMapper : public QObject
47 47 Q_OBJECT
48 48
49 49 protected:
50 explicit QPieModelMapper(QObject *parent = 0);
50 explicit QPieModelMapper(QObject *parent = Q_NULLPTR);
51 51
52 52 QAbstractItemModel *model() const;
53 53 void setModel(QAbstractItemModel *model);
@@ -49,7 +49,7 class QT_CHARTS_EXPORT QPieSeries : public QAbstractSeries
49 49 Q_PROPERTY(qreal holeSize READ holeSize WRITE setHoleSize)
50 50
51 51 public:
52 explicit QPieSeries(QObject *parent = 0);
52 explicit QPieSeries(QObject *parent = Q_NULLPTR);
53 53 virtual ~QPieSeries();
54 54
55 55 QAbstractSeries::SeriesType type() const;
@@ -72,8 +72,8 public:
72 72 };
73 73
74 74 public:
75 explicit QPieSlice(QObject *parent = 0);
76 QPieSlice(QString label, qreal value, QObject *parent = 0);
75 explicit QPieSlice(QObject *parent = Q_NULLPTR);
76 QPieSlice(QString label, qreal value, QObject *parent = Q_NULLPTR);
77 77 virtual ~QPieSlice();
78 78
79 79 void setLabel(QString label);
@@ -45,7 +45,7 class QT_CHARTS_EXPORT QVPieModelMapper : public QPieModelMapper
45 45 Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
46 46
47 47 public:
48 explicit QVPieModelMapper(QObject *parent = 0);
48 explicit QVPieModelMapper(QObject *parent = Q_NULLPTR);
49 49
50 50 QAbstractItemModel *model() const;
51 51 void setModel(QAbstractItemModel *model);
@@ -67,7 +67,7 public:
67 67 };
68 68
69 69 protected:
70 QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = 0);
70 QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = Q_NULLPTR);
71 71
72 72 public:
73 73 ~QAbstractSeries();
@@ -96,7 +96,7 public:
96 96 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
97 97
98 98 public:
99 explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
99 explicit QChart(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags());
100 100 ~QChart();
101 101
102 102 void addSeries(QAbstractSeries *series);
@@ -105,15 +105,15 public:
105 105 QList<QAbstractSeries *> series() const;
106 106
107 107 // *** deprecated ***
108 void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
109 void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
110 QAbstractAxis *axisX(QAbstractSeries *series = 0) const;
111 QAbstractAxis *axisY(QAbstractSeries *series = 0) const;
108 void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR);
109 void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR);
110 QAbstractAxis *axisX(QAbstractSeries *series = Q_NULLPTR) const;
111 QAbstractAxis *axisY(QAbstractSeries *series = Q_NULLPTR) const;
112 112 // ******************
113 113
114 114 void addAxis(QAbstractAxis *axis, Qt::Alignment alignment);
115 115 void removeAxis(QAbstractAxis *axis);
116 QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = 0) const;
116 QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = Q_NULLPTR) const;
117 117
118 118 void createDefaultAxes();
119 119
@@ -173,8 +173,8 public:
173 173 void setLocale(const QLocale &locale);
174 174 QLocale locale() const;
175 175
176 QPointF mapToValue(const QPointF &position, QAbstractSeries *series = 0);
177 QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = 0);
176 QPointF mapToValue(const QPointF &position, QAbstractSeries *series = Q_NULLPTR);
177 QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = Q_NULLPTR);
178 178
179 179 ChartType chartType() const;
180 180
@@ -59,8 +59,8 public:
59 59
60 60 Q_DECLARE_FLAGS(RubberBands, RubberBand)
61 61
62 explicit QChartView(QWidget *parent = 0);
63 explicit QChartView(QChart *chart, QWidget *parent = 0);
62 explicit QChartView(QWidget *parent = Q_NULLPTR);
63 explicit QChartView(QChart *chart, QWidget *parent = Q_NULLPTR);
64 64 ~QChartView();
65 65
66 66 void setRubberBand(const RubberBands &rubberBands);
@@ -51,12 +51,12 public:
51 51 Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation)
52 52
53 53 public:
54 explicit QPolarChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
54 explicit QPolarChart(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags());
55 55 ~QPolarChart();
56 56
57 57 void addAxis(QAbstractAxis *axis, PolarOrientation polarOrientation);
58 58
59 QList<QAbstractAxis*> axes(PolarOrientations polarOrientation = PolarOrientations(PolarOrientationRadial | PolarOrientationAngular), QAbstractSeries *series = 0) const;
59 QList<QAbstractAxis*> axes(PolarOrientations polarOrientation = PolarOrientations(PolarOrientationRadial | PolarOrientationAngular), QAbstractSeries *series = Q_NULLPTR) const;
60 60
61 61 static PolarOrientation axisPolarOrientation(QAbstractAxis *axis);
62 62
@@ -54,7 +54,7 public:
54 54 };
55 55
56 56 public:
57 explicit QScatterSeries(QObject *parent = 0);
57 explicit QScatterSeries(QObject *parent = Q_NULLPTR);
58 58 ~QScatterSeries();
59 59 QAbstractSeries::SeriesType type() const;
60 60 void setPen(const QPen &pen);
@@ -45,7 +45,7 class QT_CHARTS_EXPORT QSplineSeries : public QLineSeries
45 45 Q_OBJECT
46 46
47 47 public:
48 explicit QSplineSeries(QObject *parent = 0);
48 explicit QSplineSeries(QObject *parent = Q_NULLPTR);
49 49 ~QSplineSeries();
50 50 QAbstractSeries::SeriesType type() const;
51 51
@@ -45,7 +45,7 class QT_CHARTS_EXPORT QHXYModelMapper : public QXYModelMapper
45 45 Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
46 46
47 47 public:
48 explicit QHXYModelMapper(QObject *parent = 0);
48 explicit QHXYModelMapper(QObject *parent = Q_NULLPTR);
49 49
50 50 QAbstractItemModel *model() const;
51 51 void setModel(QAbstractItemModel *model);
@@ -45,7 +45,7 class QT_CHARTS_EXPORT QVXYModelMapper : public QXYModelMapper
45 45 Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
46 46
47 47 public:
48 explicit QVXYModelMapper(QObject *parent = 0);
48 explicit QVXYModelMapper(QObject *parent = Q_NULLPTR);
49 49
50 50 QAbstractItemModel *model() const;
51 51 void setModel(QAbstractItemModel *model);
@@ -47,7 +47,7 class QT_CHARTS_EXPORT QXYModelMapper : public QObject
47 47 Q_OBJECT
48 48
49 49 protected:
50 explicit QXYModelMapper(QObject *parent = 0);
50 explicit QXYModelMapper(QObject *parent = Q_NULLPTR);
51 51
52 52 QAbstractItemModel *model() const;
53 53 void setModel(QAbstractItemModel *model);
@@ -56,7 +56,7 class QT_CHARTS_EXPORT QXYSeries : public QAbstractSeries
56 56 Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged)
57 57
58 58 protected:
59 explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = 0);
59 explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = Q_NULLPTR);
60 60
61 61 public:
62 62 ~QXYSeries();
@@ -77,7 +77,7 void DeclarativeBarSet::setValues(QVariantList values)
77 77 while (count())
78 78 remove(count() - 1);
79 79
80 if (values.at(0).canConvert(QVariant::Point)) {
80 if (values.count() > 0 && values.at(0).canConvert(QVariant::Point)) {
81 81 // Create list of values for appending if the first item is Qt.point
82 82 int maxValue = 0;
83 83 for (int i = 0; i < values.count(); i++) {
@@ -520,14 +520,16 QSGNode *DeclarativeChart::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdateP
520 520
521 521 if (!node) {
522 522 node = new DeclarativeChartNode(window());
523 connect(window(), &QQuickWindow::beforeRendering,
524 node->glRenderNode(), &DeclarativeRenderNode::render);
523 if (node->glRenderNode()) {
524 connect(window(), &QQuickWindow::beforeRendering,
525 node->glRenderNode(), &DeclarativeRenderNode::render);
526 }
525 527 }
526 528
527 529 const QRectF &bRect = boundingRect();
528 530
529 531 // Update GL data
530 if (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty()) {
532 if (node->glRenderNode() && (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty())) {
531 533 const QRectF &plotArea = m_chart->plotArea();
532 534 const QSizeF &chartAreaSize = m_chart->size();
533 535
@@ -47,27 +47,27 DeclarativeChartNode::DeclarativeChartNode(QQuickWindow *window) :
47 47 m_textureSize(1, 1),
48 48 m_glRenderNode(0)
49 49 {
50 initializeOpenGLFunctions();
51
52 50 // Our texture node must have a texture, so use a default one pixel texture
53 GLuint defaultTexture = 0;
54 glGenTextures(1, &defaultTexture);
55 glBindTexture(GL_TEXTURE_2D, defaultTexture);
56 uchar buf[4] = { 0, 0, 0, 0 };
57 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &buf);
58
51 QImage dummyImage(QSize(1, 1), QImage::Format_ARGB32);
52 uchar *imageData = dummyImage.bits();
53 imageData[0] = 0;
54 imageData[1] = 0;
55 imageData[2] = 0;
56 imageData[3] = 0;
59 57 QQuickWindow::CreateTextureOptions defaultTextureOptions = QQuickWindow::CreateTextureOptions(
60 58 QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture);
61 m_texture = m_window->createTextureFromId(defaultTexture, QSize(1, 1), defaultTextureOptions);
59 m_texture = m_window->createTextureFromImage(dummyImage, defaultTextureOptions);
62 60
63 61 setTexture(m_texture);
64 62 setFiltering(QSGTexture::Linear);
65 63
66 // Create child node for rendering GL graphics
67 m_glRenderNode = new DeclarativeRenderNode(m_window);
68 m_glRenderNode->setFlag(OwnedByParent);
69 appendChildNode(m_glRenderNode);
70 m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default
64 if (QOpenGLContext::currentContext()) {
65 // Create child node for rendering GL graphics
66 m_glRenderNode = new DeclarativeRenderNode(m_window);
67 m_glRenderNode->setFlag(OwnedByParent);
68 appendChildNode(m_glRenderNode);
69 m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default
70 }
71 71 }
72 72
73 73 DeclarativeChartNode::~DeclarativeChartNode()
@@ -216,9 +216,9 QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QStr
216 216 QList <qreal> newColumn;
217 217 for (int i(0); i < rowCount; i++) {
218 218 if (dataCharacteristics == "Sin") {
219 newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100));
219 newColumn.append(std::abs(sin(3.14159265358979 / 50 * i) * 100));
220 220 } else if (dataCharacteristics == "Sin + random") {
221 newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5));
221 newColumn.append(std::abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5));
222 222 } else if (dataCharacteristics == "Random") {
223 223 newColumn.append(rand() % 10 + (qreal) rand() / (qreal) RAND_MAX);
224 224 } else if (dataCharacteristics == "Linear") {
General Comments 0
You need to be logged in to leave comments. Login now