##// END OF EJS Templates
Compilation quick fix...
Mika Salmela -
r2521:15f3290030f0
parent child
Show More
@@ -1,126 +1,123
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2013 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativebarseries.h"
22 22 #include "declarativeboxplotseries.h"
23 23 #include "qboxset.h"
24 24 #include "qvbarmodelmapper.h"
25 25 #include "qhbarmodelmapper.h"
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 29 DeclarativeBoxSet::DeclarativeBoxSet(QObject *parent)
30 : QBoxSet(parent)
30 : QBoxSet("", parent)
31 31 {
32 32 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int)));
33 33 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int)));
34 34 }
35 35
36 36 void DeclarativeBoxSet::handleCountChanged(int index, int count)
37 37 {
38 38 Q_UNUSED(index)
39 39 Q_UNUSED(count)
40 40 emit countChanged(QBoxSet::count());
41 41 }
42 42
43 43 QVariantList DeclarativeBoxSet::values()
44 44 {
45 45 QVariantList values;
46 46 for (int i(0); i < count(); i++)
47 47 values.append(QVariant(QBoxSet::at(i)));
48 48 return values;
49 49 }
50 50
51 51 void DeclarativeBoxSet::setValues(QVariantList values)
52 52 {
53 while (count())
54 remove(count() - 1);
55
56 53 for (int i(0); i < values.count(); i++) {
57 54 if (values.at(i).canConvert(QVariant::Double))
58 55 QBoxSet::append(values[i].toDouble());
59 56 }
60 57 }
61 58
62 59
63 60 DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QDeclarativeItem *parent) :
64 61 QBoxPlotSeries(parent),
65 62 m_axes(new DeclarativeAxes(this))
66 63 {
67 64 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
68 65 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
69 66 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
70 67 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
71 68 }
72 69
73 70 void DeclarativeBoxPlotSeries::classBegin()
74 71 {
75 72 }
76 73
77 74 void DeclarativeBoxPlotSeries::componentComplete()
78 75 {
79 76 foreach (QObject *child, children()) {
80 77 if (qobject_cast<DeclarativeBoxSet *>(child)) {
81 78 QBoxPlotSeries::append(qobject_cast<DeclarativeBoxSet *>(child));
82 79 } else if (qobject_cast<QVBarModelMapper *>(child)) {
83 80 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
84 81 //mapper->setSeries(this);
85 82 } else if (qobject_cast<QHBarModelMapper *>(child)) {
86 83 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
87 84 //mapper->setSeries(this);
88 85 }
89 86 }
90 87 }
91 88
92 89 QDeclarativeListProperty<QObject> DeclarativeBoxPlotSeries::seriesChildren()
93 90 {
94 91 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBoxPlotSeries::appendSeriesChildren);
95 92 }
96 93
97 94 void DeclarativeBoxPlotSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
98 95 {
99 96 // Empty implementation; the children are parsed in componentComplete instead
100 97 Q_UNUSED(list);
101 98 Q_UNUSED(element);
102 99 }
103 100
104 101 DeclarativeBoxSet *DeclarativeBoxPlotSeries::at(int index)
105 102 {
106 103 QList<QBoxSet *> setList = boxSets();
107 104 if (index >= 0 && index < setList.count())
108 105 return qobject_cast<DeclarativeBoxSet *>(setList[index]);
109 106
110 107 return 0;
111 108 }
112 109
113 110 DeclarativeBoxSet *DeclarativeBoxPlotSeries::insert(int index, QVariantList values)
114 111 {
115 112 DeclarativeBoxSet *barset = new DeclarativeBoxSet(this);
116 113 barset->setValues(values);
117 114 if (QBoxPlotSeries::insert(index, barset))
118 115 return barset;
119 116 delete barset;
120 117 return 0;
121 118 }
122 119
123 120
124 121 #include "moc_declarativeboxplotseries.cpp"
125 122
126 123 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,105 +1,104
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2013 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVEBOXPLOT_H
22 22 #define DECLARATIVEBOXPLOT_H
23 23
24 24 #include "qboxset.h"
25 25 #include "declarativeaxes.h"
26 26 #include "qboxplotseries.h"
27 27 #include <QtDeclarative/QDeclarativeItem>
28 28 #include <QtDeclarative/QDeclarativeParserStatus>
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 class DeclarativeBoxSet : public QBoxSet
33 33 {
34 34 Q_OBJECT
35 35 Q_PROPERTY(QVariantList values READ values WRITE setValues)
36 36 Q_PROPERTY(int count READ count NOTIFY countChanged)
37 37
38 38 public:
39 39 explicit DeclarativeBoxSet(QObject *parent = 0);
40 40 QVariantList values();
41 41 void setValues(QVariantList values);
42 42
43 43 public: // From QBoxSet
44 44 Q_INVOKABLE void append(qreal value) { QBoxSet::append(value); }
45 Q_INVOKABLE void remove(const int index, const int count = 1) { QBoxSet::remove(index, count); }
46 45 Q_INVOKABLE void replace(int index, qreal value) { QBoxSet::replace(index, value); }
47 46 Q_INVOKABLE qreal at(int index) { return QBoxSet::at(index); }
48 47
49 48 Q_SIGNALS:
50 49 void countChanged(int count);
51 50
52 51 private Q_SLOTS:
53 52 void handleCountChanged(int index, int count);
54 53 };
55 54
56 55 class DeclarativeBoxPlotSeries : public QBoxPlotSeries, public QDeclarativeParserStatus
57 56 {
58 57 Q_OBJECT
59 58 Q_INTERFACES(QDeclarativeParserStatus)
60 59 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
61 60 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
62 61 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
63 62 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
64 63 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
65 64 Q_CLASSINFO("DefaultProperty", "seriesChildren")
66 65
67 66 public:
68 67 explicit DeclarativeBoxPlotSeries(QDeclarativeItem *parent = 0);
69 68 QAbstractAxis *axisX() { return m_axes->axisX(); }
70 69 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
71 70 QAbstractAxis *axisY() { return m_axes->axisY(); }
72 71 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
73 72 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
74 73 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
75 74 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
76 75 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
77 76 QDeclarativeListProperty<QObject> seriesChildren();
78 77
79 78 public:
80 79 Q_INVOKABLE DeclarativeBoxSet *at(int index);
81 80 Q_INVOKABLE DeclarativeBoxSet *append(QVariantList values) { return insert(count(), values); }
82 81 Q_INVOKABLE DeclarativeBoxSet *insert(int index, QVariantList values);
83 82 Q_INVOKABLE bool remove(QBoxSet *boxset) { return QBoxPlotSeries::remove(boxset); }
84 83 Q_INVOKABLE void clear() { return QBoxPlotSeries::clear(); }
85 84
86 85 public: // from QDeclarativeParserStatus
87 86 void classBegin();
88 87 void componentComplete();
89 88
90 89 Q_SIGNALS:
91 90 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
92 91 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
93 92 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
94 93 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
95 94
96 95 public Q_SLOTS:
97 96 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
98 97
99 98 public:
100 99 DeclarativeAxes *m_axes;
101 100 };
102 101
103 102 QTCOMMERCIALCHART_END_NAMESPACE
104 103
105 104 #endif // DECLARATIVEBOXPLOT_H
General Comments 0
You need to be logged in to leave comments. Login now