Commit a7eda770 by Tobias Fella

### Port to Qt6

parent e111f222
 ... ... @@ -14,6 +14,7 @@ /* these includes are needed for Qt support */ #include #include #include #ifdef DEBUG #include ... ... @@ -190,12 +191,12 @@ void ExerciseCompare::update() void ExerciseCompare::createTask() { // generate the first ratio m_firstRatio = Ratio(int ((double(qrand()) / RAND_MAX) * 10 + 1), int ((double(qrand()) / RAND_MAX) * 10 + 1)); m_firstRatio = Ratio(QRandomGenerator::global()->bounded(10) + 1, QRandomGenerator::global()->bounded(10) + 1); // now the second ratio, but make sure, the second ratio is different from // the first one do { m_secondRatio = Ratio(int ((double(qrand()) / RAND_MAX) * 10 + 1), int ((double(qrand()) / RAND_MAX) * 10 + 1)); m_secondRatio = Ratio(QRandomGenerator::global()->bounded(10) + 1, QRandomGenerator::global()->bounded(10) + 1); } while (m_firstRatio == m_secondRatio); return; ... ...
 ... ... @@ -19,6 +19,7 @@ #include #include #include #include #ifdef DEBUG #include ... ... @@ -196,7 +197,7 @@ void ExerciseConvert::createTask() { // the tasks are hardcoded here; there are some algorithms to convert // rational numbers to fractions, but it is not worth the effort here switch (int ((double(qrand()) / RAND_MAX) * 19 )) { switch (QRandomGenerator::global()->bounded(19)) { case 0 : m_number = QLocale().toString(0.5, 'f', 1); m_periodStart = 2; m_periodLength = 0; ... ...
 ... ... @@ -16,6 +16,7 @@ #include #include #include #include #ifdef DEBUG #include ... ... @@ -317,7 +318,7 @@ void ExerciseFactorize::createTask() PrimeNumber tmp_primenumber; // just pick one number out of the possible numbers to factorize m_taskNumber = possibleTasks[uint((double(qrand()) / RAND_MAX) * numberPossibleTasks)]; m_taskNumber = possibleTasks[QRandomGenerator::global()->bounded(numberPossibleTasks)]; // now get the primefactors of the taskNumber m_factorsResult.clear(); ... ...
 ... ... @@ -18,6 +18,7 @@ #include #include #include #include #ifdef DEBUG #include ... ... @@ -203,13 +204,13 @@ void ExerciseMixedNumbers::createTask() int denominator = 1; do { // numerator should be between 1..15 numerator = int ((double(qrand()) / RAND_MAX) * 15 + 1); numerator = QRandomGenerator::global()->bounded(15) + 1; // denominator should be between 1..(numerator-1) denominator = int ((double(qrand()) / RAND_MAX) * numerator); denominator = QRandomGenerator::global()->bounded(numerator); // eventually make ratio negative if (double(qrand()) / RAND_MAX >= 0.5) { if (QRandomGenerator::global()->bounded(2) == 1) { numerator *= -1; } tmpRatio.setRatio(numerator, denominator); ... ...
 ... ... @@ -15,6 +15,7 @@ #include #include #include #include #ifdef DEBUG #include ... ... @@ -183,7 +184,7 @@ void ExercisePercentage::createTask() { // the tasks are hardcoded here; there are some algorithms to convert // rational numbers to fractions, but it is not worth the effort here switch (int ((double(qrand()) / RAND_MAX) * 19)) { switch (QRandomGenerator::global()->bounded(19)) { case 0 : //m_number = QLocale().toString(0.5, 'f', 1); m_numberPercentage = QStringLiteral("75"); ... ...
 ... ... @@ -26,6 +26,7 @@ #include #include #include #include #ifdef DEBUG #include ... ... @@ -402,16 +403,16 @@ void FractionRingWidget::NewTask() void FractionRingWidget::resetFraction(bool flag = true) { int denominator = int ((double(qrand()) / RAND_MAX) * 5) + 2; int numerator = int ((double(qrand()) / RAND_MAX) * (denominator - 1)) + 1; int denominator = QRandomGenerator::global()->bounded(5) + 2; int numerator = QRandomGenerator::global()->bounded(denominator - 1) + 1; rLeft = Ratio(numerator, denominator, false); int denominator2 = int ((double(qrand()) / RAND_MAX) * 5) + 2; int denominator2 = QRandomGenerator::global()->bounded(5) + 2; while (denominator2 == denominator) { denominator2 = int ((double(qrand()) / RAND_MAX) * 5) + 2; denominator2 = QRandomGenerator::global()->bounded(5) + 2; } int numerator2 = int ((double(qrand()) / RAND_MAX) * (denominator2 - 1)) + 1; int numerator2 = QRandomGenerator::global()->bounded(denominator2 - 1) + 1; rRight = Ratio(numerator2, denominator2, false); multLeft = 1; ... ...
 ... ... @@ -31,8 +31,6 @@ /* the main program */ int main(int argc, char * argv[]) { // init random generator qsrand(time(nullptr)); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif ... ...