27 , mPlainTextEdit( NULL )
38 if (
config(
"UseHtml" ).toBool() )
40 v = mTextEdit->toHtml();
44 v = mTextEdit->toPlainText();
50 v = mPlainTextEdit->toPlainText();
55 v = mLineEdit->text();
59 v == QSettings().value(
"qgis/nullValue",
"NULL" ).toString() )
68 if (
field().convertCompatible( res ) )
71 return QVariant(
field().type() );
76 if (
config(
"IsMultiline" ).toBool() )
78 if (
config(
"UseHtml" ).toBool() )
80 return new QTextEdit( parent );
84 return new QPlainTextEdit( parent );
95 mTextEdit = qobject_cast<QTextEdit*>( editor );
96 mPlainTextEdit = qobject_cast<QPlainTextEdit*>( editor );
97 mLineEdit = qobject_cast<QLineEdit*>( editor );
100 connect( mTextEdit, SIGNAL( textChanged() ),
this, SLOT(
valueChanged() ) );
102 if ( mPlainTextEdit )
103 connect( mPlainTextEdit, SIGNAL( textChanged() ),
this, SLOT(
valueChanged() ) );
110 if ( defVal.isNull() )
112 defVal = QSettings().value(
"qgis/nullValue",
"NULL" );
118 mLineEdit->setPlaceholderText( defVal.toString() );
125 connect( mLineEdit, SIGNAL( textChanged( QString ) ),
this, SLOT(
valueChanged( QString ) ) );
127 mWritablePalette = mLineEdit->palette();
128 mReadOnlyPalette = mLineEdit->palette();
129 mReadOnlyPalette.setColor( QPalette::Text, mWritablePalette.color( QPalette::Disabled, QPalette::Text ) );
138 if ( !(
field().type() == QVariant::Int ||
field().type() == QVariant::Double ||
field().type() == QVariant::LongLong ||
field().type() == QVariant::Date ) )
139 v = QSettings().value(
"qgis/nullValue",
"NULL" ).toString();
146 if ( val !=
value() )
148 if (
config(
"UseHtml" ).toBool() )
149 mTextEdit->setHtml( v );
151 mTextEdit->setPlainText( v );
155 if ( mPlainTextEdit )
157 if ( val !=
value() )
158 mPlainTextEdit->setPlainText( v );
162 mLineEdit->setText( v );
168 mTextEdit->setReadOnly( !enabled );
170 if ( mPlainTextEdit )
171 mPlainTextEdit->setReadOnly( !enabled );
175 mLineEdit->setReadOnly( !enabled );
177 mLineEdit->setPalette( mWritablePalette );
179 mLineEdit->setPalette( mReadOnlyPalette );
void setEnabled(bool enabled) override
void initWidget(QWidget *editor) override
This method should initialize the editor widget with runtime data.
Lineedit with builtin clear button.
void setNullValue(QString nullValue)
QVariant value() override
Will be used to access the widget's value.
QWidget * createWidget(QWidget *parent) override
This method should create a new widget with the provided parent.
void setValue(const QVariant &value) override
QgsTextEditWrapper(QgsVectorLayer *vl, int fieldIdx, QWidget *editor=0, QWidget *parent=0)
Represents a vector layer which manages a vector based data sets.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.