General: Make use of ranged for where applicable

This commit is contained in:
Lioncash 2020-06-28 17:30:49 -04:00
parent 9bc2723498
commit ec66d7af9d
25 changed files with 162 additions and 147 deletions

View File

@ -49,7 +49,7 @@ bool CEditorApplication::CloseAllEditors()
return true; return true;
// Close active editor windows. // Close active editor windows.
foreach (IEditor *pEditor, mEditorWindows) for (IEditor *pEditor : mEditorWindows)
{ {
if (pEditor != mpWorldEditor && !pEditor->close()) if (pEditor != mpWorldEditor && !pEditor->close())
return false; return false;
@ -318,16 +318,20 @@ void CEditorApplication::TickEditors()
gpResourceStore->ConditionalSaveStore(); gpResourceStore->ConditionalSaveStore();
// Tick each editor window and redraw their viewports // Tick each editor window and redraw their viewports
foreach(IEditor *pEditor, mEditorWindows) for (IEditor *pEditor : mEditorWindows)
{ {
if (pEditor->isVisible()) if (pEditor->isVisible())
{ {
CBasicViewport *pViewport = pEditor->Viewport(); CBasicViewport *pViewport = pEditor->Viewport();
bool ViewportVisible = (pViewport && pViewport->isVisible() && !pEditor->isMinimized()); const bool ViewportVisible = (pViewport && pViewport->isVisible() && !pEditor->isMinimized());
if (ViewportVisible) pViewport->ProcessInput(); if (ViewportVisible)
pEditor->EditorTick((float) DeltaTime); pViewport->ProcessInput();
if (ViewportVisible) pViewport->Render();
pEditor->EditorTick(static_cast<float>(DeltaTime));
if (ViewportVisible)
pViewport->Render();
} }
} }
} }

View File

@ -22,7 +22,7 @@ public:
~CNodeSelection() override ~CNodeSelection() override
{ {
foreach (CSceneNode *pNode, mSelectedNodes) for (CSceneNode *pNode : mSelectedNodes)
pNode->SetSelected(false); pNode->SetSelected(false);
} }
@ -50,7 +50,7 @@ public:
void Clear() void Clear()
{ {
foreach (CSceneNode *pNode, mSelectedNodes) for (CSceneNode *pNode : mSelectedNodes)
pNode->SetSelected(false); pNode->SetSelected(false);
mSelectedNodes.clear(); mSelectedNodes.clear();
@ -72,7 +72,7 @@ public:
blockSignals(true); blockSignals(true);
Clear(); Clear();
foreach (CSceneNode *pNode, rkList) for (CSceneNode *pNode : rkList)
SelectNode(pNode); SelectNode(pNode);
blockSignals(false); blockSignals(false);
@ -86,7 +86,7 @@ public:
{ {
mCachedBounds = CAABox::Infinite(); mCachedBounds = CAABox::Infinite();
foreach (CSceneNode *pNode, mSelectedNodes) for (CSceneNode *pNode : mSelectedNodes)
{ {
mCachedBounds.ExpandBounds(pNode->AABox()); mCachedBounds.ExpandBounds(pNode->AABox());

View File

@ -438,7 +438,7 @@ void CSceneViewport::OnSelectConnected()
FindConnectedObjects(static_cast<CScriptNode*>(mpMenuNode)->Instance()->InstanceID(), SearchOutgoing, SearchIncoming, InstanceIDs); FindConnectedObjects(static_cast<CScriptNode*>(mpMenuNode)->Instance()->InstanceID(), SearchOutgoing, SearchIncoming, InstanceIDs);
QList<CSceneNode*> Nodes; QList<CSceneNode*> Nodes;
foreach (uint32 ID, InstanceIDs) for (const uint32 ID : InstanceIDs)
Nodes << mpScene->NodeForInstanceID(ID); Nodes << mpScene->NodeForInstanceID(ID);
const bool ShouldClear = ((qApp->keyboardModifiers() & Qt::ControlModifier) == 0); const bool ShouldClear = ((qApp->keyboardModifiers() & Qt::ControlModifier) == 0);

View File

@ -129,9 +129,9 @@ void CTweakEditor::OnProjectChanged(CGameProject* pNewProject)
return pLeft->TweakName().ToUpper() < pRight->TweakName().ToUpper(); return pLeft->TweakName().ToUpper() < pRight->TweakName().ToUpper();
}); });
foreach (CTweakData* pTweakData, mTweakAssets) for (CTweakData* pTweakData : mTweakAssets)
{ {
QString TweakName = TO_QSTRING( pTweakData->TweakName() ); const QString TweakName = TO_QSTRING(pTweakData->TweakName());
mpUI->TweakTabs->addTab(TweakName); mpUI->TweakTabs->addTab(TweakName);
} }

View File

@ -20,7 +20,7 @@ INodeEditor::INodeEditor(QWidget *pParent)
mpGizmoGroup = new QActionGroup(this); mpGizmoGroup = new QActionGroup(this);
foreach (QAction *pAction, mGizmoActions) for (QAction *pAction : mGizmoActions)
{ {
pAction->setCheckable(true); pAction->setCheckable(true);
mpGizmoGroup->addAction(pAction); mpGizmoGroup->addAction(pAction);
@ -57,7 +57,7 @@ CGizmo* INodeEditor::Gizmo()
return &mGizmo; return &mGizmo;
} }
bool INodeEditor::IsGizmoVisible() bool INodeEditor::IsGizmoVisible() const
{ {
return (mShowGizmo && !mpSelection->IsEmpty()); return (mShowGizmo && !mpSelection->IsEmpty());
} }
@ -68,7 +68,7 @@ void INodeEditor::BeginGizmoTransform()
if ((qApp->keyboardModifiers() & Qt::ShiftModifier) != 0) if ((qApp->keyboardModifiers() & Qt::ShiftModifier) != 0)
mCloneState = ECloneState::ReadyToClone; mCloneState = ECloneState::ReadyToClone;
foreach (QAction *pAction, mGizmoActions) for (QAction *pAction : mGizmoActions)
pAction->setEnabled(false); pAction->setEnabled(false);
} }
@ -76,7 +76,7 @@ void INodeEditor::EndGizmoTransform()
{ {
mGizmoTransforming = false; mGizmoTransforming = false;
foreach (QAction *pAction, mGizmoActions) for (QAction *pAction : mGizmoActions)
pAction->setEnabled(true); pAction->setEnabled(true);
if (mGizmo.HasTransformed()) if (mGizmo.HasTransformed())
@ -95,7 +95,7 @@ void INodeEditor::EndGizmoTransform()
mCloneState = ECloneState::NotCloning; mCloneState = ECloneState::NotCloning;
} }
ETransformSpace INodeEditor::CurrentTransformSpace() ETransformSpace INodeEditor::CurrentTransformSpace() const
{ {
switch (mGizmo.Mode()) switch (mGizmo.Mode())
{ {
@ -108,20 +108,21 @@ ETransformSpace INodeEditor::CurrentTransformSpace()
void INodeEditor::SelectNode(CSceneNode *pNode) void INodeEditor::SelectNode(CSceneNode *pNode)
{ {
if (!mSelectionLocked) if (mSelectionLocked)
{ return;
if (!pNode->IsSelected()) if (!pNode->IsSelected())
mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode)); mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode));
} }
}
void INodeEditor::BatchSelectNodes(QList<CSceneNode*> Nodes, bool ClearExistingSelection, const QString& rkCommandName /*= "Select"*/) void INodeEditor::BatchSelectNodes(QList<CSceneNode*> Nodes, bool ClearExistingSelection, const QString& rkCommandName /*= "Select"*/)
{ {
if (!mSelectionLocked) if (mSelectionLocked)
{ return;
if (!ClearExistingSelection) if (!ClearExistingSelection)
{ {
foreach (CSceneNode *pNode, Nodes) for (CSceneNode *pNode : Nodes)
{ {
if (pNode->IsSelected()) if (pNode->IsSelected())
Nodes.removeOne(pNode); Nodes.removeOne(pNode);
@ -135,28 +136,28 @@ void INodeEditor::BatchSelectNodes(QList<CSceneNode*> Nodes, bool ClearExistingS
if (ClearExistingSelection) if (ClearExistingSelection)
ClearSelection(); ClearSelection();
foreach (CSceneNode *pNode, Nodes) for (CSceneNode *pNode : Nodes)
SelectNode(pNode); SelectNode(pNode);
mUndoStack.endMacro(); mUndoStack.endMacro();
} }
} }
}
void INodeEditor::DeselectNode(CSceneNode *pNode) void INodeEditor::DeselectNode(CSceneNode *pNode)
{ {
if (!mSelectionLocked) if (mSelectionLocked)
{ return;
if (pNode->IsSelected()) if (pNode->IsSelected())
mUndoStack.push(new CDeselectNodeCommand(mpSelection, pNode)); mUndoStack.push(new CDeselectNodeCommand(mpSelection, pNode));
} }
}
void INodeEditor::BatchDeselectNodes(QList<CSceneNode*> Nodes, const QString& rkCommandName /*= "Deselect"*/) void INodeEditor::BatchDeselectNodes(QList<CSceneNode*> Nodes, const QString& rkCommandName /*= "Deselect"*/)
{ {
if (!mSelectionLocked) if (mSelectionLocked)
{ return;
foreach (CSceneNode *pNode, Nodes)
for (CSceneNode *pNode : Nodes)
{ {
if (!pNode->IsSelected()) if (!pNode->IsSelected())
Nodes.removeOne(pNode); Nodes.removeOne(pNode);
@ -166,33 +167,35 @@ void INodeEditor::BatchDeselectNodes(QList<CSceneNode*> Nodes, const QString& rk
{ {
mUndoStack.beginMacro(rkCommandName); mUndoStack.beginMacro(rkCommandName);
foreach (CSceneNode *pNode, Nodes) for (CSceneNode *pNode : Nodes)
DeselectNode(pNode); DeselectNode(pNode);
mUndoStack.endMacro(); mUndoStack.endMacro();
} }
} }
}
void INodeEditor::ClearSelection() void INodeEditor::ClearSelection()
{ {
if (!mSelectionLocked) if (mSelectionLocked)
{ return;
if (!mpSelection->IsEmpty()) if (!mpSelection->IsEmpty())
mUndoStack.push(new CClearSelectionCommand(mpSelection)); mUndoStack.push(new CClearSelectionCommand(mpSelection));
} }
}
void INodeEditor::ClearAndSelectNode(CSceneNode *pNode) void INodeEditor::ClearAndSelectNode(CSceneNode *pNode)
{ {
if (!mSelectionLocked) if (mSelectionLocked)
{
if (mpSelection->IsEmpty())
mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode));
else if ((mpSelection->Size() == 1) && (mpSelection->Front() == pNode))
return; return;
if (mpSelection->IsEmpty())
{
mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode));
}
else if ((mpSelection->Size() == 1) && (mpSelection->Front() == pNode))
{
return;
}
else else
{ {
mUndoStack.beginMacro(tr("Select")); mUndoStack.beginMacro(tr("Select"));
@ -201,7 +204,6 @@ void INodeEditor::ClearAndSelectNode(CSceneNode *pNode)
mUndoStack.endMacro(); mUndoStack.endMacro();
} }
} }
}
void INodeEditor::SelectAll(FNodeFlags NodeFlags) void INodeEditor::SelectAll(FNodeFlags NodeFlags)
{ {
@ -246,12 +248,12 @@ void INodeEditor::EnterPickMode(FNodeFlags AllowedNodes, bool ExitOnInvalidPick,
void INodeEditor::ExitPickMode() void INodeEditor::ExitPickMode()
{ {
if (mPickMode) if (!mPickMode)
{ return;
mPickMode = false; mPickMode = false;
emit PickModeExited(); emit PickModeExited();
} }
}
void INodeEditor::NotifySelectionTransformed() void INodeEditor::NotifySelectionTransformed()
{ {

View File

@ -60,10 +60,10 @@ public:
CScene* Scene(); CScene* Scene();
CGizmo* Gizmo(); CGizmo* Gizmo();
bool IsGizmoVisible(); bool IsGizmoVisible() const;
void BeginGizmoTransform(); void BeginGizmoTransform();
void EndGizmoTransform(); void EndGizmoTransform();
ETransformSpace CurrentTransformSpace(); ETransformSpace CurrentTransformSpace() const;
void SelectNode(CSceneNode *pNode); void SelectNode(CSceneNode *pNode);
void BatchSelectNodes(QList<CSceneNode*> Nodes, bool ClearExistingSelection, const QString& rkCommandName = "Select"); void BatchSelectNodes(QList<CSceneNode*> Nodes, bool ClearExistingSelection, const QString& rkCommandName = "Select");

View File

@ -237,7 +237,7 @@ void CResourceBrowser::SelectDirectory(CVirtualDirectory *pDir)
void CResourceBrowser::CreateFilterCheckboxes() void CResourceBrowser::CreateFilterCheckboxes()
{ {
// Delete existing checkboxes // Delete existing checkboxes
foreach (const SResourceType& rkType, mTypeList) for (const SResourceType& rkType : mTypeList)
delete rkType.pFilterCheckBox; delete rkType.pFilterCheckBox;
mTypeList.clear(); mTypeList.clear();
@ -257,12 +257,12 @@ void CResourceBrowser::CreateFilterCheckboxes()
mTypeList << SResourceType { pType, pCheck }; mTypeList << SResourceType { pType, pCheck };
} }
std::sort(mTypeList.begin(), mTypeList.end(), [](const SResourceType& rkLeft, const SResourceType& rkRight) -> bool { std::sort(mTypeList.begin(), mTypeList.end(), [](const SResourceType& rkLeft, const SResourceType& rkRight) {
return rkLeft.pTypeInfo->TypeName().ToUpper() < rkRight.pTypeInfo->TypeName().ToUpper(); return rkLeft.pTypeInfo->TypeName().ToUpper() < rkRight.pTypeInfo->TypeName().ToUpper();
}); });
// Add sorted checkboxes to the UI // Add sorted checkboxes to the UI
foreach (const SResourceType& rkType, mTypeList) for (const SResourceType& rkType : mTypeList)
{ {
QCheckBox *pCheck = rkType.pFilterCheckBox; QCheckBox *pCheck = rkType.pFilterCheckBox;
mpFilterBoxesLayout->addWidget(rkType.pFilterCheckBox); mpFilterBoxesLayout->addWidget(rkType.pFilterCheckBox);
@ -380,7 +380,7 @@ bool CResourceBrowser::MoveResources(const QList<CResourceEntry*>& rkResources,
QList<CResourceEntry*> ConflictingResources; QList<CResourceEntry*> ConflictingResources;
QList<CResourceEntry*> ValidResources; QList<CResourceEntry*> ValidResources;
foreach (CResourceEntry *pEntry, rkResources) for (CResourceEntry *pEntry : rkResources)
{ {
CResourceEntry *pConflict = pNewDir->FindChildResource(pEntry->Name(), pEntry->ResourceType()); CResourceEntry *pConflict = pNewDir->FindChildResource(pEntry->Name(), pEntry->ResourceType());
@ -396,7 +396,7 @@ bool CResourceBrowser::MoveResources(const QList<CResourceEntry*>& rkResources,
QList<CVirtualDirectory*> ConflictingDirs; QList<CVirtualDirectory*> ConflictingDirs;
QList<CVirtualDirectory*> ValidDirs; QList<CVirtualDirectory*> ValidDirs;
foreach (CVirtualDirectory *pDir, rkDirectories) for (CVirtualDirectory *pDir : rkDirectories)
{ {
CVirtualDirectory *pConflict = pNewDir->FindChildDirectory(pDir->Name(), false); CVirtualDirectory *pConflict = pNewDir->FindChildDirectory(pDir->Name(), false);
@ -414,12 +414,12 @@ bool CResourceBrowser::MoveResources(const QList<CResourceEntry*>& rkResources,
{ {
QString ErrorMsg = tr("Failed to move; the destination directory has conflicting files.\n\n"); QString ErrorMsg = tr("Failed to move; the destination directory has conflicting files.\n\n");
foreach (CVirtualDirectory *pDir, ConflictingDirs) for (const CVirtualDirectory *pDir : ConflictingDirs)
{ {
ErrorMsg += tr("* %1").arg(TO_QSTRING(pDir->Name())); ErrorMsg += tr("* %1").arg(TO_QSTRING(pDir->Name()));
} }
foreach (CResourceEntry *pEntry, ConflictingResources) for (const CResourceEntry *pEntry : ConflictingResources)
{ {
ErrorMsg += tr("* %1.%2\n").arg(TO_QSTRING(pEntry->Name())).arg(TO_QSTRING(pEntry->CookedExtension().ToString())); ErrorMsg += tr("* %1.%2\n").arg(TO_QSTRING(pEntry->Name())).arg(TO_QSTRING(pEntry->CookedExtension().ToString()));
} }
@ -434,10 +434,10 @@ bool CResourceBrowser::MoveResources(const QList<CResourceEntry*>& rkResources,
mUndoStack.beginMacro(tr("Move Resources")); mUndoStack.beginMacro(tr("Move Resources"));
mUndoStack.push(new CSaveStoreCommand(mpStore)); mUndoStack.push(new CSaveStoreCommand(mpStore));
foreach (CVirtualDirectory* pDir, ValidDirs) for (CVirtualDirectory* pDir : ValidDirs)
mUndoStack.push(new CMoveDirectoryCommand(mpStore, pDir, pNewDir)); mUndoStack.push(new CMoveDirectoryCommand(mpStore, pDir, pNewDir));
foreach (CResourceEntry* pEntry, ValidResources) for (CResourceEntry* pEntry : ValidResources)
mUndoStack.push(new CMoveResourceCommand(pEntry, pNewDir)); mUndoStack.push(new CMoveResourceCommand(pEntry, pNewDir));
mUndoStack.push(new CSaveStoreCommand(mpStore)); mUndoStack.push(new CSaveStoreCommand(mpStore));
@ -744,7 +744,7 @@ bool CResourceBrowser::Delete(QVector<CResourceEntry*> Resources, QVector<CVirtu
mUndoStack.push(new CSaveStoreCommand(mpStore)); mUndoStack.push(new CSaveStoreCommand(mpStore));
// Delete resources first. // Delete resources first.
foreach (CResourceEntry* pEntry, Resources) for (CResourceEntry* pEntry : Resources)
mUndoStack.push(new CDeleteResourceCommand(pEntry)); mUndoStack.push(new CDeleteResourceCommand(pEntry));
// Now delete directories in reverse order (so subdirectories delete first) // Now delete directories in reverse order (so subdirectories delete first)
@ -922,7 +922,7 @@ void CResourceBrowser::ImportPackageContentsList()
SetActiveDirectory(nullptr); SetActiveDirectory(nullptr);
foreach(const QString& rkPath, PathList) for (const QString& rkPath : PathList)
mpStore->ImportNamesFromPakContentsTxt(TO_TSTRING(rkPath), false); mpStore->ImportNamesFromPakContentsTxt(TO_TSTRING(rkPath), false);
RefreshResources(); RefreshResources();
@ -1060,7 +1060,7 @@ void CResourceBrowser::OnFilterTypeBoxTicked(bool Checked)
else if (Checked) else if (Checked)
{ {
foreach (const SResourceType& rkType, mTypeList) for (const SResourceType& rkType : mTypeList)
{ {
rkType.pFilterCheckBox->setChecked(false); rkType.pFilterCheckBox->setChecked(false);
mpProxyModel->SetTypeFilter(rkType.pTypeInfo, false); mpProxyModel->SetTypeFilter(rkType.pTypeInfo, false);
@ -1070,7 +1070,7 @@ void CResourceBrowser::OnFilterTypeBoxTicked(bool Checked)
else else
{ {
foreach (const SResourceType& rkType, mTypeList) for (const SResourceType& rkType : mTypeList)
{ {
if (rkType.pFilterCheckBox == sender()) if (rkType.pFilterCheckBox == sender())
{ {

View File

@ -214,7 +214,7 @@ void CResourceTableContextMenu::Delete()
QVector<CResourceEntry*> Resources; QVector<CResourceEntry*> Resources;
QVector<CVirtualDirectory*> Directories; QVector<CVirtualDirectory*> Directories;
foreach (const QModelIndex& kIndex, mSelectedIndexes) for (const QModelIndex& kIndex : mSelectedIndexes)
{ {
if (mpModel->IsIndexDirectory(kIndex)) if (mpModel->IsIndexDirectory(kIndex))
Directories << mpModel->IndexDirectory(kIndex); Directories << mpModel->IndexDirectory(kIndex);

View File

@ -96,7 +96,7 @@ bool CResourceTableModel::canDropMimeData(const QMimeData *pkData, Qt::DropActio
if (pDir) if (pDir)
{ {
// Make sure this directory isn't part of the mime data, or a subdirectory of a directory in the mime data // Make sure this directory isn't part of the mime data, or a subdirectory of a directory in the mime data
foreach (CVirtualDirectory *pMimeDir, pkMimeData->Directories()) for (CVirtualDirectory *pMimeDir : pkMimeData->Directories())
{ {
if (pDir == pMimeDir || pDir->IsDescendantOf(pMimeDir)) if (pDir == pMimeDir || pDir->IsDescendantOf(pMimeDir))
return false; return false;
@ -132,13 +132,15 @@ QMimeData* CResourceTableModel::mimeData(const QModelIndexList& rkIndexes) const
QList<CResourceEntry*> Resources; QList<CResourceEntry*> Resources;
QList<CVirtualDirectory*> Dirs; QList<CVirtualDirectory*> Dirs;
foreach(QModelIndex Index, rkIndexes) for (const QModelIndex Index : rkIndexes)
{ {
CResourceEntry *pEntry = IndexEntry(Index); CResourceEntry *pEntry = IndexEntry(Index);
CVirtualDirectory *pDir = IndexDirectory(Index); CVirtualDirectory *pDir = IndexDirectory(Index);
if (pEntry) Resources << pEntry; if (pEntry)
else Dirs << pDir; Resources << pEntry;
else
Dirs << pDir;
} }
return new CResourceMimeData(Resources, Dirs); return new CResourceMimeData(Resources, Dirs);

View File

@ -47,9 +47,9 @@ void CResourceTableView::DeleteSelected()
QVector<CResourceEntry*> ResourcesToDelete; QVector<CResourceEntry*> ResourcesToDelete;
QVector<CVirtualDirectory*> DirsToDelete; QVector<CVirtualDirectory*> DirsToDelete;
foreach (QModelIndex Index, List) for (const QModelIndex Index : List)
{ {
QModelIndex SourceIndex = pProxy->mapToSource(Index); const QModelIndex SourceIndex = pProxy->mapToSource(Index);
if (pModel->IsIndexDirectory(SourceIndex)) if (pModel->IsIndexDirectory(SourceIndex))
DirsToDelete << pModel->IndexDirectory(SourceIndex); DirsToDelete << pModel->IndexDirectory(SourceIndex);

View File

@ -138,7 +138,7 @@ bool CVirtualDirectoryModel::canDropMimeData(const QMimeData *pkData, Qt::DropAc
if (pkMimeData) if (pkMimeData)
{ {
// Don't allow moving a directory into one of its children // Don't allow moving a directory into one of its children
foreach (CVirtualDirectory *pMoveDir, pkMimeData->Directories()) for (CVirtualDirectory *pMoveDir : pkMimeData->Directories())
{ {
if (pDir->IsDescendantOf(pMoveDir)) if (pDir->IsDescendantOf(pMoveDir))
return false; return false;
@ -222,7 +222,7 @@ QModelIndex CVirtualDirectoryModel::GetIndexForDirectory(CVirtualDirectory *pDir
// Traverse hierarchy // Traverse hierarchy
QModelIndex Out = index(0, 0, QModelIndex()); QModelIndex Out = index(0, 0, QModelIndex());
foreach (int Idx, Indices) for (const int Idx : Indices)
Out = index(Idx, 0, Out); Out = index(Idx, 0, Out);
ASSERT(IndexDirectory(Out) == pOriginal); ASSERT(IndexDirectory(Out) == pOriginal);

View File

@ -5,7 +5,7 @@ CChangeLayerCommand::CChangeLayerCommand(CWorldEditor *pEditor, const QList<CScr
, mpNewLayer(pNewLayer) , mpNewLayer(pNewLayer)
, mpEditor(pEditor) , mpEditor(pEditor)
{ {
foreach (CScriptNode *pNode, rkNodeList) for (CScriptNode *pNode : rkNodeList)
{ {
CScriptLayer *pLayer = pNode->Instance()->Layer(); CScriptLayer *pLayer = pNode->Instance()->Layer();
@ -23,9 +23,10 @@ void CChangeLayerCommand::undo()
QList<CSceneNode*> Nodes = mNodes.DereferenceList(); QList<CSceneNode*> Nodes = mNodes.DereferenceList();
QList<CScriptNode*> ScriptNodes; QList<CScriptNode*> ScriptNodes;
foreach (CSceneNode *pNode, Nodes) ScriptNodes << static_cast<CScriptNode*>(pNode); for (CSceneNode* pNode : Nodes)
ScriptNodes << static_cast<CScriptNode*>(pNode);
foreach (CScriptNode *pNode, ScriptNodes) for (CScriptNode *pNode : ScriptNodes)
pNode->Instance()->SetLayer(mOldLayers[pNode->ID()]); pNode->Instance()->SetLayer(mOldLayers[pNode->ID()]);
mpEditor->InstancesLayerChanged(ScriptNodes); mpEditor->InstancesLayerChanged(ScriptNodes);
@ -37,9 +38,10 @@ void CChangeLayerCommand::redo()
QList<CSceneNode*> Nodes = mNodes.DereferenceList(); QList<CSceneNode*> Nodes = mNodes.DereferenceList();
QList<CScriptNode*> ScriptNodes; QList<CScriptNode*> ScriptNodes;
foreach (CSceneNode *pNode, Nodes) ScriptNodes << static_cast<CScriptNode*>(pNode); for (CSceneNode* pNode : Nodes)
ScriptNodes << static_cast<CScriptNode*>(pNode);
foreach (CScriptNode *pNode, ScriptNodes) for (CScriptNode *pNode : ScriptNodes)
pNode->Instance()->SetLayer(mpNewLayer); pNode->Instance()->SetLayer(mpNewLayer);
mpEditor->InstancesLayerChanged(ScriptNodes); mpEditor->InstancesLayerChanged(ScriptNodes);

View File

@ -33,7 +33,7 @@ void CCloneSelectionCommand::undo()
QList<CSceneNode*> ClonedNodes = mClonedNodes.DereferenceList(); QList<CSceneNode*> ClonedNodes = mClonedNodes.DereferenceList();
mpEditor->Selection()->Clear(); mpEditor->Selection()->Clear();
foreach (CSceneNode *pNode, ClonedNodes) for (CSceneNode *pNode : ClonedNodes)
{ {
CScriptObject *pInst = static_cast<CScriptNode*>(pNode)->Instance(); CScriptObject *pInst = static_cast<CScriptNode*>(pNode)->Instance();
@ -56,7 +56,7 @@ void CCloneSelectionCommand::redo()
QList<uint32> ClonedInstanceIDs; QList<uint32> ClonedInstanceIDs;
// Clone nodes // Clone nodes
foreach (CSceneNode *pNode, ToClone) for (CSceneNode *pNode : ToClone)
{ {
mpEditor->NotifyNodeAboutToBeSpawned(); mpEditor->NotifyNodeAboutToBeSpawned();
CScriptNode *pScript = static_cast<CScriptNode*>(pNode); CScriptNode *pScript = static_cast<CScriptNode*>(pNode);
@ -101,7 +101,7 @@ void CCloneSelectionCommand::redo()
} }
// Call LoadFinished // Call LoadFinished
foreach (CSceneNode *pNode, ClonedNodes) for (CSceneNode *pNode : ClonedNodes)
pNode->OnLoadFinished(); pNode->OnLoadFinished();
mpEditor->OnLinksModified(mLinkedInstances.DereferenceList()); mpEditor->OnLinksModified(mLinkedInstances.DereferenceList());

View File

@ -75,7 +75,7 @@ CDeleteSelectionCommand::CDeleteSelectionCommand(CWorldEditor *pEditor, const QS
// Remove selected objects from the linked instances list. // Remove selected objects from the linked instances list.
LinkedInstances.removeAll(nullptr); LinkedInstances.removeAll(nullptr);
foreach (CScriptObject *pInst, LinkedInstances) for (CScriptObject *pInst : LinkedInstances)
{ {
if (mpEditor->Scene()->NodeForInstance(pInst)->IsSelected()) if (mpEditor->Scene()->NodeForInstance(pInst)->IsSelected())
LinkedInstances.removeOne(pInst); LinkedInstances.removeOne(pInst);
@ -144,7 +144,7 @@ void CDeleteSelectionCommand::undo()
} }
// Run OnLoadFinished // Run OnLoadFinished
foreach (CSceneNode *pNode, NewNodes) for (CSceneNode *pNode : NewNodes)
pNode->OnLoadFinished(); pNode->OnLoadFinished();
// Add selection and done // Add selection and done

View File

@ -25,7 +25,7 @@ void CPasteNodesCommand::undo()
mpEditor->Selection()->SetSelectedNodes(mOriginalSelection.DereferenceList()); mpEditor->Selection()->SetSelectedNodes(mOriginalSelection.DereferenceList());
QList<CSceneNode*> PastedNodes = mPastedNodes.DereferenceList(); QList<CSceneNode*> PastedNodes = mPastedNodes.DereferenceList();
foreach (CSceneNode *pNode, PastedNodes) for (CSceneNode *pNode : PastedNodes)
{ {
CScriptObject *pInst = (pNode->NodeType() == ENodeType::Script ? static_cast<CScriptNode*>(pNode)->Instance() : nullptr); CScriptObject *pInst = (pNode->NodeType() == ENodeType::Script ? static_cast<CScriptNode*>(pNode)->Instance() : nullptr);
mpEditor->NotifyNodeAboutToBeDeleted(pNode); mpEditor->NotifyNodeAboutToBeDeleted(pNode);
@ -41,14 +41,15 @@ void CPasteNodesCommand::undo()
void CPasteNodesCommand::redo() void CPasteNodesCommand::redo()
{ {
if (!mpMimeData) return; if (!mpMimeData)
return;
const QVector<CNodeCopyMimeData::SCopiedNode>& rkNodes = mpMimeData->CopiedNodes(); const QVector<CNodeCopyMimeData::SCopiedNode>& rkNodes = mpMimeData->CopiedNodes();
CScene *pScene = mpEditor->Scene(); CScene *pScene = mpEditor->Scene();
CGameArea *pArea = mpEditor->ActiveArea(); CGameArea *pArea = mpEditor->ActiveArea();
QList<CSceneNode*> PastedNodes; QList<CSceneNode*> PastedNodes;
foreach (const CNodeCopyMimeData::SCopiedNode& rkNode, rkNodes) for (const CNodeCopyMimeData::SCopiedNode& rkNode : rkNodes)
{ {
CSceneNode *pNewNode = nullptr; CSceneNode *pNewNode = nullptr;
@ -87,7 +88,7 @@ void CPasteNodesCommand::redo()
// 1. If the link receiver has also been copied then redirect to the copied version. // 1. If the link receiver has also been copied then redirect to the copied version.
// 2. If we're pasting into the same area that this data was copied from and the receiver still exists, connect to original receiver. // 2. If we're pasting into the same area that this data was copied from and the receiver still exists, connect to original receiver.
// 3. If neither of those things is true, then delete the link. // 3. If neither of those things is true, then delete the link.
foreach (CSceneNode *pNode, PastedNodes) for (CSceneNode *pNode : PastedNodes)
{ {
if (pNode && pNode->NodeType() == ENodeType::Script) if (pNode && pNode->NodeType() == ENodeType::Script)
{ {
@ -126,7 +127,7 @@ void CPasteNodesCommand::redo()
// Call PostLoad on all new nodes and select them // Call PostLoad on all new nodes and select them
PastedNodes.removeAll(nullptr); PastedNodes.removeAll(nullptr);
foreach (CSceneNode *pNode, PastedNodes) for (CSceneNode *pNode : PastedNodes)
pNode->OnLoadFinished(); pNode->OnLoadFinished();
mpEditor->Selection()->SetSelectedNodes(PastedNodes); mpEditor->Selection()->SetSelectedNodes(PastedNodes);

View File

@ -21,7 +21,7 @@ CRotateNodeCommand::CRotateNodeCommand(
{ {
mNodeList.reserve(rkNodes.size()); mNodeList.reserve(rkNodes.size());
foreach (CSceneNode *pNode, rkNodes) for (CSceneNode *pNode : rkNodes)
{ {
SNodeRotate Rotate; SNodeRotate Rotate;
Rotate.pNode = pNode; Rotate.pNode = pNode;
@ -83,7 +83,7 @@ void CRotateNodeCommand::undo()
{ {
if (!mpEditor) return; if (!mpEditor) return;
foreach (SNodeRotate Rotate, mNodeList) for (SNodeRotate& Rotate : mNodeList)
{ {
Rotate.pNode->SetPosition(Rotate.InitialPos); Rotate.pNode->SetPosition(Rotate.InitialPos);
Rotate.pNode->SetRotation(Rotate.InitialRot); Rotate.pNode->SetRotation(Rotate.InitialRot);
@ -97,7 +97,7 @@ void CRotateNodeCommand::redo()
{ {
if (!mpEditor) return; if (!mpEditor) return;
foreach (SNodeRotate Rotate, mNodeList) for (SNodeRotate& Rotate : mNodeList)
{ {
Rotate.pNode->SetPosition(Rotate.NewPos); Rotate.pNode->SetPosition(Rotate.NewPos);
Rotate.pNode->SetRotation(Rotate.NewRot); Rotate.pNode->SetRotation(Rotate.NewRot);

View File

@ -13,7 +13,7 @@ CScaleNodeCommand::CScaleNodeCommand(INodeEditor *pEditor, const QList<CSceneNod
{ {
mNodeList.reserve(rkNodes.size()); mNodeList.reserve(rkNodes.size());
foreach (CSceneNode *pNode, rkNodes) for (CSceneNode *pNode : rkNodes)
{ {
SNodeScale Scale; SNodeScale Scale;
Scale.pNode = pNode; Scale.pNode = pNode;
@ -74,9 +74,10 @@ bool CScaleNodeCommand::mergeWith(const QUndoCommand *pkOther)
void CScaleNodeCommand::undo() void CScaleNodeCommand::undo()
{ {
if (!mpEditor) return; if (!mpEditor)
return;
foreach (SNodeScale Scale, mNodeList) for (SNodeScale& Scale : mNodeList)
{ {
Scale.pNode->SetPosition(Scale.InitialPos); Scale.pNode->SetPosition(Scale.InitialPos);
Scale.pNode->SetScale(Scale.InitialScale); Scale.pNode->SetScale(Scale.InitialScale);
@ -88,9 +89,10 @@ void CScaleNodeCommand::undo()
void CScaleNodeCommand::redo() void CScaleNodeCommand::redo()
{ {
if (!mpEditor) return; if (!mpEditor)
return;
foreach (SNodeScale Scale, mNodeList) for (SNodeScale& Scale : mNodeList)
{ {
Scale.pNode->SetPosition(Scale.NewPos); Scale.pNode->SetPosition(Scale.NewPos);
Scale.pNode->SetScale(Scale.NewScale); Scale.pNode->SetScale(Scale.NewScale);

View File

@ -13,7 +13,7 @@ CTranslateNodeCommand::CTranslateNodeCommand(INodeEditor *pEditor, const QList<C
{ {
mNodeList.reserve(rkNodes.size()); mNodeList.reserve(rkNodes.size());
foreach (CSceneNode *pNode, rkNodes) for (CSceneNode *pNode : rkNodes)
{ {
SNodeTranslate Translate; SNodeTranslate Translate;
Translate.pNode = pNode; Translate.pNode = pNode;
@ -59,9 +59,10 @@ bool CTranslateNodeCommand::mergeWith(const QUndoCommand *pkOther)
void CTranslateNodeCommand::undo() void CTranslateNodeCommand::undo()
{ {
if (!mpEditor) return; if (!mpEditor)
return;
foreach (SNodeTranslate Translate, mNodeList) for (SNodeTranslate& Translate : mNodeList)
Translate.pNode->SetPosition(Translate.InitialPos); Translate.pNode->SetPosition(Translate.InitialPos);
mpEditor->NotifySelectionTransformed(); mpEditor->NotifySelectionTransformed();
@ -70,9 +71,10 @@ void CTranslateNodeCommand::undo()
void CTranslateNodeCommand::redo() void CTranslateNodeCommand::redo()
{ {
if (!mpEditor) return; if (!mpEditor)
return;
foreach (SNodeTranslate Translate, mNodeList) for (SNodeTranslate& Translate : mNodeList)
Translate.pNode->SetPosition(Translate.NewPos); Translate.pNode->SetPosition(Translate.NewPos);
mpEditor->NotifySelectionTransformed(); mpEditor->NotifySelectionTransformed();

View File

@ -11,7 +11,7 @@ void IEditPropertyCommand::SaveObjectStateToArray(std::vector<char>& rVector)
QVector<void*> DataPointers; QVector<void*> DataPointers;
GetObjectDataPointers(DataPointers); GetObjectDataPointers(DataPointers);
foreach (void* pData, DataPointers) for (void* pData : DataPointers)
{ {
mpProperty->SerializeValue(pData, Writer); mpProperty->SerializeValue(pData, Writer);
} }
@ -25,7 +25,7 @@ void IEditPropertyCommand::RestoreObjectStateFromArray(std::vector<char>& rArray
QVector<void*> DataPointers; QVector<void*> DataPointers;
GetObjectDataPointers(DataPointers); GetObjectDataPointers(DataPointers);
foreach (void* pData, DataPointers) for (void* pData : DataPointers)
{ {
mpProperty->SerializeValue(pData, Reader); mpProperty->SerializeValue(pData, Reader);
} }

View File

@ -508,7 +508,7 @@ void CInstancesModel::InstancesLayerPreChange()
void CInstancesModel::InstancesLayerPostChange(const QList<CScriptNode*>& rkInstanceList) void CInstancesModel::InstancesLayerPostChange(const QList<CScriptNode*>& rkInstanceList)
{ {
QList<CScriptObject*> InstanceList; QList<CScriptObject*> InstanceList;
foreach (CScriptNode *pNode, rkInstanceList) for (CScriptNode *pNode : rkInstanceList)
InstanceList << pNode->Instance(); InstanceList << pNode->Instance();
QModelIndex ScriptIdx = index(0, 0, QModelIndex()); QModelIndex ScriptIdx = index(0, 0, QModelIndex());

View File

@ -126,7 +126,7 @@ public slots:
{ {
QModelIndexList SelectedIndices = mpListView->selectionModel()->selectedRows(); QModelIndexList SelectedIndices = mpListView->selectionModel()->selectedRows();
foreach (const QModelIndex& rkIndex, SelectedIndices) for (const QModelIndex& rkIndex : SelectedIndices)
{ {
QModelIndex SourceIndex = mModel.mapToSource(rkIndex); QModelIndex SourceIndex = mModel.mapToSource(rkIndex);
mSelection << mSourceModel.PoiForIndex(SourceIndex); mSelection << mSourceModel.PoiForIndex(SourceIndex);

View File

@ -205,10 +205,10 @@ void CPoiMapSidebar::UpdateModelHighlights()
} }
} }
foreach (const QModelIndex& rkIndex, UnselectedIndices) for (const QModelIndex& rkIndex : UnselectedIndices)
UnhighlightPoiModels(rkIndex); UnhighlightPoiModels(rkIndex);
foreach (const QModelIndex& rkIndex, SelectedIndices) for (const QModelIndex& rkIndex : SelectedIndices)
HighlightPoiModels(rkIndex); HighlightPoiModels(rkIndex);
} }
@ -264,7 +264,7 @@ void CPoiMapSidebar::OnUnmapAllPressed()
QModelIndex Index = GetSelectedRow(); QModelIndex Index = GetSelectedRow();
QList<CModelNode*> ModelList = mSourceModel.GetPoiMeshList(Index); QList<CModelNode*> ModelList = mSourceModel.GetPoiMeshList(Index);
foreach (CModelNode *pModel, ModelList) for (CModelNode *pModel : ModelList)
{ {
mSourceModel.RemoveMapping(Index, pModel); mSourceModel.RemoveMapping(Index, pModel);
RevertModelOverlay(pModel); RevertModelOverlay(pModel);
@ -343,7 +343,7 @@ void CPoiMapSidebar::OnInstanceListButtonClicked()
if (!rkSelection.empty()) if (!rkSelection.empty())
{ {
foreach (CScriptNode *pNode, rkSelection) for (CScriptNode *pNode : rkSelection)
mSourceModel.AddPOI(pNode); mSourceModel.AddPOI(pNode);
mModel.sort(0); mModel.sort(0);

View File

@ -238,7 +238,7 @@ void CTemplateEditDialog::UpdateDescription(const TString& rkNewDesc)
} }
// Update equivalent properties with new description // Update equivalent properties with new description
foreach (IProperty* pProperty, mEquivalentProperties) for (IProperty* pProperty : mEquivalentProperties)
{ {
pProperty->SetDescription(rkNewDesc); pProperty->SetDescription(rkNewDesc);
} }

View File

@ -557,7 +557,7 @@ void CWorldEditor::OnActiveProjectChanged(CGameProject *pProj)
void CWorldEditor::OnLinksModified(const QList<CScriptObject*>& rkInstances) void CWorldEditor::OnLinksModified(const QList<CScriptObject*>& rkInstances)
{ {
foreach (CScriptObject *pInstance, rkInstances) for (CScriptObject *pInstance : rkInstances)
{ {
CScriptNode *pNode = mScene.NodeForInstance(pInstance); CScriptNode *pNode = mScene.NodeForInstance(pInstance);
pNode->LinksModified(); pNode->LinksModified();
@ -665,7 +665,7 @@ void CWorldEditor::SetSelectionActive(bool Active)
pCommand->SaveOldData(); pCommand->SaveOldData();
foreach (CScriptObject* pInstance, CommandObjects) for (CScriptObject* pInstance : CommandObjects)
pInstance->SetActive(Active); pInstance->SetActive(Active);
pCommand->SaveNewData(); pCommand->SaveNewData();
@ -736,7 +736,7 @@ void CWorldEditor::UpdateOpenRecentActions()
} }
// Remove projects that don't exist anymore // Remove projects that don't exist anymore
foreach (const QString& rkProj, RecentProjectsList) for (const QString& rkProj : RecentProjectsList)
{ {
if (!FileUtil::Exists( TO_TSTRING(rkProj) ) || rkProj.contains('\\') ) if (!FileUtil::Exists( TO_TSTRING(rkProj) ) || rkProj.contains('\\') )
RecentProjectsList.removeAll(rkProj); RecentProjectsList.removeAll(rkProj);
@ -1114,7 +1114,7 @@ void CWorldEditor::OnUnlinkClicked()
bool UnlinkIncoming = (Dialog.UserChoice() != CConfirmUnlinkDialog::EChoice::OutgoingOnly); bool UnlinkIncoming = (Dialog.UserChoice() != CConfirmUnlinkDialog::EChoice::OutgoingOnly);
bool UnlinkOutgoing = (Dialog.UserChoice() != CConfirmUnlinkDialog::EChoice::IncomingOnly); bool UnlinkOutgoing = (Dialog.UserChoice() != CConfirmUnlinkDialog::EChoice::IncomingOnly);
foreach (CScriptNode *pNode, SelectedScriptNodes) for (CScriptNode *pNode : SelectedScriptNodes)
{ {
CScriptObject *pInst = pNode->Instance(); CScriptObject *pInst = pNode->Instance();

View File

@ -226,7 +226,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
pProj->GetWorldList(WorldIDs); pProj->GetWorldList(WorldIDs);
QList<CAssetID> QWorldIDs = QList<CAssetID>::fromStdList(WorldIDs); QList<CAssetID> QWorldIDs = QList<CAssetID>::fromStdList(WorldIDs);
foreach (const CAssetID& rkID, QWorldIDs) for (const CAssetID& rkID : QWorldIDs)
{ {
CResourceEntry *pEntry = pProj->ResourceStore()->FindEntry(rkID); CResourceEntry *pEntry = pProj->ResourceStore()->FindEntry(rkID);