src/declarative/graphicsitems/qdeclarativeitem.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    67 
    67 
    68 QT_BEGIN_NAMESPACE
    68 QT_BEGIN_NAMESPACE
    69 
    69 
    70 /*!
    70 /*!
    71     \qmlclass Transform QGraphicsTransform
    71     \qmlclass Transform QGraphicsTransform
       
    72     \ingroup qml-transform-elements
    72     \since 4.7
    73     \since 4.7
    73     \brief The Transform elements provide a way of building advanced transformations on Items.
    74     \brief The Transform elements provide a way of building advanced transformations on Items.
    74 
    75 
    75     The Transform element is a base type which cannot be instantiated directly.
    76     The Transform element is a base type which cannot be instantiated directly.
    76     The following concrete Transform types are available:
    77     The following concrete Transform types are available:
    88     one at a time.
    89     one at a time.
    89 */
    90 */
    90 
    91 
    91 /*!
    92 /*!
    92     \qmlclass Translate QDeclarativeTranslate
    93     \qmlclass Translate QDeclarativeTranslate
       
    94     \ingroup qml-transform-elements
    93     \since 4.7
    95     \since 4.7
    94     \brief The Translate object provides a way to move an Item without changing its x or y properties.
    96     \brief The Translate object provides a way to move an Item without changing its x or y properties.
    95 
    97 
    96     The Translate object provides independent control over position in addition to the Item's x and y properties.
    98     The Translate object provides independent control over position in addition to the Item's x and y properties.
    97 
    99 
   129     The translation along the Y axis.
   131     The translation along the Y axis.
   130 */
   132 */
   131 
   133 
   132 /*!
   134 /*!
   133     \qmlclass Scale QGraphicsScale
   135     \qmlclass Scale QGraphicsScale
       
   136     \ingroup qml-transform-elements
   134     \since 4.7
   137     \since 4.7
   135     \brief The Scale element provides a way to scale an Item.
   138     \brief The Scale element provides a way to scale an Item.
   136 
   139 
   137     The Scale element gives more control over scaling than using \l Item's \l{Item::scale}{scale} property. Specifically,
   140     The Scale element gives more control over scaling than using \l Item's \l{Item::scale}{scale} property. Specifically,
   138     it allows a different scale for the x and y axes, and allows the scale to be relative to an
   141     it allows a different scale for the x and y axes, and allows the scale to be relative to an
   170     The scaling factor for the Y axis.
   173     The scaling factor for the Y axis.
   171 */
   174 */
   172 
   175 
   173 /*!
   176 /*!
   174     \qmlclass Rotation QGraphicsRotation
   177     \qmlclass Rotation QGraphicsRotation
       
   178     \ingroup qml-transform-elements
   175     \since 4.7
   179     \since 4.7
   176     \brief The Rotation object provides a way to rotate an Item.
   180     \brief The Rotation object provides a way to rotate an Item.
   177 
   181 
   178     The Rotation object gives more control over rotation than using \l Item's \l{Item::rotation}{rotation} property.
   182     The Rotation object gives more control over rotation than using \l Item's \l{Item::rotation}{rotation} property.
   179     Specifically, it allows (z axis) rotation to be relative to an arbitrary point.
   183     Specifically, it allows (z axis) rotation to be relative to an arbitrary point.
   223     \qmlproperty real Rotation::angle
   227     \qmlproperty real Rotation::angle
   224 
   228 
   225     The angle to rotate, in degrees clockwise.
   229     The angle to rotate, in degrees clockwise.
   226 */
   230 */
   227 
   231 
   228 /*!
       
   229     \internal
       
   230     \class QDeclarativeContents
       
   231     \brief The QDeclarativeContents class gives access to the height and width of an item's contents.
       
   232 
       
   233 */
       
   234 QDeclarativeContents::QDeclarativeContents(QDeclarativeItem *item) : m_item(item), m_x(0), m_y(0), m_width(0), m_height(0)
   232 QDeclarativeContents::QDeclarativeContents(QDeclarativeItem *item) : m_item(item), m_x(0), m_y(0), m_width(0), m_height(0)
   235 {
   233 {
   236     //### optimize
   234     //### optimize
   237     connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF)));
   235     connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF)));
   238 }
   236 }
   417 }
   415 }
   418 
   416 
   419 
   417 
   420 /*!
   418 /*!
   421     \qmlclass KeyNavigation QDeclarativeKeyNavigationAttached
   419     \qmlclass KeyNavigation QDeclarativeKeyNavigationAttached
       
   420     \ingroup qml-basic-interaction-elements
   422     \since 4.7
   421     \since 4.7
   423     \brief The KeyNavigation attached property supports key navigation by arrow keys.
   422     \brief The KeyNavigation attached property supports key navigation by arrow keys.
   424 
   423 
   425     It is common in key-based UIs to use arrow keys to navigate
   424     It is common in key-based UIs to use arrow keys to navigate
   426     between focussed items.  The KeyNavigation property provides a
   425     between focused items.  The KeyNavigation property provides a
   427     convenient way of specifying which item will gain focus
   426     convenient way of specifying which item will gain focus
   428     when an arrow key is pressed.  The following example provides
   427     when an arrow key is pressed.  The following example provides
   429     key navigation for a 2x2 grid of items.
   428     key navigation for a 2x2 grid of items.
   430 
   429 
   431     \code
   430     \code
   509 }
   508 }
   510 
   509 
   511 void QDeclarativeKeyNavigationAttached::setLeft(QDeclarativeItem *i)
   510 void QDeclarativeKeyNavigationAttached::setLeft(QDeclarativeItem *i)
   512 {
   511 {
   513     Q_D(QDeclarativeKeyNavigationAttached);
   512     Q_D(QDeclarativeKeyNavigationAttached);
       
   513     if (d->left == i)
       
   514         return;
   514     d->left = i;
   515     d->left = i;
   515     emit changed();
   516     emit leftChanged();
   516 }
   517 }
   517 
   518 
   518 QDeclarativeItem *QDeclarativeKeyNavigationAttached::right() const
   519 QDeclarativeItem *QDeclarativeKeyNavigationAttached::right() const
   519 {
   520 {
   520     Q_D(const QDeclarativeKeyNavigationAttached);
   521     Q_D(const QDeclarativeKeyNavigationAttached);
   522 }
   523 }
   523 
   524 
   524 void QDeclarativeKeyNavigationAttached::setRight(QDeclarativeItem *i)
   525 void QDeclarativeKeyNavigationAttached::setRight(QDeclarativeItem *i)
   525 {
   526 {
   526     Q_D(QDeclarativeKeyNavigationAttached);
   527     Q_D(QDeclarativeKeyNavigationAttached);
       
   528     if (d->right == i)
       
   529         return;
   527     d->right = i;
   530     d->right = i;
   528     emit changed();
   531     emit rightChanged();
   529 }
   532 }
   530 
   533 
   531 QDeclarativeItem *QDeclarativeKeyNavigationAttached::up() const
   534 QDeclarativeItem *QDeclarativeKeyNavigationAttached::up() const
   532 {
   535 {
   533     Q_D(const QDeclarativeKeyNavigationAttached);
   536     Q_D(const QDeclarativeKeyNavigationAttached);
   535 }
   538 }
   536 
   539 
   537 void QDeclarativeKeyNavigationAttached::setUp(QDeclarativeItem *i)
   540 void QDeclarativeKeyNavigationAttached::setUp(QDeclarativeItem *i)
   538 {
   541 {
   539     Q_D(QDeclarativeKeyNavigationAttached);
   542     Q_D(QDeclarativeKeyNavigationAttached);
       
   543     if (d->up == i)
       
   544         return;
   540     d->up = i;
   545     d->up = i;
   541     emit changed();
   546     emit upChanged();
   542 }
   547 }
   543 
   548 
   544 QDeclarativeItem *QDeclarativeKeyNavigationAttached::down() const
   549 QDeclarativeItem *QDeclarativeKeyNavigationAttached::down() const
   545 {
   550 {
   546     Q_D(const QDeclarativeKeyNavigationAttached);
   551     Q_D(const QDeclarativeKeyNavigationAttached);
   548 }
   553 }
   549 
   554 
   550 void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i)
   555 void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i)
   551 {
   556 {
   552     Q_D(QDeclarativeKeyNavigationAttached);
   557     Q_D(QDeclarativeKeyNavigationAttached);
       
   558     if (d->down == i)
       
   559         return;
   553     d->down = i;
   560     d->down = i;
   554     emit changed();
   561     emit downChanged();
   555 }
   562 }
   556 
   563 
   557 QDeclarativeItem *QDeclarativeKeyNavigationAttached::tab() const
   564 QDeclarativeItem *QDeclarativeKeyNavigationAttached::tab() const
   558 {
   565 {
   559     Q_D(const QDeclarativeKeyNavigationAttached);
   566     Q_D(const QDeclarativeKeyNavigationAttached);
   561 }
   568 }
   562 
   569 
   563 void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i)
   570 void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i)
   564 {
   571 {
   565     Q_D(QDeclarativeKeyNavigationAttached);
   572     Q_D(QDeclarativeKeyNavigationAttached);
       
   573     if (d->tab == i)
       
   574         return;
   566     d->tab = i;
   575     d->tab = i;
   567     emit changed();
   576     emit tabChanged();
   568 }
   577 }
   569 
   578 
   570 QDeclarativeItem *QDeclarativeKeyNavigationAttached::backtab() const
   579 QDeclarativeItem *QDeclarativeKeyNavigationAttached::backtab() const
   571 {
   580 {
   572     Q_D(const QDeclarativeKeyNavigationAttached);
   581     Q_D(const QDeclarativeKeyNavigationAttached);
   574 }
   583 }
   575 
   584 
   576 void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i)
   585 void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i)
   577 {
   586 {
   578     Q_D(QDeclarativeKeyNavigationAttached);
   587     Q_D(QDeclarativeKeyNavigationAttached);
       
   588     if (d->backtab == i)
       
   589         return;
   579     d->backtab = i;
   590     d->backtab = i;
   580     emit changed();
   591     emit backtabChanged();
   581 }
   592 }
   582 
   593 
   583 /*!
   594 /*!
   584     \qmlproperty enumeration KeyNavigation::priority
   595     \qmlproperty enumeration KeyNavigation::priority
   585 
   596 
   711     if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post);
   722     if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post);
   712 }
   723 }
   713 
   724 
   714 /*!
   725 /*!
   715     \qmlclass Keys QDeclarativeKeysAttached
   726     \qmlclass Keys QDeclarativeKeysAttached
       
   727     \ingroup qml-basic-interaction-elements
   716     \since 4.7
   728     \since 4.7
   717     \brief The Keys attached property provides key handling to Items.
   729     \brief The Keys attached property provides key handling to Items.
   718 
   730 
   719     All visual primitives support key handling via the \e Keys
   731     All visual primitives support key handling via the \e Keys
   720     attached property.  Keys can be handled via the \e onPressed
   732     attached property.  Keys can be handled via the \e onPressed
  1296 
  1308 
  1297 */
  1309 */
  1298 
  1310 
  1299 /*!
  1311 /*!
  1300     \qmlclass Item QDeclarativeItem
  1312     \qmlclass Item QDeclarativeItem
       
  1313     \ingroup qml-basic-visual-elements
  1301     \since 4.7
  1314     \since 4.7
  1302     \brief The Item is the most basic of all visual items in QML.
  1315     \brief The Item is the most basic of all visual items in QML.
  1303 
  1316 
  1304     All visual items in Qt Declarative inherit from Item.  Although Item
  1317     All visual items in Qt Declarative inherit from Item.  Although Item
  1305     has no visual appearance, it defines all the properties that are
  1318     has no visual appearance, it defines all the properties that are
  1415     \internal
  1428     \internal
  1416 */
  1429 */
  1417 
  1430 
  1418 /*! \fn void QDeclarativeItem::transformOriginChanged(TransformOrigin)
  1431 /*! \fn void QDeclarativeItem::transformOriginChanged(TransformOrigin)
  1419   \internal
  1432   \internal
  1420 */
       
  1421 
       
  1422 /*!
       
  1423     \fn void QDeclarativeItem::childrenChanged()
       
  1424     \internal
       
  1425 */
  1433 */
  1426 
  1434 
  1427 /*!
  1435 /*!
  1428     \fn void QDeclarativeItem::focusChanged(bool)
  1436     \fn void QDeclarativeItem::focusChanged(bool)
  1429     \internal
  1437     \internal
  1712 
  1720 
  1713     data is a behind-the-scenes property: you should never need to explicitly
  1721     data is a behind-the-scenes property: you should never need to explicitly
  1714     specify it.
  1722     specify it.
  1715  */
  1723  */
  1716 
  1724 
  1717 /*! \internal */
       
  1718 QDeclarativeListProperty<QObject> QDeclarativeItemPrivate::data()
  1725 QDeclarativeListProperty<QObject> QDeclarativeItemPrivate::data()
  1719 {
  1726 {
  1720     return QDeclarativeListProperty<QObject>(q_func(), 0, QDeclarativeItemPrivate::data_append);
  1727     return QDeclarativeListProperty<QObject>(q_func(), 0, QDeclarativeItemPrivate::data_append);
  1721 }
  1728 }
  1722 
  1729 
  1874         } else {
  1881         } else {
  1875             d->transformOriginDirty = true;
  1882             d->transformOriginDirty = true;
  1876         }
  1883         }
  1877     }
  1884     }
  1878 
  1885 
       
  1886     for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
       
  1887         const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
       
  1888         if (change.types & QDeclarativeItemPrivate::Geometry)
       
  1889             change.listener->itemGeometryChanged(this, newGeometry, oldGeometry);
       
  1890     }
       
  1891 
  1879     if (newGeometry.x() != oldGeometry.x())
  1892     if (newGeometry.x() != oldGeometry.x())
  1880         emit xChanged();
  1893         emit xChanged();
  1881     if (newGeometry.width() != oldGeometry.width())
  1894     if (newGeometry.width() != oldGeometry.width())
  1882         emit widthChanged();
  1895         emit widthChanged();
  1883     if (newGeometry.y() != oldGeometry.y())
  1896     if (newGeometry.y() != oldGeometry.y())
  1884         emit yChanged();
  1897         emit yChanged();
  1885     if (newGeometry.height() != oldGeometry.height())
  1898     if (newGeometry.height() != oldGeometry.height())
  1886         emit heightChanged();
  1899         emit heightChanged();
  1887 
       
  1888     for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
       
  1889         const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
       
  1890         if (change.types & QDeclarativeItemPrivate::Geometry)
       
  1891             change.listener->itemGeometryChanged(this, newGeometry, oldGeometry);
       
  1892     }
       
  1893 }
  1900 }
  1894 
  1901 
  1895 void QDeclarativeItemPrivate::removeItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
  1902 void QDeclarativeItemPrivate::removeItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
  1896 {
  1903 {
  1897     ChangeListener change(listener, types);
  1904     ChangeListener change(listener, types);
  2397 void QDeclarativeItemPrivate::focusChanged(bool flag)
  2404 void QDeclarativeItemPrivate::focusChanged(bool flag)
  2398 {
  2405 {
  2399     Q_Q(QDeclarativeItem);
  2406     Q_Q(QDeclarativeItem);
  2400     if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent)
  2407     if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent)
  2401         emit q->activeFocusChanged(flag);   //see also QDeclarativeItemPrivate::subFocusItemChange()
  2408         emit q->activeFocusChanged(flag);   //see also QDeclarativeItemPrivate::subFocusItemChange()
  2402 
  2409     emit q->focusChanged(flag);
  2403     bool inScope = false;
  2410 }
  2404     QGraphicsItem *p = parent;
  2411 
  2405     while (p) {
       
  2406         if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
       
  2407             inScope = true;
       
  2408             break;
       
  2409         }
       
  2410         p = p->parentItem();
       
  2411     }
       
  2412     if (!inScope)
       
  2413         emit q->focusChanged(flag);
       
  2414 }
       
  2415 
       
  2416 /*! \internal */
       
  2417 QDeclarativeListProperty<QObject> QDeclarativeItemPrivate::resources()
  2412 QDeclarativeListProperty<QObject> QDeclarativeItemPrivate::resources()
  2418 {
  2413 {
  2419     return QDeclarativeListProperty<QObject>(q_func(), 0, QDeclarativeItemPrivate::resources_append,
  2414     return QDeclarativeListProperty<QObject>(q_func(), 0, QDeclarativeItemPrivate::resources_append,
  2420                                              QDeclarativeItemPrivate::resources_count,
  2415                                              QDeclarativeItemPrivate::resources_count,
  2421                                              QDeclarativeItemPrivate::resources_at);
  2416                                              QDeclarativeItemPrivate::resources_at);
  2436   \endqml
  2431   \endqml
  2437 
  2432 
  2438   \sa {qmlstate}{States}
  2433   \sa {qmlstate}{States}
  2439 */
  2434 */
  2440 
  2435 
  2441 /*! \internal */
       
  2442 QDeclarativeListProperty<QDeclarativeState> QDeclarativeItemPrivate::states()
  2436 QDeclarativeListProperty<QDeclarativeState> QDeclarativeItemPrivate::states()
  2443 {
  2437 {
  2444     return _states()->statesProperty();
  2438     return _states()->statesProperty();
  2445 }
  2439 }
  2446 
  2440 
  2456       ...
  2450       ...
  2457     ]
  2451     ]
  2458   }
  2452   }
  2459   \endqml
  2453   \endqml
  2460 
  2454 
  2461   \sa {state-transitions}{Transitions}
  2455   \sa {qdeclarativeanimation.html#transitions}{QML Transitions}
  2462 */
  2456 */
  2463 
  2457 
  2464 
  2458 
  2465 /*! \internal */
       
  2466 QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItemPrivate::transitions()
  2459 QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItemPrivate::transitions()
  2467 {
  2460 {
  2468     return _states()->transitionsProperty();
  2461     return _states()->transitionsProperty();
  2469 }
  2462 }
  2470 
  2463 
  2480 
  2473 
  2481   \qml
  2474   \qml
  2482   Item {
  2475   Item {
  2483     filter: [
  2476     filter: [
  2484       Blur { ... },
  2477       Blur { ... },
  2485       Relection { ... }
  2478       Reflection { ... }
  2486       ...
  2479       ...
  2487     ]
  2480     ]
  2488   }
  2481   }
  2489   \endqml
  2482   \endqml
  2490 */
  2483 */
  2502 /*!
  2495 /*!
  2503   \property QDeclarativeItem::clip
  2496   \property QDeclarativeItem::clip
  2504   This property holds whether clipping is enabled.
  2497   This property holds whether clipping is enabled.
  2505 
  2498 
  2506   if clipping is enabled, an item will clip its own painting, as well
  2499   if clipping is enabled, an item will clip its own painting, as well
  2507   as the painting of its children, to its bounding rectangle.
  2500   as the painting of its children, to its bounding rectangle. If you set
       
  2501   clipping during an item's paint operation, remember to re-set it to 
       
  2502   prevent clipping the rest of your scene.
  2508 
  2503 
  2509   Non-rectangular clipping regions are not supported for performance reasons.
  2504   Non-rectangular clipping regions are not supported for performance reasons.
  2510 */
  2505 */
  2511 
  2506 
  2512 /*!
  2507 /*!
  2531   item to its base state by setting its current state to \c ''.
  2526   item to its base state by setting its current state to \c ''.
  2532 
  2527 
  2533   \sa {qmlstates}{States}
  2528   \sa {qmlstates}{States}
  2534 */
  2529 */
  2535 
  2530 
  2536 /*! \internal */
       
  2537 QString QDeclarativeItemPrivate::state() const
  2531 QString QDeclarativeItemPrivate::state() const
  2538 {
  2532 {
  2539     if (!_stateGroup)
  2533     if (!_stateGroup)
  2540         return QString();
  2534         return QString();
  2541     else
  2535     else
  2542         return _stateGroup->state();
  2536         return _stateGroup->state();
  2543 }
  2537 }
  2544 
  2538 
  2545 /*! \internal */
       
  2546 void QDeclarativeItemPrivate::setState(const QString &state)
  2539 void QDeclarativeItemPrivate::setState(const QString &state)
  2547 {
  2540 {
  2548     _states()->setState(state);
  2541     _states()->setState(state);
  2549 }
  2542 }
  2550 
  2543 
  2726                 }
  2719                 }
  2727             }
  2720             }
  2728         }
  2721         }
  2729         break;
  2722         break;
  2730     case ItemChildAddedChange:
  2723     case ItemChildAddedChange:
  2731         if (d->_contents)
  2724         if (d->_contents && d->componentComplete)
  2732             d->_contents->childAdded(qobject_cast<QDeclarativeItem*>(
  2725             d->_contents->childAdded(qobject_cast<QDeclarativeItem*>(
  2733                     value.value<QGraphicsItem*>()));
  2726                     value.value<QGraphicsItem*>()));
  2734         break;
  2727         break;
  2735     case ItemChildRemovedChange:
  2728     case ItemChildRemovedChange:
  2736         if (d->_contents)
  2729         if (d->_contents && d->componentComplete)
  2737             d->_contents->childRemoved(qobject_cast<QDeclarativeItem*>(
  2730             d->_contents->childRemoved(qobject_cast<QDeclarativeItem*>(
  2738                     value.value<QGraphicsItem*>()));
  2731                     value.value<QGraphicsItem*>()));
  2739         break;
  2732         break;
  2740     default:
  2733     default:
  2741         break;
  2734         break;
  2841     emit smoothChanged(smooth);
  2834     emit smoothChanged(smooth);
  2842     update();
  2835     update();
  2843 }
  2836 }
  2844 
  2837 
  2845 /*!
  2838 /*!
       
  2839   \property QDeclarativeItem::anchors
       
  2840   \internal
       
  2841 */
       
  2842 
       
  2843 /*!
       
  2844   \property QDeclarativeItem::left
       
  2845   \internal
       
  2846 */
       
  2847 
       
  2848 /*!
       
  2849   \property QDeclarativeItem::right
       
  2850   \internal
       
  2851 */
       
  2852 
       
  2853 /*!
       
  2854   \property QDeclarativeItem::horizontalCenter
       
  2855   \internal
       
  2856 */
       
  2857 
       
  2858 /*!
       
  2859   \property QDeclarativeItem::top
       
  2860   \internal
       
  2861 */
       
  2862 
       
  2863 /*!
       
  2864   \property QDeclarativeItem::bottom
       
  2865   \internal
       
  2866 */
       
  2867 
       
  2868 /*!
       
  2869   \property QDeclarativeItem::verticalCenter
       
  2870   \internal
       
  2871 */
       
  2872 
       
  2873 /*!
  2846   \property QDeclarativeItem::focus
  2874   \property QDeclarativeItem::focus
  2847   \internal
  2875   \internal
  2848 */
  2876 */
  2849 
  2877 
  2850 /*!
  2878 /*!
  2857   \internal
  2885   \internal
  2858 */
  2886 */
  2859 
  2887 
  2860 /*!
  2888 /*!
  2861   \property QDeclarativeItem::activeFocus
  2889   \property QDeclarativeItem::activeFocus
       
  2890   \internal
       
  2891 */
       
  2892 
       
  2893 /*!
       
  2894   \property QDeclarativeItem::baseline
       
  2895   \internal
       
  2896 */
       
  2897 
       
  2898 /*!
       
  2899   \property QDeclarativeItem::data
       
  2900   \internal
       
  2901 */
       
  2902 
       
  2903 /*!
       
  2904   \property QDeclarativeItem::resources
       
  2905   \internal
       
  2906 */
       
  2907 
       
  2908 /*!
       
  2909   \property QDeclarativeItem::state
       
  2910   \internal
       
  2911 */
       
  2912 
       
  2913 /*!
       
  2914   \property QDeclarativeItem::states
       
  2915   \internal
       
  2916 */
       
  2917 
       
  2918 /*!
       
  2919   \property QDeclarativeItem::transformOriginPoint
       
  2920   \internal
       
  2921 */
       
  2922 
       
  2923 /*!
       
  2924   \property QDeclarativeItem::transitions
  2862   \internal
  2925   \internal
  2863 */
  2926 */
  2864 
  2927 
  2865 /*!
  2928 /*!
  2866     \internal
  2929     \internal
  3128 /*! \internal */
  3191 /*! \internal */
  3129 bool QDeclarativeItem::hasActiveFocus() const
  3192 bool QDeclarativeItem::hasActiveFocus() const
  3130 {
  3193 {
  3131     Q_D(const QDeclarativeItem);
  3194     Q_D(const QDeclarativeItem);
  3132     return focusItem() == this ||
  3195     return focusItem() == this ||
  3133            (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0) ||
  3196            (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0);
  3134            (!parentItem() && focusItem() != 0);
       
  3135 }
  3197 }
  3136 
  3198 
  3137 /*!
  3199 /*!
  3138   \qmlproperty bool Item::focus
  3200   \qmlproperty bool Item::focus
  3139   This property indicates whether the item has focus within the enclosing focus scope. If true, this item
  3201   This property indicates whether the item has focus within the enclosing focus scope. If true, this item
  3149           }
  3211           }
  3150       }
  3212       }
  3151   }
  3213   }
  3152   \endqml
  3214   \endqml
  3153 
  3215 
  3154   For the purposes of this property, the top level item in the scene
  3216   For the purposes of this property, the scene as a whole is assumed to act like a focus scope.
  3155   is assumed to act like a focus scope, and to always have active focus
  3217   On a practical level, that means the following QML will give active focus to \c input on startup.
  3156   when the scene has focus. On a practical level, that means the following
       
  3157   QML will give active focus to \c input on startup.
       
  3158 
  3218 
  3159   \qml
  3219   \qml
  3160   Rectangle {
  3220   Rectangle {
  3161       TextInput {
  3221       TextInput {
  3162           id: input
  3222           id: input
  3178             return p->focusScopeItem() == this;
  3238             return p->focusScopeItem() == this;
  3179         }
  3239         }
  3180         p = p->parentItem();
  3240         p = p->parentItem();
  3181     }
  3241     }
  3182 
  3242 
  3183     return hasActiveFocus() ? true : (!QGraphicsItem::parentItem() ? true : false);
  3243     return hasActiveFocus();
  3184 }
  3244 }
  3185 
  3245 
  3186 /*! \internal */
  3246 /*! \internal */
  3187 void QDeclarativeItem::setFocus(bool focus)
  3247 void QDeclarativeItem::setFocus(bool focus)
  3188 {
  3248 {