##// END OF EJS Templates
Fix Qt5 building of quick2 plugin...
Miikka Heikkinen -
r2551:11500bb02eb2
parent child
Show More
@@ -1,124 +1,124
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 "qvboxplotmodelmapper.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 DeclarativeBoxSet::DeclarativeBoxSet(const QString label, QObject *parent)
29 29 : QBoxSet(label, parent)
30 30 {
31 31 connect(this, SIGNAL(valuesChanged()), this, SIGNAL(changedValues()));
32 32 connect(this, SIGNAL(valueChanged(int)), this, SIGNAL(changedValue(int)));
33 33 }
34 34
35 35 QVariantList DeclarativeBoxSet::values()
36 36 {
37 37 QVariantList values;
38 38 for (int i(0); i < 5; i++)
39 39 values.append(QVariant(QBoxSet::at(i)));
40 40 return values;
41 41 }
42 42
43 43 void DeclarativeBoxSet::setValues(QVariantList values)
44 44 {
45 45 for (int i(0); i < values.count(); i++) {
46 46 if (values.at(i).canConvert(QVariant::Double))
47 47 QBoxSet::append(values[i].toDouble());
48 48 }
49 49 }
50 50
51 51 // =====================================================
52 52
53 DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QDeclarativeItem *parent) :
53 DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QDECLARATIVE_ITEM *parent) :
54 54 QBoxPlotSeries(parent),
55 55 m_axes(new DeclarativeAxes(this))
56 56 {
57 57 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
58 58 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
59 59 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
60 60 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
61 61 connect(this, SIGNAL(hovered(bool, QBoxSet*)), this, SLOT(onHovered(bool, QBoxSet*)));
62 62 connect(this, SIGNAL(clicked(QBoxSet*)), this, SLOT(onClicked(QBoxSet*)));
63 63 }
64 64
65 65 void DeclarativeBoxPlotSeries::classBegin()
66 66 {
67 67 }
68 68
69 69 void DeclarativeBoxPlotSeries::componentComplete()
70 70 {
71 71 foreach (QObject *child, children()) {
72 72 if (qobject_cast<DeclarativeBoxSet *>(child)) {
73 73 QBoxPlotSeries::append(qobject_cast<DeclarativeBoxSet *>(child));
74 74 } else if (qobject_cast<QVBoxPlotModelMapper *>(child)) {
75 75 QVBoxPlotModelMapper *mapper = qobject_cast<QVBoxPlotModelMapper *>(child);
76 76 mapper->setSeries(this);
77 77 }
78 78 }
79 79 }
80 80
81 QDeclarativeListProperty<QObject> DeclarativeBoxPlotSeries::seriesChildren()
81 QDECLARATIVE_LIST_PROPERTY<QObject> DeclarativeBoxPlotSeries::seriesChildren()
82 82 {
83 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBoxPlotSeries::appendSeriesChildren);
83 return QDECLARATIVE_LIST_PROPERTY<QObject>(this, 0, &DeclarativeBoxPlotSeries::appendSeriesChildren LIST_PROPERTY_PARAM_DEFAULTS);
84 84 }
85 85
86 void DeclarativeBoxPlotSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
86 void DeclarativeBoxPlotSeries::appendSeriesChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element)
87 87 {
88 88 // Empty implementation; the children are parsed in componentComplete instead
89 89 Q_UNUSED(list);
90 90 Q_UNUSED(element);
91 91 }
92 92
93 93 DeclarativeBoxSet *DeclarativeBoxPlotSeries::at(int index)
94 94 {
95 95 QList<QBoxSet *> setList = boxSets();
96 96 if (index >= 0 && index < setList.count())
97 97 return qobject_cast<DeclarativeBoxSet *>(setList[index]);
98 98
99 99 return 0;
100 100 }
101 101
102 102 DeclarativeBoxSet *DeclarativeBoxPlotSeries::insert(int index, const QString label, QVariantList values)
103 103 {
104 104 DeclarativeBoxSet *barset = new DeclarativeBoxSet(label, this);
105 105 barset->setValues(values);
106 106 if (QBoxPlotSeries::insert(index, barset))
107 107 return barset;
108 108 delete barset;
109 109 return 0;
110 110 }
111 111
112 112 void DeclarativeBoxPlotSeries::onHovered(bool status, QBoxSet *boxset)
113 113 {
114 114 emit hovered(status, qobject_cast<DeclarativeBoxSet *>(boxset));
115 115 }
116 116
117 117 void DeclarativeBoxPlotSeries::onClicked(QBoxSet *boxset)
118 118 {
119 119 emit clicked(qobject_cast<DeclarativeBoxSet *>(boxset));
120 120 }
121 121
122 122 #include "moc_declarativeboxplotseries.cpp"
123 123
124 124 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,119 +1,132
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 #ifdef CHARTS_FOR_QUICK2
28 #include <QtQuick/QQuickItem>
29 #include <QtQml/QQmlParserStatus>
30 #else
27 31 #include <QtDeclarative/QDeclarativeItem>
28 32 #include <QtDeclarative/QDeclarativeParserStatus>
33 #endif
29 34
30 35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 36
32 37 class DeclarativeBoxSet : public QBoxSet
33 38 {
34 39 Q_OBJECT
35 40 Q_PROPERTY(QVariantList values READ values WRITE setValues)
36 41 Q_PROPERTY(QString label READ label WRITE setLabel)
37 42 Q_PROPERTY(int count READ count)
38 43 Q_ENUMS(ValuePositions)
39 44
40 45 public: // duplicate from QBoxSet
41 46 enum ValuePositions {
42 47 LowerExtreme = 0x0,
43 48 LowerQuartile,
44 49 Median,
45 50 UpperQuartile,
46 51 UpperExtreme
47 52 };
48 53
49 54 public:
50 55 explicit DeclarativeBoxSet(const QString label = "", QObject *parent = 0);
51 56 QVariantList values();
52 57 void setValues(QVariantList values);
53 58
54 59 public: // From QBoxSet
55 60 Q_INVOKABLE void append(qreal value) { QBoxSet::append(value); }
56 61 Q_INVOKABLE void clear() {QBoxSet::clear(); }
57 62 Q_INVOKABLE qreal at(int index) { return QBoxSet::at(index); }
58 63 Q_INVOKABLE void setValue(int index, qreal value) { QBoxSet::setValue(index, value); }
59 64
60 65 Q_SIGNALS:
61 66 void changedValues();
62 67 void changedValue(int index);
63 68 };
64 69
65 class DeclarativeBoxPlotSeries : public QBoxPlotSeries, public QDeclarativeParserStatus
70 class DeclarativeBoxPlotSeries : public QBoxPlotSeries, public QDECLARATIVE_PARSER_STATUS
66 71 {
67 72 Q_OBJECT
73 #ifdef CHARTS_FOR_QUICK2
74 Q_INTERFACES(QQmlParserStatus)
75 #else
68 76 Q_INTERFACES(QDeclarativeParserStatus)
77 #endif
69 78 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
70 79 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
71 80 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged)
72 81 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged)
82 #ifdef CHARTS_FOR_QUICK2
83 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
84 #else
73 85 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
86 #endif
74 87 Q_CLASSINFO("DefaultProperty", "seriesChildren")
75 88
76 89 public:
77 explicit DeclarativeBoxPlotSeries(QDeclarativeItem *parent = 0);
90 explicit DeclarativeBoxPlotSeries(QDECLARATIVE_ITEM *parent = 0);
78 91 QAbstractAxis *axisX() { return m_axes->axisX(); }
79 92 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
80 93 QAbstractAxis *axisY() { return m_axes->axisY(); }
81 94 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
82 95 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
83 96 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
84 97 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
85 98 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
86 QDeclarativeListProperty<QObject> seriesChildren();
99 QDECLARATIVE_LIST_PROPERTY<QObject> seriesChildren();
87 100
88 101 public:
89 102 Q_INVOKABLE DeclarativeBoxSet *at(int index);
90 103 Q_INVOKABLE DeclarativeBoxSet *append(const QString label, QVariantList values) { return insert(count(), label, values); }
91 104 Q_INVOKABLE void append(DeclarativeBoxSet *box) { QBoxPlotSeries::append(box); }
92 105 Q_INVOKABLE DeclarativeBoxSet *insert(int index, const QString label, QVariantList values);
93 106 Q_INVOKABLE bool remove(DeclarativeBoxSet *box) { return QBoxPlotSeries::remove(qobject_cast<QBoxSet *>(box)); }
94 107 Q_INVOKABLE void clear() { return QBoxPlotSeries::clear(); }
95 108
96 109 public: // from QDeclarativeParserStatus
97 110 void classBegin();
98 111 void componentComplete();
99 112
100 113 Q_SIGNALS:
101 114 void axisXChanged(QAbstractAxis *axis);
102 115 void axisYChanged(QAbstractAxis *axis);
103 116 void axisXTopChanged(QAbstractAxis *axis);
104 117 void axisYRightChanged(QAbstractAxis *axis);
105 118 void clicked(DeclarativeBoxSet *boxset);
106 119 void hovered(bool status, DeclarativeBoxSet *boxset);
107 120
108 121 public Q_SLOTS:
109 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
122 static void appendSeriesChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element);
110 123 void onHovered(bool status, QBoxSet *boxset);
111 124 void onClicked(QBoxSet *boxset);
112 125
113 126 public:
114 127 DeclarativeAxes *m_axes;
115 128 };
116 129
117 130 QTCOMMERCIALCHART_END_NAMESPACE
118 131
119 132 #endif // DECLARATIVEBOXPLOT_H
General Comments 0
You need to be logged in to leave comments. Login now