From 00fa4cb3215285684b398045b94e72e716a66dc9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 5 May 2013 05:49:35 +0200 Subject: [PATCH] Added some more checks, signal and slots related to widget adding. --- .../plugins/gui_editor/add_widget_widget.cpp | 15 ++++++++++++++- .../plugins/gui_editor/add_widget_widget.h | 3 +++ .../plugins/gui_editor/add_widget_widget.ui | 3 +++ .../gui_editor/editor_message_processor.cpp | 19 +++++++++++++++++++ .../gui_editor/editor_message_processor.h | 1 + .../plugins/gui_editor/gui_editor_window.cpp | 6 ++++++ 6 files changed, 46 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.cpp index 24bd70f63..3f32586b6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.cpp @@ -49,6 +49,16 @@ namespace GUIEditor void AddWidgetWidget::onAddClicked() { + if( groupEdit->text().isEmpty() ) + { + QMessageBox::warning( NULL, + tr( "WARNING" ), + tr( "You need to be adding the new widget into a group!" ), + QMessageBox::Ok ); + + return; + } + if( nameEdit->text().isEmpty() ) { QMessageBox::warning( NULL, @@ -60,5 +70,8 @@ namespace GUIEditor } close(); + + Q_EMIT adding( groupEdit->text(), widgetCB->currentText(), nameEdit->text() ); } -} \ No newline at end of file +} + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.h index fa5045ac2..8f9f6a0be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.h @@ -22,6 +22,9 @@ namespace GUIEditor private Q_SLOTS: void onAddClicked(); + + Q_SIGNALS: + void adding( const QString &parentGroup, const QString &widgetType, const QString &name ); }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.ui index dd7e14e48..58a1890f4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.ui @@ -31,6 +31,9 @@ + + true + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/editor_message_processor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/editor_message_processor.cpp index 28cc7d75b..25924a804 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/editor_message_processor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/editor_message_processor.cpp @@ -54,5 +54,24 @@ namespace GUIEditor CWidgetManager::getInstance()->setCurrentEditorSelection( "" ); } } + + void CEditorMessageProcessor::onAdd( const QString &parentGroup, const QString &widgetType, const QString &name ) + { + // Check if this group exists + CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( std::string( parentGroup.toAscii() ) ); + if( e == NULL ) + return; + CInterfaceGroup *g = dynamic_cast< CInterfaceGroup* >( e ); + if( g == NULL ) + return; + + // Check if an element already exists with that name + if( g->getElement( std::string( name.toAscii() ) ) != NULL ) + return; + + // Create and add the new widget + //CViewBase *v = NULL; + //g->addView( v ); + } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/editor_message_processor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/editor_message_processor.h index 17cac7683..1d41e87a6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/editor_message_processor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/editor_message_processor.h @@ -28,6 +28,7 @@ namespace GUIEditor public Q_SLOTS: void onDelete(); + void onAdd( const QString &parentGroup, const QString &widgetType, const QString &name ); }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index 33cb5e647..8ccd510ef 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -99,6 +99,12 @@ namespace GUIEditor connect( viewPort, SIGNAL( guiLoadComplete() ), this, SLOT( onGUILoaded() ) ); connect( widgetProps, SIGNAL( treeChanged() ), this, SLOT( onTreeChanged() ) ); + connect( + addWidgetWidget, + SIGNAL( adding( const QString&, const QString&, const QString& ) ), + messageProcessor, + SLOT( onAdd( const QString&, const QString&, const QString& ) ) + ); } GUIEditorWindow::~GUIEditorWindow()