diff options
Diffstat (limited to 'qtpropertybrowser/src')
-rw-r--r-- | qtpropertybrowser/src/qteditorfactory.cpp | 22 | ||||
-rw-r--r-- | qtpropertybrowser/src/qteditorfactory.h | 1 | ||||
-rw-r--r-- | qtpropertybrowser/src/qtpropertymanager.cpp | 68 | ||||
-rw-r--r-- | qtpropertybrowser/src/qtpropertymanager.h | 3 | ||||
-rw-r--r-- | qtpropertybrowser/src/qtvariantproperty.cpp | 26 | ||||
-rw-r--r-- | qtpropertybrowser/src/qtvariantproperty.h | 1 |
6 files changed, 109 insertions, 12 deletions
diff --git a/qtpropertybrowser/src/qteditorfactory.cpp b/qtpropertybrowser/src/qteditorfactory.cpp index afd1520..c9a371d 100644 --- a/qtpropertybrowser/src/qteditorfactory.cpp +++ b/qtpropertybrowser/src/qteditorfactory.cpp @@ -631,6 +631,7 @@ class QtCheckBoxFactoryPrivate : public EditorFactoryPrivate<QtBoolEdit> Q_DECLARE_PUBLIC(QtCheckBoxFactory) public: void slotPropertyChanged(QtProperty *property, bool value); + void slotTextVisibleChanged(QtProperty *property, bool textVisible); void slotSetValue(bool value); }; @@ -648,6 +649,22 @@ void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool va } } +void QtCheckBoxFactoryPrivate::slotTextVisibleChanged(QtProperty *property, bool textVisible) +{ + if (!m_createdEditors.contains(property)) + return; + + QtBoolPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QListIterator<QtBoolEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QtBoolEdit *editor = itEditor.next(); + editor->setTextVisible(textVisible); + } +} + void QtCheckBoxFactoryPrivate::slotSetValue(bool value) { QObject *object = q_ptr->sender(); @@ -702,6 +719,8 @@ void QtCheckBoxFactory::connectPropertyManager(QtBoolPropertyManager *manager) { connect(manager, SIGNAL(valueChanged(QtProperty *, bool)), this, SLOT(slotPropertyChanged(QtProperty *, bool))); + connect(manager, SIGNAL(textVisibleChanged(QtProperty *, bool)), + this, SLOT(slotTextVisibleChanged(QtProperty *, bool))); } /*! @@ -714,6 +733,7 @@ QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtPrope { QtBoolEdit *editor = d_ptr->createEditor(property, parent); editor->setChecked(manager->value(property)); + editor->setTextVisible(manager->textVisible(property)); connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool))); connect(editor, SIGNAL(destroyed(QObject *)), @@ -730,6 +750,8 @@ void QtCheckBoxFactory::disconnectPropertyManager(QtBoolPropertyManager *manager { disconnect(manager, SIGNAL(valueChanged(QtProperty *, bool)), this, SLOT(slotPropertyChanged(QtProperty *, bool))); + disconnect(manager, SIGNAL(textVisibleChanged(QtProperty *, bool)), + this, SLOT(slotTextVisibleChanged(QtProperty *, bool))); } // QtDoubleSpinBoxFactory diff --git a/qtpropertybrowser/src/qteditorfactory.h b/qtpropertybrowser/src/qteditorfactory.h index 37204ce..cbb2077 100644 --- a/qtpropertybrowser/src/qteditorfactory.h +++ b/qtpropertybrowser/src/qteditorfactory.h @@ -139,6 +139,7 @@ private: Q_DECLARE_PRIVATE(QtCheckBoxFactory) Q_DISABLE_COPY(QtCheckBoxFactory) Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool)) + Q_PRIVATE_SLOT(d_func(), void slotTextVisibleChanged(QtProperty *, bool)) Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool)) Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; diff --git a/qtpropertybrowser/src/qtpropertymanager.cpp b/qtpropertybrowser/src/qtpropertymanager.cpp index cfc54ef..e50cafc 100644 --- a/qtpropertybrowser/src/qtpropertymanager.cpp +++ b/qtpropertybrowser/src/qtpropertymanager.cpp @@ -1600,7 +1600,16 @@ class QtBoolPropertyManagerPrivate public: QtBoolPropertyManagerPrivate(); - QMap<const QtProperty *, bool> m_values; + struct Data + { + Data() : val(false), textVisible(true) {} + bool val; + bool textVisible; + }; + + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; + const QIcon m_checkedIcon; const QIcon m_uncheckedIcon; }; @@ -1663,7 +1672,12 @@ QtBoolPropertyManager::~QtBoolPropertyManager() */ bool QtBoolPropertyManager::value(const QtProperty *property) const { - return d_ptr->m_values.value(property, false); + return getValue<bool>(d_ptr->m_values, property, false); +} + +bool QtBoolPropertyManager::textVisible(const QtProperty *property) const +{ + return getData<bool>(d_ptr->m_values, &QtBoolPropertyManagerPrivate::Data::textVisible, property, false); } /*! @@ -1671,13 +1685,17 @@ bool QtBoolPropertyManager::value(const QtProperty *property) const */ QString QtBoolPropertyManager::valueText(const QtProperty *property) const { - const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); + const QtBoolPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) return QString(); + const QtBoolPropertyManagerPrivate::Data &data = it.value(); + if (!data.textVisible) + return QString(); + static const QString trueText = tr("True"); static const QString falseText = tr("False"); - return it.value() ? trueText : falseText; + return data.val ? trueText : falseText; } /*! @@ -1685,11 +1703,11 @@ QString QtBoolPropertyManager::valueText(const QtProperty *property) const */ QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const { - const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); + const QtBoolPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) return QIcon(); - return it.value() ? d_ptr->m_checkedIcon : d_ptr->m_uncheckedIcon; + return it.value().val ? d_ptr->m_checkedIcon : d_ptr->m_uncheckedIcon; } /*! @@ -1701,10 +1719,38 @@ QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const */ void QtBoolPropertyManager::setValue(QtProperty *property, bool val) { - setSimpleValue<bool, bool, QtBoolPropertyManager>(d_ptr->m_values, this, - &QtBoolPropertyManager::propertyChanged, - &QtBoolPropertyManager::valueChanged, - property, val); + const QtBoolPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; + + QtBoolPropertyManagerPrivate::Data data = it.value(); + + if (data.val == val) + return; + + data.val = val; + it.value() = data; + + emit propertyChanged(property); + emit valueChanged(property, data.val); +} + +void QtBoolPropertyManager::setTextVisible(QtProperty *property, bool textVisible) +{ + const QtBoolPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; + + QtBoolPropertyManagerPrivate::Data data = it.value(); + + if (data.textVisible == textVisible) + return; + + data.textVisible = textVisible; + it.value() = data; + + emit propertyChanged(property); + emit textVisibleChanged(property, data.textVisible); } /*! @@ -1712,7 +1758,7 @@ void QtBoolPropertyManager::setValue(QtProperty *property, bool val) */ void QtBoolPropertyManager::initializeProperty(QtProperty *property) { - d_ptr->m_values[property] = false; + d_ptr->m_values[property] = QtBoolPropertyManagerPrivate::Data(); } /*! diff --git a/qtpropertybrowser/src/qtpropertymanager.h b/qtpropertybrowser/src/qtpropertymanager.h index 6eff26e..d6b94cc 100644 --- a/qtpropertybrowser/src/qtpropertymanager.h +++ b/qtpropertybrowser/src/qtpropertymanager.h @@ -115,11 +115,14 @@ public: ~QtBoolPropertyManager(); bool value(const QtProperty *property) const; + bool textVisible(const QtProperty *property) const; public Q_SLOTS: void setValue(QtProperty *property, bool val); + void setTextVisible(QtProperty *property, bool textVisible); Q_SIGNALS: void valueChanged(QtProperty *property, bool val); + void textVisibleChanged(QtProperty *property, bool); protected: QString valueText(const QtProperty *property) const; QIcon valueIcon(const QtProperty *property) const; diff --git a/qtpropertybrowser/src/qtvariantproperty.cpp b/qtpropertybrowser/src/qtvariantproperty.cpp index d2c02e9..d7fe111 100644 --- a/qtpropertybrowser/src/qtvariantproperty.cpp +++ b/qtpropertybrowser/src/qtvariantproperty.cpp @@ -344,6 +344,7 @@ public: void slotFlagChanged(QtProperty *property, int val); void slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames); void slotReadOnlyChanged(QtProperty *property, bool readOnly); + void slotTextVisibleChanged(QtProperty *property, bool textVisible); void slotPropertyInserted(QtProperty *property, QtProperty *parent, QtProperty *after); void slotPropertyRemoved(QtProperty *property, QtProperty *parent); @@ -375,6 +376,7 @@ public: const QString m_regExpAttribute; const QString m_echoModeAttribute; const QString m_readOnlyAttribute; + const QString m_textVisibleAttribute; }; QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() : @@ -388,7 +390,8 @@ QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() : m_minimumAttribute(QLatin1String("minimum")), m_regExpAttribute(QLatin1String("regExp")), m_echoModeAttribute(QLatin1String("echoMode")), - m_readOnlyAttribute(QLatin1String("readOnly")) + m_readOnlyAttribute(QLatin1String("readOnly")), + m_textVisibleAttribute(QLatin1String("textVisible")) { } @@ -556,6 +559,12 @@ void QtVariantPropertyManagerPrivate::slotReadOnlyChanged(QtProperty *property, emit q_ptr->attributeChanged(varProp, m_readOnlyAttribute, QVariant(readOnly)); } +void QtVariantPropertyManagerPrivate::slotTextVisibleChanged(QtProperty *property, bool textVisible) +{ + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_textVisibleAttribute, QVariant(textVisible)); +} + void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QDate &val) { valueChanged(property, QVariant(val)); @@ -840,6 +849,10 @@ void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty *property, \o decimals \o QVariant::Int \row + \o \c bool + \o textVisible + \o QVariant::Bool + \row \o QString \o regExp \o QVariant::RegExp @@ -993,9 +1006,12 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent) // BoolPropertyManager QtBoolPropertyManager *boolPropertyManager = new QtBoolPropertyManager(this); d_ptr->m_typeToPropertyManager[QVariant::Bool] = boolPropertyManager; + d_ptr->m_typeToAttributeToAttributeType[QVariant::Bool][d_ptr->m_textVisibleAttribute] = QVariant::Bool; d_ptr->m_typeToValueType[QVariant::Bool] = QVariant::Bool; connect(boolPropertyManager, SIGNAL(valueChanged(QtProperty *, bool)), this, SLOT(slotValueChanged(QtProperty *, bool))); + connect(boolPropertyManager, SIGNAL(textVisibleChanged(QtProperty*, bool)), + this, SLOT(slotTextVisibleChanged(QtProperty*, bool))); // StringPropertyManager QtStringPropertyManager *stringPropertyManager = new QtStringPropertyManager(this); d_ptr->m_typeToPropertyManager[QVariant::String] = stringPropertyManager; @@ -1502,6 +1518,10 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co if (attribute == d_ptr->m_readOnlyAttribute) return doubleManager->isReadOnly(internProp); return QVariant(); + } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { + if (attribute == d_ptr->m_textVisibleAttribute) + return boolManager->textVisible(internProp); + return QVariant(); } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { if (attribute == d_ptr->m_regExpAttribute) return stringManager->regExp(internProp); @@ -1753,6 +1773,10 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property, if (attribute == d_ptr->m_readOnlyAttribute) doubleManager->setReadOnly(internProp, qVariantValue<bool>(value)); return; + } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { + if (attribute == d_ptr->m_textVisibleAttribute) + boolManager->setTextVisible(internProp, qVariantValue<bool>(value)); + return; } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { if (attribute == d_ptr->m_regExpAttribute) stringManager->setRegExp(internProp, qVariantValue<QRegExp>(value)); diff --git a/qtpropertybrowser/src/qtvariantproperty.h b/qtpropertybrowser/src/qtvariantproperty.h index 41b28a6..2c09fe9 100644 --- a/qtpropertybrowser/src/qtvariantproperty.h +++ b/qtpropertybrowser/src/qtvariantproperty.h @@ -153,6 +153,7 @@ private: Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &)) Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &)) Q_PRIVATE_SLOT(d_func(), void slotReadOnlyChanged(QtProperty *, bool)) + Q_PRIVATE_SLOT(d_func(), void slotTextVisibleChanged(QtProperty *, bool)) Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)) Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *)) Q_DECLARE_PRIVATE(QtVariantPropertyManager) |