mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Collapse the tree, and only expand the items that are needed to get to the selected items.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
9cae0c1793
commit
4ec13e57e4
2 changed files with 24 additions and 11 deletions
|
@ -285,7 +285,24 @@ namespace GUIEditor
|
||||||
item->setData( 0, Qt::DisplayRole, id );
|
item->setData( 0, Qt::DisplayRole, id );
|
||||||
item->setSelected( true );
|
item->setSelected( true );
|
||||||
newParent->addChild( item );
|
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 )
|
void WidgetHierarchy::getCurrentGroup( QString &g )
|
||||||
|
@ -345,18 +362,11 @@ namespace GUIEditor
|
||||||
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
|
widgetHT->collapseAll();
|
||||||
QTreeWidgetItem *item = itr->second;
|
|
||||||
QTreeWidgetItem *currItem = item;
|
|
||||||
while( currItem != NULL )
|
|
||||||
{
|
|
||||||
currItem->setExpanded( true );
|
|
||||||
currItem = currItem->parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// select the current item
|
// select the current item
|
||||||
item->setSelected( true );
|
QTreeWidgetItem *item = itr->second;
|
||||||
widgetHT->setCurrentItem( item );
|
selectItem( item );
|
||||||
currentSelection = newSelection;
|
currentSelection = newSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +375,8 @@ namespace GUIEditor
|
||||||
if( item->parent() == NULL )
|
if( item->parent() == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
selectItem( item );
|
||||||
|
|
||||||
std::string n = item->text( 0 ).toUtf8().constData();
|
std::string n = item->text( 0 ).toUtf8().constData();
|
||||||
currentSelection = makeFullName( item, n );
|
currentSelection = makeFullName( item, n );
|
||||||
CWidgetManager::getInstance()->setCurrentEditorSelection( currentSelection );
|
CWidgetManager::getInstance()->setCurrentEditorSelection( currentSelection );
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace GUIEditor
|
||||||
void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group );
|
void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group );
|
||||||
QTreeWidgetItem* findItem( const std::string &id );
|
QTreeWidgetItem* findItem( const std::string &id );
|
||||||
QTreeWidgetItem* findParent( const std::string &id );
|
QTreeWidgetItem* findParent( const std::string &id );
|
||||||
|
void selectItem( QTreeWidgetItem *item );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onGUILoaded();
|
void onGUILoaded();
|
||||||
|
|
Loading…
Reference in a new issue