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

Method generate

src/frontend/spreadsheet/EquidistantValuesDialog.cpp:335–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335void EquidistantValuesDialog::generate() {
336 QVector<int> newIntData;
337 QVector<qint64> newBigIntData;
338 QVector<double> newDoubleData;
339 QVector<QDateTime> newDateTimeData;
340 bool integerModePossible = false;
341 bool bigIntRequired = false;
342
343 WAIT_CURSOR;
344 bool rc = true;
345 if (m_hasNumeric) {
346 int number{0};
347 double increment{0};
348
349 // check the validness of the user input for numeric values
350 const auto numberLocale = QLocale();
351 bool ok;
352 const double start = numberLocale.toDouble(ui.leFrom->text(), &ok);
353 if (!ok) {
354 DEBUG("Invalid double value for 'start'!")
355 RESET_CURSOR;
356 return;
357 }
358
359 const auto type = static_cast<Type>(ui.cbType->currentData().toInt());
360 double end = 0.;
361 if (type != Type::FixedNumberIncrement) {
362 end = numberLocale.toDouble(ui.leTo->text(), &ok);
363 if (!ok) {
364 DEBUG("Invalid double value for 'end'!")
365 RESET_CURSOR;
366 return;
367 }
368 }
369
370 switch (type) {
371 case Type::FixedNumber: {
372 // fixed number -> determine the increment
373 number = QLocale().toInt(ui.leNumber->text(), &ok);
374 if (!ok || number == 1) {
375 DEBUG("Invalid integer value for 'number'!")
376 RESET_CURSOR;
377 return;
378 }
379
380 increment = (end - start) / (number - 1);
381 break;
382 }
383 case Type::FixedIncrement: {
384 // fixed increment -> determine the number
385 increment = QLocale().toDouble(ui.leIncrement->text(), &ok);
386 if (ok)
387 number = (end - start) / increment + 1;
388 break;
389 }
390 case Type::FixedNumberIncrement: {
391 // fixed number and increment -> determine the end value
392 number = QLocale().toInt(ui.leNumber->text(), &ok);

Callers

nothing calls this directly

Calls 15

beginMacroMethod · 0.80
clearFormulaMethod · 0.80
setIntegersMethod · 0.80
setBigIntsMethod · 0.80
setDateTimesMethod · 0.80
endMacroMethod · 0.80
QDateTimeClass · 0.50
textMethod · 0.45
dateTimeMethod · 0.45
nameMethod · 0.45
sizeMethod · 0.45
rowCountMethod · 0.45

Tested by

no test coverage detected