Newer
Older
d_ptr->setConstraint(property, data.constraint, data.val);
if (data.val == oldVal)
return;
emit propertyChanged(property);
emit valueChanged(property, data.val);
}
/**
\fn void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec)
Sets the precision of the given \a property to \a prec.
The valid decimal range is 0-13. The default is 2.
\sa decimals()
*/
void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec)
{
const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtRectFPropertyManagerPrivate::Data data = it.value();
if (prec > 13)
prec = 13;
else if (prec < 0)
prec = 0;
if (data.decimals == prec)
return;
data.decimals = prec;
d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec);
d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec);
d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec);
d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec);
emit decimalsChanged(property, data.decimals);
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
void QtRectFPropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = QtRectFPropertyManagerPrivate::Data();
QtProperty *xProp = d_ptr->m_doublePropertyManager->addProperty();
xProp->setPropertyName(tr("X"));
d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property));
d_ptr->m_doublePropertyManager->setValue(xProp, 0);
d_ptr->m_propertyToX[property] = xProp;
d_ptr->m_xToProperty[xProp] = property;
property->addSubProperty(xProp);
QtProperty *yProp = d_ptr->m_doublePropertyManager->addProperty();
yProp->setPropertyName(tr("Y"));
d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property));
d_ptr->m_doublePropertyManager->setValue(yProp, 0);
d_ptr->m_propertyToY[property] = yProp;
d_ptr->m_yToProperty[yProp] = property;
property->addSubProperty(yProp);
QtProperty *wProp = d_ptr->m_doublePropertyManager->addProperty();
wProp->setPropertyName(tr("Width"));
d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property));
d_ptr->m_doublePropertyManager->setValue(wProp, 0);
d_ptr->m_doublePropertyManager->setMinimum(wProp, 0);
d_ptr->m_propertyToW[property] = wProp;
d_ptr->m_wToProperty[wProp] = property;
property->addSubProperty(wProp);
QtProperty *hProp = d_ptr->m_doublePropertyManager->addProperty();
hProp->setPropertyName(tr("Height"));
d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property));
d_ptr->m_doublePropertyManager->setValue(hProp, 0);
d_ptr->m_doublePropertyManager->setMinimum(hProp, 0);
d_ptr->m_propertyToH[property] = hProp;
d_ptr->m_hToProperty[hProp] = property;
property->addSubProperty(hProp);
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
void QtRectFPropertyManager::uninitializeProperty(QtProperty *property)
{
QtProperty *xProp = d_ptr->m_propertyToX[property];
if (xProp) {
d_ptr->m_xToProperty.remove(xProp);
delete xProp;
}
d_ptr->m_propertyToX.remove(property);
QtProperty *yProp = d_ptr->m_propertyToY[property];
if (yProp) {
d_ptr->m_yToProperty.remove(yProp);
delete yProp;
}
d_ptr->m_propertyToY.remove(property);
QtProperty *wProp = d_ptr->m_propertyToW[property];
if (wProp) {
d_ptr->m_wToProperty.remove(wProp);
delete wProp;
}
d_ptr->m_propertyToW.remove(property);
QtProperty *hProp = d_ptr->m_propertyToH[property];
if (hProp) {
d_ptr->m_hToProperty.remove(hProp);
delete hProp;
}
d_ptr->m_propertyToH.remove(property);
d_ptr->m_values.remove(property);
class QtEnumPropertyManagerPrivate
{
QtEnumPropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtEnumPropertyManager)
struct Data
{
Data() : val(-1) {}
int val;
QStringList enumNames;
QMap<int, QIcon> enumIcons;
};
typedef QMap<const QtProperty *, Data> PropertyValueMap;
PropertyValueMap m_values;
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
};
/**
\class QtEnumPropertyManager
\brief The QtEnumPropertyManager provides and manages enum properties.
Each enum property has an associated list of enum names which can
be retrieved using the enumNames() function, and set using the
corresponding setEnumNames() function. An enum property's value is
represented by an index in this list, and can be retrieved and set
using the value() and setValue() slots respectively.
Each enum value can also have an associated icon. The mapping from
values to icons can be set using the setEnumIcons() function and
queried with the enumIcons() function.
In addition, QtEnumPropertyManager provides the valueChanged() signal
which is emitted whenever a property created by this manager
changes. The enumNamesChanged() or enumIconsChanged() signal is emitted
whenever the list of enum names or icons is altered.
\sa QtAbstractPropertyManager, QtEnumEditorFactory
*/
/**
\fn void QtEnumPropertyManager::valueChanged(QtProperty *property, int value)
This signal is emitted whenever a property created by this manager
changes its value, passing a pointer to the \a property and the new
\a value as parameters.
\sa setValue()
*/
/**
\fn void QtEnumPropertyManager::enumNamesChanged(QtProperty *property, const QStringList &names)
This signal is emitted whenever a property created by this manager
changes its enum names, passing a pointer to the \a property and
the new \a names as parameters.
\sa setEnumNames()
*/
/**
\fn void QtEnumPropertyManager::enumIconsChanged(QtProperty *property, const QMap<int, QIcon> &icons)
This signal is emitted whenever a property created by this manager
changes its enum icons, passing a pointer to the \a property and
the new mapping of values to \a icons as parameters.
\sa setEnumIcons()
*/
/**
Creates a manager with the given \a parent.
*/
QtEnumPropertyManager::QtEnumPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtEnumPropertyManagerPrivate;
d_ptr->q_ptr = this;
}
/**
Destroys this manager, and all the properties it has created.
*/
QtEnumPropertyManager::~QtEnumPropertyManager()
{
clear();
delete d_ptr;
}
/**
Returns the given \a property's value which is an index in the
list returned by enumNames()
If the given property is not managed by this manager, this
function returns -1.
\sa enumNames(), setValue()
*/
int QtEnumPropertyManager::value(const QtProperty *property) const
{
return getValue<int>(d_ptr->m_values, property, -1);
}
/**
Returns the given \a property's list of enum names.
\sa value(), setEnumNames()
*/
QStringList QtEnumPropertyManager::enumNames(const QtProperty *property) const
{
return getData<QStringList>(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumNames, property, QStringList());
}
/**
Returns the given \a property's map of enum values to their icons.
\sa value(), setEnumIcons()
*/
QMap<int, QIcon> QtEnumPropertyManager::enumIcons(const QtProperty *property) const
{
return getData<QMap<int, QIcon> >(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumIcons, property, QMap<int, QIcon>());
QString QtEnumPropertyManager::valueText(const QtProperty *property) const
{
const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
const QtEnumPropertyManagerPrivate::Data &data = it.value();
const int v = data.val;
if (v >= 0 && v < data.enumNames.count())
return data.enumNames.at(v);
return QString();
QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const
{
const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QIcon();
const QtEnumPropertyManagerPrivate::Data &data = it.value();
const int v = data.val;
return data.enumIcons.value(v);
}
/**
\fn void QtEnumPropertyManager::setValue(QtProperty *property, int value)
Sets the value of the given \a property to \a value.
The specified \a value must be less than the size of the given \a
property's enumNames() list, and larger than (or equal to) 0.
\sa value(), valueChanged()
*/
void QtEnumPropertyManager::setValue(QtProperty *property, int val)
{
const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtEnumPropertyManagerPrivate::Data data = it.value();
if (val >= data.enumNames.count())
return;
if (val < 0 && data.enumNames.count() > 0)
return;
if (data.val == val)
return;
emit propertyChanged(property);
emit valueChanged(property, data.val);
}
/**
Sets the given \a property's list of enum names to \a
enumNames. The \a property's current value is reset to 0
indicating the first item of the list.
If the specified \a enumNames list is empty, the \a property's
current value is set to -1.
\sa enumNames(), enumNamesChanged()
*/
void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList &enumNames)
{
const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtEnumPropertyManagerPrivate::Data data = it.value();
if (data.enumNames == enumNames)
return;
if (enumNames.count() > 0)
data.val = 0;
emit enumNamesChanged(property, data.enumNames);
emit propertyChanged(property);
emit valueChanged(property, data.val);
}
/**
Sets the given \a property's map of enum values to their icons to \a
enumIcons.
Each enum value can have associated icon. This association is represented with passed \a enumIcons map.
\sa enumNames(), enumNamesChanged()
*/
void QtEnumPropertyManager::setEnumIcons(QtProperty *property, const QMap<int, QIcon> &enumIcons)
{
const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
it.value().enumIcons = enumIcons;
emit enumIconsChanged(property, it.value().enumIcons);
emit propertyChanged(property);
void QtEnumPropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = QtEnumPropertyManagerPrivate::Data();
void QtEnumPropertyManager::uninitializeProperty(QtProperty *property)
{
d_ptr->m_values.remove(property);
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
void QtFlagPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool value)
{
QtProperty *prop = m_flagToProperty.value(property, 0);
if (prop == 0)
return;
QListIterator<QtProperty *> itProp(m_propertyToFlags[prop]);
int level = 0;
while (itProp.hasNext()) {
QtProperty *p = itProp.next();
if (p == property) {
int v = m_values[prop].val;
if (value) {
v |= (1 << level);
} else {
v &= ~(1 << level);
}
q_ptr->setValue(prop, v);
return;
}
level++;
void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
QtProperty *flagProperty = m_flagToProperty.value(property, 0);
if (flagProperty == 0)
return;
m_propertyToFlags[flagProperty].replace(m_propertyToFlags[flagProperty].indexOf(property), 0);
m_flagToProperty.remove(property);
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
}
/**
\class QtFlagPropertyManager
\brief The QtFlagPropertyManager provides and manages flag properties.
Each flag property has an associated list of flag names which can
be retrieved using the flagNames() function, and set using the
corresponding setFlagNames() function.
The flag manager provides properties with nested boolean
subproperties representing each flag, i.e. a flag property's value
is the binary combination of the subproperties' values. A
property's value can be retrieved and set using the value() and
setValue() slots respectively. The combination of flags is represented
by single int value - that's why it's possible to store up to
32 independent flags in one flag property.
The subproperties are created by a QtBoolPropertyManager object. This
manager can be retrieved using the subBoolPropertyManager() function. In
order to provide editing widgets for the subproperties in a
property browser widget, this manager must be associated with an
editor factory.
In addition, QtFlagPropertyManager provides the valueChanged() signal
which is emitted whenever a property created by this manager
changes, and the flagNamesChanged() signal which is emitted
whenever the list of flag names is altered.
\sa QtAbstractPropertyManager, QtBoolPropertyManager
*/
/**
\fn void QtFlagPropertyManager::valueChanged(QtProperty *property, int value)
This signal is emitted whenever a property created by this manager
changes its value, passing a pointer to the \a property and the new
\a value as parameters.
\sa setValue()
*/
/**
\fn void QtFlagPropertyManager::flagNamesChanged(QtProperty *property, const QStringList &names)
This signal is emitted whenever a property created by this manager
changes its flag names, passing a pointer to the \a property and the
new \a names as parameters.
\sa setFlagNames()
*/
/**
Creates a manager with the given \a parent.
*/
QtFlagPropertyManager::QtFlagPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtFlagPropertyManagerPrivate;
d_ptr->q_ptr = this;
d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this);
connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty *, bool)),
this, SLOT(slotBoolChanged(QtProperty *, bool)));
connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)),
this, SLOT(slotPropertyDestroyed(QtProperty *)));
}
/**
Destroys this manager, and all the properties it has created.
*/
QtFlagPropertyManager::~QtFlagPropertyManager()
{
clear();
delete d_ptr;
}
/**
Returns the manager that produces the nested boolean subproperties
representing each flag.
In order to provide editing widgets for the subproperties in a
property browser widget, this manager must be associated with an
editor factory.
\sa QtAbstractPropertyBrowser::setFactoryForManager()
*/
QtBoolPropertyManager *QtFlagPropertyManager::subBoolPropertyManager() const
{
return d_ptr->m_boolPropertyManager;
}
/**
Returns the given \a property's value.
If the given property is not managed by this manager, this
function returns 0.
\sa flagNames(), setValue()
*/
int QtFlagPropertyManager::value(const QtProperty *property) const
{
return getValue<int>(d_ptr->m_values, property, 0);
}
/**
Returns the given \a property's list of flag names.
\sa value(), setFlagNames()
*/
QStringList QtFlagPropertyManager::flagNames(const QtProperty *property) const
{
return getData<QStringList>(d_ptr->m_values, &QtFlagPropertyManagerPrivate::Data::flagNames, property, QStringList());
QString QtFlagPropertyManager::valueText(const QtProperty *property) const
{
const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
const QtFlagPropertyManagerPrivate::Data &data = it.value();
QString str;
int level = 0;
const QChar bar = QLatin1Char('|');
const QStringList::const_iterator fncend = data.flagNames.constEnd();
for (QStringList::const_iterator it = data.flagNames.constBegin(); it != fncend; ++it) {
if (data.val & (1 << level)) {
if (!str.isEmpty())
str += bar;
str += *it;
}
level++;
}
/**
\fn void QtFlagPropertyManager::setValue(QtProperty *property, int value)
Sets the value of the given \a property to \a value. Nested
properties are updated automatically.
The specified \a value must be less than the binary combination of
the property's flagNames() list size (i.e. less than 2\sup n,
where \c n is the size of the list) and larger than (or equal to)
0.
\sa value(), valueChanged()
*/
void QtFlagPropertyManager::setValue(QtProperty *property, int val)
{
const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtFlagPropertyManagerPrivate::Data data = it.value();
if (data.val == val)
return;
if (val > (1 << data.flagNames.count()) - 1)
return;
QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]);
int level = 0;
while (itProp.hasNext()) {
QtProperty *prop = itProp.next();
if (prop)
d_ptr->m_boolPropertyManager->setValue(prop, val & (1 << level));
level++;
}
emit propertyChanged(property);
emit valueChanged(property, data.val);
}
/**
Sets the given \a property's list of flag names to \a flagNames. The
property's current value is reset to 0 indicating the first item
of the list.
\sa flagNames(), flagNamesChanged()
*/
void QtFlagPropertyManager::setFlagNames(QtProperty *property, const QStringList &flagNames)
{
const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtFlagPropertyManagerPrivate::Data data = it.value();
if (data.flagNames == flagNames)
return;
data.flagNames = flagNames;
data.val = 0;
QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]);
while (itProp.hasNext()) {
QtProperty *prop = itProp.next();
if (prop) {
delete prop;
d_ptr->m_flagToProperty.remove(prop);
}
}
d_ptr->m_propertyToFlags[property].clear();
QStringListIterator itFlag(flagNames);
while (itFlag.hasNext()) {
const QString flagName = itFlag.next();
QtProperty *prop = d_ptr->m_boolPropertyManager->addProperty();
prop->setPropertyName(flagName);
property->addSubProperty(prop);
d_ptr->m_propertyToFlags[property].append(prop);
d_ptr->m_flagToProperty[prop] = property;
emit flagNamesChanged(property, data.flagNames);
emit propertyChanged(property);
emit valueChanged(property, data.val);
void QtFlagPropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = QtFlagPropertyManagerPrivate::Data();
d_ptr->m_propertyToFlags[property] = QList<QtProperty *>();
void QtFlagPropertyManager::uninitializeProperty(QtProperty *property)
{
QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]);
while (itProp.hasNext()) {
QtProperty *prop = itProp.next();
if (prop) {
delete prop;
d_ptr->m_flagToProperty.remove(prop);
}
d_ptr->m_propertyToFlags.remove(property);
d_ptr->m_values.remove(property);
}
// QtSizePolicyPropertyManager
QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate()
{
}
void QtSizePolicyPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
{
if (QtProperty *prop = m_hStretchToProperty.value(property, 0)) {
QSizePolicy sp = m_values[prop];
sp.setHorizontalStretch(static_cast<uchar>(value));
q_ptr->setValue(prop, sp);
} else if (QtProperty *prop = m_vStretchToProperty.value(property, 0)) {
QSizePolicy sp = m_values[prop];
sp.setVerticalStretch(static_cast<uchar>(value));
q_ptr->setValue(prop, sp);
}
}
void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value)
{
if (QtProperty *prop = m_hPolicyToProperty.value(property, 0)) {
QSizePolicy sp = m_values[prop];
sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(value));
q_ptr->setValue(prop, sp);
} else if (QtProperty *prop = m_vPolicyToProperty.value(property, 0)) {
QSizePolicy sp = m_values[prop];
sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(value));
q_ptr->setValue(prop, sp);
}
}
void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
if (QtProperty *pointProp = m_hStretchToProperty.value(property, 0)) {
m_propertyToHStretch[pointProp] = 0;
m_hStretchToProperty.remove(property);
} else if (QtProperty *pointProp = m_vStretchToProperty.value(property, 0)) {
m_propertyToVStretch[pointProp] = 0;
m_vStretchToProperty.remove(property);
} else if (QtProperty *pointProp = m_hPolicyToProperty.value(property, 0)) {
m_propertyToHPolicy[pointProp] = 0;
m_hPolicyToProperty.remove(property);
} else if (QtProperty *pointProp = m_vPolicyToProperty.value(property, 0)) {
m_propertyToVPolicy[pointProp] = 0;
m_vPolicyToProperty.remove(property);
}
}
/**
\class QtSizePolicyPropertyManager
\brief The QtSizePolicyPropertyManager provides and manages QSizePolicy properties.
A size policy property has nested \e horizontalPolicy, \e
verticalPolicy, \e horizontalStretch and \e verticalStretch
subproperties. The top-level property's value can be retrieved
using the value() function, and set using the setValue() slot.
The subproperties are created by QtIntPropertyManager and QtEnumPropertyManager
objects. These managers can be retrieved using the subIntPropertyManager()
and subEnumPropertyManager() functions respectively. In order to provide
editing widgets for the subproperties in a property browser widget,
these managers must be associated with editor factories.
In addition, QtSizePolicyPropertyManager provides the valueChanged()
signal which is emitted whenever a property created by this
manager changes.
\sa QtAbstractPropertyManager, QtIntPropertyManager, QtEnumPropertyManager
*/
/**
\fn void QtSizePolicyPropertyManager::valueChanged(QtProperty *property, const QSizePolicy &value)
This signal is emitted whenever a property created by this manager
changes its value, passing a pointer to the \a property and the
new \a value as parameters.
\sa setValue()
*/
/**
Creates a manager with the given \a parent.
*/
QtSizePolicyPropertyManager::QtSizePolicyPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtSizePolicyPropertyManagerPrivate;
d_ptr->q_ptr = this;
d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
this, SLOT(slotIntChanged(QtProperty *, int)));
d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
this, SLOT(slotEnumChanged(QtProperty *, int)));
connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)),
this, SLOT(slotPropertyDestroyed(QtProperty *)));
connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)),
this, SLOT(slotPropertyDestroyed(QtProperty *)));
}
/**
Destroys this manager, and all the properties it has created.
*/
QtSizePolicyPropertyManager::~QtSizePolicyPropertyManager()
{
clear();
delete d_ptr;
}
/**
Returns the manager that creates the nested \e horizontalStretch
and \e verticalStretch subproperties.
In order to provide editing widgets for the mentioned subproperties
in a property browser widget, this manager must be associated with
an editor factory.
\sa QtAbstractPropertyBrowser::setFactoryForManager()
*/
QtIntPropertyManager *QtSizePolicyPropertyManager::subIntPropertyManager() const
{
return d_ptr->m_intPropertyManager;
}
/**
Returns the manager that creates the nested \e horizontalPolicy
and \e verticalPolicy subproperties.
In order to provide editing widgets for the mentioned subproperties
in a property browser widget, this manager must be associated with
an editor factory.
\sa QtAbstractPropertyBrowser::setFactoryForManager()
*/
QtEnumPropertyManager *QtSizePolicyPropertyManager::subEnumPropertyManager() const
{
return d_ptr->m_enumPropertyManager;
}
/**
Returns the given \a property's value.
If the given property is not managed by this manager, this
function returns the default size policy.
\sa setValue()
*/
QSizePolicy QtSizePolicyPropertyManager::value(const QtProperty *property) const
{
return d_ptr->m_values.value(property, QSizePolicy());
QString QtSizePolicyPropertyManager::valueText(const QtProperty *property) const
{
const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
const QSizePolicy sp = it.value();
const QtMetaEnumProvider *mep = metaEnumProvider();
const int hIndex = mep->sizePolicyToIndex(sp.horizontalPolicy());
const int vIndex = mep->sizePolicyToIndex(sp.verticalPolicy());
//! Unknown size policy on reading invalid uic3 files
const QString hPolicy = hIndex != -1 ? mep->policyEnumNames().at(hIndex) : tr("<Invalid>");
const QString vPolicy = vIndex != -1 ? mep->policyEnumNames().at(vIndex) : tr("<Invalid>");
const QString str = tr("[%1, %2, %3, %4]").arg(hPolicy, vPolicy).arg(sp.horizontalStretch()).arg(sp.verticalStretch());
return str;
\fn void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &value)
Sets the value of the given \a property to \a value. Nested
properties are updated automatically.
\sa value(), valueChanged()
*/
void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &val)
{
const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
if (it.value() == val)
return;
d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToHPolicy[property],
metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy()));
d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToVPolicy[property],
metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy()));
d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToHStretch[property],
val.horizontalStretch());
d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToVStretch[property],
val.verticalStretch());
emit propertyChanged(property);
emit valueChanged(property, val);
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
void QtSizePolicyPropertyManager::initializeProperty(QtProperty *property)
{
QSizePolicy val;
d_ptr->m_values[property] = val;
QtProperty *hPolicyProp = d_ptr->m_enumPropertyManager->addProperty();
hPolicyProp->setPropertyName(tr("Horizontal Policy"));
d_ptr->m_enumPropertyManager->setEnumNames(hPolicyProp, metaEnumProvider()->policyEnumNames());
d_ptr->m_enumPropertyManager->setValue(hPolicyProp,
metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy()));
d_ptr->m_propertyToHPolicy[property] = hPolicyProp;
d_ptr->m_hPolicyToProperty[hPolicyProp] = property;
property->addSubProperty(hPolicyProp);
QtProperty *vPolicyProp = d_ptr->m_enumPropertyManager->addProperty();
vPolicyProp->setPropertyName(tr("Vertical Policy"));
d_ptr->m_enumPropertyManager->setEnumNames(vPolicyProp, metaEnumProvider()->policyEnumNames());
d_ptr->m_enumPropertyManager->setValue(vPolicyProp,
metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy()));
d_ptr->m_propertyToVPolicy[property] = vPolicyProp;
d_ptr->m_vPolicyToProperty[vPolicyProp] = property;
property->addSubProperty(vPolicyProp);
QtProperty *hStretchProp = d_ptr->m_intPropertyManager->addProperty();
hStretchProp->setPropertyName(tr("Horizontal Stretch"));
d_ptr->m_intPropertyManager->setValue(hStretchProp, val.horizontalStretch());
d_ptr->m_intPropertyManager->setRange(hStretchProp, 0, 0xff);
d_ptr->m_propertyToHStretch[property] = hStretchProp;
d_ptr->m_hStretchToProperty[hStretchProp] = property;
property->addSubProperty(hStretchProp);
QtProperty *vStretchProp = d_ptr->m_intPropertyManager->addProperty();
vStretchProp->setPropertyName(tr("Vertical Stretch"));
d_ptr->m_intPropertyManager->setValue(vStretchProp, val.verticalStretch());
d_ptr->m_intPropertyManager->setRange(vStretchProp, 0, 0xff);
d_ptr->m_propertyToVStretch[property] = vStretchProp;
d_ptr->m_vStretchToProperty[vStretchProp] = property;
property->addSubProperty(vStretchProp);
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
void QtSizePolicyPropertyManager::uninitializeProperty(QtProperty *property)
{
QtProperty *hPolicyProp = d_ptr->m_propertyToHPolicy[property];
if (hPolicyProp) {
d_ptr->m_hPolicyToProperty.remove(hPolicyProp);
delete hPolicyProp;
}
d_ptr->m_propertyToHPolicy.remove(property);
QtProperty *vPolicyProp = d_ptr->m_propertyToVPolicy[property];
if (vPolicyProp) {
d_ptr->m_vPolicyToProperty.remove(vPolicyProp);
delete vPolicyProp;
}
d_ptr->m_propertyToVPolicy.remove(property);
QtProperty *hStretchProp = d_ptr->m_propertyToHStretch[property];
if (hStretchProp) {
d_ptr->m_hStretchToProperty.remove(hStretchProp);
delete hStretchProp;
}
d_ptr->m_propertyToHStretch.remove(property);
QtProperty *vStretchProp = d_ptr->m_propertyToVStretch[property];
if (vStretchProp) {
d_ptr->m_vStretchToProperty.remove(vStretchProp);
delete vStretchProp;
}
d_ptr->m_propertyToVStretch.remove(property);
d_ptr->m_values.remove(property);
}
// QtFontPropertyManager:
// QtFontPropertyManagerPrivate has a mechanism for reacting
// to QApplication::fontDatabaseChanged() [4.5], which is emitted
// when someone loads an application font. The signals are compressed
// using a timer with interval 0, which then causes the family
// enumeration manager to re-set its strings and index values
// for each property.
Q_GLOBAL_STATIC(QFontDatabase, fontDatabase)
QtFontPropertyManagerPrivate::QtFontPropertyManagerPrivate() :
m_settingValue(false),
m_fontDatabaseChangeTimer(0)
{
}
void QtFontPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)