summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-05-07 08:24:22 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-05-07 08:43:12 +0300
commite824058bc1926a656736fa2490cb892ea9a4e2f5 (patch)
treec84007ce6535649de8d116d3e753a7b0a63127a0 /tests
parent65acb111b085568597ebf8a83241f4b0ab63a037 (diff)
Add API to specify plot area background.
Task-number: http://jira.sc.local/browse/QTRD-1886 Change-Id: Ica9bd72482fdca14a81574087ba0ec4614169cd2 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qchart/tst_qchart.cpp52
-rw-r--r--tests/polarcharttest/mainwindow.cpp63
-rw-r--r--tests/polarcharttest/mainwindow.h6
-rw-r--r--tests/polarcharttest/mainwindow.ui74
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml3
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorProperties.qml4
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/Chart.qml3
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/ChartEditorProperties.qml4
8 files changed, 204 insertions, 5 deletions
diff --git a/tests/auto/qchart/tst_qchart.cpp b/tests/auto/qchart/tst_qchart.cpp
index f92be649..4f78d4e4 100644
--- a/tests/auto/qchart/tst_qchart.cpp
+++ b/tests/auto/qchart/tst_qchart.cpp
@@ -71,6 +71,12 @@ private slots:
void backgroundPen();
void isBackgroundVisible_data();
void isBackgroundVisible();
+ void plotAreaBackgroundBrush_data();
+ void plotAreaBackgroundBrush();
+ void plotAreaBackgroundPen_data();
+ void plotAreaBackgroundPen();
+ void isPlotAreaBackgroundVisible_data();
+ void isPlotAreaBackgroundVisible();
void legend_data();
void legend();
void plotArea_data();
@@ -357,6 +363,52 @@ void tst_QChart::isBackgroundVisible()
QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible);
}
+void tst_QChart::plotAreaBackgroundBrush_data()
+{
+ QTest::addColumn<QBrush>("plotAreaBackgroundBrush");
+ QTest::newRow("null") << QBrush();
+ QTest::newRow("blue") << QBrush(Qt::blue);
+ QTest::newRow("white") << QBrush(Qt::white);
+ QTest::newRow("black") << QBrush(Qt::black);
+}
+
+void tst_QChart::plotAreaBackgroundBrush()
+{
+ QFETCH(QBrush, plotAreaBackgroundBrush);
+ m_chart->setPlotAreaBackgroundBrush(plotAreaBackgroundBrush);
+ QCOMPARE(m_chart->plotAreaBackgroundBrush(), plotAreaBackgroundBrush);
+}
+
+void tst_QChart::plotAreaBackgroundPen_data()
+{
+ QTest::addColumn<QPen>("plotAreaBackgroundPen");
+ QTest::newRow("null") << QPen();
+ QTest::newRow("blue") << QPen(Qt::blue);
+ QTest::newRow("white") << QPen(Qt::white);
+ QTest::newRow("black") << QPen(Qt::black);
+}
+
+
+void tst_QChart::plotAreaBackgroundPen()
+{
+ QFETCH(QPen, plotAreaBackgroundPen);
+ m_chart->setPlotAreaBackgroundPen(plotAreaBackgroundPen);
+ QCOMPARE(m_chart->plotAreaBackgroundPen(), plotAreaBackgroundPen);
+}
+
+void tst_QChart::isPlotAreaBackgroundVisible_data()
+{
+ QTest::addColumn<bool>("isPlotAreaBackgroundVisible");
+ QTest::newRow("true") << true;
+ QTest::newRow("false") << false;
+}
+
+void tst_QChart::isPlotAreaBackgroundVisible()
+{
+ QFETCH(bool, isPlotAreaBackgroundVisible);
+ m_chart->setPlotAreaBackgroundVisible(isPlotAreaBackgroundVisible);
+ QCOMPARE(m_chart->isPlotAreaBackgroundVisible(), isPlotAreaBackgroundVisible);
+}
void tst_QChart::legend_data()
{
diff --git a/tests/polarcharttest/mainwindow.cpp b/tests/polarcharttest/mainwindow.cpp
index 7e6cef04..92069a42 100644
--- a/tests/polarcharttest/mainwindow.cpp
+++ b/tests/polarcharttest/mainwindow.cpp
@@ -58,12 +58,16 @@ MainWindow::MainWindow(QWidget *parent) :
m_radialShadesBrush(new QBrush(Qt::NoBrush)),
m_labelBrush(new QBrush(Qt::black)),
m_titleBrush(new QBrush(Qt::black)),
+ m_backgroundBrush(new QBrush(Qt::white)),
+ m_plotAreaBackgroundBrush(new QBrush(Qt::NoBrush)),
m_angularShadesPen(new QPen(Qt::NoPen)),
m_radialShadesPen(new QPen(Qt::NoPen)),
m_labelPen(new QPen(Qt::NoPen)),
m_titlePen(new QPen(Qt::NoPen)),
m_gridPen(new QPen(QRgb(0x010101))), // Note: Pure black is default color, so it gets overridden by
m_arrowPen(new QPen(QRgb(0x010101))), // default theme if set to that initially. This is an example of workaround.
+ m_backgroundPen(new QPen(Qt::NoPen)),
+ m_plotAreaBackgroundPen(new QPen(Qt::NoPen)),
m_labelFormat(QString("%.2f")),
m_animationOptions(QChart::NoAnimation),
m_angularTitle(QString("Angular Title")),
@@ -157,6 +161,8 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->series6checkBox, SIGNAL(clicked()), this, SLOT(series6CheckBoxChecked()));
connect(ui->series7checkBox, SIGNAL(clicked()), this, SLOT(series7CheckBoxChecked()));
connect(ui->themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(themeIndexChanged(int)));
+ connect(ui->backgroundComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(backgroundIndexChanged(int)));
+ connect(ui->plotAreaComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(plotAreaIndexChanged(int)));
ui->chartView->setChart(m_chart);
ui->chartView->setRenderHint(QPainter::Antialiasing);
@@ -379,6 +385,10 @@ void MainWindow::initXYValueChart()
m_chart->setAnimationOptions(m_animationOptions);
//m_chart->legend()->setVisible(false);
m_chart->setAcceptHoverEvents(true);
+ m_chart->setBackgroundBrush(*m_backgroundBrush);
+ m_chart->setBackgroundPen(*m_backgroundPen);
+ m_chart->setPlotAreaBackgroundBrush(*m_plotAreaBackgroundBrush);
+ m_chart->setPlotAreaBackgroundPen(*m_plotAreaBackgroundPen);
}
void MainWindow::setAngularAxis(MainWindow::AxisMode mode)
@@ -1081,6 +1091,59 @@ void MainWindow::seriesClicked(const QPointF &point)
}
}
+void MainWindow::backgroundIndexChanged(int index)
+{
+ delete m_backgroundBrush;
+ delete m_backgroundPen;
+
+ switch (index) {
+ case 0:
+ m_backgroundBrush = new QBrush(Qt::white);
+ m_backgroundPen = new QPen(Qt::NoPen);
+ break;
+ case 1:
+ m_backgroundBrush = new QBrush(Qt::blue);
+ m_backgroundPen = new QPen(Qt::NoPen);
+ break;
+ case 2:
+ m_backgroundBrush = new QBrush(Qt::yellow);
+ m_backgroundPen = new QPen(Qt::black, 2);
+ break;
+ default:
+ break;
+ }
+ m_chart->setBackgroundBrush(*m_backgroundBrush);
+ m_chart->setBackgroundPen(*m_backgroundPen);
+}
+
+void MainWindow::plotAreaIndexChanged(int index)
+{
+ delete m_plotAreaBackgroundBrush;
+ delete m_plotAreaBackgroundPen;
+
+ switch (index) {
+ case 0:
+ m_plotAreaBackgroundBrush = new QBrush(Qt::green);
+ m_plotAreaBackgroundPen = new QPen(Qt::green);
+ m_chart->setPlotAreaBackgroundVisible(false);
+ break;
+ case 1:
+ m_plotAreaBackgroundBrush = new QBrush(Qt::magenta);
+ m_plotAreaBackgroundPen = new QPen(Qt::NoPen);
+ m_chart->setPlotAreaBackgroundVisible(true);
+ break;
+ case 2:
+ m_plotAreaBackgroundBrush = new QBrush(Qt::lightGray);
+ m_plotAreaBackgroundPen = new QPen(Qt::red, 6);
+ m_chart->setPlotAreaBackgroundVisible(true);
+ break;
+ default:
+ break;
+ }
+ m_chart->setPlotAreaBackgroundBrush(*m_plotAreaBackgroundBrush);
+ m_chart->setPlotAreaBackgroundPen(*m_plotAreaBackgroundPen);
+}
+
void MainWindow::applyCategories()
{
// Basic layout is three categories, extended has five
diff --git a/tests/polarcharttest/mainwindow.h b/tests/polarcharttest/mainwindow.h
index 94aa7d84..643f9fcc 100644
--- a/tests/polarcharttest/mainwindow.h
+++ b/tests/polarcharttest/mainwindow.h
@@ -85,6 +85,8 @@ public slots:
void themeIndexChanged(int index);
void seriesHovered(QPointF point, bool state);
void seriesClicked(const QPointF &point);
+ void backgroundIndexChanged(int index);
+ void plotAreaIndexChanged(int index);
private:
enum AxisMode {
@@ -121,12 +123,16 @@ private:
QBrush *m_radialShadesBrush;
QBrush *m_labelBrush;
QBrush *m_titleBrush;
+ QBrush *m_backgroundBrush;
+ QBrush *m_plotAreaBackgroundBrush;
QPen *m_angularShadesPen;
QPen *m_radialShadesPen;
QPen *m_labelPen;
QPen *m_titlePen;
QPen *m_gridPen;
QPen *m_arrowPen;
+ QPen *m_backgroundPen;
+ QPen *m_plotAreaBackgroundPen;
QString m_labelFormat;
QFont m_currentLabelFont;
QFont m_currentTitleFont;
diff --git a/tests/polarcharttest/mainwindow.ui b/tests/polarcharttest/mainwindow.ui
index 79cf3793..4faffb54 100644
--- a/tests/polarcharttest/mainwindow.ui
+++ b/tests/polarcharttest/mainwindow.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>1207</width>
- <height>905</height>
+ <width>1193</width>
+ <height>956</height>
</rect>
</property>
<property name="windowTitle">
@@ -892,6 +892,74 @@
<string>Hover coordinates here!</string>
</property>
</widget>
+ <widget class="QComboBox" name="backgroundComboBox">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>820</y>
+ <width>171</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>Background: White</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Background: Blue</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Background: Yellow + Black Border</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QComboBox" name="plotAreaComboBox">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>850</y>
+ <width>171</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>PlotArea: Transparent</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>PlotArea: Magenta</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>PlotArea: Gray + Red Border</string>
+ </property>
+ </item>
+ </widget>
</widget>
</item>
</layout>
@@ -901,7 +969,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>1207</width>
+ <width>1193</width>
<height>21</height>
</rect>
</property>
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml
index 07c9e8a0..6e2c97e9 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.2
+import QtCommercial.Chart 1.3
ChartView {
id: chartView
@@ -44,6 +44,7 @@ ChartView {
onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name);
onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name);
+ onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor);
legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + chart.legend.visible);
legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorProperties.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorProperties.qml
index 28fe6aea..fdced78f 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorProperties.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorProperties.qml
@@ -50,6 +50,10 @@ Flow {
onClicked: chart.backgroundColor = main.nextColor();
}
Button {
+ text: "plot area color"
+ onClicked: chart.plotAreaColor = main.nextColor();
+ }
+ Button {
text: "drop shadow enabled"
onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled;
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/Chart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/Chart.qml
index 2f8b4236..a639638d 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/Chart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/Chart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.2
+import QtCommercial.Chart 1.3
ChartView {
id: chartView
@@ -44,6 +44,7 @@ ChartView {
onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name);
onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name);
+ onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor);
legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + chart.legend.visible);
legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/ChartEditorProperties.qml b/tests/quick2chartproperties/qml/quick2chartproperties/ChartEditorProperties.qml
index f0e63a59..1bc14b4d 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/ChartEditorProperties.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/ChartEditorProperties.qml
@@ -50,6 +50,10 @@ Flow {
onClicked: chart.backgroundColor = main.nextColor();
}
Button {
+ text: "plot area color"
+ onClicked: chart.plotAreaColor = main.nextColor();
+ }
+ Button {
text: "drop shadow enabled"
onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled;
}