1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Charts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#include "declarativescatterseries_p.h"
31
32QT_CHARTS_BEGIN_NAMESPACE
33
34DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
35 QScatterSeries(parent),
36 m_axes(new DeclarativeAxes(this))
37{
38 connect(sender: m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisXChanged(QAbstractAxis*)));
39 connect(sender: m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisYChanged(QAbstractAxis*)));
40 connect(sender: m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
41 connect(sender: m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
42 connect(sender: m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisAngularChanged(QAbstractAxis*)));
43 connect(sender: m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisRadialChanged(QAbstractAxis*)));
44 connect(sender: this, SIGNAL(pointAdded(int)), receiver: this, SLOT(handleCountChanged(int)));
45 connect(sender: this, SIGNAL(pointRemoved(int)), receiver: this, SLOT(handleCountChanged(int)));
46 connect(sender: this, SIGNAL(pointsRemoved(int, int)), receiver: this, SLOT(handleCountChanged(int)));
47 connect(sender: this, SIGNAL(brushChanged()), receiver: this, SLOT(handleBrushChanged()));
48}
49
50void DeclarativeScatterSeries::handleCountChanged(int index)
51{
52 Q_UNUSED(index)
53 emit countChanged(count: QScatterSeries::count());
54}
55
56qreal DeclarativeScatterSeries::borderWidth() const
57{
58 return pen().widthF();
59}
60
61void DeclarativeScatterSeries::setBorderWidth(qreal width)
62{
63 if (width != pen().widthF()) {
64 QPen p = pen();
65 p.setWidthF(width);
66 setPen(p);
67 emit borderWidthChanged(width);
68 }
69}
70
71QQmlListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
72{
73 return QQmlListProperty<QObject>(this, 0, &appendDeclarativeChildren ,0,0,0);
74}
75
76void DeclarativeScatterSeries::appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element)
77{
78 Q_UNUSED(list)
79 Q_UNUSED(element)
80 // Empty implementation, children are parsed in componentComplete
81}
82
83QString DeclarativeScatterSeries::brushFilename() const
84{
85 return m_brushFilename;
86}
87
88void DeclarativeScatterSeries::setBrushFilename(const QString &brushFilename)
89{
90 QImage brushImage(brushFilename);
91 if (QScatterSeries::brush().textureImage() != brushImage) {
92 QBrush brush = QScatterSeries::brush();
93 brush.setTextureImage(brushImage);
94 QScatterSeries::setBrush(brush);
95 m_brushFilename = brushFilename;
96 m_brushImage = brushImage;
97 emit brushFilenameChanged(brushFilename);
98 }
99}
100
101void DeclarativeScatterSeries::setBrush(const QBrush &brush)
102{
103 QScatterSeries::setBrush(brush);
104 emit brushChanged();
105}
106
107QBrush DeclarativeScatterSeries::brush() const
108{
109 return QScatterSeries::brush();
110}
111
112void DeclarativeScatterSeries::handleBrushChanged()
113{
114 // If the texture image of the brush has changed along the brush
115 // the brush file name needs to be cleared.
116 if (!m_brushFilename.isEmpty() && QScatterSeries::brush().textureImage() != m_brushImage) {
117 m_brushFilename.clear();
118 emit brushFilenameChanged(brushFilename: QString(""));
119 }
120}
121
122QT_CHARTS_END_NAMESPACE
123
124#include "moc_declarativescatterseries_p.cpp"
125

source code of qtcharts/src/chartsqml2/declarativescatterseries.cpp