##// END OF EJS Templates
Draft version for QML PieSeries model API
Tero Ahola -
r1130:2b935e4f3207
parent child
Show More
@@ -0,0 +1,89
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "DeclarativePieModel.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
24 #include <qdeclarativelist.h>
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
28 DeclarativePieModel::DeclarativePieModel(QObject *parent) :
29 ChartTableModel(parent)
30 {
31 }
32
33 //void DeclarativePieModel::classBegin()
34 //{
35 //}
36
37 //void DeclarativePieModel::componentComplete()
38 //{
39 //}
40
41 void DeclarativePieModel::append(QPieSlice* slice)
42 {
43 // TODO: label not working...
44 qDebug() << "DeclarativePieModel::append:" << slice->label() << " " << slice->value();
45 qDebug() << "rowCount:" << rowCount();
46 qDebug() << "coolCount:" << columnCount();
47 insertRow(rowCount());
48 qDebug() << "new rowCount:" << rowCount();
49
50 qDebug() << setData(createIndex(rowCount() - 1, 0), slice->value());
51 qDebug() << setData(createIndex(rowCount() - 1, 1), slice->label());
52 }
53
54 void DeclarativePieModel::append(QVariantList slices)
55 {
56 qDebug() << "append:" << slices;
57 QString label = "";
58 for (int i(0); i < slices.count(); i++) {
59 if (i % 2) {
60 bool ok(false);
61 qreal value = slices.at(i).toReal(&ok);
62 if (ok) {
63 QPieSlice *slice = new QPieSlice(value, label);
64 append(slice);
65 }
66 } else {
67 label = slices.at(i).toString();
68 }
69 }
70 }
71
72 QDeclarativeListProperty<QPieSlice> DeclarativePieModel::slices()
73 {
74 return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieModel::appendSlice);
75 }
76
77 void DeclarativePieModel::appendSlice(QDeclarativeListProperty<QPieSlice> *list,
78 QPieSlice *slice)
79 {
80 DeclarativePieModel *pieModel = qobject_cast<DeclarativePieModel *>(list->object);
81 if (pieModel)
82 pieModel->append(slice);
83 else
84 qWarning() << "Illegal slice item";
85 }
86
87 #include "moc_declarativepiemodel.cpp"
88
89 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,61
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #ifndef DECLARATIVEPIEMODEL_H
22 #define DECLARATIVEPIEMODEL_H
23
24 #include "qchartglobal.h"
25 #include "qpieslice.h"
26 #include "qpieseries.h"
27 #include "../src/charttablemodel.h"
28 #include <QDeclarativeParserStatus>
29 #include <QDeclarativeListProperty>
30 #include <QAbstractItemModel>
31 #include <QVariant>
32
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34
35 class DeclarativePieModel : public ChartTableModel/*, public QDeclarativeParserStatus*/
36 {
37 // Q_INTERFACES(QDeclarativeParserStatus)
38 Q_OBJECT
39 Q_PROPERTY(QDeclarativeListProperty<QPieSlice> slices READ slices)
40 Q_CLASSINFO("DefaultProperty", "slices")
41
42 public:
43 explicit DeclarativePieModel(QObject *parent = 0);
44 QDeclarativeListProperty<QPieSlice> slices();
45
46 //public: // from QDeclarativeParserStatus
47 // virtual void classBegin();
48 // virtual void componentComplete();
49
50 public Q_SLOTS:
51 void append(QPieSlice* slice);
52 void append(QVariantList slices);
53 static void appendSlice(QDeclarativeListProperty<QPieSlice> *list,
54 QPieSlice *element);
55
56 public:
57 };
58
59 QTCOMMERCIALCHART_END_NAMESPACE
60
61 #endif // DECLARATIVEPIEMODEL_H
@@ -0,0 +1,141
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "charttablemodel.h"
22 #include <QVector>
23 #include <QTime>
24 #include <QRect>
25 #include <QColor>
26
27 QTCOMMERCIALCHART_USE_NAMESPACE
28
29 ChartTableModel::ChartTableModel(QObject *parent) :
30 QAbstractTableModel(parent)
31 {
32 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
33
34 m_columnCount = 2;
35 m_rowCount = 0;
36
37 // m_data
38 for (int i = 0; i < m_rowCount; i++) {
39 QVector<QVariant>* dataVec = new QVector<QVariant>(m_columnCount);
40 for (int k = 0; k < dataVec->size(); k++) {
41 if (k%2 == 0)
42 dataVec->replace(k, i * 50 + qrand()%20);
43 else
44 dataVec->replace(k, qrand()%100);
45 }
46 m_data.append(dataVec);
47 }
48 }
49
50 int ChartTableModel::rowCount(const QModelIndex & parent) const
51 {
52 Q_UNUSED(parent)
53 return m_data.count();
54 }
55
56 int ChartTableModel::columnCount(const QModelIndex & parent) const
57 {
58 Q_UNUSED(parent)
59 return m_columnCount;
60 }
61
62 QVariant ChartTableModel::headerData (int section, Qt::Orientation orientation, int role ) const
63 {
64 if (role != Qt::DisplayRole)
65 return QVariant();
66
67 if (orientation == Qt::Horizontal)
68 {
69 if (section%2 == 0)
70 return "x";
71 else
72 return "y";
73 }
74 else
75 return QString("%1").arg(section + 1);
76 }
77
78 QVariant ChartTableModel::data(const QModelIndex &index, int role) const
79 {
80 if (role == Qt::DisplayRole) {
81 return m_data[index.row()]->at(index.column());
82 } else if (role == Qt::EditRole) {
83 return m_data[index.row()]->at(index.column());
84 }
85 return QVariant();
86 }
87
88 bool ChartTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
89 {
90 if (index.isValid() && role == Qt::EditRole) {
91 m_data[index.row()]->replace(index.column(), value);
92 emit dataChanged(index, index);
93 return true;
94 }
95 return false;
96 }
97
98 void ChartTableModel::insertRow(int row, const QModelIndex &parent)
99 {
100 Q_UNUSED(parent)
101
102 beginInsertRows(QModelIndex(), row, row);
103 QVector<QVariant>* dataVec = new QVector<QVariant>(m_columnCount);
104 m_data.insert(row, dataVec);
105 endInsertRows();
106 }
107
108 //bool ChartTableModel::removeRow(int row, const QModelIndex &parent)
109 //{
110 // Q_UNUSED(parent)
111 // Q_ASSERT(row >= 0 && row < rowCount);
112
113 // beginRemoveRows(parent, row, row);
114 // m_data.removeAt(row);
115 // endRemoveRows();
116 // return true;
117 //}
118
119 bool ChartTableModel::removeRow(int row, const QModelIndex &parent)
120 {
121 return QAbstractTableModel::removeRow(row, parent);
122 }
123
124 bool ChartTableModel::removeRows(int row, int count, const QModelIndex &parent)
125 {
126 beginRemoveRows(parent, row, row + count - 1);
127 bool removed(false);
128 for (int i(row); i < (row + count); i++) {
129 m_data.removeAt(i);
130 removed = true;
131 }
132 endRemoveRows();
133 return removed;
134 }
135
136 Qt::ItemFlags ChartTableModel::flags ( const QModelIndex & index ) const
137 {
138 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
139 }
140
141 #include "moc_charttablemodel.cpp"
@@ -0,0 +1,58
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #ifndef CHARTTABLEMODEL_H
22 #define CHARTTABLEMODEL_H
23
24 #include "qchartglobal.h"
25 #include <QAbstractTableModel>
26 #include <QHash>
27 #include <QRect>
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31 class QTCOMMERCIALCHART_EXPORT ChartTableModel : public QAbstractTableModel
32 {
33 Q_OBJECT
34 Q_PROPERTY(int count READ rowCount)
35
36 public:
37 explicit ChartTableModel(QObject *parent = 0);
38
39 int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
40 int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
41 QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
42 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
43 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
44 Qt::ItemFlags flags ( const QModelIndex & index ) const;
45 void insertRow(int row, const QModelIndex &parent = QModelIndex());
46 /*Q_INVOKABLE*/ //bool removeRow(int row, const QModelIndex &parent = QModelIndex());
47 Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
48 Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex());
49
50 private:
51 QList<QVector<QVariant> * > m_data;
52 int m_columnCount;
53 int m_rowCount;
54 };
55
56 QTCOMMERCIALCHART_END_NAMESPACE
57
58 #endif // CHARTTABLEMODEL_H
@@ -1,47 +1,111
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 Chart {
27 ChartView {
28 id: chart
28 title: "Car brand shares in Finland"
29 title: "Car brand shares in Finland"
29 anchors.fill: parent
30 anchors.top: parent.top
30 theme: Chart.ChartThemeLight
31 anchors.bottom: button.top
31 legend: Chart.LegendBottom
32 anchors.left: parent.left
33 anchors.right: parent.right
34 theme: ChartView.ChartThemeLight
35 legend: ChartView.LegendBottom
36 animationOptions: ChartView.SeriesAnimations
32
37
33 PieSeries {
38 PieSeries {
34 horizontalPosition: 0.5
39 model: PieModel {
35 verticalPosition: 0.5
40 id: pieModel
36 size: 0.7
41 PieSlice { label: "Volkswagen"; value: 13.5 }
37 slices: [
42 PieSlice { label: "Toyota"; value: 10.9 }
38 PieSlice { label: "Volkswagen"; value: 13.5 },
43 PieSlice { label: "Ford"; value: 8.6 }
39 PieSlice { label: "Toyota"; value: 10.9 },
44 PieSlice { label: "Skoda"; value: 8.2 }
40 PieSlice { label: "Ford"; value: 8.6 },
45 PieSlice { label: "Volvo"; value: 6.8 }
41 PieSlice { label: "Skoda"; value: 8.2 },
46 }
42 PieSlice { label: "Volvo"; value: 6.8 },
43 PieSlice { label: "Others"; value: 52.0 }
44 ]
45 }
47 }
46 }
48 }
49
50 Rectangle {
51 id: button
52 anchors.bottom: parent.bottom
53 anchors.bottomMargin: 10
54 anchors.horizontalCenter: parent.horizontalCenter
55 height: 40
56 width: 100
57 color: "orange"
58 radius: 5
59 Text {
60 id: buttonText
61 anchors.centerIn: parent
62 text: button.state == "" ? "Show others" : "Hide others"
63 }
64 MouseArea {
65 anchors.fill: parent
66 onClicked: {
67 if (button.state == "") {
68 // The share of "others" was enabled -> append the data into the model
69 // TODO: this should also be doable by redefining the range inside the model
70 button.state = "show";
71 pieModel.append(["Others", 52.0]);
72 } else {
73 // The share of "others" was disabled -> remove the data from the model
74 // TODO: this should also be doable by redefining the range inside the model
75 button.state = "";
76 pieModel.removeRow(pieModel.count - 1);
77 }
78 }
79 }
80 }
81
82
83 // TODO: Optional syntax for defining models for different series. Is this really needed?
84 // ChartModel {
85 // id: chartModel
86 // ChartElement { column1: "Volkswagen"; column2: 13.5; column3: 1.2 }
87 // ChartElement { column1: "Toyota"; column2: 10.9; column3: 2.5 }
88 // }
89 // // column3 not used by pie series
90 // PieSeries {
91 // model: chartModel
92 // mappings: [ {"column1":"label"}, {"column2":"value"} ]
93 // }
94
95
96 // TODO: show how to use data from a list model in a chart view
97 // i.e. copy the data into a chart model
98 // ListModel {
99 // id: listModel
100 // ListElement {
101 // label: "Volkswagen"
102 // value: 13.5
103 // }
104 // ListElement {
105 // label: "Toyota"
106 // value: 10.9
107 // }
108 // // and so on...
109 // }
110
47 }
111 }
@@ -1,58 +1,58
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 Chart {
27 ChartView {
28 title: "Line&Spline"
28 title: "Line&Spline"
29 anchors.fill: parent
29 anchors.fill: parent
30 theme: Chart.ChartThemeBrownSand
30 theme: ChartView.ChartThemeBrownSand
31 animationOptions: Chart.NoAnimation
31 animationOptions: ChartView.NoAnimation
32
32
33 LineSeries {
33 LineSeries {
34 name: "Line"
34 name: "Line"
35 points: [
35 points: [
36 XyPoint { x: 0.0; y: 0.0 },
36 XyPoint { x: 0.0; y: 0.0 },
37 XyPoint { x: 1.1; y: 2.1 },
37 XyPoint { x: 1.1; y: 2.1 },
38 XyPoint { x: 1.9; y: 3.3 },
38 XyPoint { x: 1.9; y: 3.3 },
39 XyPoint { x: 2.9; y: 4.9 },
39 XyPoint { x: 2.9; y: 4.9 },
40 XyPoint { x: 3.2; y: 3.0 },
40 XyPoint { x: 3.2; y: 3.0 },
41 XyPoint { x: 4.0; y: 3.3 }
41 XyPoint { x: 4.0; y: 3.3 }
42 ]
42 ]
43 }
43 }
44
44
45 SplineSeries {
45 SplineSeries {
46 name: "Spline"
46 name: "Spline"
47 points: [
47 points: [
48 XyPoint { x: 0.0; y: 0.3 },
48 XyPoint { x: 0.0; y: 0.3 },
49 XyPoint { x: 1.1; y: 3.2 },
49 XyPoint { x: 1.1; y: 3.2 },
50 XyPoint { x: 1.7; y: 2.4 },
50 XyPoint { x: 1.7; y: 2.4 },
51 XyPoint { x: 2.1; y: 2.1 },
51 XyPoint { x: 2.1; y: 2.1 },
52 XyPoint { x: 2.9; y: 2.6 },
52 XyPoint { x: 2.9; y: 2.6 },
53 XyPoint { x: 3.4; y: 2.3 },
53 XyPoint { x: 3.4; y: 2.3 },
54 XyPoint { x: 4.1; y: 3.1 }
54 XyPoint { x: 4.1; y: 3.1 }
55 ]
55 ]
56 }
56 }
57 }
57 }
58 }
58 }
@@ -1,129 +1,129
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 Chart {
27 ChartView {
28 title: "NHL All-Star Team Players"
28 title: "NHL All-Star Team Players"
29 anchors.fill: parent
29 anchors.fill: parent
30 theme: Chart.ChartThemeHighContrast
30 theme: ChartView.ChartThemeHighContrast
31 legend: Chart.LegendTop
31 legend: ChartView.LegendTop
32
32
33 AreaSeries {
33 AreaSeries {
34 name: "Swedish"
34 name: "Swedish"
35 points: [
35 points: [
36 XyPoint { x: 0; y: 1 },
36 XyPoint { x: 0; y: 1 },
37 XyPoint { x: 1; y: 1 },
37 XyPoint { x: 1; y: 1 },
38 XyPoint { x: 2; y: 3 },
38 XyPoint { x: 2; y: 3 },
39 XyPoint { x: 3; y: 3 },
39 XyPoint { x: 3; y: 3 },
40 XyPoint { x: 4; y: 2 },
40 XyPoint { x: 4; y: 2 },
41 XyPoint { x: 5; y: 0 },
41 XyPoint { x: 5; y: 0 },
42 XyPoint { x: 6; y: 2 },
42 XyPoint { x: 6; y: 2 },
43 XyPoint { x: 7; y: 1 },
43 XyPoint { x: 7; y: 1 },
44 XyPoint { x: 8; y: 2 },
44 XyPoint { x: 8; y: 2 },
45 XyPoint { x: 9; y: 1 },
45 XyPoint { x: 9; y: 1 },
46 XyPoint { x: 10; y: 3 },
46 XyPoint { x: 10; y: 3 },
47 XyPoint { x: 11; y: 3 }
47 XyPoint { x: 11; y: 3 }
48 ]
48 ]
49 lowerPoints: [
49 lowerPoints: [
50 XyPoint { x: 0; y: 0 },
50 XyPoint { x: 0; y: 0 },
51 XyPoint { x: 1; y: 0 },
51 XyPoint { x: 1; y: 0 },
52 XyPoint { x: 2; y: 0 },
52 XyPoint { x: 2; y: 0 },
53 XyPoint { x: 3; y: 0 },
53 XyPoint { x: 3; y: 0 },
54 XyPoint { x: 4; y: 0 },
54 XyPoint { x: 4; y: 0 },
55 XyPoint { x: 5; y: 0 },
55 XyPoint { x: 5; y: 0 },
56 XyPoint { x: 6; y: 0 },
56 XyPoint { x: 6; y: 0 },
57 XyPoint { x: 7; y: 0 },
57 XyPoint { x: 7; y: 0 },
58 XyPoint { x: 8; y: 0 },
58 XyPoint { x: 8; y: 0 },
59 XyPoint { x: 9; y: 0 },
59 XyPoint { x: 9; y: 0 },
60 XyPoint { x: 10; y: 0 },
60 XyPoint { x: 10; y: 0 },
61 XyPoint { x: 11; y: 0 }
61 XyPoint { x: 11; y: 0 }
62 ]
62 ]
63 }
63 }
64
64
65 AreaSeries {
65 AreaSeries {
66 name: "Russian"
66 name: "Russian"
67 points: [
67 points: [
68 XyPoint { x: 0; y: 1 },
68 XyPoint { x: 0; y: 1 },
69 XyPoint { x: 1; y: 1 },
69 XyPoint { x: 1; y: 1 },
70 XyPoint { x: 2; y: 1 },
70 XyPoint { x: 2; y: 1 },
71 XyPoint { x: 3; y: 1 },
71 XyPoint { x: 3; y: 1 },
72 XyPoint { x: 4; y: 1 },
72 XyPoint { x: 4; y: 1 },
73 XyPoint { x: 5; y: 0 },
73 XyPoint { x: 5; y: 0 },
74 XyPoint { x: 6; y: 1 },
74 XyPoint { x: 6; y: 1 },
75 XyPoint { x: 7; y: 1 },
75 XyPoint { x: 7; y: 1 },
76 XyPoint { x: 8; y: 4 },
76 XyPoint { x: 8; y: 4 },
77 XyPoint { x: 9; y: 3 },
77 XyPoint { x: 9; y: 3 },
78 XyPoint { x: 10; y: 2 },
78 XyPoint { x: 10; y: 2 },
79 XyPoint { x: 11; y: 1 }
79 XyPoint { x: 11; y: 1 }
80 ]
80 ]
81 lowerPoints: [
81 lowerPoints: [
82 XyPoint { x: 0; y: 0 },
82 XyPoint { x: 0; y: 0 },
83 XyPoint { x: 1; y: 0 },
83 XyPoint { x: 1; y: 0 },
84 XyPoint { x: 2; y: 0 },
84 XyPoint { x: 2; y: 0 },
85 XyPoint { x: 3; y: 0 },
85 XyPoint { x: 3; y: 0 },
86 XyPoint { x: 4; y: 0 },
86 XyPoint { x: 4; y: 0 },
87 XyPoint { x: 5; y: 0 },
87 XyPoint { x: 5; y: 0 },
88 XyPoint { x: 6; y: 0 },
88 XyPoint { x: 6; y: 0 },
89 XyPoint { x: 7; y: 0 },
89 XyPoint { x: 7; y: 0 },
90 XyPoint { x: 8; y: 0 },
90 XyPoint { x: 8; y: 0 },
91 XyPoint { x: 9; y: 0 },
91 XyPoint { x: 9; y: 0 },
92 XyPoint { x: 10; y: 0 },
92 XyPoint { x: 10; y: 0 },
93 XyPoint { x: 11; y: 0 }
93 XyPoint { x: 11; y: 0 }
94 ]
94 ]
95 }
95 }
96
96
97 AreaSeries {
97 AreaSeries {
98 name: "Finnish"
98 name: "Finnish"
99 points: [
99 points: [
100 XyPoint { x: 0; y: 0 },
100 XyPoint { x: 0; y: 0 },
101 XyPoint { x: 1; y: 0 },
101 XyPoint { x: 1; y: 0 },
102 XyPoint { x: 2; y: 0 },
102 XyPoint { x: 2; y: 0 },
103 XyPoint { x: 3; y: 0 },
103 XyPoint { x: 3; y: 0 },
104 XyPoint { x: 4; y: 0 },
104 XyPoint { x: 4; y: 0 },
105 XyPoint { x: 5; y: 0 },
105 XyPoint { x: 5; y: 0 },
106 XyPoint { x: 6; y: 1 },
106 XyPoint { x: 6; y: 1 },
107 XyPoint { x: 7; y: 0 },
107 XyPoint { x: 7; y: 0 },
108 XyPoint { x: 8; y: 0 },
108 XyPoint { x: 8; y: 0 },
109 XyPoint { x: 9; y: 0 },
109 XyPoint { x: 9; y: 0 },
110 XyPoint { x: 10; y: 0 },
110 XyPoint { x: 10; y: 0 },
111 XyPoint { x: 11; y: 1 }
111 XyPoint { x: 11; y: 1 }
112 ]
112 ]
113 lowerPoints: [
113 lowerPoints: [
114 XyPoint { x: 0; y: 0 },
114 XyPoint { x: 0; y: 0 },
115 XyPoint { x: 1; y: 0 },
115 XyPoint { x: 1; y: 0 },
116 XyPoint { x: 2; y: 0 },
116 XyPoint { x: 2; y: 0 },
117 XyPoint { x: 3; y: 0 },
117 XyPoint { x: 3; y: 0 },
118 XyPoint { x: 4; y: 0 },
118 XyPoint { x: 4; y: 0 },
119 XyPoint { x: 5; y: 0 },
119 XyPoint { x: 5; y: 0 },
120 XyPoint { x: 6; y: 0 },
120 XyPoint { x: 6; y: 0 },
121 XyPoint { x: 7; y: 0 },
121 XyPoint { x: 7; y: 0 },
122 XyPoint { x: 8; y: 0 },
122 XyPoint { x: 8; y: 0 },
123 XyPoint { x: 9; y: 0 },
123 XyPoint { x: 9; y: 0 },
124 XyPoint { x: 10; y: 0 },
124 XyPoint { x: 10; y: 0 },
125 XyPoint { x: 11; y: 0 }
125 XyPoint { x: 11; y: 0 }
126 ]
126 ]
127 }
127 }
128 }
128 }
129 }
129 }
@@ -1,57 +1,57
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 Chart {
27 ChartView {
28 title: "Scatters"
28 title: "Scatters"
29 anchors.fill: parent
29 anchors.fill: parent
30 theme: Chart.ChartThemeBlueCerulean
30 theme: ChartView.ChartThemeBlueCerulean
31
31
32 ScatterSeries {
32 ScatterSeries {
33 id: scatter1
33 id: scatter1
34 name: "Scatter1"
34 name: "Scatter1"
35 points: [
35 points: [
36 XyPoint { x: 1.5; y: 1.5 },
36 XyPoint { x: 1.5; y: 1.5 },
37 XyPoint { x: 1.5; y: 1.6 },
37 XyPoint { x: 1.5; y: 1.6 },
38 XyPoint { x: 1.57; y: 1.55 },
38 XyPoint { x: 1.57; y: 1.55 },
39 XyPoint { x: 1.8; y: 1.8 },
39 XyPoint { x: 1.8; y: 1.8 },
40 XyPoint { x: 1.9; y: 1.6 },
40 XyPoint { x: 1.9; y: 1.6 },
41 XyPoint { x: 2.1; y: 1.3 },
41 XyPoint { x: 2.1; y: 1.3 },
42 XyPoint { x: 2.5; y: 2.1 }
42 XyPoint { x: 2.5; y: 2.1 }
43 ]
43 ]
44 }
44 }
45 ScatterSeries {
45 ScatterSeries {
46 name: "Scatter2"
46 name: "Scatter2"
47 points: [
47 points: [
48 XyPoint { x: 2.0; y: 2.0 },
48 XyPoint { x: 2.0; y: 2.0 },
49 XyPoint { x: 2.0; y: 2.1 },
49 XyPoint { x: 2.0; y: 2.1 },
50 XyPoint { x: 2.07; y: 2.05 },
50 XyPoint { x: 2.07; y: 2.05 },
51 XyPoint { x: 2.2; y: 2.9 },
51 XyPoint { x: 2.2; y: 2.9 },
52 XyPoint { x: 2.4; y: 2.7 },
52 XyPoint { x: 2.4; y: 2.7 },
53 XyPoint { x: 2.67; y: 2.65 }
53 XyPoint { x: 2.67; y: 2.65 }
54 ]
54 ]
55 }
55 }
56 }
56 }
57 }
57 }
@@ -1,38 +1,38
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 Chart {
27 ChartView {
28 title: "Bar series"
28 title: "Bar series"
29 anchors.fill: parent
29 anchors.fill: parent
30 theme: Chart.ChartThemeLight
30 theme: ChartView.ChartThemeLight
31 legend: Chart.LegendBottom
31 legend: ChartView.LegendBottom
32
32
33 BarSeries {
33 BarSeries {
34 barCategories: [ "2008", "2009", "2010", "2011", "2012" ]
34 barCategories: [ "2008", "2009", "2010", "2011", "2012" ]
35 // data implementation missing
35 // data implementation missing
36 }
36 }
37 }
37 }
38 }
38 }
@@ -1,53 +1,41
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 width: parent.width
25 width: parent.width
26 height: parent.height
26 height: parent.height
27 property int __viewNumber: 0
27 property int __viewNumber: 0
28
28
29 Timer {
29 MouseArea {
30 id: timer
30 anchors.fill: parent
31 running: true
31 onClicked: {
32 repeat: true
33 interval: 5000
34 triggeredOnStart: false
35 onTriggered: {
36 __viewNumber++;
32 __viewNumber++;
37 }
33 }
38 }
34 }
39
35
40 Loader {
36 Loader {
41 id: loader
37 id: loader
42 anchors.fill: parent
38 anchors.fill: parent
43 source: "View" + (__viewNumber % 5 + 1) + ".qml";
39 source: "View" + (__viewNumber % 5 + 1) + ".qml";
44 }
40 }
45
46 MouseArea {
47 anchors.fill: parent
48 onClicked: {
49 timer.restart();
50 __viewNumber++;
51 }
52 }
53 }
41 }
@@ -1,47 +1,51
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 "declarativepieseries.h"
21 #include "declarativepieseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include <qdeclarativelist.h>
24
25
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
27
27 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
28 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
28 QPieSeries(parent)
29 QPieSeries(parent)
29 {
30 {
30 }
31 }
31
32
32 QDeclarativeListProperty<QPieSlice> DeclarativePieSeries::slices()
33 bool DeclarativePieSeries::setPieModel(DeclarativePieModel *model)
33 {
34 {
34 return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieSeries::appendSlice);
35 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
36 bool value(false);
37 if (m) {
38 value = QPieSeries::setModel(m);
39 setModelMapping(0, 1, Qt::Vertical);
40 }
41 return value;
35 }
42 }
36
43
37 void DeclarativePieSeries::appendSlice(QDeclarativeListProperty<QPieSlice> *list,
44 DeclarativePieModel *DeclarativePieSeries::pieModel()
38 QPieSlice *slice)
39 {
45 {
40 DeclarativePieSeries *series = qobject_cast<DeclarativePieSeries *>(list->object);
46 return qobject_cast<DeclarativePieModel *>(model());
41 if (series)
42 series->append(slice->value(), slice->label());
43 }
47 }
44
48
45 #include "moc_declarativepieseries.cpp"
49 #include "moc_declarativepieseries.cpp"
46
50
47 QTCOMMERCIALCHART_END_NAMESPACE
51 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,49 +1,53
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 DECLARATIVEPIESERIES_H
21 #ifndef DECLARATIVEPIESERIES_H
22 #define DECLARATIVEPIESERIES_H
22 #define DECLARATIVEPIESERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "qpieslice.h"
25 #include "qpieslice.h"
26 #include "qpieseries.h"
26 #include "qpieseries.h"
27 #include <QDeclarativeListProperty>
27 #include <QDeclarativeListProperty>
28 #include <QAbstractItemModel>
29 #include <QVariant>
30 #include "declarativepiemodel.h"
28
31
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
33
31 class QChart;
34 class QChart;
32
35
33 class DeclarativePieSeries : public QPieSeries
36 class DeclarativePieSeries : public QPieSeries
34 {
37 {
35 Q_OBJECT
38 Q_OBJECT
36 Q_PROPERTY(QDeclarativeListProperty<QPieSlice> slices READ slices)
39 Q_PROPERTY(DeclarativePieModel *model READ pieModel WRITE setPieModel)
37
40
38 public:
41 public:
39 explicit DeclarativePieSeries(QObject *parent = 0);
42 explicit DeclarativePieSeries(QObject *parent = 0);
40 QDeclarativeListProperty<QPieSlice> slices();
41
43
42 public Q_SLOTS:
44 public Q_SLOTS:
43 static void appendSlice(QDeclarativeListProperty<QPieSlice> *list,
45
44 QPieSlice *element);
46 public:
47 bool setPieModel(DeclarativePieModel *model);
48 DeclarativePieModel *pieModel();
45 };
49 };
46
50
47 QTCOMMERCIALCHART_END_NAMESPACE
51 QTCOMMERCIALCHART_END_NAMESPACE
48
52
49 #endif // DECLARATIVEPIESERIES_H
53 #endif // DECLARATIVEPIESERIES_H
@@ -1,63 +1,66
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 <QtDeclarative/qdeclarativeextensionplugin.h>
21 #include <QtDeclarative/qdeclarativeextensionplugin.h>
22 #include <QtDeclarative/qdeclarative.h>
22 #include <QtDeclarative/qdeclarative.h>
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "declarativechart.h"
24 #include "declarativechart.h"
25 #include "declarativeaxis.h"
25 #include "declarativeaxis.h"
26 #include "declarativexypoint.h"
26 #include "declarativexypoint.h"
27 #include "declarativelineseries.h"
27 #include "declarativelineseries.h"
28 #include "declarativesplineseries.h"
28 #include "declarativesplineseries.h"
29 #include "declarativeareaseries.h"
29 #include "declarativeareaseries.h"
30 #include "declarativescatterseries.h"
30 #include "declarativescatterseries.h"
31 #include "declarativebarseries.h"
31 #include "declarativebarseries.h"
32 #include "declarativepieseries.h"
32 #include "declarativepieseries.h"
33 #include "declarativepiemodel.h"
33
34
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35
36
36 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
37 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
37 {
38 {
38 Q_OBJECT
39 Q_OBJECT
39 public:
40 public:
40 virtual void registerTypes(const char *uri)
41 virtual void registerTypes(const char *uri)
41 {
42 {
42 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
43 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
43
44
44 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "Chart");
45 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
45 qmlRegisterType<DeclarativeAxis>(uri, 1, 0, "Axis");
46 qmlRegisterType<DeclarativeAxis>(uri, 1, 0, "Axis");
46 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
47 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
47 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
48 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
48 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
49 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
49 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
50 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
50 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
51 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
51 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
52 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
52 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
53 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
53 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
54 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
55 // TODO: a declarative model for each type
56 qmlRegisterType<DeclarativePieModel>(uri, 1, 0, "PieModel");
54 }
57 }
55 };
58 };
56
59
57 #include "plugin.moc"
60 #include "plugin.moc"
58
61
59 QTCOMMERCIALCHART_END_NAMESPACE
62 QTCOMMERCIALCHART_END_NAMESPACE
60
63
61 QTCOMMERCIALCHART_USE_NAMESPACE
64 QTCOMMERCIALCHART_USE_NAMESPACE
62
65
63 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
66 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
@@ -1,54 +1,56
1 TEMPLATE = lib
1 TEMPLATE = lib
2 TARGET = qtcommercialchartqml
2 TARGET = qtcommercialchartqml
3 CONFIG += qt plugin
3 CONFIG += qt plugin
4 QT += declarative
4 QT += declarative
5
5
6 !include( ../config.pri ) {
6 !include( ../config.pri ) {
7 error( "Couldn't find the config.pri file!" )
7 error( "Couldn't find the config.pri file!" )
8 }
8 }
9
9
10 DESTDIR = $$CHART_BUILD_PLUGIN_DIR
10 DESTDIR = $$CHART_BUILD_PLUGIN_DIR
11 contains(QT_MAJOR_VERSION, 5) {
11 contains(QT_MAJOR_VERSION, 5) {
12 # TODO: QtQuick2 not supported by the implementation currently
12 # TODO: QtQuick2 not supported by the implementation currently
13 DEFINES += QTQUICK2
13 DEFINES += QTQUICK2
14 }
14 }
15
15
16 OBJECTS_DIR = $$CHART_BUILD_DIR/plugin
16 OBJECTS_DIR = $$CHART_BUILD_DIR/plugin
17 MOC_DIR = $$CHART_BUILD_DIR/plugin
17 MOC_DIR = $$CHART_BUILD_DIR/plugin
18 UI_DIR = $$CHART_BUILD_DIR/plugin
18 UI_DIR = $$CHART_BUILD_DIR/plugin
19 RCC_DIR = $$CHART_BUILD_DIR/plugin
19 RCC_DIR = $$CHART_BUILD_DIR/plugin
20
20
21 SOURCES += \
21 SOURCES += \
22 plugin.cpp \
22 plugin.cpp \
23 declarativechart.cpp \
23 declarativechart.cpp \
24 declarativeaxis.cpp \
24 declarativeaxis.cpp \
25 declarativexypoint.cpp \
25 declarativexypoint.cpp \
26 declarativexyseries.cpp \
26 declarativexyseries.cpp \
27 declarativelineseries.cpp \
27 declarativelineseries.cpp \
28 declarativesplineseries.cpp \
28 declarativesplineseries.cpp \
29 declarativeareaseries.cpp \
29 declarativeareaseries.cpp \
30 declarativescatterseries.cpp \
30 declarativescatterseries.cpp \
31 declarativepieseries.cpp \
31 declarativepieseries.cpp \
32 declarativebarseries.cpp
32 declarativebarseries.cpp \
33 declarativepiemodel.cpp
33 HEADERS += \
34 HEADERS += \
34 declarativechart.h \
35 declarativechart.h \
35 declarativeaxis.h \
36 declarativeaxis.h \
36 declarativexypoint.h \
37 declarativexypoint.h \
37 declarativexyseries.h \
38 declarativexyseries.h \
38 declarativelineseries.h \
39 declarativelineseries.h \
39 declarativesplineseries.h \
40 declarativesplineseries.h \
40 declarativeareaseries.h \
41 declarativeareaseries.h \
41 declarativescatterseries.h \
42 declarativescatterseries.h \
42 declarativepieseries.h \
43 declarativepieseries.h \
43 declarativebarseries.h
44 declarativebarseries.h \
45 declarativepiemodel.h
44
46
45 TARGETPATH = QtCommercial/Chart
47 TARGETPATH = QtCommercial/Chart
46 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
48 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
47 qmldir.files += $$PWD/qmldir
49 qmldir.files += $$PWD/qmldir
48 qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
50 qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
49 INSTALLS += target qmldir
51 INSTALLS += target qmldir
50
52
51 FILE = $$PWD/qmldir
53 FILE = $$PWD/qmldir
52 win32:{FILE = $$replace(FILE, "/","\\")}
54 win32:{FILE = $$replace(FILE, "/","\\")}
53 QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_PLUGIN_DIR
55 QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_PLUGIN_DIR
54 !system_build:mac: QMAKE_POST_LINK += " & $$MAC_POST_LINK_PREFIX $$MAC_PLUGINS_BIN_DIR"
56 !system_build:mac: QMAKE_POST_LINK += " & $$MAC_POST_LINK_PREFIX $$MAC_PLUGINS_BIN_DIR"
@@ -1,235 +1,237
1 !include( ../config.pri ):error( Couldn't find the config.pri file! )
1 !include( ../config.pri ):error( Couldn't find the config.pri file! )
2
2
3 ############################# BUILD CONFIG ######################################
3 ############################# BUILD CONFIG ######################################
4
4
5 TARGET = $$LIBRARY_NAME
5 TARGET = $$LIBRARY_NAME
6 DESTDIR = $$CHART_BUILD_LIB_DIR
6 DESTDIR = $$CHART_BUILD_LIB_DIR
7 TEMPLATE = lib
7 TEMPLATE = lib
8 QT = core gui
8 QT = core gui
9 DEFINES += QTCOMMERCIALCHART_LIBRARY
9 DEFINES += QTCOMMERCIALCHART_LIBRARY
10 win32:CONFIG += create_prl
10 win32:CONFIG += create_prl
11 # treat warnings as errors
11 # treat warnings as errors
12 win32-msvc*: {
12 win32-msvc*: {
13 QMAKE_CXXFLAGS += /WX
13 QMAKE_CXXFLAGS += /WX
14 } else {
14 } else {
15 QMAKE_CXXFLAGS += -Werror
15 QMAKE_CXXFLAGS += -Werror
16 }
16 }
17
17
18 unix:{
18 unix:{
19 QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
19 QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
20 }
20 }
21
21
22 ############################# DEPEDENCES ########################################
22 ############################# DEPEDENCES ########################################
23
23
24 win32-msvc*: LIBS += User32.lib
24 win32-msvc*: LIBS += User32.lib
25 LIBS -= -l$$LIBRARY_NAME
25 LIBS -= -l$$LIBRARY_NAME
26 INCLUDEPATH += ../include .
26 INCLUDEPATH += ../include .
27
27
28 ############################# SOURCES ##########################################
28 ############################# SOURCES ##########################################
29
29
30 SOURCES += \
30 SOURCES += \
31 $$PWD/chartdataset.cpp \
31 $$PWD/chartdataset.cpp \
32 $$PWD/chartpresenter.cpp \
32 $$PWD/chartpresenter.cpp \
33 $$PWD/charttheme.cpp \
33 $$PWD/charttheme.cpp \
34 $$PWD/domain.cpp \
34 $$PWD/domain.cpp \
35 $$PWD/qchart.cpp \
35 $$PWD/qchart.cpp \
36 $$PWD/qchartview.cpp \
36 $$PWD/qchartview.cpp \
37 $$PWD/qabstractseries.cpp \
37 $$PWD/qabstractseries.cpp \
38 $$PWD/chartbackground.cpp \
38 $$PWD/chartbackground.cpp \
39 $$PWD/chart.cpp \
39 $$PWD/chart.cpp \
40 $$PWD/scroller.cpp
40 $$PWD/scroller.cpp \
41 $$PWD/charttablemodel.cpp
41 PRIVATE_HEADERS += \
42 PRIVATE_HEADERS += \
42 $$PWD/chartdataset_p.h \
43 $$PWD/chartdataset_p.h \
43 $$PWD/chartitem_p.h \
44 $$PWD/chartitem_p.h \
44 $$PWD/chartpresenter_p.h \
45 $$PWD/chartpresenter_p.h \
45 $$PWD/charttheme_p.h \
46 $$PWD/charttheme_p.h \
46 $$PWD/domain_p.h \
47 $$PWD/domain_p.h \
47 $$PWD/chartbackground_p.h \
48 $$PWD/chartbackground_p.h \
48 $$PWD/chart_p.h \
49 $$PWD/chart_p.h \
49 $$PWD/chartconfig_p.h \
50 $$PWD/chartconfig_p.h \
50 $$PWD/qchart_p.h \
51 $$PWD/qchart_p.h \
51 $$PWD/qchartview_p.h \
52 $$PWD/qchartview_p.h \
52 $$PWD/scroller_p.h \
53 $$PWD/scroller_p.h \
53 $$PWD/qabstractseries_p.h
54 $$PWD/qabstractseries_p.h \
55 $$PWD/charttablemodel.h
54 PUBLIC_HEADERS += \
56 PUBLIC_HEADERS += \
55 $$PWD/qchart.h \
57 $$PWD/qchart.h \
56 $$PWD/qchartglobal.h \
58 $$PWD/qchartglobal.h \
57 $$PWD/qabstractseries.h \
59 $$PWD/qabstractseries.h \
58 $$PWD/qchartview.h
60 $$PWD/qchartview.h
59
61
60 include(animations/animations.pri)
62 include(animations/animations.pri)
61 include(areachart/areachart.pri)
63 include(areachart/areachart.pri)
62 include(axis/axis.pri)
64 include(axis/axis.pri)
63 include(barchart/barchart.pri)
65 include(barchart/barchart.pri)
64 include(legend/legend.pri)
66 include(legend/legend.pri)
65 include(linechart/linechart.pri)
67 include(linechart/linechart.pri)
66 include(piechart/piechart.pri)
68 include(piechart/piechart.pri)
67 include(scatterchart/scatter.pri)
69 include(scatterchart/scatter.pri)
68 include(splinechart/splinechart.pri)
70 include(splinechart/splinechart.pri)
69 include(themes/themes.pri)
71 include(themes/themes.pri)
70 include(xychart/xychart.pri)
72 include(xychart/xychart.pri)
71
73
72 HEADERS += $$PUBLIC_HEADERS
74 HEADERS += $$PUBLIC_HEADERS
73 HEADERS += $$PRIVATE_HEADERS
75 HEADERS += $$PRIVATE_HEADERS
74 HEADERS += $$THEMES
76 HEADERS += $$THEMES
75
77
76 ############################# BUILD PATH ##########################################
78 ############################# BUILD PATH ##########################################
77
79
78 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
80 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
79 MOC_DIR = $$CHART_BUILD_DIR/lib
81 MOC_DIR = $$CHART_BUILD_DIR/lib
80 UI_DIR = $$CHART_BUILD_DIR/lib
82 UI_DIR = $$CHART_BUILD_DIR/lib
81 RCC_DIR = $$CHART_BUILD_DIR/lib
83 RCC_DIR = $$CHART_BUILD_DIR/lib
82
84
83 ############################# PUBLIC HEADERS GENERTOR ##########################################
85 ############################# PUBLIC HEADERS GENERTOR ##########################################
84
86
85 #this is very primitive and lame parser , TODO: make perl script insted
87 #this is very primitive and lame parser , TODO: make perl script insted
86 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal)
88 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal)
87 {
89 {
88 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
90 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
89 win32:{
91 win32:{
90 command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
92 command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
91 }else{
93 }else{
92 command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
94 command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
93 }
95 }
94 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal
96 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal
95 system($$command)
97 system($$command)
96 }
98 }
97
99
98 for(file, PUBLIC_HEADERS) {
100 for(file, PUBLIC_HEADERS) {
99 name = $$split(file,'/')
101 name = $$split(file,'/')
100 name = $$last(name)
102 name = $$last(name)
101 class = "$$cat($$file)"
103 class = "$$cat($$file)"
102 class = $$find(class,class)
104 class = $$find(class,class)
103 !isEmpty(class){
105 !isEmpty(class){
104 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
106 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
105 class = $$member(class,1)
107 class = $$member(class,1)
106 class = $$split(class,' ')
108 class = $$split(class,' ')
107 class = $$replace(class,' ','')
109 class = $$replace(class,' ','')
108 class = $$member(class,0)
110 class = $$member(class,0)
109 win32:{
111 win32:{
110 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
112 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
111 }else{
113 }else{
112 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
114 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
113 }
115 }
114 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
116 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
115 system($$command)
117 system($$command)
116 }
118 }
117 }
119 }
118
120
119 ############################# INSTALLERS ##########################################
121 ############################# INSTALLERS ##########################################
120
122
121 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
123 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
122 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
124 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
123 INSTALLS += public_headers
125 INSTALLS += public_headers
124
126
125 install_build_public_headers.name = build_public_headers
127 install_build_public_headers.name = build_public_headers
126 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
128 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
127 install_build_public_headers.input = PUBLIC_HEADERS
129 install_build_public_headers.input = PUBLIC_HEADERS
128 install_build_public_headers.commands = $$QMAKE_COPY \
130 install_build_public_headers.commands = $$QMAKE_COPY \
129 ${QMAKE_FILE_NAME} \
131 ${QMAKE_FILE_NAME} \
130 $$CHART_BUILD_PUBLIC_HEADER_DIR
132 $$CHART_BUILD_PUBLIC_HEADER_DIR
131 install_build_public_headers.CONFIG += target_predeps \
133 install_build_public_headers.CONFIG += target_predeps \
132 no_link
134 no_link
133
135
134 install_build_private_headers.name = buld_private_headers
136 install_build_private_headers.name = buld_private_headers
135 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
137 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
136 install_build_private_headers.input = PRIVATE_HEADERS
138 install_build_private_headers.input = PRIVATE_HEADERS
137 install_build_private_headers.commands = $$QMAKE_COPY \
139 install_build_private_headers.commands = $$QMAKE_COPY \
138 ${QMAKE_FILE_NAME} \
140 ${QMAKE_FILE_NAME} \
139 $$CHART_BUILD_PRIVATE_HEADER_DIR
141 $$CHART_BUILD_PRIVATE_HEADER_DIR
140 install_build_private_headers.CONFIG += target_predeps \
142 install_build_private_headers.CONFIG += target_predeps \
141 no_link
143 no_link
142
144
143 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
145 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
144 install_build_private_headers \
146 install_build_private_headers \
145
147
146 win32:{
148 win32:{
147 bintarget.CONFIG += no_check_exist
149 bintarget.CONFIG += no_check_exist
148 bintarget.files = $$CHART_BUILD_LIB_DIR\\*.dll
150 bintarget.files = $$CHART_BUILD_LIB_DIR\\*.dll
149 win32-msvc*:CONFIG(debug, debug|release): {
151 win32-msvc*:CONFIG(debug, debug|release): {
150 bintarget.files += $$CHART_BUILD_LIB_DIR\\*.pdb
152 bintarget.files += $$CHART_BUILD_LIB_DIR\\*.pdb
151 }
153 }
152 bintarget.path = $$[QT_INSTALL_BINS]
154 bintarget.path = $$[QT_INSTALL_BINS]
153
155
154 libtarget.CONFIG += no_check_exist
156 libtarget.CONFIG += no_check_exist
155 libtarget.files = $$CHART_BUILD_LIB_DIR\\*.prl
157 libtarget.files = $$CHART_BUILD_LIB_DIR\\*.prl
156 win32-msvc*: {
158 win32-msvc*: {
157 libtarget.files += $$CHART_BUILD_LIB_DIR\\*.lib
159 libtarget.files += $$CHART_BUILD_LIB_DIR\\*.lib
158 } else {
160 } else {
159 libtarget.files += $$CHART_BUILD_LIB_DIR\\*.a
161 libtarget.files += $$CHART_BUILD_LIB_DIR\\*.a
160 }
162 }
161 libtarget.path = $$[QT_INSTALL_LIBS]
163 libtarget.path = $$[QT_INSTALL_LIBS]
162
164
163 DLLDESTDIR = $$CHART_BUILD_BIN_DIR
165 DLLDESTDIR = $$CHART_BUILD_BIN_DIR
164 INSTALLS += bintarget libtarget
166 INSTALLS += bintarget libtarget
165 }else{
167 }else{
166 target.path=$$[QT_INSTALL_LIBS]
168 target.path=$$[QT_INSTALL_LIBS]
167 INSTALLS += target
169 INSTALLS += target
168 }
170 }
169 ################################ DEVELOPMENT BUILD ##########################################
171 ################################ DEVELOPMENT BUILD ##########################################
170 # There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly.
172 # There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly.
171 # This is the case at least with shadow builds.
173 # This is the case at least with shadow builds.
172 # http://qt-project.org/wiki/jom
174 # http://qt-project.org/wiki/jom
173
175
174 development_build:!win32-msvc*:{
176 development_build:!win32-msvc*:{
175 chartversion.target = $$PWD/qchartversion_p.h
177 chartversion.target = $$PWD/qchartversion_p.h
176
178
177 unix:{
179 unix:{
178 chartversion.commands = @echo \
180 chartversion.commands = @echo \
179 \" $${LITERAL_HASH}ifndef QCHARTVERSION_P_H\\n\
181 \" $${LITERAL_HASH}ifndef QCHARTVERSION_P_H\\n\
180 $${LITERAL_HASH}define QCHARTVERSION_P_H\\n\
182 $${LITERAL_HASH}define QCHARTVERSION_P_H\\n\
181 const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" ; \\n\
183 const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" ; \\n\
182 const char *gitHead = \\\"`git rev-parse HEAD`\\\" ; \\n \
184 const char *gitHead = \\\"`git rev-parse HEAD`\\\" ; \\n \
183 $${LITERAL_HASH}endif \" \
185 $${LITERAL_HASH}endif \" \
184 > \
186 > \
185 $$chartversion.target;
187 $$chartversion.target;
186 }else{
188 }else{
187 chartversion.commands = @echo \
189 chartversion.commands = @echo \
188 "const char *buildTime = \"%date%_%time%\" ; \
190 "const char *buildTime = \"%date%_%time%\" ; \
189 const char *gitHead = \"unknown\" ; " \
191 const char *gitHead = \"unknown\" ; " \
190 > \
192 > \
191 $$chartversion.target
193 $$chartversion.target
192 }
194 }
193
195
194 chartversion.depends = $$HEADERS \
196 chartversion.depends = $$HEADERS \
195 $$SOURCES
197 $$SOURCES
196
198
197 PRE_TARGETDEPS += $$chartversion.target
199 PRE_TARGETDEPS += $$chartversion.target
198 QMAKE_CLEAN += $$PWD/qchartversion_p.h
200 QMAKE_CLEAN += $$PWD/qchartversion_p.h
199 QMAKE_EXTRA_TARGETS += chartversion
201 QMAKE_EXTRA_TARGETS += chartversion
200 }
202 }
201
203
202 ############################### CLEAN ###########################################
204 ############################### CLEAN ###########################################
203
205
204 unix:QMAKE_DISTCLEAN += -r \
206 unix:QMAKE_DISTCLEAN += -r \
205 $$CHART_BUILD_HEADER_DIR \
207 $$CHART_BUILD_HEADER_DIR \
206 $$CHART_BUILD_LIB_DIR
208 $$CHART_BUILD_LIB_DIR
207 win32:QMAKE_DISTCLEAN += /Q \
209 win32:QMAKE_DISTCLEAN += /Q \
208 $$CHART_BUILD_HEADER_DIR \
210 $$CHART_BUILD_HEADER_DIR \
209 $$CHART_BUILD_LIB_DIR
211 $$CHART_BUILD_LIB_DIR
210
212
211 ############################## COVERAGE #########################################
213 ############################## COVERAGE #########################################
212
214
213 unix:coverage:{
215 unix:coverage:{
214
216
215 QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
217 QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
216 QMAKE_LDFLAGS += -fprofile-arcs -ftest-coverage
218 QMAKE_LDFLAGS += -fprofile-arcs -ftest-coverage
217
219
218 LIBS += -lgcov
220 LIBS += -lgcov
219
221
220 QMAKE_CLEAN += $$OBJECTS_DIR/*.gcda $$OBJECTS_DIR/*.gcno $$PWD/*.gcov ../coverage/*.info
222 QMAKE_CLEAN += $$OBJECTS_DIR/*.gcda $$OBJECTS_DIR/*.gcno $$PWD/*.gcov ../coverage/*.info
221 QMAKE_EXTRA_TARGETS += preparecoverage gencoverage
223 QMAKE_EXTRA_TARGETS += preparecoverage gencoverage
222
224
223 preparecoverage.target = prepare_coverage
225 preparecoverage.target = prepare_coverage
224 preparecoverage.depends = all
226 preparecoverage.depends = all
225 preparecoverage.commands = lcov --directory $$OBJECTS_DIR --zerocounters ;\
227 preparecoverage.commands = lcov --directory $$OBJECTS_DIR --zerocounters ;\
226 lcov -i -d $$OBJECTS_DIR -c -o ../coverage/base.info -b $$PWD;
228 lcov -i -d $$OBJECTS_DIR -c -o ../coverage/base.info -b $$PWD;
227
229
228 gencoverage.target = gen_coverage
230 gencoverage.target = gen_coverage
229 gencoverage.depends = all
231 gencoverage.depends = all
230 gencoverage.commands = lcov -d $$OBJECTS_DIR -c -o ../coverage/src.info -b $$PWD;\
232 gencoverage.commands = lcov -d $$OBJECTS_DIR -c -o ../coverage/src.info -b $$PWD;\
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;\
233 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;\
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;\
234 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;\
233 lcov -a ../coverage/base.info -a ../coverage/src.info -o ../coverage/coverage.info;
235 lcov -a ../coverage/base.info -a ../coverage/src.info -o ../coverage/coverage.info;
234 }
236 }
235
237
General Comments 0
You need to be logged in to leave comments. Login now