X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FQT%2FOpenFileDialog.cxx;fp=lib%2FcpPlugins%2FQT%2FOpenFileDialog.cxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=784d1113c542347e0fb5faeba475f076dce5aa34;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpPlugins/QT/OpenFileDialog.cxx b/lib/cpPlugins/QT/OpenFileDialog.cxx deleted file mode 100644 index 784d111..0000000 --- a/lib/cpPlugins/QT/OpenFileDialog.cxx +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include - -// ------------------------------------------------------------------------- -cpPlugins::QT::OpenFileDialog:: -OpenFileDialog( QWidget* parent ) - : QFileDialog( parent ), - m_Parameters( NULL ), - m_Name( "" ) -{ - this->connect( - this, SIGNAL( accepted( ) ), this, SLOT( _dlg_Accepted( ) ) - ); - this->setWindowTitle( "Open an(some) file(s)" ); -} - -// ------------------------------------------------------------------------- -cpPlugins::QT::OpenFileDialog:: -~OpenFileDialog( ) -{ -} - -// ------------------------------------------------------------------------- -void cpPlugins::QT::OpenFileDialog:: -SetParameters( - cpPlugins::Pipeline::Parameters* params, const std::string& name - ) -{ - if( params == NULL ) - { - this->m_Parameters = NULL; - this->m_Name = ""; - return; - - } // fi - auto param_type = params->GetType( name ); - if( - param_type != cpPlugins::Pipeline::Parameters::OpenFileName && - param_type != cpPlugins::Pipeline::Parameters::OpenFileNameList - ) - { - this->m_Parameters = NULL; - this->m_Name = ""; - return; - - } // fi - this->m_Parameters = params; - this->m_Name = name; - - QStringList filters; - auto extensions = this->m_Parameters->GetAcceptedFileExtensions( name ); - if( extensions != "" ) - filters << extensions.c_str( ); - filters << "Any file (*)"; - if( param_type == cpPlugins::Pipeline::Parameters::OpenFileName ) - this->setFileMode( QFileDialog::ExistingFile ); - else - this->setFileMode( QFileDialog::ExistingFiles ); - this->setNameFilters( filters ); - this->setAcceptMode( QFileDialog::AcceptOpen ); - if( param_type == cpPlugins::Pipeline::Parameters::OpenFileName ) - { - auto file = this->m_Parameters->GetOpenFileName( this->m_Name ); - if( file == "" ) - file = "."; - QFileInfo info( file.c_str( ) ); - this->setDirectory( info.canonicalPath( ) ); - } - else - { - auto files = this->m_Parameters->GetOpenFileNameList( this->m_Name ); - if( files.size( ) > 0 ) - { - QFileInfo info( files[ 0 ].c_str( ) ); - this->setDirectory( info.canonicalPath( ) ); - } - else - this->setDirectory( "." ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpPlugins::QT::OpenFileDialog:: -_dlg_Accepted( ) -{ - if( this->m_Parameters != NULL ) - { - auto files = this->selectedFiles( ); - auto param_type = this->m_Parameters->GetType( this->m_Name ); - if( param_type == cpPlugins::Pipeline::Parameters::OpenFileNameList ) - { - this->m_Parameters->ClearOpenFileNameList( this->m_Name ); - for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt ) - this->m_Parameters->AddToOpenFileNameList( - this->m_Name, fIt->toStdString( ) - ); - } - else - this->m_Parameters->SetOpenFileName( - this->m_Name, files[ 0 ].toStdString( ) - ); - - } // fi -} - -// eof - $RCSfile$