src/hbwidgets/itemviews/hbabstractitemview.cpp
changeset 21 4633027730f5
parent 6 c3690ec91ef8
child 23 e6ad4ef83b23
--- a/src/hbwidgets/itemviews/hbabstractitemview.cpp	Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbwidgets/itemviews/hbabstractitemview.cpp	Wed Aug 18 10:05:37 2010 +0300
@@ -34,6 +34,7 @@
 #include <hbinstance.h>
 #include <hbscrollbar.h>
 #include <hbmodeliterator.h>
+#include <hbdataform.h>
 
 #include <QGraphicsSceneMouseEvent>
 #include <QGraphicsScene>
@@ -513,6 +514,7 @@
 {
     Q_D(HbAbstractItemView);    
 
+    d->stopAnimating();
     d->mModelIterator->setRootIndex(QPersistentModelIndex());
     d->resetContainer();
 
@@ -530,25 +532,7 @@
     bool result = HbScrollArea::event(e);
 
     // The two above statements have to be executed before these
-    if (e->type() == HbEvent::ChildFocusIn) {
-        HbAbstractViewItem *item = 0;
-        QList<HbAbstractViewItem *> items = d->mContainer->items();
-
-        for (QGraphicsItem *currentItem = scene()->focusItem(); currentItem != 0; currentItem = currentItem->parentItem()) {
-            item = d->viewItem(currentItem);
-            if (item) {
-                if (items.indexOf(item) == -1) {
-                    item = 0;
-                } else {
-                    break;
-                }
-            }
-        }
-        if (item && item->modelIndex() != d->mCurrentIndex) {
-            setCurrentIndex(item->modelIndex());
-        }
-        result = true;
-    } else if (e->type() == QEvent::LayoutRequest) {
+    if (e->type() == QEvent::LayoutRequest) {
         d->mContainer->resizeContainer();
         if (d->mPostponedScrollIndex.isValid()) { 
            d->scrollTo(d->mPostponedScrollIndex, d->mPostponedScrollHint);
@@ -774,19 +758,12 @@
 */
 void HbAbstractItemView::currentIndexChanged(const QModelIndex &current, const QModelIndex &previous)
 {
+    Q_UNUSED(previous);
     Q_D(HbAbstractItemView);
 
+
     if (current != d->mCurrentIndex) {
         d->mCurrentIndex = current;
-               
-        if (previous.isValid()) {
-           d->mContainer->setItemTransientStateValue(previous, "focused", false);
-        }
-        
-        if (d->mCurrentIndex.isValid()) {
-            d->mContainer->setItemTransientStateValue(d->mCurrentIndex, "focused", true);
-        }
-
     }
 }
 
@@ -1205,6 +1182,8 @@
     }
 
     emitActivated(index);
+
+    setCurrentIndex(index);
 }
 
 /*! 
@@ -1225,6 +1204,8 @@
     d->mSelectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
 
     emit longPressed(item, item->mapToScene(pos));
+
+    setCurrentIndex(index);
 }
 
 /*! 
@@ -1289,6 +1270,40 @@
 }
 
 /*!
+    Enables item's pixmap cache if \a enable is true, or disables item's pixmap cache if \a enable is false.
+
+    Enabling item's pixmap cache will significantly improve the item view scrolling speed. That is why in
+    most of the cases the pixmap cache should be enabled. It should only be disabled if there is a real need to
+    do it like; a custom view item prototype used that cannot update the pixmap properly or an effect is applied 
+    to view item's child item.
+
+    \note Item pixmap cache is not supported by HbDataForm.
+
+    By default, the item's pixmap cache is disabled.
+
+    \sa HbAbstractItemView::itemPixmapCacheEnabled(), HbAbstractViewItem::updatePixmapCache()
+*/
+void HbAbstractItemView::setItemPixmapCacheEnabled(bool enabled)
+{
+    Q_D(HbAbstractItemView);
+    
+    if (qgraphicsitem_cast<HbDataForm*>(this) == 0) {
+        d->mItemPixmapCacheEnabled = enabled;
+    }
+}
+
+/*!
+    Returns true if item's pixmap cache is enabled; otherwise returns false.
+
+    \sa HbAbstractItemView::setItemPixmapCacheEnabled()
+*/
+bool HbAbstractItemView::itemPixmapCacheEnabled() const
+{
+    Q_D(const HbAbstractItemView);
+    return d->mItemPixmapCacheEnabled;
+}
+
+/*!
     Slot handles QAbstractItemModel::layoutChanged() signal. 
     Default implementation sets first model item visible as first view item. 
 */