Commit 7c5051a3 authored by Otmane Lahlou's avatar Otmane Lahlou

ENH : add notifications handling to update the view

parent 2c4d5ea0
......@@ -29,10 +29,8 @@ namespace Wrapper
QtWidgetModel::QtWidgetModel(Application* app)
: m_Application(app)
{
m_Application->Init();
m_ProgressWindow = new QWidget();
//m_Application->RegisterListener( this );
}
QtWidgetModel::~QtWidgetModel()
......@@ -41,7 +39,11 @@ QtWidgetModel::~QtWidgetModel()
void QtWidgetModel::NotifyUpdate()
{
// Update the parameters
m_Application->UpdateParameters();
// Notify all
this->NotifyAll("ParametersUpdated");
}
void QtWidgetModel::ExecuteAndWriteOutput()
......
......@@ -21,7 +21,8 @@
#include <QtGui>
#include "otbWrapperApplication.h"
#include "otbWrapperChoiceParameter.h"
//#include "otbWrapperEventsListener.h"
#include "otbWrapperEventsSender.h"
#include "otbWrapperEvent.h"
namespace otb
{
......@@ -55,7 +56,7 @@ private:
/** \class
* \brief
*/
class QtWidgetModel : public QObject /*, public EventsListener<std::string>*/
class QtWidgetModel : public QObject, public EventsSender<std::string>
{
Q_OBJECT
public:
......@@ -75,8 +76,6 @@ protected slots:
// slot called everytime one of the widget is updated
void NotifyUpdate();
//void Notify();
private:
QtWidgetModel(const QtWidgetModel&); //purposely not implemented
void operator=(const QtWidgetModel&); //purposely not implemented
......
......@@ -34,6 +34,7 @@ QtWidgetView::QtWidgetView(Application* app)
m_Model = new QtWidgetModel(app);
m_Application = app;
m_Model->RegisterListener( this );
}
QtWidgetView::~QtWidgetView()
......@@ -124,6 +125,7 @@ QWidget* QtWidgetView::CreateFooter()
m_ExecButton = new QPushButton(footerGroup);
m_ExecButton->setDefault(true);
m_ExecButton->setEnabled(false);
m_ExecButton->setText(QObject::tr("Execute"));
connect( m_ExecButton, SIGNAL(clicked()), this, SLOT(ExecuteAndWriteOutputSlot() ) );
......@@ -251,6 +253,21 @@ 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);
}
}
}
}
}
......@@ -21,7 +21,7 @@
#include <QtGui>
#include "otbWrapperApplication.h"
#include "otbWrapperQtWidgetModel.h"
//#include "otbWrapperEventsListener.h"
#include "otbWrapperEventsListener.h"
namespace otb
......@@ -32,7 +32,7 @@ namespace Wrapper
/** \class
* \brief
*/
class QtWidgetView : public QWidget /*, public EventsListener<std::string>*/
class QtWidgetView : public QWidget , public EventsListener<std::string>
{
Q_OBJECT
public:
......@@ -48,6 +48,9 @@ public:
}
*/
// Get the notifications
void Notify(const std::string& event);
public slots:
void ExecuteAndWriteOutputSlot();
void CloseSlot();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment