1 /*
2  Copyright (C) 2010-2014 Kristian Duske
3 
4  This file is part of TrenchBroom.
5 
6  TrenchBroom is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  TrenchBroom is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "EntityDefinitionFileCommand.h"
21 #include "View/MapDocumentCommandFacade.h"
22 
23 #include <cassert>
24 
25 namespace TrenchBroom {
26     namespace View {
27         const Command::CommandType EntityDefinitionFileCommand::Type = Command::freeType();
28 
set(const Assets::EntityDefinitionFileSpec & spec)29         EntityDefinitionFileCommand::Ptr EntityDefinitionFileCommand::set(const Assets::EntityDefinitionFileSpec& spec) {
30             return Ptr(new EntityDefinitionFileCommand("Set Entity Definitions", spec));
31         }
32 
EntityDefinitionFileCommand(const String & name,const Assets::EntityDefinitionFileSpec & spec)33         EntityDefinitionFileCommand::EntityDefinitionFileCommand(const String& name, const Assets::EntityDefinitionFileSpec& spec) :
34         DocumentCommand(Type, name),
35         m_newSpec(spec) {}
36 
doPerformDo(MapDocumentCommandFacade * document)37         bool EntityDefinitionFileCommand::doPerformDo(MapDocumentCommandFacade* document) {
38             m_oldSpec = document->entityDefinitionFile();
39             document->performSetEntityDefinitionFile(m_newSpec);
40             return true;
41         }
42 
doPerformUndo(MapDocumentCommandFacade * document)43         bool EntityDefinitionFileCommand::doPerformUndo(MapDocumentCommandFacade* document) {
44             document->performSetEntityDefinitionFile(m_oldSpec);
45             return true;
46         }
47 
doIsRepeatable(MapDocumentCommandFacade * document) const48         bool EntityDefinitionFileCommand::doIsRepeatable(MapDocumentCommandFacade* document) const {
49             return false;
50         }
51 
doCollateWith(UndoableCommand::Ptr command)52         bool EntityDefinitionFileCommand::doCollateWith(UndoableCommand::Ptr command) {
53             return false;
54         }
55     }
56 }
57