1 #include <cpPlugins/QT/SaveFileDialog.h>
5 #include <cpPlugins/BaseObjects/Parameters.h>
7 // -------------------------------------------------------------------------
8 cpPlugins::QT::SaveFileDialog::
9 SaveFileDialog( QWidget* parent )
10 : QFileDialog( parent ),
15 this, SIGNAL( accepted( ) ), this, SLOT( _dlg_Accepted( ) )
17 this->setWindowTitle( "Save a file" );
20 // -------------------------------------------------------------------------
21 cpPlugins::QT::SaveFileDialog::
26 // -------------------------------------------------------------------------
27 void cpPlugins::QT::SaveFileDialog::
29 cpPlugins::BaseObjects::Parameters* params, const std::string& name
34 this->m_Parameters = NULL;
39 auto param_type = params->GetType( name );
40 if( param_type != cpPlugins::BaseObjects::Parameters::SaveFileName )
42 this->m_Parameters = NULL;
47 this->m_Parameters = params;
51 auto extensions = this->m_Parameters->GetAcceptedFileExtensions( name );
52 if( extensions != "" )
53 filters << extensions.c_str( );
54 filters << "Any file (*)";
55 this->setFileMode( QFileDialog::AnyFile );
56 this->setNameFilters( filters );
57 this->setAcceptMode( QFileDialog::AcceptOpen );
58 auto file = this->m_Parameters->GetSaveFileName( this->m_Name );
61 QFileInfo info( file.c_str( ) );
62 this->setDirectory( info.canonicalPath( ) );
65 // -------------------------------------------------------------------------
66 void cpPlugins::QT::SaveFileDialog::
69 if( this->m_Parameters != NULL )
71 auto files = this->selectedFiles( );
72 this->m_Parameters->SetSaveFileName(
73 this->m_Name, files[ 0 ].toStdString( )
79 #endif // cpPlugins_QT4