1 /*!
2 	@file
3 	@author		Albert Semenov
4 	@date		08/2010
5 */
6 
7 #include "Precompiled.h"
8 #include "PropertyControl.h"
9 #include "PropertyUtility.h"
10 
11 namespace tools
12 {
13 
PropertyControl()14 	PropertyControl::PropertyControl() :
15 		mProperty(nullptr)
16 	{
17 	}
18 
setProperty(PropertyPtr _value)19 	void PropertyControl::setProperty(PropertyPtr _value)
20 	{
21 		unadvice();
22 		mProperty = _value;
23 		advice();
24 
25 		updateCaption();
26 		updateProperty();
27 	}
28 
getProperty()29 	PropertyPtr PropertyControl::getProperty()
30 	{
31 		return mProperty;
32 	}
33 
advice()34 	void PropertyControl::advice()
35 	{
36 		if (mProperty != nullptr)
37 		{
38 			mProperty->eventChangeProperty.connect(this, &PropertyControl::notifyChangeProperty);
39 		}
40 	}
41 
unadvice()42 	void PropertyControl::unadvice()
43 	{
44 		if (mProperty != nullptr)
45 		{
46 			mProperty->eventChangeProperty.disconnect(this);
47 			mProperty = nullptr;
48 		}
49 	}
50 
updateProperty()51 	void PropertyControl::updateProperty()
52 	{
53 	}
54 
notifyChangeProperty(PropertyPtr _sender)55 	void PropertyControl::notifyChangeProperty(PropertyPtr _sender)
56 	{
57 		updateProperty();
58 	}
59 
updateCaption()60 	void PropertyControl::updateCaption()
61 	{
62 	}
63 
executeAction(const std::string & _value,bool _merge)64 	void PropertyControl::executeAction(const std::string& _value, bool _merge)
65 	{
66 		PropertyUtility::executeAction(mProperty, _value, _merge);
67 	}
68 
69 }
70