##// END OF EJS Templates
tablemodelchart: axes re-enabled on toggle (pie disables them)
Marek Rosa -
r878:2ebc46308a23
parent child
Show More
@@ -33,6 +33,7
33 #include <QBarSet>
33 #include <QBarSet>
34 #include <QPushButton>
34 #include <QPushButton>
35 #include <QRadioButton>
35 #include <QRadioButton>
36 #include <QLabel>
36 #include <QSpinBox>
37 #include <QSpinBox>
37 #include <QTime>
38 #include <QTime>
38
39
@@ -64,6 +65,8 TableWidget::TableWidget(QWidget *parent)
64 QPushButton* removeRowButton = new QPushButton("Remove row");
65 QPushButton* removeRowButton = new QPushButton("Remove row");
65 connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
66 connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
66
67
68 QLabel *spinBoxLabel = new QLabel("Rows affected:");
69
67 // spin box for setting number of affected items (add, remove)
70 // spin box for setting number of affected items (add, remove)
68 m_linesCountSpinBox = new QSpinBox;
71 m_linesCountSpinBox = new QSpinBox;
69 m_linesCountSpinBox->setRange(1, 10);
72 m_linesCountSpinBox->setRange(1, 10);
@@ -71,6 +74,7 TableWidget::TableWidget(QWidget *parent)
71
74
72 // buttons layout
75 // buttons layout
73 QVBoxLayout* buttonsLayout = new QVBoxLayout;
76 QVBoxLayout* buttonsLayout = new QVBoxLayout;
77 buttonsLayout->addWidget(spinBoxLabel);
74 buttonsLayout->addWidget(m_linesCountSpinBox);
78 buttonsLayout->addWidget(m_linesCountSpinBox);
75 buttonsLayout->addWidget(addRowAboveButton);
79 buttonsLayout->addWidget(addRowAboveButton);
76 buttonsLayout->addWidget(addRowBelowButton);
80 buttonsLayout->addWidget(addRowBelowButton);
@@ -85,12 +89,12 TableWidget::TableWidget(QWidget *parent)
85 m_areaRadioButton = new QRadioButton("Area");
89 m_areaRadioButton = new QRadioButton("Area");
86 m_barRadioButton = new QRadioButton("Bar");
90 m_barRadioButton = new QRadioButton("Bar");
87
91
88 connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
92 connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
89 connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
93 connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
90 connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
94 connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
91 connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
95 connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
92 connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
96 connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
93 connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
97 connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
94 m_lineRadioButton->setChecked(true);
98 m_lineRadioButton->setChecked(true);
95
99
96 // radio buttons layout
100 // radio buttons layout
@@ -130,9 +134,26 void TableWidget::removeRow()
130 m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value()));
134 m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value()));
131 }
135 }
132
136
133 void TableWidget::updateChartType()
137 void TableWidget::updateChartType(bool toggle)
134 {
138 {
139 // this if is needed, so that the function is only called once.
140 // For the radioButton that was enabled.
141 if (toggle) {
135 m_chart->removeAllSeries();
142 m_chart->removeAllSeries();
143
144 // renable axes of the chart (pie hides them)
145 // x axis
146 QChartAxis *axis = m_chart->axisX();
147 axis->setAxisVisible(true);
148 axis->setGridLineVisible(true);
149 axis->setLabelsVisible(true);
150
151 // y axis
152 axis = m_chart->axisY();
153 axis->setAxisVisible(true);
154 axis->setGridLineVisible(true);
155 axis->setLabelsVisible(true);
156
136 m_model->clearMapping();
157 m_model->clearMapping();
137
158
138 QString seriesColorHex = "#000000";
159 QString seriesColorHex = "#000000";
@@ -304,6 +325,7 void TableWidget::updateChartType()
304 m_tableView->repaint();
325 m_tableView->repaint();
305 m_tableView->setFocus();
326 m_tableView->setFocus();
306 }
327 }
328 }
307
329
308 TableWidget::~TableWidget()
330 TableWidget::~TableWidget()
309 {
331 {
@@ -46,7 +46,7 public:
46 void addRowAbove();
46 void addRowAbove();
47 void addRowBelow();
47 void addRowBelow();
48 void removeRow();
48 void removeRow();
49 void updateChartType();
49 void updateChartType(bool toggle);
50
50
51 private:
51 private:
52 QChartView* m_chartView;
52 QChartView* m_chartView;
General Comments 0
You need to be logged in to leave comments. Login now