1 #include "LightApp_DataObject.h"
3 #include "LightApp_Study.h"
4 #include "LightApp_RootObject.h"
6 #include "CAM_DataModel.h"
7 #include "CAM_Module.h"
9 #include <SUIT_Application.h>
10 #include <SUIT_ResourceMgr.h>
11 #include <SUIT_DataObjectKey.h>
16 Class: LightApp_DataObject::Key
19 class LightApp_DataObject::Key : public SUIT_DataObjectKey
22 Key( const QString& );
25 virtual bool isLess( const SUIT_DataObjectKey* ) const;
26 virtual bool isEqual( const SUIT_DataObjectKey* ) const;
32 /*!Constructor. Initialize by \a entry.*/
33 LightApp_DataObject::Key::Key( const QString& entry )
34 : SUIT_DataObjectKey(),
39 /*!Destructor. Do nothing.*/
40 LightApp_DataObject::Key::~Key()
44 /*!Checks: Is current key less than \a other.*/
45 bool LightApp_DataObject::Key::isLess( const SUIT_DataObjectKey* other ) const
47 Key* that = (Key*)other;
48 return myEntry < that->myEntry;
51 /*!Checks: Is current key equal with \a other.*/
52 bool LightApp_DataObject::Key::isEqual( const SUIT_DataObjectKey* other ) const
54 Key* that = (Key*)other;
55 return myEntry == that->myEntry;
59 Class: LightApp_DataObject
62 /*!Constructor. Initialize by \a parent*/
63 LightApp_DataObject::LightApp_DataObject( SUIT_DataObject* parent )
64 : CAM_DataObject( parent )
68 /*!Destructor. Do nothing.*/
69 LightApp_DataObject::~LightApp_DataObject()
76 QString LightApp_DataObject::entry() const
81 /*!Create and return new key object.*/
82 SUIT_DataObjectKey* LightApp_DataObject::key() const
84 QString str = entry();
85 return new Key( str );
88 /*!Gets component object.
89 *\retval SUIT_DataObject.
91 SUIT_DataObject* LightApp_DataObject::componentObject() const
93 SUIT_DataObject* compObj = 0; // for root object
95 if ( parent() && parent() == root() )
96 compObj = (SUIT_DataObject*)this; // for component-level objects
99 compObj = parent(); // for lower level objects
100 while ( compObj && compObj->parent() != root() )
101 compObj = compObj->parent();
106 /*!Get component type.*/
107 QString LightApp_DataObject::componentDataType() const
109 SUIT_DataObject* aCompObj = componentObject();
110 LightApp_ModuleObject* anObj = dynamic_cast<LightApp_ModuleObject*>( aCompObj );
112 CAM_DataModel* aModel = anObj->dataModel();
114 return aModel->module()->name();
120 Class: LightApp_ModuleObject
124 /*!Constructor.Initialize by \a parent.*/
125 LightApp_ModuleObject::LightApp_ModuleObject( SUIT_DataObject* parent )
126 : CAM_RootObject( parent ),
127 CAM_DataObject( parent )
131 /*!Constructor.Initialize by \a module and parent.*/
132 LightApp_ModuleObject::LightApp_ModuleObject( CAM_DataModel* dm, SUIT_DataObject* parent )
133 : CAM_RootObject( dm, parent ),
134 CAM_DataObject( parent )
138 /*!Destructor. Do nothing.*/
139 LightApp_ModuleObject::~LightApp_ModuleObject()
143 /*!Returns module name */
144 QString LightApp_ModuleObject::name() const
146 return CAM_RootObject::name();
149 /*!Insert new child object to the children list at specified position
150 *\add component in Study for this module object if it necessary*/
151 void LightApp_ModuleObject::insertChild( SUIT_DataObject* theObj, int thePosition )
153 CAM_RootObject::insertChild(theObj, thePosition);
155 CAM_DataModel* aModel = dataModel();
157 LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>(parent());
160 aRoot->study()->addComponent(aModel);