@@ -1,77 +1,58 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 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 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | Rectangle { |
|
25 | 25 | anchors.fill: parent |
|
26 | 26 | |
|
27 | 27 | ChartView { |
|
28 | 28 | title: "Bar series" |
|
29 | 29 | anchors.fill: parent |
|
30 | 30 | theme: ChartView.ChartThemeLight |
|
31 | 31 | legend: ChartView.LegendBottom |
|
32 | 32 | // axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] |
|
33 | 33 | axisX.max: 10 |
|
34 | 34 | |
|
35 | 35 | BarSeries { |
|
36 | 36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
37 | model: barModel | |
|
37 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
38 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
|
39 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
|
38 | 40 | } |
|
39 | 41 | |
|
40 |
|
|
|
42 | // TODO: optional syntax with ChartModel base model API | |
|
41 | 43 | // BarSeries { |
|
42 | 44 | // model: chartModel |
|
43 | 45 | // modelMapping: BarSeriesMapping { |
|
44 | // // Giving "undefined" x mapping value means that the indexes are used as x-values | |
|
45 | // setIndexes: [BarSeriesMapping.Undefined, 0, | |
|
46 | // BarSeriesMapping.Undefined, 1, | |
|
47 | // BarSeriesMapping.Undefined, 2] // defaults to [] | |
|
48 | //// setValues: [ | |
|
49 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 0}, | |
|
50 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 1}, | |
|
51 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 2} | |
|
52 | //// ] | |
|
53 | // orientation: BarSeriesMapping.Vertical // defaults to Vertical | |
|
46 | // ? | |
|
54 | 47 | // startIndex: 0 // defaults to 0 |
|
55 | 48 | // count: BarSeriesMapping.Undefined // defaults to "Undefined" |
|
56 | 49 | // } |
|
57 | 50 | // } |
|
58 | } | |
|
59 | ||
|
60 | 51 | // ChartModel { |
|
61 | 52 | // id: chartModel |
|
53 | // ChartModelElement { values: ["Bob", 2, 2, 3, 4, 5, 6] } | |
|
54 | // ChartModelElement { values: ["Susan", 5, 1, 2, 4, 1, 7] } | |
|
55 | // ChartModelElement { values: ["James", 3, 5, 8, 13, 5, 8] } | |
|
62 | 56 | // } |
|
63 | ||
|
64 | BarModel { | |
|
65 | id: barModel | |
|
66 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
67 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
|
68 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
|
69 | 57 | } |
|
70 | ||
|
71 | // TODO | |
|
72 | // Component.onCompleted: { | |
|
73 | // bobBars.append(1.2); | |
|
74 | // bobBars.append(1.5); | |
|
75 | // bobBars.append([1.5, 1.4, 1.9]); | |
|
76 | // } | |
|
77 | 58 | } |
@@ -1,97 +1,106 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 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 "declarativechart.h" |
|
23 | 23 | #include <QBarSet> |
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : |
|
28 | 28 | QBarSet("", parent) |
|
29 | 29 | { |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | QVariantList DeclarativeBarSet::values() |
|
33 | 33 | { |
|
34 | 34 | QVariantList values; |
|
35 | 35 | for (int i(0); i < count(); i++) |
|
36 | 36 | values.append(QVariant(at(i))); |
|
37 | 37 | return values; |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | void DeclarativeBarSet::setValues(QVariantList values) |
|
41 | 41 | { |
|
42 | 42 | while (count()) |
|
43 | 43 | remove(count() - 1); |
|
44 | 44 | |
|
45 | 45 | for (int i(0); i < values.count(); i++) { |
|
46 | 46 | if (values.at(i).canConvert(QVariant::Double)) |
|
47 | 47 | append(values[i].toDouble()); |
|
48 | 48 | } |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
52 | QBarSeries(parent) | |
|
52 | QGroupedBarSeries(parent) | |
|
53 | 53 | { |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | void DeclarativeBarSeries::classBegin() |
|
57 | 57 | { |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | void DeclarativeBarSeries::componentComplete() |
|
61 | 61 | { |
|
62 | // if (model()) | |
|
63 | // setModelMapping(0, 1, 1, Qt::Vertical); | |
|
62 | foreach(QObject *child, children()) { | |
|
63 | if (qobject_cast<QBarSet *>(child)) { | |
|
64 | qDebug() << "append bar set:" << child; | |
|
65 | QBarSeries::appendBarSet(qobject_cast<QBarSet *>(child)); | |
|
66 | } | |
|
67 | } | |
|
68 | } | |
|
69 | ||
|
70 | QDeclarativeListProperty<DeclarativeBarSet> DeclarativeBarSeries::initialBarSets() | |
|
71 | { | |
|
72 | return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeBarSeries::appendInitialBarSets); | |
|
64 | 73 | } |
|
65 | 74 | |
|
66 |
bool DeclarativeBarSeries::setDeclarativeModel(Declarative |
|
|
75 | bool DeclarativeBarSeries::setDeclarativeModel(DeclarativeTableModel *model) | |
|
67 | 76 | { |
|
68 | 77 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
69 | 78 | bool value(false); |
|
70 | 79 | if (m) { |
|
71 | 80 | setModel(m); |
|
72 | 81 | //setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
73 | 82 | // setModelMapping(0, 1, 1, Qt::Vertical); |
|
74 | 83 | } else { |
|
75 | 84 | qWarning("DeclarativeBarSeries: Illegal model"); |
|
76 | 85 | } |
|
77 | 86 | return value; |
|
78 | 87 | } |
|
79 | 88 | |
|
80 |
Declarative |
|
|
89 | DeclarativeTableModel *DeclarativeBarSeries::declarativeModel() | |
|
81 | 90 | { |
|
82 |
return qobject_cast<Declarative |
|
|
91 | return qobject_cast<DeclarativeTableModel *>(model()); | |
|
83 | 92 | } |
|
84 | 93 | |
|
85 | 94 | void DeclarativeBarSeries::setBarCategories(QStringList categories) |
|
86 | 95 | { |
|
87 | 96 | setCategories(categories); |
|
88 | 97 | } |
|
89 | 98 | |
|
90 | 99 | QStringList DeclarativeBarSeries::barCategories() |
|
91 | 100 | { |
|
92 | 101 | return categories(); |
|
93 | 102 | } |
|
94 | 103 | |
|
95 | 104 | #include "moc_declarativebarseries.cpp" |
|
96 | 105 | |
|
97 | 106 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,76 +1,75 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 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 DECLARATIVEBARSERIES_H |
|
22 | 22 | #define DECLARATIVEBARSERIES_H |
|
23 | 23 | |
|
24 | 24 | #include "qchartglobal.h" |
|
25 | 25 | #include "declarativemodel.h" |
|
26 | 26 | #include <QDeclarativeItem> |
|
27 | 27 | #include <QDeclarativeParserStatus> |
|
28 | #include <QBarSeries> | |
|
28 | #include <QGroupedBarSeries> | |
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | class QChart; |
|
33 | class QBarSeries; | |
|
34 | 33 | |
|
35 | 34 | class DeclarativeBarSet : public QBarSet |
|
36 | 35 | { |
|
37 | 36 | Q_OBJECT |
|
38 | 37 | Q_PROPERTY(QVariantList values READ values WRITE setValues) |
|
39 | 38 | Q_PROPERTY(QString name READ name WRITE setName) |
|
40 | 39 | |
|
41 | 40 | public: |
|
42 | 41 | explicit DeclarativeBarSet(QObject *parent = 0); |
|
43 | 42 | QVariantList values(); |
|
44 | 43 | void setValues(QVariantList values); |
|
45 | 44 | }; |
|
46 | 45 | |
|
47 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |
|
46 | class DeclarativeBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus | |
|
48 | 47 | { |
|
49 | 48 | Q_OBJECT |
|
50 | 49 | Q_INTERFACES(QDeclarativeParserStatus) |
|
51 |
Q_PROPERTY(Declarative |
|
|
50 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) | |
|
52 | 51 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) |
|
52 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets) | |
|
53 | Q_CLASSINFO("DefaultProperty", "initialBarSets") | |
|
53 | 54 | |
|
54 | 55 | public: |
|
55 | 56 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
57 | QDeclarativeListProperty<DeclarativeBarSet> initialBarSets(); | |
|
56 | 58 | |
|
57 | 59 | public: // from QDeclarativeParserStatus |
|
58 | 60 | void classBegin(); |
|
59 | 61 | void componentComplete(); |
|
60 | 62 | |
|
61 | 63 | public: |
|
62 |
bool setDeclarativeModel(Declarative |
|
|
63 |
Declarative |
|
|
64 | bool setDeclarativeModel(DeclarativeTableModel *model); | |
|
65 | DeclarativeTableModel *declarativeModel(); | |
|
64 | 66 | void setBarCategories(QStringList categories); |
|
65 | 67 | QStringList barCategories(); |
|
66 | 68 | |
|
67 | Q_SIGNALS: | |
|
68 | ||
|
69 | 69 | public Q_SLOTS: |
|
70 | ||
|
71 | public: | |
|
70 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> */*list*/, DeclarativeBarSet */*element*/) {} | |
|
72 | 71 | }; |
|
73 | 72 | |
|
74 | 73 | QTCOMMERCIALCHART_END_NAMESPACE |
|
75 | 74 | |
|
76 | 75 | #endif // DECLARATIVEBARSERIES_H |
@@ -1,132 +1,111 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 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 "declarativemodel.h" |
|
22 | 22 | #include <qdeclarativelist.h> |
|
23 | 23 | #include <QDebug> |
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | ////////////// Table model row /////////////////// |
|
29 | 29 | |
|
30 | 30 | DeclarativeTableModelElement::DeclarativeTableModelElement(QObject *parent) |
|
31 | 31 | : QObject(parent) |
|
32 | 32 | { |
|
33 | 33 | } |
|
34 | 34 | |
|
35 | 35 | QVariantList DeclarativeTableModelElement::values() |
|
36 | 36 | { |
|
37 | 37 | return m_values; |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | void DeclarativeTableModelElement::setValues(QVariantList values) |
|
41 | 41 | { |
|
42 | 42 | m_values = values; |
|
43 | 43 | } |
|
44 | 44 | |
|
45 | 45 | ////////////// Table model /////////////////// |
|
46 | 46 | |
|
47 | 47 | DeclarativeTableModel::DeclarativeTableModel(QObject *parent) : |
|
48 | 48 | ChartTableModel(parent) |
|
49 | 49 | { |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | void DeclarativeTableModel::classBegin() |
|
53 | 53 | { |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | void DeclarativeTableModel::componentComplete() |
|
57 | 57 | { |
|
58 | 58 | foreach (QObject *child, children()) { |
|
59 | 59 | if (qobject_cast<DeclarativeTableModelElement *>(child)) { |
|
60 | 60 | append(qobject_cast<DeclarativeTableModelElement *>(child)->values()); |
|
61 | 61 | } |
|
62 | 62 | } |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | QDeclarativeListProperty<QObject> DeclarativeTableModel::modelChildren() |
|
66 | 66 | { |
|
67 | 67 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeTableModel::appendModelChild); |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | void DeclarativeTableModel::appendModelChild(QDeclarativeListProperty<QObject> *list, |
|
71 | 71 | QObject *child) |
|
72 | 72 | { |
|
73 | 73 | // childs are added in componentComplete instead |
|
74 | 74 | Q_UNUSED(list) |
|
75 | 75 | Q_UNUSED(child) |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | void DeclarativeTableModel::append(QVariantList values) |
|
79 | 79 | { |
|
80 | 80 | // qDebug() << "DeclarativeTableModel::append:" << values; |
|
81 | 81 | |
|
82 | 82 | while (columnCount() < values.count()) |
|
83 | 83 | insertColumn(columnCount()); |
|
84 | 84 | |
|
85 | 85 | insertRow(rowCount()); |
|
86 | 86 | |
|
87 | 87 | QModelIndex beginIndex = QModelIndex(); |
|
88 | 88 | QModelIndex endIndex = QModelIndex(); |
|
89 | 89 | for (int i(0); i < values.count(); i++) { |
|
90 | 90 | QModelIndex modelIndex = createIndex(rowCount() - 1, i); |
|
91 | 91 | if (i == 0) |
|
92 | 92 | beginIndex = modelIndex; |
|
93 | 93 | if (i == (values.count() - 1)) |
|
94 | 94 | endIndex = modelIndex; |
|
95 | 95 | setData(modelIndex, values.at(i)); |
|
96 | 96 | } |
|
97 | 97 | dataChanged(beginIndex, endIndex); |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | void DeclarativeTableModel::appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point) |
|
101 | 101 | { |
|
102 | 102 | // qDebug() << "DeclarativeTableModel::appendPoint:" << point; |
|
103 | 103 | QVariantList values; |
|
104 | 104 | values.insert(mapper->mapX(), point->x()); |
|
105 | 105 | values.insert(mapper->mapY(), point->y()); |
|
106 | 106 | append(values); |
|
107 | 107 | } |
|
108 | 108 | |
|
109 | ////////////// Bar model /////////////////////// | |
|
110 | ||
|
111 | DeclarativeBarModel::DeclarativeBarModel(QObject *parent) : | |
|
112 | DeclarativeTableModel(parent) | |
|
113 | { | |
|
114 | } | |
|
115 | ||
|
116 | void DeclarativeBarModel::append(QBarSet* barSet) | |
|
117 | { | |
|
118 | insertColumn(columnCount()); | |
|
119 | for (int i(0); i < barSet->count(); i++) { | |
|
120 | if (rowCount() < (i + 1)) | |
|
121 | insertRow(rowCount()); | |
|
122 | setData(createIndex(i, columnCount() - 1), barSet->at(i)); | |
|
123 | // insertRow(rowCount()); | |
|
124 | // setData(createIndex(rowCount() - 1, 0), ); | |
|
125 | // setData(createIndex(rowCount() - 1, 1), barSet->at(i)); | |
|
126 | } | |
|
127 | // TODO: setModelMapping(0, 1, columnCount(), Qt::Vertical); | |
|
128 | } | |
|
129 | ||
|
130 | 109 | #include "moc_declarativemodel.cpp" |
|
131 | 110 | |
|
132 | 111 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,84 +1,73 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 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 DECLARATIVEMODEL_H |
|
22 | 22 | #define DECLARATIVEMODEL_H |
|
23 | 23 | |
|
24 | 24 | #include "qchartglobal.h" |
|
25 | 25 | #include "declarativexypoint.h" |
|
26 | 26 | #include <QPieSlice> |
|
27 | 27 | #include "../src/charttablemodel.h" // TODO |
|
28 | 28 | #include <QBarSet> |
|
29 | 29 | #include <QXYModelMapper> |
|
30 | 30 | #include <QDeclarativeListProperty> |
|
31 | 31 | #include <QVariant> |
|
32 | 32 | #include <QDeclarativeParserStatus> |
|
33 | 33 | |
|
34 | 34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | 35 | |
|
36 | 36 | class DeclarativeTableModelElement : public QObject |
|
37 | 37 | { |
|
38 | 38 | Q_OBJECT |
|
39 | 39 | Q_PROPERTY(QVariantList values READ values WRITE setValues) |
|
40 | 40 | |
|
41 | 41 | public: |
|
42 | 42 | explicit DeclarativeTableModelElement(QObject *parent = 0); |
|
43 | 43 | QVariantList values(); |
|
44 | 44 | void setValues(QVariantList values); |
|
45 | 45 | private: |
|
46 | 46 | QVariantList m_values; |
|
47 | 47 | }; |
|
48 | 48 | |
|
49 | 49 | class DeclarativeTableModel : public ChartTableModel, public QDeclarativeParserStatus |
|
50 | 50 | { |
|
51 | 51 | Q_OBJECT |
|
52 | 52 | Q_INTERFACES(QDeclarativeParserStatus) |
|
53 | 53 | Q_PROPERTY(QDeclarativeListProperty<QObject> modelChildren READ modelChildren) |
|
54 | 54 | Q_CLASSINFO("DefaultProperty", "modelChildren") |
|
55 | 55 | |
|
56 | 56 | public: |
|
57 | 57 | explicit DeclarativeTableModel(QObject *parent = 0); |
|
58 | 58 | QDeclarativeListProperty<QObject> modelChildren(); |
|
59 | 59 | void appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point); |
|
60 | 60 | |
|
61 | 61 | public: // from QDeclarativeParserStatus |
|
62 | 62 | void classBegin(); |
|
63 | 63 | void componentComplete(); |
|
64 | 64 | |
|
65 | 65 | public Q_SLOTS: |
|
66 | 66 | void append(QVariantList slices); |
|
67 | 67 | static void appendModelChild(QDeclarativeListProperty<QObject> *list, |
|
68 | 68 | QObject *element); |
|
69 | 69 | }; |
|
70 | 70 | |
|
71 | class DeclarativeBarModel : public DeclarativeTableModel | |
|
72 | { | |
|
73 | Q_OBJECT | |
|
74 | ||
|
75 | public: | |
|
76 | explicit DeclarativeBarModel(QObject *parent = 0); | |
|
77 | ||
|
78 | public Q_SLOTS: | |
|
79 | void append(QBarSet* barSet); | |
|
80 | }; | |
|
81 | ||
|
82 | 71 | QTCOMMERCIALCHART_END_NAMESPACE |
|
83 | 72 | |
|
84 | 73 | #endif // DECLARATIVEMODEL_H |
@@ -1,79 +1,77 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 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 <QtDeclarative/qdeclarativeextensionplugin.h> |
|
22 | 22 | #include <QtDeclarative/qdeclarative.h> |
|
23 | 23 | #include "qchart.h" |
|
24 | 24 | #include "qaxiscategories.h" |
|
25 | 25 | #include "declarativechart.h" |
|
26 | 26 | #include "declarativexypoint.h" |
|
27 | 27 | #include "declarativelineseries.h" |
|
28 | 28 | #include "declarativesplineseries.h" |
|
29 | 29 | #include "declarativeareaseries.h" |
|
30 | 30 | #include "declarativescatterseries.h" |
|
31 | 31 | #include "declarativebarseries.h" |
|
32 | 32 | #include "declarativepieseries.h" |
|
33 | 33 | #include "declarativemodel.h" |
|
34 | 34 | #include <QPieModelMapper> |
|
35 | 35 | #include <QXYModelMapper> |
|
36 | 36 | |
|
37 | 37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
38 | 38 | |
|
39 | 39 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
40 | 40 | { |
|
41 | 41 | Q_OBJECT |
|
42 | 42 | public: |
|
43 | 43 | virtual void registerTypes(const char *uri) |
|
44 | 44 | { |
|
45 | 45 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
46 | 46 | |
|
47 | 47 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
48 | 48 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", |
|
49 | 49 | QLatin1String("Trying to create uncreatable: Axis.")); |
|
50 | 50 | //qmlRegisterType<DeclarativeAxisCategory>(uri, 1, 0, "AxisCategory"); |
|
51 | 51 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); |
|
52 | 52 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
53 | 53 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
54 | 54 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
55 | 55 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
56 | 56 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
57 | 57 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
58 | 58 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
59 | 59 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel"); |
|
60 | 60 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); |
|
61 | 61 | //qmlRegisterType<DeclarativePieMapping>(uri, 1, 0, "PieMapping"); |
|
62 | 62 | //qmlRegisterType<QPieModelMapper>(uri, 1, 0, "PieModelMapper"); |
|
63 | 63 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
64 | 64 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
65 | 65 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
66 | 66 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
67 | ||
|
68 | qmlRegisterType<DeclarativeBarModel>(uri, 1, 0, "BarModel"); | |
|
69 | 67 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
70 | 68 | } |
|
71 | 69 | }; |
|
72 | 70 | |
|
73 | 71 | #include "plugin.moc" |
|
74 | 72 | |
|
75 | 73 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | 74 | |
|
77 | 75 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
78 | 76 | |
|
79 | 77 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
General Comments 0
You need to be logged in to leave comments.
Login now