Collapse the tree, and only expand the items that are needed to get to the selected items.

This commit is contained in:
dfighter1985 2014-09-25 00:37:25 +02:00
parent b46483a2a6
commit 6eb4cf9c3f
2 changed files with 24 additions and 11 deletions

View file

@ -285,7 +285,24 @@ namespace GUIEditor
item->setData( 0, Qt::DisplayRole, id );
item->setSelected( true );
newParent->addChild( item );
newParent->setExpanded( true );
selectItem( item );
}
void WidgetHierarchy::selectItem( QTreeWidgetItem *item )
{
widgetHT->collapseAll();
QTreeWidgetItem *currItem = item;
while( currItem != NULL )
{
currItem->setExpanded( true );
currItem = currItem->parent();
}
widgetHT->setCurrentItem( item );
item->setSelected( true );
}
void WidgetHierarchy::getCurrentGroup( QString &g )
@ -345,18 +362,11 @@ namespace GUIEditor
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 )
{
currItem->setExpanded( true );
currItem = currItem->parent();
}
widgetHT->collapseAll();
// select the current item
item->setSelected( true );
widgetHT->setCurrentItem( item );
QTreeWidgetItem *item = itr->second;
selectItem( item );
currentSelection = newSelection;
}
@ -365,6 +375,8 @@ namespace GUIEditor
if( item->parent() == NULL )
return;
selectItem( item );
std::string n = item->text( 0 ).toUtf8().constData();
currentSelection = makeFullName( item, n );
CWidgetManager::getInstance()->setCurrentEditorSelection( currentSelection );

View file

@ -52,6 +52,7 @@ namespace GUIEditor
void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group );
QTreeWidgetItem* findItem( const std::string &id );
QTreeWidgetItem* findParent( const std::string &id );
void selectItem( QTreeWidgetItem *item );
public Q_SLOTS:
void onGUILoaded();