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 theSuitPtr->setAutoDeleteChildren( true );
21 theSuitPtr->deleteLater();
24 suitPtr HYDROGUI_DataModelSync::nullSrc() const
29 suitPtr HYDROGUI_DataModelSync::nullTrg() const
34 QList<suitPtr> HYDROGUI_DataModelSync::children( const suitPtr& theSuitPtr ) const
36 QList<suitPtr> aChildren;
39 DataObjectList anObjList;
40 theSuitPtr->children( anObjList );
41 foreach( SUIT_DataObject* anObj, anObjList )
42 aChildren.append( anObj );
47 suitPtr HYDROGUI_DataModelSync::parent( const suitPtr& theSuitPtr ) const
49 return theSuitPtr ? theSuitPtr->parent() : 0;
52 void HYDROGUI_DataModelSync::updateItem( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const
54 HYDROGUI_DataObject* aDataObj = dynamic_cast<HYDROGUI_DataObject*>( theTrgPtr );
56 aDataObj->updateBy( theSrcPtr );
58 HYDROGUI_NamedObject* aNamedObj = dynamic_cast<HYDROGUI_NamedObject*>( theTrgPtr );
60 aNamedObj->updateBy( theSrcPtr );
63 bool HYDROGUI_DataModelSync::isEqual( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const
65 if( theSrcPtr==myRoot )
74 QString aSrcClass = typeid( *theSrcPtr ).name();
75 QString aTrgClass = typeid( *theTrgPtr ).name();
76 return aSrcClass==aTrgClass;
79 suitPtr HYDROGUI_DataModelSync::createItem( const suitPtr& theSrcPtr,
80 const suitPtr& theParent,
81 const suitPtr& theAfter ) const
85 int aPos = theParent->childPos( theAfter );
87 theParent->insertChild( theSrcPtr, aPos+1 );
89 theParent->appendChild( theSrcPtr );