@@ -8,7 +8,7 | |||||
8 | #include <QLabel> |
|
8 | #include <QLabel> | |
9 | #include <QDebug> |
|
9 | #include <QDebug> | |
10 |
|
10 | |||
11 |
DataSerieDialog::DataSerieDialog( |
|
11 | DataSerieDialog::DataSerieDialog(QWidget *parent) : | |
12 | QDialog(parent) |
|
12 | QDialog(parent) | |
13 | { |
|
13 | { | |
14 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal); |
|
14 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal); | |
@@ -53,6 +53,7 QGroupBox *DataSerieDialog::seriesTypeSelector() | |||||
53 |
|
53 | |||
54 | QGroupBox *groupBox = new QGroupBox("Series type"); |
|
54 | QGroupBox *groupBox = new QGroupBox("Series type"); | |
55 | groupBox->setLayout(layout); |
|
55 | groupBox->setLayout(layout); | |
|
56 | selectRadio(groupBox, 0); | |||
56 |
|
57 | |||
57 | return groupBox; |
|
58 | return groupBox; | |
58 | } |
|
59 | } | |
@@ -72,6 +73,7 QGroupBox *DataSerieDialog::columnCountSelector() | |||||
72 |
|
73 | |||
73 | QGroupBox *groupBox = new QGroupBox("Column count"); |
|
74 | QGroupBox *groupBox = new QGroupBox("Column count"); | |
74 | groupBox->setLayout(layout); |
|
75 | groupBox->setLayout(layout); | |
|
76 | selectRadio(groupBox, 0); | |||
75 |
|
77 | |||
76 | return groupBox; |
|
78 | return groupBox; | |
77 | } |
|
79 | } | |
@@ -91,6 +93,7 QGroupBox *DataSerieDialog::rowCountSelector() | |||||
91 |
|
93 | |||
92 | QGroupBox *groupBox = new QGroupBox("Row count"); |
|
94 | QGroupBox *groupBox = new QGroupBox("Row count"); | |
93 | groupBox->setLayout(layout); |
|
95 | groupBox->setLayout(layout); | |
|
96 | selectRadio(groupBox, 0); | |||
94 |
|
97 | |||
95 | return groupBox; |
|
98 | return groupBox; | |
96 | } |
|
99 | } | |
@@ -99,9 +102,7 QGroupBox *DataSerieDialog::dataCharacteristicsSelector() | |||||
99 | { |
|
102 | { | |
100 | QVBoxLayout *layout = new QVBoxLayout(); |
|
103 | QVBoxLayout *layout = new QVBoxLayout(); | |
101 |
|
104 | |||
102 |
|
|
105 | layout->addWidget(new QRadioButton("Linear")); | |
103 | radio1->setChecked(true); |
|
|||
104 | layout->addWidget(radio1); |
|
|||
105 | layout->addWidget(new QRadioButton("Constant")); |
|
106 | layout->addWidget(new QRadioButton("Constant")); | |
106 | layout->addWidget(new QRadioButton("Random")); |
|
107 | layout->addWidget(new QRadioButton("Random")); | |
107 | layout->addWidget(new QRadioButton("Sin")); |
|
108 | layout->addWidget(new QRadioButton("Sin")); | |
@@ -109,6 +110,7 QGroupBox *DataSerieDialog::dataCharacteristicsSelector() | |||||
109 |
|
110 | |||
110 | QGroupBox *groupBox = new QGroupBox("Data Characteristics"); |
|
111 | QGroupBox *groupBox = new QGroupBox("Data Characteristics"); | |
111 | groupBox->setLayout(layout); |
|
112 | groupBox->setLayout(layout); | |
|
113 | selectRadio(groupBox, 0); | |||
112 |
|
114 | |||
113 | return groupBox; |
|
115 | return groupBox; | |
114 | } |
|
116 | } | |
@@ -123,6 +125,24 void DataSerieDialog::accept() | |||||
123 | QDialog::accept(); |
|
125 | QDialog::accept(); | |
124 | } |
|
126 | } | |
125 |
|
127 | |||
|
128 | void DataSerieDialog::selectRadio(QGroupBox *groupBox, int defaultSelection) | |||
|
129 | { | |||
|
130 | QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout()); | |||
|
131 | Q_ASSERT(layout); | |||
|
132 | Q_ASSERT(layout->count()); | |||
|
133 | ||||
|
134 | QLayoutItem *item = 0; | |||
|
135 | if (defaultSelection == -1) { | |||
|
136 | item = layout->itemAt(0); | |||
|
137 | } else if (layout->count() > defaultSelection) { | |||
|
138 | item = layout->itemAt(defaultSelection); | |||
|
139 | } | |||
|
140 | Q_ASSERT(item); | |||
|
141 | QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget()); | |||
|
142 | Q_ASSERT(radio); | |||
|
143 | radio->setChecked(true); | |||
|
144 | } | |||
|
145 | ||||
126 | QString DataSerieDialog::radioSelection(QGroupBox *groupBox) |
|
146 | QString DataSerieDialog::radioSelection(QGroupBox *groupBox) | |
127 | { |
|
147 | { | |
128 | QString selection; |
|
148 | QString selection; |
@@ -10,7 +10,7 class DataSerieDialog : public QDialog | |||||
10 | { |
|
10 | { | |
11 | Q_OBJECT |
|
11 | Q_OBJECT | |
12 | public: |
|
12 | public: | |
13 |
explicit DataSerieDialog( |
|
13 | explicit DataSerieDialog(QWidget *parent = 0); | |
14 |
|
14 | |||
15 | signals: |
|
15 | signals: | |
16 | void accepted(QString series, int columnCount, int rowCount, QString dataCharacteristics, bool labelsDefined); |
|
16 | void accepted(QString series, int columnCount, int rowCount, QString dataCharacteristics, bool labelsDefined); | |
@@ -23,6 +23,7 private: | |||||
23 | QGroupBox *columnCountSelector(); |
|
23 | QGroupBox *columnCountSelector(); | |
24 | QGroupBox *rowCountSelector(); |
|
24 | QGroupBox *rowCountSelector(); | |
25 | QGroupBox *dataCharacteristicsSelector(); |
|
25 | QGroupBox *dataCharacteristicsSelector(); | |
|
26 | void selectRadio(QGroupBox *groupBox, int defaultSelection); | |||
26 | QString radioSelection(QGroupBox *groupBox); |
|
27 | QString radioSelection(QGroupBox *groupBox); | |
27 | QGroupBox *m_seriesTypeSelector; |
|
28 | QGroupBox *m_seriesTypeSelector; | |
28 | QGroupBox *m_columnCountSelector; |
|
29 | QGroupBox *m_columnCountSelector; |
@@ -25,7 +25,9 | |||||
25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |
26 |
|
26 | |||
27 | MainWidget::MainWidget(QWidget *parent) : |
|
27 | MainWidget::MainWidget(QWidget *parent) : | |
28 | QWidget(parent) |
|
28 | QWidget(parent), | |
|
29 | m_addSerieDialog(0), | |||
|
30 | m_chartWidget(0) | |||
29 | { |
|
31 | { | |
30 | m_chartWidget = new QChartView(this); |
|
32 | m_chartWidget = new QChartView(this); | |
31 | m_chartWidget->setRubberBandPolicy(QChartView::HorizonalRubberBand); |
|
33 | m_chartWidget->setRubberBandPolicy(QChartView::HorizonalRubberBand); | |
@@ -163,10 +165,12 void MainWidget::initPieControls() | |||||
163 |
|
165 | |||
164 | void MainWidget::addSeries() |
|
166 | void MainWidget::addSeries() | |
165 | { |
|
167 | { | |
166 | DataSerieDialog dialog(m_defaultSeriesName, this); |
|
168 | if (!m_addSerieDialog) { | |
167 | connect(&dialog, SIGNAL(accepted(QString, int, int, QString, bool)), |
|
169 | m_addSerieDialog = new DataSerieDialog(this); | |
168 |
|
|
170 | connect(m_addSerieDialog, SIGNAL(accepted(QString, int, int, QString, bool)), | |
169 | dialog.exec(); |
|
171 | this, SLOT(addSeries(QString, int, int, QString, bool))); | |
|
172 | } | |||
|
173 | m_addSerieDialog->exec(); | |||
170 | } |
|
174 | } | |
171 |
|
175 | |||
172 | QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics) |
|
176 | QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics) |
@@ -12,6 +12,7 class QGridLayout; | |||||
12 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
12 | QTCOMMERCIALCHART_USE_NAMESPACE | |
13 |
|
13 | |||
14 | #define RealList QList<qreal> |
|
14 | #define RealList QList<qreal> | |
|
15 | class DataSerieDialog; | |||
15 |
|
16 | |||
16 | class MainWidget : public QWidget |
|
17 | class MainWidget : public QWidget | |
17 | { |
|
18 | { | |
@@ -44,6 +45,7 private slots: | |||||
44 | QStringList generateLabels(int count); |
|
45 | QStringList generateLabels(int count); | |
45 |
|
46 | |||
46 | private: |
|
47 | private: | |
|
48 | DataSerieDialog *m_addSerieDialog; | |||
47 | QChartView *m_chartWidget; |
|
49 | QChartView *m_chartWidget; | |
48 | QCheckBox *m_autoScaleCheck; |
|
50 | QCheckBox *m_autoScaleCheck; | |
49 | QSpinBox *m_xMinSpin; |
|
51 | QSpinBox *m_xMinSpin; |
General Comments 0
You need to be logged in to leave comments.
Login now