Added some more checks, signal and slots related to widget adding.

This commit is contained in:
dfighter1985 2013-05-05 05:49:35 +02:00
parent 1e84771ba0
commit 80c6617ccc
6 changed files with 46 additions and 1 deletions

View file

@ -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() );
}
}
}

View file

@ -22,6 +22,9 @@ namespace GUIEditor
private Q_SLOTS:
void onAddClicked();
Q_SIGNALS:
void adding( const QString &parentGroup, const QString &widgetType, const QString &name );
};
}

View file

@ -31,6 +31,9 @@
<property name="text">
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">

View file

@ -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 );
}
}

View file

@ -28,6 +28,7 @@ namespace GUIEditor
public Q_SLOTS:
void onDelete();
void onAdd( const QString &parentGroup, const QString &widgetType, const QString &name );
};
}

View file

@ -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()