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