/usr/include/qgis/qgsexpressionlineedit.h is in libqgis-dev 2.18.17+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | /***************************************************************************
qgsexpressionlineedit.h
----------------------
Date : 18.08.2016
Copyright : (C) 2016 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSEXPRESSIONLINEEDIT_H
#define QGSEXPRESSIONLINEEDIT_H
#include <QWidget>
#include "qgsexpressioncontext.h"
#include "qgsdistancearea.h"
class QgsFilterLineEdit;
class QToolButton;
class QgsDistanceArea;
class QgsExpressionContextGenerator;
class QgsCodeEditorSQL;
/** \ingroup gui
* @class QgsExpressionLineEdit
* @brief The QgsExpressionLineEdit widget includes a line edit for entering expressions
* together with a button to open the expression creation dialog.
*
* This widget is designed for use in contexts where no layer fields are available for
* use in an expression. In contexts where the expression is directly associated with
* a layer and fields can be used, then QgsFieldExpressionWidget is a more appropriate
* choice as it gives users direct access to select fields from a drop down list.
*
* QgsExpressionLineEdit also supports a multiline editor mode which is useful where
* more space is available for the widget, but where QgsExpressionBuilderWidget
* is too complex or large for use.
*
* @note added in QGIS 2.18
*/
class GUI_EXPORT QgsExpressionLineEdit : public QWidget
{
Q_OBJECT
public:
/**
* Constructor for QgsExpressionLineEdit.
* @param parent parent widget
*/
explicit QgsExpressionLineEdit( QWidget *parent = nullptr );
/** Sets the title used in the expression builder dialog
* @param title dialog title
* @see expressionDialogTitle()
*/
void setExpressionDialogTitle( const QString& title );
/** Returns the title used for the expression dialog.
* @see setExpressionDialogTitle()
*/
QString expressionDialogTitle() const { return mExpressionDialogTitle; }
/** Sets whether the widget should show a multiline text editor.
* @param multiLine set to true to show multiline editor, or false
* to show single line editor (the default).
*/
void setMultiLine( bool multiLine );
/** Set the geometry calculator used in the expression dialog.
* @param distanceArea calculator
*/
void setGeomCalculator( const QgsDistanceArea &distanceArea );
/** Sets a layer associated with the widget. Required in order to get the fields and values
* from the layer.
* @param layer vector layer
*/
void setLayer( QgsVectorLayer* layer );
/** Returns the current expression shown in the widget.
* @see setExpression()
*/
QString expression() const;
/**
* Returns true if the current expression is valid.
* @param expressionError will be set to any generated error message if specified
*/
bool isValidExpression( QString *expressionError = nullptr ) const;
signals:
/** Emitted when the expression is changed.
* @param expression new expression
*/
void expressionChanged( const QString& expression );
public slots:
/** Sets the current expression to show in the widget.
* @param expression expression string
* @see expression()
*/
void setExpression( const QString& expression );
protected:
void changeEvent( QEvent* event ) override;
private slots:
//! When the expression is edited by the user in the line edit, it will be checked for validity
void expressionEdited( const QString& expression );
void expressionEdited();
//! Opens the expression editor dialog to edit the current expression or add a new expression
void editExpression();
/**
* @brief updateLineEditStyle will re-style (color/font) the line edit depending on content and status
* @param expression if expression is given it will be evaluated for the given string, otherwise it takes
* current expression from the model
*/
void updateLineEditStyle( const QString& expression = QString() );
private:
QgsFilterLineEdit* mLineEdit;
QgsCodeEditorSQL* mCodeEditor;
QToolButton* mButton;
QString mExpressionDialogTitle;
QScopedPointer<QgsDistanceArea> mDa;
QgsExpressionContext mExpressionContext;
QgsVectorLayer* mLayer;
bool isExpressionValid( const QString& expressionStr );
friend class TestQgsFieldExpressionWidget;
};
#endif // QGSEXPRESSIONLINEEDIT_H
|