Renamed NelGUIWidget to NelGUICtrl, and changed it's base class from QWidget to QObject.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-06-14 18:44:57 +02:00
parent 1457469dfe
commit 676587559b
4 changed files with 33 additions and 38 deletions

View file

@ -65,8 +65,8 @@ namespace GUIEditor
projectWindow = new ProjectWindow; projectWindow = new ProjectWindow;
addWidgetWidget = new AddWidgetWidget; addWidgetWidget = new AddWidgetWidget;
connect( projectWindow, SIGNAL( projectFilesChanged() ), this, SLOT( onProjectFilesChanged() ) ); connect( projectWindow, SIGNAL( projectFilesChanged() ), this, SLOT( onProjectFilesChanged() ) );
viewPort = new NelGUIWidget; GUICtrl = new NelGUICtrl();
setCentralWidget( viewPort->getViewPort() ); setCentralWidget( GUICtrl->getViewPort() );
widgetInfoTree = new CWidgetInfoTree; widgetInfoTree = new CWidgetInfoTree;
@ -97,9 +97,9 @@ namespace GUIEditor
dock->setWidget( propBrowser ); dock->setWidget( propBrowser );
addDockWidget( Qt::RightDockWidgetArea, dock ); addDockWidget( Qt::RightDockWidgetArea, dock );
viewPort->init(); GUICtrl->init();
connect( viewPort, SIGNAL( guiLoadComplete() ), this, SLOT( onGUILoaded() ) ); connect( GUICtrl, SIGNAL( guiLoadComplete() ), this, SLOT( onGUILoaded() ) );
connect( widgetProps, SIGNAL( treeChanged() ), this, SLOT( onTreeChanged() ) ); connect( widgetProps, SIGNAL( treeChanged() ), this, SLOT( onTreeChanged() ) );
connect( connect(
addWidgetWidget, addWidgetWidget,
@ -130,8 +130,8 @@ namespace GUIEditor
delete projectWindow; delete projectWindow;
projectWindow = NULL; projectWindow = NULL;
delete viewPort; delete GUICtrl;
viewPort = NULL; GUICtrl = NULL;
delete addWidgetWidget; delete addWidgetWidget;
addWidgetWidget = NULL; addWidgetWidget = NULL;
@ -181,7 +181,7 @@ namespace GUIEditor
currentProject = projectFiles.projectName.c_str(); currentProject = projectFiles.projectName.c_str();
currentProjectFile = fileName; currentProjectFile = fileName;
projectWindow->setupFiles( projectFiles ); projectWindow->setupFiles( projectFiles );
if( viewPort->parse( projectFiles ) ) if( GUICtrl->parse( projectFiles ) )
{ {
hierarchyView->buildHierarchy( projectFiles.masterGroup ); hierarchyView->buildHierarchy( projectFiles.masterGroup );
} }
@ -282,14 +282,14 @@ namespace GUIEditor
return false; return false;
CEditorSelectionWatcher *w = viewPort->getWatcher(); CEditorSelectionWatcher *w = GUICtrl->getWatcher();
disconnect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), hierarchyView, SLOT( onSelectionChanged( std::string& ) ) ); disconnect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), hierarchyView, SLOT( onSelectionChanged( std::string& ) ) );
disconnect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) ); disconnect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
projectFiles.clearAll(); projectFiles.clearAll();
projectWindow->clear(); projectWindow->clear();
hierarchyView->clearHierarchy(); hierarchyView->clearHierarchy();
viewPort->reset(); GUICtrl->reset();
browserCtrl.clear(); browserCtrl.clear();
linkList->clear(); linkList->clear();
procList->clear(); procList->clear();
@ -305,7 +305,7 @@ namespace GUIEditor
setCursor( Qt::WaitCursor ); setCursor( Qt::WaitCursor );
projectWindow->updateFiles( projectFiles ); projectWindow->updateFiles( projectFiles );
if( !viewPort->parse( projectFiles ) ) if( !GUICtrl->parse( projectFiles ) )
{ {
QMessageBox::critical( this, QMessageBox::critical( this,
tr( "Error parsing GUI XML files" ), tr( "Error parsing GUI XML files" ),
@ -321,7 +321,7 @@ namespace GUIEditor
procList->onGUILoaded(); procList->onGUILoaded();
linkList->onGUILoaded(); linkList->onGUILoaded();
CEditorSelectionWatcher *w = viewPort->getWatcher(); CEditorSelectionWatcher *w = GUICtrl->getWatcher();
connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), hierarchyView, SLOT( onSelectionChanged( std::string& ) ) ); connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), hierarchyView, SLOT( onSelectionChanged( std::string& ) ) );
connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) ); connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
} }
@ -345,13 +345,13 @@ namespace GUIEditor
void GUIEditorWindow::hideEvent( QHideEvent *evnt ) void GUIEditorWindow::hideEvent( QHideEvent *evnt )
{ {
QWidget::hideEvent( evnt ); QWidget::hideEvent( evnt );
viewPort->hide(); GUICtrl->hide();
} }
void GUIEditorWindow::showEvent( QShowEvent *evnt ) void GUIEditorWindow::showEvent( QShowEvent *evnt )
{ {
QWidget::showEvent( evnt ); QWidget::showEvent( evnt );
viewPort->show(); GUICtrl->show();
} }
void GUIEditorWindow::createMenus() void GUIEditorWindow::createMenus()

View file

@ -36,7 +36,7 @@ namespace GUIEditor
class LinkList; class LinkList;
class ProcList; class ProcList;
class ProjectWindow; class ProjectWindow;
class NelGUIWidget; class NelGUICtrl;
class CWidgetInfoTree; class CWidgetInfoTree;
class CEditorMessageProcessor; class CEditorMessageProcessor;
class AddWidgetWidget; class AddWidgetWidget;
@ -87,7 +87,7 @@ private:
LinkList *linkList; LinkList *linkList;
ProcList *procList; ProcList *procList;
ProjectWindow *projectWindow; ProjectWindow *projectWindow;
NelGUIWidget *viewPort; NelGUICtrl *GUICtrl;
CWidgetInfoTree *widgetInfoTree; CWidgetInfoTree *widgetInfoTree;
CEditorMessageProcessor *messageProcessor; CEditorMessageProcessor *messageProcessor;
AddWidgetWidget *addWidgetWidget; AddWidgetWidget *addWidgetWidget;

View file

@ -35,8 +35,8 @@ namespace GUIEditor
{ {
std::set< std::string > hwCursors; std::set< std::string > hwCursors;
NelGUIWidget::NelGUIWidget( QWidget *parent ) : NelGUICtrl::NelGUICtrl( QObject *parent ) :
QWidget( parent ) QObject( parent )
{ {
timerID = 0; timerID = 0;
guiLoaded = false; guiLoaded = false;
@ -44,7 +44,7 @@ namespace GUIEditor
w = new Nel3DWidget(); w = new Nel3DWidget();
} }
NelGUIWidget::~NelGUIWidget() NelGUICtrl::~NelGUICtrl()
{ {
guiLoaded = false; guiLoaded = false;
if( timerID != 0 ) if( timerID != 0 )
@ -57,7 +57,7 @@ namespace GUIEditor
w = NULL; w = NULL;
} }
void NelGUIWidget::init() void NelGUICtrl::init()
{ {
NLMISC::CI18N::setNoResolution( true ); NLMISC::CI18N::setNoResolution( true );
NLMISC::CPath::remapExtension( "dds", "tga", true ); NLMISC::CPath::remapExtension( "dds", "tga", true );
@ -81,7 +81,7 @@ namespace GUIEditor
watcher = new CEditorSelectionWatcher(); watcher = new CEditorSelectionWatcher();
} }
bool NelGUIWidget::parse( SProjectFiles &files ) bool NelGUICtrl::parse( SProjectFiles &files )
{ {
reset(); reset();
IParser *parser = CWidgetManager::getInstance()->getParser(); IParser *parser = CWidgetManager::getInstance()->getParser();
@ -120,7 +120,7 @@ namespace GUIEditor
return true; return true;
} }
void NelGUIWidget::reset() void NelGUICtrl::reset()
{ {
guiLoaded = false; guiLoaded = false;
if( timerID != 0 ) if( timerID != 0 )
@ -133,7 +133,7 @@ namespace GUIEditor
w->clear(); w->clear();
} }
void NelGUIWidget::draw() void NelGUICtrl::draw()
{ {
w->getDriver()->clearBuffers( NLMISC::CRGBA::Black ); w->getDriver()->clearBuffers( NLMISC::CRGBA::Black );
CWidgetManager::getInstance()->checkCoords(); CWidgetManager::getInstance()->checkCoords();
@ -141,13 +141,7 @@ namespace GUIEditor
w->getDriver()->swapBuffers(); w->getDriver()->swapBuffers();
} }
void NelGUIWidget::paintEvent( QPaintEvent *evnt ) void NelGUICtrl::timerEvent( QTimerEvent *evnt )
{
if( !guiLoaded )
w->clear();
}
void NelGUIWidget::timerEvent( QTimerEvent *evnt )
{ {
if( evnt->timerId() == timerID ) if( evnt->timerId() == timerID )
{ {
@ -159,13 +153,13 @@ namespace GUIEditor
} }
} }
void NelGUIWidget::show() void NelGUICtrl::show()
{ {
if( timerID == 0 ) if( timerID == 0 )
timerID = startTimer( 200 ); timerID = startTimer( 200 );
} }
void NelGUIWidget::hide() void NelGUICtrl::hide()
{ {
if( timerID != 0 ) if( timerID != 0 )
{ {
@ -174,7 +168,7 @@ namespace GUIEditor
} }
} }
QWidget* NelGUIWidget::getViewPort() QWidget* NelGUICtrl::getViewPort()
{ {
return w; return w;
} }

View file

@ -18,21 +18,23 @@
#ifndef NELGUI_WIDGET_H #ifndef NELGUI_WIDGET_H
#define NELGUI_WIDGET_H #define NELGUI_WIDGET_H
#include <QWidget> #include <QObject>
#include "project_files.h" #include "project_files.h"
class QWidget;
namespace GUIEditor namespace GUIEditor
{ {
class CEditorSelectionWatcher; class CEditorSelectionWatcher;
class Nel3DWidget; class Nel3DWidget;
/// Qt viewport for the Nel GUI library /// Qt viewport controller for the Nel GUI library
class NelGUIWidget : public QWidget class NelGUICtrl : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
NelGUIWidget( QWidget *parent = NULL ); NelGUICtrl( QObject *parent = NULL );
~NelGUIWidget(); ~NelGUICtrl();
void init(); void init();
bool parse( SProjectFiles &files ); bool parse( SProjectFiles &files );
@ -49,7 +51,6 @@ Q_SIGNALS:
void guiLoadComplete(); void guiLoadComplete();
protected: protected:
void paintEvent( QPaintEvent *evnt );
void timerEvent( QTimerEvent *evnt ); void timerEvent( QTimerEvent *evnt );
private: private: