ADDED: #1471 The widget hierarchy tree view is now filled with real data, when loading a project.

This commit is contained in:
dfighter1985 2012-07-20 06:53:30 +02:00
parent 4e08299eb7
commit 1584bdfaf0
5 changed files with 88 additions and 66 deletions

View file

@ -69,16 +69,16 @@ namespace GUIEditor
QDockWidget *dock = new QDockWidget( "Widget Hierarchy", this );
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
WidgetHierarchy *ha = new WidgetHierarchy;
dock->setWidget( ha );
hierarchyView = new WidgetHierarchy;
dock->setWidget( hierarchyView );
addDockWidget( Qt::LeftDockWidgetArea, dock );
dock = new QDockWidget( "Widget Properties", this );
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
QtTreePropertyBrowser *tb = new QtTreePropertyBrowser;
browserCtrl.setBrowser( tb );
QtTreePropertyBrowser *propBrowser = new QtTreePropertyBrowser;
browserCtrl.setBrowser( propBrowser );
browserCtrl.setup();
dock->setWidget( tb );
dock->setWidget( propBrowser );
addDockWidget( Qt::RightDockWidgetArea, dock );
viewPort->init();
@ -102,6 +102,10 @@ namespace GUIEditor
delete viewPort;
viewPort = NULL;
// no deletion needed for these, since dockwidget owns them
hierarchyView = NULL;
propBrowser = NULL;
}
QUndoStack *GUIEditorWindow::undoStack() const
@ -145,7 +149,10 @@ namespace GUIEditor
currentProject = projectFiles.projectName.c_str();
projectWindow->setupFiles( projectFiles );
if( viewPort->parse( projectFiles ) )
{
hierarchyView->buildHierarchy( projectFiles.masterGroup );
viewPort->draw();
}
else
{
QMessageBox::critical( this,
@ -168,7 +175,10 @@ namespace GUIEditor
tr( "There was an error while parsing the GUI XML files. See the log file for details." ) );
}
else
{
hierarchyView->buildHierarchy( projectFiles.masterGroup );
viewPort->draw();
}
setCursor( Qt::ArrowCursor );
}

View file

@ -24,10 +24,13 @@
#include "widget_info.h"
#include "property_browser_ctrl.h"
class QtTreePropertyBrowser;
namespace GUIEditor
{
class CWidgetProperties;
class WidgetHierarchy;
class LinkEditor;
class ProcEditor;
class ProjectWindow;
@ -62,6 +65,8 @@ private:
Ui::GUIEditorWindow m_ui;
CWidgetProperties *widgetProps;
WidgetHierarchy *hierarchyView;
QtTreePropertyBrowser *propBrowser;
LinkEditor *linkEditor;
ProcEditor *procEditor;
ProjectWindow *projectWindow;

View file

@ -16,6 +16,8 @@
#include "widget_hierarchy.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
namespace GUIEditor
{
@ -28,4 +30,57 @@ namespace GUIEditor
WidgetHierarchy::~WidgetHierarchy()
{
}
void WidgetHierarchy::clearHierarchy()
{
widgetHT->clear();
}
void WidgetHierarchy::buildHierarchy( std::string &masterGroup )
{
clearHierarchy();
CInterfaceGroup *mg = CWidgetManager::getInstance()->getMasterGroupFromId( masterGroup );
if( mg != NULL )
{
QTreeWidgetItem *item = new QTreeWidgetItem( NULL );
item->setText( 0, "root" );
widgetHT->addTopLevelItem( item );
buildHierarchy( item, mg );
}
}
void WidgetHierarchy::buildHierarchy( QTreeWidgetItem *parent, CInterfaceGroup *group )
{
// First add ourselves
QTreeWidgetItem *item = new QTreeWidgetItem( parent );
item->setText( 0, group->getId().c_str() );
// Then add recursively our subgroups
const std::vector< CInterfaceGroup* > &groups = group->getGroups();
std::vector< CInterfaceGroup* >::const_iterator gitr;
for( gitr = groups.begin(); gitr != groups.end(); ++gitr )
{
buildHierarchy( item, *gitr );
}
// Add our controls
const std::vector< CCtrlBase* > &controls = group->getControls();
std::vector< CCtrlBase* >::const_iterator citr;
for( citr = controls.begin(); citr != controls.end(); ++citr )
{
QTreeWidgetItem *subItem = new QTreeWidgetItem( item );
subItem->setText( 0, (*citr)->getId().c_str() );
}
// Add our views
const std::vector< CViewBase* > &views = group->getViews();
std::vector< CViewBase* >::const_iterator vitr;
for( vitr = views.begin(); vitr != views.end(); ++vitr )
{
QTreeWidgetItem *subItem = new QTreeWidgetItem( item );
subItem->setText( 0, (*vitr)->getId().c_str() );
}
}
}

View file

@ -19,6 +19,13 @@
#include "ui_widget_hierarchy.h"
namespace NLGUI
{
class CInterfaceGroup;
}
class QTreeWidgetItem;
namespace GUIEditor
{
class WidgetHierarchy : public QWidget, public Ui::WidgetHierarchyTree
@ -28,6 +35,11 @@ namespace GUIEditor
WidgetHierarchy( QWidget *parent = NULL );
~WidgetHierarchy();
void clearHierarchy();
void buildHierarchy( std::string &masterGroup );
private:
void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group );
};
}

View file

@ -21,66 +21,6 @@
<string>Widgets</string>
</property>
</column>
<item>
<property name="text">
<string>root</string>
</property>
<item>
<property name="text">
<string>container1</string>
</property>
<item>
<property name="text">
<string>group1</string>
</property>
<item>
<property name="text">
<string>group3</string>
</property>
</item>
<item>
<property name="text">
<string>group4</string>
</property>
<item>
<property name="text">
<string>button1</string>
</property>
</item>
<item>
<property name="text">
<string>button2</string>
</property>
</item>
<item>
<property name="text">
<string>text1</string>
</property>
</item>
<item>
<property name="text">
<string>bitmap1</string>
</property>
</item>
</item>
</item>
<item>
<property name="text">
<string>group2</string>
</property>
</item>
</item>
<item>
<property name="text">
<string>container2</string>
</property>
</item>
<item>
<property name="text">
<string>container3</string>
</property>
</item>
</item>
</widget>
</item>
</layout>