From 046502905502e7d2c701a02d49135681fe637f21 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 10 Jul 2020 16:16:36 -0400 Subject: [PATCH] WModifyTab: Make use of push_back over operator<< --- src/Editor/WorldEditor/WModifyTab.cpp | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Editor/WorldEditor/WModifyTab.cpp b/src/Editor/WorldEditor/WModifyTab.cpp index 305c41d0..ef4c32bf 100644 --- a/src/Editor/WorldEditor/WModifyTab.cpp +++ b/src/Editor/WorldEditor/WModifyTab.cpp @@ -219,23 +219,23 @@ void WModifyTab::OnPickModeExit() void WModifyTab::OnDeleteLinksClicked() { - if (mpSelectedNode && mpSelectedNode->NodeType() == ENodeType::Script) - { - ELinkType Type = (sender() == ui->DeleteOutgoingConnectionButton ? ELinkType::Outgoing : ELinkType::Incoming); - QModelIndexList SelectedIndices = (Type == ELinkType::Outgoing ? ui->OutLinksTableView->selectionModel()->selectedRows() : ui->InLinksTableView->selectionModel()->selectedRows()); + if (mpSelectedNode == nullptr || mpSelectedNode->NodeType() != ENodeType::Script) + return; - if (!SelectedIndices.isEmpty()) - { - QVector Indices; + const ELinkType Type = (sender() == ui->DeleteOutgoingConnectionButton ? ELinkType::Outgoing : ELinkType::Incoming); + const QModelIndexList SelectedIndices = (Type == ELinkType::Outgoing ? ui->OutLinksTableView->selectionModel()->selectedRows() : ui->InLinksTableView->selectionModel()->selectedRows()); - for (int iIdx = 0; iIdx < SelectedIndices.size(); iIdx++) - Indices << SelectedIndices[iIdx].row(); + if (SelectedIndices.isEmpty()) + return; - CScriptObject *pInst = static_cast(mpSelectedNode)->Instance(); - CDeleteLinksCommand *pCmd = new CDeleteLinksCommand(mpWorldEditor, pInst, Type, Indices); - mpWorldEditor->UndoStack().push(pCmd); - } - } + QVector Indices; + Indices.reserve(SelectedIndices.size()); + for (const auto& index : SelectedIndices) + Indices.push_back(index.row()); + + auto *pInst = static_cast(mpSelectedNode)->Instance(); + auto *pCmd = new CDeleteLinksCommand(mpWorldEditor, pInst, Type, Indices); + mpWorldEditor->UndoStack().push(pCmd); } void WModifyTab::OnEditLinkClicked()