@@ -48,6 +48,42 void DeclarativeBarSet::setValues(QVariantList values) | |||||
48 | } |
|
48 | } | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
|
51 | QColor DeclarativeBarSet::color() | |||
|
52 | { | |||
|
53 | return brush().color(); | |||
|
54 | } | |||
|
55 | ||||
|
56 | void DeclarativeBarSet::setColor(QColor color) | |||
|
57 | { | |||
|
58 | QBrush b = brush(); | |||
|
59 | b.setColor(color); | |||
|
60 | setBrush(b); | |||
|
61 | } | |||
|
62 | ||||
|
63 | QColor DeclarativeBarSet::borderColor() | |||
|
64 | { | |||
|
65 | return pen().color(); | |||
|
66 | } | |||
|
67 | ||||
|
68 | void DeclarativeBarSet::setBorderColor(QColor color) | |||
|
69 | { | |||
|
70 | QPen p = pen(); | |||
|
71 | p.setColor(color); | |||
|
72 | setPen(p); | |||
|
73 | } | |||
|
74 | ||||
|
75 | QColor DeclarativeBarSet::labelColor() | |||
|
76 | { | |||
|
77 | return labelBrush().color(); | |||
|
78 | } | |||
|
79 | ||||
|
80 | void DeclarativeBarSet::setLabelColor(QColor color) | |||
|
81 | { | |||
|
82 | QBrush b = labelBrush(); | |||
|
83 | b.setColor(color); | |||
|
84 | setLabelBrush(b); | |||
|
85 | } | |||
|
86 | ||||
51 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
87 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : | |
52 | QBarSeries(parent) |
|
88 | QBarSeries(parent) | |
53 | { |
|
89 | { | |
@@ -60,8 +96,8 void DeclarativeBarSeries::classBegin() | |||||
60 | void DeclarativeBarSeries::componentComplete() |
|
96 | void DeclarativeBarSeries::componentComplete() | |
61 | { |
|
97 | { | |
62 | foreach(QObject *child, children()) { |
|
98 | foreach(QObject *child, children()) { | |
63 |
if (qobject_cast< |
|
99 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
64 |
QBarSeries::append(qobject_cast< |
|
100 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
65 | } |
|
101 | } | |
66 | } |
|
102 | } | |
67 | } |
|
103 | } | |
@@ -81,6 +117,15 QStringList DeclarativeBarSeries::barCategories() | |||||
81 | return categories(); |
|
117 | return categories(); | |
82 | } |
|
118 | } | |
83 |
|
119 | |||
|
120 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | |||
|
121 | { | |||
|
122 | QList<QBarSet*> setList = barSets(); | |||
|
123 | if (index < setList.count()) | |||
|
124 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |||
|
125 | ||||
|
126 | return 0; | |||
|
127 | } | |||
|
128 | ||||
84 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : |
|
129 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : | |
85 | QGroupedBarSeries(parent) |
|
130 | QGroupedBarSeries(parent) | |
86 | { |
|
131 | { | |
@@ -93,8 +138,8 void DeclarativeGroupedBarSeries::classBegin() | |||||
93 | void DeclarativeGroupedBarSeries::componentComplete() |
|
138 | void DeclarativeGroupedBarSeries::componentComplete() | |
94 | { |
|
139 | { | |
95 | foreach(QObject *child, children()) { |
|
140 | foreach(QObject *child, children()) { | |
96 |
if (qobject_cast< |
|
141 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
97 |
QBarSeries::append(qobject_cast< |
|
142 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
98 | } |
|
143 | } | |
99 | } |
|
144 | } | |
100 | } |
|
145 | } | |
@@ -114,6 +159,15 QStringList DeclarativeGroupedBarSeries::barCategories() | |||||
114 | return categories(); |
|
159 | return categories(); | |
115 | } |
|
160 | } | |
116 |
|
161 | |||
|
162 | DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) | |||
|
163 | { | |||
|
164 | QList<QBarSet*> setList = barSets(); | |||
|
165 | if (index < setList.count()) | |||
|
166 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |||
|
167 | ||||
|
168 | return 0; | |||
|
169 | } | |||
|
170 | ||||
117 | #include "moc_declarativebarseries.cpp" |
|
171 | #include "moc_declarativebarseries.cpp" | |
118 |
|
172 | |||
119 | QTCOMMERCIALCHART_END_NAMESPACE |
|
173 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -35,12 +35,20 class DeclarativeBarSet : public QBarSet | |||||
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 | Q_PROPERTY(QVariantList values READ values WRITE setValues) |
|
37 | Q_PROPERTY(QVariantList values READ values WRITE setValues) | |
38 |
Q_PROPERTY(Q |
|
38 | Q_PROPERTY(QColor color READ color WRITE setColor) | |
|
39 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) | |||
|
40 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) | |||
39 |
|
41 | |||
40 | public: |
|
42 | public: | |
41 | explicit DeclarativeBarSet(QObject *parent = 0); |
|
43 | explicit DeclarativeBarSet(QObject *parent = 0); | |
42 | QVariantList values(); |
|
44 | QVariantList values(); | |
43 | void setValues(QVariantList values); |
|
45 | void setValues(QVariantList values); | |
|
46 | QColor color(); | |||
|
47 | void setColor(QColor color); | |||
|
48 | QColor borderColor(); | |||
|
49 | void setBorderColor(QColor color); | |||
|
50 | QColor labelColor(); | |||
|
51 | void setLabelColor(QColor color); | |||
44 |
|
52 | |||
45 | public: // From QBarSet |
|
53 | public: // From QBarSet | |
46 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } |
|
54 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } | |
@@ -62,6 +70,8 public: | |||||
62 | void setBarCategories(QStringList categories); |
|
70 | void setBarCategories(QStringList categories); | |
63 | QStringList barCategories(); |
|
71 | QStringList barCategories(); | |
64 |
|
72 | |||
|
73 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |||
|
74 | ||||
65 | public: // from QDeclarativeParserStatus |
|
75 | public: // from QDeclarativeParserStatus | |
66 | void classBegin(); |
|
76 | void classBegin(); | |
67 | void componentComplete(); |
|
77 | void componentComplete(); | |
@@ -82,14 +92,15 public: | |||||
82 | explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0); |
|
92 | explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0); | |
83 | QDeclarativeListProperty<DeclarativeBarSet> initialBarSets(); |
|
93 | QDeclarativeListProperty<DeclarativeBarSet> initialBarSets(); | |
84 |
|
94 | |||
|
95 | void setBarCategories(QStringList categories); | |||
|
96 | QStringList barCategories(); | |||
|
97 | ||||
|
98 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |||
|
99 | ||||
85 | public: // from QDeclarativeParserStatus |
|
100 | public: // from QDeclarativeParserStatus | |
86 | void classBegin(); |
|
101 | void classBegin(); | |
87 | void componentComplete(); |
|
102 | void componentComplete(); | |
88 |
|
103 | |||
89 | public: |
|
|||
90 | void setBarCategories(QStringList categories); |
|
|||
91 | QStringList barCategories(); |
|
|||
92 |
|
||||
93 | public Q_SLOTS: |
|
104 | public Q_SLOTS: | |
94 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> * /*list*/, DeclarativeBarSet * /*element*/) {} |
|
105 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> * /*list*/, DeclarativeBarSet * /*element*/) {} | |
95 | }; |
|
106 | }; |
@@ -237,7 +237,7 void QBarSeries::setLabelsVisible(bool visible) | |||||
237 | Q_D(QBarSeries); |
|
237 | Q_D(QBarSeries); | |
238 | if (d->m_labelsVisible != visible) { |
|
238 | if (d->m_labelsVisible != visible) { | |
239 | d->m_labelsVisible = visible; |
|
239 | d->m_labelsVisible = visible; | |
240 | emit d->updatedBars(); |
|
240 | emit d->labelsVisibleChanged(visible); | |
241 | } |
|
241 | } | |
242 | } |
|
242 | } | |
243 |
|
243 |
@@ -36,6 +36,9 class QBarSeriesPrivate; | |||||
36 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries |
|
36 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
|
39 | Q_PROPERTY(int count READ barsetCount) // TODO: categoryCount to be removed | |||
|
40 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible) | |||
|
41 | ||||
39 | public: |
|
42 | public: | |
40 | explicit QBarSeries(QObject *parent = 0); |
|
43 | explicit QBarSeries(QObject *parent = 0); | |
41 | virtual ~QBarSeries(); |
|
44 | virtual ~QBarSeries(); |
@@ -27,11 +27,19 Flow { | |||||
27 | property variant series |
|
27 | property variant series | |
28 |
|
28 | |||
29 | Button { |
|
29 | Button { | |
30 | text: "color" |
|
30 | text: "set 1 color" | |
31 | onClicked: series.color = main.nextColor(); |
|
31 | onClicked: series.at(0).color = main.nextColor(); | |
32 | } |
|
32 | } | |
33 | Button { |
|
33 | Button { | |
34 | text: "points visible" |
|
34 | text: "set 1 border color" | |
35 | onClicked: series.pointsVisible = !series.pointsVisible |
|
35 | onClicked: series.at(0).borderColor = main.nextColor(); | |
|
36 | } | |||
|
37 | Button { | |||
|
38 | text: "set 1 label color" | |||
|
39 | onClicked: series.at(0).labelColor = main.nextColor(); | |||
|
40 | } | |||
|
41 | Button { | |||
|
42 | text: "labels visible" | |||
|
43 | onClicked: series.labelsVisible = !series.labelsVisible; | |||
36 | } |
|
44 | } | |
37 | } |
|
45 | } |
General Comments 0
You need to be logged in to leave comments.
Login now