From 92bd4d3a05e12630412a1e861b5e2197408a90c8 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 28 Jul 2017 18:35:17 +0200 Subject: [PATCH] ENH: wait the end of edition before calling update (InputImage widget) --- .../otbWrapperQtWidgetInputImageParameter.h | 5 ++++- .../src/otbWrapperQtWidgetInputImageParameter.cxx | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h index 8c2a578642..01684af932 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h @@ -48,8 +48,11 @@ public: inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); +signals: + void FileNameIsSet(); + protected slots: - bool SetFileName( const QString& value ); + bool SetFileName(); void SelectFile(); private: diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx index 2f2b06519d..2929d528a5 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx @@ -69,8 +69,8 @@ void QtWidgetInputImageParameter::DoCreateWidget() m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; m_Input->setToolTip( m_InputImageParam->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, SIGNAL(editingFinished()), this, SLOT(SetFileName()) ); + connect( this, SIGNAL(FileNameIsSet()), GetModel(), SLOT(NotifyUpdate()) ); m_HLayout->addWidget(m_Input); @@ -105,7 +105,9 @@ QtWidgetInputImageParameter if( filename.isEmpty() ) return; - if( !SetFileName( filename ) ) + m_Input->setText( filename ); + + if( !SetFileName() ) { std::ostringstream oss; @@ -119,21 +121,20 @@ QtWidgetInputImageParameter return; } - - m_Input->setText( filename ); } -bool QtWidgetInputImageParameter::SetFileName(const QString& value) +bool QtWidgetInputImageParameter::SetFileName() { bool res = true; // save value if( m_InputImageParam->SetFromFileName( - QFile::encodeName( value ).constData() ) == true ) + QFile::encodeName( m_Input->text() ).constData() ) == true ) { // notify of value change QString key( m_InputImageParam->GetKey() ); emit ParameterChanged(key); + emit FileNameIsSet(); } else res = false; -- GitLab