]> Creatis software - cpPlugins.git/blob - lib/cpBaseQtApplication/PathsDialog.cxx
...
[cpPlugins.git] / lib / cpBaseQtApplication / PathsDialog.cxx
1 #include <cpBaseQtApplication/PathsDialog.h>
2
3 #include <cpBaseQtApplication/ui_PathsDialog.h>
4 #include <QFileDialog>
5
6 // -------------------------------------------------------------------------
7 cpBaseQtApplication::PathsDialog::
8 PathsDialog( QWidget* parent, Qt::WindowFlags flags )
9   : QDialog( parent, flags ),
10     m_UI( new Ui::PathsDialog )
11 {
12   this->m_UI->setupUi( this );
13   this->connect(
14     this->m_UI->AddButton, SIGNAL( clicked( ) ),
15     this, SLOT( _addPath( ) )
16     );
17   this->connect(
18     this->m_UI->RemoveButton, SIGNAL( clicked( ) ),
19     this, SLOT( _removePath( ) )
20     );
21 }
22
23 // -------------------------------------------------------------------------
24 cpBaseQtApplication::PathsDialog::
25 ~PathsDialog( )
26 {
27   delete this->m_UI;
28 }
29
30 // -------------------------------------------------------------------------
31 void cpBaseQtApplication::PathsDialog::
32 addPaths( const std::set< std::string >& paths )
33 {
34   QStringList lst;
35   for( auto i = paths.begin( ); i != paths.end( ); ++i )
36     lst << i->c_str( );
37   this->m_UI->Paths->addItems( lst );
38 }
39
40 // -------------------------------------------------------------------------
41 std::set< std::string > cpBaseQtApplication::PathsDialog::
42 getPaths( ) const
43 {
44   std::set< std::string > paths;
45   for( int c = 0; c < this->m_UI->Paths->count( ); ++c )
46     paths.insert( this->m_UI->Paths->item( c )->text( ).toStdString( ) );
47   return( paths );
48 }
49
50 // -------------------------------------------------------------------------
51 void cpBaseQtApplication::PathsDialog::
52 _addPath( )
53 {
54   auto res =
55     QFileDialog::getExistingDirectory( this, "Choose a directory", "." );
56   if( res.toStdString( ) != "" )
57     this->m_UI->Paths->addItem( res );
58 }
59
60 // -------------------------------------------------------------------------
61 void cpBaseQtApplication::PathsDialog::
62 _removePath( )
63 {
64   /* TODO
65      auto items = this->m_UI->Paths->selectedItems( );
66      if( items.size( ) == 1 )
67      this->m_UI->Paths->removeItemWidget( items[ 0 ] );
68   */
69 }
70
71 // eof - $RCSfile$