src/hbwidgets/itemviews/hbindexfeedback_p.cpp
changeset 28 b7da29130b0e
parent 21 4633027730f5
child 30 80e4d18b72f5
--- a/src/hbwidgets/itemviews/hbindexfeedback_p.cpp	Thu Sep 02 20:44:51 2010 +0300
+++ b/src/hbwidgets/itemviews/hbindexfeedback_p.cpp	Fri Sep 17 08:32:10 2010 +0300
@@ -37,6 +37,7 @@
 #include <hbeffectinternal_p.h>
 
 #include <hbstyleoptionindexfeedback_p.h>
+#include <hbabstractitemview_p.h>
 
 #include <QTimer>
 #include <QSize>
@@ -118,7 +119,6 @@
 
     //mItemView = 0; // double check that this is safe.
 
-    HbEffect::add(HB_INDEXFEEDBACK_TYPE, "indexfeedback_appear", EFFECT_IFAPPEAR);
     if (!HbEffect::add(HB_INDEXFEEDBACK_TYPE, "indexfeedback_disappear", EFFECT_IFDISAPPEAR)) {
         mDisappearTimer = new QTimer(q);
         mDisappearTimer->setSingleShot(true);
@@ -149,13 +149,17 @@
         return;
     }
 
-    QList <HbAbstractViewItem *> visibleItems = mItemView->visibleItems();
+    HbAbstractItemViewPrivate *viewPrivate = HbAbstractItemViewPrivate::d_ptr(mItemView);
+    QList<HbAbstractViewItem *> items = viewPrivate->mContainer->items();
+    QModelIndex targetIndex;
 
-    QModelIndex targetIndex = visibleItems.first()->modelIndex();   
-    qreal top = visibleItems.first()->mapToItem(mItemView, 0, 0).y();
-    if (top < 0 
-        && visibleItems.count() > 1) {
-        targetIndex = visibleItems.at(1)->modelIndex();
+    const int count(items.count());
+    for (int i = 0; i < count; ++i) {
+        HbAbstractViewItem *item = items.at(i);
+        if(viewPrivate->visible(item, true)) {
+            targetIndex = item->modelIndex();
+            break;
+        }
     }
 
     if (targetIndex.isValid()) {
@@ -168,14 +172,13 @@
                 updatePrimitives();
             }
 
-            if (mTextItem && mTextItem->opacity() == 0.0) {
-                HbEffect::start(mPopupItemList, HB_INDEXFEEDBACK_TYPE, EFFECT_IFAPPEAR);
-            }
-            if (mTextItem) {
+           if (mTextItem) {
+                mTextItem->setOpacity(1.0);
                 mTextItem->show();
             }
 
             if (mPopupItem) {
+                mPopupItem->setOpacity(1.0);
                 mPopupItem->show();
             }
 
@@ -224,6 +227,7 @@
 */
 void HbIndexFeedbackPrivate::scrollBarPressed()
 {
+    cancelEffect(EFFECT_IFDISAPPEAR);
     showIndexFeedback();
 
     // need to record the scrollbar values    
@@ -553,3 +557,12 @@
 
     return retVal;
 }
+
+void HbIndexFeedbackPrivate::cancelEffect(const QString& effect)
+{
+    int count = mPopupItemList.count();
+    for (int i=0; i<count; i++) {
+        HbEffect::cancel(mPopupItemList.at(i),effect);
+    }
+}
+