QGIS/python/gui/qgsfilterlineedit.sip

128 lines
4.1 KiB
Plaintext
Raw Normal View History

/** \class QgsFilterLineEdit
* \ingroup gui
* QLineEdit subclass with built in support for clearing the widget's value and
* handling custom null value representations.
*
* When using QgsFilterLineEdit the value(), setValue() and clearValue() methods should be used
* instead of QLineEdit's text(), setText() and clear() methods, and the valueChanged()
* signal should be used instead of textChanged().
**/
class QgsFilterLineEdit : QLineEdit
{
%TypeHeaderCode
#include <qgsfilterlineedit.h>
%End
public:
//! Behaviour when clearing value of widget
enum ClearMode
{
ClearToNull, //!< Reset value to null
ClearToDefault, //!< Reset value to default value (see defaultValue() )
};
/** Constructor for QgsFilterLineEdit.
* @param parent parent widget
* @param nullValue string for representing null values
*/
QgsFilterLineEdit( QWidget* parent /TransferThis/ = 0, const QString& nullValue = QString::null );
/** Returns the clear mode for the widget. The clear mode defines the behaviour of the
* widget when its value is cleared. This defaults to ClearToNull.
* @see setClearMode()
*/
ClearMode clearMode() const;
/** Sets the clear mode for the widget. The clear mode defines the behaviour of the
* widget when its value is cleared. This defaults to ClearToNull.
* @see clearMode()
*/
void setClearMode( ClearMode mode );
/** Sets the string representation for null values in the widget. This does not
* affect the values returned for null values by value(), rather it only affects
* the text that is shown to users when the widget's value is null.
* @param nullValue string to show when widget's value is null
* @see nullValue()
*/
void setNullValue( const QString& nullValue );
/** Returns the string used for representating null values in the widget.
* @see setNullValue()
* @see isNull()
*/
QString nullValue() const;
/** Sets the default value for the widget. The default value is a value
* which the widget will be reset to if it is cleared and the clearMode()
* is equal to ClearToDefault.
* @param defaultValue default value
* @see defaultValue()
* @see clearMode()
*/
void setDefaultValue( const QString& defaultValue );
/** Returns the default value for the widget. The default value is a value
* which the widget will be reset to if it is cleared and the clearMode()
* is equal to ClearToDefault.
* @see setDefaultValue()
* @see clearMode()
*/
QString defaultValue() const;
2014-09-23 14:38:40 +02:00
/**
* Sets the current text for the widget with support for handling null values.
2014-09-23 14:38:40 +02:00
*
* @param value The text to set. If a null string is provided, the text shown in the
* widget will be set to the current nullValue().
* @see value()
2014-09-23 14:38:40 +02:00
*/
void setValue( const QString& value );
2014-09-23 14:38:40 +02:00
/**
* Returns the text of this edit with support for handling null values. If the text
* in the widget matches the current nullValue() then the returned value will be
* a null string.
2014-09-23 14:38:40 +02:00
*
* @return Current text (or null string if it matches the nullValue() property )
* @see setValue()
2014-09-23 14:38:40 +02:00
*/
QString value() const;
/**
* Determine if the current text represents null.
2014-09-23 14:38:40 +02:00
*
* @return True if the widget's value is null.
* @see nullValue()
2014-09-23 14:38:40 +02:00
*/
bool isNull() const;
2014-05-27 23:22:50 +02:00
public slots:
/** Clears the widget and resets it to the null value.
* @see nullValue()
*/
virtual void clearValue();
2013-06-23 16:00:16 +02:00
signals:
/** Emitted when the widget is cleared
* @see clearValue()
*/
2013-06-23 16:00:16 +02:00
void cleared();
2014-09-23 14:38:40 +02:00
/**
* Same as textChanged() but with support for null values.
2014-09-23 14:38:40 +02:00
*
* @param value The current text or null string if it matches the nullValue() property.
2014-09-23 14:38:40 +02:00
*/
void valueChanged( const QString& value );
protected:
void mousePressEvent( QMouseEvent* e );
void mouseMoveEvent( QMouseEvent* e );
void focusInEvent( QFocusEvent* e );
void paintEvent( QPaintEvent* e );
void leaveEvent( QEvent* e );
};