Skip to content
Permalink
Browse files

fix #3124

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14386 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Oct 16, 2010
1 parent 2b611d7 commit deffaaf50bbbe81bb91ee341784f7a82a3594120
Showing with 7 additions and 27 deletions.
  1. +6 −25 src/app/qgsquerybuilder.cpp
  2. +1 −2 src/app/qgsquerybuilder.h
@@ -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 );
@@ -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 );
@@ -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
@@ -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
@@ -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" ),
@@ -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
@@ -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();
@@ -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

0 comments on commit deffaaf

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