src/hbwidgets/itemviews/hbindexfeedback_p.cpp
changeset 28 b7da29130b0e
parent 21 4633027730f5
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    35 
    35 
    36 #include <hbeffect.h>
    36 #include <hbeffect.h>
    37 #include <hbeffectinternal_p.h>
    37 #include <hbeffectinternal_p.h>
    38 
    38 
    39 #include <hbstyleoptionindexfeedback_p.h>
    39 #include <hbstyleoptionindexfeedback_p.h>
       
    40 #include <hbabstractitemview_p.h>
    40 
    41 
    41 #include <QTimer>
    42 #include <QTimer>
    42 #include <QSize>
    43 #include <QSize>
    43 #include <QGraphicsScene>
    44 #include <QGraphicsScene>
    44 
    45 
   116 {
   117 {
   117     Q_Q( HbIndexFeedback );
   118     Q_Q( HbIndexFeedback );
   118 
   119 
   119     //mItemView = 0; // double check that this is safe.
   120     //mItemView = 0; // double check that this is safe.
   120 
   121 
   121     HbEffect::add(HB_INDEXFEEDBACK_TYPE, "indexfeedback_appear", EFFECT_IFAPPEAR);
       
   122     if (!HbEffect::add(HB_INDEXFEEDBACK_TYPE, "indexfeedback_disappear", EFFECT_IFDISAPPEAR)) {
   122     if (!HbEffect::add(HB_INDEXFEEDBACK_TYPE, "indexfeedback_disappear", EFFECT_IFDISAPPEAR)) {
   123         mDisappearTimer = new QTimer(q);
   123         mDisappearTimer = new QTimer(q);
   124         mDisappearTimer->setSingleShot(true);
   124         mDisappearTimer->setSingleShot(true);
   125         mDisappearTimer->setInterval(INDEX_FEEDBACK_DISAPPEAR_DURATION);
   125         mDisappearTimer->setInterval(INDEX_FEEDBACK_DISAPPEAR_DURATION);
   126         q->connect(mDisappearTimer, SIGNAL(timeout()),
   126         q->connect(mDisappearTimer, SIGNAL(timeout()),
   147     if (!mItemView 
   147     if (!mItemView 
   148         || mIndexFeedbackPolicy == HbIndexFeedback::IndexFeedbackNone) {
   148         || mIndexFeedbackPolicy == HbIndexFeedback::IndexFeedbackNone) {
   149         return;
   149         return;
   150     }
   150     }
   151 
   151 
   152     QList <HbAbstractViewItem *> visibleItems = mItemView->visibleItems();
   152     HbAbstractItemViewPrivate *viewPrivate = HbAbstractItemViewPrivate::d_ptr(mItemView);
   153 
   153     QList<HbAbstractViewItem *> items = viewPrivate->mContainer->items();
   154     QModelIndex targetIndex = visibleItems.first()->modelIndex();   
   154     QModelIndex targetIndex;
   155     qreal top = visibleItems.first()->mapToItem(mItemView, 0, 0).y();
   155 
   156     if (top < 0 
   156     const int count(items.count());
   157         && visibleItems.count() > 1) {
   157     for (int i = 0; i < count; ++i) {
   158         targetIndex = visibleItems.at(1)->modelIndex();
   158         HbAbstractViewItem *item = items.at(i);
       
   159         if(viewPrivate->visible(item, true)) {
       
   160             targetIndex = item->modelIndex();
       
   161             break;
       
   162         }
   159     }
   163     }
   160 
   164 
   161     if (targetIndex.isValid()) {
   165     if (targetIndex.isValid()) {
   162         QVariant data = targetIndex.data(Hb::IndexFeedbackRole);
   166         QVariant data = targetIndex.data(Hb::IndexFeedbackRole);
   163         if (data.canConvert<QString>()) {
   167         if (data.canConvert<QString>()) {
   166             if (testString != mPopupContent) {
   170             if (testString != mPopupContent) {
   167                 mPopupContent = testString;
   171                 mPopupContent = testString;
   168                 updatePrimitives();
   172                 updatePrimitives();
   169             }
   173             }
   170 
   174 
   171             if (mTextItem && mTextItem->opacity() == 0.0) {
   175            if (mTextItem) {
   172                 HbEffect::start(mPopupItemList, HB_INDEXFEEDBACK_TYPE, EFFECT_IFAPPEAR);
   176                 mTextItem->setOpacity(1.0);
   173             }
       
   174             if (mTextItem) {
       
   175                 mTextItem->show();
   177                 mTextItem->show();
   176             }
   178             }
   177 
   179 
   178             if (mPopupItem) {
   180             if (mPopupItem) {
       
   181                 mPopupItem->setOpacity(1.0);
   179                 mPopupItem->show();
   182                 mPopupItem->show();
   180             }
   183             }
   181 
   184 
   182             if (mDisappearTimer) {
   185             if (mDisappearTimer) {
   183                 mDisappearTimer->stop();
   186                 mDisappearTimer->stop();
   222     This is show the index feedback and start the dismissal timer with the
   225     This is show the index feedback and start the dismissal timer with the
   223     press timeout.
   226     press timeout.
   224 */
   227 */
   225 void HbIndexFeedbackPrivate::scrollBarPressed()
   228 void HbIndexFeedbackPrivate::scrollBarPressed()
   226 {
   229 {
       
   230     cancelEffect(EFFECT_IFDISAPPEAR);
   227     showIndexFeedback();
   231     showIndexFeedback();
   228 
   232 
   229     // need to record the scrollbar values    
   233     // need to record the scrollbar values    
   230 
   234 
   231     // TODO::The values are storred here is a work around for a bug in hbscrollbar.
   235     // TODO::The values are storred here is a work around for a bug in hbscrollbar.
   551             break;
   555             break;
   552     }
   556     }
   553 
   557 
   554     return retVal;
   558     return retVal;
   555 }
   559 }
       
   560 
       
   561 void HbIndexFeedbackPrivate::cancelEffect(const QString& effect)
       
   562 {
       
   563     int count = mPopupItemList.count();
       
   564     for (int i=0; i<count; i++) {
       
   565         HbEffect::cancel(mPopupItemList.at(i),effect);
       
   566     }
       
   567 }
       
   568