From 0a927fec5270716d4cfd1d5a8814b6e1992231b6 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 25 Mar 2019 05:18:21 +0100 Subject: [PATCH] Modernize --- colorlineedit.cpp | 2 +- configdialog.cpp | 5 +++-- drawmapfiguretablemodel.cpp | 2 +- geometry.cpp | 24 ++++++++++++------------ mainwindow.cpp | 6 +++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/colorlineedit.cpp b/colorlineedit.cpp index 9ae0b26..bce7521 100644 --- a/colorlineedit.cpp +++ b/colorlineedit.cpp @@ -19,7 +19,7 @@ void ColorLineEdit::selectColor() if (!current.isValid()) { current = Qt::white; } - const QColor color = QColorDialog::getColor(current, this, NULL, options); + const QColor color = QColorDialog::getColor(current, this, nullptr, options); if (color.isValid()) { this->setText(color.name()); diff --git a/configdialog.cpp b/configdialog.cpp index 6aa488e..c20534c 100644 --- a/configdialog.cpp +++ b/configdialog.cpp @@ -119,8 +119,9 @@ void ConfigDialog::on_browseMapper_clicked() QString ConfigSettings::getDefaultMapperExecutable() { QStringList locations = getMapperExecutables(); - if (locations.empty()) return ""; - else return locations.at(0); + if (locations.empty()) + return QString(); + return locations.at(0); } void ConfigSettings::addMapperExecutablesToList(QStringList &existingList, QStringList &pathList) diff --git a/drawmapfiguretablemodel.cpp b/drawmapfiguretablemodel.cpp index 4d5692e..d78078b 100644 --- a/drawmapfiguretablemodel.cpp +++ b/drawmapfiguretablemodel.cpp @@ -116,7 +116,7 @@ QVariant DrawMapFigureTableModel::data(const QModelIndex &index, int role) const // FIXME: Implement me! return QVariant(); } - else if(role == Qt::DecorationRole && col==4){ + else if(role == Qt::DecorationRole && col==4){ return item->getColor(); } else if(role == Qt::CheckStateRole && col ==1){ diff --git a/geometry.cpp b/geometry.cpp index 754b0a3..d38897c 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -207,9 +207,9 @@ void Geometry::computeCorner0() { for (int i = 0; i < 2; i++) { if (dimension[i] < 0) - corner[0][i] = center[i] + (-dimension[i]) / 2; - else - corner[0][i] = center[i] - dimension[i] / 2; + corner[0][i] = center[i] + (-dimension[i]) / 2; + else + corner[0][i] = center[i] - dimension[i] / 2; } } @@ -217,9 +217,9 @@ void Geometry::computeCorner1() { for (int i = 0; i < 2; i++) { if (dimension[i] < 0) - corner[1][i] = corner[0][i] + dimension[i] + 1; - else - corner[1][i] = corner[0][i] + dimension[i] - 1; + corner[1][i] = corner[0][i] + dimension[i] + 1; + else + corner[1][i] = corner[0][i] + dimension[i] - 1; } } @@ -227,9 +227,9 @@ void Geometry::computeCenter() { for (int i = 0; i < 2; i++) { if (corner[0][i] > corner[1][i]) - center[i] = corner[0][i] - (-dimension[i]) / 2; - else - center[i] = corner[0][i] + dimension[i] / 2; + center[i] = corner[0][i] - (-dimension[i]) / 2; + else + center[i] = corner[0][i] + dimension[i] / 2; } } @@ -237,8 +237,8 @@ void Geometry::computeDimensions() { for (int i = 0; i < 2; i++) { if (corner[0][i] > corner[1][i]) - dimension[i] = corner[1][i] - corner[0][i] - 1; - else - dimension[i] = corner[1][i] - corner[0][i] + 1; + dimension[i] = corner[1][i] - corner[0][i] - 1; + else + dimension[i] = corner[1][i] - corner[0][i] + 1; } } diff --git a/mainwindow.cpp b/mainwindow.cpp index cd353ba..1f36c72 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -431,7 +431,7 @@ void MainWindow::on_button_generate_clicked() tr("MinetestMapper will be executed using this arguments. \n" "The arguments can be removed, modified, or new arguments can be added."),//label arguments.join("\n"),//text - &ok,0); + &ok); if (ok) arguments = parameters.split("\n"); else { ui->button_generate->setDisabled(false); @@ -560,7 +560,7 @@ void MainWindow::createProfilesMenu(){ // Called every time, when a menu entry of the profile menu is called void MainWindow::slotProfileChanged(QAction* action) { - if(action != 0) { + if(action) { writeProfile(); currentProfile = action->data().toString(); readProfile(); @@ -889,7 +889,7 @@ void MainWindow::on_actionNew_Profile_triggered() tr("Name of the new Profile:"),//label QLineEdit::Normal, "",//text - &ok,0); + &ok); if(ok && !profile.isEmpty()) { currentProfile = profile; QAction *action = new QAction(profile, this);