Skip to content

Commit

Permalink
fix #4259
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 19, 2012
1 parent f432e83 commit 3cea699
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
35 changes: 29 additions & 6 deletions src/plugins/grass/qgsgrassmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2363,8 +2363,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,

QHBoxLayout *l = new QHBoxLayout( this );
mLayerComboBox = new QComboBox();
mLayerComboBox->setSizePolicy( QSizePolicy::Expanding,
QSizePolicy:: Preferred );
mLayerComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy:: Preferred );
l->addWidget( mLayerComboBox );

QString region = qdesc.attribute( "region" );
Expand Down Expand Up @@ -2917,12 +2916,23 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput(
}
}

QHBoxLayout *l = new QHBoxLayout( this );
QVBoxLayout *l = new QVBoxLayout( this );
mLayerComboBox = new QComboBox();
mLayerComboBox->setSizePolicy( QSizePolicy::Expanding,
QSizePolicy:: Preferred );
mLayerComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy:: Preferred );
l->addWidget( mLayerComboBox );

QLabel *lbl = new QLabel( tr( "Password" ) );
l->addWidget( lbl );

mLayerPassword = new QLineEdit();
mLayerPassword->setEchoMode( QLineEdit::Password );
mLayerPassword->setEnabled( false );
l->addWidget( mLayerPassword );

lbl->setBuddy( mLayerPassword );

connect( mLayerComboBox, SIGNAL( activated( int ) ), this, SLOT( changed( int ) ) );

// Of course, activated(int) is not enough, but there is no signal
// BEFORE the cobo is opened
// connect ( mLayerComboBox, SIGNAL( activated(int) ), this, SLOT(updateQgisLayers()) );
Expand Down Expand Up @@ -3069,8 +3079,16 @@ QStringList QgsGrassModuleGdalInput::options()

if ( current >= 0 && current < mUri.size() )
{
opt.append( mUri[current] );
QString uri = mUri[current];

if ( uri.startsWith( "PG:" ) && uri.contains( "password=" ) && !mLayerPassword->text().isEmpty() )
{
uri += " password=" + mLayerPassword->text();
}

opt.append( uri );
}

list.push_back( opt );

if ( !mOgrLayerOption.isEmpty() && mOgrLayers[current].size() > 0 )
Expand Down Expand Up @@ -3124,6 +3142,11 @@ QString QgsGrassModuleGdalInput::ready()
return error;
}

void QgsGrassModuleGdalInput::changed( int i )
{
mLayerPassword->setEnabled( i < mUri.size() && mUri[i].startsWith( "PG:" ) && !mUri[i].contains( "password=" ) );
}

QgsGrassModuleGdalInput::~QgsGrassModuleGdalInput()
{
}
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/grass/qgsgrassmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class QgsGrassModuleInput: public QgsGrassModuleGroupBoxItem
void changed( int );

signals:
// emited when value changed/selected
// emitted when value changed/selected
void valueChanged();

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

void changed( int );

private:
//! Input type
int mType;
Expand All @@ -721,6 +723,9 @@ class QgsGrassModuleGdalInput: public QgsGrassModuleGroupBoxItem
//! Combobox for QGIS layers
QComboBox *mLayerComboBox;

//! Lineedit for postgres password
QLineEdit *mLayerPassword;

//! Vector of URI in the combobox
QStringList mUri;

Expand Down

0 comments on commit 3cea699

Please sign in to comment.