Skip to content
Permalink
Browse files
fix #4259
  • Loading branch information
jef-n committed Feb 19, 2012
1 parent f432e83 commit 3cea699a7ebc2c4ae232b138727c03d5cbafd9fd
Showing with 35 additions and 7 deletions.
  1. +29 −6 src/plugins/grass/qgsgrassmodule.cpp
  2. +6 −1 src/plugins/grass/qgsgrassmodule.h
@@ -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" );
@@ -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()) );
@@ -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 )
@@ -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()
{
}
@@ -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:
@@ -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;
@@ -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;

0 comments on commit 3cea699

Please sign in to comment.