#include #include #include // ------------------------------------------------------------------------- cpBaseQtApplication::PathsDialog:: PathsDialog( QWidget* parent, Qt::WindowFlags flags ) : QDialog( parent, flags ), m_UI( new Ui::PathsDialog ) { this->m_UI->setupUi( this ); this->connect( this->m_UI->AddButton, SIGNAL( clicked( ) ), this, SLOT( _addPath( ) ) ); this->connect( this->m_UI->RemoveButton, SIGNAL( clicked( ) ), this, SLOT( _removePath( ) ) ); } // ------------------------------------------------------------------------- cpBaseQtApplication::PathsDialog:: ~PathsDialog( ) { delete this->m_UI; } // ------------------------------------------------------------------------- void cpBaseQtApplication::PathsDialog:: addPaths( const std::set< std::string >& paths ) { QStringList lst; for( auto i = paths.begin( ); i != paths.end( ); ++i ) lst << i->c_str( ); this->m_UI->Paths->addItems( lst ); } // ------------------------------------------------------------------------- std::set< std::string > cpBaseQtApplication::PathsDialog:: getPaths( ) const { std::set< std::string > paths; for( int c = 0; c < this->m_UI->Paths->count( ); ++c ) paths.insert( this->m_UI->Paths->item( c )->text( ).toStdString( ) ); return( paths ); } // ------------------------------------------------------------------------- void cpBaseQtApplication::PathsDialog:: _addPath( ) { auto res = QFileDialog::getExistingDirectory( this, "Choose a directory", "." ); if( res.toStdString( ) != "" ) this->m_UI->Paths->addItem( res ); } // ------------------------------------------------------------------------- void cpBaseQtApplication::PathsDialog:: _removePath( ) { /* TODO auto items = this->m_UI->Paths->selectedItems( ); if( items.size( ) == 1 ) this->m_UI->Paths->removeItemWidget( items[ 0 ] ); */ } // eof - $RCSfile$