src/hbwidgets/itemviews/hbabstractitemcontainer_p.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    82 
    82 
    83 void HbAbstractItemContainerPrivate::init()
    83 void HbAbstractItemContainerPrivate::init()
    84 {
    84 {
    85     Q_Q(HbAbstractItemContainer);
    85     Q_Q(HbAbstractItemContainer);
    86     q->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    86     q->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
       
    87 
       
    88     q->setFlag(QGraphicsItem::ItemHasNoContents, true);
    87 }
    89 }
    88 
    90 
    89 /*!
    91 /*!
    90    Returns given item's bounding rectangle in scene coordinates.
    92    Returns given item's bounding rectangle in scene coordinates.
    91  */
    93  */
   136 */
   138 */
   137 bool HbAbstractItemContainerPrivate::visible(HbAbstractViewItem* item, const QRectF &viewRect, bool fullyVisible) const
   139 bool HbAbstractItemContainerPrivate::visible(HbAbstractViewItem* item, const QRectF &viewRect, bool fullyVisible) const
   138 {
   140 {
   139     if (item) {
   141     if (item) {
   140         QRectF itemRect(itemBoundingRect(item));
   142         QRectF itemRect(itemBoundingRect(item));
       
   143         // 0.5 tolerance otherwise it fail - for instance if pos.y = -5.68434e-14 then item will be not fullyVisible
       
   144         itemRect.adjust(0.5, 0.5, -0.5, -0.5);
   141         if (fullyVisible) {
   145         if (fullyVisible) {
   142             if (viewRect.contains(itemRect)) {
   146             if (viewRect.contains(itemRect)) {
   143                 return true;
   147                 return true;
   144             }
   148             }
   145         } else {
   149         } else {
   413     Q_Q(HbAbstractItemContainer);
   417     Q_Q(HbAbstractItemContainer);
   414 
   418 
   415     q->setItemTransientState(item->modelIndex(), item->transientState());
   419     q->setItemTransientState(item->modelIndex(), item->transientState());
   416     mItems.removeOne(item);
   420     mItems.removeOne(item);
   417     q->itemRemoved(item, animate);
   421     q->itemRemoved(item, animate);
       
   422 
       
   423     emit q->itemAboutToBeDeleted(item);
   418 
   424 
   419 #ifndef HB_EFFECTS
   425 #ifndef HB_EFFECTS
   420     delete item;
   426     delete item;
   421 #else
   427 #else
   422     if (!HbEffect::effectRunning(item, "disappear") 
   428     if (!HbEffect::effectRunning(item, "disappear") 
   528 HbAbstractItemContainer::HbAbstractItemContainer(QGraphicsItem *parent) : 
   534 HbAbstractItemContainer::HbAbstractItemContainer(QGraphicsItem *parent) : 
   529     HbWidget(*new HbAbstractItemContainerPrivate(), parent) 
   535     HbWidget(*new HbAbstractItemContainerPrivate(), parent) 
   530 {
   536 {
   531     Q_D(HbAbstractItemContainer);
   537     Q_D(HbAbstractItemContainer);
   532 
   538 
   533 	d->q_ptr = this;
   539     d->q_ptr = this;
   534     d->init();
   540     d->init();
   535 }
   541 }
   536 
   542 
   537 /*!
   543 /*!
   538     Constructs an item with private class object \a dd and \a parent. 
   544     Constructs an item with private class object \a dd and \a parent. 
   599 
   605 
   600     qDeleteAll(d->mItems);
   606     qDeleteAll(d->mItems);
   601     d->mItems.clear();
   607     d->mItems.clear();
   602     d->mItemStateList.clear();
   608     d->mItemStateList.clear();
   603     d->mItemStates.clear();
   609     d->mItemStates.clear();
       
   610 
       
   611     emit itemAboutToBeDeleted(0);
       
   612 
   604 }
   613 }
   605 
   614 
   606 /*!
   615 /*!
   607     Returns the item view that container is connected.
   616     Returns the item view that container is connected.
   608 */
   617 */
   715             break;
   724             break;
   716         }
   725         }
   717     }
   726     }
   718 
   727 
   719     // if items have been added/removed in the middle of the buffer, there might be items 
   728     // if items have been added/removed in the middle of the buffer, there might be items 
   720 	// that can be reused at the end of the buffer. The following block will scan for 
   729     // that can be reused at the end of the buffer. The following block will scan for 
   721 	// those items and move them in correct position 
   730     // those items and move them in correct position 
   722     int lastUsedItem = -1;
   731     int lastUsedItem = -1;
   723     for (int indexCounter = 0; indexCounter < indexList.count(); ++indexCounter) {
   732     for (int indexCounter = 0; indexCounter < indexList.count(); ++indexCounter) {
   724         HbAbstractViewItem *item = d->mItems.at(indexCounter);
   733         HbAbstractViewItem *item = d->mItems.at(indexCounter);
   725         if (item && item->modelIndex() == indexList.at(indexCounter)) { 
   734         if (item && item->modelIndex() == indexList.at(indexCounter)) { 
   726             lastUsedItem = indexCounter;
   735             lastUsedItem = indexCounter;