diff --git a/src/Editor/CEditorApplication.cpp b/src/Editor/CEditorApplication.cpp index c837518d..02ea769a 100644 --- a/src/Editor/CEditorApplication.cpp +++ b/src/Editor/CEditorApplication.cpp @@ -49,7 +49,7 @@ bool CEditorApplication::CloseAllEditors() return true; // Close active editor windows. - foreach (IEditor *pEditor, mEditorWindows) + for (IEditor *pEditor : mEditorWindows) { if (pEditor != mpWorldEditor && !pEditor->close()) return false; @@ -318,16 +318,20 @@ void CEditorApplication::TickEditors() gpResourceStore->ConditionalSaveStore(); // Tick each editor window and redraw their viewports - foreach(IEditor *pEditor, mEditorWindows) + for (IEditor *pEditor : mEditorWindows) { if (pEditor->isVisible()) { CBasicViewport *pViewport = pEditor->Viewport(); - bool ViewportVisible = (pViewport && pViewport->isVisible() && !pEditor->isMinimized()); + const bool ViewportVisible = (pViewport && pViewport->isVisible() && !pEditor->isMinimized()); - if (ViewportVisible) pViewport->ProcessInput(); - pEditor->EditorTick((float) DeltaTime); - if (ViewportVisible) pViewport->Render(); + if (ViewportVisible) + pViewport->ProcessInput(); + + pEditor->EditorTick(static_cast(DeltaTime)); + + if (ViewportVisible) + pViewport->Render(); } } } diff --git a/src/Editor/CNodeSelection.h b/src/Editor/CNodeSelection.h index 1f4f0893..396bb194 100644 --- a/src/Editor/CNodeSelection.h +++ b/src/Editor/CNodeSelection.h @@ -22,7 +22,7 @@ public: ~CNodeSelection() override { - foreach (CSceneNode *pNode, mSelectedNodes) + for (CSceneNode *pNode : mSelectedNodes) pNode->SetSelected(false); } @@ -50,7 +50,7 @@ public: void Clear() { - foreach (CSceneNode *pNode, mSelectedNodes) + for (CSceneNode *pNode : mSelectedNodes) pNode->SetSelected(false); mSelectedNodes.clear(); @@ -72,7 +72,7 @@ public: blockSignals(true); Clear(); - foreach (CSceneNode *pNode, rkList) + for (CSceneNode *pNode : rkList) SelectNode(pNode); blockSignals(false); @@ -86,7 +86,7 @@ public: { mCachedBounds = CAABox::Infinite(); - foreach (CSceneNode *pNode, mSelectedNodes) + for (CSceneNode *pNode : mSelectedNodes) { mCachedBounds.ExpandBounds(pNode->AABox()); diff --git a/src/Editor/CSceneViewport.cpp b/src/Editor/CSceneViewport.cpp index 3803b57b..86a67e83 100644 --- a/src/Editor/CSceneViewport.cpp +++ b/src/Editor/CSceneViewport.cpp @@ -438,7 +438,7 @@ void CSceneViewport::OnSelectConnected() FindConnectedObjects(static_cast(mpMenuNode)->Instance()->InstanceID(), SearchOutgoing, SearchIncoming, InstanceIDs); QList Nodes; - foreach (uint32 ID, InstanceIDs) + for (const uint32 ID : InstanceIDs) Nodes << mpScene->NodeForInstanceID(ID); const bool ShouldClear = ((qApp->keyboardModifiers() & Qt::ControlModifier) == 0); diff --git a/src/Editor/CTweakEditor.cpp b/src/Editor/CTweakEditor.cpp index 7bf4ff3f..856a0540 100644 --- a/src/Editor/CTweakEditor.cpp +++ b/src/Editor/CTweakEditor.cpp @@ -129,9 +129,9 @@ void CTweakEditor::OnProjectChanged(CGameProject* pNewProject) 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); } diff --git a/src/Editor/INodeEditor.cpp b/src/Editor/INodeEditor.cpp index 69e8666d..b3dd4093 100644 --- a/src/Editor/INodeEditor.cpp +++ b/src/Editor/INodeEditor.cpp @@ -20,7 +20,7 @@ INodeEditor::INodeEditor(QWidget *pParent) mpGizmoGroup = new QActionGroup(this); - foreach (QAction *pAction, mGizmoActions) + for (QAction *pAction : mGizmoActions) { pAction->setCheckable(true); mpGizmoGroup->addAction(pAction); @@ -57,7 +57,7 @@ CGizmo* INodeEditor::Gizmo() return &mGizmo; } -bool INodeEditor::IsGizmoVisible() +bool INodeEditor::IsGizmoVisible() const { return (mShowGizmo && !mpSelection->IsEmpty()); } @@ -68,7 +68,7 @@ void INodeEditor::BeginGizmoTransform() if ((qApp->keyboardModifiers() & Qt::ShiftModifier) != 0) mCloneState = ECloneState::ReadyToClone; - foreach (QAction *pAction, mGizmoActions) + for (QAction *pAction : mGizmoActions) pAction->setEnabled(false); } @@ -76,7 +76,7 @@ void INodeEditor::EndGizmoTransform() { mGizmoTransforming = false; - foreach (QAction *pAction, mGizmoActions) + for (QAction *pAction : mGizmoActions) pAction->setEnabled(true); if (mGizmo.HasTransformed()) @@ -95,7 +95,7 @@ void INodeEditor::EndGizmoTransform() mCloneState = ECloneState::NotCloning; } -ETransformSpace INodeEditor::CurrentTransformSpace() +ETransformSpace INodeEditor::CurrentTransformSpace() const { switch (mGizmo.Mode()) { @@ -108,98 +108,100 @@ ETransformSpace INodeEditor::CurrentTransformSpace() void INodeEditor::SelectNode(CSceneNode *pNode) { - if (!mSelectionLocked) - { - if (!pNode->IsSelected()) - mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode)); - } + if (mSelectionLocked) + return; + + if (!pNode->IsSelected()) + mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode)); } void INodeEditor::BatchSelectNodes(QList Nodes, bool ClearExistingSelection, const QString& rkCommandName /*= "Select"*/) { - if (!mSelectionLocked) + if (mSelectionLocked) + return; + + if (!ClearExistingSelection) { - if (!ClearExistingSelection) + for (CSceneNode *pNode : Nodes) { - foreach (CSceneNode *pNode, Nodes) - { - if (pNode->IsSelected()) - Nodes.removeOne(pNode); - } + if (pNode->IsSelected()) + Nodes.removeOne(pNode); } + } - if (Nodes.size() > 0) - { - mUndoStack.beginMacro(rkCommandName); + if (Nodes.size() > 0) + { + mUndoStack.beginMacro(rkCommandName); - if (ClearExistingSelection) - ClearSelection(); + if (ClearExistingSelection) + ClearSelection(); - foreach (CSceneNode *pNode, Nodes) - SelectNode(pNode); + for (CSceneNode *pNode : Nodes) + SelectNode(pNode); - mUndoStack.endMacro(); - } + mUndoStack.endMacro(); } } void INodeEditor::DeselectNode(CSceneNode *pNode) { - if (!mSelectionLocked) - { - if (pNode->IsSelected()) - mUndoStack.push(new CDeselectNodeCommand(mpSelection, pNode)); - } + if (mSelectionLocked) + return; + + if (pNode->IsSelected()) + mUndoStack.push(new CDeselectNodeCommand(mpSelection, pNode)); } void INodeEditor::BatchDeselectNodes(QList Nodes, const QString& rkCommandName /*= "Deselect"*/) { - if (!mSelectionLocked) + if (mSelectionLocked) + return; + + for (CSceneNode *pNode : Nodes) { - foreach (CSceneNode *pNode, Nodes) - { - if (!pNode->IsSelected()) - Nodes.removeOne(pNode); - } + if (!pNode->IsSelected()) + Nodes.removeOne(pNode); + } - if (Nodes.size() > 0) - { - mUndoStack.beginMacro(rkCommandName); + if (Nodes.size() > 0) + { + mUndoStack.beginMacro(rkCommandName); - foreach (CSceneNode *pNode, Nodes) - DeselectNode(pNode); + for (CSceneNode *pNode : Nodes) + DeselectNode(pNode); - mUndoStack.endMacro(); - } + mUndoStack.endMacro(); } } void INodeEditor::ClearSelection() { - if (!mSelectionLocked) - { - if (!mpSelection->IsEmpty()) - mUndoStack.push(new CClearSelectionCommand(mpSelection)); - } + if (mSelectionLocked) + return; + + if (!mpSelection->IsEmpty()) + mUndoStack.push(new CClearSelectionCommand(mpSelection)); } void INodeEditor::ClearAndSelectNode(CSceneNode *pNode) { - if (!mSelectionLocked) + if (mSelectionLocked) + return; + + if (mpSelection->IsEmpty()) { - if (mpSelection->IsEmpty()) - mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode)); - - else if ((mpSelection->Size() == 1) && (mpSelection->Front() == pNode)) - return; - - else - { - mUndoStack.beginMacro(tr("Select")); - mUndoStack.push(new CClearSelectionCommand(mpSelection)); - mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode)); - mUndoStack.endMacro(); - } + mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode)); + } + else if ((mpSelection->Size() == 1) && (mpSelection->Front() == pNode)) + { + return; + } + else + { + mUndoStack.beginMacro(tr("Select")); + mUndoStack.push(new CClearSelectionCommand(mpSelection)); + mUndoStack.push(new CSelectNodeCommand(mpSelection, pNode)); + mUndoStack.endMacro(); } } @@ -246,11 +248,11 @@ void INodeEditor::EnterPickMode(FNodeFlags AllowedNodes, bool ExitOnInvalidPick, void INodeEditor::ExitPickMode() { - if (mPickMode) - { - mPickMode = false; - emit PickModeExited(); - } + if (!mPickMode) + return; + + mPickMode = false; + emit PickModeExited(); } void INodeEditor::NotifySelectionTransformed() diff --git a/src/Editor/INodeEditor.h b/src/Editor/INodeEditor.h index 69ad83e1..9a2c2e7f 100644 --- a/src/Editor/INodeEditor.h +++ b/src/Editor/INodeEditor.h @@ -60,10 +60,10 @@ public: CScene* Scene(); CGizmo* Gizmo(); - bool IsGizmoVisible(); + bool IsGizmoVisible() const; void BeginGizmoTransform(); void EndGizmoTransform(); - ETransformSpace CurrentTransformSpace(); + ETransformSpace CurrentTransformSpace() const; void SelectNode(CSceneNode *pNode); void BatchSelectNodes(QList Nodes, bool ClearExistingSelection, const QString& rkCommandName = "Select"); diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.cpp b/src/Editor/ResourceBrowser/CResourceBrowser.cpp index 52fcda0e..ed65d886 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.cpp +++ b/src/Editor/ResourceBrowser/CResourceBrowser.cpp @@ -237,7 +237,7 @@ void CResourceBrowser::SelectDirectory(CVirtualDirectory *pDir) void CResourceBrowser::CreateFilterCheckboxes() { // Delete existing checkboxes - foreach (const SResourceType& rkType, mTypeList) + for (const SResourceType& rkType : mTypeList) delete rkType.pFilterCheckBox; mTypeList.clear(); @@ -257,12 +257,12 @@ void CResourceBrowser::CreateFilterCheckboxes() 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(); }); // Add sorted checkboxes to the UI - foreach (const SResourceType& rkType, mTypeList) + for (const SResourceType& rkType : mTypeList) { QCheckBox *pCheck = rkType.pFilterCheckBox; mpFilterBoxesLayout->addWidget(rkType.pFilterCheckBox); @@ -380,7 +380,7 @@ bool CResourceBrowser::MoveResources(const QList& rkResources, QList ConflictingResources; QList ValidResources; - foreach (CResourceEntry *pEntry, rkResources) + for (CResourceEntry *pEntry : rkResources) { CResourceEntry *pConflict = pNewDir->FindChildResource(pEntry->Name(), pEntry->ResourceType()); @@ -396,7 +396,7 @@ bool CResourceBrowser::MoveResources(const QList& rkResources, QList ConflictingDirs; QList ValidDirs; - foreach (CVirtualDirectory *pDir, rkDirectories) + for (CVirtualDirectory *pDir : rkDirectories) { CVirtualDirectory *pConflict = pNewDir->FindChildDirectory(pDir->Name(), false); @@ -414,12 +414,12 @@ bool CResourceBrowser::MoveResources(const QList& rkResources, { 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())); } - 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())); } @@ -434,10 +434,10 @@ bool CResourceBrowser::MoveResources(const QList& rkResources, mUndoStack.beginMacro(tr("Move Resources")); mUndoStack.push(new CSaveStoreCommand(mpStore)); - foreach (CVirtualDirectory* pDir, ValidDirs) + for (CVirtualDirectory* pDir : ValidDirs) mUndoStack.push(new CMoveDirectoryCommand(mpStore, pDir, pNewDir)); - foreach (CResourceEntry* pEntry, ValidResources) + for (CResourceEntry* pEntry : ValidResources) mUndoStack.push(new CMoveResourceCommand(pEntry, pNewDir)); mUndoStack.push(new CSaveStoreCommand(mpStore)); @@ -744,7 +744,7 @@ bool CResourceBrowser::Delete(QVector Resources, QVectorImportNamesFromPakContentsTxt(TO_TSTRING(rkPath), false); RefreshResources(); @@ -1060,7 +1060,7 @@ void CResourceBrowser::OnFilterTypeBoxTicked(bool Checked) else if (Checked) { - foreach (const SResourceType& rkType, mTypeList) + for (const SResourceType& rkType : mTypeList) { rkType.pFilterCheckBox->setChecked(false); mpProxyModel->SetTypeFilter(rkType.pTypeInfo, false); @@ -1070,7 +1070,7 @@ void CResourceBrowser::OnFilterTypeBoxTicked(bool Checked) else { - foreach (const SResourceType& rkType, mTypeList) + for (const SResourceType& rkType : mTypeList) { if (rkType.pFilterCheckBox == sender()) { diff --git a/src/Editor/ResourceBrowser/CResourceTableContextMenu.cpp b/src/Editor/ResourceBrowser/CResourceTableContextMenu.cpp index 03f0a8e0..6fc863d3 100644 --- a/src/Editor/ResourceBrowser/CResourceTableContextMenu.cpp +++ b/src/Editor/ResourceBrowser/CResourceTableContextMenu.cpp @@ -214,7 +214,7 @@ void CResourceTableContextMenu::Delete() QVector Resources; QVector Directories; - foreach (const QModelIndex& kIndex, mSelectedIndexes) + for (const QModelIndex& kIndex : mSelectedIndexes) { if (mpModel->IsIndexDirectory(kIndex)) Directories << mpModel->IndexDirectory(kIndex); diff --git a/src/Editor/ResourceBrowser/CResourceTableModel.cpp b/src/Editor/ResourceBrowser/CResourceTableModel.cpp index b9c0c747..06c47310 100644 --- a/src/Editor/ResourceBrowser/CResourceTableModel.cpp +++ b/src/Editor/ResourceBrowser/CResourceTableModel.cpp @@ -96,7 +96,7 @@ bool CResourceTableModel::canDropMimeData(const QMimeData *pkData, Qt::DropActio if (pDir) { // 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)) return false; @@ -132,13 +132,15 @@ QMimeData* CResourceTableModel::mimeData(const QModelIndexList& rkIndexes) const QList Resources; QList Dirs; - foreach(QModelIndex Index, rkIndexes) + for (const QModelIndex Index : rkIndexes) { CResourceEntry *pEntry = IndexEntry(Index); CVirtualDirectory *pDir = IndexDirectory(Index); - if (pEntry) Resources << pEntry; - else Dirs << pDir; + if (pEntry) + Resources << pEntry; + else + Dirs << pDir; } return new CResourceMimeData(Resources, Dirs); diff --git a/src/Editor/ResourceBrowser/CResourceTableView.cpp b/src/Editor/ResourceBrowser/CResourceTableView.cpp index bfa76826..f86f9445 100644 --- a/src/Editor/ResourceBrowser/CResourceTableView.cpp +++ b/src/Editor/ResourceBrowser/CResourceTableView.cpp @@ -47,9 +47,9 @@ void CResourceTableView::DeleteSelected() QVector ResourcesToDelete; QVector 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)) DirsToDelete << pModel->IndexDirectory(SourceIndex); diff --git a/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp b/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp index c75b6319..fc4c813d 100644 --- a/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp +++ b/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp @@ -138,7 +138,7 @@ bool CVirtualDirectoryModel::canDropMimeData(const QMimeData *pkData, Qt::DropAc if (pkMimeData) { // 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)) return false; @@ -222,7 +222,7 @@ QModelIndex CVirtualDirectoryModel::GetIndexForDirectory(CVirtualDirectory *pDir // Traverse hierarchy QModelIndex Out = index(0, 0, QModelIndex()); - foreach (int Idx, Indices) + for (const int Idx : Indices) Out = index(Idx, 0, Out); ASSERT(IndexDirectory(Out) == pOriginal); diff --git a/src/Editor/Undo/CChangeLayerCommand.cpp b/src/Editor/Undo/CChangeLayerCommand.cpp index a21f9088..caa263be 100644 --- a/src/Editor/Undo/CChangeLayerCommand.cpp +++ b/src/Editor/Undo/CChangeLayerCommand.cpp @@ -5,7 +5,7 @@ CChangeLayerCommand::CChangeLayerCommand(CWorldEditor *pEditor, const QListInstance()->Layer(); @@ -23,9 +23,10 @@ void CChangeLayerCommand::undo() QList Nodes = mNodes.DereferenceList(); QList ScriptNodes; - foreach (CSceneNode *pNode, Nodes) ScriptNodes << static_cast(pNode); + for (CSceneNode* pNode : Nodes) + ScriptNodes << static_cast(pNode); - foreach (CScriptNode *pNode, ScriptNodes) + for (CScriptNode *pNode : ScriptNodes) pNode->Instance()->SetLayer(mOldLayers[pNode->ID()]); mpEditor->InstancesLayerChanged(ScriptNodes); @@ -37,9 +38,10 @@ void CChangeLayerCommand::redo() QList Nodes = mNodes.DereferenceList(); QList ScriptNodes; - foreach (CSceneNode *pNode, Nodes) ScriptNodes << static_cast(pNode); + for (CSceneNode* pNode : Nodes) + ScriptNodes << static_cast(pNode); - foreach (CScriptNode *pNode, ScriptNodes) + for (CScriptNode *pNode : ScriptNodes) pNode->Instance()->SetLayer(mpNewLayer); mpEditor->InstancesLayerChanged(ScriptNodes); diff --git a/src/Editor/Undo/CCloneSelectionCommand.cpp b/src/Editor/Undo/CCloneSelectionCommand.cpp index 094d4261..825f5017 100644 --- a/src/Editor/Undo/CCloneSelectionCommand.cpp +++ b/src/Editor/Undo/CCloneSelectionCommand.cpp @@ -33,7 +33,7 @@ void CCloneSelectionCommand::undo() QList ClonedNodes = mClonedNodes.DereferenceList(); mpEditor->Selection()->Clear(); - foreach (CSceneNode *pNode, ClonedNodes) + for (CSceneNode *pNode : ClonedNodes) { CScriptObject *pInst = static_cast(pNode)->Instance(); @@ -56,7 +56,7 @@ void CCloneSelectionCommand::redo() QList ClonedInstanceIDs; // Clone nodes - foreach (CSceneNode *pNode, ToClone) + for (CSceneNode *pNode : ToClone) { mpEditor->NotifyNodeAboutToBeSpawned(); CScriptNode *pScript = static_cast(pNode); @@ -101,7 +101,7 @@ void CCloneSelectionCommand::redo() } // Call LoadFinished - foreach (CSceneNode *pNode, ClonedNodes) + for (CSceneNode *pNode : ClonedNodes) pNode->OnLoadFinished(); mpEditor->OnLinksModified(mLinkedInstances.DereferenceList()); diff --git a/src/Editor/Undo/CDeleteSelectionCommand.cpp b/src/Editor/Undo/CDeleteSelectionCommand.cpp index ca68a124..8a1ee3b7 100644 --- a/src/Editor/Undo/CDeleteSelectionCommand.cpp +++ b/src/Editor/Undo/CDeleteSelectionCommand.cpp @@ -75,7 +75,7 @@ CDeleteSelectionCommand::CDeleteSelectionCommand(CWorldEditor *pEditor, const QS // Remove selected objects from the linked instances list. LinkedInstances.removeAll(nullptr); - foreach (CScriptObject *pInst, LinkedInstances) + for (CScriptObject *pInst : LinkedInstances) { if (mpEditor->Scene()->NodeForInstance(pInst)->IsSelected()) LinkedInstances.removeOne(pInst); @@ -144,7 +144,7 @@ void CDeleteSelectionCommand::undo() } // Run OnLoadFinished - foreach (CSceneNode *pNode, NewNodes) + for (CSceneNode *pNode : NewNodes) pNode->OnLoadFinished(); // Add selection and done diff --git a/src/Editor/Undo/CPasteNodesCommand.cpp b/src/Editor/Undo/CPasteNodesCommand.cpp index 00285ca5..275298b7 100644 --- a/src/Editor/Undo/CPasteNodesCommand.cpp +++ b/src/Editor/Undo/CPasteNodesCommand.cpp @@ -25,7 +25,7 @@ void CPasteNodesCommand::undo() mpEditor->Selection()->SetSelectedNodes(mOriginalSelection.DereferenceList()); QList PastedNodes = mPastedNodes.DereferenceList(); - foreach (CSceneNode *pNode, PastedNodes) + for (CSceneNode *pNode : PastedNodes) { CScriptObject *pInst = (pNode->NodeType() == ENodeType::Script ? static_cast(pNode)->Instance() : nullptr); mpEditor->NotifyNodeAboutToBeDeleted(pNode); @@ -41,14 +41,15 @@ void CPasteNodesCommand::undo() void CPasteNodesCommand::redo() { - if (!mpMimeData) return; + if (!mpMimeData) + return; const QVector& rkNodes = mpMimeData->CopiedNodes(); CScene *pScene = mpEditor->Scene(); CGameArea *pArea = mpEditor->ActiveArea(); QList PastedNodes; - foreach (const CNodeCopyMimeData::SCopiedNode& rkNode, rkNodes) + for (const CNodeCopyMimeData::SCopiedNode& rkNode : rkNodes) { 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. // 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. - foreach (CSceneNode *pNode, PastedNodes) + for (CSceneNode *pNode : PastedNodes) { if (pNode && pNode->NodeType() == ENodeType::Script) { @@ -126,7 +127,7 @@ void CPasteNodesCommand::redo() // Call PostLoad on all new nodes and select them PastedNodes.removeAll(nullptr); - foreach (CSceneNode *pNode, PastedNodes) + for (CSceneNode *pNode : PastedNodes) pNode->OnLoadFinished(); mpEditor->Selection()->SetSelectedNodes(PastedNodes); diff --git a/src/Editor/Undo/CRotateNodeCommand.cpp b/src/Editor/Undo/CRotateNodeCommand.cpp index 1eebea46..0d6d3cd8 100644 --- a/src/Editor/Undo/CRotateNodeCommand.cpp +++ b/src/Editor/Undo/CRotateNodeCommand.cpp @@ -21,7 +21,7 @@ CRotateNodeCommand::CRotateNodeCommand( { mNodeList.reserve(rkNodes.size()); - foreach (CSceneNode *pNode, rkNodes) + for (CSceneNode *pNode : rkNodes) { SNodeRotate Rotate; Rotate.pNode = pNode; @@ -83,7 +83,7 @@ void CRotateNodeCommand::undo() { if (!mpEditor) return; - foreach (SNodeRotate Rotate, mNodeList) + for (SNodeRotate& Rotate : mNodeList) { Rotate.pNode->SetPosition(Rotate.InitialPos); Rotate.pNode->SetRotation(Rotate.InitialRot); @@ -97,7 +97,7 @@ void CRotateNodeCommand::redo() { if (!mpEditor) return; - foreach (SNodeRotate Rotate, mNodeList) + for (SNodeRotate& Rotate : mNodeList) { Rotate.pNode->SetPosition(Rotate.NewPos); Rotate.pNode->SetRotation(Rotate.NewRot); diff --git a/src/Editor/Undo/CScaleNodeCommand.cpp b/src/Editor/Undo/CScaleNodeCommand.cpp index db28a2e3..f609d840 100644 --- a/src/Editor/Undo/CScaleNodeCommand.cpp +++ b/src/Editor/Undo/CScaleNodeCommand.cpp @@ -13,7 +13,7 @@ CScaleNodeCommand::CScaleNodeCommand(INodeEditor *pEditor, const QListSetPosition(Scale.InitialPos); Scale.pNode->SetScale(Scale.InitialScale); @@ -88,9 +89,10 @@ void CScaleNodeCommand::undo() void CScaleNodeCommand::redo() { - if (!mpEditor) return; + if (!mpEditor) + return; - foreach (SNodeScale Scale, mNodeList) + for (SNodeScale& Scale : mNodeList) { Scale.pNode->SetPosition(Scale.NewPos); Scale.pNode->SetScale(Scale.NewScale); diff --git a/src/Editor/Undo/CTranslateNodeCommand.cpp b/src/Editor/Undo/CTranslateNodeCommand.cpp index 0c9292bf..2866c8bc 100644 --- a/src/Editor/Undo/CTranslateNodeCommand.cpp +++ b/src/Editor/Undo/CTranslateNodeCommand.cpp @@ -13,7 +13,7 @@ CTranslateNodeCommand::CTranslateNodeCommand(INodeEditor *pEditor, const QListSetPosition(Translate.InitialPos); mpEditor->NotifySelectionTransformed(); @@ -70,9 +71,10 @@ void CTranslateNodeCommand::undo() void CTranslateNodeCommand::redo() { - if (!mpEditor) return; + if (!mpEditor) + return; - foreach (SNodeTranslate Translate, mNodeList) + for (SNodeTranslate& Translate : mNodeList) Translate.pNode->SetPosition(Translate.NewPos); mpEditor->NotifySelectionTransformed(); diff --git a/src/Editor/Undo/IEditPropertyCommand.cpp b/src/Editor/Undo/IEditPropertyCommand.cpp index 05380125..25979278 100644 --- a/src/Editor/Undo/IEditPropertyCommand.cpp +++ b/src/Editor/Undo/IEditPropertyCommand.cpp @@ -11,7 +11,7 @@ void IEditPropertyCommand::SaveObjectStateToArray(std::vector& rVector) QVector DataPointers; GetObjectDataPointers(DataPointers); - foreach (void* pData, DataPointers) + for (void* pData : DataPointers) { mpProperty->SerializeValue(pData, Writer); } @@ -25,7 +25,7 @@ void IEditPropertyCommand::RestoreObjectStateFromArray(std::vector& rArray QVector DataPointers; GetObjectDataPointers(DataPointers); - foreach (void* pData, DataPointers) + for (void* pData : DataPointers) { mpProperty->SerializeValue(pData, Reader); } diff --git a/src/Editor/WorldEditor/CInstancesModel.cpp b/src/Editor/WorldEditor/CInstancesModel.cpp index 0421d2b3..68bbe599 100644 --- a/src/Editor/WorldEditor/CInstancesModel.cpp +++ b/src/Editor/WorldEditor/CInstancesModel.cpp @@ -508,7 +508,7 @@ void CInstancesModel::InstancesLayerPreChange() void CInstancesModel::InstancesLayerPostChange(const QList& rkInstanceList) { QList InstanceList; - foreach (CScriptNode *pNode, rkInstanceList) + for (CScriptNode *pNode : rkInstanceList) InstanceList << pNode->Instance(); QModelIndex ScriptIdx = index(0, 0, QModelIndex()); diff --git a/src/Editor/WorldEditor/CPoiListDialog.h b/src/Editor/WorldEditor/CPoiListDialog.h index 05b5e94f..f6973325 100644 --- a/src/Editor/WorldEditor/CPoiListDialog.h +++ b/src/Editor/WorldEditor/CPoiListDialog.h @@ -126,7 +126,7 @@ public slots: { QModelIndexList SelectedIndices = mpListView->selectionModel()->selectedRows(); - foreach (const QModelIndex& rkIndex, SelectedIndices) + for (const QModelIndex& rkIndex : SelectedIndices) { QModelIndex SourceIndex = mModel.mapToSource(rkIndex); mSelection << mSourceModel.PoiForIndex(SourceIndex); diff --git a/src/Editor/WorldEditor/CPoiMapSidebar.cpp b/src/Editor/WorldEditor/CPoiMapSidebar.cpp index 9eae99ac..46abd5cc 100644 --- a/src/Editor/WorldEditor/CPoiMapSidebar.cpp +++ b/src/Editor/WorldEditor/CPoiMapSidebar.cpp @@ -205,10 +205,10 @@ void CPoiMapSidebar::UpdateModelHighlights() } } - foreach (const QModelIndex& rkIndex, UnselectedIndices) + for (const QModelIndex& rkIndex : UnselectedIndices) UnhighlightPoiModels(rkIndex); - foreach (const QModelIndex& rkIndex, SelectedIndices) + for (const QModelIndex& rkIndex : SelectedIndices) HighlightPoiModels(rkIndex); } @@ -264,7 +264,7 @@ void CPoiMapSidebar::OnUnmapAllPressed() QModelIndex Index = GetSelectedRow(); QList ModelList = mSourceModel.GetPoiMeshList(Index); - foreach (CModelNode *pModel, ModelList) + for (CModelNode *pModel : ModelList) { mSourceModel.RemoveMapping(Index, pModel); RevertModelOverlay(pModel); @@ -343,7 +343,7 @@ void CPoiMapSidebar::OnInstanceListButtonClicked() if (!rkSelection.empty()) { - foreach (CScriptNode *pNode, rkSelection) + for (CScriptNode *pNode : rkSelection) mSourceModel.AddPOI(pNode); mModel.sort(0); diff --git a/src/Editor/WorldEditor/CTemplateEditDialog.cpp b/src/Editor/WorldEditor/CTemplateEditDialog.cpp index aaf7d49f..8c4cc724 100644 --- a/src/Editor/WorldEditor/CTemplateEditDialog.cpp +++ b/src/Editor/WorldEditor/CTemplateEditDialog.cpp @@ -238,7 +238,7 @@ void CTemplateEditDialog::UpdateDescription(const TString& rkNewDesc) } // Update equivalent properties with new description - foreach (IProperty* pProperty, mEquivalentProperties) + for (IProperty* pProperty : mEquivalentProperties) { pProperty->SetDescription(rkNewDesc); } diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 4a60a109..30b72e59 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -557,7 +557,7 @@ void CWorldEditor::OnActiveProjectChanged(CGameProject *pProj) void CWorldEditor::OnLinksModified(const QList& rkInstances) { - foreach (CScriptObject *pInstance, rkInstances) + for (CScriptObject *pInstance : rkInstances) { CScriptNode *pNode = mScene.NodeForInstance(pInstance); pNode->LinksModified(); @@ -665,7 +665,7 @@ void CWorldEditor::SetSelectionActive(bool Active) pCommand->SaveOldData(); - foreach (CScriptObject* pInstance, CommandObjects) + for (CScriptObject* pInstance : CommandObjects) pInstance->SetActive(Active); pCommand->SaveNewData(); @@ -736,7 +736,7 @@ void CWorldEditor::UpdateOpenRecentActions() } // 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('\\') ) RecentProjectsList.removeAll(rkProj); @@ -1114,7 +1114,7 @@ void CWorldEditor::OnUnlinkClicked() bool UnlinkIncoming = (Dialog.UserChoice() != CConfirmUnlinkDialog::EChoice::OutgoingOnly); bool UnlinkOutgoing = (Dialog.UserChoice() != CConfirmUnlinkDialog::EChoice::IncomingOnly); - foreach (CScriptNode *pNode, SelectedScriptNodes) + for (CScriptNode *pNode : SelectedScriptNodes) { CScriptObject *pInst = pNode->Instance(); diff --git a/src/Editor/WorldEditor/CWorldTreeModel.cpp b/src/Editor/WorldEditor/CWorldTreeModel.cpp index e41bb9dd..94d99f2f 100644 --- a/src/Editor/WorldEditor/CWorldTreeModel.cpp +++ b/src/Editor/WorldEditor/CWorldTreeModel.cpp @@ -226,7 +226,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj) pProj->GetWorldList(WorldIDs); QList QWorldIDs = QList::fromStdList(WorldIDs); - foreach (const CAssetID& rkID, QWorldIDs) + for (const CAssetID& rkID : QWorldIDs) { CResourceEntry *pEntry = pProj->ResourceStore()->FindEntry(rkID);