##// 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 33 #include <QBarSet>
34 34 #include <QPushButton>
35 35 #include <QRadioButton>
36 #include <QLabel>
36 37 #include <QSpinBox>
37 38 #include <QTime>
38 39
@@ -64,6 +65,8 TableWidget::TableWidget(QWidget *parent)
64 65 QPushButton* removeRowButton = new QPushButton("Remove row");
65 66 connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
66 67
68 QLabel *spinBoxLabel = new QLabel("Rows affected:");
69
67 70 // spin box for setting number of affected items (add, remove)
68 71 m_linesCountSpinBox = new QSpinBox;
69 72 m_linesCountSpinBox->setRange(1, 10);
@@ -71,6 +74,7 TableWidget::TableWidget(QWidget *parent)
71 74
72 75 // buttons layout
73 76 QVBoxLayout* buttonsLayout = new QVBoxLayout;
77 buttonsLayout->addWidget(spinBoxLabel);
74 78 buttonsLayout->addWidget(m_linesCountSpinBox);
75 79 buttonsLayout->addWidget(addRowAboveButton);
76 80 buttonsLayout->addWidget(addRowBelowButton);
@@ -85,12 +89,12 TableWidget::TableWidget(QWidget *parent)
85 89 m_areaRadioButton = new QRadioButton("Area");
86 90 m_barRadioButton = new QRadioButton("Bar");
87 91
88 connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
89 connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
90 connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
91 connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
92 connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
93 connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
92 connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
93 connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
94 connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
95 connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
96 connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
97 connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
94 98 m_lineRadioButton->setChecked(true);
95 99
96 100 // radio buttons layout
@@ -130,9 +134,26 void TableWidget::removeRow()
130 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 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 157 m_model->clearMapping();
137 158
138 159 QString seriesColorHex = "#000000";
@@ -304,6 +325,7 void TableWidget::updateChartType()
304 325 m_tableView->repaint();
305 326 m_tableView->setFocus();
306 327 }
328 }
307 329
308 330 TableWidget::~TableWidget()
309 331 {
@@ -46,7 +46,7 public:
46 46 void addRowAbove();
47 47 void addRowBelow();
48 48 void removeRow();
49 void updateChartType();
49 void updateChartType(bool toggle);
50 50
51 51 private:
52 52 QChartView* m_chartView;
General Comments 0
You need to be logged in to leave comments. Login now