mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-24 09:58:46 +00:00
Collapse the tree, and only expand the items that are needed to get to the selected items.
This commit is contained in:
parent
b46483a2a6
commit
6eb4cf9c3f
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,6 +374,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 );
|
||||||
|
|
|
@ -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