summaryrefslogtreecommitdiffstats
path: root/qtpropertybrowser/src/qtvariantproperty.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qtpropertybrowser/src/qtvariantproperty.cpp')
-rw-r--r--qtpropertybrowser/src/qtvariantproperty.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/qtpropertybrowser/src/qtvariantproperty.cpp b/qtpropertybrowser/src/qtvariantproperty.cpp
index 1dd291d..275ae16 100644
--- a/qtpropertybrowser/src/qtvariantproperty.cpp
+++ b/qtpropertybrowser/src/qtvariantproperty.cpp
@@ -343,6 +343,7 @@ public:
void slotValueChanged(QtProperty *property, const QCursor &val);
void slotFlagChanged(QtProperty *property, int val);
void slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames);
+ void slotReadOnlyChanged(QtProperty *property, bool readOnly);
void slotPropertyInserted(QtProperty *property, QtProperty *parent, QtProperty *after);
void slotPropertyRemoved(QtProperty *property, QtProperty *parent);
@@ -373,6 +374,7 @@ public:
const QString m_minimumAttribute;
const QString m_regExpAttribute;
const QString m_echoModeAttribute;
+ const QString m_readOnlyAttribute;
};
QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() :
@@ -385,7 +387,8 @@ QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() :
m_maximumAttribute(QLatin1String("maximum")),
m_minimumAttribute(QLatin1String("minimum")),
m_regExpAttribute(QLatin1String("regExp")),
- m_echoModeAttribute(QLatin1String("echoMode"))
+ m_echoModeAttribute(QLatin1String("echoMode")),
+ m_readOnlyAttribute(QLatin1String("readOnly"))
{
}
@@ -547,6 +550,12 @@ void QtVariantPropertyManagerPrivate::slotEchoModeChanged(QtProperty *property,
emit q_ptr->attributeChanged(varProp, m_echoModeAttribute, QVariant(mode));
}
+void QtVariantPropertyManagerPrivate::slotReadOnlyChanged(QtProperty *property, bool readOnly)
+{
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ emit q_ptr->attributeChanged(varProp, m_readOnlyAttribute, QVariant(readOnly));
+}
+
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QDate &val)
{
valueChanged(property, QVariant(val));
@@ -947,6 +956,7 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent)
d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_minimumAttribute] = QVariant::Int;
d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_maximumAttribute] = QVariant::Int;
d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_singleStepAttribute] = QVariant::Int;
+ d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_readOnlyAttribute] = QVariant::Bool;
d_ptr->m_typeToValueType[QVariant::Int] = QVariant::Int;
connect(intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
this, SLOT(slotValueChanged(QtProperty *, int)));
@@ -965,6 +975,8 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent)
QVariant::Double;
d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_decimalsAttribute] =
QVariant::Int;
+ d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_readOnlyAttribute] =
+ QVariant::Bool;
d_ptr->m_typeToValueType[QVariant::Double] = QVariant::Double;
connect(doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)),
this, SLOT(slotValueChanged(QtProperty *, double)));
@@ -988,12 +1000,18 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent)
QVariant::RegExp;
d_ptr->m_typeToAttributeToAttributeType[QVariant::String][d_ptr->m_echoModeAttribute] =
QVariant::Int;
+ d_ptr->m_typeToAttributeToAttributeType[QVariant::String][d_ptr->m_readOnlyAttribute] =
+ QVariant::Bool;
+
connect(stringPropertyManager, SIGNAL(valueChanged(QtProperty *, const QString &)),
this, SLOT(slotValueChanged(QtProperty *, const QString &)));
connect(stringPropertyManager, SIGNAL(regExpChanged(QtProperty *, const QRegExp &)),
this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &)));
connect(stringPropertyManager, SIGNAL(echoModeChanged(QtProperty*,int)),
this, SLOT(slotEchoModeChanged(QtProperty*, int)));
+ connect(stringPropertyManager, SIGNAL(readOnlyChanged(QtProperty*, bool)),
+ this, SLOT(slotReadOnlyChanged(QtProperty*, bool)));
+
// DatePropertyManager
QtDatePropertyManager *datePropertyManager = new QtDatePropertyManager(this);
d_ptr->m_typeToPropertyManager[QVariant::Date] = datePropertyManager;
@@ -1465,6 +1483,8 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co
return intManager->minimum(internProp);
if (attribute == d_ptr->m_singleStepAttribute)
return intManager->singleStep(internProp);
+ if (attribute == d_ptr->m_readOnlyAttribute)
+ return intManager->isReadOnly(internProp);
return QVariant();
} else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
@@ -1475,12 +1495,16 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co
return doubleManager->singleStep(internProp);
if (attribute == d_ptr->m_decimalsAttribute)
return doubleManager->decimals(internProp);
+ if (attribute == d_ptr->m_readOnlyAttribute)
+ return doubleManager->isReadOnly(internProp);
return QVariant();
} else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
if (attribute == d_ptr->m_regExpAttribute)
return stringManager->regExp(internProp);
if (attribute == d_ptr->m_echoModeAttribute)
return stringManager->echoMode(internProp);
+ if (attribute == d_ptr->m_readOnlyAttribute)
+ return stringManager->isReadOnly(internProp);
return QVariant();
} else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
@@ -1710,6 +1734,8 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property,
intManager->setMinimum(internProp, qVariantValue<int>(value));
else if (attribute == d_ptr->m_singleStepAttribute)
intManager->setSingleStep(internProp, qVariantValue<int>(value));
+ else if (attribute == d_ptr->m_readOnlyAttribute)
+ intManager->setReadOnly(internProp, qVariantValue<bool>(value));
return;
} else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
@@ -1720,12 +1746,16 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property,
doubleManager->setSingleStep(internProp, qVariantValue<double>(value));
if (attribute == d_ptr->m_decimalsAttribute)
doubleManager->setDecimals(internProp, qVariantValue<int>(value));
+ if (attribute == d_ptr->m_readOnlyAttribute)
+ doubleManager->setReadOnly(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));
if (attribute == d_ptr->m_echoModeAttribute)
stringManager->setEchoMode(internProp, (EchoMode)qVariantValue<int>(value));
+ if (attribute == d_ptr->m_readOnlyAttribute)
+ stringManager->setReadOnly(internProp, (EchoMode)qVariantValue<bool>(value));
return;
} else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)