Skip to content

Commit d352d70

Browse files
committed
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: .qmake.conf README src/charts/qchartglobal.h tests/auto/chartdataset/tst_chartdataset.cpp tests/auto/domain/tst_domain.cpp Change-Id: Ib4e01f2646d87b691c7b2f8bee4ed1f5521e4f6d
2 parents a7b80c0 + 7a0be48 commit d352d70

27 files changed

+291
-207
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---------------
2-
Qt Charts 5.7.0
2+
Qt Charts
33
---------------
44

55
Qt Charts module provides a set of easy to use chart components. It uses

dist/changes-2.1.2

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Qt Charts 2.1.2
2+
3+
Fixed issues
4+
------------
5+
- [QTBUG-54914] Make OpenGL accelerated series obey series visibility
6+
- [QTBUG-54803] Ensure the chart is drawn whenever the render node is recreated
7+
- [QTBUG-55098] Fix partial blurriness of the gl accelerated graph
8+
- [QTBUG-54763] Clarify QML BarSet::values documentation
9+
- [QTBUG-53073] Fix VXYModelMapper documentation
10+
- [QTBUG-52654] Print console warning when invalid row/column used in model mapper
11+
- [QTBUG-52086] Fix BarSet value rounding
12+
- [QTBUG-53949] Fix axis minimum height in case of multiple axes on same orientation
13+
- [QTBUG-54401] Fix issues with reverse axes
14+
- QChart mapping functions returned unreversed values
15+
- Bounding regions of series were incorrect
16+
- Mouse events gave wrong positions
17+
- Chart scrolling and zooming didn't account for reversed axes
18+
- [QTBUG-55278] Disconnect boxplot series from chart's dataset correctly
19+
- [QTBUG-53337] Fix setting axis color properties to black for the first time
20+
- [QTBUG-55348] Disconnect a series from ChartItem when it is removed from a chart
21+
- Fix logarithmic axis for area chart
22+
23+
Fixed examples
24+
--------------
25+
- [QTBUG-54492] Fix resize handling in Callout example

examples/charts/callout/callout.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@
3232
#include <QtGui/QFontMetrics>
3333
#include <QtWidgets/QGraphicsSceneMouseEvent>
3434
#include <QtGui/QMouseEvent>
35+
#include <QtCharts/QChart>
3536

36-
Callout::Callout(QGraphicsItem * parent):
37-
QGraphicsItem(parent)
37+
Callout::Callout(QChart *chart):
38+
QGraphicsItem(chart),
39+
m_chart(chart)
3840
{
3941
}
4042

4143
QRectF Callout::boundingRect() const
4244
{
43-
QPointF anchor = mapFromParent(m_anchor);
45+
QPointF anchor = mapFromParent(m_chart->mapToPosition(m_anchor));
4446
QRectF rect;
4547
rect.setLeft(qMin(m_rect.left(), anchor.x()));
4648
rect.setRight(qMax(m_rect.right(), anchor.x()));
@@ -56,7 +58,7 @@ void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
5658
QPainterPath path;
5759
path.addRoundedRect(m_rect, 5, 5);
5860

59-
QPointF anchor = mapFromParent(m_anchor);
61+
QPointF anchor = mapFromParent(m_chart->mapToPosition(m_anchor));
6062
if (!m_rect.contains(anchor)) {
6163
QPointF point1, point2;
6264

@@ -88,7 +90,7 @@ void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
8890
point2.setY(y2);
8991

9092
path.moveTo(point1);
91-
path.lineTo(mapFromParent(m_anchor));
93+
path.lineTo(anchor);
9294
path.lineTo(point2);
9395
path = path.simplified();
9496
}
@@ -126,3 +128,9 @@ void Callout::setAnchor(QPointF point)
126128
{
127129
m_anchor = point;
128130
}
131+
132+
void Callout::updateGeometry()
133+
{
134+
prepareGeometryChange();
135+
setPos(m_chart->mapToPosition(m_anchor) + QPoint(10, -50));
136+
}

examples/charts/callout/callout.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,28 @@
3030
#ifndef CALLOUT_H
3131
#define CALLOUT_H
3232

33+
#include <QtCharts/QChartGlobal>
3334
#include <QtWidgets/QGraphicsItem>
3435
#include <QtGui/QFont>
3536

3637
QT_BEGIN_NAMESPACE
3738
class QGraphicsSceneMouseEvent;
3839
QT_END_NAMESPACE
3940

41+
QT_CHARTS_BEGIN_NAMESPACE
42+
class QChart;
43+
QT_CHARTS_END_NAMESPACE
44+
45+
QT_CHARTS_USE_NAMESPACE
46+
4047
class Callout : public QGraphicsItem
4148
{
4249
public:
43-
Callout(QGraphicsItem * parent = 0);
50+
Callout(QChart *parent);
4451

4552
void setText(const QString &text);
4653
void setAnchor(QPointF point);
54+
void updateGeometry();
4755

4856
QRectF boundingRect() const;
4957
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget);
@@ -58,6 +66,7 @@ class Callout : public QGraphicsItem
5866
QRectF m_rect;
5967
QPointF m_anchor;
6068
QFont m_font;
69+
QChart *m_chart;
6170
};
6271

6372
#endif // CALLOUT_H

examples/charts/callout/view.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ void View::resizeEvent(QResizeEvent *event)
9898
m_chart->resize(event->size());
9999
m_coordX->setPos(m_chart->size().width()/2 - 50, m_chart->size().height() - 20);
100100
m_coordY->setPos(m_chart->size().width()/2 + 50, m_chart->size().height() - 20);
101+
foreach (Callout *callout, m_callouts)
102+
callout->updateGeometry();
101103
}
102104
QGraphicsView::resizeEvent(event);
103105
}
@@ -111,6 +113,7 @@ void View::mouseMoveEvent(QMouseEvent *event)
111113

112114
void View::keepCallout()
113115
{
116+
m_callouts.append(m_tooltip);
114117
m_tooltip = new Callout(m_chart);
115118
}
116119

@@ -121,10 +124,9 @@ void View::tooltip(QPointF point, bool state)
121124

122125
if (state) {
123126
m_tooltip->setText(QString("X: %1 \nY: %2 ").arg(point.x()).arg(point.y()));
124-
QXYSeries *series = qobject_cast<QXYSeries *>(sender());
125-
m_tooltip->setAnchor(m_chart->mapToPosition(point, series));
126-
m_tooltip->setPos(m_chart->mapToPosition(point, series) + QPoint(10, -50));
127+
m_tooltip->setAnchor(point);
127128
m_tooltip->setZValue(11);
129+
m_tooltip->updateGeometry();
128130
m_tooltip->show();
129131
} else {
130132
m_tooltip->hide();

examples/charts/callout/view.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public slots:
6666
QGraphicsSimpleTextItem *m_coordY;
6767
QChart *m_chart;
6868
Callout *m_tooltip;
69+
QList<Callout *> m_callouts;
6970
};
7071

7172
#endif

src/charts/areachart/areachartitem.cpp

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <QtCharts/QLineSeries>
3434
#include <private/chartpresenter_p.h>
3535
#include <private/abstractdomain_p.h>
36+
#include <private/chartdataset_p.h>
3637
#include <QtGui/QPainter>
3738
#include <QtWidgets/QGraphicsSceneMouseEvent>
3839
#include <QtCore/QDebug>
@@ -171,18 +172,26 @@ void AreaChartItem::handleUpdated()
171172

172173
void AreaChartItem::handleDomainUpdated()
173174
{
174-
if (m_upper) {
175-
AbstractDomain* d = m_upper->domain();
176-
d->setSize(domain()->size());
177-
d->setRange(domain()->minX(),domain()->maxX(),domain()->minY(),domain()->maxY());
178-
m_upper->handleDomainUpdated();
179-
}
175+
fixEdgeSeriesDomain(m_upper);
176+
fixEdgeSeriesDomain(m_lower);
177+
}
180178

181-
if (m_lower) {
182-
AbstractDomain* d = m_lower->domain();
183-
d->setSize(domain()->size());
184-
d->setRange(domain()->minX(),domain()->maxX(),domain()->minY(),domain()->maxY());
185-
m_lower->handleDomainUpdated();
179+
void AreaChartItem::fixEdgeSeriesDomain(LineChartItem *edgeSeries)
180+
{
181+
if (edgeSeries) {
182+
AbstractDomain* mainDomain = domain();
183+
AbstractDomain* edgeDomain = edgeSeries->domain();
184+
185+
if (edgeDomain->type() != mainDomain->type()) {
186+
// Change the domain of edge series to the same type as the area series
187+
edgeDomain = dataSet()->createDomain(mainDomain->type());
188+
edgeSeries->seriesPrivate()->setDomain(edgeDomain);
189+
}
190+
edgeDomain->setSize(mainDomain->size());
191+
edgeDomain->setRange(mainDomain->minX(), mainDomain->maxX(), mainDomain->minY(), mainDomain->maxY());
192+
edgeDomain->setReverseX(mainDomain->isReverseX());
193+
edgeDomain->setReverseY(mainDomain->isReverseY());
194+
edgeSeries->handleDomainUpdated();
186195
}
187196
}
188197

@@ -199,8 +208,6 @@ void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
199208
else
200209
painter->setClipRect(clipRect);
201210

202-
reversePainter(painter, clipRect);
203-
204211
painter->drawPath(m_path);
205212
if (m_pointsVisible) {
206213
painter->setPen(m_pointPen);
@@ -209,8 +216,6 @@ void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
209216
painter->drawPoints(m_lower->geometryPoints());
210217
}
211218

212-
reversePainter(painter, clipRect);
213-
214219
// Draw series point label
215220
if (m_pointLabelsVisible) {
216221
static const QString xPointTag(QLatin1String("@xPoint"));
@@ -239,17 +244,9 @@ void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
239244
// Position text in relation to the point
240245
int pointLabelWidth = fm.width(pointLabel);
241246
QPointF position(m_upper->geometryPoints().at(i));
242-
if (!seriesPrivate()->reverseXAxis())
243-
position.setX(position.x() - pointLabelWidth / 2);
244-
else
245-
position.setX(domain()->size().width() - position.x() - pointLabelWidth / 2);
246-
if (!seriesPrivate()->reverseYAxis()) {
247-
position.setY(position.y() - m_series->upperSeries()->pen().width() / 2
248-
- labelOffset);
249-
} else {
250-
position.setY(domain()->size().height() - position.y()
251-
- m_series->upperSeries()->pen().width() / 2 - labelOffset);
252-
}
247+
position.setX(position.x() - pointLabelWidth / 2);
248+
position.setY(position.y() - m_series->upperSeries()->pen().width() / 2
249+
- labelOffset);
253250
painter->drawText(position, pointLabel);
254251
}
255252
}
@@ -265,17 +262,9 @@ void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
265262
// Position text in relation to the point
266263
int pointLabelWidth = fm.width(pointLabel);
267264
QPointF position(m_lower->geometryPoints().at(i));
268-
if (!seriesPrivate()->reverseXAxis())
269-
position.setX(position.x() - pointLabelWidth / 2);
270-
else
271-
position.setX(domain()->size().width() - position.x() - pointLabelWidth / 2);
272-
if (!seriesPrivate()->reverseYAxis()) {
273-
position.setY(position.y() - m_series->lowerSeries()->pen().width() / 2
274-
- labelOffset);
275-
} else {
276-
position.setY(domain()->size().height() - position.y()
277-
- m_series->lowerSeries()->pen().width() / 2 - labelOffset);
278-
}
265+
position.setX(position.x() - pointLabelWidth / 2);
266+
position.setY(position.y() - m_series->lowerSeries()->pen().width() / 2
267+
- labelOffset);
279268
painter->drawText(position, pointLabel);
280269
}
281270
}

src/charts/areachart/areachartitem_p.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public Q_SLOTS:
8787
void handleDomainUpdated();
8888

8989
private:
90+
void fixEdgeSeriesDomain(LineChartItem *edgeSeries);
91+
9092
QAreaSeries *m_series;
9193
LineChartItem *m_upper;
9294
LineChartItem *m_lower;

src/charts/axis/qabstractaxis.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ QPen QAbstractAxis::linePen() const
523523
void QAbstractAxis::setLinePenColor(QColor color)
524524
{
525525
QPen p = linePen();
526-
if (p.color() != color) {
526+
if (p.color() != color || d_ptr->m_axisPen == QChartPrivate::defaultPen()) {
527527
p.setColor(color);
528528
setLinePen(p);
529529
emit colorChanged(color);
@@ -618,31 +618,31 @@ QPen QAbstractAxis::minorGridLinePen() const
618618
void QAbstractAxis::setGridLineColor(const QColor &color)
619619
{
620620
QPen pen = gridLinePen();
621-
if (color != pen.color()) {
621+
if (color != pen.color() || d_ptr->m_gridLinePen == QChartPrivate::defaultPen()) {
622622
pen.setColor(color);
623-
d_ptr->m_gridLinePen = pen;
623+
setGridLinePen(pen);
624624
emit gridLineColorChanged(color);
625625
}
626626
}
627627

628628
QColor QAbstractAxis::gridLineColor()
629629
{
630-
return d_ptr->m_gridLinePen.color();
630+
return gridLinePen().color();
631631
}
632632

633633
void QAbstractAxis::setMinorGridLineColor(const QColor &color)
634634
{
635635
QPen pen = minorGridLinePen();
636-
if (color != pen.color()) {
636+
if (color != pen.color() || d_ptr->m_minorGridLinePen == QChartPrivate::defaultPen()) {
637637
pen.setColor(color);
638-
d_ptr->m_minorGridLinePen = pen;
638+
setMinorGridLinePen(pen);
639639
emit minorGridLineColorChanged(color);
640640
}
641641
}
642642

643643
QColor QAbstractAxis::minorGridLineColor()
644644
{
645-
return d_ptr->m_minorGridLinePen.color();
645+
return minorGridLinePen().color();
646646
}
647647

648648
void QAbstractAxis::setLabelsVisible(bool visible)
@@ -717,7 +717,7 @@ int QAbstractAxis::labelsAngle() const
717717
void QAbstractAxis::setLabelsColor(QColor color)
718718
{
719719
QBrush b = labelsBrush();
720-
if (b.color() != color) {
720+
if (b.color() != color || d_ptr->m_labelsBrush == QChartPrivate::defaultBrush()) {
721721
b.setColor(color);
722722
setLabelsBrush(b);
723723
emit labelsColorChanged(color);
@@ -860,7 +860,7 @@ QBrush QAbstractAxis::shadesBrush() const
860860
void QAbstractAxis::setShadesColor(QColor color)
861861
{
862862
QBrush b = shadesBrush();
863-
if (b.color() != color) {
863+
if (b.color() != color || d_ptr->m_shadesBrush == QChartPrivate::defaultBrush()) {
864864
b.setColor(color);
865865
setShadesBrush(b);
866866
emit shadesColorChanged(color);
@@ -874,8 +874,8 @@ QColor QAbstractAxis::shadesColor() const
874874

875875
void QAbstractAxis::setShadesBorderColor(QColor color)
876876
{
877-
QPen p = d_ptr->m_shadesPen;
878-
if (p.color() != color) {
877+
QPen p = shadesPen();
878+
if (p.color() != color || d_ptr->m_shadesPen == QChartPrivate::defaultPen()) {
879879
p.setColor(color);
880880
setShadesPen(p);
881881
emit shadesColorChanged(color);

src/charts/boxplotchart/qboxplotseries.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,10 @@ void QBoxPlotSeriesPrivate::handleSeriesRemove(QAbstractSeries *series)
535535

536536
QBoxPlotSeries *removedSeries = static_cast<QBoxPlotSeries *>(series);
537537

538-
if (q == removedSeries && m_animation) {
539-
m_animation->stopAll();
540-
QObject::disconnect(m_chart->d_ptr->m_dataset, 0, removedSeries->d_func(), 0);
538+
if (q == removedSeries) {
539+
if (m_animation)
540+
m_animation->stopAll();
541+
QObject::disconnect(m_chart->d_ptr->m_dataset, 0, this, 0);
541542
}
542543

543544
// Test if series removed is me, then don't do anything

src/charts/chartdataset_p.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class Q_AUTOTEST_EXPORT ChartDataSet : public QObject
8181

8282
GLXYSeriesDataManager *glXYSeriesDataManager() { return m_glXYSeriesDataManager; }
8383

84+
AbstractDomain* createDomain(AbstractDomain::DomainType type);
85+
8486
Q_SIGNALS:
8587
void axisAdded(QAbstractAxis* axis);
8688
void axisRemoved(QAbstractAxis* axis);
@@ -92,7 +94,6 @@ public Q_SLOTS:
9294
void createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation orientation);
9395
QAbstractAxis *createAxis(QAbstractAxis::AxisType type, Qt::Orientation orientation);
9496
AbstractDomain::DomainType selectDomain(QList<QAbstractAxis* > axes);
95-
AbstractDomain* createDomain(AbstractDomain::DomainType type);
9697
void deleteAllAxes();
9798
void deleteAllSeries();
9899
void findMinMaxForSeries(QList<QAbstractSeries *> series,Qt::Orientations orientation, qreal &min, qreal &max);

src/charts/chartitem.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ void ChartItem::handleDomainUpdated()
5252
qWarning() << __FUNCTION__<< "Slot not implemented";
5353
}
5454

55-
void ChartItem::reversePainter(QPainter *painter, const QRectF &clipRect)
56-
{
57-
if (m_series->reverseXAxis()) {
58-
painter->translate(clipRect.width(), 0);
59-
painter->scale(-1, 1);
60-
}
61-
62-
if (m_series->reverseYAxis()) {
63-
painter->translate(0, clipRect.height());
64-
painter->scale(1, -1);
65-
}
66-
}
67-
6855
#include "moc_chartitem_p.cpp"
6956

7057
QT_CHARTS_END_NAMESPACE

0 commit comments

Comments
 (0)