MODIFIED: collapse the widget hierarchy tree and remove the widget from it when it's deleted. Also clear the widget properties panel.

This commit is contained in:
dfighter1985 2013-03-03 03:49:56 +01:00
parent c15cf6375c
commit 8af3618cbf
4 changed files with 48 additions and 2 deletions

View file

@ -3181,9 +3181,13 @@ namespace NLGUI
prev->setEditorSelected( false );
}
e->setEditorSelected( true );
currentEditorSelection = name;
notifySelectionWatchers();
}
else
if( !name.empty() )
return;
currentEditorSelection = name;
notifySelectionWatchers();
}
void CWidgetManager::notifySelectionWatchers()

View file

@ -50,7 +50,9 @@ namespace GUIEditor
return;
if( g->delElement( e ) )
{
CWidgetManager::getInstance()->setCurrentEditorSelection( "" );
}
}
}

View file

@ -78,7 +78,12 @@ namespace GUIEditor
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( id );
if( e == NULL )
{
connect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
this, SLOT( onPropertyChanged( QtProperty* ) ) );
return;
}
currentElement = id;

View file

@ -144,14 +144,47 @@ namespace GUIEditor
if( newSelection == currentSelection )
return;
if( newSelection.empty() )
{
if( widgetHT->currentItem() != NULL )
{
QTreeWidgetItem *item = widgetHT->currentItem();
QTreeWidgetItem *p = item;
// Deselect item
item->setSelected( false );
widgetHT->setCurrentItem( NULL );
// Collapse the tree
while( p != NULL )
{
p->setExpanded( false );
p = p->parent();
}
// Finally remove the item!
delete item;
item = NULL;
std::map< std::string, QTreeWidgetItem* >::iterator itr =
widgetHierarchyMap.find( currentSelection );
if( itr != widgetHierarchyMap.end() )
widgetHierarchyMap.erase( itr );
currentSelection = "";
}
return;
}
std::map< std::string, QTreeWidgetItem* >::iterator itr =
widgetHierarchyMap.find( newSelection );
if( itr == widgetHierarchyMap.end() )
return;
// deselect current item
if( widgetHT->currentItem() != NULL )
widgetHT->currentItem()->setSelected( false );
// expand the tree items, so that we can see the selected item
QTreeWidgetItem *item = itr->second;
QTreeWidgetItem *currItem = item;
while( currItem != NULL )
@ -160,8 +193,10 @@ namespace GUIEditor
currItem = currItem->parent();
}
// select the current item
item->setSelected( true );
widgetHT->setCurrentItem( item );
currentSelection = newSelection;
}
void WidgetHierarchy::onItemDblClicked( QTreeWidgetItem *item )