Skip to content

Commit 2161c86

Browse files
committed
expression builder: fix typos and warnings and follow selection (not just clicked)
1 parent a3452a5 commit 2161c86

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

src/app/qgsfieldcalculator.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,7 @@ void QgsFieldCalculator::populateFields()
269269

270270
void QgsFieldCalculator::setOkButtonState()
271271
{
272-
bool okEnabled = true;
273-
if (( mOutputFieldNameLineEdit->text().isEmpty()
274-
&& !mUpdateExistingGroupBox->isChecked()
275-
|| !builder->isExpressionVaild() ) )
276-
{
277-
okEnabled = false;
278-
}
272+
bool okEnabled = ( !mOutputFieldNameLineEdit->text().isEmpty() || mUpdateExistingGroupBox->isChecked() ) && builder->isExpressionValid();
273+
279274
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( okEnabled );
280275
}

src/app/qgsfieldcalculator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class QgsFieldCalculator: public QDialog, private Ui::QgsFieldCalculatorBase
5959
/**idx of changed attribute*/
6060
int mAttributeId;
6161

62-
bool mExpressionVaild;
62+
bool mExpressionValid;
6363
};
6464

6565
#endif // QGSFIELDCALCULATOR_H

src/gui/qgsexpressionbuilderwidget.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
4141
expressionTree->setModel( mProxyModel );
4242

4343
expressionTree->setContextMenuPolicy( Qt::CustomContextMenu );
44-
connect( this, SIGNAL( expressionParsed( bool ) ), this, SLOT( setExpressionState ) );
44+
connect( this, SIGNAL( expressionParsed( bool ) ), this, SLOT( setExpressionState( bool ) ) );
4545
connect( expressionTree, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( showContextMenu( const QPoint & ) ) );
46+
connect( expressionTree->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
47+
this, SLOT( currentChanged( const QModelIndex &, const QModelIndex & ) ) );
4648

47-
foreach( QPushButton* button, this->mOperatorsGroupBox->findChildren<QPushButton *>() )
49+
foreach( QPushButton* button, mOperatorsGroupBox->findChildren<QPushButton *>() )
4850
{
4951
connect( button, SIGNAL( pressed() ), this, SLOT( operatorButtonClicked() ) );
5052
}
@@ -99,7 +101,7 @@ void QgsExpressionBuilderWidget::setLayer( QgsVectorLayer *layer )
99101
mLayer = layer;
100102
}
101103

102-
void QgsExpressionBuilderWidget::on_expressionTree_clicked( const QModelIndex &index )
104+
void QgsExpressionBuilderWidget::currentChanged( const QModelIndex &index, const QModelIndex & )
103105
{
104106
// Get the item
105107
QModelIndex idx = mProxyModel->mapToSource( index );
@@ -214,9 +216,9 @@ void QgsExpressionBuilderWidget::registerItem( QString group,
214216
}
215217
}
216218

217-
bool QgsExpressionBuilderWidget::isExpressionVaild()
219+
bool QgsExpressionBuilderWidget::isExpressionValid()
218220
{
219-
return mExpressionVaild;
221+
return mExpressionValid;
220222
}
221223

222224
QString QgsExpressionBuilderWidget::getExpressionString()
@@ -370,7 +372,7 @@ void QgsExpressionBuilderWidget::loadAllValues()
370372

371373
void QgsExpressionBuilderWidget::setExpressionState( bool state )
372374
{
373-
mExpressionVaild = state;
375+
mExpressionValid = state;
374376
}
375377

376378
QString QgsExpressionBuilderWidget::loadFunctionHelp( QgsExpressionItem* functionName )

src/gui/qgsexpressionbuilderwidget.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
140140
QString helpText = "",
141141
QgsExpressionItem::ItemType type = QgsExpressionItem::ExpressionNode );
142142

143-
bool isExpressionVaild();
143+
bool isExpressionValid();
144144

145145
public slots:
146-
void on_expressionTree_clicked( const QModelIndex &index );
146+
void currentChanged( const QModelIndex &index, const QModelIndex & );
147147
void on_expressionTree_doubleClicked( const QModelIndex &index );
148148
void on_txtExpressionString_textChanged();
149149
void on_txtSearchEdit_textChanged();
@@ -175,7 +175,7 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
175175
QMap<QString, QgsExpressionItem*> mExpressionGroups;
176176
QgsFeature mFeature;
177177
QgsExpressionHighlighter* highlighter;
178-
bool mExpressionVaild;
178+
bool mExpressionValid;
179179
};
180180

181181
#endif // QGSEXPRESSIONBUILDER_H

src/ui/qgsfieldcalculatorbase.ui

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156
<bool>false</bool>
157157
</property>
158158
<zorder>mButtonBox</zorder>
159-
<zorder>mButtonBox</zorder>
160159
</widget>
161160
</item>
162161
<item row="3" column="0" colspan="2">

0 commit comments

Comments
 (0)