Skip to content
Permalink
Browse files

implement #3337

  • Loading branch information
jef-n committed Jun 30, 2012
1 parent 40dc7df commit d79c2963d3b72b276a15f211f635b3438678f077
Showing with 41 additions and 2 deletions.
  1. +31 −2 src/gui/qgsquerybuilder.cpp
  2. +10 −0 src/ui/qgsquerybuilderbase.ui
@@ -47,6 +47,8 @@ QgsQueryBuilder::QgsQueryBuilder( QgsVectorLayer *layer,

mOrigSubsetString = layer->subsetString();

mUseUnfilteredLayer->setDisabled( mLayer->subsetString().isEmpty() );

lblDataUri->setText( layer->name() );
txtSQL->setText( mOrigSubsetString );

@@ -124,31 +126,54 @@ void QgsQueryBuilder::on_btnSampleValues_clicked()
{
lstValues->setCursor( Qt::WaitCursor );

QString prevSubsetString = mLayer->subsetString();
if ( mUseUnfilteredLayer->isChecked() && !prevSubsetString.isEmpty() )
{
mLayer->setSubsetString( "" );
}

//delete connection mModelValues and lstValues
QStandardItemModel *tmp = new QStandardItemModel();
lstValues->setModel( tmp );
//Clear and fill the mModelValues
fillValues( mModelFields->data( lstFields->currentIndex(), Qt::UserRole + 1 ).toInt(), 25 );
lstValues->setModel( mModelValues );
lstValues->setCursor( Qt::ArrowCursor );
//delete the tmp
delete tmp;

if ( prevSubsetString != mLayer->subsetString() )
{
mLayer->setSubsetString( prevSubsetString );
}

lstValues->setCursor( Qt::ArrowCursor );
}

void QgsQueryBuilder::on_btnGetAllValues_clicked()
{
lstValues->setCursor( Qt::WaitCursor );

QString prevSubsetString = mLayer->subsetString();
if ( mUseUnfilteredLayer->isChecked() && !prevSubsetString.isEmpty() )
{
mLayer->setSubsetString( "" );
}

//delete connection mModelValues and lstValues
QStandardItemModel *tmp = new QStandardItemModel();
lstValues->setModel( tmp );
//Clear and fill the mModelValues
fillValues( mModelFields->data( lstFields->currentIndex(), Qt::UserRole + 1 ).toInt(), -1 );
lstValues->setModel( mModelValues );
lstValues->setCursor( Qt::ArrowCursor );
//delete the tmp
delete tmp;

if ( prevSubsetString != mLayer->subsetString() )
{
mLayer->setSubsetString( prevSubsetString );
}

lstValues->setCursor( Qt::ArrowCursor );
}

void QgsQueryBuilder::test()
@@ -159,6 +184,8 @@ void QgsQueryBuilder::test()

if ( mLayer->setSubsetString( txtSQL->toPlainText() ) )
{
mUseUnfilteredLayer->setDisabled( mLayer->subsetString().isEmpty() );

QMessageBox::information( this,
tr( "Query Result" ),
tr( "The where clause returned %n row(s).", "returned test rows", mLayer->featureCount() ) );
@@ -319,12 +346,14 @@ void QgsQueryBuilder::clear()
{
txtSQL->clear();
mLayer->setSubsetString( "" );
mUseUnfilteredLayer->setDisabled( true );
}

void QgsQueryBuilder::on_btnILike_clicked()
{
txtSQL->insertPlainText( " ILIKE " );
}

void QgsQueryBuilder::setDatasourceDescription( QString uri )
{
lblDataUri->setText( uri );
@@ -125,6 +125,16 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="mUseUnfilteredLayer">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Use unfiltered layer</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

0 comments on commit d79c296

Please sign in to comment.
You can’t perform that action at this time.