QGIS/python/gui/qgsfieldexpressionwidget.sip

80 lines
2.8 KiB
Plaintext
Raw Normal View History

class QgsFieldExpressionWidget : QWidget
{
%TypeHeaderCode
#include "qgsfieldexpressionwidget.h"
%End
public:
/**
* @brief QgsFieldExpressionWidget creates a widget with a combo box to display the fields and expression and a button to open the expression dialog
*/
explicit QgsFieldExpressionWidget( QWidget *parent /TransferThis/ = 0 );
//! define the title used in the expression dialog
void setExpressionDialogTitle( QString title );
2014-05-18 15:22:26 +02:00
//! return the title used for the expression dialog
const QString expressionDialogTitle();
//! setFilters allows fitering according to the type of field
void setFilters( QgsFieldProxyModel::Filters filters );
//! currently used filter on list of fields
QgsFieldProxyModel::Filters filters();
//! set the geometry calculator used in the expression dialog
void setGeomCalculator( const QgsDistanceArea &da );
2014-05-18 15:22:26 +02:00
/**
* @brief currentField returns the currently selected field or expression if allowed
* @param isExpression determines if the string returned is the name of a field or an expression
* @param isValid determines if the expression (or field) returned is valid
*/
QString currentField( bool *isExpression = 0, bool *isValid = 0 );
//! Returns the currently used layer
QgsVectorLayer* layer();
2014-05-18 15:22:26 +02:00
signals:
2014-05-02 10:32:37 +02:00
//! the signal is emitted when the currently selected field changes
void fieldChanged( QString fieldName );
2014-05-02 07:42:00 +02:00
//! fieldChanged signal with indication of the validity of the expression
void fieldChanged( QString fieldName, bool isValid );
public slots:
//! set the layer used to display the fields and expression
2014-05-02 07:42:00 +02:00
void setLayer( QgsVectorLayer* layer );
2014-05-02 10:32:37 +02:00
2014-05-02 07:42:00 +02:00
//! convenience slot to connect QgsMapLayerComboBox layer signal
void setLayer( QgsMapLayer* layer );
//! sets the current field or expression in the widget
2014-05-18 15:22:26 +02:00
void setField( const QString &fieldName );
2014-05-27 23:22:50 +02:00
protected slots:
//! open the expression dialog to edit the current or add a new expression
void editExpression();
//! when expression is edited by the user in the line edit, it will be checked for validity
void expressionEdited( const QString expression );
//! when expression has been edited (finished) it will be added to the model
void expressionEditingFinished();
void currentFieldChanged();
2014-05-27 23:22:50 +02:00
/**
* @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() );
bool isExpressionValid( const QString expressionStr );
protected:
void changeEvent( QEvent* event );
};