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

Method loadDataColumns

src/frontend/dockwidgets/BarPlotDock.cpp:175–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void BarPlotDock::loadDataColumns() {
176 // add the combobox for the first column, is always present
177 if (m_dataComboBoxes.count() == 0)
178 addDataColumn();
179
180 int count = m_barPlot->dataColumns().count();
181 ui.cbNumber->clear();
182 ui.cbErrorBarsNumber->clear();
183
184 auto* model = aspectModel();
185 if (count != 0) {
186 // box plot has already data columns, make sure we have the proper number of comboboxes
187 int diff = count - m_dataComboBoxes.count();
188 if (diff > 0) {
189 for (int i = 0; i < diff; ++i)
190 addDataColumn();
191 } else if (diff < 0) {
192 for (int i = diff; i != 0; ++i)
193 removeDataColumn();
194 }
195
196 // show the columns in the comboboxes
197 for (int i = 0; i < count; ++i) {
198 m_dataComboBoxes.at(i)->setModel(model); // the model might have changed in-between, reset the current model
199 m_dataComboBoxes.at(i)->setAspect(m_barPlot->dataColumns().at(i), m_barPlot->dataColumnPaths().at(i));
200 }
201
202 // show columns names in the combobox for the selection of the bar to be modified
203 for (int i = 0; i < count; ++i)
204 if (m_barPlot->dataColumns().at(i)) {
205 const auto& name = m_barPlot->dataColumns().at(i)->name();
206 ui.cbNumber->addItem(name);
207 ui.cbErrorBarsNumber->addItem(name);
208 }
209 } else {
210 // no data columns set in the box plot yet, we show the first combo box only and reset its model
211 m_dataComboBoxes.first()->setModel(model);
212 m_dataComboBoxes.first()->setAspect(nullptr);
213 for (int i = 0; i < m_dataComboBoxes.count(); ++i)
214 removeDataColumn();
215 }
216
217 // disable data column widgets if we're modifying more than one box plot at the same time
218 bool enabled = (m_barPlots.count() == 1);
219 m_buttonNew->setVisible(enabled);
220 for (auto* cb : m_dataComboBoxes)
221 cb->setEnabled(enabled);
222 for (auto* b : m_removeButtons)
223 b->setVisible(enabled);
224
225 // select the first column after all of them were added to the combobox
226 ui.cbNumber->setCurrentIndex(0);
227 ui.cbErrorBarsNumber->setCurrentIndex(0);
228}
229
230void BarPlotDock::setDataColumns() const {
231 int newCount = m_dataComboBoxes.count();

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