mirror of
https://github.com/huderlem/porymap.git
synced 2026-04-25 15:27:53 -05:00
Fix some clazy warnings (container-anti-pattern, incorrect-emit, and unused-non-trivial-variable)
This commit is contained in:
parent
f03d817800
commit
77134072da
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -865,7 +865,7 @@ void Editor::displayDivingConnection(MapConnection *connection) {
|
|||
}
|
||||
|
||||
void Editor::renderDivingConnections() {
|
||||
for (auto item : diving_map_items.values())
|
||||
for (auto &item : diving_map_items)
|
||||
item->updatePixmap();
|
||||
}
|
||||
|
||||
|
|
@ -1696,7 +1696,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;
|
||||
|
|
@ -1708,7 +1708,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;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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<QString, uint16_t> 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<QString> regexList = {QString("\\b%1").arg(projectConfig.getIdentifier(ProjectIdentifier::define_metatile_label_prefix))};
|
||||
QMap<QString, int> defines = parser.readCDefinesByRegex(metatileLabelsFilename, regexList);
|
||||
|
||||
for (QString label : defines.keys()) {
|
||||
uint32_t metatileId = static_cast<uint32_t>(defines[label]);
|
||||
const QMap<QString, int> 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)));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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<Tileset*> primaryTilesets;
|
||||
QSet<Tileset*> 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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user