##// END OF EJS Templates
Removed resize hack from chartwidgettest theme change
Tero Ahola -
r824:921979357fc9
parent child
Show More
@@ -1,329 +1,325
1 #include "mainwidget.h"
1 #include "mainwidget.h"
2 #include "dataseriedialog.h"
2 #include "dataseriedialog.h"
3 #include "qchartview.h"
3 #include "qchartview.h"
4 #include "qpieseries.h"
4 #include "qpieseries.h"
5 #include "qscatterseries.h"
5 #include "qscatterseries.h"
6 #include "qlineseries.h"
6 #include "qlineseries.h"
7 #include <qareaseries.h>
7 #include <qareaseries.h>
8 #include <qsplineseries.h>
8 #include <qsplineseries.h>
9 #include <qbarset.h>
9 #include <qbarset.h>
10 #include <qbarseries.h>
10 #include <qbarseries.h>
11 #include <qstackedbarseries.h>
11 #include <qstackedbarseries.h>
12 #include <qpercentbarseries.h>
12 #include <qpercentbarseries.h>
13 #include <QPushButton>
13 #include <QPushButton>
14 #include <QComboBox>
14 #include <QComboBox>
15 #include <QSpinBox>
15 #include <QSpinBox>
16 #include <QCheckBox>
16 #include <QCheckBox>
17 #include <QGridLayout>
17 #include <QGridLayout>
18 #include <QHBoxLayout>
18 #include <QHBoxLayout>
19 #include <QLabel>
19 #include <QLabel>
20 #include <QSpacerItem>
20 #include <QSpacerItem>
21 #include <QMessageBox>
21 #include <QMessageBox>
22 #include <cmath>
22 #include <cmath>
23 #include <QDebug>
23 #include <QDebug>
24 #include <QStandardItemModel>
24 #include <QStandardItemModel>
25
25
26
26
27 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
28
28
29 MainWidget::MainWidget(QWidget *parent) :
29 MainWidget::MainWidget(QWidget *parent) :
30 QWidget(parent),
30 QWidget(parent),
31 m_addSerieDialog(0),
31 m_addSerieDialog(0),
32 m_chart(0)
32 m_chart(0)
33 {
33 {
34 m_chart = new QChart();
34 m_chart = new QChart();
35
35
36 // Grid layout for the controls for configuring the chart widget
36 // Grid layout for the controls for configuring the chart widget
37 QGridLayout *grid = new QGridLayout();
37 QGridLayout *grid = new QGridLayout();
38 QPushButton *addSeriesButton = new QPushButton("Add series");
38 QPushButton *addSeriesButton = new QPushButton("Add series");
39 connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries()));
39 connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries()));
40 grid->addWidget(addSeriesButton, 0, 1);
40 grid->addWidget(addSeriesButton, 0, 1);
41 initBackroundCombo(grid);
41 initBackroundCombo(grid);
42 initScaleControls(grid);
42 initScaleControls(grid);
43 initThemeCombo(grid);
43 initThemeCombo(grid);
44 initCheckboxes(grid);
44 initCheckboxes(grid);
45
45
46 // add row with empty label to make all the other rows static
46 // add row with empty label to make all the other rows static
47 grid->addWidget(new QLabel(""), grid->rowCount(), 0);
47 grid->addWidget(new QLabel(""), grid->rowCount(), 0);
48 grid->setRowStretch(grid->rowCount() - 1, 1);
48 grid->setRowStretch(grid->rowCount() - 1, 1);
49
49
50 // Create chart view with the chart
50 // Create chart view with the chart
51 m_chartView = new QChartView(m_chart, this);
51 m_chartView = new QChartView(m_chart, this);
52 m_chartView->setRubberBand(QChartView::HorizonalRubberBand);
52 m_chartView->setRubberBand(QChartView::HorizonalRubberBand);
53
53
54 // Another grid layout as a main layout
54 // Another grid layout as a main layout
55 QGridLayout *mainLayout = new QGridLayout();
55 QGridLayout *mainLayout = new QGridLayout();
56 mainLayout->addLayout(grid, 0, 0);
56 mainLayout->addLayout(grid, 0, 0);
57 mainLayout->addWidget(m_chartView, 0, 1, 3, 1);
57 mainLayout->addWidget(m_chartView, 0, 1, 3, 1);
58 setLayout(mainLayout);
58 setLayout(mainLayout);
59 }
59 }
60
60
61 // Combo box for selecting the chart's background
61 // Combo box for selecting the chart's background
62 void MainWidget::initBackroundCombo(QGridLayout *grid)
62 void MainWidget::initBackroundCombo(QGridLayout *grid)
63 {
63 {
64 QComboBox *backgroundCombo = new QComboBox(this);
64 QComboBox *backgroundCombo = new QComboBox(this);
65 backgroundCombo->addItem("Color");
65 backgroundCombo->addItem("Color");
66 backgroundCombo->addItem("Gradient");
66 backgroundCombo->addItem("Gradient");
67 backgroundCombo->addItem("Image");
67 backgroundCombo->addItem("Image");
68 connect(backgroundCombo, SIGNAL(currentIndexChanged(int)),
68 connect(backgroundCombo, SIGNAL(currentIndexChanged(int)),
69 this, SLOT(backgroundChanged(int)));
69 this, SLOT(backgroundChanged(int)));
70
70
71 grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0);
71 grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0);
72 grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1);
72 grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1);
73 }
73 }
74
74
75 // Scale related controls (auto-scale vs. manual min-max values)
75 // Scale related controls (auto-scale vs. manual min-max values)
76 void MainWidget::initScaleControls(QGridLayout *grid)
76 void MainWidget::initScaleControls(QGridLayout *grid)
77 {
77 {
78 m_autoScaleCheck = new QCheckBox("Automatic scaling");
78 m_autoScaleCheck = new QCheckBox("Automatic scaling");
79 connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int)));
79 connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int)));
80 // Allow setting also non-sense values (like -2147483648 and 2147483647)
80 // Allow setting also non-sense values (like -2147483648 and 2147483647)
81 m_xMinSpin = new QSpinBox();
81 m_xMinSpin = new QSpinBox();
82 m_xMinSpin->setMinimum(INT_MIN);
82 m_xMinSpin->setMinimum(INT_MIN);
83 m_xMinSpin->setMaximum(INT_MAX);
83 m_xMinSpin->setMaximum(INT_MAX);
84 m_xMinSpin->setValue(0);
84 m_xMinSpin->setValue(0);
85 connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int)));
85 connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int)));
86 m_xMaxSpin = new QSpinBox();
86 m_xMaxSpin = new QSpinBox();
87 m_xMaxSpin->setMinimum(INT_MIN);
87 m_xMaxSpin->setMinimum(INT_MIN);
88 m_xMaxSpin->setMaximum(INT_MAX);
88 m_xMaxSpin->setMaximum(INT_MAX);
89 m_xMaxSpin->setValue(10);
89 m_xMaxSpin->setValue(10);
90 connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int)));
90 connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int)));
91 m_yMinSpin = new QSpinBox();
91 m_yMinSpin = new QSpinBox();
92 m_yMinSpin->setMinimum(INT_MIN);
92 m_yMinSpin->setMinimum(INT_MIN);
93 m_yMinSpin->setMaximum(INT_MAX);
93 m_yMinSpin->setMaximum(INT_MAX);
94 m_yMinSpin->setValue(0);
94 m_yMinSpin->setValue(0);
95 connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int)));
95 connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int)));
96 m_yMaxSpin = new QSpinBox();
96 m_yMaxSpin = new QSpinBox();
97 m_yMaxSpin->setMinimum(INT_MIN);
97 m_yMaxSpin->setMinimum(INT_MIN);
98 m_yMaxSpin->setMaximum(INT_MAX);
98 m_yMaxSpin->setMaximum(INT_MAX);
99 m_yMaxSpin->setValue(10);
99 m_yMaxSpin->setValue(10);
100 connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int)));
100 connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int)));
101
101
102 grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0);
102 grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0);
103 grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0);
103 grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0);
104 grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1);
104 grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1);
105 grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0);
105 grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0);
106 grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1);
106 grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1);
107 grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0);
107 grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0);
108 grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1);
108 grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1);
109 grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0);
109 grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0);
110 grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1);
110 grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1);
111
111
112 m_autoScaleCheck->setChecked(true);
112 m_autoScaleCheck->setChecked(true);
113 }
113 }
114
114
115 // Combo box for selecting theme
115 // Combo box for selecting theme
116 void MainWidget::initThemeCombo(QGridLayout *grid)
116 void MainWidget::initThemeCombo(QGridLayout *grid)
117 {
117 {
118 QComboBox *chartTheme = new QComboBox();
118 QComboBox *chartTheme = new QComboBox();
119 chartTheme->addItem("Default");
119 chartTheme->addItem("Default");
120 chartTheme->addItem("Light");
120 chartTheme->addItem("Light");
121 chartTheme->addItem("Blue Cerulean");
121 chartTheme->addItem("Blue Cerulean");
122 chartTheme->addItem("Dark");
122 chartTheme->addItem("Dark");
123 chartTheme->addItem("Brown Sand");
123 chartTheme->addItem("Brown Sand");
124 chartTheme->addItem("Blue NCS");
124 chartTheme->addItem("Blue NCS");
125 chartTheme->addItem("High Contrast");
125 chartTheme->addItem("High Contrast");
126 chartTheme->addItem("Blue Icy");
126 chartTheme->addItem("Blue Icy");
127 connect(chartTheme, SIGNAL(currentIndexChanged(int)),
127 connect(chartTheme, SIGNAL(currentIndexChanged(int)),
128 this, SLOT(changeChartTheme(int)));
128 this, SLOT(changeChartTheme(int)));
129 grid->addWidget(new QLabel("Chart theme:"), 8, 0);
129 grid->addWidget(new QLabel("Chart theme:"), 8, 0);
130 grid->addWidget(chartTheme, 8, 1);
130 grid->addWidget(chartTheme, 8, 1);
131 }
131 }
132
132
133 // Different check boxes for customizing chart
133 // Different check boxes for customizing chart
134 void MainWidget::initCheckboxes(QGridLayout *grid)
134 void MainWidget::initCheckboxes(QGridLayout *grid)
135 {
135 {
136 // TODO: setZoomEnabled slot has been removed from QChartView -> Re-implement zoom on/off
136 // TODO: setZoomEnabled slot has been removed from QChartView -> Re-implement zoom on/off
137 QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom");
137 QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom");
138 // connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartView, SLOT(setZoomEnabled(bool)));
138 // connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartView, SLOT(setZoomEnabled(bool)));
139 zoomCheckBox->setChecked(true);
139 zoomCheckBox->setChecked(true);
140 grid->addWidget(zoomCheckBox, grid->rowCount(), 0);
140 grid->addWidget(zoomCheckBox, grid->rowCount(), 0);
141
141
142 QCheckBox *aliasCheckBox = new QCheckBox("Anti-alias");
142 QCheckBox *aliasCheckBox = new QCheckBox("Anti-alias");
143 connect(aliasCheckBox, SIGNAL(toggled(bool)), this, SLOT(antiAliasToggled(bool)));
143 connect(aliasCheckBox, SIGNAL(toggled(bool)), this, SLOT(antiAliasToggled(bool)));
144 aliasCheckBox->setChecked(false);
144 aliasCheckBox->setChecked(false);
145 grid->addWidget(aliasCheckBox, grid->rowCount(), 0);
145 grid->addWidget(aliasCheckBox, grid->rowCount(), 0);
146 }
146 }
147
147
148 void MainWidget::antiAliasToggled(bool enabled)
148 void MainWidget::antiAliasToggled(bool enabled)
149 {
149 {
150 m_chartView->setRenderHint(QPainter::Antialiasing, enabled);
150 m_chartView->setRenderHint(QPainter::Antialiasing, enabled);
151 }
151 }
152
152
153 void MainWidget::addSeries()
153 void MainWidget::addSeries()
154 {
154 {
155 if (!m_addSerieDialog) {
155 if (!m_addSerieDialog) {
156 m_addSerieDialog = new DataSerieDialog(this);
156 m_addSerieDialog = new DataSerieDialog(this);
157 connect(m_addSerieDialog, SIGNAL(accepted(QString, int, int, QString, bool)),
157 connect(m_addSerieDialog, SIGNAL(accepted(QString, int, int, QString, bool)),
158 this, SLOT(addSeries(QString, int, int, QString, bool)));
158 this, SLOT(addSeries(QString, int, int, QString, bool)));
159 }
159 }
160 m_addSerieDialog->exec();
160 m_addSerieDialog->exec();
161 }
161 }
162
162
163 QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics)
163 QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics)
164 {
164 {
165 // TODO: dataCharacteristics
165 // TODO: dataCharacteristics
166 QList<RealList> testData;
166 QList<RealList> testData;
167 for (int j(0); j < columnCount; j++) {
167 for (int j(0); j < columnCount; j++) {
168 QList <qreal> newColumn;
168 QList <qreal> newColumn;
169 for (int i(0); i < rowCount; i++) {
169 for (int i(0); i < rowCount; i++) {
170 if (dataCharacteristics == "Sin") {
170 if (dataCharacteristics == "Sin") {
171 newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100));
171 newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100));
172 } else if (dataCharacteristics == "Sin + random") {
172 } else if (dataCharacteristics == "Sin + random") {
173 newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5));
173 newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5));
174 } else if (dataCharacteristics == "Random") {
174 } else if (dataCharacteristics == "Random") {
175 newColumn.append(rand() % 10 + (qreal) rand() / (qreal) RAND_MAX);
175 newColumn.append(rand() % 10 + (qreal) rand() / (qreal) RAND_MAX);
176 } else if (dataCharacteristics == "Linear") {
176 } else if (dataCharacteristics == "Linear") {
177 //newColumn.append(i * (j + 1.0));
177 //newColumn.append(i * (j + 1.0));
178 // TODO: temporary hack to make pie work; prevent zero values:
178 // TODO: temporary hack to make pie work; prevent zero values:
179 newColumn.append(i * (j + 1.0) + 0.1);
179 newColumn.append(i * (j + 1.0) + 0.1);
180 } else { // "constant"
180 } else { // "constant"
181 newColumn.append((j + 1.0));
181 newColumn.append((j + 1.0));
182 }
182 }
183 }
183 }
184 testData.append(newColumn);
184 testData.append(newColumn);
185 }
185 }
186 return testData;
186 return testData;
187 }
187 }
188
188
189 QStringList MainWidget::generateLabels(int count)
189 QStringList MainWidget::generateLabels(int count)
190 {
190 {
191 QStringList result;
191 QStringList result;
192 for (int i(0); i < count; i++)
192 for (int i(0); i < count; i++)
193 result.append("label" + QString::number(i));
193 result.append("label" + QString::number(i));
194 return result;
194 return result;
195 }
195 }
196
196
197 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QString dataCharacteristics, bool labelsEnabled)
197 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QString dataCharacteristics, bool labelsEnabled)
198 {
198 {
199 qDebug() << "addSeries: " << seriesName
199 qDebug() << "addSeries: " << seriesName
200 << " columnCount: " << columnCount
200 << " columnCount: " << columnCount
201 << " rowCount: " << rowCount
201 << " rowCount: " << rowCount
202 << " dataCharacteristics: " << dataCharacteristics
202 << " dataCharacteristics: " << dataCharacteristics
203 << " labels enabled: " << labelsEnabled;
203 << " labels enabled: " << labelsEnabled;
204 m_defaultSeriesName = seriesName;
204 m_defaultSeriesName = seriesName;
205
205
206 QList<RealList> data = generateTestData(columnCount, rowCount, dataCharacteristics);
206 QList<RealList> data = generateTestData(columnCount, rowCount, dataCharacteristics);
207
207
208 // Line series and scatter series use similar data
208 // Line series and scatter series use similar data
209 if (seriesName == "Line") {
209 if (seriesName == "Line") {
210 for (int j(0); j < data.count(); j ++) {
210 for (int j(0); j < data.count(); j ++) {
211 QList<qreal> column = data.at(j);
211 QList<qreal> column = data.at(j);
212 QLineSeries *series = new QLineSeries();
212 QLineSeries *series = new QLineSeries();
213 for (int i(0); i < column.count(); i++)
213 for (int i(0); i < column.count(); i++)
214 series->append(i, column.at(i));
214 series->append(i, column.at(i));
215 m_chart->addSeries(series);
215 m_chart->addSeries(series);
216 }
216 }
217 } else if (seriesName == "Area") {
217 } else if (seriesName == "Area") {
218 // TODO: lower series for the area?
218 // TODO: lower series for the area?
219 for (int j(0); j < data.count(); j ++) {
219 for (int j(0); j < data.count(); j ++) {
220 QList<qreal> column = data.at(j);
220 QList<qreal> column = data.at(j);
221 QLineSeries *lineSeries = new QLineSeries();
221 QLineSeries *lineSeries = new QLineSeries();
222 for (int i(0); i < column.count(); i++)
222 for (int i(0); i < column.count(); i++)
223 lineSeries->append(i, column.at(i));
223 lineSeries->append(i, column.at(i));
224 QAreaSeries *areaSeries = new QAreaSeries(lineSeries);
224 QAreaSeries *areaSeries = new QAreaSeries(lineSeries);
225 m_chart->addSeries(areaSeries);
225 m_chart->addSeries(areaSeries);
226 }
226 }
227 } else if (seriesName == "Scatter") {
227 } else if (seriesName == "Scatter") {
228 for (int j(0); j < data.count(); j++) {
228 for (int j(0); j < data.count(); j++) {
229 QList<qreal> column = data.at(j);
229 QList<qreal> column = data.at(j);
230 QScatterSeries *series = new QScatterSeries();
230 QScatterSeries *series = new QScatterSeries();
231 for (int i(0); i < column.count(); i++)
231 for (int i(0); i < column.count(); i++)
232 series->append(i, column.at(i));
232 series->append(i, column.at(i));
233 m_chart->addSeries(series);
233 m_chart->addSeries(series);
234 }
234 }
235 } else if (seriesName == "Pie") {
235 } else if (seriesName == "Pie") {
236 QStringList labels = generateLabels(rowCount);
236 QStringList labels = generateLabels(rowCount);
237 for (int j(0); j < data.count(); j++) {
237 for (int j(0); j < data.count(); j++) {
238 QPieSeries *series = new QPieSeries();
238 QPieSeries *series = new QPieSeries();
239 QList<qreal> column = data.at(j);
239 QList<qreal> column = data.at(j);
240 for (int i(0); i < column.count(); i++)
240 for (int i(0); i < column.count(); i++)
241 series->append(column.at(i), labels.at(i));
241 series->append(column.at(i), labels.at(i));
242 m_chart->addSeries(series);
242 m_chart->addSeries(series);
243 }
243 }
244 } else if (seriesName == "Bar"
244 } else if (seriesName == "Bar"
245 || seriesName == "Stacked bar"
245 || seriesName == "Stacked bar"
246 || seriesName == "Percent bar") {
246 || seriesName == "Percent bar") {
247 QStringList category;
247 QStringList category;
248 QStringList labels = generateLabels(rowCount);
248 QStringList labels = generateLabels(rowCount);
249 foreach(QString label, labels)
249 foreach(QString label, labels)
250 category << label;
250 category << label;
251 QBarSeries* series = 0;
251 QBarSeries* series = 0;
252 if (seriesName == "Bar")
252 if (seriesName == "Bar")
253 series = new QBarSeries(category, this);
253 series = new QBarSeries(category, this);
254 else if (seriesName == "Stacked bar")
254 else if (seriesName == "Stacked bar")
255 series = new QStackedBarSeries(category, this);
255 series = new QStackedBarSeries(category, this);
256 else
256 else
257 series = new QPercentBarSeries(category, this);
257 series = new QPercentBarSeries(category, this);
258
258
259 for (int j(0); j < data.count(); j++) {
259 for (int j(0); j < data.count(); j++) {
260 QList<qreal> column = data.at(j);
260 QList<qreal> column = data.at(j);
261 QBarSet *set = new QBarSet("set" + QString::number(j));
261 QBarSet *set = new QBarSet("set" + QString::number(j));
262 for (int i(0); i < column.count(); i++)
262 for (int i(0); i < column.count(); i++)
263 *set << column.at(i);
263 *set << column.at(i);
264 series->appendBarSet(set);
264 series->appendBarSet(set);
265 }
265 }
266
266
267 // TODO: new implementation of setFloatingValuesEnabled with signals
267 // TODO: new implementation of setFloatingValuesEnabled with signals
268 //series->setFloatingValuesEnabled(true);
268 //series->setFloatingValuesEnabled(true);
269 series->setToolTipEnabled(true);
269 series->setToolTipEnabled(true);
270 m_chart->addSeries(series);
270 m_chart->addSeries(series);
271 } else if (seriesName == "Spline") {
271 } else if (seriesName == "Spline") {
272 for (int j(0); j < data.count(); j ++) {
272 for (int j(0); j < data.count(); j ++) {
273 QList<qreal> column = data.at(j);
273 QList<qreal> column = data.at(j);
274 QSplineSeries *series = new QSplineSeries();
274 QSplineSeries *series = new QSplineSeries();
275 for (int i(0); i < column.count(); i++)
275 for (int i(0); i < column.count(); i++)
276 series->append(i, column.at(i));
276 series->append(i, column.at(i));
277 m_chart->addSeries(series);
277 m_chart->addSeries(series);
278 }
278 }
279 }
279 }
280 }
280 }
281
281
282 void MainWidget::backgroundChanged(int itemIndex)
282 void MainWidget::backgroundChanged(int itemIndex)
283 {
283 {
284 qDebug() << "backgroundChanged: " << itemIndex;
284 qDebug() << "backgroundChanged: " << itemIndex;
285 }
285 }
286
286
287 void MainWidget::autoScaleChanged(int value)
287 void MainWidget::autoScaleChanged(int value)
288 {
288 {
289 if (value) {
289 if (value) {
290 // TODO: enable auto scaling
290 // TODO: enable auto scaling
291 } else {
291 } else {
292 // TODO: set scaling manually (and disable auto scaling)
292 // TODO: set scaling manually (and disable auto scaling)
293 }
293 }
294
294
295 m_xMinSpin->setEnabled(!value);
295 m_xMinSpin->setEnabled(!value);
296 m_xMaxSpin->setEnabled(!value);
296 m_xMaxSpin->setEnabled(!value);
297 m_yMinSpin->setEnabled(!value);
297 m_yMinSpin->setEnabled(!value);
298 m_yMaxSpin->setEnabled(!value);
298 m_yMaxSpin->setEnabled(!value);
299 }
299 }
300
300
301 void MainWidget::xMinChanged(int value)
301 void MainWidget::xMinChanged(int value)
302 {
302 {
303 qDebug() << "xMinChanged: " << value;
303 qDebug() << "xMinChanged: " << value;
304 }
304 }
305
305
306 void MainWidget::xMaxChanged(int value)
306 void MainWidget::xMaxChanged(int value)
307 {
307 {
308 qDebug() << "xMaxChanged: " << value;
308 qDebug() << "xMaxChanged: " << value;
309 }
309 }
310
310
311 void MainWidget::yMinChanged(int value)
311 void MainWidget::yMinChanged(int value)
312 {
312 {
313 qDebug() << "yMinChanged: " << value;
313 qDebug() << "yMinChanged: " << value;
314 }
314 }
315
315
316 void MainWidget::yMaxChanged(int value)
316 void MainWidget::yMaxChanged(int value)
317 {
317 {
318 qDebug() << "yMaxChanged: " << value;
318 qDebug() << "yMaxChanged: " << value;
319 }
319 }
320
320
321 void MainWidget::changeChartTheme(int themeIndex)
321 void MainWidget::changeChartTheme(int themeIndex)
322 {
322 {
323 qDebug() << "changeChartTheme: " << themeIndex;
323 qDebug() << "changeChartTheme: " << themeIndex;
324 m_chart->setTheme((QChart::ChartTheme) themeIndex);
324 m_chart->setTheme((QChart::ChartTheme) themeIndex);
325 //TODO: remove this hack. This is just to make it so that theme change is seen immediately.
326 QSize s = size();
327 s.setWidth(s.width()+1);
328 resize(s);
329 }
325 }
General Comments 0
You need to be logged in to leave comments. Login now