diff --git a/src/core/editcommands.cpp b/src/core/editcommands.cpp index 0cc378fc..38b6a0d5 100644 --- a/src/core/editcommands.cpp +++ b/src/core/editcommands.cpp @@ -220,7 +220,7 @@ void ResizeLayout::redo() { layout->lastCommitBlocks.layoutDimensions = QSize(layout->getWidth(), layout->getHeight()); layout->lastCommitBlocks.borderDimensions = QSize(layout->getBorderWidth(), layout->getBorderHeight()); - layout->needsRedrawing(); + emit layout->needsRedrawing(); } void ResizeLayout::undo() { @@ -237,7 +237,7 @@ void ResizeLayout::undo() { layout->lastCommitBlocks.layoutDimensions = QSize(layout->getWidth(), layout->getHeight()); layout->lastCommitBlocks.borderDimensions = QSize(layout->getBorderWidth(), layout->getBorderHeight()); - layout->needsRedrawing(); + emit layout->needsRedrawing(); QUndoCommand::undo(); } diff --git a/src/core/events.cpp b/src/core/events.cpp index ac197bc7..d6667450 100644 --- a/src/core/events.cpp +++ b/src/core/events.cpp @@ -206,7 +206,7 @@ bool ObjectEvent::loadFromJson(const QJsonObject &json, Project *) { } void ObjectEvent::setDefaultValues(Project *project) { - this->setGfx(project->gfxDefines.keys().value(0, "0")); + this->setGfx(project->gfxDefines.key(0, "0")); this->setMovement(project->movementTypes.value(0, "0")); this->setScript("NULL"); this->setTrainerType(project->trainerTypes.value(0, "0")); @@ -310,7 +310,7 @@ bool CloneObjectEvent::loadFromJson(const QJsonObject &json, Project *project) { } void CloneObjectEvent::setDefaultValues(Project *project) { - this->setGfx(project->gfxDefines.keys().value(0, "0")); + this->setGfx(project->gfxDefines.key(0, "0")); this->setTargetID(1); if (this->getMap()) this->setTargetMap(this->getMap()->name()); } diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp index 22880562..8a3ad534 100644 --- a/src/core/parseutil.cpp +++ b/src/core/parseutil.cpp @@ -677,7 +677,6 @@ bool ParseUtil::tryParseJsonFile(QJsonDocument *out, const QString &filepath, QS } bool ParseUtil::tryParseOrderedJsonFile(poryjson::Json::object *out, const QString &filepath, QString *error) { - QString err; QString jsonTxt = readTextFile(filepath, error); if (error && !error->isEmpty()) { return false; diff --git a/src/editor.cpp b/src/editor.cpp index b6c810a9..e351d0df 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -879,7 +879,7 @@ void Editor::displayDivingConnection(MapConnection *connection) { } void Editor::renderDivingConnections() { - for (auto item : diving_map_items.values()) + for (auto &item : diving_map_items) item->updatePixmap(); } @@ -1710,7 +1710,7 @@ void Editor::removeEventPixmapItem(Event *event) { } void Editor::clearMapConnections() { - for (auto item : connection_items) { + for (auto &item : connection_items) { if (item->scene()) item->scene()->removeItem(item); delete item; @@ -1722,7 +1722,7 @@ void Editor::clearMapConnections() { ui->comboBox_DiveMap->setCurrentText(""); ui->comboBox_EmergeMap->setCurrentText(""); - for (auto item : diving_map_items.values()) { + for (auto &item : diving_map_items) { if (item->scene()) item->scene()->removeItem(item); delete item; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ed7e7d77..08350694 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1546,9 +1546,9 @@ void MainWindow::updateMapList() { this->mapLocationModel->setActiveItem(activeItemName); this->layoutTreeModel->setActiveItem(activeItemName); - this->groupListProxyModel->layoutChanged(); - this->locationListProxyModel->layoutChanged(); - this->layoutListProxyModel->layoutChanged(); + emit this->groupListProxyModel->layoutChanged(); + emit this->locationListProxyModel->layoutChanged(); + emit this->layoutListProxyModel->layoutChanged(); } void MainWindow::on_action_Save_Project_triggered() { diff --git a/src/project.cpp b/src/project.cpp index 6590aac7..429dd6c2 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -692,7 +692,6 @@ void Project::saveRegionMapSections() { return; } - const QString emptyMapsecName = getEmptyMapsecName(); OrderedJson::array mapSectionArray; for (const auto &idName : this->mapSectionIdNamesSaveOrder) { OrderedJson::object mapSectionObj; @@ -889,11 +888,12 @@ void Project::updateTilesetMetatileLabels(Tileset *tileset) { // Erase old labels, then repopulate with new labels const QString prefix = tileset->getMetatileLabelPrefix(); this->metatileLabelsMap[tileset->name].clear(); - for (int metatileId : tileset->metatileLabels.keys()) { - if (tileset->metatileLabels[metatileId].isEmpty()) - continue; - QString label = prefix + tileset->metatileLabels[metatileId]; - this->metatileLabelsMap[tileset->name][label] = metatileId; + for (auto i = tileset->metatileLabels.constBegin(); i != tileset->metatileLabels.constEnd(); i++) { + uint16_t metatileId = i.key(); + QString label = i.value(); + if (!label.isEmpty()) { + this->metatileLabelsMap[tileset->name][prefix + label] = metatileId; + } } } @@ -932,11 +932,12 @@ void Project::saveTilesetMetatileLabels(Tileset *primaryTileset, Tileset *second const QString guardName = "GUARD_METATILE_LABELS_H"; QString outputText = QString("#ifndef %1\n#define %1\n").arg(guardName); - for (QString tilesetName : metatileLabelsMap.keys()) { - if (metatileLabelsMap[tilesetName].size() == 0) + for (auto i = this->metatileLabelsMap.constBegin(); i != this->metatileLabelsMap.constEnd(); i++) { + const QString tilesetName = i.key(); + const QMap tilesetMetatileLabels = i.value(); + if (tilesetMetatileLabels.isEmpty()) continue; - outputText += QString("\n// %1\n").arg(tilesetName); - outputText += buildMetatileLabelsText(metatileLabelsMap[tilesetName]); + outputText += QString("\n// %1\n%2").arg(tilesetName).arg(buildMetatileLabelsText(tilesetMetatileLabels)); } if (unusedMetatileLabels.size() != 0) { @@ -1499,10 +1500,10 @@ bool Project::readTilesetMetatileLabels() { fileWatcher.addPath(root + "/" + metatileLabelsFilename); const QSet regexList = {QString("\\b%1").arg(projectConfig.getIdentifier(ProjectIdentifier::define_metatile_label_prefix))}; - QMap defines = parser.readCDefinesByRegex(metatileLabelsFilename, regexList); - - for (QString label : defines.keys()) { - uint32_t metatileId = static_cast(defines[label]); + const QMap defines = parser.readCDefinesByRegex(metatileLabelsFilename, regexList); + for (auto i = defines.constBegin(); i != defines.constEnd(); i++) { + QString label = i.key(); + uint32_t metatileId = i.value(); if (metatileId > Block::maxValue) { metatileId &= Block::maxValue; logWarn(QString("Value of metatile label '%1' truncated to %2").arg(label).arg(Metatile::getMetatileIdString(metatileId))); diff --git a/src/ui/resizelayoutpopup.cpp b/src/ui/resizelayoutpopup.cpp index 20a378b9..5629d8e9 100644 --- a/src/ui/resizelayoutpopup.cpp +++ b/src/ui/resizelayoutpopup.cpp @@ -172,7 +172,7 @@ void ResizeLayoutPopup::setupLayoutView() { scene->addItem(outline); layoutPixmap->setBoundary(outline); - this->outline->rectUpdated(outline->rect().toAlignedRect()); + emit this->outline->rectUpdated(outline->rect().toAlignedRect()); // TODO: is this an ideal size for all maps, or should this adjust based on starting dimensions? this->ui->graphicsView->setTransform(QTransform::fromScale(0.5, 0.5)); diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index 5d6dede9..64b03734 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -123,8 +123,8 @@ void TilesetEditor::setTilesets(QString primaryTilesetLabel, QString secondaryTi void TilesetEditor::setAttributesUi() { // Behavior if (projectConfig.metatileBehaviorMask) { - for (int num : project->metatileBehaviorMapInverse.keys()) { - this->ui->comboBox_metatileBehaviors->addItem(project->metatileBehaviorMapInverse[num], num); + for (auto i = project->metatileBehaviorMapInverse.constBegin(); i != project->metatileBehaviorMapInverse.constEnd(); i++) { + this->ui->comboBox_metatileBehaviors->addItem(i.value(), i.key()); } this->ui->comboBox_metatileBehaviors->setMinimumContentsLength(0); } else { @@ -1123,7 +1123,7 @@ void TilesetEditor::countTileUsage() { QSet primaryTilesets; QSet secondaryTilesets; - for (auto layout : this->project->mapLayouts.values()) { + for (auto &layout : this->project->mapLayouts) { this->project->loadLayoutTilesets(layout); if (layout->tileset_primary_label == this->primaryTileset->name || layout->tileset_secondary_label == this->secondaryTileset->name) {