Newer
Older
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
{
if (m_settingValue)
return;
if (QtProperty *prop = m_pointSizeToProperty.value(property, 0)) {
QFont f = m_values[prop];
f.setPointSize(value);
q_ptr->setValue(prop, f);
}
}
void QtFontPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value)
{
if (m_settingValue)
return;
if (QtProperty *prop = m_familyToProperty.value(property, 0)) {
QFont f = m_values[prop];
f.setFamily(m_familyNames.at(value));
q_ptr->setValue(prop, f);
}
}
void QtFontPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool value)
{
if (m_settingValue)
return;
if (QtProperty *prop = m_boldToProperty.value(property, 0)) {
QFont f = m_values[prop];
f.setBold(value);
q_ptr->setValue(prop, f);
} else if (QtProperty *prop = m_italicToProperty.value(property, 0)) {
QFont f = m_values[prop];
f.setItalic(value);
q_ptr->setValue(prop, f);
} else if (QtProperty *prop = m_underlineToProperty.value(property, 0)) {
QFont f = m_values[prop];
f.setUnderline(value);
q_ptr->setValue(prop, f);
} else if (QtProperty *prop = m_strikeOutToProperty.value(property, 0)) {
QFont f = m_values[prop];
f.setStrikeOut(value);
q_ptr->setValue(prop, f);
} else if (QtProperty *prop = m_kerningToProperty.value(property, 0)) {
QFont f = m_values[prop];
f.setKerning(value);
q_ptr->setValue(prop, f);
}
}
void QtFontPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
if (QtProperty *pointProp = m_pointSizeToProperty.value(property, 0)) {
m_propertyToPointSize[pointProp] = 0;
m_pointSizeToProperty.remove(property);
} else if (QtProperty *pointProp = m_familyToProperty.value(property, 0)) {
m_propertyToFamily[pointProp] = 0;
m_familyToProperty.remove(property);
} else if (QtProperty *pointProp = m_boldToProperty.value(property, 0)) {
m_propertyToBold[pointProp] = 0;
m_boldToProperty.remove(property);
} else if (QtProperty *pointProp = m_italicToProperty.value(property, 0)) {
m_propertyToItalic[pointProp] = 0;
m_italicToProperty.remove(property);
} else if (QtProperty *pointProp = m_underlineToProperty.value(property, 0)) {
m_propertyToUnderline[pointProp] = 0;
m_underlineToProperty.remove(property);
} else if (QtProperty *pointProp = m_strikeOutToProperty.value(property, 0)) {
m_propertyToStrikeOut[pointProp] = 0;
m_strikeOutToProperty.remove(property);
} else if (QtProperty *pointProp = m_kerningToProperty.value(property, 0)) {
m_propertyToKerning[pointProp] = 0;
m_kerningToProperty.remove(property);
}
}
void QtFontPropertyManagerPrivate::slotFontDatabaseChanged()
{
if (!m_fontDatabaseChangeTimer) {
m_fontDatabaseChangeTimer = new QTimer(q_ptr);
m_fontDatabaseChangeTimer->setInterval(0);
m_fontDatabaseChangeTimer->setSingleShot(true);
QObject::connect(m_fontDatabaseChangeTimer, SIGNAL(timeout()), q_ptr, SLOT(slotFontDatabaseDelayedChange()));
}
if (!m_fontDatabaseChangeTimer->isActive())
m_fontDatabaseChangeTimer->start();
}
void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange()
{
typedef QMap<const QtProperty *, QtProperty *> PropertyPropertyMap;
// rescan available font names
const QStringList oldFamilies = m_familyNames;
m_familyNames = fontDatabase()->families();
// Adapt all existing properties
if (!m_propertyToFamily.empty()) {
PropertyPropertyMap::const_iterator cend = m_propertyToFamily.constEnd();
for (PropertyPropertyMap::const_iterator it = m_propertyToFamily.constBegin(); it != cend; ++it) {
QtProperty *familyProp = it.value();
const int oldIdx = m_enumPropertyManager->value(familyProp);
int newIdx = m_familyNames.indexOf(oldFamilies.at(oldIdx));
if (newIdx < 0)
newIdx = 0;
m_enumPropertyManager->setEnumNames(familyProp, m_familyNames);
m_enumPropertyManager->setValue(familyProp, newIdx);
}
}
}
/**
\class QtFontPropertyManager
\brief The QtFontPropertyManager provides and manages QFont properties.
A font property has nested \e family, \e pointSize, \e bold, \e
italic, \e underline, \e strikeOut and \e kerning 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, QtEnumPropertyManager and
QtBoolPropertyManager objects. These managers can be retrieved using the
corresponding subIntPropertyManager(), subEnumPropertyManager() and
subBoolPropertyManager() functions. In order to provide editing widgets
for the subproperties in a property browser widget, these managers
must be associated with editor factories.
In addition, QtFontPropertyManager provides the valueChanged() signal
which is emitted whenever a property created by this manager
changes.
\sa QtAbstractPropertyManager, QtEnumPropertyManager, QtIntPropertyManager, QtBoolPropertyManager
\fn void QtFontPropertyManager::valueChanged(QtProperty *property, const QFont &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.
*/
QtFontPropertyManager::QtFontPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtFontPropertyManagerPrivate;
d_ptr->q_ptr = this;
QObject::connect(qApp, SIGNAL(fontDatabaseChanged()), this, SLOT(slotFontDatabaseChanged()));
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)));
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_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)),
this, SLOT(slotPropertyDestroyed(QtProperty *)));
connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)),
this, SLOT(slotPropertyDestroyed(QtProperty *)));
connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)),
this, SLOT(slotPropertyDestroyed(QtProperty *)));
}
/**
Destroys this manager, and all the properties it has created.
*/
QtFontPropertyManager::~QtFontPropertyManager()
{
clear();
delete d_ptr;
}
/**
Returns the manager that creates the \e pointSize subproperty.
In order to provide editing widgets for the \e pointSize property
in a property browser widget, this manager must be associated
with an editor factory.
\sa QtAbstractPropertyBrowser::setFactoryForManager()
*/
QtIntPropertyManager *QtFontPropertyManager::subIntPropertyManager() const
{
return d_ptr->m_intPropertyManager;
}
/**
Returns the manager that create the \e family subproperty.
In order to provide editing widgets for the \e family property
in a property browser widget, this manager must be associated
with an editor factory.
\sa QtAbstractPropertyBrowser::setFactoryForManager()
*/
QtEnumPropertyManager *QtFontPropertyManager::subEnumPropertyManager() const
{
return d_ptr->m_enumPropertyManager;
}
/**
Returns the manager that creates the \e bold, \e italic, \e underline,
\e strikeOut and \e kerning subproperties.
In order to provide editing widgets for the mentioned properties
in a property browser widget, this manager must be associated with
an editor factory.
\sa QtAbstractPropertyBrowser::setFactoryForManager()
*/
QtBoolPropertyManager *QtFontPropertyManager::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 a font object that uses the application's default
font.
\sa setValue()
*/
QFont QtFontPropertyManager::value(const QtProperty *property) const
{
return d_ptr->m_values.value(property, QFont());
QString QtFontPropertyManager::valueText(const QtProperty *property) const
{
const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
return QtPropertyBrowserUtils::fontValueText(it.value());
QIcon QtFontPropertyManager::valueIcon(const QtProperty *property) const
{
const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QIcon();
return QtPropertyBrowserUtils::fontValueIcon(it.value());
\fn void QtFontPropertyManager::setValue(QtProperty *property, const QFont &value)
Sets the value of the given \a property to \a value. Nested
properties are updated automatically.
\sa value(), valueChanged()
*/
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
void QtFontPropertyManager::setValue(QtProperty *property, const QFont &val)
{
const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
const QFont oldVal = it.value();
if (oldVal == val && oldVal.resolve() == val.resolve())
return;
it.value() = val;
int idx = d_ptr->m_familyNames.indexOf(val.family());
if (idx == -1)
idx = 0;
bool settingValue = d_ptr->m_settingValue;
d_ptr->m_settingValue = true;
d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToFamily[property], idx);
d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToPointSize[property], val.pointSize());
d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToBold[property], val.bold());
d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToItalic[property], val.italic());
d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToUnderline[property], val.underline());
d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToStrikeOut[property], val.strikeOut());
d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToKerning[property], val.kerning());
d_ptr->m_settingValue = settingValue;
emit propertyChanged(property);
emit valueChanged(property, val);
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
void QtFontPropertyManager::initializeProperty(QtProperty *property)
{
QFont val;
d_ptr->m_values[property] = val;
QtProperty *familyProp = d_ptr->m_enumPropertyManager->addProperty();
familyProp->setPropertyName(tr("Family"));
if (d_ptr->m_familyNames.empty())
d_ptr->m_familyNames = fontDatabase()->families();
d_ptr->m_enumPropertyManager->setEnumNames(familyProp, d_ptr->m_familyNames);
int idx = d_ptr->m_familyNames.indexOf(val.family());
if (idx == -1)
idx = 0;
d_ptr->m_enumPropertyManager->setValue(familyProp, idx);
d_ptr->m_propertyToFamily[property] = familyProp;
d_ptr->m_familyToProperty[familyProp] = property;
property->addSubProperty(familyProp);
QtProperty *pointSizeProp = d_ptr->m_intPropertyManager->addProperty();
pointSizeProp->setPropertyName(tr("Point Size"));
d_ptr->m_intPropertyManager->setValue(pointSizeProp, val.pointSize());
d_ptr->m_intPropertyManager->setMinimum(pointSizeProp, 1);
d_ptr->m_propertyToPointSize[property] = pointSizeProp;
d_ptr->m_pointSizeToProperty[pointSizeProp] = property;
property->addSubProperty(pointSizeProp);
QtProperty *boldProp = d_ptr->m_boolPropertyManager->addProperty();
boldProp->setPropertyName(tr("Bold"));
d_ptr->m_boolPropertyManager->setValue(boldProp, val.bold());
d_ptr->m_propertyToBold[property] = boldProp;
d_ptr->m_boldToProperty[boldProp] = property;
property->addSubProperty(boldProp);
QtProperty *italicProp = d_ptr->m_boolPropertyManager->addProperty();
italicProp->setPropertyName(tr("Italic"));
d_ptr->m_boolPropertyManager->setValue(italicProp, val.italic());
d_ptr->m_propertyToItalic[property] = italicProp;
d_ptr->m_italicToProperty[italicProp] = property;
property->addSubProperty(italicProp);
QtProperty *underlineProp = d_ptr->m_boolPropertyManager->addProperty();
underlineProp->setPropertyName(tr("Underline"));
d_ptr->m_boolPropertyManager->setValue(underlineProp, val.underline());
d_ptr->m_propertyToUnderline[property] = underlineProp;
d_ptr->m_underlineToProperty[underlineProp] = property;
property->addSubProperty(underlineProp);
QtProperty *strikeOutProp = d_ptr->m_boolPropertyManager->addProperty();
strikeOutProp->setPropertyName(tr("Strikeout"));
d_ptr->m_boolPropertyManager->setValue(strikeOutProp, val.strikeOut());
d_ptr->m_propertyToStrikeOut[property] = strikeOutProp;
d_ptr->m_strikeOutToProperty[strikeOutProp] = property;
property->addSubProperty(strikeOutProp);
QtProperty *kerningProp = d_ptr->m_boolPropertyManager->addProperty();
kerningProp->setPropertyName(tr("Kerning"));
d_ptr->m_boolPropertyManager->setValue(kerningProp, val.kerning());
d_ptr->m_propertyToKerning[property] = kerningProp;
d_ptr->m_kerningToProperty[kerningProp] = property;
property->addSubProperty(kerningProp);
void QtFontPropertyManager::uninitializeProperty(QtProperty *property)
{
QtProperty *familyProp = d_ptr->m_propertyToFamily[property];
if (familyProp) {
d_ptr->m_familyToProperty.remove(familyProp);
delete familyProp;
}
d_ptr->m_propertyToFamily.remove(property);
QtProperty *pointSizeProp = d_ptr->m_propertyToPointSize[property];
if (pointSizeProp) {
d_ptr->m_pointSizeToProperty.remove(pointSizeProp);
delete pointSizeProp;
}
d_ptr->m_propertyToPointSize.remove(property);
QtProperty *boldProp = d_ptr->m_propertyToBold[property];
if (boldProp) {
d_ptr->m_boldToProperty.remove(boldProp);
delete boldProp;
}
d_ptr->m_propertyToBold.remove(property);
QtProperty *italicProp = d_ptr->m_propertyToItalic[property];
if (italicProp) {
d_ptr->m_italicToProperty.remove(italicProp);
delete italicProp;
}
d_ptr->m_propertyToItalic.remove(property);
QtProperty *underlineProp = d_ptr->m_propertyToUnderline[property];
if (underlineProp) {
d_ptr->m_underlineToProperty.remove(underlineProp);
delete underlineProp;
}
d_ptr->m_propertyToUnderline.remove(property);
QtProperty *strikeOutProp = d_ptr->m_propertyToStrikeOut[property];
if (strikeOutProp) {
d_ptr->m_strikeOutToProperty.remove(strikeOutProp);
delete strikeOutProp;
}
d_ptr->m_propertyToStrikeOut.remove(property);
QtProperty *kerningProp = d_ptr->m_propertyToKerning[property];
if (kerningProp) {
d_ptr->m_kerningToProperty.remove(kerningProp);
delete kerningProp;
}
d_ptr->m_propertyToKerning.remove(property);
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
d_ptr->m_values.remove(property);
}
// QtColorPropertyManager
void QtColorPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
{
if (QtProperty *prop = m_rToProperty.value(property, 0)) {
QColor c = m_values[prop];
c.setRed(value);
q_ptr->setValue(prop, c);
} else if (QtProperty *prop = m_gToProperty.value(property, 0)) {
QColor c = m_values[prop];
c.setGreen(value);
q_ptr->setValue(prop, c);
} else if (QtProperty *prop = m_bToProperty.value(property, 0)) {
QColor c = m_values[prop];
c.setBlue(value);
q_ptr->setValue(prop, c);
} else if (QtProperty *prop = m_aToProperty.value(property, 0)) {
QColor c = m_values[prop];
c.setAlpha(value);
q_ptr->setValue(prop, c);
}
}
void QtColorPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
if (QtProperty *pointProp = m_rToProperty.value(property, 0)) {
m_propertyToR[pointProp] = 0;
m_rToProperty.remove(property);
} else if (QtProperty *pointProp = m_gToProperty.value(property, 0)) {
m_propertyToG[pointProp] = 0;
m_gToProperty.remove(property);
} else if (QtProperty *pointProp = m_bToProperty.value(property, 0)) {
m_propertyToB[pointProp] = 0;
m_bToProperty.remove(property);
} else if (QtProperty *pointProp = m_aToProperty.value(property, 0)) {
m_propertyToA[pointProp] = 0;
m_aToProperty.remove(property);
}
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
}
/**
\class QtColorPropertyManager
\brief The QtColorPropertyManager provides and manages QColor properties.
A color property has nested \e red, \e green and \e blue
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 a QtIntPropertyManager object. This
manager can be retrieved using the subIntPropertyManager() 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, QtColorPropertyManager provides the valueChanged() signal
which is emitted whenever a property created by this manager
changes.
\sa QtAbstractPropertyManager, QtAbstractPropertyBrowser, QtIntPropertyManager
\fn void QtColorPropertyManager::valueChanged(QtProperty *property, const QColor &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.
*/
QtColorPropertyManager::QtColorPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtColorPropertyManagerPrivate;
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)));
connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)),
this, SLOT(slotPropertyDestroyed(QtProperty *)));
}
/**
Destroys this manager, and all the properties it has created.
*/
QtColorPropertyManager::~QtColorPropertyManager()
{
clear();
delete d_ptr;
}
/**
Returns the manager that produces the nested \e red, \e green and
\e blue subproperties.
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()
*/
QtIntPropertyManager *QtColorPropertyManager::subIntPropertyManager() const
{
return d_ptr->m_intPropertyManager;
}
/**
Returns the given \a property's value.
If the given \a property is not managed by \e this manager, this
function returns an invalid color.
\sa setValue()
*/
QColor QtColorPropertyManager::value(const QtProperty *property) const
{
return d_ptr->m_values.value(property, QColor());
QString QtColorPropertyManager::valueText(const QtProperty *property) const
{
const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
return QtPropertyBrowserUtils::colorValueText(it.value());
QIcon QtColorPropertyManager::valueIcon(const QtProperty *property) const
{
const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QIcon();
return QtPropertyBrowserUtils::brushValueIcon(QBrush(it.value()));
\fn void QtColorPropertyManager::setValue(QtProperty *property, const QColor &value)
Sets the value of the given \a property to \a value. Nested
properties are updated automatically.
\sa value(), valueChanged()
*/
void QtColorPropertyManager::setValue(QtProperty *property, const QColor &val)
{
const QtColorPropertyManagerPrivate::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_intPropertyManager->setValue(d_ptr->m_propertyToR[property], val.red());
d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToG[property], val.green());
d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToB[property], val.blue());
d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToA[property], val.alpha());
emit propertyChanged(property);
emit valueChanged(property, val);
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
void QtColorPropertyManager::initializeProperty(QtProperty *property)
{
QColor val;
d_ptr->m_values[property] = val;
QtProperty *rProp = d_ptr->m_intPropertyManager->addProperty();
rProp->setPropertyName(tr("Red"));
d_ptr->m_intPropertyManager->setValue(rProp, val.red());
d_ptr->m_intPropertyManager->setRange(rProp, 0, 0xFF);
d_ptr->m_propertyToR[property] = rProp;
d_ptr->m_rToProperty[rProp] = property;
property->addSubProperty(rProp);
QtProperty *gProp = d_ptr->m_intPropertyManager->addProperty();
gProp->setPropertyName(tr("Green"));
d_ptr->m_intPropertyManager->setValue(gProp, val.green());
d_ptr->m_intPropertyManager->setRange(gProp, 0, 0xFF);
d_ptr->m_propertyToG[property] = gProp;
d_ptr->m_gToProperty[gProp] = property;
property->addSubProperty(gProp);
QtProperty *bProp = d_ptr->m_intPropertyManager->addProperty();
bProp->setPropertyName(tr("Blue"));
d_ptr->m_intPropertyManager->setValue(bProp, val.blue());
d_ptr->m_intPropertyManager->setRange(bProp, 0, 0xFF);
d_ptr->m_propertyToB[property] = bProp;
d_ptr->m_bToProperty[bProp] = property;
property->addSubProperty(bProp);
QtProperty *aProp = d_ptr->m_intPropertyManager->addProperty();
aProp->setPropertyName(tr("Alpha"));
d_ptr->m_intPropertyManager->setValue(aProp, val.alpha());
d_ptr->m_intPropertyManager->setRange(aProp, 0, 0xFF);
d_ptr->m_propertyToA[property] = aProp;
d_ptr->m_aToProperty[aProp] = property;
property->addSubProperty(aProp);
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
void QtColorPropertyManager::uninitializeProperty(QtProperty *property)
{
QtProperty *rProp = d_ptr->m_propertyToR[property];
if (rProp) {
d_ptr->m_rToProperty.remove(rProp);
delete rProp;
}
d_ptr->m_propertyToR.remove(property);
QtProperty *gProp = d_ptr->m_propertyToG[property];
if (gProp) {
d_ptr->m_gToProperty.remove(gProp);
delete gProp;
}
d_ptr->m_propertyToG.remove(property);
QtProperty *bProp = d_ptr->m_propertyToB[property];
if (bProp) {
d_ptr->m_bToProperty.remove(bProp);
delete bProp;
}
d_ptr->m_propertyToB.remove(property);
QtProperty *aProp = d_ptr->m_propertyToA[property];
if (aProp) {
d_ptr->m_aToProperty.remove(aProp);
delete aProp;
}
d_ptr->m_propertyToA.remove(property);
d_ptr->m_values.remove(property);
}
// QtCursorPropertyManager
Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase)
class QtCursorPropertyManagerPrivate
{
QtCursorPropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtCursorPropertyManager)
typedef QMap<const QtProperty *, QCursor> PropertyValueMap;
PropertyValueMap m_values;
};
/**
\class QtCursorPropertyManager
\brief The QtCursorPropertyManager provides and manages QCursor properties.
A cursor property has a current value which can be
retrieved using the value() function, and set using the setValue()
slot. In addition, QtCursorPropertyManager provides the
valueChanged() signal which is emitted whenever a property created
by this manager changes.
\sa QtAbstractPropertyManager
*/
/**
\fn void QtCursorPropertyManager::valueChanged(QtProperty *property, const QCursor &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.
*/
QtCursorPropertyManager::QtCursorPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtCursorPropertyManagerPrivate;
d_ptr->q_ptr = this;
}
/**
Destroys this manager, and all the properties it has created.
*/
QtCursorPropertyManager::~QtCursorPropertyManager()
{
clear();
delete d_ptr;
}
/**
Returns the given \a property's value.
If the given \a property is not managed by this manager, this
function returns a default QCursor object.
\sa setValue()
*/
#ifndef QT_NO_CURSOR
QCursor QtCursorPropertyManager::value(const QtProperty *property) const
{
return d_ptr->m_values.value(property, QCursor());
}
#endif
/**
\reimp
*/
QString QtCursorPropertyManager::valueText(const QtProperty *property) const
{
const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
return cursorDatabase()->cursorToShapeName(it.value());
QIcon QtCursorPropertyManager::valueIcon(const QtProperty *property) const
{
const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QIcon();
return cursorDatabase()->cursorToShapeIcon(it.value());
\fn void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value)
Sets the value of the given \a property to \a value.
\sa value(), valueChanged()
*/
void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value)
{
const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
if (it.value().shape() == value.shape() && value.shape() != Qt::BitmapCursor)
return;
emit propertyChanged(property);
emit valueChanged(property, value);
#endif
}
/**
\reimp
*/
void QtCursorPropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = QCursor();
#endif
}
/**
\reimp
*/
void QtCursorPropertyManager::uninitializeProperty(QtProperty *property)
{
d_ptr->m_values.remove(property);
}
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif