QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Slots | Public Member Functions | Private Member Functions | Private Attributes | List of all members
QgsQueryBuilder Class Reference

Query Builder for layers. More...

#include <qgsquerybuilder.h>

Inheritance diagram for QgsQueryBuilder:
Inheritance graph
Collaboration diagram for QgsQueryBuilder:
Collaboration graph

Public Slots

void accept ()
void reject ()
void clear ()
void on_btnEqual_clicked ()
void on_btnLessThan_clicked ()
void on_btnGreaterThan_clicked ()
void on_btnPct_clicked ()
void on_btnIn_clicked ()
void on_btnNotIn_clicked ()
void on_btnLike_clicked ()
void on_btnILike_clicked ()
QString sql ()
void setSql (QString sqlStatement)
void on_lstFields_clicked (const QModelIndex &index)
void on_lstFields_doubleClicked (const QModelIndex &index)
void on_lstValues_doubleClicked (const QModelIndex &index)
void on_btnLessEqual_clicked ()
void on_btnGreaterEqual_clicked ()
void on_btnNotEqual_clicked ()
void on_btnAnd_clicked ()
void on_btnNot_clicked ()
void on_btnOr_clicked ()
void on_buttonBox_helpRequested ()
void test ()
void on_btnGetAllValues_clicked ()
void on_btnSampleValues_clicked ()
void setDatasourceDescription (QString uri)

Public Member Functions

 QgsQueryBuilder (QgsVectorLayer *layer, QWidget *parent=0, Qt::WindowFlags fl=QgisGui::ModalDialogFlags)
 ~QgsQueryBuilder ()
void showEvent (QShowEvent *event)

Private Member Functions

void populateFields ()
void setupGuiViews ()
void setupLstFieldsModel ()
void fillValues (int idx, int limit)

Private Attributes

QStandardItemModel * mModelFields
 Model for fields ListView. More...
QStandardItemModel * mModelValues
 Model for values ListView. More...
int mPreviousFieldRow
 Previous field row to delete model. More...
 vector layer More...
QString mOrigSubsetString
 original subset string More...

Detailed Description

Query Builder for layers.

The query builder allows interactive creation of a SQL for limiting the features displayed in a database layer. The fields in the table are displayed and sample values (or all values) can be viewed to aid in constructing the query. A test function returns the number of features that will be returned.

Definition at line 40 of file qgsquerybuilder.h.

Constructor & Destructor Documentation

QgsQueryBuilder::QgsQueryBuilder ( QgsVectorLayer layer,
QWidget *  parent = 0,
Qt::WindowFlags  fl = QgisGui::ModalDialogFlags 

This constructor is used when the query builder is called from the vector layer properties dialog

layerexisting vector layer
parentParent widget
fldialog flags

Definition at line 27 of file qgsquerybuilder.cpp.

References clear(), mLayer, mOrigSubsetString, QgsMapLayer::name(), populateFields(), setupGuiViews(), QgsVectorLayer::subsetString(), test(), and tr.

QgsQueryBuilder::~QgsQueryBuilder ( )

Definition at line 58 of file qgsquerybuilder.cpp.

Member Function Documentation

void QgsQueryBuilder::accept ( )
void QgsQueryBuilder::clear ( )

Definition at line 378 of file qgsquerybuilder.cpp.

References mLayer, and QgsVectorLayer::setSubsetString().

Referenced by QgsQueryBuilder().

void QgsQueryBuilder::fillValues ( int  idx,
int  limit 
void QgsQueryBuilder::on_btnAnd_clicked ( )

Definition at line 360 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnEqual_clicked ( )

Definition at line 256 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnGetAllValues_clicked ( )

Get all distinct values for the field. Values are inserted into the value list box

Definition at line 167 of file qgsquerybuilder.cpp.

References fillValues(), mLayer, mModelFields, mModelValues, QgsVectorLayer::setSubsetString(), and QgsVectorLayer::subsetString().

void QgsQueryBuilder::on_btnGreaterEqual_clicked ( )

Definition at line 348 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnGreaterThan_clicked ( )

Definition at line 268 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnILike_clicked ( )

Definition at line 385 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnIn_clicked ( )

Definition at line 280 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnLessEqual_clicked ( )

Definition at line 342 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnLessThan_clicked ( )

Definition at line 262 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnLike_clicked ( )

Definition at line 292 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnNot_clicked ( )

Definition at line 366 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnNotEqual_clicked ( )

Definition at line 354 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnNotIn_clicked ( )

Definition at line 286 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnOr_clicked ( )

Definition at line 372 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnPct_clicked ( )

Definition at line 274 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::on_btnSampleValues_clicked ( )

Get sample distinct values for the selected field. The sample size is limited to an arbitrary value (currently set to 25). The values are inserted into the values list box.

Definition at line 140 of file qgsquerybuilder.cpp.

References fillValues(), mLayer, mModelFields, mModelValues, QgsVectorLayer::setSubsetString(), and QgsVectorLayer::subsetString().

void QgsQueryBuilder::on_buttonBox_helpRequested ( )

Definition at line 81 of file qgsquerybuilder.h.

References QgsContextHelp::run().

void QgsQueryBuilder::on_lstFields_clicked ( const QModelIndex &  index)

Definition at line 308 of file qgsquerybuilder.cpp.

References mModelValues, and mPreviousFieldRow.

void QgsQueryBuilder::on_lstFields_doubleClicked ( const QModelIndex &  index)

Definition at line 321 of file qgsquerybuilder.cpp.

References mLayer, mModelFields, and QgsVectorLayer::pendingFields().

void QgsQueryBuilder::on_lstValues_doubleClicked ( const QModelIndex &  index)
void QgsQueryBuilder::populateFields ( )

Populate the field list for the selected table

Definition at line 70 of file qgsquerybuilder.cpp.

References QgsFields::count(), mLayer, mModelFields, QgsVectorLayer::pendingFields(), and setupLstFieldsModel().

Referenced by QgsQueryBuilder().

void QgsQueryBuilder::reject ( )
void QgsQueryBuilder::setDatasourceDescription ( QString  uri)

Definition at line 391 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::setSql ( QString  sqlStatement)

Definition at line 303 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::setupGuiViews ( )

Setup models for listviews

Definition at line 90 of file qgsquerybuilder.cpp.

References mModelFields, and mModelValues.

Referenced by QgsQueryBuilder().

void QgsQueryBuilder::setupLstFieldsModel ( )

Definition at line 85 of file qgsquerybuilder.cpp.

References mModelFields.

Referenced by populateFields().

void QgsQueryBuilder::showEvent ( QShowEvent *  event)

Definition at line 64 of file qgsquerybuilder.cpp.

QString QgsQueryBuilder::sql ( )

Definition at line 298 of file qgsquerybuilder.cpp.

void QgsQueryBuilder::test ( )

Test the constructed sql statement to see if the database likes it. The number of rows that would be returned is displayed in a message box. The test uses a "select count(*) from ..." query to test the SQL statement.

Definition at line 194 of file qgsquerybuilder.cpp.

References QgsVectorDataProvider::clearErrors(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::errors(), QgsVectorLayer::featureCount(), QgsVectorDataProvider::hasErrors(), mLayer, QgsVectorLayer::setSubsetString(), QgsVectorLayer::subsetString(), and tr.

Referenced by QgsQueryBuilder().

Member Data Documentation

QgsVectorLayer* QgsQueryBuilder::mLayer
QStandardItemModel* QgsQueryBuilder::mModelFields
QStandardItemModel* QgsQueryBuilder::mModelValues
QString QgsQueryBuilder::mOrigSubsetString

original subset string

Definition at line 128 of file qgsquerybuilder.h.

Referenced by QgsQueryBuilder(), and reject().

int QgsQueryBuilder::mPreviousFieldRow

Previous field row to delete model.

Definition at line 122 of file qgsquerybuilder.h.

Referenced by on_lstFields_clicked().

The documentation for this class was generated from the following files: