2 #include <HYDROGUI_DataModelSync.h>
3 #include <HYDROGUI_DataObject.h>
6 HYDROGUI_DataModelSync::HYDROGUI_DataModelSync( SUIT_DataObject* theRoot )
11 HYDROGUI_DataModelSync::~HYDROGUI_DataModelSync()
15 void HYDROGUI_DataModelSync::deleteItemWithChildren( const suitPtr& theSuitPtr ) const
20 DataObjectList aChildren;
21 theSuitPtr->children( aChildren );
22 foreach( SUIT_DataObject* anObj, aChildren )
23 deleteItemWithChildren( anObj );
28 suitPtr HYDROGUI_DataModelSync::nullSrc() const
33 suitPtr HYDROGUI_DataModelSync::nullTrg() const
38 QList<suitPtr> HYDROGUI_DataModelSync::children( const suitPtr& theSuitPtr ) const
40 QList<suitPtr> aChildren;
43 DataObjectList anObjList;
44 theSuitPtr->children( anObjList );
45 foreach( SUIT_DataObject* anObj, anObjList )
46 aChildren.append( anObj );
51 suitPtr HYDROGUI_DataModelSync::parent( const suitPtr& theSuitPtr ) const
53 return theSuitPtr ? theSuitPtr->parent() : 0;
56 void HYDROGUI_DataModelSync::updateItem( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const
58 HYDROGUI_DataObject* aDataObj = dynamic_cast<HYDROGUI_DataObject*>( theTrgPtr );
60 aDataObj->updateBy( theSrcPtr );
62 HYDROGUI_NamedObject* aNamedObj = dynamic_cast<HYDROGUI_NamedObject*>( theTrgPtr );
64 aNamedObj->updateBy( theSrcPtr );
67 bool HYDROGUI_DataModelSync::isEqual( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const
69 if( theSrcPtr==myRoot )
78 QString aSrcClass = typeid( *theSrcPtr ).name();
79 QString aTrgClass = typeid( *theTrgPtr ).name();
80 return aSrcClass==aTrgClass;
83 suitPtr HYDROGUI_DataModelSync::createItem( const suitPtr& theSrcPtr,
84 const suitPtr& theParent,
85 const suitPtr& theAfter ) const
89 int aPos = theParent->childPos( theAfter );
91 theParent->insertChild( theSrcPtr, aPos+1 );
93 theParent->appendChild( theSrcPtr );