32 #include <QLatin1String>
34 #include <QSizePolicy>
35 #include <QStaticStringData>
36 #include <QStringData>
37 #include <QStringDataPtr>
41 #include "../vproperty_p.h"
48 , m_osSeparator(false)
59 , m_osSeparator(false)
73 const QAbstractItemDelegate *delegate)
79 textEditor->setMinimumWidth(140);
80 textEditor->setFixedHeight(28);
81 textEditor->setLocale(parent->locale());
82 textEditor->setReadOnly(m_readOnly);
83 textEditor->installEventFilter(
this);
84 textEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
85 textEditor->setPlainText(d_ptr->VariantValue.toString());
87 d_ptr->editor = textEditor;
97 const QPlainTextEdit* textEditor = qobject_cast<const QPlainTextEdit*>(editor);
100 return textEditor->toPlainText();
103 return QVariant(QString());
108 this->m_readOnly = m_readOnly;
113 m_osSeparator = separator;
121 if (key == QLatin1String(
"ReadOnly"))
123 setReadOnly(value.toBool());
125 if (key == QLatin1String(
"TypeForParent"))
127 setTypeForParent(value.toInt());
136 if (key == QLatin1String(
"ReadOnly"))
140 else if (key == QLatin1String(
"TypeForParent"))
142 return m_typeForParent;
153 QStringList settings;
154 settings << QStringLiteral(
"ReadOnly") << QStringLiteral(
"TypeForParent");
163 return QStringLiteral(
"string");
180 emit childChanged(value, m_typeForParent);
186 return m_typeForParent;
191 m_typeForParent = value;
196 if (QPlainTextEdit *textEdit = qobject_cast<QPlainTextEdit *>(
object))
198 if (event->type() == QEvent::KeyPress)
200 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(event);
201 if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
205 textEdit->insertPlainText(QLocale().decimalPoint());
209 textEdit->insertPlainText(QLocale::c().decimalPoint());
218 return VProperty::eventFilter(
object, event);
Class for holding a plain text property.
void setReadOnly(bool readOnly)
virtual void updateParent(const QVariant &value) Q_DECL_OVERRIDE
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
setSetting Sets the settings.
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE
void setOsSeparator(bool separator)
int getTypeForParent() const
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
getEditorData Gets the data from the widget @oaram editor
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
clone Clones this property
PlainTextProperty(const QString &name, const QMap< QString, QVariant > &settings)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE
createEditor Returns an editor widget, or NULL if it doesn't supply one
void setTypeForParent(int value)
virtual QString type() const Q_DECL_OVERRIDE
type Returns a string containing the type of the property.
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
getSettingKeys Returns the list of keys of the property's settings.
virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE
getSetting Gets the settings.his function has to be implemented in a subclass in order to have an eff...
QVariant VariantValue
The property's value. This does not have to be used by subclasses, but it makes sense in cases where ...
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const
Clones this property.
VPropertyPrivate * d_ptr
The protected structure holding the member variables (to assure binary compatibility)
virtual QVariant getSetting(const QString &key) const
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual void setSettings(const QMap< QString, QVariant > &settings)
Sets the settings by calling the overloaded setSetting(const QString &key, const QVariant &value) for...