##// 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 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 Rectangle {
25 25 anchors.fill: parent
26 26
27 Chart {
27 ChartView {
28 id: chart
28 29 title: "Car brand shares in Finland"
29 anchors.fill: parent
30 theme: Chart.ChartThemeLight
31 legend: Chart.LegendBottom
30 anchors.top: parent.top
31 anchors.bottom: button.top
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 38 PieSeries {
34 horizontalPosition: 0.5
35 verticalPosition: 0.5
36 size: 0.7
37 slices: [
38 PieSlice { label: "Volkswagen"; value: 13.5 },
39 PieSlice { label: "Toyota"; value: 10.9 },
40 PieSlice { label: "Ford"; value: 8.6 },
41 PieSlice { label: "Skoda"; value: 8.2 },
42 PieSlice { label: "Volvo"; value: 6.8 },
43 PieSlice { label: "Others"; value: 52.0 }
44 ]
39 model: PieModel {
40 id: pieModel
41 PieSlice { label: "Volkswagen"; value: 13.5 }
42 PieSlice { label: "Toyota"; value: 10.9 }
43 PieSlice { label: "Ford"; value: 8.6 }
44 PieSlice { label: "Skoda"; value: 8.2 }
45 PieSlice { label: "Volvo"; value: 6.8 }
46 }
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 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 Rectangle {
25 25 anchors.fill: parent
26 26
27 Chart {
27 ChartView {
28 28 title: "Line&Spline"
29 29 anchors.fill: parent
30 theme: Chart.ChartThemeBrownSand
31 animationOptions: Chart.NoAnimation
30 theme: ChartView.ChartThemeBrownSand
31 animationOptions: ChartView.NoAnimation
32 32
33 33 LineSeries {
34 34 name: "Line"
35 35 points: [
36 36 XyPoint { x: 0.0; y: 0.0 },
37 37 XyPoint { x: 1.1; y: 2.1 },
38 38 XyPoint { x: 1.9; y: 3.3 },
39 39 XyPoint { x: 2.9; y: 4.9 },
40 40 XyPoint { x: 3.2; y: 3.0 },
41 41 XyPoint { x: 4.0; y: 3.3 }
42 42 ]
43 43 }
44 44
45 45 SplineSeries {
46 46 name: "Spline"
47 47 points: [
48 48 XyPoint { x: 0.0; y: 0.3 },
49 49 XyPoint { x: 1.1; y: 3.2 },
50 50 XyPoint { x: 1.7; y: 2.4 },
51 51 XyPoint { x: 2.1; y: 2.1 },
52 52 XyPoint { x: 2.9; y: 2.6 },
53 53 XyPoint { x: 3.4; y: 2.3 },
54 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 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 Rectangle {
25 25 anchors.fill: parent
26 26
27 Chart {
27 ChartView {
28 28 title: "NHL All-Star Team Players"
29 29 anchors.fill: parent
30 theme: Chart.ChartThemeHighContrast
31 legend: Chart.LegendTop
30 theme: ChartView.ChartThemeHighContrast
31 legend: ChartView.LegendTop
32 32
33 33 AreaSeries {
34 34 name: "Swedish"
35 35 points: [
36 36 XyPoint { x: 0; y: 1 },
37 37 XyPoint { x: 1; y: 1 },
38 38 XyPoint { x: 2; y: 3 },
39 39 XyPoint { x: 3; y: 3 },
40 40 XyPoint { x: 4; y: 2 },
41 41 XyPoint { x: 5; y: 0 },
42 42 XyPoint { x: 6; y: 2 },
43 43 XyPoint { x: 7; y: 1 },
44 44 XyPoint { x: 8; y: 2 },
45 45 XyPoint { x: 9; y: 1 },
46 46 XyPoint { x: 10; y: 3 },
47 47 XyPoint { x: 11; y: 3 }
48 48 ]
49 49 lowerPoints: [
50 50 XyPoint { x: 0; y: 0 },
51 51 XyPoint { x: 1; y: 0 },
52 52 XyPoint { x: 2; y: 0 },
53 53 XyPoint { x: 3; y: 0 },
54 54 XyPoint { x: 4; y: 0 },
55 55 XyPoint { x: 5; y: 0 },
56 56 XyPoint { x: 6; y: 0 },
57 57 XyPoint { x: 7; y: 0 },
58 58 XyPoint { x: 8; y: 0 },
59 59 XyPoint { x: 9; y: 0 },
60 60 XyPoint { x: 10; y: 0 },
61 61 XyPoint { x: 11; y: 0 }
62 62 ]
63 63 }
64 64
65 65 AreaSeries {
66 66 name: "Russian"
67 67 points: [
68 68 XyPoint { x: 0; y: 1 },
69 69 XyPoint { x: 1; y: 1 },
70 70 XyPoint { x: 2; y: 1 },
71 71 XyPoint { x: 3; y: 1 },
72 72 XyPoint { x: 4; y: 1 },
73 73 XyPoint { x: 5; y: 0 },
74 74 XyPoint { x: 6; y: 1 },
75 75 XyPoint { x: 7; y: 1 },
76 76 XyPoint { x: 8; y: 4 },
77 77 XyPoint { x: 9; y: 3 },
78 78 XyPoint { x: 10; y: 2 },
79 79 XyPoint { x: 11; y: 1 }
80 80 ]
81 81 lowerPoints: [
82 82 XyPoint { x: 0; y: 0 },
83 83 XyPoint { x: 1; y: 0 },
84 84 XyPoint { x: 2; y: 0 },
85 85 XyPoint { x: 3; y: 0 },
86 86 XyPoint { x: 4; y: 0 },
87 87 XyPoint { x: 5; y: 0 },
88 88 XyPoint { x: 6; y: 0 },
89 89 XyPoint { x: 7; y: 0 },
90 90 XyPoint { x: 8; y: 0 },
91 91 XyPoint { x: 9; y: 0 },
92 92 XyPoint { x: 10; y: 0 },
93 93 XyPoint { x: 11; y: 0 }
94 94 ]
95 95 }
96 96
97 97 AreaSeries {
98 98 name: "Finnish"
99 99 points: [
100 100 XyPoint { x: 0; y: 0 },
101 101 XyPoint { x: 1; y: 0 },
102 102 XyPoint { x: 2; y: 0 },
103 103 XyPoint { x: 3; y: 0 },
104 104 XyPoint { x: 4; y: 0 },
105 105 XyPoint { x: 5; y: 0 },
106 106 XyPoint { x: 6; y: 1 },
107 107 XyPoint { x: 7; y: 0 },
108 108 XyPoint { x: 8; y: 0 },
109 109 XyPoint { x: 9; y: 0 },
110 110 XyPoint { x: 10; y: 0 },
111 111 XyPoint { x: 11; y: 1 }
112 112 ]
113 113 lowerPoints: [
114 114 XyPoint { x: 0; y: 0 },
115 115 XyPoint { x: 1; y: 0 },
116 116 XyPoint { x: 2; y: 0 },
117 117 XyPoint { x: 3; y: 0 },
118 118 XyPoint { x: 4; y: 0 },
119 119 XyPoint { x: 5; y: 0 },
120 120 XyPoint { x: 6; y: 0 },
121 121 XyPoint { x: 7; y: 0 },
122 122 XyPoint { x: 8; y: 0 },
123 123 XyPoint { x: 9; y: 0 },
124 124 XyPoint { x: 10; y: 0 },
125 125 XyPoint { x: 11; y: 0 }
126 126 ]
127 127 }
128 128 }
129 129 }
@@ -1,57 +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 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 Rectangle {
25 25 anchors.fill: parent
26 26
27 Chart {
27 ChartView {
28 28 title: "Scatters"
29 29 anchors.fill: parent
30 theme: Chart.ChartThemeBlueCerulean
30 theme: ChartView.ChartThemeBlueCerulean
31 31
32 32 ScatterSeries {
33 33 id: scatter1
34 34 name: "Scatter1"
35 35 points: [
36 36 XyPoint { x: 1.5; y: 1.5 },
37 37 XyPoint { x: 1.5; y: 1.6 },
38 38 XyPoint { x: 1.57; y: 1.55 },
39 39 XyPoint { x: 1.8; y: 1.8 },
40 40 XyPoint { x: 1.9; y: 1.6 },
41 41 XyPoint { x: 2.1; y: 1.3 },
42 42 XyPoint { x: 2.5; y: 2.1 }
43 43 ]
44 44 }
45 45 ScatterSeries {
46 46 name: "Scatter2"
47 47 points: [
48 48 XyPoint { x: 2.0; y: 2.0 },
49 49 XyPoint { x: 2.0; y: 2.1 },
50 50 XyPoint { x: 2.07; y: 2.05 },
51 51 XyPoint { x: 2.2; y: 2.9 },
52 52 XyPoint { x: 2.4; y: 2.7 },
53 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 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 Rectangle {
25 25 anchors.fill: parent
26 26
27 Chart {
27 ChartView {
28 28 title: "Bar series"
29 29 anchors.fill: parent
30 theme: Chart.ChartThemeLight
31 legend: Chart.LegendBottom
30 theme: ChartView.ChartThemeLight
31 legend: ChartView.LegendBottom
32 32
33 33 BarSeries {
34 34 barCategories: [ "2008", "2009", "2010", "2011", "2012" ]
35 35 // data implementation missing
36 36 }
37 37 }
38 38 }
@@ -1,53 +1,41
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 Rectangle {
25 25 width: parent.width
26 26 height: parent.height
27 27 property int __viewNumber: 0
28 28
29 Timer {
30 id: timer
31 running: true
32 repeat: true
33 interval: 5000
34 triggeredOnStart: false
35 onTriggered: {
29 MouseArea {
30 anchors.fill: parent
31 onClicked: {
36 32 __viewNumber++;
37 33 }
38 34 }
39 35
40 36 Loader {
41 37 id: loader
42 38 anchors.fill: parent
43 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 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 "declarativepieseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 #include <qdeclarativelist.h>
24 25
25 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 27
27 28 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
28 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,
38 QPieSlice *slice)
44 DeclarativePieModel *DeclarativePieSeries::pieModel()
39 45 {
40 DeclarativePieSeries *series = qobject_cast<DeclarativePieSeries *>(list->object);
41 if (series)
42 series->append(slice->value(), slice->label());
46 return qobject_cast<DeclarativePieModel *>(model());
43 47 }
44 48
45 49 #include "moc_declarativepieseries.cpp"
46 50
47 51 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,49 +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 21 #ifndef DECLARATIVEPIESERIES_H
22 22 #define DECLARATIVEPIESERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qpieslice.h"
26 26 #include "qpieseries.h"
27 27 #include <QDeclarativeListProperty>
28 #include <QAbstractItemModel>
29 #include <QVariant>
30 #include "declarativepiemodel.h"
28 31
29 32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 33
31 34 class QChart;
32 35
33 36 class DeclarativePieSeries : public QPieSeries
34 37 {
35 38 Q_OBJECT
36 Q_PROPERTY(QDeclarativeListProperty<QPieSlice> slices READ slices)
39 Q_PROPERTY(DeclarativePieModel *model READ pieModel WRITE setPieModel)
37 40
38 41 public:
39 42 explicit DeclarativePieSeries(QObject *parent = 0);
40 QDeclarativeListProperty<QPieSlice> slices();
41 43
42 44 public Q_SLOTS:
43 static void appendSlice(QDeclarativeListProperty<QPieSlice> *list,
44 QPieSlice *element);
45
46 public:
47 bool setPieModel(DeclarativePieModel *model);
48 DeclarativePieModel *pieModel();
45 49 };
46 50
47 51 QTCOMMERCIALCHART_END_NAMESPACE
48 52
49 53 #endif // DECLARATIVEPIESERIES_H
@@ -1,63 +1,66
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 "declarativechart.h"
25 25 #include "declarativeaxis.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 "declarativepiemodel.h"
33 34
34 35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 36
36 37 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
37 38 {
38 39 Q_OBJECT
39 40 public:
40 41 virtual void registerTypes(const char *uri)
41 42 {
42 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 46 qmlRegisterType<DeclarativeAxis>(uri, 1, 0, "Axis");
46 47 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
47 48 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
48 49 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
49 50 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
50 51 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
51 52 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
52 53 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
53 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 60 #include "plugin.moc"
58 61
59 62 QTCOMMERCIALCHART_END_NAMESPACE
60 63
61 64 QTCOMMERCIALCHART_USE_NAMESPACE
62 65
63 66 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
@@ -1,54 +1,56
1 1 TEMPLATE = lib
2 2 TARGET = qtcommercialchartqml
3 3 CONFIG += qt plugin
4 4 QT += declarative
5 5
6 6 !include( ../config.pri ) {
7 7 error( "Couldn't find the config.pri file!" )
8 8 }
9 9
10 10 DESTDIR = $$CHART_BUILD_PLUGIN_DIR
11 11 contains(QT_MAJOR_VERSION, 5) {
12 12 # TODO: QtQuick2 not supported by the implementation currently
13 13 DEFINES += QTQUICK2
14 14 }
15 15
16 16 OBJECTS_DIR = $$CHART_BUILD_DIR/plugin
17 17 MOC_DIR = $$CHART_BUILD_DIR/plugin
18 18 UI_DIR = $$CHART_BUILD_DIR/plugin
19 19 RCC_DIR = $$CHART_BUILD_DIR/plugin
20 20
21 21 SOURCES += \
22 22 plugin.cpp \
23 23 declarativechart.cpp \
24 24 declarativeaxis.cpp \
25 25 declarativexypoint.cpp \
26 26 declarativexyseries.cpp \
27 27 declarativelineseries.cpp \
28 28 declarativesplineseries.cpp \
29 29 declarativeareaseries.cpp \
30 30 declarativescatterseries.cpp \
31 31 declarativepieseries.cpp \
32 declarativebarseries.cpp
32 declarativebarseries.cpp \
33 declarativepiemodel.cpp
33 34 HEADERS += \
34 35 declarativechart.h \
35 36 declarativeaxis.h \
36 37 declarativexypoint.h \
37 38 declarativexyseries.h \
38 39 declarativelineseries.h \
39 40 declarativesplineseries.h \
40 41 declarativeareaseries.h \
41 42 declarativescatterseries.h \
42 43 declarativepieseries.h \
43 declarativebarseries.h
44 declarativebarseries.h \
45 declarativepiemodel.h
44 46
45 47 TARGETPATH = QtCommercial/Chart
46 48 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
47 49 qmldir.files += $$PWD/qmldir
48 50 qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
49 51 INSTALLS += target qmldir
50 52
51 53 FILE = $$PWD/qmldir
52 54 win32:{FILE = $$replace(FILE, "/","\\")}
53 55 QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_PLUGIN_DIR
54 56 !system_build:mac: QMAKE_POST_LINK += " & $$MAC_POST_LINK_PREFIX $$MAC_PLUGINS_BIN_DIR"
@@ -1,235 +1,237
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
40 $$PWD/scroller.cpp \
41 $$PWD/charttablemodel.cpp
41 42 PRIVATE_HEADERS += \
42 43 $$PWD/chartdataset_p.h \
43 44 $$PWD/chartitem_p.h \
44 45 $$PWD/chartpresenter_p.h \
45 46 $$PWD/charttheme_p.h \
46 47 $$PWD/domain_p.h \
47 48 $$PWD/chartbackground_p.h \
48 49 $$PWD/chart_p.h \
49 50 $$PWD/chartconfig_p.h \
50 51 $$PWD/qchart_p.h \
51 52 $$PWD/qchartview_p.h \
52 53 $$PWD/scroller_p.h \
53 $$PWD/qabstractseries_p.h
54 $$PWD/qabstractseries_p.h \
55 $$PWD/charttablemodel.h
54 56 PUBLIC_HEADERS += \
55 57 $$PWD/qchart.h \
56 58 $$PWD/qchartglobal.h \
57 59 $$PWD/qabstractseries.h \
58 60 $$PWD/qchartview.h
59 61
60 62 include(animations/animations.pri)
61 63 include(areachart/areachart.pri)
62 64 include(axis/axis.pri)
63 65 include(barchart/barchart.pri)
64 66 include(legend/legend.pri)
65 67 include(linechart/linechart.pri)
66 68 include(piechart/piechart.pri)
67 69 include(scatterchart/scatter.pri)
68 70 include(splinechart/splinechart.pri)
69 71 include(themes/themes.pri)
70 72 include(xychart/xychart.pri)
71 73
72 74 HEADERS += $$PUBLIC_HEADERS
73 75 HEADERS += $$PRIVATE_HEADERS
74 76 HEADERS += $$THEMES
75 77
76 78 ############################# BUILD PATH ##########################################
77 79
78 80 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
79 81 MOC_DIR = $$CHART_BUILD_DIR/lib
80 82 UI_DIR = $$CHART_BUILD_DIR/lib
81 83 RCC_DIR = $$CHART_BUILD_DIR/lib
82 84
83 85 ############################# PUBLIC HEADERS GENERTOR ##########################################
84 86
85 87 #this is very primitive and lame parser , TODO: make perl script insted
86 88 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal)
87 89 {
88 90 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
89 91 win32:{
90 92 command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
91 93 }else{
92 94 command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
93 95 }
94 96 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal
95 97 system($$command)
96 98 }
97 99
98 100 for(file, PUBLIC_HEADERS) {
99 101 name = $$split(file,'/')
100 102 name = $$last(name)
101 103 class = "$$cat($$file)"
102 104 class = $$find(class,class)
103 105 !isEmpty(class){
104 106 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
105 107 class = $$member(class,1)
106 108 class = $$split(class,' ')
107 109 class = $$replace(class,' ','')
108 110 class = $$member(class,0)
109 111 win32:{
110 112 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
111 113 }else{
112 114 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
113 115 }
114 116 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
115 117 system($$command)
116 118 }
117 119 }
118 120
119 121 ############################# INSTALLERS ##########################################
120 122
121 123 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
122 124 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
123 125 INSTALLS += public_headers
124 126
125 127 install_build_public_headers.name = build_public_headers
126 128 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
127 129 install_build_public_headers.input = PUBLIC_HEADERS
128 130 install_build_public_headers.commands = $$QMAKE_COPY \
129 131 ${QMAKE_FILE_NAME} \
130 132 $$CHART_BUILD_PUBLIC_HEADER_DIR
131 133 install_build_public_headers.CONFIG += target_predeps \
132 134 no_link
133 135
134 136 install_build_private_headers.name = buld_private_headers
135 137 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
136 138 install_build_private_headers.input = PRIVATE_HEADERS
137 139 install_build_private_headers.commands = $$QMAKE_COPY \
138 140 ${QMAKE_FILE_NAME} \
139 141 $$CHART_BUILD_PRIVATE_HEADER_DIR
140 142 install_build_private_headers.CONFIG += target_predeps \
141 143 no_link
142 144
143 145 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
144 146 install_build_private_headers \
145 147
146 148 win32:{
147 149 bintarget.CONFIG += no_check_exist
148 150 bintarget.files = $$CHART_BUILD_LIB_DIR\\*.dll
149 151 win32-msvc*:CONFIG(debug, debug|release): {
150 152 bintarget.files += $$CHART_BUILD_LIB_DIR\\*.pdb
151 153 }
152 154 bintarget.path = $$[QT_INSTALL_BINS]
153 155
154 156 libtarget.CONFIG += no_check_exist
155 157 libtarget.files = $$CHART_BUILD_LIB_DIR\\*.prl
156 158 win32-msvc*: {
157 159 libtarget.files += $$CHART_BUILD_LIB_DIR\\*.lib
158 160 } else {
159 161 libtarget.files += $$CHART_BUILD_LIB_DIR\\*.a
160 162 }
161 163 libtarget.path = $$[QT_INSTALL_LIBS]
162 164
163 165 DLLDESTDIR = $$CHART_BUILD_BIN_DIR
164 166 INSTALLS += bintarget libtarget
165 167 }else{
166 168 target.path=$$[QT_INSTALL_LIBS]
167 169 INSTALLS += target
168 170 }
169 171 ################################ DEVELOPMENT BUILD ##########################################
170 172 # There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly.
171 173 # This is the case at least with shadow builds.
172 174 # http://qt-project.org/wiki/jom
173 175
174 176 development_build:!win32-msvc*:{
175 177 chartversion.target = $$PWD/qchartversion_p.h
176 178
177 179 unix:{
178 180 chartversion.commands = @echo \
179 181 \" $${LITERAL_HASH}ifndef QCHARTVERSION_P_H\\n\
180 182 $${LITERAL_HASH}define QCHARTVERSION_P_H\\n\
181 183 const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" ; \\n\
182 184 const char *gitHead = \\\"`git rev-parse HEAD`\\\" ; \\n \
183 185 $${LITERAL_HASH}endif \" \
184 186 > \
185 187 $$chartversion.target;
186 188 }else{
187 189 chartversion.commands = @echo \
188 190 "const char *buildTime = \"%date%_%time%\" ; \
189 191 const char *gitHead = \"unknown\" ; " \
190 192 > \
191 193 $$chartversion.target
192 194 }
193 195
194 196 chartversion.depends = $$HEADERS \
195 197 $$SOURCES
196 198
197 199 PRE_TARGETDEPS += $$chartversion.target
198 200 QMAKE_CLEAN += $$PWD/qchartversion_p.h
199 201 QMAKE_EXTRA_TARGETS += chartversion
200 202 }
201 203
202 204 ############################### CLEAN ###########################################
203 205
204 206 unix:QMAKE_DISTCLEAN += -r \
205 207 $$CHART_BUILD_HEADER_DIR \
206 208 $$CHART_BUILD_LIB_DIR
207 209 win32:QMAKE_DISTCLEAN += /Q \
208 210 $$CHART_BUILD_HEADER_DIR \
209 211 $$CHART_BUILD_LIB_DIR
210 212
211 213 ############################## COVERAGE #########################################
212 214
213 215 unix:coverage:{
214 216
215 217 QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
216 218 QMAKE_LDFLAGS += -fprofile-arcs -ftest-coverage
217 219
218 220 LIBS += -lgcov
219 221
220 222 QMAKE_CLEAN += $$OBJECTS_DIR/*.gcda $$OBJECTS_DIR/*.gcno $$PWD/*.gcov ../coverage/*.info
221 223 QMAKE_EXTRA_TARGETS += preparecoverage gencoverage
222 224
223 225 preparecoverage.target = prepare_coverage
224 226 preparecoverage.depends = all
225 227 preparecoverage.commands = lcov --directory $$OBJECTS_DIR --zerocounters ;\
226 228 lcov -i -d $$OBJECTS_DIR -c -o ../coverage/base.info -b $$PWD;
227 229
228 230 gencoverage.target = gen_coverage
229 231 gencoverage.depends = all
230 232 gencoverage.commands = lcov -d $$OBJECTS_DIR -c -o ../coverage/src.info -b $$PWD;\
231 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 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 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