2 #include <HYDROGUI_DataModelSync.h>
3 #include <HYDROGUI_DataObject.h>
5 HYDROGUI_DataModelSync::HYDROGUI_DataModelSync( SUIT_DataObject* theRoot )
10 HYDROGUI_DataModelSync::~HYDROGUI_DataModelSync()
14 void HYDROGUI_DataModelSync::deleteItemWithChildren( const suitPtr& theSuitPtr ) const
19 DataObjectList aChildren;
20 theSuitPtr->children( aChildren );
21 foreach( SUIT_DataObject* anObj, aChildren )
22 deleteItemWithChildren( anObj );
27 suitPtr HYDROGUI_DataModelSync::nullSrc() const
32 suitPtr HYDROGUI_DataModelSync::nullTrg() const
37 QList<suitPtr> HYDROGUI_DataModelSync::children( const suitPtr& theSuitPtr ) const
39 QList<suitPtr> aChildren;
42 DataObjectList anObjList;
43 theSuitPtr->children( anObjList );
44 foreach( SUIT_DataObject* anObj, anObjList )
45 aChildren.append( anObj );
50 suitPtr HYDROGUI_DataModelSync::parent( const suitPtr& theSuitPtr ) const
52 return theSuitPtr ? theSuitPtr->parent() : 0;
55 void HYDROGUI_DataModelSync::updateItem( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const
57 HYDROGUI_DataObject* aDataObj = dynamic_cast<HYDROGUI_DataObject*>( theTrgPtr );
59 aDataObj->updateBy( theSrcPtr );
61 HYDROGUI_NamedObject* aNamedObj = dynamic_cast<HYDROGUI_NamedObject*>( theTrgPtr );
63 aNamedObj->updateBy( theSrcPtr );
66 bool HYDROGUI_DataModelSync::isEqual( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const
68 if( theSrcPtr==myRoot )
77 QString aSrcClass = typeid( *theSrcPtr ).name();
78 QString aTrgClass = typeid( *theTrgPtr ).name();
79 return aSrcClass==aTrgClass;
82 suitPtr HYDROGUI_DataModelSync::createItem( const suitPtr& theSrcPtr,
83 const suitPtr& theParent,
84 const suitPtr& theAfter ) const
88 int aPos = theParent->childPos( theAfter );
90 theParent->insertChild( theSrcPtr, aPos+1 );
92 theParent->appendChild( theSrcPtr );