+++ /dev/null
-#include <cpPlugins/QT/SaveFileDialog.h>
-#include <cpPlugins/Pipeline/Parameters.h>
-
-// -------------------------------------------------------------------------
-cpPlugins::QT::SaveFileDialog::
-SaveFileDialog( QWidget* parent )
- : QFileDialog( parent ),
- m_Parameters( NULL ),
- m_Name( "" )
-{
- this->connect(
- this, SIGNAL( accepted( ) ), this, SLOT( _dlg_Accepted( ) )
- );
- this->setWindowTitle( "Save a file" );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::QT::SaveFileDialog::
-~SaveFileDialog( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::QT::SaveFileDialog::
-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::SaveFileName )
- {
- 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 (*)";
- this->setFileMode( QFileDialog::AnyFile );
- this->setNameFilters( filters );
- this->setAcceptMode( QFileDialog::AcceptOpen );
- auto file = this->m_Parameters->GetSaveFileName( this->m_Name );
- if( file == "" )
- file = ".";
- QFileInfo info( file.c_str( ) );
- this->setDirectory( info.canonicalPath( ) );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::QT::SaveFileDialog::
-_dlg_Accepted( )
-{
- if( this->m_Parameters != NULL )
- {
- auto files = this->selectedFiles( );
- this->m_Parameters->SetSaveFileName(
- this->m_Name, files[ 0 ].toStdString( )
- );
-
- } // fi
-}
-
-// eof - $RCSfile$