From dde391dc31a220fe9f4010198b02d46c4f051fc1 2012-05-31 07:02:51 From: Tero Ahola Date: 2012-05-31 07:02:51 Subject: [PATCH] Rest of the pie, bar, area and scatter properties to QML property tester --- diff --git a/plugins/declarative/declarativeareaseries.cpp b/plugins/declarative/declarativeareaseries.cpp index 62adf04..12f9b2b 100644 --- a/plugins/declarative/declarativeareaseries.cpp +++ b/plugins/declarative/declarativeareaseries.cpp @@ -50,6 +50,30 @@ DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const return qobject_cast(QAreaSeries::lowerSeries()); } +QColor DeclarativeAreaSeries::penColor() const +{ + return pen().color(); +} + +void DeclarativeAreaSeries::setPenColor(QColor color) +{ + QPen p = pen(); + p.setColor(color); + setPen(p); +} + +QColor DeclarativeAreaSeries::brushColor() const +{ + return brush().color(); +} + +void DeclarativeAreaSeries::setBrushColor(QColor color) +{ + QBrush b = brush(); + b.setColor(color); + setBrush(b); +} + #include "moc_declarativeareaseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativeareaseries.h b/plugins/declarative/declarativeareaseries.h index 790de23..347216b 100644 --- a/plugins/declarative/declarativeareaseries.h +++ b/plugins/declarative/declarativeareaseries.h @@ -32,18 +32,19 @@ class DeclarativeAreaSeries : public QAreaSeries Q_OBJECT Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) + Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor) + Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor) public: explicit DeclarativeAreaSeries(QObject *parent = 0); - -public: - QXYModelMapper* upperModelMapper() const; - QXYModelMapper* lowerModelMapper() const; -public: void setUpperSeries(DeclarativeLineSeries* series); DeclarativeLineSeries* upperSeries() const; void setLowerSeries(DeclarativeLineSeries* series); DeclarativeLineSeries* lowerSeries() const; + QColor penColor() const; + void setPenColor(QColor color); + QColor brushColor() const; + void setBrushColor(QColor color); }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativexyseries.cpp b/plugins/declarative/declarativexyseries.cpp index ac3d436..07bf338 100644 --- a/plugins/declarative/declarativexyseries.cpp +++ b/plugins/declarative/declarativexyseries.cpp @@ -58,7 +58,6 @@ void DeclarativeXySeries::componentComplete() } } - QColor DeclarativeXySeries::penColor() { // All the inherited objects must be of type QXYSeries, so it is safe to cast diff --git a/src/areachart/qareaseries.h b/src/areachart/qareaseries.h index 22573c9..f82ea17 100644 --- a/src/areachart/qareaseries.h +++ b/src/areachart/qareaseries.h @@ -33,6 +33,7 @@ class QAreaSeriesPrivate; class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries { Q_OBJECT + public: explicit QAreaSeries(QObject *parent = 0); explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index 1583350..ec66fa7 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -36,7 +36,9 @@ class QBarSeriesPrivate; class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries { Q_OBJECT + Q_PROPERTY(qreal barMargin READ barMargin WRITE setBarMargin) Q_PROPERTY(int count READ barsetCount) // TODO: categoryCount to be removed + Q_PROPERTY(bool visible READ isVisible WRITE setVisible) Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible) public: diff --git a/src/barchart/qbarset.h b/src/barchart/qbarset.h index 9afc363..21ac9a4 100644 --- a/src/barchart/qbarset.h +++ b/src/barchart/qbarset.h @@ -33,6 +33,10 @@ class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush) + Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont) public: explicit QBarSet(const QString name, QObject *parent = 0); diff --git a/src/xychart/qxyseries.h b/src/xychart/qxyseries.h index e50551a..88f3cbe 100644 --- a/src/xychart/qxyseries.h +++ b/src/xychart/qxyseries.h @@ -37,6 +37,7 @@ class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries { Q_OBJECT Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) + Q_PROPERTY(int count READ count) protected: explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml new file mode 100644 index 0000000..cbd29be --- /dev/null +++ b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import QtCommercial.Chart 1.0 + + +Flow { + id: flow + spacing: 5 + flow: Flow.TopToBottom + property variant series + + Button { + text: "color" + onClicked: series.color = main.nextColor(); + } + Button { + text: "borderColor" + onClicked: series.borderColor = main.nextColor(); + } + Button { + text: "upper color" + onClicked: series.upperSeries.color = main.nextColor(); + } + Button { + text: "lower color" + onClicked: series.lowerSeries.color = main.nextColor(); + } + Button { + text: "upper points visible" + onClicked: series.upperSeries.pointsVisible = !series.pointsVisible; + } + Button { + text: "lower points visible" + onClicked: series.lowerSeries.pointsVisible = !series.pointsVisible; + } +} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml index 5f6f73f..424af4b 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml @@ -24,6 +24,7 @@ import QtCommercial.Chart 1.0 Flow { id: flow spacing: 5 + flow: Flow.TopToBottom property variant series Button { @@ -39,7 +40,27 @@ Flow { onClicked: series.at(0).labelColor = main.nextColor(); } Button { + text: "visible" + onClicked: series.visible = !series.visible; + } + Button { text: "labels visible" onClicked: series.labelsVisible = !series.labelsVisible; } + Button { + text: "bar margin +" + onClicked: series.barMargin += 0.1; + } + Button { + text: "bar margin -" + onClicked: series.barMargin -= 0.1; + } + Button { + text: "set 1 font size +" + onClicked: series.at(0).labelFont.pixelSize += 1; + } + Button { + text: "set 1 font size -" + onClicked: series.at(0).labelFont.pixelSize -= 1; + } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/Button.qml b/tests/qmlchartproperties/qml/qmlchartproperties/Button.qml index 6666d32..5f07e0c 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/Button.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/Button.qml @@ -22,8 +22,8 @@ import QtQuick 1.0 Rectangle { id: button - height: 45 - width: 165 + height: 25 + width: 110 color: "#afafaf" radius: 5 diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml index 6648a95..425a31d 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml @@ -25,6 +25,7 @@ import QtCommercial.Chart 1.0 Flow { id: flow spacing: 5 + flow: Flow.TopToBottom property variant series Button { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml index bb3274d..42a3af8 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml @@ -24,6 +24,7 @@ import QtCommercial.Chart 1.0 Flow { id: flow spacing: 5 + flow: Flow.TopToBottom property variant series Button { @@ -47,6 +48,14 @@ Flow { onClicked: series.at(0).labelVisible = !series.at(0).labelVisible; } Button { + text: "slice label arm len +" + onClicked: series.at(0).labelArmLengthFactor += 0.1; + } + Button { + text: "slice label arm len -" + onClicked: series.at(0).labelArmLengthFactor -= 0.1; + } + Button { text: "slice label color" onClicked: series.at(0).labelColor = main.nextColor(); } @@ -54,4 +63,52 @@ Flow { text: "slice exploded" onClicked: series.at(0).exploded = !series.at(0).exploded; } + Button { + text: "slice explode dist +" + onClicked: series.at(0).explodeDistanceFactor += 0.1; + } + Button { + text: "slice explode dist -" + onClicked: series.at(0).explodeDistanceFactor -= 0.1; + } + Button { + text: "series hpos +" + onClicked: series.horizontalPosition += 0.1; + } + Button { + text: "series hpos -" + onClicked: series.horizontalPosition -= 0.1; + } + Button { + text: "series vpos +" + onClicked: series.verticalPosition += 0.1; + } + Button { + text: "series vpos -" + onClicked: series.verticalPosition -= 0.1; + } + Button { + text: "series size +" + onClicked: series.size += 0.1; + } + Button { + text: "series size -" + onClicked: series.size -= 0.1; + } + Button { + text: "series start angle +" + onClicked: series.startAngle += 0.1; + } + Button { + text: "series start angle -" + onClicked: series.startAngle -= 0.1; + } + Button { + text: "series end angle +" + onClicked: series.endAngle += 0.1; + } + Button { + text: "series end angle -" + onClicked: series.endAngle -= 0.1; + } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml new file mode 100644 index 0000000..e1d5ebc --- /dev/null +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import QtCommercial.Chart 1.0 + + +Flow { + id: flow + spacing: 5 + flow: Flow.TopToBottom + property variant series + + Button { + text: "color" + onClicked: series.color = main.nextColor(); + } + Button { + text: "borderColor" + onClicked: series.borderColor = main.nextColor(); + } + Button { + text: "markerSize +" + onClicked: series.markerSize += 1.0; + } + Button { + text: "markerSize -" + onClicked: series.markerSize -= 1.0; + } + Button { + text: "markerShape" + onClicked: series.markerShape = ((series.markerShape + 1) % 2); + } +} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/main.qml b/tests/qmlchartproperties/qml/qmlchartproperties/main.qml index 7f4ed85..7c02877 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/main.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/main.qml @@ -48,10 +48,10 @@ Rectangle { editorLoader.source = "LineEditor.qml"; } else if (viewNumber == 3) { chartLoader.source = "ScatterChart.qml"; - editorLoader.source = "LineEditor.qml"; // TODO: scatter specific properties + editorLoader.source = "ScatterEditor.qml"; } else if (viewNumber == 4) { chartLoader.source = "AreaChart.qml"; - editorLoader.source = "LineEditor.qml"; // TODO: area specific properties + editorLoader.source = "AreaEditor.qml"; } else if (viewNumber == 5) { chartLoader.source = "BarChart.qml"; editorLoader.source = "BarEditor.qml"; @@ -80,7 +80,7 @@ Rectangle { Loader { id: editorLoader - width: 150 + width: 230 height: parent.height source: "PieEditor.qml" onStatusChanged: { @@ -91,15 +91,6 @@ Rectangle { } } -// Loader { -// id: loader -// anchors.top: parent.top -// anchors.bottom: buttonRow.top -// anchors.left: parent.left -// anchors.right: parent.right -// source: "View" + viewNumber + ".qml"; -// } - Row { id: buttonRow height: 100 diff --git a/tests/qmlchartproperties/resources.qrc b/tests/qmlchartproperties/resources.qrc index 9d68b9b..f2ba921 100644 --- a/tests/qmlchartproperties/resources.qrc +++ b/tests/qmlchartproperties/resources.qrc @@ -12,5 +12,7 @@ qml/qmlchartproperties/AreaChart.qml qml/qmlchartproperties/BarChart.qml qml/qmlchartproperties/BarEditor.qml + qml/qmlchartproperties/ScatterEditor.qml + qml/qmlchartproperties/AreaEditor.qml