diff --git a/drawmapfiguretablemodel.cpp b/drawmapfiguretablemodel.cpp index f9ae5e9..2beacca 100644 --- a/drawmapfiguretablemodel.cpp +++ b/drawmapfiguretablemodel.cpp @@ -15,7 +15,7 @@ QVariant DrawMapFigureTableModel::headerData(int section, Qt::Orientation orient { return header[section]; } - else if(role == Qt::DisplayRole && orientation == Qt::Vertical){ + if(role == Qt::DisplayRole && orientation == Qt::Vertical){ return section+1; } return QVariant(); @@ -67,18 +67,18 @@ QVariant DrawMapFigureTableModel::data(const QModelIndex &index, int role) const { return item->getIcon(); } - else if(role == Qt::BackgroundRole) + if(role == Qt::BackgroundRole) { if(item->getFigure()==DrawMapFigure::Unknown){ return QBrush(Qt::red); } - else if(col == 2 && !item->requiresPoint()){ + if(col == 2 && !item->requiresPoint()){ return QBrush(Qt::lightGray); } - else if (col == 3 && !item->requiresGeometry()){ + if (col == 3 && !item->requiresGeometry()){ return QBrush(Qt::lightGray); } - else if(col == 5 && !item->requiresText()){ + if(col == 5 && !item->requiresText()){ return QBrush(Qt::lightGray); } } @@ -157,7 +157,7 @@ bool DrawMapFigureTableModel::setData(const QModelIndex &index, const QVariant & emit dataChanged(index, index, QVector() << role); return true; } - else if( index.isValid() && role == Qt::CheckStateRole &&index.column()==1){ + if( index.isValid() && role == Qt::CheckStateRole &&index.column()==1){ DrawMapFigure *item = list->at(index.row()); item->setUseImageCoordinates(value.toInt() == Qt::Checked); emit dataChanged(index, index, QVector() << role); @@ -170,7 +170,7 @@ Qt::ItemFlags DrawMapFigureTableModel::flags(const QModelIndex &index) const { if (!index.isValid()) return Qt::NoItemFlags; - Qt::ItemFlags flag = QAbstractItemModel::flags(index); + Qt::ItemFlags flag = QAbstractTableModel::flags(index); int col = index.column(); DrawMapFigure *item = list->at(index.row()); if(col == 0) diff --git a/figuredelegate.cpp b/figuredelegate.cpp index 91d0a76..0ab74c8 100644 --- a/figuredelegate.cpp +++ b/figuredelegate.cpp @@ -28,14 +28,14 @@ void FigureDelegate::setEditorData(QWidget *editor, { int value = index.model()->data(index, Qt::EditRole).toInt(); - QComboBox *comboBox = static_cast(editor); + QComboBox *comboBox = dynamic_cast(editor); comboBox->setCurrentIndex(value); } void FigureDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - QComboBox *comboBox = static_cast(editor); + QComboBox *comboBox = dynamic_cast(editor); model->setData(index, comboBox->currentData(), Qt::EditRole); } diff --git a/geometrywidget.cpp b/geometrywidget.cpp index e3c8d73..13d686a 100644 --- a/geometrywidget.cpp +++ b/geometrywidget.cpp @@ -51,7 +51,7 @@ GeometryWidget::~GeometryWidget() } // Return true when parsing succeeded // false when not (string was still accepted, mode was set to custom) -bool GeometryWidget::set(const QString geomStr, Geometry::Format requestedFormat) +bool GeometryWidget::set(const QString& geomStr, Geometry::Format requestedFormat) { Geometry geometry; Geometry::Format parsedFormat; @@ -136,8 +136,8 @@ bool GeometryWidget::setFormat(Geometry::Format format) if (format != prevFormat) // Update all invisible widgets return set(getGeometry(), format); - else - return true; + + return true; } Geometry::Format GeometryWidget::getFormat() const diff --git a/geometrywidget.h b/geometrywidget.h index 0a5ffcc..a76d3fe 100644 --- a/geometrywidget.h +++ b/geometrywidget.h @@ -23,7 +23,7 @@ public: explicit GeometryWidget(QWidget *parent = 0); ~GeometryWidget(); - bool set(const QString geomStr, Geometry::Format format = Geometry::FormatUnknown); //{ return set(geomStr.toStdString().c_str(), format); } + bool set(const QString& geomStr, Geometry::Format format = Geometry::FormatUnknown); //{ return set(geomStr.toStdString().c_str(), format); } bool setDefault(void) { return set(""); } bool setFormat(int i) { return setFormat(static_cast(i)); } bool setFormat(Geometry::Format format); diff --git a/main.cpp b/main.cpp index 5d96cfd..1ba963c 100644 --- a/main.cpp +++ b/main.cpp @@ -9,10 +9,10 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - a.setApplicationName("MinetestMapperGui"); - a.setApplicationDisplayName("Minetest Mapper GUI"); - a.setApplicationVersion(GIT_VERSION); - a.setOrganizationName("MinetestMapperGui"); + QApplication::setApplicationName("MinetestMapperGui"); + QApplication::setApplicationDisplayName("Minetest Mapper GUI"); + QApplication::setApplicationVersion(GIT_VERSION); + QApplication::setOrganizationName("MinetestMapperGui"); // Setup the translators @@ -21,5 +21,5 @@ int main(int argc, char *argv[]) MainWindow w(&t); w.show(); - return a.exec(); + return QApplication::exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 1f36c72..c2c19e1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -535,7 +535,7 @@ void MainWindow::createProfilesMenu(){ qDebug()<<"found the Profiles"<< fileNames<< "in"<value("pos", QPoint(200, 200)).toPoint()); } - if(settings->value("help",false).toBool()==false){ + if(!settings->value("help",false).toBool()){ ui->dockHelp->close(); } - if(settings->value("showOutputLog",false).toBool()==false){ + if(!settings->value("showOutputLog",false).toBool()){ ui->dockOutput->close(); } currentProfile = settings->value("profile","default").toString(); @@ -1062,7 +1062,7 @@ void MainWindow::on_figure_geometry_apply_clicked() void MainWindow::on_button_deleteFigure_clicked() { QModelIndexList indexes; - while ((indexes = ui->figures_list->selectionModel()->selectedIndexes()).size()) { + while (!(indexes = ui->figures_list->selectionModel()->selectedIndexes()).empty()) { drawMapFigureTable->removeRow(indexes.first().row()); } } diff --git a/makecolors.cpp b/makecolors.cpp index 5908b3e..fb2d6ee 100644 --- a/makecolors.cpp +++ b/makecolors.cpp @@ -83,23 +83,19 @@ bool MakeColors::parseNodesTxt(const QString &nodesTxt) QTextStream in(&inputFile); while (!in.atEnd()) { - QString line = in.readLine(); if(line.isEmpty() || line.startsWith('#')) continue; - else{ - //qDebug()<< line; - QStringList lineS = line.split(' '); - const QString textureName = lineS[1];//get the filename out of the line - - //Insert the texturename and a invalid Color. The color will be set by searchAndProgrssTextures - requiredColors.insert(textureName,QColor()); - - //Insert Nodename and texturename into QMap to be sorted in alphabetical order - nodeList.insert(lineS[0],lineS[1]); - } + + //qDebug()<< line; + QStringList lineS = line.split(' '); + const QString textureName = lineS[1];//get the filename out of the line + //Insert the texturename and a invalid Color. The color will be set by searchAndProgrssTextures + requiredColors.insert(textureName,QColor()); + //Insert Nodename and texturename into QMap to be sorted in alphabetical order + nodeList.insert(lineS[0],lineS[1]); } inputFile.close(); numberOfNodes = requiredColors.size(); diff --git a/minetestmapperexe.cpp b/minetestmapperexe.cpp index 627ca51..51a3ba4 100644 --- a/minetestmapperexe.cpp +++ b/minetestmapperexe.cpp @@ -267,7 +267,7 @@ void MinetestMapperExe::errorOccured(QProcess::ProcessError error) qDebug() <<"Error starting MinetestMapper:"<error() <<"Error string: "<errorString(); - QMessageBox::critical((QWidget*)this->parent(), tr("Minetest Mapper failed"), + QMessageBox::critical(dynamic_cast(this->parent()), tr("Minetest Mapper failed"), tr("

ERROR

minetestmapper failed

" "Error code: %1
" "Error Message:
%2

") diff --git a/translator.cpp b/translator.cpp index b631e4a..6e89a50 100644 --- a/translator.cpp +++ b/translator.cpp @@ -14,17 +14,17 @@ void Translator::load(const QLocale &locale) { qDebug() << "Loading Locale:" << locale; if (qtTranslator.load(locale, "qt", "_", systemTranslationPath)) { - qApp->installTranslator(&qtTranslator); + QApplication::installTranslator(&qtTranslator); qDebug() << "Qt Translator installed from system path" << systemTranslationPath; } else { qtTranslator.load(locale, "qt", "_", translationsPath); - qApp->installTranslator(&qtTranslator); + QApplication::installTranslator(&qtTranslator); qDebug() << "Qt Translator installed from standard path" << translationsPath; } if (appTranslator.load(locale, "gui", "_", translationsPath)) - qApp->installTranslator(&appTranslator); + QApplication::installTranslator(&appTranslator); } QStringList Translator::getTranslations() const