diff --git a/src/canvas.cpp b/src/canvas.cpp --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -110,9 +110,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) @@ -174,7 +174,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) @@ -219,7 +219,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 @@ -260,7 +260,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); @@ -276,7 +276,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); 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 @@ -452,7 +452,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; @@ -475,7 +475,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; @@ -507,7 +507,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 @@ -556,7 +556,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; @@ -631,7 +631,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"; @@ -964,7 +964,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) { @@ -1080,7 +1080,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)(static_cast(round(x)) % static_cast(round(y))); + double m = (static_cast(round(x)) % static_cast(round(y))); node->value()->setNumber(m); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -196,7 +196,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);