QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsexpressionlineedit.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsexpressionlineedit.h
3 ----------------------
4 Date : 18.08.2016
5 Copyright : (C) 2016 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7***************************************************************************
8* *
9* This program is free software; you can redistribute it and/or modify *
10* it under the terms of the GNU General Public License as published by *
11* the Free Software Foundation; either version 2 of the License, or *
12* (at your option) any later version. *
13* *
14***************************************************************************/
15
16#ifndef QGSEXPRESSIONLINEEDIT_H
17#define QGSEXPRESSIONLINEEDIT_H
18
19#include <memory>
20
21#include "qgis_gui.h"
22#include "qgis_sip.h"
24
25#include <QWidget>
26
28class QToolButton;
29class QgsDistanceArea;
32
49class GUI_EXPORT QgsExpressionLineEdit : public QWidget
50{
51 Q_OBJECT
52
53 public:
54
59 explicit QgsExpressionLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
61
67 void setExpressionDialogTitle( const QString &title );
68
73 QString expressionDialogTitle() const { return mExpressionDialogTitle; }
74
80 void setMultiLine( bool multiLine );
81
89 QString expectedOutputFormat() const;
90
97 void setExpectedOutputFormat( const QString &expected );
98
103 void setGeomCalculator( const QgsDistanceArea &distanceArea );
104
113 void setLayer( QgsVectorLayer *layer );
114
119 QString expression() const;
120
126 bool isValidExpression( QString *expressionError SIP_OUT = nullptr ) const;
127
134 void registerExpressionContextGenerator( const QgsExpressionContextGenerator *generator );
135
136 signals:
137
142 void expressionChanged( const QString &expression );
143
144 public slots:
145
151 void setExpression( const QString &expression );
152
153 protected:
154 void changeEvent( QEvent *event ) override;
155
156 private slots:
157
159 void expressionEdited( const QString &expression );
160 void expressionEdited();
161
163 void editExpression();
164
170 void updateLineEditStyle( const QString &expression = QString() );
171
172 private:
173 QgsFilterLineEdit *mLineEdit = nullptr;
174 QgsCodeEditorExpression *mCodeEditor = nullptr;
175 QToolButton *mButton = nullptr;
176 QString mExpressionDialogTitle;
177 std::unique_ptr<QgsDistanceArea> mDa;
178 QgsExpressionContext mExpressionContext;
179 const QgsExpressionContextGenerator *mExpressionContextGenerator = nullptr;
180 QgsVectorLayer *mLayer = nullptr;
181 QString mExpectedOutputFormat;
182
183 bool isExpressionValid( const QString &expressionStr );
184
186};
187
188#endif // QGSEXPRESSIONLINEEDIT_H
A QGIS expression editor based on QScintilla2.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Abstract interface for generating an expression context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QString expression() const
Returns the current expression shown in the widget.
friend class TestQgsFieldExpressionWidget
QString expressionDialogTitle() const
Returns the title used for the expression dialog.
void changeEvent(QEvent *event) override
~QgsExpressionLineEdit() override
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
void setExpressionDialogTitle(const QString &title)
Sets the title used in the expression builder dialog.
void setExpression(const QString &expression)
Sets the current expression to show in the widget.
QgsExpressionLineEdit(QWidget *parent=nullptr)
Constructor for QgsExpressionLineEdit.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_OUT
Definition qgis_sip.h:58