@@ -1,117 +1,122 | |||||
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 "customtablemodel.h" |
|
21 | #include "customtablemodel.h" | |
22 | #include <QVector> |
|
22 | #include <QVector> | |
23 | #include <QRect> |
|
23 | #include <QRect> | |
24 | #include <QColor> |
|
24 | #include <QColor> | |
25 |
|
25 | |||
26 | CustomTableModel::CustomTableModel(QObject *parent) : |
|
26 | CustomTableModel::CustomTableModel(QObject *parent) : | |
27 | QAbstractTableModel(parent), |
|
27 | QAbstractTableModel(parent), | |
28 | m_columnCount(0), |
|
28 | m_columnCount(0), | |
29 | m_rowCount(0) |
|
29 | m_rowCount(0) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | int CustomTableModel::rowCount(const QModelIndex & parent) const |
|
33 | int CustomTableModel::rowCount(const QModelIndex & parent) const | |
34 | { |
|
34 | { | |
35 | Q_UNUSED(parent) |
|
35 | Q_UNUSED(parent) | |
36 | return m_data.count(); |
|
36 | return m_data.count(); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | int CustomTableModel::columnCount(const QModelIndex & parent) const |
|
39 | int CustomTableModel::columnCount(const QModelIndex & parent) const | |
40 | { |
|
40 | { | |
41 | Q_UNUSED(parent) |
|
41 | Q_UNUSED(parent) | |
42 | return m_columnCount; |
|
42 | return m_columnCount; | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | QVariant CustomTableModel::headerData (int section, Qt::Orientation orientation, int role ) const |
|
45 | QVariant CustomTableModel::headerData (int section, Qt::Orientation orientation, int role ) const | |
46 | { |
|
46 | { | |
47 | if (role != Qt::DisplayRole) |
|
47 | if (role != Qt::DisplayRole) | |
48 | return QVariant(); |
|
48 | return QVariant(); | |
49 |
|
49 | |||
50 | if (orientation == Qt::Horizontal) { |
|
50 | if (orientation == Qt::Horizontal) { | |
51 | if (section % 2 == 0) |
|
51 | if (section % 2 == 0) | |
52 | return "x"; |
|
52 | return "x"; | |
53 | else |
|
53 | else | |
54 | return "y"; |
|
54 | return "y"; | |
55 | } else { |
|
55 | } else { | |
56 | return QString("%1").arg(section + 1); |
|
56 | return QString("%1").arg(section + 1); | |
57 | } |
|
57 | } | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | QVariant CustomTableModel::data(const QModelIndex &index, int role) const |
|
60 | QVariant CustomTableModel::data(const QModelIndex &index, int role) const | |
61 | { |
|
61 | { | |
62 | if (role == Qt::DisplayRole) { |
|
62 | if (role == Qt::DisplayRole) { | |
63 | return m_data[index.row()]->at(index.column()); |
|
63 | return m_data[index.row()]->at(index.column()); | |
64 | } else if (role == Qt::EditRole) { |
|
64 | } else if (role == Qt::EditRole) { | |
65 | return m_data[index.row()]->at(index.column()); |
|
65 | return m_data[index.row()]->at(index.column()); | |
66 | } |
|
66 | } | |
67 | return QVariant(); |
|
67 | return QVariant(); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role) |
|
70 | bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role) | |
71 | { |
|
71 | { | |
72 | if (index.isValid() && role == Qt::EditRole) { |
|
72 | if (index.isValid() && role == Qt::EditRole) { | |
73 | m_data[index.row()]->replace(index.column(), value); |
|
73 | m_data[index.row()]->replace(index.column(), value); | |
74 | emit dataChanged(index, index); |
|
74 | emit dataChanged(index, index); | |
75 | return true; |
|
75 | return true; | |
76 | } |
|
76 | } | |
77 | return false; |
|
77 | return false; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
|
80 | QVariant CustomTableModel::at(int row, int column) | |||
|
81 | { | |||
|
82 | return data(index(row, column)); | |||
|
83 | } | |||
|
84 | ||||
80 | void CustomTableModel::insertColumn(int column, const QModelIndex &parent) |
|
85 | void CustomTableModel::insertColumn(int column, const QModelIndex &parent) | |
81 | { |
|
86 | { | |
82 | beginInsertColumns(parent, column, column); |
|
87 | beginInsertColumns(parent, column, column); | |
83 | m_columnCount++; |
|
88 | m_columnCount++; | |
84 | endInsertColumns(); |
|
89 | endInsertColumns(); | |
85 | } |
|
90 | } | |
86 |
|
91 | |||
87 | void CustomTableModel::insertRow(int row, const QModelIndex &parent) |
|
92 | void CustomTableModel::insertRow(int row, const QModelIndex &parent) | |
88 | { |
|
93 | { | |
89 | beginInsertRows(parent, row, row); |
|
94 | beginInsertRows(parent, row, row); | |
90 | QVector<QVariant>* dataVec = new QVector<QVariant>(m_columnCount); |
|
95 | QVector<QVariant>* dataVec = new QVector<QVariant>(m_columnCount); | |
91 | m_data.insert(row, dataVec); |
|
96 | m_data.insert(row, dataVec); | |
92 | endInsertRows(); |
|
97 | endInsertRows(); | |
93 | } |
|
98 | } | |
94 |
|
99 | |||
95 | bool CustomTableModel::removeRow(int row, const QModelIndex &parent) |
|
100 | bool CustomTableModel::removeRow(int row, const QModelIndex &parent) | |
96 | { |
|
101 | { | |
97 | return QAbstractTableModel::removeRow(row, parent); |
|
102 | return QAbstractTableModel::removeRow(row, parent); | |
98 | } |
|
103 | } | |
99 |
|
104 | |||
100 | bool CustomTableModel::removeRows(int row, int count, const QModelIndex &parent) |
|
105 | bool CustomTableModel::removeRows(int row, int count, const QModelIndex &parent) | |
101 | { |
|
106 | { | |
102 | beginRemoveRows(parent, row, row + count - 1); |
|
107 | beginRemoveRows(parent, row, row + count - 1); | |
103 | bool removed(false); |
|
108 | bool removed(false); | |
104 | for (int i(row); i < (row + count); i++) { |
|
109 | for (int i(row); i < (row + count); i++) { | |
105 | m_data.removeAt(i); |
|
110 | m_data.removeAt(i); | |
106 | removed = true; |
|
111 | removed = true; | |
107 | } |
|
112 | } | |
108 | endRemoveRows(); |
|
113 | endRemoveRows(); | |
109 | return removed; |
|
114 | return removed; | |
110 | } |
|
115 | } | |
111 |
|
116 | |||
112 | Qt::ItemFlags CustomTableModel::flags ( const QModelIndex & index ) const |
|
117 | Qt::ItemFlags CustomTableModel::flags ( const QModelIndex & index ) const | |
113 | { |
|
118 | { | |
114 | return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; |
|
119 | return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; | |
115 | } |
|
120 | } | |
116 |
|
121 | |||
117 | #include "moc_customtablemodel.cpp" |
|
122 | #include "moc_customtablemodel.cpp" |
@@ -1,52 +1,54 | |||||
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 CUSTOMTABLEMODEL_H |
|
21 | #ifndef CUSTOMTABLEMODEL_H | |
22 | #define CUSTOMTABLEMODEL_H |
|
22 | #define CUSTOMTABLEMODEL_H | |
23 |
|
23 | |||
24 | #include <QAbstractTableModel> |
|
24 | #include <QAbstractTableModel> | |
25 | #include <QHash> |
|
25 | #include <QHash> | |
26 |
|
26 | |||
27 | class CustomTableModel : public QAbstractTableModel |
|
27 | class CustomTableModel : public QAbstractTableModel | |
28 | { |
|
28 | { | |
29 | Q_OBJECT |
|
29 | Q_OBJECT | |
30 |
Q_PROPERTY(int |
|
30 | Q_PROPERTY(int rowCount READ rowCount) | |
|
31 | Q_PROPERTY(int columnCount READ columnCount) | |||
31 |
|
32 | |||
32 | public: |
|
33 | public: | |
33 | explicit CustomTableModel(QObject *parent = 0); |
|
34 | explicit CustomTableModel(QObject *parent = 0); | |
34 |
|
35 | |||
35 | int rowCount ( const QModelIndex & parent = QModelIndex() ) const; |
|
36 | int rowCount ( const QModelIndex & parent = QModelIndex() ) const; | |
36 | int columnCount ( const QModelIndex & parent = QModelIndex() ) const; |
|
37 | int columnCount ( const QModelIndex & parent = QModelIndex() ) const; | |
37 | QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; |
|
38 | QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; | |
38 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |
|
39 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | |
39 | bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); |
|
40 | bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); | |
40 | Qt::ItemFlags flags ( const QModelIndex & index ) const; |
|
41 | Qt::ItemFlags flags ( const QModelIndex & index ) const; | |
41 | void insertColumn(int column, const QModelIndex &parent = QModelIndex()); |
|
42 | void insertColumn(int column, const QModelIndex &parent = QModelIndex()); | |
42 | void insertRow(int row, const QModelIndex &parent = QModelIndex()); |
|
43 | void insertRow(int row, const QModelIndex &parent = QModelIndex()); | |
43 | Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); |
|
44 | Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); | |
44 | Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex()); |
|
45 | Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex()); | |
|
46 | Q_INVOKABLE QVariant at(int row, int column); | |||
45 |
|
47 | |||
46 | private: |
|
48 | private: | |
47 | QList<QVector<QVariant> * > m_data; |
|
49 | QList<QVector<QVariant> * > m_data; | |
48 | int m_columnCount; |
|
50 | int m_columnCount; | |
49 | int m_rowCount; |
|
51 | int m_rowCount; | |
50 | }; |
|
52 | }; | |
51 |
|
53 | |||
52 | #endif // CUSTOMTABLEMODEL_H |
|
54 | #endif // CUSTOMTABLEMODEL_H |
@@ -1,134 +1,105 | |||||
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 | import QmlCustomModel 1.0 |
|
23 | import QmlCustomModel 1.0 | |
24 |
|
24 | |||
25 | Rectangle { |
|
25 | Rectangle { | |
26 | width: parent.width |
|
26 | width: parent.width | |
27 | height: parent.height |
|
27 | height: parent.height | |
28 |
|
28 | |||
29 | ChartView { |
|
29 | ChartView { | |
30 | id: chart |
|
30 | id: chart | |
31 | title: "Custom model example" |
|
31 | title: "Top-5 car brand shares in Finland" | |
32 | anchors.fill: parent |
|
32 | anchors.fill: parent | |
33 | theme: ChartView.ChartThemeLight |
|
33 | theme: ChartView.ChartThemeLight | |
34 | axisX.max: 10 |
|
34 | axisX.max: 10 | |
35 | axisX.min: 0 |
|
35 | axisX.min: 0 | |
36 | axisY.max: 20 |
|
36 | axisY.max: 20 | |
37 | axisY.min: 0 |
|
37 | axisY.min: 0 | |
|
38 | animationOptions: ChartView.SeriesAnimations | |||
|
39 | axisXLabels: [0, "2007", 1, "2008", 2, "2009", 3, "2010", 4, "2011", 5, "2012"] | |||
38 |
|
40 | |||
39 | // For dynamic data we use a custom data model derived from QAbstractiItemModel |
|
41 | // For dynamic data we use a custom data model derived from QAbstractiItemModel | |
40 | CustomModel { |
|
42 | CustomModel { | |
41 | id: customModel |
|
43 | id: customModel | |
42 | CustomModelElement { values: [0, "Manufacturer", 1, 2] } |
|
44 | CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] } | |
43 |
CustomModelElement { values: [1, "Volkswagen", 1 |
|
45 | CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] } | |
44 |
CustomModelElement { values: [2, "Toyota", 1 |
|
46 | CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] } | |
45 |
CustomModelElement { values: [3, "Ford", |
|
47 | CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] } | |
46 |
CustomModelElement { values: [4, "Skoda", |
|
48 | CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] } | |
47 |
CustomModelElement { values: [5, "Volvo", |
|
49 | CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] } | |
|
50 | CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] } | |||
48 | } |
|
51 | } | |
49 |
|
52 | |||
50 |
|
|
53 | BarSeries { | |
51 |
name: " |
|
54 | name: "Others" | |
52 |
|
|
55 | barMargin: 0 | |
|
56 | HBarModelMapper { | |||
53 | model: customModel |
|
57 | model: customModel | |
54 |
|
|
58 | firstBarSetRow: 6 | |
55 |
|
|
59 | lastBarSetRow: 6 | |
56 | first: 2 |
|
60 | first: 2 | |
57 | } |
|
61 | } | |
58 | } |
|
62 | } | |
59 |
|
63 | |||
60 | LineSeries { |
|
64 | LineSeries { | |
61 | name: "Toyota" |
|
65 | id: lineSeries | |
|
66 | name: "Volkswagen" | |||
62 | HXYModelMapper { |
|
67 | HXYModelMapper { | |
|
68 | id: lineSeriesMapper | |||
63 | model: customModel |
|
69 | model: customModel | |
64 | xRow: 0 |
|
70 | xRow: 0 | |
65 |
yRow: |
|
71 | yRow: 1 | |
66 | first: 2 |
|
72 | first: 2 | |
67 | } |
|
73 | } | |
68 | } |
|
74 | } | |
69 |
|
75 | |||
70 | PieSeries { |
|
76 | PieSeries { | |
71 | id: pieSeries |
|
77 | id: pieSeries | |
72 | size: 0.4 |
|
78 | size: 0.4 | |
73 | horizontalPosition: 0.7 |
|
79 | horizontalPosition: 0.7 | |
74 |
verticalPosition: 0. |
|
80 | verticalPosition: 0.4 | |
75 | } |
|
81 | onClicked: { | |
|
82 | // Show the selection by exploding the slice | |||
|
83 | for (var i = 0; i < pieSeries.count; i++) | |||
|
84 | pieSeries.at(i).exploded = false; | |||
|
85 | slice.exploded = true; | |||
76 |
|
86 | |||
77 | // VPieModelMapper { |
|
87 | // Update the line series to show the yearly data for this slice | |
78 | // series: pieSeries |
|
88 | lineSeries.name = slice.label; | |
79 | // model: customModel |
|
89 | for (var j = 0; j < customModel.rowCount; j++) { | |
80 | // labelsColumn: 1 |
|
90 | if (customModel.at(j, 1) == slice.label) { | |
81 | // valuesColumn: 2 |
|
91 | lineSeriesMapper.yRow = j; | |
82 | // first: 1 |
|
|||
83 | // } |
|
|||
84 | HPieModelMapper { |
|
|||
85 | series: pieSeries |
|
|||
86 | model: customModel |
|
|||
87 | labelsRow: 1 |
|
|||
88 | valuesRow: 2 |
|
|||
89 | first: 2 |
|
|||
90 | } |
|
92 | } | |
91 |
|
||||
92 | AreaSeries { |
|
|||
93 | name: "Ford" |
|
|||
94 | upperSeries: LineSeries { |
|
|||
95 | HXYModelMapper { |
|
|||
96 | model: customModel |
|
|||
97 | xRow: 0 |
|
|||
98 | yRow: 3 |
|
|||
99 | first: 2 |
|
|||
100 | } |
|
93 | } | |
101 | } |
|
94 | } | |
102 | } |
|
95 | } | |
103 |
|
96 | |||
104 | GroupedBarSeries { |
|
97 | VPieModelMapper { | |
105 | name: "Skoda and Volvo" |
|
98 | series: pieSeries | |
106 | HBarModelMapper { |
|
|||
107 |
|
|
99 | model: customModel | |
108 | firstBarSetRow: 4 |
|
100 | labelsColumn: 1 | |
109 | lastBarSetRow: 5 |
|
101 | valuesColumn: 2 | |
110 |
|
|
102 | first: 1 | |
111 | } |
|
|||
112 | } |
|
103 | } | |
113 | } |
|
104 | } | |
114 |
|
||||
115 |
|
||||
116 | // TODO: you could also implement appending to your model, for example: |
|
|||
117 | // pieSeries.model.append(["Others", 52.0]); |
|
|||
118 |
|
||||
119 | // TODO: show how to use data from a list model in a chart view |
|
|||
120 | // i.e. copy the data into a custom model |
|
|||
121 | // ListModel { |
|
|||
122 | // id: listModel |
|
|||
123 | // ListElement { |
|
|||
124 | // label: "Volkswagen" |
|
|||
125 | // value: 13.5 |
|
|||
126 | // } |
|
|||
127 | // ListElement { |
|
|||
128 | // label: "Toyota" |
|
|||
129 | // value: 10.9 |
|
|||
130 | // } |
|
|||
131 | // // and so on... |
|
|||
132 | // } |
|
|||
133 |
|
||||
134 | } |
|
105 | } |
@@ -1,150 +1,96 | |||||
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 | #include <qdeclarativelist.h> | |
25 | #include <QVPieModelMapper> |
|
25 | #include <QVPieModelMapper> | |
26 | #include <QHPieModelMapper> |
|
26 | #include <QHPieModelMapper> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | DeclarativePieSlice::DeclarativePieSlice(QObject *parent) : |
|
|||
31 | QPieSlice(parent) |
|
|||
32 | { |
|
|||
33 | } |
|
|||
34 |
|
||||
35 | QColor DeclarativePieSlice::color() |
|
|||
36 | { |
|
|||
37 | return brush().color(); |
|
|||
38 | } |
|
|||
39 |
|
||||
40 | void DeclarativePieSlice::setColor(QColor color) |
|
|||
41 | { |
|
|||
42 | QBrush b = brush(); |
|
|||
43 | b.setColor(color); |
|
|||
44 | setBrush(b); |
|
|||
45 | } |
|
|||
46 |
|
||||
47 | QColor DeclarativePieSlice::borderColor() |
|
|||
48 | { |
|
|||
49 | return pen().color(); |
|
|||
50 | } |
|
|||
51 |
|
||||
52 | void DeclarativePieSlice::setBorderColor(QColor color) |
|
|||
53 | { |
|
|||
54 | QPen p = pen(); |
|
|||
55 | p.setColor(color); |
|
|||
56 | setPen(p); |
|
|||
57 | } |
|
|||
58 |
|
||||
59 | int DeclarativePieSlice::borderWidth() |
|
|||
60 | { |
|
|||
61 | return pen().width(); |
|
|||
62 | } |
|
|||
63 |
|
||||
64 | void DeclarativePieSlice::setBorderWidth(int width) |
|
|||
65 | { |
|
|||
66 | QPen p = pen(); |
|
|||
67 | p.setWidth(width); |
|
|||
68 | setPen(p); |
|
|||
69 | } |
|
|||
70 |
|
||||
71 | QColor DeclarativePieSlice::labelColor() |
|
|||
72 | { |
|
|||
73 | return labelBrush().color(); |
|
|||
74 | } |
|
|||
75 |
|
||||
76 | void DeclarativePieSlice::setLabelColor(QColor color) |
|
|||
77 | { |
|
|||
78 | // TODO: use brush instead for label color |
|
|||
79 | QBrush b = labelBrush(); |
|
|||
80 | b.setColor(color); |
|
|||
81 | setLabelBrush(b); |
|
|||
82 | } |
|
|||
83 |
|
||||
84 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : |
|
30 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : | |
85 | QPieSeries(parent) |
|
31 | QPieSeries(parent) | |
86 | { |
|
32 | { | |
87 | } |
|
33 | } | |
88 |
|
34 | |||
89 | void DeclarativePieSeries::classBegin() |
|
35 | void DeclarativePieSeries::classBegin() | |
90 | { |
|
36 | { | |
91 | } |
|
37 | } | |
92 |
|
38 | |||
93 | void DeclarativePieSeries::componentComplete() |
|
39 | void DeclarativePieSeries::componentComplete() | |
94 | { |
|
40 | { | |
95 | foreach(QObject *child, children()) { |
|
41 | foreach(QObject *child, children()) { | |
96 |
if (qobject_cast< |
|
42 | if (qobject_cast<QPieSlice *>(child)) { | |
97 |
QPieSeries::append(qobject_cast< |
|
43 | QPieSeries::append(qobject_cast<QPieSlice *>(child)); | |
98 | } else if(qobject_cast<QVPieModelMapper *>(child)) { |
|
44 | } else if(qobject_cast<QVPieModelMapper *>(child)) { | |
99 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); |
|
45 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); | |
100 | mapper->setSeries(this); |
|
46 | mapper->setSeries(this); | |
101 | } else if(qobject_cast<QHPieModelMapper *>(child)) { |
|
47 | } else if(qobject_cast<QHPieModelMapper *>(child)) { | |
102 | QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); |
|
48 | QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); | |
103 | mapper->setSeries(this); |
|
49 | mapper->setSeries(this); | |
104 | } |
|
50 | } | |
105 | } |
|
51 | } | |
106 | } |
|
52 | } | |
107 |
|
53 | |||
108 | QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren() |
|
54 | QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren() | |
109 | { |
|
55 | { | |
110 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren); |
|
56 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren); | |
111 | } |
|
57 | } | |
112 |
|
58 | |||
113 | void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
59 | void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
114 | { |
|
60 | { | |
115 | // Empty implementation; the children are parsed in componentComplete instead |
|
61 | // Empty implementation; the children are parsed in componentComplete instead | |
116 | Q_UNUSED(list); |
|
62 | Q_UNUSED(list); | |
117 | Q_UNUSED(element); |
|
63 | Q_UNUSED(element); | |
118 | } |
|
64 | } | |
119 |
|
65 | |||
120 |
|
|
66 | QPieSlice *DeclarativePieSeries::at(int index) | |
121 | { |
|
67 | { | |
122 | QList<QPieSlice*> sliceList = slices(); |
|
68 | QList<QPieSlice*> sliceList = slices(); | |
123 | if (index < sliceList.count()) |
|
69 | if (index < sliceList.count()) | |
124 |
return |
|
70 | return sliceList[index]; | |
125 |
|
71 | |||
126 | return 0; |
|
72 | return 0; | |
127 | } |
|
73 | } | |
128 |
|
74 | |||
129 |
|
|
75 | QPieSlice* DeclarativePieSeries::find(QString label) | |
130 | { |
|
76 | { | |
131 | foreach (QPieSlice *slice, slices()) { |
|
77 | foreach (QPieSlice *slice, slices()) { | |
132 | if (slice->label() == label) |
|
78 | if (slice->label() == label) | |
133 | return qobject_cast<DeclarativePieSlice *>(slice); |
|
79 | return slice; | |
134 | } |
|
80 | } | |
135 | return 0; |
|
81 | return 0; | |
136 | } |
|
82 | } | |
137 |
|
83 | |||
138 |
|
|
84 | QPieSlice* DeclarativePieSeries::append(QString label, qreal value) | |
139 | { |
|
85 | { | |
140 | // TODO: parameter order is wrong, switch it: |
|
86 | // TODO: parameter order is wrong, switch it: | |
141 |
|
|
87 | QPieSlice *slice = new QPieSlice(this); | |
142 | slice->setLabel(label); |
|
88 | slice->setLabel(label); | |
143 | slice->setValue(value); |
|
89 | slice->setValue(value); | |
144 | QPieSeries::append(slice); |
|
90 | QPieSeries::append(slice); | |
145 | return slice; |
|
91 | return slice; | |
146 | } |
|
92 | } | |
147 |
|
93 | |||
148 | #include "moc_declarativepieseries.cpp" |
|
94 | #include "moc_declarativepieseries.cpp" | |
149 |
|
95 | |||
150 | QTCOMMERCIALCHART_END_NAMESPACE |
|
96 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,79 +1,59 | |||||
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> |
|
25 | #include <QPieSlice> | |
26 | #include <QPieSeries> |
|
26 | #include <QPieSeries> | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 | #include <QDeclarativeListProperty> |
|
28 | #include <QDeclarativeListProperty> | |
29 | #include <QAbstractItemModel> |
|
29 | #include <QAbstractItemModel> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QChart; |
|
33 | class QChart; | |
34 |
|
34 | |||
35 | class DeclarativePieSlice: public QPieSlice |
|
|||
36 | { |
|
|||
37 | Q_OBJECT |
|
|||
38 | Q_PROPERTY(QColor color READ color WRITE setColor) |
|
|||
39 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) |
|
|||
40 | Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) |
|
|||
41 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) |
|
|||
42 |
|
||||
43 | public: |
|
|||
44 | explicit DeclarativePieSlice(QObject *parent = 0); |
|
|||
45 | QColor color(); |
|
|||
46 | void setColor(QColor color); |
|
|||
47 | QColor borderColor(); |
|
|||
48 | void setBorderColor(QColor color); |
|
|||
49 | int borderWidth(); |
|
|||
50 | void setBorderWidth(int width); |
|
|||
51 | QColor labelColor(); |
|
|||
52 | void setLabelColor(QColor color); |
|
|||
53 | }; |
|
|||
54 |
|
||||
55 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus |
|
35 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus | |
56 | { |
|
36 | { | |
57 | Q_OBJECT |
|
37 | Q_OBJECT | |
58 | Q_INTERFACES(QDeclarativeParserStatus) |
|
38 | Q_INTERFACES(QDeclarativeParserStatus) | |
59 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
39 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
60 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
40 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
61 |
|
41 | |||
62 | public: |
|
42 | public: | |
63 | explicit DeclarativePieSeries(QObject *parent = 0); |
|
43 | explicit DeclarativePieSeries(QObject *parent = 0); | |
64 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
44 | QDeclarativeListProperty<QObject> seriesChildren(); | |
65 |
Q_INVOKABLE |
|
45 | Q_INVOKABLE QPieSlice *at(int index); | |
66 |
Q_INVOKABLE |
|
46 | Q_INVOKABLE QPieSlice *find(QString label); | |
67 |
Q_INVOKABLE |
|
47 | Q_INVOKABLE QPieSlice *append(QString label, qreal value); | |
68 |
|
48 | |||
69 | public: |
|
49 | public: | |
70 | void classBegin(); |
|
50 | void classBegin(); | |
71 | void componentComplete(); |
|
51 | void componentComplete(); | |
72 |
|
52 | |||
73 | public Q_SLOTS: |
|
53 | public Q_SLOTS: | |
74 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
54 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
75 | }; |
|
55 | }; | |
76 |
|
56 | |||
77 | QTCOMMERCIALCHART_END_NAMESPACE |
|
57 | QTCOMMERCIALCHART_END_NAMESPACE | |
78 |
|
58 | |||
79 | #endif // DECLARATIVEPIESERIES_H |
|
59 | #endif // DECLARATIVEPIESERIES_H |
@@ -1,101 +1,99 | |||||
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 "qaxiscategories.h" |
|
24 | #include "qaxiscategories.h" | |
25 | #include "declarativechart.h" |
|
25 | #include "declarativechart.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 <QVXYModelMapper> |
|
33 | #include <QVXYModelMapper> | |
34 | #include <QHXYModelMapper> |
|
34 | #include <QHXYModelMapper> | |
35 | #include <QHPieModelMapper> |
|
35 | #include <QHPieModelMapper> | |
36 | #include <QVPieModelMapper> |
|
36 | #include <QVPieModelMapper> | |
37 | #include <QHBarModelMapper> |
|
37 | #include <QHBarModelMapper> | |
38 | #include <QVBarModelMapper> |
|
38 | #include <QVBarModelMapper> | |
39 |
|
39 | |||
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
41 |
|
41 | |||
42 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
42 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | public: |
|
45 | public: | |
46 | virtual void registerTypes(const char *uri) |
|
46 | virtual void registerTypes(const char *uri) | |
47 | { |
|
47 | { | |
48 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
48 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
49 |
|
49 | |||
50 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
50 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
51 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); |
|
51 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); | |
52 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
52 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
53 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
53 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
54 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
54 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
55 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
55 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
56 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
56 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
57 | qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries"); |
|
57 | qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries"); | |
58 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
58 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | |
59 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
59 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | |
60 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
60 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
61 |
qmlRegisterType< |
|
61 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
62 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
62 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
63 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
63 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); | |
64 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
64 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); | |
65 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
65 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | |
66 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
66 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | |
67 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
67 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | |
68 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
68 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | |
69 |
|
69 | |||
70 | qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries", |
|
70 | qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries", | |
71 | QLatin1String("Trying to create uncreatable: QScatterSeries.")); |
|
71 | QLatin1String("Trying to create uncreatable: QScatterSeries.")); | |
72 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
72 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |
73 | QLatin1String("Trying to create uncreatable: QPieSeries.")); |
|
73 | QLatin1String("Trying to create uncreatable: QPieSeries.")); | |
74 | qmlRegisterUncreatableType<QPieSlice>(uri, 1, 0, "QPieSlice", |
|
|||
75 | QLatin1String("Trying to create uncreatable: QPieSlice.")); |
|
|||
76 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
74 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
77 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
75 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
78 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
76 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
79 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
77 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
80 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
78 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
81 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
79 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
82 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
80 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", | |
83 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
81 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
84 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
82 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
85 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
83 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
86 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", |
|
84 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", | |
87 | QLatin1String("Trying to create uncreatable: Axis.")); |
|
85 | QLatin1String("Trying to create uncreatable: Axis.")); | |
88 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
86 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
89 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
87 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
90 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
88 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
91 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
89 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
92 | } |
|
90 | } | |
93 | }; |
|
91 | }; | |
94 |
|
92 | |||
95 | #include "plugin.moc" |
|
93 | #include "plugin.moc" | |
96 |
|
94 | |||
97 | QTCOMMERCIALCHART_END_NAMESPACE |
|
95 | QTCOMMERCIALCHART_END_NAMESPACE | |
98 |
|
96 | |||
99 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
97 | QTCOMMERCIALCHART_USE_NAMESPACE | |
100 |
|
98 | |||
101 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
99 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
@@ -1,547 +1,612 | |||||
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 "qpieslice.h" |
|
21 | #include "qpieslice.h" | |
22 | #include "qpieslice_p.h" |
|
22 | #include "qpieslice_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QPieSlice |
|
27 | \class QPieSlice | |
28 | \brief Defines a slice in pie series. |
|
28 | \brief Defines a slice in pie series. | |
29 |
|
29 | |||
30 | This object defines the properties of a single slice in a QPieSeries. |
|
30 | This object defines the properties of a single slice in a QPieSeries. | |
31 |
|
31 | |||
32 | In addition to the obvious value and label properties the user can also control |
|
32 | In addition to the obvious value and label properties the user can also control | |
33 | the visual appearance of a slice. By modifying the visual appearance also means that |
|
33 | the visual appearance of a slice. By modifying the visual appearance also means that | |
34 | the user is overriding the default appearance set by the theme. |
|
34 | the user is overriding the default appearance set by the theme. | |
35 |
|
35 | |||
36 | Note that if the user has customized slices and theme is changed all customizations will be lost. |
|
36 | Note that if the user has customized slices and theme is changed all customizations will be lost. | |
37 |
|
37 | |||
38 | To enable user interaction with the pie some basic signals are provided about clicking and hovering. |
|
38 | To enable user interaction with the pie some basic signals are provided about clicking and hovering. | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \property QPieSlice::label |
|
42 | \property QPieSlice::label | |
43 |
|
43 | |||
44 | Label of the slice. |
|
44 | Label of the slice. | |
45 |
|
45 | |||
46 | \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor |
|
46 | \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \fn void QPieSlice::labelChanged() |
|
50 | \fn void QPieSlice::labelChanged() | |
51 |
|
51 | |||
52 | This signal emitted when the slice label has been changed. |
|
52 | This signal emitted when the slice label has been changed. | |
53 |
|
53 | |||
54 | \sa label |
|
54 | \sa label | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \property QPieSlice::value |
|
58 | \property QPieSlice::value | |
59 |
|
59 | |||
60 | Value of the slice. |
|
60 | Value of the slice. | |
61 |
|
61 | |||
62 | Note that if users sets a negative value it is converted to a positive value. |
|
62 | Note that if users sets a negative value it is converted to a positive value. | |
63 |
|
63 | |||
64 | \sa percentage(), QPieSeries::sum() |
|
64 | \sa percentage(), QPieSeries::sum() | |
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | \fn void QPieSlice::valueChanged() |
|
68 | \fn void QPieSlice::valueChanged() | |
69 |
|
69 | |||
70 | This signal is emitted when the slice value changes. |
|
70 | This signal is emitted when the slice value changes. | |
71 |
|
71 | |||
72 | \sa value |
|
72 | \sa value | |
73 | */ |
|
73 | */ | |
74 |
|
74 | |||
75 | /*! |
|
75 | /*! | |
76 | \property QPieSlice::labelVisible |
|
76 | \property QPieSlice::labelVisible | |
77 |
|
77 | |||
78 | Defienes the visibility of the slice label. |
|
78 | Defienes the visibility of the slice label. | |
79 |
|
79 | |||
80 | Default is not visible. |
|
80 | Default is not visible. | |
81 |
|
81 | |||
82 | \sa label, labelBrush, labelFont, labelArmLengthFactor |
|
82 | \sa label, labelBrush, labelFont, labelArmLengthFactor | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \fn void QPieSlice::labelVisibleChanged() |
|
86 | \fn void QPieSlice::labelVisibleChanged() | |
87 |
|
87 | |||
88 | This signal emitted when visibility of the slice label has changed. |
|
88 | This signal emitted when visibility of the slice label has changed. | |
89 |
|
89 | |||
90 | \sa labelVisible |
|
90 | \sa labelVisible | |
91 | */ |
|
91 | */ | |
92 |
|
92 | |||
93 | /*! |
|
93 | /*! | |
94 | \property QPieSlice::exploded |
|
94 | \property QPieSlice::exploded | |
95 |
|
95 | |||
96 | Defines if the slice is exploded from the pie. |
|
96 | Defines if the slice is exploded from the pie. | |
97 |
|
97 | |||
98 | \sa explodeDistanceFactor |
|
98 | \sa explodeDistanceFactor | |
99 | */ |
|
99 | */ | |
100 |
|
100 | |||
101 | /*! |
|
101 | /*! | |
102 | \fn void QPieSlice::explodedChanged() |
|
102 | \fn void QPieSlice::explodedChanged() | |
103 |
|
103 | |||
104 | This signal is emitted the the slice has been exploded from the pie or is returned back to the pie. |
|
104 | This signal is emitted the the slice has been exploded from the pie or is returned back to the pie. | |
105 |
|
105 | |||
106 | \sa exploded |
|
106 | \sa exploded | |
107 | */ |
|
107 | */ | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | \property QPieSlice::pen |
|
110 | \property QPieSlice::pen | |
111 |
|
111 | |||
112 | Pen used to draw the slice border. |
|
112 | Pen used to draw the slice border. | |
113 | */ |
|
113 | */ | |
114 |
|
114 | |||
115 | /*! |
|
115 | /*! | |
116 | \fn void QPieSlice::penChanged() |
|
116 | \fn void QPieSlice::penChanged() | |
117 |
|
117 | |||
118 | This signal is emitted when the pen of the slice has changed. |
|
118 | This signal is emitted when the pen of the slice has changed. | |
119 |
|
119 | |||
120 | \sa pen |
|
120 | \sa pen | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | /*! |
|
123 | /*! | |
124 | \property QPieSlice::brush |
|
124 | \property QPieSlice::brush | |
125 |
|
125 | |||
126 | Brush used to draw the slice. |
|
126 | Brush used to draw the slice. | |
127 | */ |
|
127 | */ | |
128 |
|
128 | |||
129 | /*! |
|
129 | /*! | |
130 | \fn void QPieSlice::brushChanged() |
|
130 | \fn void QPieSlice::brushChanged() | |
131 |
|
131 | |||
132 | This signal is emitted when the brush of the slice has changed. |
|
132 | This signal is emitted when the brush of the slice has changed. | |
133 |
|
133 | |||
134 | \sa brush |
|
134 | \sa brush | |
135 | */ |
|
135 | */ | |
136 |
|
136 | |||
137 | /*! |
|
137 | /*! | |
138 | \property QPieSlice::labelBrush |
|
138 | \property QPieSlice::labelBrush | |
139 |
|
139 | |||
140 | Pen used to draw label and label arm of the slice. |
|
140 | Pen used to draw label and label arm of the slice. | |
141 |
|
141 | |||
142 | \sa label, labelVisible, labelFont, labelArmLengthFactor |
|
142 | \sa label, labelVisible, labelFont, labelArmLengthFactor | |
143 | */ |
|
143 | */ | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \fn void QPieSlice::labelBrushChanged() |
|
146 | \fn void QPieSlice::labelBrushChanged() | |
147 |
|
147 | |||
148 | This signal is emitted when the label pen of the slice has changed. |
|
148 | This signal is emitted when the label pen of the slice has changed. | |
149 |
|
149 | |||
150 | \sa labelBrush |
|
150 | \sa labelBrush | |
151 | */ |
|
151 | */ | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | \property QPieSlice::labelFont |
|
154 | \property QPieSlice::labelFont | |
155 |
|
155 | |||
156 | Font used for drawing label text. |
|
156 | Font used for drawing label text. | |
157 |
|
157 | |||
158 | \sa label, labelVisible, labelArmLengthFactor |
|
158 | \sa label, labelVisible, labelArmLengthFactor | |
159 | */ |
|
159 | */ | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | \fn void QPieSlice::labelFontChanged() |
|
162 | \fn void QPieSlice::labelFontChanged() | |
163 |
|
163 | |||
164 | This signal is emitted when the label font of the slice has changed. |
|
164 | This signal is emitted when the label font of the slice has changed. | |
165 |
|
165 | |||
166 | \sa labelFont |
|
166 | \sa labelFont | |
167 | */ |
|
167 | */ | |
168 |
|
168 | |||
169 | /*! |
|
169 | /*! | |
170 | \property QPieSlice::labelArmLengthFactor |
|
170 | \property QPieSlice::labelArmLengthFactor | |
171 |
|
171 | |||
172 | Defines the length of the label arm. |
|
172 | Defines the length of the label arm. | |
173 |
|
173 | |||
174 | The factor is relative to pie radius. For example: |
|
174 | The factor is relative to pie radius. For example: | |
175 | 1.0 means the length is the same as the radius. |
|
175 | 1.0 means the length is the same as the radius. | |
176 | 0.5 means the length is half of the radius. |
|
176 | 0.5 means the length is half of the radius. | |
177 |
|
177 | |||
178 | Default value is 0.15 |
|
178 | Default value is 0.15 | |
179 |
|
179 | |||
180 | \sa label, labelVisible, labelBrush, labelFont |
|
180 | \sa label, labelVisible, labelBrush, labelFont | |
181 | */ |
|
181 | */ | |
182 |
|
182 | |||
183 | /*! |
|
183 | /*! | |
184 | \fn void QPieSlice::labelArmLengthFactorChanged() |
|
184 | \fn void QPieSlice::labelArmLengthFactorChanged() | |
185 |
|
185 | |||
186 | This signal is emitted when the label arm factor of the slice has changed. |
|
186 | This signal is emitted when the label arm factor of the slice has changed. | |
187 |
|
187 | |||
188 | \sa labelArmLengthFactor |
|
188 | \sa labelArmLengthFactor | |
189 | */ |
|
189 | */ | |
190 |
|
190 | |||
191 | /*! |
|
191 | /*! | |
192 | \property QPieSlice::explodeDistanceFactor |
|
192 | \property QPieSlice::explodeDistanceFactor | |
193 |
|
193 | |||
194 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. |
|
194 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. | |
195 |
|
195 | |||
196 | The factor is relative to pie radius. For example: |
|
196 | The factor is relative to pie radius. For example: | |
197 | 1.0 means the distance is the same as the radius. |
|
197 | 1.0 means the distance is the same as the radius. | |
198 | 0.5 means the distance is half of the radius. |
|
198 | 0.5 means the distance is half of the radius. | |
199 |
|
199 | |||
200 | Default value is 0.15 |
|
200 | Default value is 0.15 | |
201 |
|
201 | |||
202 | \sa exploded |
|
202 | \sa exploded | |
203 | */ |
|
203 | */ | |
204 |
|
204 | |||
205 | /*! |
|
205 | /*! | |
206 | \fn void QPieSlice::explodeDistanceFactorChanged() |
|
206 | \fn void QPieSlice::explodeDistanceFactorChanged() | |
207 |
|
207 | |||
208 | This signal is emitted when the explode distance factor of the slice has changed. |
|
208 | This signal is emitted when the explode distance factor of the slice has changed. | |
209 |
|
209 | |||
210 | \sa explodeDistanceFactor |
|
210 | \sa explodeDistanceFactor | |
211 | */ |
|
211 | */ | |
212 |
|
212 | |||
213 | /*! |
|
213 | /*! | |
214 | \property QPieSlice::percentage |
|
214 | \property QPieSlice::percentage | |
215 |
|
215 | |||
216 | Percentage of the slice compared to the sum of all slices in the series. |
|
216 | Percentage of the slice compared to the sum of all slices in the series. | |
217 |
|
217 | |||
218 | The actual value ranges from 0.0 to 1.0. |
|
218 | The actual value ranges from 0.0 to 1.0. | |
219 |
|
219 | |||
220 | Updated automatically once the slice is added to the series. |
|
220 | Updated automatically once the slice is added to the series. | |
221 |
|
221 | |||
222 | \sa value, QPieSeries::sum |
|
222 | \sa value, QPieSeries::sum | |
223 | */ |
|
223 | */ | |
224 |
|
224 | |||
225 | /*! |
|
225 | /*! | |
226 | \fn void QPieSlice::percentageChanged() |
|
226 | \fn void QPieSlice::percentageChanged() | |
227 |
|
227 | |||
228 | This signal is emitted when the percentage of the slice has changed. |
|
228 | This signal is emitted when the percentage of the slice has changed. | |
229 |
|
229 | |||
230 | \sa percentage |
|
230 | \sa percentage | |
231 | */ |
|
231 | */ | |
232 |
|
232 | |||
233 | /*! |
|
233 | /*! | |
234 | \property QPieSlice::startAngle |
|
234 | \property QPieSlice::startAngle | |
235 |
|
235 | |||
236 | Defines the starting angle of this slice in the series it belongs to. |
|
236 | Defines the starting angle of this slice in the series it belongs to. | |
237 |
|
237 | |||
238 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
238 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
239 |
|
239 | |||
240 | Updated automatically once the slice is added to the series. |
|
240 | Updated automatically once the slice is added to the series. | |
241 | */ |
|
241 | */ | |
242 |
|
242 | |||
243 | /*! |
|
243 | /*! | |
244 | \fn void QPieSlice::startAngleChanged() |
|
244 | \fn void QPieSlice::startAngleChanged() | |
245 |
|
245 | |||
246 | This signal is emitted when the starting angle f the slice has changed. |
|
246 | This signal is emitted when the starting angle f the slice has changed. | |
247 |
|
247 | |||
248 | \sa startAngle |
|
248 | \sa startAngle | |
249 | */ |
|
249 | */ | |
250 |
|
250 | |||
251 | /*! |
|
251 | /*! | |
252 | \property QPieSlice::angleSpan |
|
252 | \property QPieSlice::angleSpan | |
253 |
|
253 | |||
254 | Span of the slice in degrees. |
|
254 | Span of the slice in degrees. | |
255 |
|
255 | |||
256 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
256 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
257 |
|
257 | |||
258 | Updated automatically once the slice is added to the series. |
|
258 | Updated automatically once the slice is added to the series. | |
259 | */ |
|
259 | */ | |
260 |
|
260 | |||
261 | /*! |
|
261 | /*! | |
262 | \fn void QPieSlice::angleSpanChanged() |
|
262 | \fn void QPieSlice::angleSpanChanged() | |
263 |
|
263 | |||
264 | This signal is emitted when the angle span of the slice has changed. |
|
264 | This signal is emitted when the angle span of the slice has changed. | |
265 |
|
265 | |||
266 | \sa angleSpan |
|
266 | \sa angleSpan | |
267 | */ |
|
267 | */ | |
268 |
|
268 | |||
269 |
|
269 | |||
270 | /*! |
|
270 | /*! | |
271 | \fn void QPieSlice::clicked() |
|
271 | \fn void QPieSlice::clicked() | |
272 |
|
272 | |||
273 | This signal is emitted when user has clicked the slice. |
|
273 | This signal is emitted when user has clicked the slice. | |
274 |
|
274 | |||
275 | \sa QPieSeries::clicked() |
|
275 | \sa QPieSeries::clicked() | |
276 | */ |
|
276 | */ | |
277 |
|
277 | |||
278 | /*! |
|
278 | /*! | |
279 | \fn void QPieSlice::hovered(bool state) |
|
279 | \fn void QPieSlice::hovered(bool state) | |
280 |
|
280 | |||
281 | This signal is emitted when user has hovered over or away from the slice. |
|
281 | This signal is emitted when user has hovered over or away from the slice. | |
282 |
|
282 | |||
283 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
283 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
284 |
|
284 | |||
285 | \sa QPieSeries::hovered() |
|
285 | \sa QPieSeries::hovered() | |
286 | */ |
|
286 | */ | |
287 |
|
287 | |||
288 | /*! |
|
288 | /*! | |
289 | Constructs an empty slice with a \a parent. |
|
289 | Constructs an empty slice with a \a parent. | |
290 |
|
290 | |||
291 | \sa QPieSeries::append(), QPieSeries::insert() |
|
291 | \sa QPieSeries::append(), QPieSeries::insert() | |
292 | */ |
|
292 | */ | |
293 | QPieSlice::QPieSlice(QObject *parent) |
|
293 | QPieSlice::QPieSlice(QObject *parent) | |
294 | :QObject(parent), |
|
294 | :QObject(parent), | |
295 | d_ptr(new QPieSlicePrivate(this)) |
|
295 | d_ptr(new QPieSlicePrivate(this)) | |
296 | { |
|
296 | { | |
297 |
|
297 | |||
298 | } |
|
298 | } | |
299 |
|
299 | |||
300 | /*! |
|
300 | /*! | |
301 | Constructs an empty slice with given \a value, \a label and a \a parent. |
|
301 | Constructs an empty slice with given \a value, \a label and a \a parent. | |
302 | \sa QPieSeries::append(), QPieSeries::insert() |
|
302 | \sa QPieSeries::append(), QPieSeries::insert() | |
303 | */ |
|
303 | */ | |
304 | QPieSlice::QPieSlice(QString label, qreal value, QObject *parent) |
|
304 | QPieSlice::QPieSlice(QString label, qreal value, QObject *parent) | |
305 | :QObject(parent), |
|
305 | :QObject(parent), | |
306 | d_ptr(new QPieSlicePrivate(this)) |
|
306 | d_ptr(new QPieSlicePrivate(this)) | |
307 | { |
|
307 | { | |
308 | setValue(value); |
|
308 | setValue(value); | |
309 | setLabel(label); |
|
309 | setLabel(label); | |
310 | } |
|
310 | } | |
311 |
|
311 | |||
312 | /*! |
|
312 | /*! | |
313 | Destroys the slice. |
|
313 | Destroys the slice. | |
314 | User should not delete the slice if it has been added to the series. |
|
314 | User should not delete the slice if it has been added to the series. | |
315 | */ |
|
315 | */ | |
316 | QPieSlice::~QPieSlice() |
|
316 | QPieSlice::~QPieSlice() | |
317 | { |
|
317 | { | |
318 |
|
318 | |||
319 | } |
|
319 | } | |
320 |
|
320 | |||
321 | void QPieSlice::setLabel(QString label) |
|
321 | void QPieSlice::setLabel(QString label) | |
322 | { |
|
322 | { | |
323 | if (d_ptr->m_data.m_labelText != label) { |
|
323 | if (d_ptr->m_data.m_labelText != label) { | |
324 | d_ptr->m_data.m_labelText = label; |
|
324 | d_ptr->m_data.m_labelText = label; | |
325 | emit labelChanged(); |
|
325 | emit labelChanged(); | |
326 | } |
|
326 | } | |
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 | QString QPieSlice::label() const |
|
329 | QString QPieSlice::label() const | |
330 | { |
|
330 | { | |
331 | return d_ptr->m_data.m_labelText; |
|
331 | return d_ptr->m_data.m_labelText; | |
332 | } |
|
332 | } | |
333 |
|
333 | |||
334 | void QPieSlice::setValue(qreal value) |
|
334 | void QPieSlice::setValue(qreal value) | |
335 | { |
|
335 | { | |
336 | value = qAbs(value); // negative values not allowed |
|
336 | value = qAbs(value); // negative values not allowed | |
337 | if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) { |
|
337 | if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) { | |
338 | d_ptr->m_data.m_value = value; |
|
338 | d_ptr->m_data.m_value = value; | |
339 | emit valueChanged(); |
|
339 | emit valueChanged(); | |
340 | } |
|
340 | } | |
341 | } |
|
341 | } | |
342 |
|
342 | |||
343 | qreal QPieSlice::value() const |
|
343 | qreal QPieSlice::value() const | |
344 | { |
|
344 | { | |
345 | return d_ptr->m_data.m_value; |
|
345 | return d_ptr->m_data.m_value; | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | void QPieSlice::setLabelVisible(bool visible) |
|
348 | void QPieSlice::setLabelVisible(bool visible) | |
349 | { |
|
349 | { | |
350 | if (d_ptr->m_data.m_isLabelVisible != visible) { |
|
350 | if (d_ptr->m_data.m_isLabelVisible != visible) { | |
351 | d_ptr->m_data.m_isLabelVisible = visible; |
|
351 | d_ptr->m_data.m_isLabelVisible = visible; | |
352 | emit labelVisibleChanged(); |
|
352 | emit labelVisibleChanged(); | |
353 | } |
|
353 | } | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | bool QPieSlice::isLabelVisible() const |
|
356 | bool QPieSlice::isLabelVisible() const | |
357 | { |
|
357 | { | |
358 | return d_ptr->m_data.m_isLabelVisible; |
|
358 | return d_ptr->m_data.m_isLabelVisible; | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | void QPieSlice::setExploded(bool exploded) |
|
361 | void QPieSlice::setExploded(bool exploded) | |
362 | { |
|
362 | { | |
363 | if (d_ptr->m_data.m_isExploded != exploded) { |
|
363 | if (d_ptr->m_data.m_isExploded != exploded) { | |
364 | d_ptr->m_data.m_isExploded = exploded; |
|
364 | d_ptr->m_data.m_isExploded = exploded; | |
365 | emit explodedChanged(); |
|
365 | emit explodedChanged(); | |
366 | } |
|
366 | } | |
367 | } |
|
367 | } | |
368 |
|
368 | |||
369 | bool QPieSlice::isExploded() const |
|
369 | bool QPieSlice::isExploded() const | |
370 | { |
|
370 | { | |
371 | return d_ptr->m_data.m_isExploded; |
|
371 | return d_ptr->m_data.m_isExploded; | |
372 | } |
|
372 | } | |
373 |
|
373 | |||
374 | void QPieSlice::setPen(const QPen &pen) |
|
374 | void QPieSlice::setPen(const QPen &pen) | |
375 | { |
|
375 | { | |
376 | d_ptr->setPen(pen, false); |
|
376 | d_ptr->setPen(pen, false); | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | QPen QPieSlice::pen() const |
|
379 | QPen QPieSlice::pen() const | |
380 | { |
|
380 | { | |
381 | return d_ptr->m_data.m_slicePen; |
|
381 | return d_ptr->m_data.m_slicePen; | |
382 | } |
|
382 | } | |
383 |
|
383 | |||
384 | void QPieSlice::setBrush(const QBrush &brush) |
|
384 | void QPieSlice::setBrush(const QBrush &brush) | |
385 | { |
|
385 | { | |
386 | d_ptr->setBrush(brush, false); |
|
386 | d_ptr->setBrush(brush, false); | |
387 | } |
|
387 | } | |
388 |
|
388 | |||
389 | QBrush QPieSlice::brush() const |
|
389 | QBrush QPieSlice::brush() const | |
390 | { |
|
390 | { | |
391 | return d_ptr->m_data.m_sliceBrush; |
|
391 | return d_ptr->m_data.m_sliceBrush; | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
394 | void QPieSlice::setLabelBrush(const QBrush &brush) |
|
394 | void QPieSlice::setLabelBrush(const QBrush &brush) | |
395 | { |
|
395 | { | |
396 | d_ptr->setLabelBrush(brush, false); |
|
396 | d_ptr->setLabelBrush(brush, false); | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | QBrush QPieSlice::labelBrush() const |
|
399 | QBrush QPieSlice::labelBrush() const | |
400 | { |
|
400 | { | |
401 | return d_ptr->m_data.m_labelBrush; |
|
401 | return d_ptr->m_data.m_labelBrush; | |
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | void QPieSlice::setLabelFont(const QFont &font) |
|
404 | void QPieSlice::setLabelFont(const QFont &font) | |
405 | { |
|
405 | { | |
406 | d_ptr->setLabelFont(font, false); |
|
406 | d_ptr->setLabelFont(font, false); | |
407 | } |
|
407 | } | |
408 |
|
408 | |||
409 | QFont QPieSlice::labelFont() const |
|
409 | QFont QPieSlice::labelFont() const | |
410 | { |
|
410 | { | |
411 | return d_ptr->m_data.m_labelFont; |
|
411 | return d_ptr->m_data.m_labelFont; | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 | void QPieSlice::setLabelArmLengthFactor(qreal factor) |
|
414 | void QPieSlice::setLabelArmLengthFactor(qreal factor) | |
415 | { |
|
415 | { | |
416 | if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) { |
|
416 | if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) { | |
417 | d_ptr->m_data.m_labelArmLengthFactor = factor; |
|
417 | d_ptr->m_data.m_labelArmLengthFactor = factor; | |
418 | emit labelArmLengthFactorChanged(); |
|
418 | emit labelArmLengthFactorChanged(); | |
419 | } |
|
419 | } | |
420 | } |
|
420 | } | |
421 |
|
421 | |||
422 | qreal QPieSlice::labelArmLengthFactor() const |
|
422 | qreal QPieSlice::labelArmLengthFactor() const | |
423 | { |
|
423 | { | |
424 | return d_ptr->m_data.m_labelArmLengthFactor; |
|
424 | return d_ptr->m_data.m_labelArmLengthFactor; | |
425 | } |
|
425 | } | |
426 |
|
426 | |||
427 | void QPieSlice::setExplodeDistanceFactor(qreal factor) |
|
427 | void QPieSlice::setExplodeDistanceFactor(qreal factor) | |
428 | { |
|
428 | { | |
429 | if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) { |
|
429 | if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) { | |
430 | d_ptr->m_data.m_explodeDistanceFactor = factor; |
|
430 | d_ptr->m_data.m_explodeDistanceFactor = factor; | |
431 | emit explodeDistanceFactorChanged(); |
|
431 | emit explodeDistanceFactorChanged(); | |
432 | } |
|
432 | } | |
433 | } |
|
433 | } | |
434 |
|
434 | |||
435 | qreal QPieSlice::explodeDistanceFactor() const |
|
435 | qreal QPieSlice::explodeDistanceFactor() const | |
436 | { |
|
436 | { | |
437 | return d_ptr->m_data.m_explodeDistanceFactor; |
|
437 | return d_ptr->m_data.m_explodeDistanceFactor; | |
438 | } |
|
438 | } | |
439 |
|
439 | |||
440 | qreal QPieSlice::percentage() const |
|
440 | qreal QPieSlice::percentage() const | |
441 | { |
|
441 | { | |
442 | return d_ptr->m_data.m_percentage; |
|
442 | return d_ptr->m_data.m_percentage; | |
443 | } |
|
443 | } | |
444 |
|
444 | |||
445 | qreal QPieSlice::startAngle() const |
|
445 | qreal QPieSlice::startAngle() const | |
446 | { |
|
446 | { | |
447 | return d_ptr->m_data.m_startAngle; |
|
447 | return d_ptr->m_data.m_startAngle; | |
448 | } |
|
448 | } | |
449 |
|
449 | |||
450 | qreal QPieSlice::angleSpan() const |
|
450 | qreal QPieSlice::angleSpan() const | |
451 | { |
|
451 | { | |
452 | return d_ptr->m_data.m_angleSpan; |
|
452 | return d_ptr->m_data.m_angleSpan; | |
453 | } |
|
453 | } | |
454 |
|
454 | |||
|
455 | QColor QPieSlice::color() | |||
|
456 | { | |||
|
457 | return brush().color(); | |||
|
458 | } | |||
|
459 | ||||
|
460 | void QPieSlice::setColor(QColor color) | |||
|
461 | { | |||
|
462 | QBrush b = brush(); | |||
|
463 | if (color != b.color()) { | |||
|
464 | b.setColor(color); | |||
|
465 | setBrush(b); | |||
|
466 | } | |||
|
467 | } | |||
|
468 | ||||
|
469 | QColor QPieSlice::borderColor() | |||
|
470 | { | |||
|
471 | return pen().color(); | |||
|
472 | } | |||
|
473 | ||||
|
474 | void QPieSlice::setBorderColor(QColor color) | |||
|
475 | { | |||
|
476 | QPen p = pen(); | |||
|
477 | if (color != p.color()) { | |||
|
478 | p.setColor(color); | |||
|
479 | setPen(p); | |||
|
480 | emit borderColorChanged(); | |||
|
481 | } | |||
|
482 | } | |||
|
483 | ||||
|
484 | int QPieSlice::borderWidth() | |||
|
485 | { | |||
|
486 | return pen().width(); | |||
|
487 | } | |||
|
488 | ||||
|
489 | void QPieSlice::setBorderWidth(int width) | |||
|
490 | { | |||
|
491 | QPen p = pen(); | |||
|
492 | if (width != p.width()) { | |||
|
493 | p.setWidth(width); | |||
|
494 | setPen(p); | |||
|
495 | } | |||
|
496 | } | |||
|
497 | ||||
|
498 | QColor QPieSlice::labelColor() | |||
|
499 | { | |||
|
500 | return labelBrush().color(); | |||
|
501 | } | |||
|
502 | ||||
|
503 | void QPieSlice::setLabelColor(QColor color) | |||
|
504 | { | |||
|
505 | QBrush b = labelBrush(); | |||
|
506 | if (color != b.color()) { | |||
|
507 | b.setColor(color); | |||
|
508 | setLabelBrush(b); | |||
|
509 | } | |||
|
510 | } | |||
|
511 | ||||
455 | /*! |
|
512 | /*! | |
456 | Returns the series that this slice belongs to. |
|
513 | Returns the series that this slice belongs to. | |
457 |
|
514 | |||
458 | \sa QPieSeries::append() |
|
515 | \sa QPieSeries::append() | |
459 | */ |
|
516 | */ | |
460 | QPieSeries *QPieSlice::series() const |
|
517 | QPieSeries *QPieSlice::series() const | |
461 | { |
|
518 | { | |
462 | return d_ptr->m_series; |
|
519 | return d_ptr->m_series; | |
463 | } |
|
520 | } | |
464 |
|
521 | |||
465 | QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent) |
|
522 | QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent) | |
466 | :QObject(parent), |
|
523 | :QObject(parent), | |
467 | q_ptr(parent), |
|
524 | q_ptr(parent), | |
468 | m_series(0) |
|
525 | m_series(0) | |
469 | { |
|
526 | { | |
470 |
|
527 | |||
471 | } |
|
528 | } | |
472 |
|
529 | |||
473 | QPieSlicePrivate::~QPieSlicePrivate() |
|
530 | QPieSlicePrivate::~QPieSlicePrivate() | |
474 | { |
|
531 | { | |
475 |
|
532 | |||
476 | } |
|
533 | } | |
477 |
|
534 | |||
478 | QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice) |
|
535 | QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice) | |
479 | { |
|
536 | { | |
480 | return slice->d_func(); |
|
537 | return slice->d_func(); | |
481 | } |
|
538 | } | |
482 |
|
539 | |||
483 | void QPieSlicePrivate::setPen(const QPen &pen, bool themed) |
|
540 | void QPieSlicePrivate::setPen(const QPen &pen, bool themed) | |
484 | { |
|
541 | { | |
485 | if (m_data.m_slicePen != pen) { |
|
542 | if (m_data.m_slicePen != pen) { | |
|
543 | if (m_data.m_slicePen.color() != pen.color()) | |||
|
544 | emit q_ptr->borderColorChanged(); | |||
|
545 | if (m_data.m_slicePen.width() != pen.width()) | |||
|
546 | emit q_ptr->borderWidthChanged(); | |||
486 | m_data.m_slicePen = pen; |
|
547 | m_data.m_slicePen = pen; | |
487 | m_data.m_slicePen.setThemed(themed); |
|
548 | m_data.m_slicePen.setThemed(themed); | |
488 | emit q_ptr->penChanged(); |
|
549 | emit q_ptr->penChanged(); | |
489 | } |
|
550 | } | |
490 | } |
|
551 | } | |
491 |
|
552 | |||
492 | void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed) |
|
553 | void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed) | |
493 | { |
|
554 | { | |
494 | if (m_data.m_sliceBrush != brush) { |
|
555 | if (m_data.m_sliceBrush != brush) { | |
|
556 | if (m_data.m_sliceBrush.color() != brush.color()) | |||
|
557 | emit q_ptr->colorChanged(); | |||
495 | m_data.m_sliceBrush = brush; |
|
558 | m_data.m_sliceBrush = brush; | |
496 | m_data.m_sliceBrush.setThemed(themed); |
|
559 | m_data.m_sliceBrush.setThemed(themed); | |
497 | emit q_ptr->brushChanged(); |
|
560 | emit q_ptr->brushChanged(); | |
498 | } |
|
561 | } | |
499 | } |
|
562 | } | |
500 |
|
563 | |||
501 | void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed) |
|
564 | void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed) | |
502 | { |
|
565 | { | |
503 | if (m_data.m_labelBrush != brush) { |
|
566 | if (m_data.m_labelBrush != brush) { | |
|
567 | if (m_data.m_labelBrush.color() != brush.color()) | |||
|
568 | emit q_ptr->labelColorChanged(); | |||
504 | m_data.m_labelBrush = brush; |
|
569 | m_data.m_labelBrush = brush; | |
505 | m_data.m_labelBrush.setThemed(themed); |
|
570 | m_data.m_labelBrush.setThemed(themed); | |
506 | emit q_ptr->labelBrushChanged(); |
|
571 | emit q_ptr->labelBrushChanged(); | |
507 | } |
|
572 | } | |
508 | } |
|
573 | } | |
509 |
|
574 | |||
510 | void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed) |
|
575 | void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed) | |
511 | { |
|
576 | { | |
512 | if (m_data.m_labelFont != font) { |
|
577 | if (m_data.m_labelFont != font) { | |
513 | m_data.m_labelFont = font; |
|
578 | m_data.m_labelFont = font; | |
514 | m_data.m_labelFont.setThemed(themed); |
|
579 | m_data.m_labelFont.setThemed(themed); | |
515 | emit q_ptr->labelFontChanged(); |
|
580 | emit q_ptr->labelFontChanged(); | |
516 | } |
|
581 | } | |
517 | } |
|
582 | } | |
518 |
|
583 | |||
519 | void QPieSlicePrivate::setPercentage(qreal percentage) |
|
584 | void QPieSlicePrivate::setPercentage(qreal percentage) | |
520 | { |
|
585 | { | |
521 | if (!qFuzzyIsNull(m_data.m_percentage - percentage)) { |
|
586 | if (!qFuzzyIsNull(m_data.m_percentage - percentage)) { | |
522 | m_data.m_percentage = percentage; |
|
587 | m_data.m_percentage = percentage; | |
523 | emit q_ptr->percentageChanged(); |
|
588 | emit q_ptr->percentageChanged(); | |
524 | } |
|
589 | } | |
525 | } |
|
590 | } | |
526 |
|
591 | |||
527 | void QPieSlicePrivate::setStartAngle(qreal angle) |
|
592 | void QPieSlicePrivate::setStartAngle(qreal angle) | |
528 | { |
|
593 | { | |
529 | if (!qFuzzyIsNull(m_data.m_startAngle - angle)) { |
|
594 | if (!qFuzzyIsNull(m_data.m_startAngle - angle)) { | |
530 | m_data.m_startAngle = angle; |
|
595 | m_data.m_startAngle = angle; | |
531 | emit q_ptr->startAngleChanged(); |
|
596 | emit q_ptr->startAngleChanged(); | |
532 | } |
|
597 | } | |
533 | } |
|
598 | } | |
534 |
|
599 | |||
535 | void QPieSlicePrivate::setAngleSpan(qreal span) |
|
600 | void QPieSlicePrivate::setAngleSpan(qreal span) | |
536 | { |
|
601 | { | |
537 | if (!qFuzzyIsNull(m_data.m_angleSpan - span)) { |
|
602 | if (!qFuzzyIsNull(m_data.m_angleSpan - span)) { | |
538 | m_data.m_angleSpan = span; |
|
603 | m_data.m_angleSpan = span; | |
539 | emit q_ptr->angleSpanChanged(); |
|
604 | emit q_ptr->angleSpanChanged(); | |
540 | } |
|
605 | } | |
541 | } |
|
606 | } | |
542 |
|
607 | |||
543 | QTCOMMERCIALCHART_END_NAMESPACE |
|
608 | QTCOMMERCIALCHART_END_NAMESPACE | |
544 |
|
609 | |||
545 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
610 | QTCOMMERCIALCHART_USE_NAMESPACE | |
546 | #include "moc_qpieslice.cpp" |
|
611 | #include "moc_qpieslice.cpp" | |
547 | #include "moc_qpieslice_p.cpp" |
|
612 | #include "moc_qpieslice_p.cpp" |
@@ -1,117 +1,134 | |||||
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 QPIESLICE_H |
|
21 | #ifndef QPIESLICE_H | |
22 | #define QPIESLICE_H |
|
22 | #define QPIESLICE_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QObject> |
|
25 | #include <QObject> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 | #include <QFont> |
|
28 | #include <QFont> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 | class QPieSlicePrivate; |
|
31 | class QPieSlicePrivate; | |
32 | class QPieSeries; |
|
32 | class QPieSeries; | |
33 |
|
33 | |||
34 | class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject |
|
34 | class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject | |
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
37 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
38 | Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) |
|
38 | Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) | |
39 | Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged) |
|
39 | Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged) | |
40 | Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged) |
|
40 | Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged) | |
41 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
41 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
42 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
42 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
43 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
|
43 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) | |
44 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) |
|
44 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) | |
45 | Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor) |
|
45 | Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor) | |
46 | Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor) |
|
46 | Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor) | |
47 | Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged) |
|
47 | Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged) | |
48 | Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged) |
|
48 | Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged) | |
49 | Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged) |
|
49 | Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged) | |
|
50 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |||
|
51 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |||
|
52 | Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) | |||
|
53 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) | |||
50 |
|
54 | |||
51 | public: |
|
55 | public: | |
52 | explicit QPieSlice(QObject *parent = 0); |
|
56 | explicit QPieSlice(QObject *parent = 0); | |
53 | QPieSlice(QString label, qreal value, QObject *parent = 0); |
|
57 | QPieSlice(QString label, qreal value, QObject *parent = 0); | |
54 | virtual ~QPieSlice(); |
|
58 | virtual ~QPieSlice(); | |
55 |
|
59 | |||
56 | void setLabel(QString label); |
|
60 | void setLabel(QString label); | |
57 | QString label() const; |
|
61 | QString label() const; | |
58 |
|
62 | |||
59 | void setValue(qreal value); |
|
63 | void setValue(qreal value); | |
60 | qreal value() const; |
|
64 | qreal value() const; | |
61 |
|
65 | |||
62 | void setLabelVisible(bool visible = true); |
|
66 | void setLabelVisible(bool visible = true); | |
63 | bool isLabelVisible() const; |
|
67 | bool isLabelVisible() const; | |
64 |
|
68 | |||
65 | void setExploded(bool exploded = true); |
|
69 | void setExploded(bool exploded = true); | |
66 | bool isExploded() const; |
|
70 | bool isExploded() const; | |
67 |
|
71 | |||
68 | void setPen(const QPen &pen); |
|
72 | void setPen(const QPen &pen); | |
69 | QPen pen() const; |
|
73 | QPen pen() const; | |
70 |
|
74 | |||
71 | void setBrush(const QBrush &brush); |
|
75 | void setBrush(const QBrush &brush); | |
72 | QBrush brush() const; |
|
76 | QBrush brush() const; | |
73 |
|
77 | |||
74 | void setLabelBrush(const QBrush &brush); |
|
78 | void setLabelBrush(const QBrush &brush); | |
75 | QBrush labelBrush() const; |
|
79 | QBrush labelBrush() const; | |
76 |
|
80 | |||
77 | void setLabelFont(const QFont &font); |
|
81 | void setLabelFont(const QFont &font); | |
78 | QFont labelFont() const; |
|
82 | QFont labelFont() const; | |
79 |
|
83 | |||
80 | void setLabelArmLengthFactor(qreal factor); |
|
84 | void setLabelArmLengthFactor(qreal factor); | |
81 | qreal labelArmLengthFactor() const; |
|
85 | qreal labelArmLengthFactor() const; | |
82 |
|
86 | |||
83 | void setExplodeDistanceFactor(qreal factor); |
|
87 | void setExplodeDistanceFactor(qreal factor); | |
84 | qreal explodeDistanceFactor() const; |
|
88 | qreal explodeDistanceFactor() const; | |
85 |
|
89 | |||
86 | qreal percentage() const; |
|
90 | qreal percentage() const; | |
87 | qreal startAngle() const; |
|
91 | qreal startAngle() const; | |
88 | qreal angleSpan() const; |
|
92 | qreal angleSpan() const; | |
89 |
|
93 | |||
|
94 | QColor color(); | |||
|
95 | void setColor(QColor color); | |||
|
96 | QColor borderColor(); | |||
|
97 | void setBorderColor(QColor color); | |||
|
98 | int borderWidth(); | |||
|
99 | void setBorderWidth(int width); | |||
|
100 | QColor labelColor(); | |||
|
101 | void setLabelColor(QColor color); | |||
|
102 | ||||
90 | QPieSeries *series() const; |
|
103 | QPieSeries *series() const; | |
91 |
|
104 | |||
92 | Q_SIGNALS: |
|
105 | Q_SIGNALS: | |
93 | void labelChanged(); |
|
106 | void labelChanged(); | |
94 | void valueChanged(); |
|
107 | void valueChanged(); | |
95 | void labelVisibleChanged(); |
|
108 | void labelVisibleChanged(); | |
96 | void explodedChanged(); |
|
109 | void explodedChanged(); | |
97 | void penChanged(); |
|
110 | void penChanged(); | |
98 | void brushChanged(); |
|
111 | void brushChanged(); | |
99 | void labelBrushChanged(); |
|
112 | void labelBrushChanged(); | |
100 | void labelFontChanged(); |
|
113 | void labelFontChanged(); | |
101 | void labelArmLengthFactorChanged(); |
|
114 | void labelArmLengthFactorChanged(); | |
102 | void explodeDistanceFactorChanged(); |
|
115 | void explodeDistanceFactorChanged(); | |
103 | void percentageChanged(); |
|
116 | void percentageChanged(); | |
104 | void startAngleChanged(); |
|
117 | void startAngleChanged(); | |
105 | void angleSpanChanged(); |
|
118 | void angleSpanChanged(); | |
|
119 | void colorChanged(); | |||
|
120 | void borderColorChanged(); | |||
|
121 | void borderWidthChanged(); | |||
|
122 | void labelColorChanged(); | |||
106 | void clicked(); |
|
123 | void clicked(); | |
107 | void hovered(bool state); |
|
124 | void hovered(bool state); | |
108 |
|
125 | |||
109 | private: |
|
126 | private: | |
110 | QPieSlicePrivate * const d_ptr; |
|
127 | QPieSlicePrivate * const d_ptr; | |
111 | Q_DECLARE_PRIVATE(QPieSlice) |
|
128 | Q_DECLARE_PRIVATE(QPieSlice) | |
112 | Q_DISABLE_COPY(QPieSlice) |
|
129 | Q_DISABLE_COPY(QPieSlice) | |
113 | }; |
|
130 | }; | |
114 |
|
131 | |||
115 | QTCOMMERCIALCHART_END_NAMESPACE |
|
132 | QTCOMMERCIALCHART_END_NAMESPACE | |
116 |
|
133 | |||
117 | #endif // QPIESLICE_H |
|
134 | #endif // QPIESLICE_H |
General Comments 0
You need to be logged in to leave comments.
Login now