##// END OF EJS Templates
Use labelBrush instead of labelPen for text labels
Use labelBrush instead of labelPen for text labels

File last commit:

r1276:2661cb767b8b
r1307:7b3a3ea4ca65
Show More
dataseriedialog.cpp
190 lines | 6.2 KiB | text/x-c | CppLexer
Jani Honkonen
Add/modify license headers
r830 /****************************************************************************
**
** 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$
**
****************************************************************************/
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 #include "dataseriedialog.h"
#include <QDialogButtonBox>
Tero Ahola
Test app now adds n data series of different type
r20 #include <QGridLayout>
Michal Klocek
minor.typo
r292 #include <QCheckBox>
Tero Ahola
Test app now adds n data series of different type
r20 #include <QPushButton>
Tero Ahola
Refactored chartwidgettest test data impl
r278 #include <QGroupBox>
#include <QRadioButton>
Tero Ahola
Test app now adds n data series of different type
r20 #include <QLabel>
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 #include <QDebug>
Tero Ahola
Add dialog of chartwidgettest now remembers selections
r376 DataSerieDialog::DataSerieDialog(QWidget *parent) :
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 QDialog(parent)
{
Tero Ahola
Test app now adds n data series of different type
r20 QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal);
QPushButton *b = addSeriesBox->addButton(QDialogButtonBox::Ok);
connect(b, SIGNAL(clicked()), this, SLOT(accept()));
b = addSeriesBox->addButton(QDialogButtonBox::Cancel);
connect(b, SIGNAL(clicked()), this, SLOT(reject()));
QGridLayout *grid = new QGridLayout();
Tero Ahola
Refactored chartwidgettest test data impl
r278
m_seriesTypeSelector = seriesTypeSelector();
m_columnCountSelector = columnCountSelector();
m_rowCountSelector = rowCountSelector();
m_dataCharacteristicsSelector = dataCharacteristicsSelector();
grid->addWidget(m_seriesTypeSelector, 0, 0);
grid->addWidget(m_columnCountSelector, 0, 1);
grid->addWidget(m_rowCountSelector, 1, 1);
grid->addWidget(m_dataCharacteristicsSelector, 1, 0);
m_labelsSelector = new QCheckBox("Labels defined");
m_labelsSelector->setChecked(true);
grid->addWidget(m_labelsSelector, 2, 0);
grid->addWidget(addSeriesBox, 3, 1);
Tero Ahola
Test app now adds n data series of different type
r20
setLayout(grid);
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 }
Tero Ahola
Refactored chartwidgettest test data impl
r278 QGroupBox *DataSerieDialog::seriesTypeSelector()
{
QVBoxLayout *layout = new QVBoxLayout();
Tero Ahola
Restored bar series in chartwidgettest
r279 QRadioButton *line = new QRadioButton("Line");
Tero Ahola
Refactored chartwidgettest test data impl
r278 line->setChecked(true);
layout->addWidget(line);
Tero Ahola
Restored bar series in chartwidgettest
r279 layout->addWidget(new QRadioButton("Area"));
layout->addWidget(new QRadioButton("Pie"));
layout->addWidget(new QRadioButton("Bar"));
Tero Ahola
Added grouped bar series to chart widget test
r1223 layout->addWidget(new QRadioButton("Grouped bar"));
Tero Ahola
Restored bar series in chartwidgettest
r279 layout->addWidget(new QRadioButton("Stacked bar"));
layout->addWidget(new QRadioButton("Percent bar"));
layout->addWidget(new QRadioButton("Scatter"));
layout->addWidget(new QRadioButton("Spline"));
Tero Ahola
Refactored chartwidgettest test data impl
r278
QGroupBox *groupBox = new QGroupBox("Series type");
groupBox->setLayout(layout);
Tero Ahola
Add dialog of chartwidgettest now remembers selections
r376 selectRadio(groupBox, 0);
Tero Ahola
Refactored chartwidgettest test data impl
r278
return groupBox;
}
QGroupBox *DataSerieDialog::columnCountSelector()
{
QVBoxLayout *layout = new QVBoxLayout();
QRadioButton *radio = new QRadioButton("1");
radio->setChecked(true);
layout->addWidget(radio);
layout->addWidget(new QRadioButton("2"));
layout->addWidget(new QRadioButton("3"));
Tero Ahola
Bar series to use theme base colors. Pie brush minor fix....
r661 layout->addWidget(new QRadioButton("4"));
Tero Ahola
Refactored chartwidgettest test data impl
r278 layout->addWidget(new QRadioButton("5"));
Tero Ahola
Bar series to use theme base colors. Pie brush minor fix....
r661 layout->addWidget(new QRadioButton("8"));
Tero Ahola
Refactored chartwidgettest test data impl
r278 layout->addWidget(new QRadioButton("10"));
layout->addWidget(new QRadioButton("100"));
QGroupBox *groupBox = new QGroupBox("Column count");
groupBox->setLayout(layout);
Tero Ahola
Add dialog of chartwidgettest now remembers selections
r376 selectRadio(groupBox, 0);
Tero Ahola
Refactored chartwidgettest test data impl
r278
return groupBox;
}
QGroupBox *DataSerieDialog::rowCountSelector()
{
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(new QRadioButton("1"));
QRadioButton *radio = new QRadioButton("10");
radio->setChecked(true);
layout->addWidget(radio);
layout->addWidget(new QRadioButton("50"));
layout->addWidget(new QRadioButton("100"));
Tero Ahola
Scatter customization to QML api
r1276 layout->addWidget(new QRadioButton("1000"));
Tero Ahola
Refactored chartwidgettest test data impl
r278 layout->addWidget(new QRadioButton("10000"));
Tero Ahola
Bar series to use theme base colors. Pie brush minor fix....
r661 layout->addWidget(new QRadioButton("100000"));
Tero Ahola
Refactored chartwidgettest test data impl
r278 layout->addWidget(new QRadioButton("1000000"));
QGroupBox *groupBox = new QGroupBox("Row count");
groupBox->setLayout(layout);
Tero Ahola
Add dialog of chartwidgettest now remembers selections
r376 selectRadio(groupBox, 0);
Tero Ahola
Refactored chartwidgettest test data impl
r278
return groupBox;
}
QGroupBox *DataSerieDialog::dataCharacteristicsSelector()
{
QVBoxLayout *layout = new QVBoxLayout();
Tero Ahola
Add dialog of chartwidgettest now remembers selections
r376 layout->addWidget(new QRadioButton("Linear"));
Tero Ahola
Refactored chartwidgettest test data impl
r278 layout->addWidget(new QRadioButton("Constant"));
layout->addWidget(new QRadioButton("Random"));
layout->addWidget(new QRadioButton("Sin"));
layout->addWidget(new QRadioButton("Sin + random"));
QGroupBox *groupBox = new QGroupBox("Data Characteristics");
groupBox->setLayout(layout);
Tero Ahola
Add dialog of chartwidgettest now remembers selections
r376 selectRadio(groupBox, 0);
Tero Ahola
Refactored chartwidgettest test data impl
r278
return groupBox;
}
Tero Ahola
Test app now adds n data series of different type
r20 void DataSerieDialog::accept()
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 {
Tero Ahola
Refactored chartwidgettest test data impl
r278 accepted(radioSelection(m_seriesTypeSelector),
radioSelection(m_columnCountSelector).toInt(),
radioSelection(m_rowCountSelector).toInt(),
radioSelection(m_dataCharacteristicsSelector),
m_labelsSelector->isChecked());
Tero Ahola
Test app now adds n data series of different type
r20 QDialog::accept();
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 }
Tero Ahola
Refactored chartwidgettest test data impl
r278
Tero Ahola
Add dialog of chartwidgettest now remembers selections
r376 void DataSerieDialog::selectRadio(QGroupBox *groupBox, int defaultSelection)
{
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout());
Q_ASSERT(layout);
Q_ASSERT(layout->count());
QLayoutItem *item = 0;
if (defaultSelection == -1) {
item = layout->itemAt(0);
} else if (layout->count() > defaultSelection) {
item = layout->itemAt(defaultSelection);
}
Q_ASSERT(item);
QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget());
Q_ASSERT(radio);
radio->setChecked(true);
}
Tero Ahola
Refactored chartwidgettest test data impl
r278 QString DataSerieDialog::radioSelection(QGroupBox *groupBox)
{
QString selection;
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout());
Q_ASSERT(layout);
for (int i(0); i < layout->count(); i++) {
QLayoutItem *item = layout->itemAt(i);
Q_ASSERT(item);
QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget());
Q_ASSERT(radio);
if (radio->isChecked()) {
selection = radio->text();
break;
}
}
qDebug() << "radioSelection: " << selection;
return selection;
}