1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #include "UnassignPathCommand.h" 10 11 #include <Catalog.h> 12 #include <Locale.h> 13 14 #include "PathContainer.h" 15 #include "PathSourceShape.h" 16 #include "VectorPath.h" 17 18 19 #undef B_TRANSLATION_CONTEXT 20 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-UnassignPathCmd" 21 22 23 // constructor 24 UnassignPathCommand::UnassignPathCommand(PathSourceShape* shape, 25 VectorPath* path) 26 : Command(), 27 fShape(shape), 28 fPath(path), 29 fPathRemoved(false) 30 { 31 } 32 33 // destructor 34 UnassignPathCommand::~UnassignPathCommand() 35 { 36 if (fPathRemoved && fPath) 37 fPath->ReleaseReference(); 38 } 39 40 // InitCheck 41 status_t 42 UnassignPathCommand::InitCheck() 43 { 44 return fShape && fPath ? B_OK : B_NO_INIT; 45 } 46 47 // Perform 48 status_t 49 UnassignPathCommand::Perform() 50 { 51 // remove path from shape 52 fShape->Paths()->RemovePath(fPath); 53 fPathRemoved = true; 54 55 return B_OK; 56 } 57 58 // Undo 59 status_t 60 UnassignPathCommand::Undo() 61 { 62 // add path to shape 63 fShape->Paths()->AddPath(fPath); 64 fPathRemoved = false; 65 66 return B_OK; 67 } 68 69 // GetName 70 void 71 UnassignPathCommand::GetName(BString& name) 72 { 73 name << B_TRANSLATE("Unassign Path"); 74 } 75