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