@@ -2363,8 +2363,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
23632363
23642364 QHBoxLayout *l = new QHBoxLayout ( this );
23652365 mLayerComboBox = new QComboBox ();
2366- mLayerComboBox ->setSizePolicy ( QSizePolicy::Expanding,
2367- QSizePolicy:: Preferred );
2366+ mLayerComboBox ->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy:: Preferred );
23682367 l->addWidget ( mLayerComboBox );
23692368
23702369 QString region = qdesc.attribute ( " region" );
@@ -2917,12 +2916,23 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput(
29172916 }
29182917 }
29192918
2920- QHBoxLayout *l = new QHBoxLayout ( this );
2919+ QVBoxLayout *l = new QVBoxLayout ( this );
29212920 mLayerComboBox = new QComboBox ();
2922- mLayerComboBox ->setSizePolicy ( QSizePolicy::Expanding,
2923- QSizePolicy:: Preferred );
2921+ mLayerComboBox ->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy:: Preferred );
29242922 l->addWidget ( mLayerComboBox );
29252923
2924+ QLabel *lbl = new QLabel ( tr ( " Password" ) );
2925+ l->addWidget ( lbl );
2926+
2927+ mLayerPassword = new QLineEdit ();
2928+ mLayerPassword ->setEchoMode ( QLineEdit::Password );
2929+ mLayerPassword ->setEnabled ( false );
2930+ l->addWidget ( mLayerPassword );
2931+
2932+ lbl->setBuddy ( mLayerPassword );
2933+
2934+ connect ( mLayerComboBox , SIGNAL ( activated ( int ) ), this , SLOT ( changed ( int ) ) );
2935+
29262936 // Of course, activated(int) is not enough, but there is no signal
29272937 // BEFORE the cobo is opened
29282938 // connect ( mLayerComboBox, SIGNAL( activated(int) ), this, SLOT(updateQgisLayers()) );
@@ -3069,8 +3079,16 @@ QStringList QgsGrassModuleGdalInput::options()
30693079
30703080 if ( current >= 0 && current < mUri .size () )
30713081 {
3072- opt.append ( mUri [current] );
3082+ QString uri = mUri [current];
3083+
3084+ if ( uri.startsWith ( " PG:" ) && uri.contains ( " password=" ) && !mLayerPassword ->text ().isEmpty () )
3085+ {
3086+ uri += " password=" + mLayerPassword ->text ();
3087+ }
3088+
3089+ opt.append ( uri );
30733090 }
3091+
30743092 list.push_back ( opt );
30753093
30763094 if ( !mOgrLayerOption .isEmpty () && mOgrLayers [current].size () > 0 )
@@ -3124,6 +3142,11 @@ QString QgsGrassModuleGdalInput::ready()
31243142 return error;
31253143}
31263144
3145+ void QgsGrassModuleGdalInput::changed ( int i )
3146+ {
3147+ mLayerPassword ->setEnabled ( i < mUri .size () && mUri [i].startsWith ( " PG:" ) && !mUri [i].contains ( " password=" ) );
3148+ }
3149+
31273150QgsGrassModuleGdalInput::~QgsGrassModuleGdalInput ()
31283151{
31293152}
0 commit comments