Skip to content
Snippets Groups Projects
Commit e5b3d2e1 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH : Don't use the WrapperEvent{Listener,Sender}, use qt signals ans slots instead

parent 7c5051a3
Branches
Tags
No related merge requests found
......@@ -43,7 +43,8 @@ void QtWidgetModel::NotifyUpdate()
m_Application->UpdateParameters();
// Notify all
this->NotifyAll("ParametersUpdated");
bool applicationStatus = m_Application->IsApplicationReady();
emit SetApplicationReady(applicationStatus);
}
void QtWidgetModel::ExecuteAndWriteOutput()
......
......@@ -42,7 +42,7 @@ class AppliThread : public QThread
void run()
{
m_Application->ExecuteAndWriteOutput();
}
}
private:
AppliThread(const AppliThread&); //purposely not implemented
......@@ -56,7 +56,7 @@ private:
/** \class
* \brief
*/
class QtWidgetModel : public QObject, public EventsSender<std::string>
class QtWidgetModel : public QObject
{
Q_OBJECT
public:
......@@ -72,6 +72,9 @@ public:
// slot called when execution is requested
void ExecuteAndWriteOutput();
signals:
void SetApplicationReady(bool);
protected slots:
// slot called everytime one of the widget is updated
void NotifyUpdate();
......
......@@ -34,7 +34,6 @@ QtWidgetView::QtWidgetView(Application* app)
m_Model = new QtWidgetModel(app);
m_Application = app;
m_Model->RegisterListener( this );
}
QtWidgetView::~QtWidgetView()
......@@ -128,6 +127,7 @@ QWidget* QtWidgetView::CreateFooter()
m_ExecButton->setEnabled(false);
m_ExecButton->setText(QObject::tr("Execute"));
connect( m_ExecButton, SIGNAL(clicked()), this, SLOT(ExecuteAndWriteOutputSlot() ) );
connect( m_Model, SIGNAL(SetApplicationReady(bool)), m_ExecButton, SLOT(setEnabled(bool)) );
m_QuitButton = new QPushButton(footerGroup);
m_QuitButton->setText(QObject::tr("Quit"));
......@@ -253,21 +253,6 @@ void QtWidgetView::CloseSlot()
{
this->close();
}
void QtWidgetView::Notify(const std::string& event)
{
if(event == "ParametersUpdated")
{
// "Execute" button activation depends on the application status
if(m_Model->GetApplication()->IsApplicationReady())
{
m_ExecButton->setEnabled(true);
}
else
{
m_ExecButton->setEnabled(false);
}
}
}
}
}
......@@ -32,7 +32,7 @@ namespace Wrapper
/** \class
* \brief
*/
class QtWidgetView : public QWidget , public EventsListener<std::string>
class QtWidgetView : public QWidget
{
Q_OBJECT
public:
......@@ -48,9 +48,6 @@ public:
}
*/
// Get the notifications
void Notify(const std::string& event);
public slots:
void ExecuteAndWriteOutputSlot();
void CloseSlot();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment