mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 15:46:18 +00:00
MODIFIED: collapse the widget hierarchy tree and remove the widget from it when it's deleted. Also clear the widget properties panel.
--HG-- branch : gsoc2012-gui-editor
This commit is contained in:
parent
b80c47cc10
commit
532a3ef7d3
4 changed files with 48 additions and 2 deletions
|
@ -3181,9 +3181,13 @@ namespace NLGUI
|
||||||
prev->setEditorSelected( false );
|
prev->setEditorSelected( false );
|
||||||
}
|
}
|
||||||
e->setEditorSelected( true );
|
e->setEditorSelected( true );
|
||||||
currentEditorSelection = name;
|
|
||||||
notifySelectionWatchers();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if( !name.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
currentEditorSelection = name;
|
||||||
|
notifySelectionWatchers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWidgetManager::notifySelectionWatchers()
|
void CWidgetManager::notifySelectionWatchers()
|
||||||
|
|
|
@ -50,7 +50,9 @@ namespace GUIEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( g->delElement( e ) )
|
if( g->delElement( e ) )
|
||||||
|
{
|
||||||
CWidgetManager::getInstance()->setCurrentEditorSelection( "" );
|
CWidgetManager::getInstance()->setCurrentEditorSelection( "" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,12 @@ namespace GUIEditor
|
||||||
|
|
||||||
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( id );
|
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( id );
|
||||||
if( e == NULL )
|
if( e == NULL )
|
||||||
|
{
|
||||||
|
connect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
|
||||||
|
this, SLOT( onPropertyChanged( QtProperty* ) ) );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
currentElement = id;
|
currentElement = id;
|
||||||
|
|
||||||
|
|
|
@ -144,14 +144,47 @@ namespace GUIEditor
|
||||||
if( newSelection == currentSelection )
|
if( newSelection == currentSelection )
|
||||||
return;
|
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 =
|
std::map< std::string, QTreeWidgetItem* >::iterator itr =
|
||||||
widgetHierarchyMap.find( newSelection );
|
widgetHierarchyMap.find( newSelection );
|
||||||
if( itr == widgetHierarchyMap.end() )
|
if( itr == widgetHierarchyMap.end() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// deselect current item
|
||||||
if( widgetHT->currentItem() != NULL )
|
if( widgetHT->currentItem() != NULL )
|
||||||
widgetHT->currentItem()->setSelected( false );
|
widgetHT->currentItem()->setSelected( false );
|
||||||
|
|
||||||
|
// expand the tree items, so that we can see the selected item
|
||||||
QTreeWidgetItem *item = itr->second;
|
QTreeWidgetItem *item = itr->second;
|
||||||
QTreeWidgetItem *currItem = item;
|
QTreeWidgetItem *currItem = item;
|
||||||
while( currItem != NULL )
|
while( currItem != NULL )
|
||||||
|
@ -160,8 +193,10 @@ namespace GUIEditor
|
||||||
currItem = currItem->parent();
|
currItem = currItem->parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// select the current item
|
||||||
item->setSelected( true );
|
item->setSelected( true );
|
||||||
widgetHT->setCurrentItem( item );
|
widgetHT->setCurrentItem( item );
|
||||||
|
currentSelection = newSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetHierarchy::onItemDblClicked( QTreeWidgetItem *item )
|
void WidgetHierarchy::onItemDblClicked( QTreeWidgetItem *item )
|
||||||
|
|
Loading…
Reference in a new issue