24 #include <QLatin1String>
27 #include <QSizePolicy>
28 #include <QStaticStringData>
29 #include <QStringData>
30 #include <QStringDataPtr>
33 #include "../vproperty_p.h"
40 , m_osSeparator(false)
52 , m_osSeparator(false)
59 const QAbstractItemDelegate *delegate)
64 QLineEdit *tmpEditor =
new QLineEdit(parent);
65 tmpEditor->setMinimumWidth(140);
66 tmpEditor->setAlignment(Qt::AlignTop);
67 tmpEditor->setLocale(parent->locale());
68 tmpEditor->setReadOnly(readOnly);
69 tmpEditor->installEventFilter(
this);
70 tmpEditor->setClearButtonEnabled(clearButton);
71 tmpEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
72 tmpEditor->setText(d_ptr->VariantValue.toString());
74 d_ptr->editor = tmpEditor;
80 const QLineEdit *tmpEditor = qobject_cast<const QLineEdit*>(editor);
83 return tmpEditor->text();
86 return QVariant(QString());
91 this->readOnly = readOnly;
96 m_osSeparator = separator;
101 this->clearButton = value;
106 if (key == QLatin1String(
"ReadOnly"))
108 setReadOnly(value.toBool());
110 if (key == QLatin1String(
"TypeForParent"))
112 setTypeForParent(value.toInt());
118 if (key == QLatin1String(
"ReadOnly"))
122 else if (key == QLatin1String(
"TypeForParent"))
124 return typeForParent;
132 QStringList settings;
133 settings << QStringLiteral(
"ReadOnly") << QStringLiteral(
"TypeForParent");
139 return QStringLiteral(
"string");
149 emit childChanged(value, typeForParent);
155 return typeForParent;
160 typeForParent = value;
165 if (QLineEdit *textEdit = qobject_cast<QLineEdit *>(
object))
167 if (event->type() == QEvent::KeyPress)
169 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(event);
170 if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
174 textEdit->insert(QLocale().decimalPoint());
178 textEdit->insert(QLocale::c().decimalPoint());
187 return VProperty::eventFilter(
object, event);
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...
Class for holding a string property.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE
Get the settings. This function has to be implemented in a subclass in order to have an effect.
void setTypeForParent(int value)
void setReadOnly(bool readOnly)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE
Returns an editor widget, or NULL if it doesn't supply one.
void setOsSeparator(bool separator)
virtual void updateParent(const QVariant &value) Q_DECL_OVERRIDE
int getTypeForParent() const
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
Returns the list of keys of the property's settings.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
void setClearButtonEnable(bool value)
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
Sets the settings.
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE
VStringProperty(const QString &name, const QMap< QString, QVariant > &settings)