From ce98b360d446f42658a84308b41d8a5bacb7b824 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 5 Apr 2006 06:24:17 +0000 Subject: [PATCH] PAL12040, PAL12025 - incorrect object browser tree --- src/ObjBrowser/OB_Browser.cxx | 42 ++++++++--------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index 6eb296fe5..7e490cb54 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -178,7 +178,9 @@ void OB_BrowserSync::deleteItemWithChildren( const ItemPtr& i ) const bool OB_BrowserSync::isEqual( const ObjPtr& p, const ItemPtr& q ) const { - return ( !p && !q ) || ( p && q && q->dataObject()==p ); + bool isRoot = p==myBrowser->getRootObject() && !q, + isEq = p && q && q->dataObject()==p; + return isRoot || ( !p && !q ) || isEq; } ObjPtr OB_BrowserSync::nullSrc() const @@ -205,7 +207,7 @@ void OB_BrowserSync::children( const ObjPtr& p, QValueList& ch ) const void OB_BrowserSync::children( const ItemPtr& p, QValueList& ch ) const { - for( QListViewItem* item = p->firstChild(); item; item = item->nextSibling() ) + for( QListViewItem* item = p ? p->firstChild() : myBrowser->listView()->firstChild(); item; item = item->nextSibling() ) { ItemPtr p = dynamic_cast( item ); if( p ) @@ -733,39 +735,13 @@ void OB_Browser::updateView( SUIT_DataObject* startObj ) if ( !startObj || startObj->root() != getRootObject() ) return; + //qDebug( "updateView:" ); + //startObj->dump(); + if ( startObj == myRoot ) { - DataObjectList ch; - myRoot->children( ch ); - - ItemMap exist; - QListViewItem* st = lv->firstChild(); - for( ; st; st = st->nextSibling() ) - { - OB_ListItem* ob_item = dynamic_cast( st ); - exist.insert( ob_item->dataObject(), ob_item ); - } - - SUIT_DataObject* local_root = ch.first(); - for( ; local_root; local_root = ch.next() ) - { - OB_BrowserSync sync( this ); - OB_ListItem* local_item = dynamic_cast( listViewItem( local_root ) ); - synchronize( local_root, local_item, sync ); - exist[local_root] = 0; - } - - ItemMap::const_iterator anIt = exist.begin(), aLast = exist.end(); - for( ; anIt!=aLast; anIt++ ) - { - if( anIt.data() ) // exist[local_root]==1 -> this local root was NOT in data model, should be removed - { - removeReferences( anIt.data() ); - OB_ListItem* item = dynamic_cast( anIt.data() ); - if( item && myItems.contains( item->dataObject() ) ) - delete anIt.data(); - } - } + OB_BrowserSync sync( this ); + synchronize( myRoot, 0, sync ); } else { -- 2.39.2