1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "declarativescatterseries_p.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : |
9 | QScatterSeries(parent), |
10 | m_axes(new DeclarativeAxes(this)) |
11 | { |
12 | connect(sender: m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisXChanged(QAbstractAxis*))); |
13 | connect(sender: m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisYChanged(QAbstractAxis*))); |
14 | connect(sender: m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
15 | connect(sender: m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
16 | connect(sender: m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisAngularChanged(QAbstractAxis*))); |
17 | connect(sender: m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisRadialChanged(QAbstractAxis*))); |
18 | connect(sender: this, SIGNAL(pointAdded(int)), receiver: this, SLOT(handleCountChanged(int))); |
19 | connect(sender: this, SIGNAL(pointRemoved(int)), receiver: this, SLOT(handleCountChanged(int))); |
20 | connect(sender: this, SIGNAL(pointsRemoved(int, int)), receiver: this, SLOT(handleCountChanged(int))); |
21 | connect(sender: this, SIGNAL(brushChanged()), receiver: this, SLOT(handleBrushChanged())); |
22 | } |
23 | |
24 | void DeclarativeScatterSeries::handleCountChanged(int index) |
25 | { |
26 | Q_UNUSED(index); |
27 | emit countChanged(count: QScatterSeries::count()); |
28 | } |
29 | |
30 | qreal DeclarativeScatterSeries::borderWidth() const |
31 | { |
32 | return pen().widthF(); |
33 | } |
34 | |
35 | void DeclarativeScatterSeries::setBorderWidth(qreal width) |
36 | { |
37 | if (width != pen().widthF()) { |
38 | QPen p = pen(); |
39 | p.setWidthF(width); |
40 | setPen(p); |
41 | emit borderWidthChanged(width); |
42 | } |
43 | } |
44 | |
45 | QQmlListProperty<QObject> DeclarativeScatterSeries::declarativeChildren() |
46 | { |
47 | return QQmlListProperty<QObject>(this, 0, &appendDeclarativeChildren ,0,0,0); |
48 | } |
49 | |
50 | void DeclarativeScatterSeries::appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element) |
51 | { |
52 | Q_UNUSED(list); |
53 | Q_UNUSED(element); |
54 | // Empty implementation, children are parsed in componentComplete |
55 | } |
56 | |
57 | QString DeclarativeScatterSeries::brushFilename() const |
58 | { |
59 | return m_brushFilename; |
60 | } |
61 | |
62 | void DeclarativeScatterSeries::setBrushFilename(const QString &brushFilename) |
63 | { |
64 | QImage brushImage(brushFilename); |
65 | if (QScatterSeries::brush().textureImage() != brushImage) { |
66 | QBrush brush = QScatterSeries::brush(); |
67 | brush.setTextureImage(brushImage); |
68 | QScatterSeries::setBrush(brush); |
69 | m_brushFilename = brushFilename; |
70 | m_brushImage = brushImage; |
71 | emit brushFilenameChanged(brushFilename); |
72 | } |
73 | } |
74 | |
75 | void DeclarativeScatterSeries::setBrush(const QBrush &brush) |
76 | { |
77 | QScatterSeries::setBrush(brush); |
78 | emit brushChanged(); |
79 | } |
80 | |
81 | QBrush DeclarativeScatterSeries::brush() const |
82 | { |
83 | return QScatterSeries::brush(); |
84 | } |
85 | |
86 | void DeclarativeScatterSeries::handleBrushChanged() |
87 | { |
88 | // If the texture image of the brush has changed along the brush |
89 | // the brush file name needs to be cleared. |
90 | if (!m_brushFilename.isEmpty() && QScatterSeries::brush().textureImage() != m_brushImage) { |
91 | m_brushFilename.clear(); |
92 | emit brushFilenameChanged(brushFilename: QString()); |
93 | } |
94 | } |
95 | |
96 | QT_END_NAMESPACE |
97 | |
98 | #include "moc_declarativescatterseries_p.cpp" |
99 | |