xref: /haiku/src/apps/icon-o-matic/document/IconObject.cpp (revision 1d9d47fc72028bb71b5f232a877231e59cfe2438)
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 "IconObject.h"
10 
11 #include "CommonPropertyIDs.h"
12 #include "Property.h"
13 #include "PropertyObject.h"
14 
15 // constructor
16 IconObject::IconObject(const char* name)
17 	: Observable(),
18 	  Referenceable(),
19 	  Selectable(),
20 
21 	  fName(name)
22 {
23 }
24 
25 // copy constructor
26 IconObject::IconObject(const IconObject& other)
27 	: Observable(),
28 	  Referenceable(),
29 	  Selectable(),
30 
31 	  fName(other.fName)
32 {
33 }
34 
35 // destructor
36 IconObject::~IconObject()
37 {
38 }
39 
40 // SelectedChanged
41 void
42 IconObject::SelectedChanged()
43 {
44 	// simply pass on the event for now
45 //	Notify();
46 }
47 
48 // #pragma mark -
49 
50 // MakePropertyObject
51 PropertyObject*
52 IconObject::MakePropertyObject() const
53 {
54 	PropertyObject* object = new PropertyObject();
55 
56 	object->AddProperty(new StringProperty(PROPERTY_NAME, fName.String()));
57 
58 	return object;
59 }
60 
61 // SetToPropertyObject
62 bool
63 IconObject::SetToPropertyObject(const PropertyObject* object)
64 {
65 	AutoNotificationSuspender _(this);
66 
67 	BString name;
68 	if (object->GetValue(PROPERTY_NAME, name))
69 		SetName(name.String());
70 
71 	return HasPendingNotifications();
72 }
73 
74 // SetName
75 void
76 IconObject::SetName(const char* name)
77 {
78 	if (fName == name)
79 		return;
80 
81 	fName = name;
82 	Notify();
83 }
84