#include "CSelectAllCommand.h" #include CSelectAllCommand::CSelectAllCommand(INodeEditor *pEditor, QList &rSelection, CScene *pScene, FNodeFlags NodeFlags) : IUndoCommand("Select All") , mpEditor(pEditor) , mOldSelection(rSelection) , mpSelection(&rSelection) { CSceneIterator it(pScene, NodeFlags); while (!it.DoneIterating()) { mNewSelection.append(*it); ++it; } } CSelectAllCommand::~CSelectAllCommand() { } void CSelectAllCommand::undo() { *mpSelection = mOldSelection; // Deselect all nodes in new selection foreach (CSceneNode *pNode, mNewSelection) pNode->SetSelected(false); // Select all nodes in the old selection foreach (CSceneNode *pNode, mOldSelection) pNode->SetSelected(true); // Update editor mpEditor->RecalculateSelectionBounds(); mpEditor->NotifySelectionModified(); } void CSelectAllCommand::redo() { *mpSelection = mNewSelection; // Deselect all nodes in the old selection foreach (CSceneNode *pNode, mOldSelection) pNode->SetSelected(false); // Select all nodes in the new selection foreach (CSceneNode *pNode, mNewSelection) pNode->SetSelected(true); // Update editor mpEditor->RecalculateSelectionBounds(); mpEditor->NotifySelectionModified(); }