Commit a9789cc4 authored by Victor Poughon's avatar Victor Poughon

REFAC: begin upgrade to qt5 signal/slot syntax

parent 258d3f59
......@@ -146,16 +146,6 @@ signals:
void Stop();
protected slots:
/**
* \brief Slot called when execution is requested (e.g. by
* otb::Wrapper::QtWidgetView).
*
* This slot is protected so it can only be called via Qt
* signal/slot mechanism and not directly by extern caller.
*/
void ExecuteAndWriteOutputSlot();
public slots:
/**
* \brief Slots called every time one of the widget needs to be
......@@ -164,6 +154,12 @@ public slots:
*/
void NotifyUpdate();
/**
* \brief Slot called when execution is requested (e.g. by
* otb::Wrapper::QtWidgetView).
*/
void ExecuteAndWriteOutputSlot();
private slots:
/**
* \brief
......
......@@ -103,6 +103,8 @@ public:
// Public SLOTS.
public slots:
void UnhandledException(QString message);
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
......@@ -144,7 +146,6 @@ protected slots:
*/
void OnExecButtonClicked();
void UnhandledException(QString message);
void OnExceptionRaised( QString what );
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
......
......@@ -95,9 +95,9 @@ int main(int argc, char* argv[])
gui->CreateGui();
// Connect the View "Quit" signal, to the mainWindow close slot
QObject::connect(gui, SIGNAL(QuitSignal()), mainWindow, SLOT(close()));
QObject::connect(gui, &QtWidgetView::QuitSignal, mainWindow, &QMainWindow::close);
QObject::connect(&qtApp, SIGNAL(UnhandledException(QString)), gui, SLOT(UnhandledException(QString)));
QObject::connect(&qtApp, &QtApplication::UnhandledException, gui, &QtWidgetView::UnhandledException);
// build the main window, central widget is the plugin view, other
......
......@@ -74,7 +74,7 @@ void QtFileSelectionWidget::DoCreateWidget()
m_HLayout->addWidget(m_Checkbox);
m_Input = new QLineEdit;
connect( m_Input, SIGNAL(editingFinished()), this, SLOT(CallFilenameChanged()) );
connect( m_Input, &QLineEdit::editingFinished, this, &QtFileSelectionWidget::CallFilenameChanged );
m_HLayout->addWidget(m_Input);
// Set up input text edit
......@@ -83,7 +83,7 @@ void QtFileSelectionWidget::DoCreateWidget()
m_Button->setToolTip("Select file...");
m_Button->setFixedWidth(30);
connect( m_Button, SIGNAL(clicked()), this, SLOT(SelectFile()) );
connect( m_Button, &QPushButton::clicked, this, &QtFileSelectionWidget::SelectFile );
m_HLayout->addWidget(m_Button);
this->setLayout(m_HLayout);
......
......@@ -85,8 +85,8 @@ void QtWidgetBoolParameter::DoCreateWidget()
//Set the tool tip associated to the parameter
m_Button->setToolTip(QString::fromStdString( paramDown->GetDescription() ));
connect( m_Button, SIGNAL(toggled(bool)), this, SLOT(SetValue(bool)) );
connect( m_Button, SIGNAL(toggled(bool)), GetModel(), SLOT(NotifyUpdate()) );
connect( m_Button, &QToolButton::toggled, this, &QtWidgetBoolParameter::SetValue );
connect( m_Button, &QToolButton::toggled, GetModel(), &QtWidgetModel::NotifyUpdate );
hLayout->addWidget(m_Button);
hLayout->addStretch();
......
......@@ -84,9 +84,9 @@ void QtWidgetChoiceParameter::DoCreateWidget()
}
}
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetValue(int)) );
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), m_StackWidget, SLOT(setCurrentIndex(int)) );
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), GetModel(), SLOT(NotifyUpdate()) );
connect( m_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &QtWidgetChoiceParameter::SetValue);
connect( m_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), m_StackWidget, &QStackedWidget::setCurrentIndex);
connect( m_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), GetModel(), &QtWidgetModel::NotifyUpdate );
m_VLayout = new QVBoxLayout(this);
m_VLayout->addWidget(m_ComboBox);
......
......@@ -64,8 +64,8 @@ void QtWidgetInputFilenameParameter::DoCreateWidget()
m_Input->setToolTip(
QString::fromStdString( m_FilenameParam->GetDescription() )
);
connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) );
connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) );
connect( m_Input, &QLineEdit::textChanged, this, &QtWidgetInputFilenameParameter::SetFileName );
connect( m_Input, &QLineEdit::textChanged, GetModel(), &QtWidgetModel::NotifyUpdate );
m_HLayout->addWidget(m_Input);
......@@ -74,7 +74,7 @@ void QtWidgetInputFilenameParameter::DoCreateWidget()
m_Button->setText("...");
m_Button->setToolTip("Select file...");
m_Button->setMaximumWidth(m_Button->width());
connect( m_Button, SIGNAL(clicked()), this, SLOT(SelectFile()) );
connect( m_Button, &QPushButton::clicked, this, &QtWidgetInputFilenameParameter::SelectFile );
m_HLayout->addWidget(m_Button);
this->setLayout(m_HLayout);
......
......@@ -51,12 +51,7 @@ QtWidgetModel
m_Timer = new QTimer(this);
m_Timer->setSingleShot(true);
m_Timer->setInterval(1000);
QObject::connect(
m_Timer,
SIGNAL( timeout() ),
this,
SLOT( TimerDone() )
);
QObject::connect( m_Timer, &QTimer::timeout, this, &QtWidgetModel::TimerDone );
}
QtWidgetModel::~QtWidgetModel()
......@@ -202,35 +197,17 @@ QtWidgetModel
// launch the output image writing
AppliThread *taskAppli = new AppliThread( m_Application );
QObject::connect(
taskAppli,
SIGNAL( ExceptionRaised( QString ) ),
// to:
this,
SIGNAL( ExceptionRaised( QString ) )
);
QObject::connect(
taskAppli,
SIGNAL( ApplicationExecutionDone( int ) ),
// to:
this,
SLOT( OnApplicationExecutionDone( int ) )
);
QObject::connect(
taskAppli,
SIGNAL( finished() ),
taskAppli,
SLOT( deleteLater() )
);
QObject::connect(
this,
SIGNAL( Stop() ),
taskAppli,
SLOT( Stop() )
);
QObject::connect( taskAppli, &AppliThread::ExceptionRaised,
this, &QtWidgetModel::ExceptionRaised );
QObject::connect( taskAppli, &AppliThread::ApplicationExecutionDone,
this, &QtWidgetModel::OnApplicationExecutionDone );
QObject::connect( taskAppli, &AppliThread::finished,
taskAppli, &AppliThread::deleteLater );
QObject::connect( this, &QtWidgetModel::Stop,
taskAppli, &AppliThread::Stop );
// Tell the Progress Reporter to begin
emit SetProgressReportBegin();
......
......@@ -60,8 +60,8 @@ void QtWidgetOutputFilenameParameter::DoCreateWidget()
m_Input->setToolTip(
QString::fromStdString( m_FilenameParam->GetDescription() )
);
connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) );
connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) );
connect( m_Input, &QLineEdit::textChanged, this, &QtWidgetOutputFilenameParameter::SetFileName );
connect( m_Input, &QLineEdit::textChanged, GetModel(), &QtWidgetModel::NotifyUpdate );
m_HLayout->addWidget(m_Input);
......@@ -70,7 +70,7 @@ void QtWidgetOutputFilenameParameter::DoCreateWidget()
m_Button->setText("...");
m_Button->setToolTip("Select file...");
m_Button->setMaximumWidth(m_Button->width());
connect( m_Button, SIGNAL(clicked()), this, SLOT(SelectFile()) );
connect( m_Button, &QPushButton::clicked, this, &QtWidgetOutputFilenameParameter::SelectFile );
m_HLayout->addWidget(m_Button);
this->setLayout(m_HLayout);
......
......@@ -61,8 +61,8 @@ void QtWidgetOutputImageParameter::DoCreateWidget()
m_Input->setToolTip(
QString::fromStdString( m_OutputImageParam->GetDescription() )
);
connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) );
connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) );
connect( m_Input, &QLineEdit::textChanged, this, &QtWidgetOutputImageParameter::SetFileName );
connect( m_Input, &QLineEdit::textChanged, GetModel(), &QtWidgetModel::NotifyUpdate );
m_HLayout->addWidget(m_Input);
// Set the Output PixelType choice Combobox
......@@ -80,8 +80,8 @@ void QtWidgetOutputImageParameter::DoCreateWidget()
m_ComboBox->addItem( "cfloat");
m_ComboBox->addItem( "cdouble");
m_ComboBox->setCurrentIndex(m_OutputImageParam->GetPixelType());
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPixelType(int)) );
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), GetModel(), SLOT(NotifyUpdate()) );
connect( m_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &QtWidgetOutputImageParameter::SetPixelType );
connect( m_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), GetModel(), &QtWidgetModel::NotifyUpdate );
m_HLayout->addWidget(m_ComboBox);
// Set up input text edit
......@@ -89,7 +89,7 @@ void QtWidgetOutputImageParameter::DoCreateWidget()
m_Button->setText("...");
m_Button->setToolTip("Select output filename...");
m_Button->setMaximumWidth(m_Button->width());
connect( m_Button, SIGNAL(clicked()), this, SLOT(SelectFile()) );
connect( m_Button, &QPushButton::clicked, this, &QtWidgetOutputImageParameter::SelectFile );
m_HLayout->addWidget(m_Button);
this->setLayout(m_HLayout);
......
......@@ -35,9 +35,9 @@ QtWidgetSimpleProgressReport::QtWidgetSimpleProgressReport(QtWidgetModel * model
, m_CurrentProcess()
{
m_Model = model;
connect(model, SIGNAL(SetProgressReportBegin()), this, SLOT(show()) );
connect(model, SIGNAL(SetProgressReportDone()), this, SLOT(Init()) );
connect(this, SIGNAL(AddNewProcessToReport()), this, SLOT(ReportProcess()) );
connect(model, &QtWidgetModel::SetProgressReportBegin, this, &QtWidgetSimpleProgressReport::show );
connect(model, &QtWidgetModel::SetProgressReportDone, this, &QtWidgetSimpleProgressReport::Init );
connect(this, &QtWidgetSimpleProgressReport::AddNewProcessToReport, this, &QtWidgetSimpleProgressReport::ReportProcess );
m_Layout = new QVBoxLayout(this);
this->setLayout(m_Layout);
......@@ -49,8 +49,8 @@ QtWidgetSimpleProgressReport::QtWidgetSimpleProgressReport(QtWidgetModel * model
m_Label = new QLabel("No process", this);
m_Label->setWordWrap(true);
connect( m_Bar, SIGNAL(SetValueChanged(int)), m_Bar, SLOT(setValue(int)) );
connect( m_Model, SIGNAL(SetProgressReportDone()), m_Bar, SLOT(reset()) );
connect( m_Bar, &itk::QtProgressBar::SetValueChanged, m_Bar, &itk::QtProgressBar::setValue );
connect( m_Model, &QtWidgetModel::SetProgressReportDone, m_Bar, &itk::QtProgressBar::reset );
m_Layout->addWidget(m_Label);
m_Layout->addWidget(m_Bar);
......
......@@ -72,18 +72,18 @@ QtWidgetView::QtWidgetView( const otb::Wrapper::Application::Pointer & otbApp,
m_QuitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this);
QObject::connect(
m_Model, SIGNAL( SetProgressReportBegin() ),
this, SLOT( OnProgressReportBegin() )
m_Model, &QtWidgetModel::SetProgressReportBegin,
this, &QtWidgetView::OnProgressReportBegin
);
QObject::connect(
m_Model, SIGNAL( SetProgressReportDone( int ) ),
this, SLOT( OnProgressReportEnd( int ) )
m_Model, &QtWidgetModel::SetProgressReportDone,
this, &QtWidgetView::OnProgressReportEnd
);
QObject::connect(
m_Model, SIGNAL( ExceptionRaised( QString ) ),
this, SLOT( OnExceptionRaised( QString ) )
m_Model, &QtWidgetModel::ExceptionRaised,
this, &QtWidgetView::OnExceptionRaised
);
}
......@@ -101,14 +101,14 @@ void QtWidgetView::CreateGui()
m_TabWidget->addTab(CreateInputWidgets(), tr("Parameters"));
m_LogText = new QTextEdit(this);
connect( m_Model->GetLogOutput(), SIGNAL(NewContentLog(QString)), m_LogText, SLOT(append(QString) ) );
connect( m_Model->GetLogOutput(), &QtLogOutput::NewContentLog, m_LogText, &QTextEdit::append );
m_TabWidget->addTab(m_LogText, tr("Logs"));
m_TabWidget->addTab(CreateDoc(), tr("Documentation"));
mainLayout->addWidget(m_TabWidget);
m_Message = new QLabel("<center><font color=\"#FF0000\">"+tr("Select parameters")+"</font></center>", this);
connect( m_Model, SIGNAL(SetApplicationReady(bool)), this, SLOT( UpdateMessageAfterApplicationReady(bool)) );
connect( m_Model, SIGNAL(SetProgressReportDone(int)), this, SLOT(UpdateMessageAfterExecution(int)) );
connect( m_Model, &QtWidgetModel::SetApplicationReady, this, &QtWidgetView::UpdateMessageAfterApplicationReady );
connect( m_Model, &QtWidgetModel::SetProgressReportDone, this, &QtWidgetView::UpdateMessageAfterExecution );
mainLayout->addWidget(m_Message);
otb::Wrapper::QtWidgetSimpleProgressReport * progressReport = new otb::Wrapper::QtWidgetSimpleProgressReport(m_Model, this);
......@@ -190,17 +190,17 @@ QWidget* QtWidgetView::CreateFooter()
m_ExecButton->setDefault(true);
m_ExecButton->setEnabled(false);
m_ExecButton->setText(QObject::tr("Execute"));
connect( m_Model, SIGNAL( SetApplicationReady( bool ) ), m_ExecButton, SLOT( setEnabled( bool ) ));
QObject::connect( m_ExecButton, SIGNAL( clicked() ), this, SLOT( OnExecButtonClicked() ));
QObject::connect( this, SIGNAL( ExecuteAndWriteOutput() ), m_Model, SLOT( ExecuteAndWriteOutputSlot() ));
QObject::connect( this, SIGNAL( Stop() ), m_Model, SIGNAL( Stop() ));
connect( m_Model, &QtWidgetModel::SetApplicationReady, m_ExecButton, &QPushButton::setEnabled );
connect( m_ExecButton, &QPushButton::clicked, this, &QtWidgetView::OnExecButtonClicked );
connect( this, &QtWidgetView::ExecuteAndWriteOutput, m_Model, &QtWidgetModel::ExecuteAndWriteOutputSlot );
connect( this, &QtWidgetView::Stop, m_Model, &QtWidgetModel::Stop );
m_QuitButton = new QPushButton(footerGroup);
m_QuitButton->setText(QObject::tr("Quit"));
connect(m_QuitButton, SIGNAL( clicked() ), this, SLOT( close() ));
connect(m_QuitButton, &QPushButton::clicked, this, &QtWidgetView::close );
// Add Ctrl-Q shortcut to quit
connect( m_QuitShortcut, SIGNAL(activated()), this, SLOT(close()) );
connect( m_QuitShortcut, &QShortcut::activated, this, &QtWidgetView::close );
// Put the buttons on the right
footerLayout->addStretch();
......
......@@ -77,7 +77,7 @@ int otbWrapperQtWidgetShowWidget(int argc, char* argv[])
gui->CreateGui();
// Connect the View "Quit" signal, to the mainWindow close slot
QObject::connect(gui, SIGNAL(QuitSignal()), mainWindow, SLOT(close()));
QObject::connect(gui, &QtWidgetView::QuitSignal, mainWindow, &QMainWindow::close);
// Create a progressReport object
QtWidgetProgressReport* progressReport = new QtWidgetProgressReport(gui->GetModel(), mainWindow);
......
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