diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp index 04cdbcc7..76d58af8 100644 --- a/src/core/parseutil.cpp +++ b/src/core/parseutil.cpp @@ -49,10 +49,10 @@ void ParseUtil::recordErrors(const QStringList &errors) { } void ParseUtil::logRecordedErrors() { - QStringList errors = this->errorMap.value(this->curDefine); + const QStringList errors = this->errorMap.value(this->curDefine); if (errors.isEmpty()) return; QString message = QString("Failed to parse '%1':").arg(this->curDefine); - for (const auto error : errors) + for (const auto &error : errors) message.append(QString("\n%1").arg(error)); logError(message); } diff --git a/src/lib/orderedjson.cpp b/src/lib/orderedjson.cpp index 387dac6d..d7dd35e8 100644 --- a/src/lib/orderedjson.cpp +++ b/src/lib/orderedjson.cpp @@ -33,7 +33,6 @@ static const int max_depth = 200; using std::map; using std::make_shared; using std::initializer_list; -using std::move; /* Helper for representing null - just a do-nothing struct, plus comparison * operators so the helpers in JsonValue work. We can't use nullptr_t because @@ -164,7 +163,7 @@ protected: // Constructors explicit Value(const T &value) : m_value(value) {} - explicit Value(T &&value) : m_value(move(value)) {} + explicit Value(T &&value) : m_value(std::move(value)) {} // Get type tag Json::Type type() const override { @@ -211,7 +210,7 @@ class JsonString final : public Value { const QString &string_value() const override { return m_value; } public: explicit JsonString(const QString &value) : Value(value) {} - explicit JsonString(QString &&value) : Value(move(value)) {} + explicit JsonString(QString &&value) : Value(std::move(value)) {} }; class JsonArray final : public Value { @@ -219,7 +218,7 @@ class JsonArray final : public Value { const Json & operator[](int i) const override; public: explicit JsonArray(const Json::array &value) : Value(value) {} - explicit JsonArray(Json::array &&value) : Value(move(value)) {} + explicit JsonArray(Json::array &&value) : Value(std::move(value)) {} }; class JsonObject final : public Value { @@ -227,7 +226,7 @@ class JsonObject final : public Value { const Json & operator[](const QString &key) const override; public: explicit JsonObject(const Json::object &value) : Value(value) {} - explicit JsonObject(Json::object &&value) : Value(move(value)) {} + explicit JsonObject(Json::object &&value) : Value(std::move(value)) {} }; class JsonNull final : public Value { @@ -269,12 +268,12 @@ Json::Json(double value) : m_ptr(make_shared(value)) { Json::Json(int value) : m_ptr(make_shared(value)) {} Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {} Json::Json(const QString &value) : m_ptr(make_shared(value)) {} -Json::Json(QString &&value) : m_ptr(make_shared(move(value))) {} +Json::Json(QString &&value) : m_ptr(make_shared(std::move(value))) {} Json::Json(const char * value) : m_ptr(make_shared(value)) {} Json::Json(const Json::array &values) : m_ptr(make_shared(values)) {} -Json::Json(Json::array &&values) : m_ptr(make_shared(move(values))) {} +Json::Json(Json::array &&values) : m_ptr(make_shared(std::move(values))) {} Json::Json(const Json::object &values) : m_ptr(make_shared(values)) {} -Json::Json(Json::object &&values) : m_ptr(make_shared(move(values))) {} +Json::Json(Json::object &&values) : m_ptr(make_shared(std::move(values))) {} /* * * * * * * * * * * * * * * * * * * * * Accessors @@ -399,7 +398,7 @@ struct JsonParser final { * Mark this parse as failed. */ Json fail(QString &&msg) { - return fail(move(msg), Json()); + return fail(std::move(msg), Json()); } template diff --git a/src/project.cpp b/src/project.cpp index c87d2c9c..690323f5 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1963,9 +1963,9 @@ bool Project::readTilesetLabels() { } else { this->usingAsmTilesets = false; const auto structs = parser.readCStructs(filename, "", Tileset::getHeaderMemberMap(this->usingAsmTilesets)); - QStringList labels = structs.keys(); + const QStringList labels = structs.keys(); // TODO: This is alphabetical, AdvanceMap import wants the vanilla order in tilesetLabelsOrdered - for (const auto tilesetLabel : labels){ + for (const auto &tilesetLabel : labels){ appendTilesetLabel(tilesetLabel, structs[tilesetLabel].value("isSecondary")); } } @@ -2242,7 +2242,7 @@ bool Project::readHealLocations() { // Pattern for an x, y number pair const QString coordPattern = "\\s*(?[0-9A-Fa-fx]+),\\s*(?[0-9A-Fa-fx]+)"; - for (const auto idName : constants) { + for (const auto &idName : constants) { // Create regex pattern for e.g. "SPAWN_PALLET_TOWN - 1] = " const QString initializerPattern = QString("%1\\s*-\\s*1\\s*\\]\\s*=\\s*").arg(idName); diff --git a/src/ui/eventframes.cpp b/src/ui/eventframes.cpp index 90d5b776..e90658a2 100644 --- a/src/ui/eventframes.cpp +++ b/src/ui/eventframes.cpp @@ -12,11 +12,6 @@ static inline QSpacerItem *createSpacerH() { return new QSpacerItem(2, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); } -static inline QSpacerItem *createSpacerV() { - return new QSpacerItem(1, 2, QSizePolicy::Minimum, QSizePolicy::Expanding); -} - - void EventFrame::setup() { // delete default layout due to lack of parent at initialization diff --git a/src/ui/flowlayout.cpp b/src/ui/flowlayout.cpp index 2d5a5faa..54cde082 100644 --- a/src/ui/flowlayout.cpp +++ b/src/ui/flowlayout.cpp @@ -81,7 +81,7 @@ QSize FlowLayout::sizeHint() const { QSize FlowLayout::minimumSize() const { QSize size; - for (const QLayoutItem *item : qAsConst(itemList)) + for (const QLayoutItem *item : std::as_const(itemList)) size = size.expandedTo(item->minimumSize()); const QMargins margins = contentsMargins(); @@ -97,7 +97,7 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const { int y = effectiveRect.y(); int lineHeight = 0; - for (QLayoutItem *item : qAsConst(itemList)) { + for (QLayoutItem *item : std::as_const(itemList)) { const QWidget *wid = item->widget(); int spaceX = horizontalSpacing(); if (spaceX == -1) diff --git a/src/ui/tileseteditormetatileselector.cpp b/src/ui/tileseteditormetatileselector.cpp index 92d07e3a..15d3d60f 100644 --- a/src/ui/tileseteditormetatileselector.cpp +++ b/src/ui/tileseteditormetatileselector.cpp @@ -234,10 +234,6 @@ void TilesetEditorMetatileSelector::drawUnused() { int primaryLength = this->primaryTileset->metatiles.length(); int length_ = primaryLength + this->secondaryTileset->metatiles.length(); - int height_ = length_ / this->numMetatilesWide; - if (length_ % this->numMetatilesWide != 0) { - height_++; - } for (int i = 0; i < length_; i++) { int tile = i; @@ -277,10 +273,6 @@ void TilesetEditorMetatileSelector::drawCounts() { int primaryLength = this->primaryTileset->metatiles.length(); int length_ = primaryLength + this->secondaryTileset->metatiles.length(); - int height_ = length_ / this->numMetatilesWide; - if (length_ % this->numMetatilesWide != 0) { - height_++; - } for (int i = 0; i < length_; i++) { int tile = i; diff --git a/src/ui/wildmonchart.cpp b/src/ui/wildmonchart.cpp index 4594e2bd..1e8c1017 100644 --- a/src/ui/wildmonchart.cpp +++ b/src/ui/wildmonchart.cpp @@ -218,7 +218,7 @@ bool WildMonChart::usesGroupLabels() const { QChart* WildMonChart::createSpeciesDistributionChart() { QList barSets; - for (const auto species : getSpeciesNamesAlphabetical()) { + for (const auto &species : getSpeciesNamesAlphabetical()) { // Add encounter chance data auto set = new QBarSet(species); for (auto groupName : this->groupNamesReversed) @@ -326,7 +326,7 @@ QChart* WildMonChart::createLevelDistributionChart() { levelRange = getLevelRange(species, groupName); } else { // Species box is inactive, we display data for all species in the table. - for (const auto species : this->speciesInLegendOrder) + for (const auto &species : this->speciesInLegendOrder) barSets.append(createLevelDistributionBarSet(species, groupName, false)); levelRange = this->groupedLevelRanges.value(groupName); } diff --git a/src/vendor/QtGifImage/gifimage/qgifimage.cpp b/src/vendor/QtGifImage/gifimage/qgifimage.cpp index 46748d94..b607c7e0 100644 --- a/src/vendor/QtGifImage/gifimage/qgifimage.cpp +++ b/src/vendor/QtGifImage/gifimage/qgifimage.cpp @@ -136,7 +136,7 @@ bool QGifImagePrivate::load(QIODevice *device) int error; GifFileType *gifFile = DGifOpen(device, readFromIODevice, &error); if (!gifFile) { - qWarning(GifErrorString(error)); + qWarning("%s", GifErrorString(error)); return false; } @@ -228,7 +228,7 @@ bool QGifImagePrivate::save(QIODevice *device) const int error; GifFileType *gifFile = EGifOpen(device, writeToIODevice, &error); if (!gifFile) { - qWarning(GifErrorString(error)); + qWarning("%s", GifErrorString(error)); return false; }