if ( theRoot )
curObj = storeState( selObjs, openObjs, selKeys, openKeys, curKey );
+ removeConnections( myRoot );
if ( myRoot != theRoot && isAutoDeleteObjects() )
delete myRoot;
lv->setColumnText( myColumnIds[id], icon, label );
}
+QString OB_Browser::nameTitle() const
+{
+ return myView->columnText( 0 );
+}
+
+QString OB_Browser::columnTitle( const int id ) const
+{
+ QString txt;
+ if ( myColumnIds.contains( id ) )
+ txt = myView->columnText( myColumnIds[id] );
+ return txt;
+}
+
bool OB_Browser::isColumnVisible( const int id ) const
{
return myColumnIds.contains( id ) && myView->isShown( myColumnIds[id] );
myView->setShown( myColumnIds[id], on );
}
+void OB_Browser::setWidthMode( QListView::WidthMode mode )
+{
+ for ( int i = 0, n = myView->columns(); i < n; i++ )
+ myView->setColumnWidthMode( i, mode );
+}
+
QValueList<int> OB_Browser::columns() const
{
QValueList<int> lst;
return lst;
}
-void OB_Browser::updateTree( SUIT_DataObject* o )
+bool OB_Browser::appropriateColumn( const int id ) const
+{
+ bool res = false;
+ if ( myColumnIds.contains( id ) )
+ res = myView->appropriate( myColumnIds[id] );
+ return res;
+}
+
+void OB_Browser::setAppropriateColumn( const int id, const bool on )
{
- updateTree( o ? o : getRootObject(), false );
+ if ( !myColumnIds.contains( id ) )
+ return;
+
+ myView->setAppropriate( myColumnIds[id], on );
}
-void OB_Browser::updateTree( SUIT_DataObject* obj, const bool notify )
+void OB_Browser::updateTree( SUIT_DataObject* obj )
{
- if ( !obj )
+ if ( !obj && !(obj = getRootObject()) )
return;
DataObjectKey curKey;
SUIT_DataObject* curObj = storeState( selObjs, openObjs, selKeys, openKeys, curKey );
- if ( notify )
- {
- bool upd = isAutoUpdate();
- setAutoUpdate( false );
- emit aboutRefresh();
- setAutoUpdate( upd );
- }
-
createConnections( obj );
updateView( obj );
void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg )
{
- if ( !src || !trg || src->root() != getRootObject() )
+ if ( !src || !trg || src == trg || src->root() != getRootObject() )
return;
DataObjectKey curKey;
src->setParent( 0 );
- if ( src != trg && isAutoDeleteObjects() )
+ removeConnections( src );
+ if ( isAutoDeleteObjects() )
delete src;
if ( parent && pos != -1 )
createTree( it.current(), 0, 0 );
}
else
- createTree( theStartObj, parent, after );
+ createTree( theStartObj, parent, after ? after : parent );
}
QListViewItem* OB_Browser::createTree( const SUIT_DataObject* obj,
for ( DataObjectListIterator it ( lst ); it.current(); ++it )
createTree( it.current(), item );
+ if ( item )
+ item->setOpen( obj->isOpen() );
+
return item;
}
return;
SUIT_DataObject* obj = dataObject( item );
+ obj->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
myItems.remove( obj );
QListViewItem* i = item->firstChild();
it.current()->connect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
}
+void OB_Browser::removeConnections( SUIT_DataObject* obj )
+{
+ if ( !obj )
+ return;
+
+ DataObjectList childList;
+ obj->children( childList, true );
+
+ childList.prepend( obj );
+
+ for ( DataObjectListIterator it( childList ); it.current(); ++it )
+ it.current()->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
+}
+
SUIT_DataObject* OB_Browser::storeState( DataObjectMap& selObjs, DataObjectMap& openObjs,
DataObjectKeyMap& selKeys, DataObjectKeyMap& openKeys,
DataObjectKey& curKey ) const
expand( listViewItem( itr.current() ) );
}
-void OB_Browser::onRefresh()
+void OB_Browser::onColumnVisible( int id )
{
- updateTree( 0, true );
+ setColumnShown( id, !isColumnVisible( id ) );
}
void OB_Browser::onDestroyed( SUIT_DataObject* obj )
void OB_Browser::contextMenuPopup( QPopupMenu* menu )
{
+/* QValueList<int> cols;
+ for ( QMap<int, int>::ConstIterator it = myColumnIds.begin(); it != myColumnIds.end(); ++it )
+ {
+ if ( appropriateColumn( it.key() ) )
+ cols.append( it.key() );
+ }
+
+ uint num = menu->count();
+ menu->setCheckable( true );
+ for ( QValueList<int>::const_iterator iter = cols.begin(); iter != cols.end(); ++iter )
+ {
+ QString name = columnTitle( *iter );
+ if ( name.isEmpty() )
+ continue;
+
+ int id = menu->insertItem( name, this, SLOT( onColumnVisible( int ) ) );
+ menu->setItemChecked( id, isColumnVisible( *iter ) );
+ menu->setItemParameter( id, *iter );
+ }
+ if ( menu->count() != num )
+ menu->insertSeparator();*/
+
DataObjectList selected;
getSelected( selected );
menu->insertItem( tr( "MEN_EXPAND_ALL" ), this, SLOT( onExpand() ) );
menu->insertSeparator();
}
- menu->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
}
void OB_Browser::expand( QListViewItem* item )
QListViewItem* item = listViewItem( obj );
+ obj->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
myItems.remove( obj );
if ( obj == myRoot )
if ( !item || level < 1 || !item->childCount() )
return;
- item->setOpen( true );
while ( item )
{
- openBranch( item, level - 1 );
+ item->setOpen( true );
+ openBranch( item->firstChild(), level - 1 );
item = item->nextSibling();
}
}