diff --git a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h index 023029fc205e56b9111a9260409a2d648ee8380e..61d425e75d7597f248933b7c80b066f1bda3aaf8 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h @@ -763,13 +763,29 @@ SetupForFilenameDrop( W* widget, const char* text ) lineEdit->installEventFilter( eventFilter ); - QObject::connect( - eventFilter, - SIGNAL( FilenameDropped( const QString& ) ), - // to: - lineEdit, - SLOT( setText( const QString& ) ) - ); + // BUG : temporary fix for drag & drop in InputImageParameter + // in the future, all "filename" parameters should have the same behaviour + if (dynamic_cast<otb::Wrapper::QtWidgetInputImageParameter*>(widget) || + dynamic_cast<otb::Wrapper::QtFileSelectionWidget*>(widget)) + { + QObject::connect( + eventFilter, + SIGNAL( FilenameDropped( const QString& ) ), + // to: + widget, + SLOT( SetFileName( const QString& ) ) + ); + } + else + { + QObject::connect( + eventFilter, + SIGNAL( FilenameDropped( const QString& ) ), + // to: + lineEdit, + SLOT( setText( const QString& ) ) + ); + } } /*****************************************************************************/ diff --git a/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h b/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h index d7b42e3083116faed0e1d51627f39c48206114d6..ec1977b33a45fb3cfaf3c5f6f77bd80e135a3545 100644 --- a/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h +++ b/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h @@ -87,6 +87,7 @@ signals: protected slots: void SelectFile(); void CallFilenameChanged(); + void SetFileName(const QString &); private: QtFileSelectionWidget(const QtFileSelectionWidget&); //purposely not implemented diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h index 01684af9326ed3b20133ddedcce04d9f29f4c8ae..5c970fc5c7b6e41a5c57eed44931d5e3172e1f0d 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h @@ -52,9 +52,12 @@ signals: void FileNameIsSet(); protected slots: - bool SetFileName(); + bool SetFileName(const QString& value); void SelectFile(); +private slots: + void OnEditingFinished(); + private: QtWidgetInputImageParameter(const QtWidgetInputImageParameter&); //purposely not implemented void operator=(const QtWidgetInputImageParameter&); //purposely not implemented diff --git a/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx b/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx index 37e4f3eed3ee02c97da7956d506f55d3c82ab98c..44eb911061301a5c3373857794a037ac2059f088 100644 --- a/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx +++ b/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx @@ -116,15 +116,22 @@ QtFileSelectionWidget if( filename.isEmpty() ) return; - m_Input->setText( filename ); + SetFileName(filename); +} +void +QtFileSelectionWidget +::CallFilenameChanged() +{ emit FilenameChanged(); } void QtFileSelectionWidget -::CallFilenameChanged() +::SetFileName(const QString & filename) { + m_Input->setText( filename ); + emit FilenameChanged(); } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx index 2929d528a5515d1f4696b390e99e4ef46b0b0b20..e41c35dc01c1ede50efab19452972e0970abd9ce 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx @@ -69,7 +69,7 @@ void QtWidgetInputImageParameter::DoCreateWidget() m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; m_Input->setToolTip( m_InputImageParam->GetDescription() ); - connect( m_Input, SIGNAL(editingFinished()), this, SLOT(SetFileName()) ); + connect( m_Input, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()) ); connect( this, SIGNAL(FileNameIsSet()), GetModel(), SLOT(NotifyUpdate()) ); m_HLayout->addWidget(m_Input); @@ -105,9 +105,7 @@ QtWidgetInputImageParameter if( filename.isEmpty() ) return; - m_Input->setText( filename ); - - if( !SetFileName() ) + if( !SetFileName(filename) ) { std::ostringstream oss; @@ -123,13 +121,14 @@ QtWidgetInputImageParameter } } -bool QtWidgetInputImageParameter::SetFileName() +bool QtWidgetInputImageParameter::SetFileName(const QString& value) { bool res = true; // save value if( m_InputImageParam->SetFromFileName( - QFile::encodeName( m_Input->text() ).constData() ) == true ) + QFile::encodeName( value ).constData() ) == true ) { + m_Input->setText( value ); // notify of value change QString key( m_InputImageParam->GetKey() ); @@ -142,5 +141,10 @@ bool QtWidgetInputImageParameter::SetFileName() return res; } +void QtWidgetInputImageParameter::OnEditingFinished() +{ + SetFileName( m_Input->text() ); +} + } }