Commit 92fb7640 authored by Stéphane Albert's avatar Stéphane Albert

BUG: MANTIS-1112 (File not found if filename contains accents when using GUI)...

BUG: MANTIS-1112 (File not found if filename contains accents when using GUI) Replaced QString::toAscii() by QFile::encodeName() when converting filenames to std::string and used QFile::decodeName() when converting std::string filenames to QString ones.
parent 4245d8c9
......@@ -55,7 +55,7 @@ public:
std::string GetFilename()
{
return m_Input->text().toAscii().constData();
return QFile::encodeName( m_Input->text() ).constData();
}
void ClearFilename()
......
......@@ -34,7 +34,12 @@ QtWidgetComplexInputImageParameter::~QtWidgetComplexInputImageParameter()
void QtWidgetComplexInputImageParameter::DoUpdateGUI()
{
QString text( m_ComplexInputImageParam->GetFileName().c_str() );
QString text(
QFile::decodeName(
m_ComplexInputImageParam->GetFileName().c_str()
)
);
if (text != m_Input->text())
m_Input->setText(text);
}
......@@ -72,7 +77,8 @@ void QtWidgetComplexInputImageParameter::SelectFile()
if (fileDialog.exec())
{
this->SetFileName(fileDialog.selectedFiles().at(0));
this->SetFileName( fileDialog.selectedFiles().at(0) );
m_Input->setText(fileDialog.selectedFiles().at(0));
}
}
......@@ -80,7 +86,9 @@ void QtWidgetComplexInputImageParameter::SelectFile()
void QtWidgetComplexInputImageParameter::SetFileName(const QString& value)
{
// save value
m_ComplexInputImageParam->SetFromFileName(value.toAscii().constData());
m_ComplexInputImageParam->SetFromFileName(
QFile::encodeName( value ).constData()
);
// notify of value change
QString key( m_ComplexInputImageParam->GetKey() );
......
......@@ -36,7 +36,10 @@ QtWidgetComplexOutputImageParameter::~QtWidgetComplexOutputImageParameter()
void QtWidgetComplexOutputImageParameter::DoUpdateGUI()
{
// Update the lineEdit
QString text( m_OutputImageParam->GetFileName() );
QString text(
QFile::decodeName( m_OutputImageParam->GetFileName() )
);
if (text != m_Input->text())
m_Input->setText(text);
}
......@@ -91,7 +94,7 @@ void QtWidgetComplexOutputImageParameter::SelectFile()
void QtWidgetComplexOutputImageParameter::SetFileName(const QString& value)
{
// save value
m_FileName = value.toAscii().constData();
m_FileName = QFile::encodeName( value ).constData();
m_OutputImageParam->SetFileName(m_FileName);
......
......@@ -35,7 +35,12 @@ QtWidgetDirectoryParameter::~QtWidgetDirectoryParameter()
void QtWidgetDirectoryParameter::DoUpdateGUI()
{
// Update the lineEdit
QString text( m_DirectoryParam->GetValue().c_str() );
QString text(
QFile::decodeName(
m_DirectoryParam->GetValue().c_str()
)
);
m_Input->setText(text);
}
......@@ -72,7 +77,8 @@ void QtWidgetDirectoryParameter::SelectFile()
if (fileDialog.exec())
{
this->SetFileName(fileDialog.selectedFiles().at(0));
this->SetFileName( fileDialog.selectedFiles().at(0) );
m_Input->setText(fileDialog.selectedFiles().at(0));
}
}
......@@ -80,7 +86,9 @@ void QtWidgetDirectoryParameter::SelectFile()
void QtWidgetDirectoryParameter::SetFileName(const QString& value)
{
// save value
m_DirectoryParam->SetValue(value.toAscii().constData());
m_DirectoryParam->SetValue(
QFile::encodeName( value ).constData()
);
// notify of value change
QString key( m_DirectoryParam->GetKey() );
......
......@@ -47,7 +47,11 @@ void QtWidgetInputFilenameListParameter::DoUpdateGUI()
std::vector<std::string>::iterator it;
for (it = fileList.begin(); it != fileList.end(); ++it)
{
m_FileSelectionList[i++]->GetInput()->setText(QString( (*it).c_str() ));
m_FileSelectionList[i++]->GetInput()->setText(
QFile::decodeName(
it->c_str()
)
);
}
}
......
......@@ -39,7 +39,12 @@ QtWidgetInputFilenameParameter::~QtWidgetInputFilenameParameter()
void QtWidgetInputFilenameParameter::DoUpdateGUI()
{
// Update the lineEdit
QString text( m_FilenameParam->GetValue().c_str() );
QString text(
QFile::decodeName(
m_FilenameParam->GetValue().c_str()
)
);
if (text != m_Input->text())
m_Input->setText(text);
}
......@@ -109,7 +114,8 @@ void QtWidgetInputFilenameParameter::SelectFile()
if (fileDialog.exec())
{
this->SetFileName(fileDialog.selectedFiles().at(0));
this->SetFileName( fileDialog.selectedFiles().at(0) );
m_Input->setText(fileDialog.selectedFiles().at(0));
}
}
......@@ -117,7 +123,9 @@ void QtWidgetInputFilenameParameter::SelectFile()
void QtWidgetInputFilenameParameter::SetFileName(const QString& value)
{
// save value
m_FilenameParam->SetValue(value.toAscii().constData());
m_FilenameParam->SetValue(
QFile::encodeName( value ).constData()
);
// notify of value change
QString key( m_FilenameParam->GetKey() );
......
......@@ -51,7 +51,9 @@ void QtWidgetInputImageListParameter::DoUpdateGUI()
std::vector<std::string>::iterator it;
for (it = fileList.begin(); it != fileList.end(); ++it)
{
m_FileSelectionList[i++]->GetInput()->setText( QString::fromAscii(it->c_str()) );
m_FileSelectionList[i++]->GetInput()->setText(
QFile::decodeName( it->c_str() )
);
}
}
}
......
......@@ -41,7 +41,12 @@ void QtWidgetInputImageParameter::DoUpdateGUI()
//update lineedit if HasUserValue flag is set(from xml)
if(m_InputImageParam->HasUserValue())
{
QString text( m_InputImageParam->GetFileName().c_str() );
QString text(
QFile::decodeName(
m_InputImageParam->GetFileName().c_str()
)
);
if (text != m_Input->text())
m_Input->setText(text);
}
......@@ -93,13 +98,13 @@ void QtWidgetInputImageParameter::SelectFile()
if (fileDialog.exec())
{
if ( this->SetFileName(fileDialog.selectedFiles().at(0)) == true )
if ( this->SetFileName( fileDialog.selectedFiles().at(0) ) == true )
m_Input->setText(fileDialog.selectedFiles().at(0));
else
{
std::ostringstream oss;
oss << "The given file "
<< fileDialog.selectedFiles().at(0).toAscii().constData()
<< QFile::encodeName( fileDialog.selectedFiles().at( 0 ) ).constData()
<< " is not valid.";
this->GetModel()->SendLogWARNING( oss.str() );
}
......@@ -110,7 +115,8 @@ bool QtWidgetInputImageParameter::SetFileName(const QString& value)
{
bool res = true;
// save value
if(m_InputImageParam->SetFromFileName(value.toAscii().constData()) == true)
if( m_InputImageParam->SetFromFileName(
QFile::encodeName( value ).constData() ) == true )
{
// notify of value change
QString key( m_InputImageParam->GetKey() );
......
......@@ -37,7 +37,10 @@ void QtWidgetInputProcessXMLParameter::DoUpdateGUI()
if (m_XMLParam->HasUserValue())
{
// Update the lineEdit
QString text( m_XMLParam->GetFileName() );
QString text(
QFile::decodeName( m_XMLParam->GetFileName() )
);
if (text != m_Input->text())
m_Input->setText(text);
}
......@@ -90,9 +93,11 @@ void QtWidgetInputProcessXMLParameter::SelectFile()
if (fileDialog.exec())
{
QString name = fileDialog.selectedFiles().at(0);
if( !name.isEmpty() )
{
this->SetFileName(name);
this->SetFileName( name );
m_Input->setText(name);
}
}
......@@ -101,7 +106,8 @@ void QtWidgetInputProcessXMLParameter::SelectFile()
void QtWidgetInputProcessXMLParameter::SetFileName(const QString& value)
{
// load xml file name
if (m_XMLParam->SetFileName(value.toAscii().constData()))
if( m_XMLParam->SetFileName(
QFile::encodeName( value ).constData() ) )
{
// notify of value change
QString key( m_XMLParam->GetKey() );
......
......@@ -48,7 +48,9 @@ void QtWidgetInputVectorDataListParameter::DoUpdateGUI()
std::vector<std::string>::iterator it;
for (it = fileList.begin(); it != fileList.end(); ++it)
{
m_FileSelectionList[i++]->GetInput()->setText(QString( (*it).c_str() ));
m_FileSelectionList[i++]->GetInput()->setText(
QFile::decodeName( it->c_str() )
);
}
}
......
......@@ -40,7 +40,10 @@ void QtWidgetInputVectorDataParameter::DoUpdateGUI()
//update lineedit
if(m_InputVectorDataParam->HasUserValue())
{
QString text( m_InputVectorDataParam->GetFileName().c_str() );
QString text(
QFile::decodeName( m_InputVectorDataParam->GetFileName().c_str() )
);
if (text != m_Input->text())
m_Input->setText(text);
}
......@@ -92,7 +95,7 @@ void QtWidgetInputVectorDataParameter::SelectFile()
if (fileDialog.exec())
{
if ( this->SetFileName(fileDialog.selectedFiles().at(0)) == true )
if ( this->SetFileName( fileDialog.selectedFiles().at(0) ) == true )
{
m_Input->setText(fileDialog.selectedFiles().at(0));
}
......@@ -100,7 +103,7 @@ void QtWidgetInputVectorDataParameter::SelectFile()
{
std::ostringstream oss;
oss << "The given file "
<< fileDialog.selectedFiles().at(0).toAscii().constData()
<< QFile::encodeName( fileDialog.selectedFiles().at( 0 ) ).constData()
<< " is not valid.";
this->GetModel()->SendLogWARNING( oss.str() );
}
......@@ -111,7 +114,8 @@ bool QtWidgetInputVectorDataParameter::SetFileName(const QString& value)
{
bool res = true;
// save value
if(m_InputVectorDataParam->SetFromFileName(value.toAscii().constData()) == true)
if( m_InputVectorDataParam->SetFromFileName(
QFile::encodeName( value ).constData() ) == true )
{
// notify of value change
QString key( m_InputVectorDataParam->GetKey() );
......
......@@ -35,7 +35,12 @@ QtWidgetOutputFilenameParameter::~QtWidgetOutputFilenameParameter()
void QtWidgetOutputFilenameParameter::DoUpdateGUI()
{
// Update the lineEdit
QString text( m_FilenameParam->GetValue().c_str() );
QString text(
QFile::decodeName(
m_FilenameParam->GetValue().c_str()
)
);
if (text != m_Input->text())
m_Input->setText(text);
}
......@@ -102,7 +107,8 @@ void QtWidgetOutputFilenameParameter::SelectFile()
if (fileDialog.exec())
{
this->SetFileName(fileDialog.selectedFiles().at(0));
this->SetFileName( fileDialog.selectedFiles().at( 0 ) );
m_Input->setText(fileDialog.selectedFiles().at(0));
}
}
......@@ -110,7 +116,9 @@ void QtWidgetOutputFilenameParameter::SelectFile()
void QtWidgetOutputFilenameParameter::SetFileName(const QString& value)
{
// save value
m_FilenameParam->SetValue(value.toAscii().constData());
m_FilenameParam->SetValue(
QFile::encodeName( value ).constData()
);
// notify of value change
QString key( m_FilenameParam->GetKey() );
......
......@@ -38,7 +38,10 @@ void QtWidgetOutputImageParameter::DoUpdateGUI()
// Update the lineEdit
if (m_Input->text() != m_OutputImageParam->GetFileName())
{
m_Input->setText(m_OutputImageParam->GetFileName());
m_Input->setText(
QFile::decodeName( m_OutputImageParam->GetFileName() )
);
m_ComboBox->setCurrentIndex(m_OutputImageParam->GetPixelType());
}
}
......@@ -113,7 +116,7 @@ void QtWidgetOutputImageParameter::SelectFile()
void QtWidgetOutputImageParameter::SetFileName(const QString& value)
{
// save value
m_FileName = value.toAscii().constData();
m_FileName = QFile::encodeName( value ).constData();
m_OutputImageParam->SetFileName(m_FileName);
......
......@@ -35,7 +35,10 @@ QtWidgetOutputProcessXMLParameter::~QtWidgetOutputProcessXMLParameter()
void QtWidgetOutputProcessXMLParameter::DoUpdateGUI()
{
// Update the lineEdit
QString text( m_XMLParam->GetFileName() );
QString text(
QFile::decodeName( m_XMLParam->GetFileName() )
);
;
if (text != m_Input->text())
m_Input->setText(text);
}
......@@ -87,7 +90,8 @@ void QtWidgetOutputProcessXMLParameter::SelectFile()
if (fileDialog.exec())
{
this->SetFileName(fileDialog.selectedFiles().at(0));
this->SetFileName( fileDialog.selectedFiles().at(0) );
m_Input->setText(fileDialog.selectedFiles().at(0));
}
}
......@@ -95,7 +99,9 @@ void QtWidgetOutputProcessXMLParameter::SelectFile()
void QtWidgetOutputProcessXMLParameter::SetFileName(const QString& value)
{
// save xml file name
m_XMLParam->SetValue(value.toAscii().constData());
m_XMLParam->SetValue(
QFile::encodeName( value ).constData()
);
// notify of value change
QString key( m_XMLParam->GetKey() );
......
......@@ -94,7 +94,7 @@ void QtWidgetOutputVectorDataParameter::SelectFile()
void QtWidgetOutputVectorDataParameter::SetFileName(const QString& value)
{
// save value
m_FileName = value.toAscii().constData();
m_FileName = QFile::encodeName( value ).constData();
m_OutputVectorDataParam->SetFileName(m_FileName);
......
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