mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Wire up operator buttons
This commit is contained in:
parent
0359e5b417
commit
5797360c6b
@ -35,7 +35,17 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget(QWidget *parent)
|
||||
|
||||
expressionTree->setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
connect( expressionTree, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( showContextMenu( const QPoint & ) ) );
|
||||
connect( btnPlusPushButton, SIGNAL(pressed()), this, SLOT(operatorButtonClicked()));
|
||||
connect( btnMinusPushButton, SIGNAL(pressed()), this, SLOT(operatorButtonClicked()));
|
||||
connect( btnDividePushButton, SIGNAL(pressed()), this, SLOT(operatorButtonClicked()));
|
||||
connect( btnMultiplyPushButton, SIGNAL(pressed()), this, SLOT(operatorButtonClicked()));
|
||||
connect( btnExpButton, SIGNAL(pressed()), this, SLOT(operatorButtonClicked()));
|
||||
connect( btnConcatButton, SIGNAL(pressed()), this, SLOT(operatorButtonClicked()));
|
||||
connect( btnOpenBracketPushButton, SIGNAL(pressed()), this, SLOT(operatorButtonClicked()));
|
||||
connect( btnCloseBracketPushButton, SIGNAL(pressed()), this, SLOT(operatorButtonClicked()));
|
||||
|
||||
|
||||
// TODO Can we move this stuff to QgsExpression, like the functions?
|
||||
this->registerItem("Operators","+"," + ");
|
||||
this->registerItem("Operators","-"," -");
|
||||
this->registerItem("Operators","*"," * ");
|
||||
@ -184,13 +194,6 @@ void QgsExpressionBuilderWidget::setExpressionString(const QString expressionStr
|
||||
this->txtExpressionString->setPlainText(expressionString);
|
||||
}
|
||||
|
||||
bool QgsExpressionBuilderWidget::hasExpressionError()
|
||||
{
|
||||
QString text = this->txtExpressionString->toPlainText();
|
||||
QgsExpression exp( text );
|
||||
return exp.hasParserError();
|
||||
}
|
||||
|
||||
void QgsExpressionBuilderWidget::on_txtExpressionString_textChanged()
|
||||
{
|
||||
QString text = this->txtExpressionString->toPlainText();
|
||||
@ -261,6 +264,12 @@ void QgsExpressionBuilderWidget::on_lblPreview_linkActivated(QString link)
|
||||
mv->exec();
|
||||
}
|
||||
|
||||
void QgsExpressionBuilderWidget::operatorButtonClicked()
|
||||
{
|
||||
QPushButton* button = dynamic_cast<QPushButton*>( sender() );
|
||||
txtExpressionString->insertPlainText( " " + button->text() + " " );
|
||||
}
|
||||
|
||||
void QgsExpressionBuilderWidget::showContextMenu( const QPoint & pt)
|
||||
{
|
||||
QModelIndex idx = expressionTree->indexAt( pt );
|
||||
|
@ -130,23 +130,23 @@ public:
|
||||
QString helpText = "",
|
||||
QgsExpressionItem::ItemType type = QgsExpressionItem::ExpressionNode);
|
||||
|
||||
/** Does the expression used in the widget have any errors
|
||||
* @note Users of this widget can check this to see if they should let the
|
||||
* user move forward.
|
||||
*/
|
||||
bool hasExpressionError();
|
||||
|
||||
public slots:
|
||||
void on_expressionTree_clicked(const QModelIndex &index);
|
||||
void on_expressionTree_doubleClicked(const QModelIndex &index);
|
||||
void on_txtExpressionString_textChanged();
|
||||
void on_txtSearchEdit_textChanged();
|
||||
void on_lblPreview_linkActivated(QString link);
|
||||
void operatorButtonClicked();
|
||||
void showContextMenu( const QPoint & );
|
||||
void loadSampleValues();
|
||||
void loadAllValues();
|
||||
|
||||
signals:
|
||||
/** Emited when the user changes the expression in the widget.
|
||||
* Users of this widget should connect to this signal to decide if to let the user
|
||||
* continue.
|
||||
* @param isVaild Is true if the expression the user has typed is vaild.
|
||||
*/
|
||||
void expressionParsed(bool isVaild);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user