QComboBox clear button in property browser.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-09 13:13:34 +02:00
parent 6f1dcb7592
commit da827ad952
4 changed files with 19 additions and 5 deletions

View File

@ -52,6 +52,7 @@ VFormulaProperty::VFormulaProperty(const QString &name)
VStringProperty* tmpFormula = new VStringProperty(tr("Formula")); VStringProperty* tmpFormula = new VStringProperty(tr("Formula"));
addChild(tmpFormula); addChild(tmpFormula);
tmpFormula->setClearButtonEnable(true);
tmpFormula->setUpdateBehaviour(true, false); tmpFormula->setUpdateBehaviour(true, false);
tmpFormula->setTypeForParent(static_cast<int>(ChildType::Formula)); tmpFormula->setTypeForParent(static_cast<int>(ChildType::Formula));

View File

@ -438,7 +438,8 @@ void VToolOptionsPropertyBrowser::AddPropertyFormula(const QString &propertyName
template<class Tool> template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &propertyName) void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &propertyName)
{ {
VProperty* itemName = new VProperty(propertyName); VStringProperty *itemName = new VStringProperty(propertyName);
itemName->setClearButtonEnable(true);
itemName->setValue(i->name()); itemName->setValue(i->name());
AddProperty(itemName, AttrName); AddProperty(itemName, AttrName);
} }
@ -448,7 +449,8 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &p
template<class Tool> template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &propertyName) void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &propertyName)
{ {
VProperty* itemName = new VProperty(propertyName); VStringProperty *itemName = new VStringProperty(propertyName);
itemName->setClearButtonEnable(true);
itemName->setValue(i->nameP1()); itemName->setValue(i->nameP1());
AddProperty(itemName, AttrName1); AddProperty(itemName, AttrName1);
} }
@ -457,7 +459,8 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &
template<class Tool> template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyPointName2(Tool *i, const QString &propertyName) void VToolOptionsPropertyBrowser::AddPropertyPointName2(Tool *i, const QString &propertyName)
{ {
VProperty* itemName = new VProperty(propertyName); VStringProperty *itemName = new VStringProperty(propertyName);
itemName->setClearButtonEnable(true);
itemName->setValue(i->nameP2()); itemName->setValue(i->nameP2());
AddProperty(itemName, AttrName2); AddProperty(itemName, AttrName2);
} }

View File

@ -29,7 +29,7 @@ using namespace VPE;
VPE::VStringProperty::VStringProperty(const QString &name, const QMap<QString, QVariant> &settings) VPE::VStringProperty::VStringProperty(const QString &name, const QMap<QString, QVariant> &settings)
: VProperty(name, QVariant::String), readOnly(false), typeForParent(0) : VProperty(name, QVariant::String), readOnly(false), typeForParent(0), clearButton(false)
{ {
VProperty::setSettings(settings); VProperty::setSettings(settings);
d_ptr->VariantValue.setValue(QString()); d_ptr->VariantValue.setValue(QString());
@ -37,7 +37,7 @@ VPE::VStringProperty::VStringProperty(const QString &name, const QMap<QString, Q
} }
VPE::VStringProperty::VStringProperty(const QString &name) VPE::VStringProperty::VStringProperty(const QString &name)
: VProperty(name), readOnly(false), typeForParent(0) : VProperty(name), readOnly(false), typeForParent(0), clearButton(false)
{ {
d_ptr->VariantValue.setValue(QString()); d_ptr->VariantValue.setValue(QString());
d_ptr->VariantValue.convert(QVariant::String); d_ptr->VariantValue.convert(QVariant::String);
@ -52,6 +52,9 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV
QLineEdit* tmpEditor = new QLineEdit(parent); QLineEdit* tmpEditor = new QLineEdit(parent);
tmpEditor->setLocale(parent->locale()); tmpEditor->setLocale(parent->locale());
tmpEditor->setReadOnly(readOnly); tmpEditor->setReadOnly(readOnly);
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
tmpEditor->setClearButtonEnabled(clearButton);
#endif
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
tmpEditor->setText(d_ptr->VariantValue.toString()); tmpEditor->setText(d_ptr->VariantValue.toString());
@ -75,6 +78,11 @@ void VPE::VStringProperty::setReadOnly(bool readOnly)
this->readOnly = readOnly; this->readOnly = readOnly;
} }
void VStringProperty::setClearButtonEnable(bool value)
{
this->clearButton = value;
}
void VPE::VStringProperty::setSetting(const QString &key, const QVariant &value) void VPE::VStringProperty::setSetting(const QString &key, const QVariant &value)
{ {
if (key == QLatin1String("ReadOnly")) if (key == QLatin1String("ReadOnly"))

View File

@ -49,6 +49,7 @@ public:
virtual QVariant getEditorData(const QWidget* editor) const Q_DECL_OVERRIDE; virtual QVariant getEditorData(const QWidget* editor) const Q_DECL_OVERRIDE;
void setReadOnly(bool readOnly); void setReadOnly(bool readOnly);
void setClearButtonEnable(bool value);
//! Sets the settings. //! Sets the settings.
virtual void setSetting(const QString& key, const QVariant& value) Q_DECL_OVERRIDE; virtual void setSetting(const QString& key, const QVariant& value) Q_DECL_OVERRIDE;
@ -77,6 +78,7 @@ public:
protected: protected:
bool readOnly; bool readOnly;
int typeForParent; int typeForParent;
bool clearButton;
private: private:
Q_DISABLE_COPY(VStringProperty) Q_DISABLE_COPY(VStringProperty)