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 "PathSourceShape.h"
15#include "VectorPath.h"
16
17
18#undef B_TRANSLATION_CONTEXT
19#define B_TRANSLATION_CONTEXT "Icon-O-Matic-UnassignPathCmd"
20
21
22// constructor
23UnassignPathCommand::UnassignPathCommand(PathSourceShape* shape,
24										 VectorPath* path)
25	: Command(),
26	  fShape(shape),
27	  fPath(path),
28	  fPathRemoved(false)
29{
30}
31
32// destructor
33UnassignPathCommand::~UnassignPathCommand()
34{
35	if (fPathRemoved && fPath)
36		fPath->ReleaseReference();
37}
38
39// InitCheck
40status_t
41UnassignPathCommand::InitCheck()
42{
43	return fShape && fPath ? B_OK : B_NO_INIT;
44}
45
46// Perform
47status_t
48UnassignPathCommand::Perform()
49{
50	// remove path from shape
51	fShape->Paths()->RemoveItem(fPath);
52	fPathRemoved = true;
53
54	return B_OK;
55}
56
57// Undo
58status_t
59UnassignPathCommand::Undo()
60{
61	// add path to shape
62	fShape->Paths()->AddItem(fPath);
63	fPathRemoved = false;
64
65	return B_OK;
66}
67
68// GetName
69void
70UnassignPathCommand::GetName(BString& name)
71{
72	name << B_TRANSLATE("Unassign path");
73}
74