Skip to content

Commit

Permalink
fix #3124
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14386 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Oct 16, 2010
1 parent 2b611d7 commit deffaaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
31 changes: 6 additions & 25 deletions src/app/qgsquerybuilder.cpp
Expand Up @@ -27,10 +27,10 @@
// connection to the database
QgsQueryBuilder::QgsQueryBuilder( QgsVectorLayer *layer,
QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl ), mLayer( layer )
: QDialog( parent, fl )
, mLayer( layer )
{
setupUi( this );
connect( buttonBox, SIGNAL( helpRequested() ), this, SLOT( helpClicked() ) );

QPushButton *pbn = new QPushButton( tr( "&Test" ) );
buttonBox->addButton( pbn, QDialogButtonBox::ActionRole );
Expand Down Expand Up @@ -91,17 +91,11 @@ void QgsQueryBuilder::setupGuiViews()
lstValues->setAlternatingRowColors( true );
}

void QgsQueryBuilder::fillValues( int idx, QString subsetString, int limit )
void QgsQueryBuilder::fillValues( int idx, int limit )
{
// clear the model
mModelValues->clear();

if ( !mLayer->setSubsetString( subsetString ) )
{
QMessageBox::information( this, tr( "Invalid Query" ), tr( "Setting the query failed" ) );
return;
}

// determine the field type
QList<QVariant> values;
mLayer->dataProvider()->uniqueValues( idx, values, limit );
Expand All @@ -122,7 +116,7 @@ void QgsQueryBuilder::on_btnSampleValues_clicked()
QStandardItemModel *tmp = new QStandardItemModel();
lstValues->setModel( tmp );
//Clear and fill the mModelValues
fillValues( mModelFields->data( lstFields->currentIndex(), Qt::UserRole + 1 ).toInt(), mOrigSubsetString, 25 );
fillValues( mModelFields->data( lstFields->currentIndex(), Qt::UserRole + 1 ).toInt(), 25 );
lstValues->setModel( mModelValues );
lstValues->setCursor( Qt::ArrowCursor );
//delete the tmp
Expand All @@ -138,7 +132,7 @@ void QgsQueryBuilder::on_btnGetAllValues_clicked()
QStandardItemModel *tmp = new QStandardItemModel();
lstValues->setModel( tmp );
//Clear and fill the mModelValues
fillValues( mModelFields->data( lstFields->currentIndex(), Qt::UserRole + 1 ).toInt(), mOrigSubsetString, -1 );
fillValues( mModelFields->data( lstFields->currentIndex(), Qt::UserRole + 1 ).toInt(), -1 );
lstValues->setModel( mModelValues );
lstValues->setCursor( Qt::ArrowCursor );
//delete the tmp
Expand All @@ -151,14 +145,7 @@ void QgsQueryBuilder::test()
// by counting the number of records that would be
// returned

// if there is no sql, issue a warning
if ( txtSQL->toPlainText().isEmpty() )
{
QMessageBox::information( this,
tr( "No Query" ),
tr( "You must create a query before you can test it" ) );
}
else if ( mLayer->setSubsetString( txtSQL->toPlainText() ) )
if ( mLayer->setSubsetString( txtSQL->toPlainText() ) )
{
QMessageBox::information( this,
tr( "Query Result" ),
Expand All @@ -172,12 +159,6 @@ void QgsQueryBuilder::test()
}
}

// Slot for showing help
void QgsQueryBuilder::helpClicked()
{
// QgsContextHelp::run( context_id );
}

void QgsQueryBuilder::accept()
{
// if user hits Ok and there is no query, skip the validation
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgsquerybuilder.h
Expand Up @@ -68,7 +68,6 @@ class QgsQueryBuilder : public QDialog, private Ui::QgsQueryBuilderBase
public slots:
void accept();
void reject();
void helpClicked();
void clear();
void on_btnEqual_clicked();
void on_btnLessThan_clicked();
Expand Down Expand Up @@ -124,7 +123,7 @@ class QgsQueryBuilder : public QDialog, private Ui::QgsQueryBuilderBase
*/
void setupGuiViews();
void setupLstFieldsModel();
void fillValues( int idx, QString subsetString, int limit );
void fillValues( int idx, int limit );

// private members
//! Model for fields ListView
Expand Down

0 comments on commit deffaaf

Please sign in to comment.