1389 { |
1389 { |
1390 d_ptr->m_values.remove(property); |
1390 d_ptr->m_values.remove(property); |
1391 } |
1391 } |
1392 |
1392 |
1393 // QtBoolPropertyManager |
1393 // QtBoolPropertyManager |
1394 |
1394 // Return an icon containing a check box indicator |
1395 class QtBoolPropertyManagerPrivate |
|
1396 { |
|
1397 QtBoolPropertyManager *q_ptr; |
|
1398 Q_DECLARE_PUBLIC(QtBoolPropertyManager) |
|
1399 public: |
|
1400 |
|
1401 QMap<const QtProperty *, bool> m_values; |
|
1402 }; |
|
1403 |
|
1404 /*! |
|
1405 \class QtBoolPropertyManager |
|
1406 \internal |
|
1407 \inmodule QtDesigner |
|
1408 \since 4.4 |
|
1409 |
|
1410 \brief The QtBoolPropertyManager class provides and manages boolean properties. |
|
1411 |
|
1412 The property's value can be retrieved using the value() function, |
|
1413 and set using the setValue() slot. |
|
1414 |
|
1415 In addition, QtBoolPropertyManager provides the valueChanged() signal |
|
1416 which is emitted whenever a property created by this manager |
|
1417 changes. |
|
1418 |
|
1419 \sa QtAbstractPropertyManager, QtCheckBoxFactory |
|
1420 */ |
|
1421 |
|
1422 /*! |
|
1423 \fn void QtBoolPropertyManager::valueChanged(QtProperty *property, bool value) |
|
1424 |
|
1425 This signal is emitted whenever a property created by this manager |
|
1426 changes its value, passing a pointer to the \a property and the |
|
1427 new \a value as parameters. |
|
1428 */ |
|
1429 |
|
1430 /*! |
|
1431 Creates a manager with the given \a parent. |
|
1432 */ |
|
1433 QtBoolPropertyManager::QtBoolPropertyManager(QObject *parent) |
|
1434 : QtAbstractPropertyManager(parent), d_ptr(new QtBoolPropertyManagerPrivate) |
|
1435 { |
|
1436 d_ptr->q_ptr = this; |
|
1437 } |
|
1438 |
|
1439 /*! |
|
1440 Destroys this manager, and all the properties it has created. |
|
1441 */ |
|
1442 QtBoolPropertyManager::~QtBoolPropertyManager() |
|
1443 { |
|
1444 clear(); |
|
1445 } |
|
1446 |
|
1447 /*! |
|
1448 Returns the given \a property's value. |
|
1449 |
|
1450 If the given \a property is not managed by \e this manager, this |
|
1451 function returns false. |
|
1452 |
|
1453 \sa setValue() |
|
1454 */ |
|
1455 bool QtBoolPropertyManager::value(const QtProperty *property) const |
|
1456 { |
|
1457 return d_ptr->m_values.value(property, false); |
|
1458 } |
|
1459 |
|
1460 /*! |
|
1461 \reimp |
|
1462 */ |
|
1463 QString QtBoolPropertyManager::valueText(const QtProperty *property) const |
|
1464 { |
|
1465 const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); |
|
1466 if (it == d_ptr->m_values.constEnd()) |
|
1467 return QString(); |
|
1468 |
|
1469 static const QString trueText = tr("True"); |
|
1470 static const QString falseText = tr("False"); |
|
1471 return it.value() ? trueText : falseText; |
|
1472 } |
|
1473 |
|
1474 // Return an icon containing a check box indicator |
|
1475 static QIcon drawCheckBox(bool value) |
1395 static QIcon drawCheckBox(bool value) |
1476 { |
1396 { |
1477 QStyleOptionButton opt; |
1397 QStyleOptionButton opt; |
1478 opt.state |= value ? QStyle::State_On : QStyle::State_Off; |
1398 opt.state |= value ? QStyle::State_On : QStyle::State_Off; |
1479 opt.state |= QStyle::State_Enabled; |
1399 opt.state |= QStyle::State_Enabled; |
1499 style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter); |
1419 style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter); |
1500 } |
1420 } |
1501 return QIcon(pixmap); |
1421 return QIcon(pixmap); |
1502 } |
1422 } |
1503 |
1423 |
|
1424 class QtBoolPropertyManagerPrivate |
|
1425 { |
|
1426 QtBoolPropertyManager *q_ptr; |
|
1427 Q_DECLARE_PUBLIC(QtBoolPropertyManager) |
|
1428 public: |
|
1429 QtBoolPropertyManagerPrivate(); |
|
1430 |
|
1431 QMap<const QtProperty *, bool> m_values; |
|
1432 const QIcon m_checkedIcon; |
|
1433 const QIcon m_uncheckedIcon; |
|
1434 }; |
|
1435 |
|
1436 QtBoolPropertyManagerPrivate::QtBoolPropertyManagerPrivate() : |
|
1437 m_checkedIcon(drawCheckBox(true)), |
|
1438 m_uncheckedIcon(drawCheckBox(false)) |
|
1439 { |
|
1440 } |
|
1441 |
|
1442 /*! |
|
1443 \class QtBoolPropertyManager |
|
1444 \internal |
|
1445 \inmodule QtDesigner |
|
1446 \since 4.4 |
|
1447 |
|
1448 \brief The QtBoolPropertyManager class provides and manages boolean properties. |
|
1449 |
|
1450 The property's value can be retrieved using the value() function, |
|
1451 and set using the setValue() slot. |
|
1452 |
|
1453 In addition, QtBoolPropertyManager provides the valueChanged() signal |
|
1454 which is emitted whenever a property created by this manager |
|
1455 changes. |
|
1456 |
|
1457 \sa QtAbstractPropertyManager, QtCheckBoxFactory |
|
1458 */ |
|
1459 |
|
1460 /*! |
|
1461 \fn void QtBoolPropertyManager::valueChanged(QtProperty *property, bool value) |
|
1462 |
|
1463 This signal is emitted whenever a property created by this manager |
|
1464 changes its value, passing a pointer to the \a property and the |
|
1465 new \a value as parameters. |
|
1466 */ |
|
1467 |
|
1468 /*! |
|
1469 Creates a manager with the given \a parent. |
|
1470 */ |
|
1471 QtBoolPropertyManager::QtBoolPropertyManager(QObject *parent) |
|
1472 : QtAbstractPropertyManager(parent), d_ptr(new QtBoolPropertyManagerPrivate) |
|
1473 { |
|
1474 d_ptr->q_ptr = this; |
|
1475 } |
|
1476 |
|
1477 /*! |
|
1478 Destroys this manager, and all the properties it has created. |
|
1479 */ |
|
1480 QtBoolPropertyManager::~QtBoolPropertyManager() |
|
1481 { |
|
1482 clear(); |
|
1483 } |
|
1484 |
|
1485 /*! |
|
1486 Returns the given \a property's value. |
|
1487 |
|
1488 If the given \a property is not managed by \e this manager, this |
|
1489 function returns false. |
|
1490 |
|
1491 \sa setValue() |
|
1492 */ |
|
1493 bool QtBoolPropertyManager::value(const QtProperty *property) const |
|
1494 { |
|
1495 return d_ptr->m_values.value(property, false); |
|
1496 } |
|
1497 |
|
1498 /*! |
|
1499 \reimp |
|
1500 */ |
|
1501 QString QtBoolPropertyManager::valueText(const QtProperty *property) const |
|
1502 { |
|
1503 const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); |
|
1504 if (it == d_ptr->m_values.constEnd()) |
|
1505 return QString(); |
|
1506 |
|
1507 static const QString trueText = tr("True"); |
|
1508 static const QString falseText = tr("False"); |
|
1509 return it.value() ? trueText : falseText; |
|
1510 } |
|
1511 |
1504 /*! |
1512 /*! |
1505 \reimp |
1513 \reimp |
1506 */ |
1514 */ |
1507 QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const |
1515 QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const |
1508 { |
1516 { |
1509 const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); |
1517 const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); |
1510 if (it == d_ptr->m_values.constEnd()) |
1518 if (it == d_ptr->m_values.constEnd()) |
1511 return QIcon(); |
1519 return QIcon(); |
1512 |
1520 |
1513 static const QIcon checkedIcon = drawCheckBox(true); |
1521 return it.value() ? d_ptr->m_checkedIcon : d_ptr->m_uncheckedIcon; |
1514 static const QIcon uncheckedIcon = drawCheckBox(false); |
|
1515 return it.value() ? checkedIcon : uncheckedIcon; |
|
1516 } |
1522 } |
1517 |
1523 |
1518 /*! |
1524 /*! |
1519 \fn void QtBoolPropertyManager::setValue(QtProperty *property, bool value) |
1525 \fn void QtBoolPropertyManager::setValue(QtProperty *property, bool value) |
1520 |
1526 |
6285 d_ptr->m_values.remove(property); |
6291 d_ptr->m_values.remove(property); |
6286 } |
6292 } |
6287 |
6293 |
6288 // QtCursorPropertyManager |
6294 // QtCursorPropertyManager |
6289 |
6295 |
6290 Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase) |
6296 // Make sure icons are removed as soon as QApplication is destroyed, otherwise, |
|
6297 // handles are leaked on X11. |
|
6298 static void clearCursorDatabase(); |
|
6299 Q_GLOBAL_STATIC_WITH_INITIALIZER(QtCursorDatabase, cursorDatabase, qAddPostRoutine(clearCursorDatabase)) |
|
6300 |
|
6301 static void clearCursorDatabase() |
|
6302 { |
|
6303 cursorDatabase()->clear(); |
|
6304 } |
6291 |
6305 |
6292 class QtCursorPropertyManagerPrivate |
6306 class QtCursorPropertyManagerPrivate |
6293 { |
6307 { |
6294 QtCursorPropertyManager *q_ptr; |
6308 QtCursorPropertyManager *q_ptr; |
6295 Q_DECLARE_PUBLIC(QtCursorPropertyManager) |
6309 Q_DECLARE_PUBLIC(QtCursorPropertyManager) |