27
27
// connection to the database
28
28
QgsQueryBuilder::QgsQueryBuilder ( QgsVectorLayer *layer,
29
29
QWidget *parent, Qt::WFlags fl )
30
- : QDialog( parent, fl ), mLayer( layer )
30
+ : QDialog( parent, fl )
31
+ , mLayer( layer )
31
32
{
32
33
setupUi ( this );
33
- connect ( buttonBox, SIGNAL ( helpRequested () ), this , SLOT ( helpClicked () ) );
34
34
35
35
QPushButton *pbn = new QPushButton ( tr ( " &Test" ) );
36
36
buttonBox->addButton ( pbn, QDialogButtonBox::ActionRole );
@@ -91,17 +91,11 @@ void QgsQueryBuilder::setupGuiViews()
91
91
lstValues->setAlternatingRowColors ( true );
92
92
}
93
93
94
- void QgsQueryBuilder::fillValues ( int idx, QString subsetString, int limit )
94
+ void QgsQueryBuilder::fillValues ( int idx, int limit )
95
95
{
96
96
// clear the model
97
97
mModelValues ->clear ();
98
98
99
- if ( !mLayer ->setSubsetString ( subsetString ) )
100
- {
101
- QMessageBox::information ( this , tr ( " Invalid Query" ), tr ( " Setting the query failed" ) );
102
- return ;
103
- }
104
-
105
99
// determine the field type
106
100
QList<QVariant> values;
107
101
mLayer ->dataProvider ()->uniqueValues ( idx, values, limit );
@@ -122,7 +116,7 @@ void QgsQueryBuilder::on_btnSampleValues_clicked()
122
116
QStandardItemModel *tmp = new QStandardItemModel ();
123
117
lstValues->setModel ( tmp );
124
118
// Clear and fill the mModelValues
125
- fillValues ( mModelFields ->data ( lstFields->currentIndex (), Qt::UserRole + 1 ).toInt (), mOrigSubsetString , 25 );
119
+ fillValues ( mModelFields ->data ( lstFields->currentIndex (), Qt::UserRole + 1 ).toInt (), 25 );
126
120
lstValues->setModel ( mModelValues );
127
121
lstValues->setCursor ( Qt::ArrowCursor );
128
122
// delete the tmp
@@ -138,7 +132,7 @@ void QgsQueryBuilder::on_btnGetAllValues_clicked()
138
132
QStandardItemModel *tmp = new QStandardItemModel ();
139
133
lstValues->setModel ( tmp );
140
134
// Clear and fill the mModelValues
141
- fillValues ( mModelFields ->data ( lstFields->currentIndex (), Qt::UserRole + 1 ).toInt (), mOrigSubsetString , -1 );
135
+ fillValues ( mModelFields ->data ( lstFields->currentIndex (), Qt::UserRole + 1 ).toInt (), -1 );
142
136
lstValues->setModel ( mModelValues );
143
137
lstValues->setCursor ( Qt::ArrowCursor );
144
138
// delete the tmp
@@ -151,14 +145,7 @@ void QgsQueryBuilder::test()
151
145
// by counting the number of records that would be
152
146
// returned
153
147
154
- // if there is no sql, issue a warning
155
- if ( txtSQL->toPlainText ().isEmpty () )
156
- {
157
- QMessageBox::information ( this ,
158
- tr ( " No Query" ),
159
- tr ( " You must create a query before you can test it" ) );
160
- }
161
- else if ( mLayer ->setSubsetString ( txtSQL->toPlainText () ) )
148
+ if ( mLayer ->setSubsetString ( txtSQL->toPlainText () ) )
162
149
{
163
150
QMessageBox::information ( this ,
164
151
tr ( " Query Result" ),
@@ -172,12 +159,6 @@ void QgsQueryBuilder::test()
172
159
}
173
160
}
174
161
175
- // Slot for showing help
176
- void QgsQueryBuilder::helpClicked ()
177
- {
178
- // QgsContextHelp::run( context_id );
179
- }
180
-
181
162
void QgsQueryBuilder::accept ()
182
163
{
183
164
// if user hits Ok and there is no query, skip the validation
0 commit comments