src/hbwidgets/itemviews/hbabstractviewitem.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    55 #include <QGestureEvent>
    55 #include <QGestureEvent>
    56 #include <QGraphicsSceneEvent>
    56 #include <QGraphicsSceneEvent>
    57 
    57 
    58 const QString KDefaultLayoutOption = "default";
    58 const QString KDefaultLayoutOption = "default";
    59 const int HbAbstractViewItemShared::ViewItemDeferredDeleteEvent = QEvent::registerEventType();
    59 const int HbAbstractViewItemShared::ViewItemDeferredDeleteEvent = QEvent::registerEventType();
    60 const int HbViewItemPressDelay = 50;
    60 const int HbViewItemPressDelay = 100;
    61 
    61 
    62 /*!
    62 /*!
    63     @alpha
    63     @alpha
    64     @hbwidgets
    64     @hbwidgets
    65     \class HbAbstractViewItem
    65     \class HbAbstractViewItem
   464         if (!(subChild->flags() & QGraphicsItem::ItemStacksBehindParent))
   464         if (!(subChild->flags() & QGraphicsItem::ItemStacksBehindParent))
   465             break;
   465             break;
   466         paintChildItemsRecursively(subChild, painter,option);
   466         paintChildItemsRecursively(subChild, painter,option);
   467     }
   467     }
   468     option->exposedRect = child->boundingRect();
   468     option->exposedRect = child->boundingRect();
       
   469 
       
   470     bool restorePainter = false;
       
   471     if (child->flags() & QGraphicsItem::ItemClipsToShape) {
       
   472         painter->save();
       
   473         restorePainter = true;
       
   474 
       
   475         painter->setClipRect(child->boundingRect());
       
   476     }
   469     child->paint(painter, option, 0);
   477     child->paint(painter, option, 0);
       
   478 
       
   479     if (restorePainter) {
       
   480         painter->restore();
       
   481     }
       
   482 
   470     // Draw children in front
   483     // Draw children in front
   471     for (; i < count; ++i) {
   484     for (; i < count; ++i) {
   472         QGraphicsItem *subChild = children.at(i);
   485         QGraphicsItem *subChild = children.at(i);
   473         paintChildItemsRecursively(subChild, painter,option);
   486         paintChildItemsRecursively(subChild, painter,option);
   474     }
   487     }
  1263 */
  1276 */
  1264 QSizeF HbAbstractViewItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
  1277 QSizeF HbAbstractViewItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
  1265 {
  1278 {
  1266     Q_D(const HbAbstractViewItem);
  1279     Q_D(const HbAbstractViewItem);
  1267     if (d->mRepolishRequested) {
  1280     if (d->mRepolishRequested) {
  1268         if (d->repolishOutstanding) {
  1281         // force the polish event in order to get the real size
  1269             // force the polish event in order to get the real size
  1282         // updateGeometry() in ::updateChildItems() causes this function to be called
  1270             // updateGeometry() in ::updateChildItems() causes this function to be called
  1283         // before QEvent::Polish of repolish() is handled from the event loop.
  1271             // before QEvent::Polish of repolish() is handled from the event loop
  1284         QCoreApplication::sendPostedEvents(const_cast<HbAbstractViewItem*>(this), QEvent::Polish);
  1272             QCoreApplication::sendPostedEvents(const_cast<HbAbstractViewItem*>(this), QEvent::Polish);
       
  1273         } else {
       
  1274             // needed for pure widget or at startup phase, if first polish has not yet been done
       
  1275             QEvent polishEvent(QEvent::Polish);
       
  1276             QCoreApplication::sendEvent(const_cast<HbAbstractViewItem *>(this), &polishEvent);
       
  1277         }
       
  1278         QCoreApplication::sendPostedEvents(const_cast<HbAbstractViewItem *>(this), QEvent::LayoutRequest);
  1285         QCoreApplication::sendPostedEvents(const_cast<HbAbstractViewItem *>(this), QEvent::LayoutRequest);
  1279     }
  1286     }
  1280     return HbWidget::sizeHint(which, constraint);
  1287     return HbWidget::sizeHint(which, constraint);
  1281 }
  1288 }
  1282 
  1289 
  1338 void HbAbstractViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
  1345 void HbAbstractViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
  1339 {
  1346 {
  1340     Q_UNUSED(widget);
  1347     Q_UNUSED(widget);
  1341 
  1348 
  1342     Q_D(HbAbstractViewItem);
  1349     Q_D(HbAbstractViewItem);
       
  1350     
       
  1351     if (!d->mFrontPixmapPainter) {
       
  1352         return;
       
  1353     }
       
  1354     
  1343     if (!d->mInPaintItems) {
  1355     if (!d->mInPaintItems) {
  1344         bool usePixmapCache = d->usePixmapCache();
  1356         bool usePixmapCache = d->usePixmapCache();
  1345 
  1357 
  1346         if (usePixmapCache) {
  1358         if (usePixmapCache) {
  1347             QRectF deviceBounds = painter->worldTransform().mapRect(boundingRect());
  1359             QRectF deviceBounds = painter->worldTransform().mapRect(boundingRect());