diff --git a/plugins/declarative/declarativebarseries.cpp b/plugins/declarative/declarativebarseries.cpp index e6a5bcb..d4e2ab6 100644 --- a/plugins/declarative/declarativebarseries.cpp +++ b/plugins/declarative/declarativebarseries.cpp @@ -48,6 +48,42 @@ void DeclarativeBarSet::setValues(QVariantList values) } } +QColor DeclarativeBarSet::color() +{ + return brush().color(); +} + +void DeclarativeBarSet::setColor(QColor color) +{ + QBrush b = brush(); + b.setColor(color); + setBrush(b); +} + +QColor DeclarativeBarSet::borderColor() +{ + return pen().color(); +} + +void DeclarativeBarSet::setBorderColor(QColor color) +{ + QPen p = pen(); + p.setColor(color); + setPen(p); +} + +QColor DeclarativeBarSet::labelColor() +{ + return labelBrush().color(); +} + +void DeclarativeBarSet::setLabelColor(QColor color) +{ + QBrush b = labelBrush(); + b.setColor(color); + setLabelBrush(b); +} + DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : QBarSeries(parent) { @@ -60,8 +96,8 @@ void DeclarativeBarSeries::classBegin() void DeclarativeBarSeries::componentComplete() { foreach(QObject *child, children()) { - if (qobject_cast(child)) { - QBarSeries::append(qobject_cast(child)); + if (qobject_cast(child)) { + QBarSeries::append(qobject_cast(child)); } } } @@ -81,6 +117,15 @@ QStringList DeclarativeBarSeries::barCategories() return categories(); } +DeclarativeBarSet *DeclarativeBarSeries::at(int index) +{ + QList setList = barSets(); + if (index < setList.count()) + return qobject_cast(setList[index]); + + return 0; +} + DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : QGroupedBarSeries(parent) { @@ -93,8 +138,8 @@ void DeclarativeGroupedBarSeries::classBegin() void DeclarativeGroupedBarSeries::componentComplete() { foreach(QObject *child, children()) { - if (qobject_cast(child)) { - QBarSeries::append(qobject_cast(child)); + if (qobject_cast(child)) { + QBarSeries::append(qobject_cast(child)); } } } @@ -114,6 +159,15 @@ QStringList DeclarativeGroupedBarSeries::barCategories() return categories(); } +DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) +{ + QList setList = barSets(); + if (index < setList.count()) + return qobject_cast(setList[index]); + + return 0; +} + #include "moc_declarativebarseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativebarseries.h b/plugins/declarative/declarativebarseries.h index 09a3275..05ba199 100644 --- a/plugins/declarative/declarativebarseries.h +++ b/plugins/declarative/declarativebarseries.h @@ -35,12 +35,20 @@ class DeclarativeBarSet : public QBarSet { Q_OBJECT Q_PROPERTY(QVariantList values READ values WRITE setValues) - Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) + Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) public: explicit DeclarativeBarSet(QObject *parent = 0); QVariantList values(); void setValues(QVariantList values); + QColor color(); + void setColor(QColor color); + QColor borderColor(); + void setBorderColor(QColor color); + QColor labelColor(); + void setLabelColor(QColor color); public: // From QBarSet Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } @@ -62,6 +70,8 @@ public: void setBarCategories(QStringList categories); QStringList barCategories(); + Q_INVOKABLE DeclarativeBarSet *at(int index); + public: // from QDeclarativeParserStatus void classBegin(); void componentComplete(); @@ -82,14 +92,15 @@ public: explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0); QDeclarativeListProperty initialBarSets(); + void setBarCategories(QStringList categories); + QStringList barCategories(); + + Q_INVOKABLE DeclarativeBarSet *at(int index); + public: // from QDeclarativeParserStatus void classBegin(); void componentComplete(); -public: - void setBarCategories(QStringList categories); - QStringList barCategories(); - public Q_SLOTS: static void appendInitialBarSets(QDeclarativeListProperty * /*list*/, DeclarativeBarSet * /*element*/) {} }; diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index 494503f..24256f7 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -237,7 +237,7 @@ void QBarSeries::setLabelsVisible(bool visible) Q_D(QBarSeries); if (d->m_labelsVisible != visible) { d->m_labelsVisible = visible; - emit d->updatedBars(); + emit d->labelsVisibleChanged(visible); } } diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index 6be6eb9..1583350 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -36,6 +36,9 @@ class QBarSeriesPrivate; class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries { Q_OBJECT + Q_PROPERTY(int count READ barsetCount) // TODO: categoryCount to be removed + Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible) + public: explicit QBarSeries(QObject *parent = 0); virtual ~QBarSeries(); diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml index 014a2e2..5f6f73f 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml @@ -27,11 +27,19 @@ Flow { property variant series Button { - text: "color" - onClicked: series.color = main.nextColor(); + text: "set 1 color" + onClicked: series.at(0).color = main.nextColor(); } Button { - text: "points visible" - onClicked: series.pointsVisible = !series.pointsVisible + text: "set 1 border color" + onClicked: series.at(0).borderColor = main.nextColor(); + } + Button { + text: "set 1 label color" + onClicked: series.at(0).labelColor = main.nextColor(); + } + Button { + text: "labels visible" + onClicked: series.labelsVisible = !series.labelsVisible; } }