##// END OF EJS Templates
QML custom model demo now implements it's own QAbstractItemModel based model
Tero Ahola -
r1272:5cb84e6f3423
parent child
Show More
@@ -1,130 +1,117
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 #include "charttablemodel.h"
21 #include "customtablemodel.h"
22 22 #include <QVector>
23 23 #include <QRect>
24 24 #include <QColor>
25 25
26 QTCOMMERCIALCHART_USE_NAMESPACE
27
28 ChartTableModel::ChartTableModel(QObject *parent) :
26 CustomTableModel::CustomTableModel(QObject *parent) :
29 27 QAbstractTableModel(parent),
30 28 m_columnCount(0),
31 29 m_rowCount(0)
32 30 {
33 31 }
34 32
35 int ChartTableModel::rowCount(const QModelIndex & parent) const
33 int CustomTableModel::rowCount(const QModelIndex & parent) const
36 34 {
37 35 Q_UNUSED(parent)
38 36 return m_data.count();
39 37 }
40 38
41 int ChartTableModel::columnCount(const QModelIndex & parent) const
39 int CustomTableModel::columnCount(const QModelIndex & parent) const
42 40 {
43 41 Q_UNUSED(parent)
44 42 return m_columnCount;
45 43 }
46 44
47 QVariant ChartTableModel::headerData (int section, Qt::Orientation orientation, int role ) const
45 QVariant CustomTableModel::headerData (int section, Qt::Orientation orientation, int role ) const
48 46 {
49 47 if (role != Qt::DisplayRole)
50 48 return QVariant();
51 49
52 50 if (orientation == Qt::Horizontal) {
53 51 if (section % 2 == 0)
54 52 return "x";
55 53 else
56 54 return "y";
57 55 } else {
58 56 return QString("%1").arg(section + 1);
59 57 }
60 58 }
61 59
62 QVariant ChartTableModel::data(const QModelIndex &index, int role) const
60 QVariant CustomTableModel::data(const QModelIndex &index, int role) const
63 61 {
64 62 if (role == Qt::DisplayRole) {
65 63 return m_data[index.row()]->at(index.column());
66 64 } else if (role == Qt::EditRole) {
67 65 return m_data[index.row()]->at(index.column());
68 66 }
69 67 return QVariant();
70 68 }
71 69
72 bool ChartTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
70 bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
73 71 {
74 72 if (index.isValid() && role == Qt::EditRole) {
75 73 m_data[index.row()]->replace(index.column(), value);
76 74 emit dataChanged(index, index);
77 75 return true;
78 76 }
79 77 return false;
80 78 }
81 79
82 void ChartTableModel::insertColumn(int column, const QModelIndex &parent)
80 void CustomTableModel::insertColumn(int column, const QModelIndex &parent)
83 81 {
84 82 beginInsertColumns(parent, column, column);
85 83 m_columnCount++;
86 84 endInsertColumns();
87 85 }
88 86
89 void ChartTableModel::insertRow(int row, const QModelIndex &parent)
87 void CustomTableModel::insertRow(int row, const QModelIndex &parent)
90 88 {
91 89 beginInsertRows(parent, row, row);
92 90 QVector<QVariant>* dataVec = new QVector<QVariant>(m_columnCount);
93 91 m_data.insert(row, dataVec);
94 92 endInsertRows();
95 93 }
96 94
97 //bool ChartTableModel::removeRow(int row, const QModelIndex &parent)
98 //{
99 // Q_UNUSED(parent)
100 // Q_ASSERT(row >= 0 && row < rowCount);
101
102 // beginRemoveRows(parent, row, row);
103 // m_data.removeAt(row);
104 // endRemoveRows();
105 // return true;
106 //}
107
108 bool ChartTableModel::removeRow(int row, const QModelIndex &parent)
95 bool CustomTableModel::removeRow(int row, const QModelIndex &parent)
109 96 {
110 97 return QAbstractTableModel::removeRow(row, parent);
111 98 }
112 99
113 bool ChartTableModel::removeRows(int row, int count, const QModelIndex &parent)
100 bool CustomTableModel::removeRows(int row, int count, const QModelIndex &parent)
114 101 {
115 102 beginRemoveRows(parent, row, row + count - 1);
116 103 bool removed(false);
117 104 for (int i(row); i < (row + count); i++) {
118 105 m_data.removeAt(i);
119 106 removed = true;
120 107 }
121 108 endRemoveRows();
122 109 return removed;
123 110 }
124 111
125 Qt::ItemFlags ChartTableModel::flags ( const QModelIndex & index ) const
112 Qt::ItemFlags CustomTableModel::flags ( const QModelIndex & index ) const
126 113 {
127 114 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
128 115 }
129 116
130 #include "moc_charttablemodel.cpp"
117 #include "moc_customtablemodel.cpp"
@@ -1,59 +1,53
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 #ifndef CHARTTABLEMODEL_H
22 #define CHARTTABLEMODEL_H
21 #ifndef CUSTOMTABLEMODEL_H
22 #define CUSTOMTABLEMODEL_H
23 23
24 #include "qchartglobal.h"
25 24 #include <QAbstractTableModel>
26 25 #include <QHash>
27 #include <QRect>
28 26
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31 class QTCOMMERCIALCHART_EXPORT ChartTableModel : public QAbstractTableModel
27 class CustomTableModel : public QAbstractTableModel
32 28 {
33 29 Q_OBJECT
34 30 Q_PROPERTY(int count READ rowCount)
35 31
36 32 public:
37 explicit ChartTableModel(QObject *parent = 0);
33 explicit CustomTableModel(QObject *parent = 0);
38 34
39 35 int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
40 36 int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
41 37 QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
42 38 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
43 39 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
44 40 Qt::ItemFlags flags ( const QModelIndex & index ) const;
45 41 void insertColumn(int column, const QModelIndex &parent = QModelIndex());
46 42 void insertRow(int row, const QModelIndex &parent = QModelIndex());
47 43 /*Q_INVOKABLE*/ //bool removeRow(int row, const QModelIndex &parent = QModelIndex());
48 44 Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
49 45 Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex());
50 46
51 47 private:
52 48 QList<QVector<QVariant> * > m_data;
53 49 int m_columnCount;
54 50 int m_rowCount;
55 51 };
56 52
57 QTCOMMERCIALCHART_END_NAMESPACE
58
59 #endif // CHARTTABLEMODEL_H
53 #endif // CUSTOMTABLEMODEL_H
@@ -1,114 +1,109
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 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
27
28 ////////////// Table model row ///////////////////
25 ////////////// Table model element ///////////////////
29 26
30 27 DeclarativeTableModelElement::DeclarativeTableModelElement(QObject *parent)
31 28 : QObject(parent)
32 29 {
33 30 }
34 31
35 32 QVariantList DeclarativeTableModelElement::values()
36 33 {
37 34 return m_values;
38 35 }
39 36
40 37 void DeclarativeTableModelElement::setValues(QVariantList values)
41 38 {
42 39 m_values = values;
43 40 }
44 41
45 42 ////////////// Table model ///////////////////
46 43
47 44 DeclarativeTableModel::DeclarativeTableModel(QObject *parent) :
48 ChartTableModel(parent)
45 CustomTableModel(parent)
49 46 {
50 47 }
51 48
52 49 void DeclarativeTableModel::classBegin()
53 50 {
54 51 }
55 52
56 53 void DeclarativeTableModel::componentComplete()
57 54 {
58 55 foreach (QObject *child, children()) {
59 56 if (qobject_cast<DeclarativeTableModelElement *>(child)) {
60 57 append(qobject_cast<DeclarativeTableModelElement *>(child)->values());
61 58 }
62 59 }
63 60 }
64 61
65 62 QDeclarativeListProperty<QObject> DeclarativeTableModel::modelChildren()
66 63 {
67 64 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeTableModel::appendModelChild);
68 65 }
69 66
70 67 void DeclarativeTableModel::appendModelChild(QDeclarativeListProperty<QObject> *list,
71 68 QObject *child)
72 69 {
73 70 // childs are added in componentComplete instead
74 71 Q_UNUSED(list)
75 72 Q_UNUSED(child)
76 73 }
77 74
78 75 void DeclarativeTableModel::append(QVariantList values)
79 76 {
80 77 // qDebug() << "DeclarativeTableModel::append:" << values;
81 78
82 79 while (columnCount() < values.count())
83 80 insertColumn(columnCount());
84 81
85 82 insertRow(rowCount());
86 83
87 84 QModelIndex beginIndex = QModelIndex();
88 85 QModelIndex endIndex = QModelIndex();
89 86 for (int i(0); i < values.count(); i++) {
90 87 QModelIndex modelIndex = createIndex(rowCount() - 1, i);
91 88 if (i == 0)
92 89 beginIndex = modelIndex;
93 90 if (i == (values.count() - 1))
94 91 endIndex = modelIndex;
95 92 setData(modelIndex, values.at(i));
96 93 }
97 94 dataChanged(beginIndex, endIndex);
98 95 }
99 96
100 void DeclarativeTableModel::appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point)
101 {
102 Q_UNUSED(mapper)
103 Q_UNUSED(point)
104 // TODO: XYModelMapper implementation has change, this code has to be updated.
105 // qDebug() << "DeclarativeTableModel::appendPoint:" << point;
106 // QVariantList values;
107 // values.insert(mapper->mapX(), point->x());
108 // values.insert(mapper->mapY(), point->y());
109 // append(values);
110 }
97 //void DeclarativeTableModel::appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point)
98 //{
99 // Q_UNUSED(mapper)
100 // Q_UNUSED(point)
101 // // TODO: XYModelMapper implementation has change, this code has to be updated.
102 //// qDebug() << "DeclarativeTableModel::appendPoint:" << point;
103 //// QVariantList values;
104 //// values.insert(mapper->mapX(), point->x());
105 //// values.insert(mapper->mapY(), point->y());
106 //// append(values);
107 //}
111 108
112 109 #include "moc_declarativemodel.cpp"
113
114 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,76 +1,64
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 #include "qchartglobal.h"
25 #include "declarativexypoint.h"
26 #include <QPieSlice>
27 #include "../src/charttablemodel.h" // TODO
28 #include <QBarSet>
29 #include <QXYModelMapper>
24 #include "customtablemodel.h"
30 25 #include <QDeclarativeListProperty>
31 26 #include <QVariant>
32 27 #include <QDeclarativeParserStatus>
33 28
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35
36 // TODO: move model into demo app,
37 // the ChartModel API will not be implemented by charts declarative plugin
38
39 29 class DeclarativeTableModelElement : public QObject
40 30 {
41 31 Q_OBJECT
42 32 Q_PROPERTY(QVariantList values READ values WRITE setValues)
43 33
44 34 public:
45 35 explicit DeclarativeTableModelElement(QObject *parent = 0);
46 36 QVariantList values();
47 37 void setValues(QVariantList values);
48 38 private:
49 39 QVariantList m_values;
50 40 };
51 41
52 class DeclarativeTableModel : public ChartTableModel, public QDeclarativeParserStatus
42 class DeclarativeTableModel : public CustomTableModel, public QDeclarativeParserStatus
53 43 {
54 44 Q_OBJECT
55 45 Q_INTERFACES(QDeclarativeParserStatus)
56 46 Q_PROPERTY(QDeclarativeListProperty<QObject> modelChildren READ modelChildren)
57 47 Q_CLASSINFO("DefaultProperty", "modelChildren")
58 48
59 49 public:
60 50 explicit DeclarativeTableModel(QObject *parent = 0);
61 51 QDeclarativeListProperty<QObject> modelChildren();
62 void appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point);
52 // void appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point);
63 53
64 54 public: // from QDeclarativeParserStatus
65 55 void classBegin();
66 56 void componentComplete();
67 57
68 58 public Q_SLOTS:
69 59 void append(QVariantList slices);
70 60 static void appendModelChild(QDeclarativeListProperty<QObject> *list,
71 61 QObject *element);
72 62 };
73 63
74 QTCOMMERCIALCHART_END_NAMESPACE
75
76 64 #endif // DECLARATIVEMODEL_H
@@ -1,35 +1,47
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 <QtGui/QApplication>
22 22 #include <QDeclarativeEngine>
23 #include <QtDeclarative>
24 #include <QAbstractItemModel>
25 #include "declarativemodel.h"
26 #include "customtablemodel.h"
23 27 #include "qmlapplicationviewer.h"
24 28
29 const char *uri = "QmlCustomModel";
30
25 31 Q_DECL_EXPORT int main(int argc, char *argv[])
26 32 {
27 33 QScopedPointer<QApplication> app(createApplication(argc, argv));
28 34 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
29 35
36 // @uri QmlCustomModel
37 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
38 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
39 qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "CustomModel");
40 qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "CustomModelElement");
41
30 42 viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
31 43 viewer->setSource(QUrl("qrc:/qml/qmlcustommodel/loader.qml"));
32 44 viewer->showExpanded();
33 45
34 46 return app->exec();
35 47 }
@@ -1,102 +1,102
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 import QmlCustomModel 1.0
23 24
24 25 Rectangle {
25 26 width: parent.width
26 27 height: parent.height
27 28
28 29 ChartView {
29 30 id: chart
30 31 title: "Custom model example"
31 32 anchors.fill: parent
32 33 theme: ChartView.ChartThemeLight
33 34
34 // For dynamic data you can use the ChartModel API.
35 ChartModel {
36 id: chartModel
37 ChartModelElement { values: ["Volkswagen", 13.5, 4.4] }
38 ChartModelElement { values: ["Toyota", 10.9, 4.2] }
39 ChartModelElement { values: ["Ford", 8.6, 3.0] }
40 ChartModelElement { values: ["Skoda", 8.2, 1.9] }
41 ChartModelElement { values: ["Volvo", 6.8, 1.5] }
35 // For dynamic data we use a custom data model derived from QAbstractiItemModel
36 CustomModel {
37 id: customModel
38 CustomModelElement { values: ["Volkswagen", 13.5, 4.4] }
39 CustomModelElement { values: ["Toyota", 10.9, 4.2] }
40 CustomModelElement { values: ["Ford", 8.6, 3.0] }
41 CustomModelElement { values: ["Skoda", 8.2, 1.9] }
42 CustomModelElement { values: ["Volvo", 6.8, 1.5] }
42 43 }
43 44
44 45 LineSeries {
45 46 name: "line"
46 47
47 48 // TODO: the new mapper api
48 49 // VXYModelMapper {
49 // model: chartModel
50 // model: customModel
50 51 // xColumn: 0
51 52 // yColumn: 1
52 53 // }
53 54 }
54 55
55 56
56 57 PieSeries {
57 58 id: pieSeries
58 59 size: 0.4
59 60 horizontalPosition: 0.2
60 61 verticalPosition: 0.3
61 62 }
62 63
63 64 VPieModelMapper {
64 65 series: pieSeries
65 model: chartModel
66 model: customModel
66 67 labelsColumn: 0
67 68 valuesColumn: 1
68 69 }
69 70
70 71 // AreaSeries {
71 72 // name: "area"
72 73 // upperSeries: LineSeries {}
73 74 // lowerSeries: LineSeries {}
74 75 // }
75 76
76 // TODO: BarSeries with ChartModel base model API
77 77 // BarSeries {
78 // model: chartModel
78 // model: customModel
79 79 // modelMapper.first: 0
80 80 // }
81 81 }
82 82
83 83
84 84 // TODO: you could also implement appending to your model, for example:
85 85 // pieSeries.model.append(["Others", 52.0]);
86 86
87 87 // TODO: show how to use data from a list model in a chart view
88 // i.e. copy the data into a chart model
88 // i.e. copy the data into a custom model
89 89 // ListModel {
90 90 // id: listModel
91 91 // ListElement {
92 92 // label: "Volkswagen"
93 93 // value: 13.5
94 94 // }
95 95 // ListElement {
96 96 // label: "Toyota"
97 97 // value: 10.9
98 98 // }
99 99 // // and so on...
100 100 // }
101 101
102 102 }
@@ -1,10 +1,14
1 1 !include( ../demos.pri ) {
2 2 error( "Couldn't find the demos.pri file!" )
3 3 }
4 4
5 5 RESOURCES += resources.qrc
6 SOURCES += main.cpp
6 SOURCES += main.cpp\
7 customtablemodel.cpp \
8 declarativemodel.cpp
9 HEADERS += customtablemodel.h \
10 declarativemodel.h
7 11
8 12 include(qmlapplicationviewer/qmlapplicationviewer.pri)
9 13
10 14 !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_DEMOS_BIN_DIR"
@@ -1,47 +1,45
1 1 TARGET = qtcommercialchartqml
2 2 QT += declarative
3 3
4 4 !include( ../plugins.pri ) {
5 5 error( "Couldn't find the plugins.pri file!" )
6 6 }
7 7
8 8 contains(QT_MAJOR_VERSION, 5) {
9 9 # TODO: QtQuick2 not supported by the implementation currently
10 10 DEFINES += QTQUICK2
11 11 }
12 12
13 13 SOURCES += \
14 14 plugin.cpp \
15 15 declarativechart.cpp \
16 16 declarativexypoint.cpp \
17 17 declarativexyseries.cpp \
18 18 declarativelineseries.cpp \
19 19 declarativesplineseries.cpp \
20 20 declarativeareaseries.cpp \
21 21 declarativescatterseries.cpp \
22 22 declarativepieseries.cpp \
23 declarativebarseries.cpp \
24 declarativemodel.cpp
23 declarativebarseries.cpp
25 24
26 25 HEADERS += \
27 26 declarativechart.h \
28 27 declarativexypoint.h \
29 28 declarativexyseries.h \
30 29 declarativelineseries.h \
31 30 declarativesplineseries.h \
32 31 declarativeareaseries.h \
33 32 declarativescatterseries.h \
34 33 declarativepieseries.h \
35 declarativebarseries.h \
36 declarativemodel.h
34 declarativebarseries.h
37 35
38 36 TARGETPATH = QtCommercial/Chart
39 37 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
40 38 qmldir.files += $$PWD/qmldir
41 39 qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
42 40 INSTALLS += target qmldir
43 41
44 42 FILE = $$PWD/qmldir
45 43 win32:{FILE = $$replace(FILE, "/","\\")}
46 44 QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_PLUGIN_DIR
47 45 !system_build:mac: QMAKE_POST_LINK += " & $$MAC_POST_LINK_PREFIX $$MAC_PLUGINS_BIN_DIR"
@@ -1,55 +1,51
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 DECLARATIVEAREASERIES_H
22 22 #define DECLARATIVEAREASERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qareaseries.h"
26 26 #include "declarativelineseries.h"
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 class DeclarativeAreaSeries : public QAreaSeries
31 31 {
32 32 Q_OBJECT
33 33 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
34 34 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
35 35
36 36 public:
37 37 explicit DeclarativeAreaSeries(QObject *parent = 0);
38 38
39 39 public:
40 bool setDeclarativeUpperModel(DeclarativeTableModel *model);
41 DeclarativeTableModel *declarativeUpperModel();
42 bool setDeclarativeLowerModel(DeclarativeTableModel *model);
43 DeclarativeTableModel *declarativeLowerModel();
44 40 QXYModelMapper* upperModelMapper() const;
45 41 QXYModelMapper* lowerModelMapper() const;
46 42 public:
47 43 void setUpperSeries(DeclarativeLineSeries* series);
48 44 DeclarativeLineSeries* upperSeries() const;
49 45 void setLowerSeries(DeclarativeLineSeries* series);
50 46 DeclarativeLineSeries* lowerSeries() const;
51 47 };
52 48
53 49 QTCOMMERCIALCHART_END_NAMESPACE
54 50
55 51 #endif // DECLARATIVEAREASERIES_H
@@ -1,99 +1,99
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 #include "declarativemodel.h"
26 25 #include <QDeclarativeItem>
27 26 #include <QDeclarativeParserStatus>
28 27 #include <QGroupedBarSeries>
28 #include <QBarSet>
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 class QChart;
33 33
34 34 class DeclarativeBarSet : public QBarSet
35 35 {
36 36 Q_OBJECT
37 37 Q_PROPERTY(QVariantList values READ values WRITE setValues)
38 38 Q_PROPERTY(QString name READ name WRITE setName)
39 39
40 40 public:
41 41 explicit DeclarativeBarSet(QObject *parent = 0);
42 42 QVariantList values();
43 43 void setValues(QVariantList values);
44 44
45 45 public: // From QBarSet
46 46 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
47 47 Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); }
48 48 };
49 49
50 50 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
51 51 {
52 52 Q_OBJECT
53 53 Q_INTERFACES(QDeclarativeParserStatus)
54 54 Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories)
55 55 Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets)
56 56 Q_CLASSINFO("DefaultProperty", "initialBarSets")
57 57
58 58 public:
59 59 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
60 60 QDeclarativeListProperty<DeclarativeBarSet> initialBarSets();
61 61
62 62 void setBarCategories(QStringList categories);
63 63 QStringList barCategories();
64 64
65 65 public: // from QDeclarativeParserStatus
66 66 void classBegin();
67 67 void componentComplete();
68 68
69 69 public Q_SLOTS:
70 70 static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> * /*list*/, DeclarativeBarSet * /*element*/) {}
71 71 };
72 72
73 73 class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus
74 74 {
75 75 Q_OBJECT
76 76 Q_INTERFACES(QDeclarativeParserStatus)
77 77 Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories)
78 78 Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets)
79 79 Q_CLASSINFO("DefaultProperty", "initialBarSets")
80 80
81 81 public:
82 82 explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0);
83 83 QDeclarativeListProperty<DeclarativeBarSet> initialBarSets();
84 84
85 85 public: // from QDeclarativeParserStatus
86 86 void classBegin();
87 87 void componentComplete();
88 88
89 89 public:
90 90 void setBarCategories(QStringList categories);
91 91 QStringList barCategories();
92 92
93 93 public Q_SLOTS:
94 94 static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> * /*list*/, DeclarativeBarSet * /*element*/) {}
95 95 };
96 96
97 97 QTCOMMERCIALCHART_END_NAMESPACE
98 98
99 99 #endif // DECLARATIVEBARSERIES_H
@@ -1,55 +1,55
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 DECLARATIVELINESERIES_H
22 22 #define DECLARATIVELINESERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qlineseries.h"
26 26 #include "declarativexyseries.h"
27 27 #include <QDeclarativeParserStatus>
28 #include <QDebug>
28 #include <QDeclarativeListProperty>
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries
33 33 {
34 34 Q_OBJECT
35 35 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
36 36 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
37 37 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
38 38
39 39 public:
40 40 explicit DeclarativeLineSeries(QObject *parent = 0);
41 41 QDeclarativeListProperty<QObject> declarativeChildren();
42 42
43 43 public: // from QLineSeries
44 44 Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); }
45 45 Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); }
46 46 Q_INVOKABLE void clear() { QLineSeries::removeAll(); }
47 47 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
48 48
49 49 public Q_SLOTS:
50 50 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
51 51 };
52 52
53 53 QTCOMMERCIALCHART_END_NAMESPACE
54 54
55 55 #endif // DECLARATIVELINESERIES_H
@@ -1,77 +1,76
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 DECLARATIVEPIESERIES_H
22 22 #define DECLARATIVEPIESERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include <QPieSlice>
26 26 #include <QPieSeries>
27 27 #include <QDeclarativeParserStatus>
28 28 #include <QDeclarativeListProperty>
29 29 #include <QAbstractItemModel>
30 #include "declarativemodel.h"
31 30
32 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 32
34 33 class QChart;
35 34
36 35 class DeclarativePieSlice: public QPieSlice
37 36 {
38 37 Q_OBJECT
39 38 Q_PROPERTY(QColor color READ color WRITE setColor)
40 39 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
41 40 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth)
42 41
43 42 public:
44 43 explicit DeclarativePieSlice(QObject *parent = 0);
45 44 QColor color();
46 45 void setColor(QColor color);
47 46 QColor borderColor();
48 47 void setBorderColor(QColor color);
49 48 int borderWidth();
50 49 void setBorderWidth(int width);
51 50 };
52 51
53 52 class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
54 53 {
55 54 Q_OBJECT
56 55 Q_INTERFACES(QDeclarativeParserStatus)
57 56 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
58 57 Q_CLASSINFO("DefaultProperty", "seriesChildren")
59 58
60 59 public:
61 60 explicit DeclarativePieSeries(QObject *parent = 0);
62 61 QDeclarativeListProperty<QObject> seriesChildren();
63 62 Q_INVOKABLE DeclarativePieSlice *at(int index);
64 63 Q_INVOKABLE DeclarativePieSlice* find(QString label);
65 64 Q_INVOKABLE DeclarativePieSlice* append(QString label, qreal value);
66 65
67 66 public:
68 67 void classBegin();
69 68 void componentComplete();
70 69
71 70 public Q_SLOTS:
72 71 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
73 72 };
74 73
75 74 QTCOMMERCIALCHART_END_NAMESPACE
76 75
77 76 #endif // DECLARATIVEPIESERIES_H
@@ -1,56 +1,57
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 DECLARATIVESCATTERSERIES_H
22 22 #define DECLARATIVESCATTERSERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qscatterseries.h"
26 26 #include "declarativexyseries.h"
27 #include <QDeclarativeListProperty>
27 28
28 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 30
30 31 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries
31 32 {
32 33 Q_OBJECT
33 34 Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor)
34 35 Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor)
35 36 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
36 37 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
37 38
38 39 public:
39 40 explicit DeclarativeScatterSeries(QObject *parent = 0);
40 41 QDeclarativeListProperty<QObject> declarativeChildren();
41 42 QColor brushColor();
42 43 void setBrushColor(QColor color);
43 44
44 45 public: // from QScatterSeries
45 46 Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); }
46 47 Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); }
47 48 Q_INVOKABLE void clear() { QScatterSeries::removeAll(); }
48 49 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
49 50
50 51 public Q_SLOTS:
51 52 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
52 53 };
53 54
54 55 QTCOMMERCIALCHART_END_NAMESPACE
55 56
56 57 #endif // DECLARATIVESCATTERSERIES_H
@@ -1,54 +1,55
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 DECLARATIVESPLINESERIES_H
22 22 #define DECLARATIVESPLINESERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qsplineseries.h"
26 26 #include "declarativexyseries.h"
27 27 #include <QDeclarativeParserStatus>
28 #include <QDeclarativeListProperty>
28 29
29 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 31
31 32 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries
32 33 {
33 34 Q_OBJECT
34 35 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
35 36 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
36 37 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
37 38
38 39 public:
39 40 explicit DeclarativeSplineSeries(QObject *parent = 0);
40 41 QDeclarativeListProperty<QObject> declarativeChildren();
41 42
42 43 public: // from QSplineSeries
43 44 Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); }
44 45 Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); }
45 46 Q_INVOKABLE void clear() { QSplineSeries::removeAll(); }
46 47 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
47 48
48 49 public Q_SLOTS:
49 50 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
50 51 };
51 52
52 53 QTCOMMERCIALCHART_END_NAMESPACE
53 54
54 55 #endif // DECLARATIVESPLINESERIES_H
@@ -1,47 +1,47
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 DECLARATIVE_XY_SERIES_H
22 22 #define DECLARATIVE_XY_SERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "declarativexypoint.h"
26 #include "declarativemodel.h"
26 #include <QColor>
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 class QChart;
31 31 class QAbstractSeries;
32 32
33 33 class DeclarativeXySeries
34 34 {
35 35 public:
36 36 explicit DeclarativeXySeries();
37 37 ~DeclarativeXySeries();
38 38
39 39 public:
40 40 QColor penColor();
41 41 void setPenColor(QColor color);
42 42 DeclarativeXyPoint *at(int index);
43 43 };
44 44
45 45 QTCOMMERCIALCHART_END_NAMESPACE
46 46
47 47 #endif // DECLARATIVE_XY_SERIES_H
@@ -1,88 +1,85
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 #include "declarativemodel.h"
34 33 #include <QHPieModelMapper>
35 34 #include <QVPieModelMapper>
36 35 #include <QXYModelMapper>
37 36
38 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 38
40 39 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
41 40 {
42 41 Q_OBJECT
43 42 public:
44 43 virtual void registerTypes(const char *uri)
45 44 {
46 45 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
47 46
48 47 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
49 48 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
50 49 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
51 50 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
52 51 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
53 52 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
54 53 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
55 54 qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries");
56 55 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
57 56 qmlRegisterType<DeclarativePieSlice>(uri, 1, 0, "PieSlice");
58 qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel");
59 qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement");
60 57 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
61 58
62 59 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
63 60 QLatin1String("Trying to create uncreatable: QPieSeries."));
64 61 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
65 62 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
66 63 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
67 64 QLatin1String("Trying to create uncreatable: PieModelMapper."));
68 65 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
69 66 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
70 67
71 68 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
72 69 QLatin1String("Trying to create uncreatable: AbstractSeries."));
73 70 qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis",
74 71 QLatin1String("Trying to create uncreatable: Axis."));
75 72 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
76 73 QLatin1String("Trying to create uncreatable: PieModelMapper."));
77 74 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
78 75 QLatin1String("Trying to create uncreatable: XYModelMapper."));
79 76 }
80 77 };
81 78
82 79 #include "plugin.moc"
83 80
84 81 QTCOMMERCIALCHART_END_NAMESPACE
85 82
86 83 QTCOMMERCIALCHART_USE_NAMESPACE
87 84
88 85 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
@@ -1,237 +1,235
1 1 !include( ../config.pri ):error( "Couldn't find the config.pri file!" )
2 2
3 3 ############################# BUILD CONFIG ######################################
4 4
5 5 TARGET = $$LIBRARY_NAME
6 6 DESTDIR = $$CHART_BUILD_LIB_DIR
7 7 TEMPLATE = lib
8 8 QT = core gui
9 9 DEFINES += QTCOMMERCIALCHART_LIBRARY
10 10 win32:CONFIG += create_prl
11 11 # treat warnings as errors
12 12 win32-msvc*: {
13 13 QMAKE_CXXFLAGS += /WX
14 14 } else {
15 15 QMAKE_CXXFLAGS += -Werror
16 16 }
17 17
18 18 unix:{
19 19 QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
20 20 }
21 21
22 22 ############################# DEPEDENCES ########################################
23 23
24 24 win32-msvc*: LIBS += User32.lib
25 25 LIBS -= -l$$LIBRARY_NAME
26 26 INCLUDEPATH += ../include .
27 27
28 28 ############################# SOURCES ##########################################
29 29
30 30 SOURCES += \
31 31 $$PWD/chartdataset.cpp \
32 32 $$PWD/chartpresenter.cpp \
33 33 $$PWD/charttheme.cpp \
34 34 $$PWD/domain.cpp \
35 35 $$PWD/qchart.cpp \
36 36 $$PWD/qchartview.cpp \
37 37 $$PWD/qabstractseries.cpp \
38 38 $$PWD/chartbackground.cpp \
39 39 $$PWD/chart.cpp \
40 $$PWD/scroller.cpp \
41 $$PWD/charttablemodel.cpp
40 $$PWD/scroller.cpp
42 41 PRIVATE_HEADERS += \
43 42 $$PWD/chartdataset_p.h \
44 43 $$PWD/chartitem_p.h \
45 44 $$PWD/chartpresenter_p.h \
46 45 $$PWD/charttheme_p.h \
47 46 $$PWD/domain_p.h \
48 47 $$PWD/chartbackground_p.h \
49 48 $$PWD/chart_p.h \
50 49 $$PWD/chartconfig_p.h \
51 50 $$PWD/qchart_p.h \
52 51 $$PWD/qchartview_p.h \
53 52 $$PWD/scroller_p.h \
54 $$PWD/qabstractseries_p.h \
55 $$PWD/charttablemodel.h
53 $$PWD/qabstractseries_p.h
56 54 PUBLIC_HEADERS += \
57 55 $$PWD/qchart.h \
58 56 $$PWD/qchartglobal.h \
59 57 $$PWD/qabstractseries.h \
60 58 $$PWD/qchartview.h
61 59
62 60 include(animations/animations.pri)
63 61 include(areachart/areachart.pri)
64 62 include(axis/axis.pri)
65 63 include(barchart/barchart.pri)
66 64 include(legend/legend.pri)
67 65 include(linechart/linechart.pri)
68 66 include(piechart/piechart.pri)
69 67 include(scatterchart/scatter.pri)
70 68 include(splinechart/splinechart.pri)
71 69 include(themes/themes.pri)
72 70 include(xychart/xychart.pri)
73 71
74 72 HEADERS += $$PUBLIC_HEADERS
75 73 HEADERS += $$PRIVATE_HEADERS
76 74 HEADERS += $$THEMES
77 75
78 76 ############################# BUILD PATH ##########################################
79 77
80 78 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
81 79 MOC_DIR = $$CHART_BUILD_DIR/lib
82 80 UI_DIR = $$CHART_BUILD_DIR/lib
83 81 RCC_DIR = $$CHART_BUILD_DIR/lib
84 82
85 83 ############################# PUBLIC HEADERS GENERTOR ##########################################
86 84
87 85 #this is very primitive and lame parser , TODO: make perl script insted
88 86 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal)
89 87 {
90 88 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
91 89 win32:{
92 90 command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
93 91 }else{
94 92 command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
95 93 }
96 94 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal
97 95 system($$command)
98 96 }
99 97
100 98 for(file, PUBLIC_HEADERS) {
101 99 name = $$split(file,'/')
102 100 name = $$last(name)
103 101 class = "$$cat($$file)"
104 102 class = $$find(class,class)
105 103 !isEmpty(class){
106 104 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
107 105 class = $$member(class,1)
108 106 class = $$split(class,' ')
109 107 class = $$replace(class,' ','')
110 108 class = $$member(class,0)
111 109 win32:{
112 110 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
113 111 }else{
114 112 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
115 113 }
116 114 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
117 115 system($$command)
118 116 }
119 117 }
120 118
121 119 ############################# INSTALLERS ##########################################
122 120
123 121 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
124 122 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
125 123 INSTALLS += public_headers
126 124
127 125 install_build_public_headers.name = build_public_headers
128 126 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
129 127 install_build_public_headers.input = PUBLIC_HEADERS
130 128 install_build_public_headers.commands = $$QMAKE_COPY \
131 129 ${QMAKE_FILE_NAME} \
132 130 $$CHART_BUILD_PUBLIC_HEADER_DIR
133 131 install_build_public_headers.CONFIG += target_predeps \
134 132 no_link
135 133
136 134 install_build_private_headers.name = buld_private_headers
137 135 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
138 136 install_build_private_headers.input = PRIVATE_HEADERS
139 137 install_build_private_headers.commands = $$QMAKE_COPY \
140 138 ${QMAKE_FILE_NAME} \
141 139 $$CHART_BUILD_PRIVATE_HEADER_DIR
142 140 install_build_private_headers.CONFIG += target_predeps \
143 141 no_link
144 142
145 143 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
146 144 install_build_private_headers \
147 145
148 146 win32:{
149 147 bintarget.CONFIG += no_check_exist
150 148 bintarget.files = $$CHART_BUILD_LIB_DIR\\$${TARGET}.dll
151 149 win32-msvc*:CONFIG(debug, debug|release): {
152 150 bintarget.files += $$CHART_BUILD_LIB_DIR\\$${TARGET}.pdb
153 151 }
154 152 bintarget.path = $$[QT_INSTALL_BINS]
155 153
156 154 libtarget.CONFIG += no_check_exist
157 155 libtarget.files = $$CHART_BUILD_LIB_DIR\\$${TARGET}.prl
158 156 win32-msvc*: {
159 157 libtarget.files += $$CHART_BUILD_LIB_DIR\\$${TARGET}.lib
160 158 } else {
161 159 libtarget.files += $$CHART_BUILD_LIB_DIR\\lib$${TARGET}.a
162 160 }
163 161 libtarget.path = $$[QT_INSTALL_LIBS]
164 162
165 163 DLLDESTDIR = $$CHART_BUILD_BIN_DIR
166 164 INSTALLS += bintarget libtarget
167 165 }else{
168 166 target.path=$$[QT_INSTALL_LIBS]
169 167 INSTALLS += target
170 168 }
171 169 ################################ DEVELOPMENT BUILD ##########################################
172 170 # There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly.
173 171 # This is the case at least with shadow builds.
174 172 # http://qt-project.org/wiki/jom
175 173
176 174 development_build:!win32-msvc*:{
177 175 chartversion.target = $$PWD/qchartversion_p.h
178 176
179 177 unix:{
180 178 chartversion.commands = @echo \
181 179 \" $${LITERAL_HASH}ifndef QCHARTVERSION_P_H\\n\
182 180 $${LITERAL_HASH}define QCHARTVERSION_P_H\\n\
183 181 const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" ; \\n\
184 182 const char *gitHead = \\\"`git rev-parse HEAD`\\\" ; \\n \
185 183 $${LITERAL_HASH}endif \" \
186 184 > \
187 185 $$chartversion.target;
188 186 }else{
189 187 chartversion.commands = @echo \
190 188 "const char *buildTime = \"%date%_%time%\" ; \
191 189 const char *gitHead = \"unknown\" ; " \
192 190 > \
193 191 $$chartversion.target
194 192 }
195 193
196 194 chartversion.depends = $$HEADERS \
197 195 $$SOURCES
198 196
199 197 PRE_TARGETDEPS += $$chartversion.target
200 198 QMAKE_CLEAN += $$PWD/qchartversion_p.h
201 199 QMAKE_EXTRA_TARGETS += chartversion
202 200 }
203 201
204 202 ############################### CLEAN ###########################################
205 203
206 204 unix:QMAKE_DISTCLEAN += -r \
207 205 $$CHART_BUILD_HEADER_DIR \
208 206 $$CHART_BUILD_LIB_DIR
209 207 win32:QMAKE_DISTCLEAN += /Q \
210 208 $$CHART_BUILD_HEADER_DIR \
211 209 $$CHART_BUILD_LIB_DIR
212 210
213 211 ############################## COVERAGE #########################################
214 212
215 213 unix:coverage:{
216 214
217 215 QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
218 216 QMAKE_LDFLAGS += -fprofile-arcs -ftest-coverage
219 217
220 218 LIBS += -lgcov
221 219
222 220 QMAKE_CLEAN += $$OBJECTS_DIR/*.gcda $$OBJECTS_DIR/*.gcno $$PWD/*.gcov ../coverage/*.info
223 221 QMAKE_EXTRA_TARGETS += preparecoverage gencoverage
224 222
225 223 preparecoverage.target = prepare_coverage
226 224 preparecoverage.depends = all
227 225 preparecoverage.commands = lcov --directory $$OBJECTS_DIR --zerocounters ;\
228 226 lcov -i -d $$OBJECTS_DIR -c -o ../coverage/base.info -b $$PWD;
229 227
230 228 gencoverage.target = gen_coverage
231 229 gencoverage.depends = all
232 230 gencoverage.commands = lcov -d $$OBJECTS_DIR -c -o ../coverage/src.info -b $$PWD;\
233 231 lcov -e ../coverage/base.info $$PWD/* $$PWD/animations/* $$PWD/areachart/* $$PWD/axis/* $$PWD/barchart/* $$PWD/legend/* $$PWD/linechart/* $$PWD/piechart/* $$PWD/scatterchart/* $$PWD/splinechart/* $$PWD/themes/* $$PWD/xychart/* -o ../coverage/base.info;\
234 232 lcov -e ../coverage/src.info $$PWD/* $$PWD/animations/* $$PWD/areachart/* $$PWD/axis/* $$PWD/barchart/* $$PWD/legend/* $$PWD/linechart/* $$PWD/piechart/* $$PWD/scatterchart/* $$PWD/splinechart/* $$PWD/themes/* $$PWD/xychart/* -o ../coverage/src.info;\
235 233 lcov -a ../coverage/base.info -a ../coverage/src.info -o ../coverage/coverage.info;
236 234 }
237 235
General Comments 0
You need to be logged in to leave comments. Login now