Skip to content

Commit 3cea699

Browse files
committed
fix #4259
1 parent f432e83 commit 3cea699

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

src/plugins/grass/qgsgrassmodule.cpp

+29-6
Original file line numberDiff line numberDiff line change
@@ -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+
31273150
QgsGrassModuleGdalInput::~QgsGrassModuleGdalInput()
31283151
{
31293152
}

src/plugins/grass/qgsgrassmodule.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ class QgsGrassModuleInput: public QgsGrassModuleGroupBoxItem
621621
void changed( int );
622622

623623
signals:
624-
// emited when value changed/selected
624+
// emitted when value changed/selected
625625
void valueChanged();
626626

627627
private:
@@ -708,6 +708,8 @@ class QgsGrassModuleGdalInput: public QgsGrassModuleGroupBoxItem
708708
//! Fill combobox with currently available maps in QGIS canvas
709709
void updateQgisLayers();
710710

711+
void changed( int );
712+
711713
private:
712714
//! Input type
713715
int mType;
@@ -721,6 +723,9 @@ class QgsGrassModuleGdalInput: public QgsGrassModuleGroupBoxItem
721723
//! Combobox for QGIS layers
722724
QComboBox *mLayerComboBox;
723725

726+
//! Lineedit for postgres password
727+
QLineEdit *mLayerPassword;
728+
724729
//! Vector of URI in the combobox
725730
QStringList mUri;
726731

0 commit comments

Comments
 (0)