| 333 | } |
| 334 | |
| 335 | void 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); |
nothing calls this directly
no test coverage detected