src/hbwidgets/itemviews/hbindexfeedback_p.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
equal deleted inserted replaced
28:b7da29130b0e 30:80e4d18b72f5
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include "hbindexfeedback_p.h"
    26 #include "hbindexfeedback_p.h"
    27 #include "hbindexfeedback.h"
    27 #include "hbindexfeedback.h"
    28 
    28 
       
    29 #include <hbapplication.h>
    29 #include <hbscrollbar.h>
    30 #include <hbscrollbar.h>
    30 #include <hbabstractitemview.h>
    31 #include <hbabstractitemview.h>
    31 #include <hbabstractviewitem.h>
    32 #include <hbabstractviewitem.h>
    32 #include <hbstyle.h>
    33 #include <hbstyle.h>
    33 #include <hbabstractitemcontainer_p.h>
    34 #include <hbabstractitemcontainer_p.h>
    34 #include <hbapplication.h>
    35 #include <hbtextitem.h>
       
    36 #include <hbframeitem.h>
       
    37 #include <hbframedrawer.h>
    35 
    38 
    36 #include <hbeffect.h>
    39 #include <hbeffect.h>
    37 #include <hbeffectinternal_p.h>
    40 #include <hbeffectinternal_p.h>
    38 
    41 
    39 #include <hbstyleoptionindexfeedback_p.h>
       
    40 #include <hbabstractitemview_p.h>
    42 #include <hbabstractitemview_p.h>
    41 
    43 
    42 #include <QTimer>
    44 #include <QTimer>
    43 #include <QSize>
    45 #include <QSize>
    44 #include <QGraphicsScene>
    46 #include <QGraphicsScene>
   142 /*
   144 /*
   143     Update the data for, and show the index feedback (if it's not already shown)
   145     Update the data for, and show the index feedback (if it's not already shown)
   144 */
   146 */
   145 void HbIndexFeedbackPrivate::showIndexFeedback()
   147 void HbIndexFeedbackPrivate::showIndexFeedback()
   146 {
   148 {
       
   149     Q_Q( HbIndexFeedback );
   147     if (!mItemView 
   150     if (!mItemView 
   148         || mIndexFeedbackPolicy == HbIndexFeedback::IndexFeedbackNone) {
   151         || mIndexFeedbackPolicy == HbIndexFeedback::IndexFeedbackNone) {
   149         return;
   152         return;
   150     }
   153     }
   151 
   154 
   167         if (data.canConvert<QString>()) {
   170         if (data.canConvert<QString>()) {
   168 
   171 
   169             QString testString = displayText(data);
   172             QString testString = displayText(data);
   170             if (testString != mPopupContent) {
   173             if (testString != mPopupContent) {
   171                 mPopupContent = testString;
   174                 mPopupContent = testString;
   172                 updatePrimitives();
   175                 q->updatePrimitives();
   173             }
   176             }
   174 
   177 
   175            if (mTextItem) {
   178            if (mTextItem) {
   176                 mTextItem->setOpacity(1.0);
   179                 mTextItem->setOpacity(1.0);
   177                 mTextItem->show();
   180                 mTextItem->show();
   336 {
   339 {
   337     mItemView = 0;
   340     mItemView = 0;
   338 }
   341 }
   339 
   342 
   340 /*
   343 /*
   341     Update the primitives for the index feedback.
   344     Create the primitives for the index feedback.
   342 */
   345 */
   343 void HbIndexFeedbackPrivate::updatePrimitives()
   346 void HbIndexFeedbackPrivate::createPrimitives()
   344 {
   347 {
   345     Q_Q( HbIndexFeedback );
   348     Q_Q( HbIndexFeedback );
   346 
   349 
   347     HbStyleOptionIndexFeedback option;
       
   348     q->initStyleOption(&option);
       
   349     if (mTextItem) {
       
   350         HbStylePrivate::updatePrimitive(mTextItem, HbStylePrivate::P_IndexFeedback_popup_text, &option);
       
   351     }
       
   352     if (mPopupItem) {
       
   353         HbStylePrivate::updatePrimitive(mPopupItem, HbStylePrivate::P_IndexFeedback_popup_background, &option);
       
   354     }
       
   355 }
       
   356 
       
   357 /*
       
   358     Create the primitives for the index feedback.
       
   359 */
       
   360 void HbIndexFeedbackPrivate::createPrimitives()
       
   361 {
       
   362     Q_Q( HbIndexFeedback );
       
   363 
       
   364     mPopupItemList.clear();
   350     mPopupItemList.clear();
   365 
   351 
   366     if (!mTextItem) {
   352     if (!mTextItem) {
   367         mTextItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_IndexFeedback_popup_text, q);
   353         mTextItem = q->style()->createPrimitive(HbStyle::PT_TextItem, QLatin1String("index-text"), q);
       
   354         mTextItem->setZValue(4);
       
   355 
       
   356         HbTextItem *textItem = qobject_cast<HbTextItem*>(mTextItem);
       
   357         if (textItem) {
       
   358             textItem->setAlignment(Qt::AlignCenter);
       
   359             textItem->setTextWrapping(Hb::TextNoWrap);
       
   360         }
       
   361 
   368         mTextItem->hide();
   362         mTextItem->hide();
   369         mPopupItemList.append(mTextItem);
   363         mPopupItemList.append(mTextItem);
   370     }
   364     }
   371 
   365 
   372     if (!mPopupItem) {
   366     if (!mPopupItem) {
   373         mPopupItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_IndexFeedback_popup_background, q);
   367         mPopupItem = q->style()->createPrimitive(HbStyle::PT_FrameItem, QLatin1String("index-background"), q);
       
   368         mPopupItem->setZValue(3);
       
   369         HbFrameItem *frameItem = qobject_cast<HbFrameItem*>(mPopupItem);
       
   370         if (frameItem) {
       
   371             HbFrameDrawer &frameDrawer(frameItem->frameDrawer());
       
   372             frameDrawer.setFrameGraphicsName(QLatin1String("qtg_fr_popup_preview"));
       
   373             frameDrawer.setFrameType(HbFrameDrawer::NinePieces);
       
   374 
       
   375             qreal cornerPieceSize = 0;
       
   376             q->style()->parameter(QLatin1String("hb-param-background-popup-preview"),cornerPieceSize);
       
   377             frameDrawer.setBorderWidths(cornerPieceSize, cornerPieceSize, cornerPieceSize, cornerPieceSize);
       
   378         }
       
   379 
   374         mPopupItem->hide();
   380         mPopupItem->hide();
   375         mPopupItemList.append(mPopupItem);
   381         mPopupItemList.append(mPopupItem);
   376     }
   382     }
   377 }
   383 }
   378 
   384