diff --git a/src/canvas.cpp b/src/canvas.cpp --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -116,9 +116,9 @@ QColor Canvas::rgbDoublesToColor(double r, double g, double b) { - return QColor(qMin(qMax((int)r, 0), 255), - qMin(qMax((int)g, 0), 255), - qMin(qMax((int)b, 0), 255)); + return QColor(qMin(qMax(static_cast(r), 0), 255), + qMin(qMax(static_cast(g), 0), 255), + qMin(qMax(static_cast(b), 0), 255)); } void Canvas::drawLine(double x1, double y1, double x2, double y2) @@ -164,7 +164,7 @@ void Canvas::slotPenWidth(double width) { - int w = qMax(ROUND2INT(width), 0); + int w = qMax(ROUND2INT(width), 0); if (w == 0) { penWidthIsZero = true; return; @@ -180,7 +180,7 @@ void Canvas::slotPenColor(double r, double g, double b) { pen->setColor(rgbDoublesToColor(r, g, b)); - textColor.setRgb((int)r, (int)g, (int)b); + textColor.setRgb(static_cast(r), static_cast(g), static_cast(b)); } void Canvas::slotCanvasColor(double r, double g, double b) @@ -225,7 +225,7 @@ void Canvas::wheelEvent(QWheelEvent *event) { - scaleView(std::pow((double)2.0, -event->delta() / 240.0)); + scaleView(std::pow(static_cast(2.0), -event->delta() / 240.0)); } void Canvas::scaleView(double scaleFactor) diff --git a/src/colorpicker.cpp b/src/colorpicker.cpp --- a/src/colorpicker.cpp +++ b/src/colorpicker.cpp @@ -86,7 +86,7 @@ blueSlider->setMaximum(255); blueSpin = new QSpinBox(this); blueSpin->setMaximum(255); - QLabel* blueLabel = new QLabel(i18n("Amount blue:")); + QLabel* blueLabel = new QLabel(i18n("Amount blue:")); blueLabel->setBuddy(blueSpin); gridLayout->addWidget(blueLabel, 2, 0); gridLayout->addWidget(blueSlider, 2, 1); diff --git a/src/directiondialog.cpp b/src/directiondialog.cpp --- a/src/directiondialog.cpp +++ b/src/directiondialog.cpp @@ -264,7 +264,7 @@ previousDirectionSpin->setRange(-360, 720); previousDirectionSpin->setWrapping(true); previousDirectionSpin->setSingleStep(10); - previousDirectionSpin->setValue((int)deg); + previousDirectionSpin->setValue(static_cast(deg)); rightLayout->addWidget(previousDirectionSpin); previousDirectionLabel->setBuddy(previousDirectionSpin); connect(previousDirectionSpin, static_cast(&QSpinBox::valueChanged), this, &DirectionDialog::directionChanged); @@ -280,7 +280,7 @@ directionSpin->setRange(-360, 720); directionSpin->setWrapping(true); directionSpin->setSingleStep(10); - directionSpin->setValue((int)deg); + directionSpin->setValue(static_cast(deg)); rightLayout->addWidget(directionSpin); directionLabel->setBuddy(directionSpin); connect(directionSpin, static_cast(&QSpinBox::valueChanged), this, &DirectionDialog::directionChanged); @@ -376,15 +376,15 @@ { // The canvas has changed, update the spinbox and command-LineEdit skipValueChangedEvent = true; - directionSpin->setValue(ROUND2INT(deg)); + directionSpin->setValue(ROUND2INT(deg)); updateCommandBox(); } void DirectionDialog::updatePreviousDegrees(double deg) { // The canvas has changed, update the spinbox and commandBox skipValueChangedEvent = true; - previousDirectionSpin->setValue(ROUND2INT(deg)); + previousDirectionSpin->setValue(ROUND2INT(deg)); updateCommandBox(); } diff --git a/src/editor.cpp b/src/editor.cpp --- a/src/editor.cpp +++ b/src/editor.cpp @@ -137,7 +137,7 @@ removeMarkings(); // removes the character markings if there are any int lineCount = 1; for (QTextBlock block = editor->document()->begin(); block.isValid(); block = block.next()) lineCount++; - numbers->setWidth(qMax(1, 1 + (int)std::floor(std::log10((double)lineCount - 1)))); + numbers->setWidth(qMax(1, 1 + static_cast(std::floor(std::log10(static_cast(lineCount) - 1))))); emit contentChanged(); } diff --git a/src/interpreter/executer.cpp b/src/interpreter/executer.cpp --- a/src/interpreter/executer.cpp +++ b/src/interpreter/executer.cpp @@ -457,7 +457,7 @@ } void Executer::executeIf(TreeNode* node) { // //qDebug() << "called"; - QString id = QString("__%1_%2").arg(node->token()->look()).arg((quintptr)node); + QString id = QString("__%1_%2").arg(node->token()->look()).arg(reinterpret_cast(node)); if (currentVariableTable()->contains(id)) { currentVariableTable()->remove(id); return; @@ -480,7 +480,7 @@ } void Executer::executeRepeat(TreeNode* node) { // //qDebug() << "called"; - QString id = QString("__%1_%2").arg(node->token()->look()).arg((quintptr)node); + QString id = QString("__%1_%2").arg(node->token()->look()).arg(reinterpret_cast(node)); if(breaking) { breaking = false; @@ -501,7 +501,7 @@ if(ROUND2INT(node->child(0)->value()->number())<=0) // handle 'repeat 0' return; - currentVariableTable()->insert(id, Value((double)(ROUND2INT(node->child(0)->value()->number()) - 1))); + currentVariableTable()->insert(id, Value(static_cast(ROUND2INT(node->child(0)->value()->number()) - 1))); } newScope = node->child(1); } @@ -512,7 +512,7 @@ // so we do the following on every call to executeWhile: // exec scope, exec expression, exec scope, exec expression, ... - QString id = QString("__%1_%2").arg(node->token()->look()).arg((quintptr)node); + QString id = QString("__%1_%2").arg(node->token()->look()).arg(reinterpret_cast(node)); if (breaking) { // We hit a break command while executing the scope @@ -561,7 +561,7 @@ firstIteration = true; } - QString id = QString("__%1_%2").arg(node->token()->look()).arg((quintptr)node); + QString id = QString("__%1_%2").arg(node->token()->look()).arg(reinterpret_cast(node)); if(breaking) { breaking = false; @@ -636,7 +636,7 @@ if (!checkParameterQuantity(node, 1, 20000+Token::Wait*100+90)) return; if (!checkParameterType(node, Value::Number, 20000+Token::Wait*100+91) ) return; waiting = true; - QTimer::singleShot((int)(1000*node->child(0)->value()->number()), this, SLOT(stopWaiting())); + QTimer::singleShot(static_cast(1000*node->child(0)->value()->number()), this, SLOT(stopWaiting())); } void Executer::executeAssert(TreeNode* node) { // //qDebug() << "called"; @@ -969,7 +969,7 @@ if (!checkParameterType(node, Value::Number, 20000+Token::Random*100+91)) return; double x = nodeX->value()->number(); double y = nodeY->value()->number(); - double r = (double)(KRandom::random()) / RAND_MAX; + double r = static_cast(KRandom::random()) / RAND_MAX; node->value()->setNumber(r * (y - x) + x); } void Executer::executeGetX(TreeNode* node) { @@ -1067,7 +1067,7 @@ if (!checkParameterQuantity(node, 1, 20000+Token::Round*100+90)) return; double val = node->child(0)->value()->number(); - node->value()->setNumber((double)ROUND2INT(val)); + node->value()->setNumber(static_cast(ROUND2INT(val))); } void Executer::executeGetDirection(TreeNode* node) { // //qDebug() << "called"; @@ -1085,7 +1085,7 @@ if (!checkParameterType(node, Value::Number, 20000+Token::Mod*100+91)) return; double x = nodeX->value()->number(); double y = nodeY->value()->number(); - double m = (double)(ROUND2INT(x) % ROUND2INT(y)); + double m = static_cast(ROUND2INT(x) % ROUND2INT(y)); node->value()->setNumber(m); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -195,7 +195,7 @@ a->setWhatsThis(i18n("Open File: Open an existing file")); //TODO: Is this correct? -- It doesn't seem to be working - recentFilesAction = (KRecentFilesAction*)actionCollection()->addAction(KStandardAction::OpenRecent, "file_recent", editor, SLOT(openFile(QUrl))); + recentFilesAction = dynamic_cast(actionCollection()->addAction(KStandardAction::OpenRecent, "file_recent", editor, SLOT(openFile(QUrl)))); recentFilesAction->setStatusTip(i18n("Open a recently used file")); recentFilesAction->setWhatsThis(i18n("Open Recent File: Open a recently used file")); diff --git a/src/sprite.cpp b/src/sprite.cpp --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -42,7 +42,7 @@ if (size <= 0 || w <= 0 || h <= 0) return; - qreal s = ((qreal)size) / ((w > h) ? w : h); + qreal s = (static_cast(size)) / ((w > h) ? w : h); setTransform(QTransform::fromScale(s, s), true); } @@ -56,8 +56,8 @@ // but we want to the rotation to be around the SVG's center... // This is why this "translation" is needed before the actual rotation. QTransform transform = QTransform::fromTranslate( - renderer()->defaultSize().width() * cos((degrees-135) * M_PI/180) * sqrt((double)2.0)/2, - renderer()->defaultSize().height() * sin((degrees-135) * M_PI/180) * sqrt((double)2.0)/2 + renderer()->defaultSize().width() * cos((degrees-135) * M_PI/180) * sqrt(static_cast(2.0))/2, + renderer()->defaultSize().height() * sin((degrees-135) * M_PI/180) * sqrt(static_cast(2.0))/2 ); transform.rotate(degrees); setTransform(transform, true);