From 6639ed1a819200dbf96ad07ea1efda8e17b94424 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Jul 2012 04:12:39 +0200 Subject: [PATCH] CHANGED: #1471 The widget hierarchy widget will not use the full name of widgets (e.g.: ui:something:somethingelse ), only their own name ( e.g.: somethingelse ). --- .../plugins/gui_editor/widget_hierarchy.cpp | 65 +++++++++++++++++-- .../src/plugins/gui_editor/widget_hierarchy.h | 3 + 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp index 3dafa6e04..8896cdc80 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp @@ -19,12 +19,53 @@ #include "nel/gui/interface_group.h" #include "nel/gui/widget_manager.h" +namespace +{ + std::string makeNodeName( const std::string &name ) + { + std::string s = name; + if( s.empty() ) + return s; + + std::string::size_type i = s.find_last_of( ":" ); + if( i == std::string::npos ) + return s; + + if( i == ( s.size() - 1 ) ) + return s; + + s = name.substr( i + 1, s.size() - 1 ); + return s; + } + + std::string& makeFullName( QTreeWidgetItem *item, std::string &name ) + { + if( item == NULL ) + return name; + QString s; + + s = item->text( 0 ); + item = item->parent(); + + while( item != NULL ) + { + s.prepend( item->text( 0 ) + ":" ); + item = item->parent(); + } + + name = s.toStdString(); + return name; + } +} + namespace GUIEditor { WidgetHierarchy::WidgetHierarchy( QWidget *parent ) : QWidget( parent ) { setupUi( this ); + connect( widgetHT, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), + this, SLOT( onItemDblClicked( QTreeWidgetItem* ) ) ); } WidgetHierarchy::~WidgetHierarchy() @@ -44,7 +85,7 @@ namespace GUIEditor if( mg != NULL ) { QTreeWidgetItem *item = new QTreeWidgetItem( NULL ); - item->setText( 0, "root" ); + item->setText( 0, "ui" ); widgetHT->addTopLevelItem( item ); buildHierarchy( item, mg ); @@ -55,7 +96,7 @@ namespace GUIEditor { // First add ourselves QTreeWidgetItem *item = new QTreeWidgetItem( parent ); - item->setText( 0, group->getId().c_str() ); + item->setText( 0, makeNodeName( group->getId() ).c_str() ); // Then add recursively our subgroups const std::vector< CInterfaceGroup* > &groups = group->getGroups(); @@ -71,7 +112,7 @@ namespace GUIEditor for( citr = controls.begin(); citr != controls.end(); ++citr ) { QTreeWidgetItem *subItem = new QTreeWidgetItem( item ); - subItem->setText( 0, (*citr)->getId().c_str() ); + subItem->setText( 0, makeNodeName( (*citr)->getId() ).c_str() ); } // Add our views @@ -80,7 +121,23 @@ namespace GUIEditor for( vitr = views.begin(); vitr != views.end(); ++vitr ) { QTreeWidgetItem *subItem = new QTreeWidgetItem( item ); - subItem->setText( 0, (*vitr)->getId().c_str() ); + subItem->setText( 0, makeNodeName( (*vitr)->getId() ).c_str() ); } } + + void WidgetHierarchy::onItemDblClicked( QTreeWidgetItem *item ) + { + CWidgetManager *mg = CWidgetManager::getInstance(); + + if( item->parent() == NULL ) + return; + + std::string name = item->text( 0 ).toStdString(); + CInterfaceElement *e = mg->getElementFromId( makeFullName( item, name ) ); + if( e != NULL ) + { + + } + + } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h index 00996f6ab..2797dfef6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h @@ -40,6 +40,9 @@ namespace GUIEditor private: void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group ); + + private Q_SLOTS: + void onItemDblClicked( QTreeWidgetItem *item ); }; }