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 "declarativesplineseries_p.h" |
31 | |
32 | QT_CHARTS_BEGIN_NAMESPACE |
33 | |
34 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : |
35 | QSplineSeries(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 | } |
48 | |
49 | void DeclarativeSplineSeries::handleCountChanged(int index) |
50 | { |
51 | Q_UNUSED(index) |
52 | emit countChanged(count: points().count()); |
53 | } |
54 | |
55 | qreal DeclarativeSplineSeries::width() const |
56 | { |
57 | return pen().widthF(); |
58 | } |
59 | |
60 | void DeclarativeSplineSeries::setWidth(qreal width) |
61 | { |
62 | if (width != pen().widthF()) { |
63 | QPen p = pen(); |
64 | p.setWidthF(width); |
65 | setPen(p); |
66 | emit widthChanged(width); |
67 | } |
68 | } |
69 | |
70 | Qt::PenStyle DeclarativeSplineSeries::style() const |
71 | { |
72 | return pen().style(); |
73 | } |
74 | |
75 | void DeclarativeSplineSeries::setStyle(Qt::PenStyle style) |
76 | { |
77 | if (style != pen().style()) { |
78 | QPen p = pen(); |
79 | p.setStyle(style); |
80 | setPen(p); |
81 | emit styleChanged(style); |
82 | } |
83 | } |
84 | |
85 | Qt::PenCapStyle DeclarativeSplineSeries::capStyle() const |
86 | { |
87 | return pen().capStyle(); |
88 | } |
89 | |
90 | void DeclarativeSplineSeries::setCapStyle(Qt::PenCapStyle capStyle) |
91 | { |
92 | if (capStyle != pen().capStyle()) { |
93 | QPen p = pen(); |
94 | p.setCapStyle(capStyle); |
95 | setPen(p); |
96 | emit capStyleChanged(capStyle); |
97 | } |
98 | } |
99 | |
100 | QQmlListProperty<QObject> DeclarativeSplineSeries::declarativeChildren() |
101 | { |
102 | return QQmlListProperty<QObject>(this, 0, &appendDeclarativeChildren ,0,0,0); |
103 | } |
104 | |
105 | void DeclarativeSplineSeries::appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element) |
106 | { |
107 | Q_UNUSED(list) |
108 | Q_UNUSED(element) |
109 | // Empty implementation, children are parsed in componentComplete |
110 | } |
111 | |
112 | QT_CHARTS_END_NAMESPACE |
113 | |
114 | #include "moc_declarativesplineseries_p.cpp" |
115 | |