MCPcopy Create free account
hub / github.com/KDE/labplot / loadDataColumns

Method loadDataColumns

src/frontend/dockwidgets/BoxPlotDock.cpp:197–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197void BoxPlotDock::loadDataColumns() {
198 // add the combobox for the first column, is always present
199 if (m_dataComboBoxes.count() == 0)
200 addDataColumn();
201
202 int count = m_boxPlot->dataColumns().count();
203 ui.cbNumber->clear();
204
205 auto* model = aspectModel();
206 if (count != 0) {
207 // box plot has already data columns, make sure we have the proper number of comboboxes
208 int diff = count - m_dataComboBoxes.count();
209 if (diff > 0) {
210 for (int i = 0; i < diff; ++i)
211 addDataColumn();
212 } else if (diff < 0) {
213 for (int i = diff; i != 0; ++i)
214 removeDataColumn();
215 }
216
217 // show the columns in the comboboxes
218 for (int i = 0; i < count; ++i) {
219 m_dataComboBoxes.at(i)->setModel(model); // the model might have changed in-between, reset the current model
220 m_dataComboBoxes.at(i)->setAspect(m_boxPlot->dataColumns().at(i), m_boxPlot->dataColumnPaths().at(i));
221 }
222
223 // show columns names in the combobox for the selection of the box to be modified
224 for (int i = 0; i < count; ++i)
225 if (m_boxPlot->dataColumns().at(i))
226 ui.cbNumber->addItem(m_boxPlot->dataColumns().at(i)->name());
227 } else {
228 // no data columns set in the box plot yet, we show the first combo box only and reset its model
229 m_dataComboBoxes.first()->setModel(model);
230 m_dataComboBoxes.first()->setAspect(nullptr);
231 for (int i = 1; i < m_dataComboBoxes.count(); ++i)
232 removeDataColumn();
233 }
234
235 // disable data column widgets if we're modifying more than one box plot at the same time
236 bool enabled = (m_boxPlots.count() == 1);
237 m_buttonNew->setVisible(enabled);
238 for (auto* cb : m_dataComboBoxes)
239 cb->setEnabled(enabled);
240 for (auto* b : m_removeButtons)
241 b->setVisible(enabled);
242
243 // select the first column after all of them were added to the combobox
244 ui.cbNumber->setCurrentIndex(0);
245}
246
247void BoxPlotDock::setDataColumns() const {
248 QVector<const AbstractColumn*> columns;

Callers

nothing calls this directly

Calls 8

setAspectMethod · 0.80
countMethod · 0.45
clearMethod · 0.45
setModelMethod · 0.45
nameMethod · 0.45
setVisibleMethod · 0.45
setEnabledMethod · 0.45
setCurrentIndexMethod · 0.45

Tested by

no test coverage detected