src/hbwidgets/itemviews/hbabstractviewitem.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    26 #include "hbabstractviewitem_p.h"
    26 #include "hbabstractviewitem_p.h"
    27 
    27 
    28 #include <hbabstractviewitem.h>
    28 #include <hbabstractviewitem.h>
    29 #include <hbabstractitemview.h>
    29 #include <hbabstractitemview.h>
    30 #include <hbnamespace.h>
    30 #include <hbnamespace.h>
    31 #include <hbstyleoptionabstractviewitem.h>
    31 #include <hbstyleoptionabstractviewitem_p.h>
    32 #include <hbstyle.h>
    32 #include <hbstyle.h>
    33 #include <hbiconitem.h>
    33 #include <hbiconitem.h>
    34 #include <hbframebackground.h>
    34 #include <hbframebackground.h>
    35 #include <hbabstractitemview_p.h>
    35 #include <hbabstractitemview_p.h>
    36 #include <hbwidgetfeedback.h>
    36 #include <hbwidgetfeedback.h>
    44 #include <QDebug>
    44 #include <QDebug>
    45 
    45 
    46 #include <QGesture>
    46 #include <QGesture>
    47 #include <QGestureEvent>
    47 #include <QGestureEvent>
    48 
    48 
    49 #ifdef QMAP_INT__ITEM_STATE_DEPRECATED
       
    50 #define HB_ITEM_STATE_ASSERT Q_ASSERT_X(0, "", "QMap<int,QVariant> based view item state system is deprecated. Use QHash<QString, QVariant> based instead" )
       
    51 #else
       
    52 #define HB_ITEM_STATE_ASSERT
       
    53 #endif
       
    54 
       
    55 const QString KDefaultLayoutOption = "default";
    49 const QString KDefaultLayoutOption = "default";
    56 const int HbAbstractViewItemShared::ViewItemDeferredDeleteEvent = QEvent::registerEventType();
    50 const int HbAbstractViewItemShared::ViewItemDeferredDeleteEvent = QEvent::registerEventType();
    57 
    51 
    58 /*!
    52 /*!
    59     @alpha
    53     @alpha
    60     @hbwidgets
    54     @hbwidgets
    61     \class HbAbstractViewItem
    55     \class HbAbstractViewItem
    62     \brief The HbAbstractViewItem class represents a single item in a AbstractItemView.  
    56     \brief The HbAbstractViewItem class represents a single item in a AbstractItemView.  
    63 
    57 
    64     The HbAbstractViewItem class provides an item that is used by HbAbstractItemView class to
    58     The HbAbstractViewItem class provides an item that is used by HbAbstractItemView class to
    65     visualize content within single model index. By default HbAbstractViewItem supports QString
    59     visualize content within single model index. By default HbAbstractViewItem supports QString and QStringList 
    66     that is stored into Qt::DisplayRole role and QIcon or HbIcon that is stored into
    60     stored into Qt::DisplayRole role and QIcon, HbIcon or list of them in QVariantList stored into
    67     Qt::DecoratorRole role within the index. 
    61     Qt::DecoratorRole role. 
    68 
    62 
    69     This class is provided mainly for customization purposes but it also acts as a default
    63     This class is provided mainly for customization purposes but it also acts as a default
    70     item prototype inside HbAbstractItemView. See HbAbstractItemView how to set customized class as a item prototype.
    64     item prototype inside HbAbstractItemView. See HbAbstractItemView how to set customized class as a item prototype.
    71 
    65 
    72     \b Subclassing
    66     \b Subclassing
    73 
    67 
    74     When subclassing HbAbstractViewItem, childclass must provide implementations of createItem() and updateChildItems() functions.
    68     When subclassing HbAbstractViewItem, child class must provide implementations of createItem() and updateChildItems() functions.
    75     
    69     
    76     To support multiple Abstractview items within single AbstractItemview, you must also provide an implementation of canSetModelIndex().
    70     To support multiple Abstractview items within single AbstractItemview, you must also provide an implementation of canSetModelIndex().
    77 
    71 
    78     If derived abstract view item has transient state information that is not meaningful to store within model index (child item cursor 
    72     If derived abstract view item has transient state information that is not meaningful to store within model index (child item cursor 
    79     position selection areas etc.) view item can use abstract views internal state model to store this information. This feature can
    73     position selection areas etc.) this information can be supplied to transient state model. Transient state model is maintained 
    80     be taken into use by implementing transientState() and setTransientState() functions in derived class.
    74     internally by abstract item view. 
    81 */
       
    82 
       
    83 /*!
       
    84     \deprecated HbAbstractViewItem::StateKey
       
    85         is deprecated. Please use string based state keys.
       
    86 
       
    87     \enum HbAbstractViewItem::StateKey
       
    88 
       
    89     HbAbstractViewItem's predefined set of state keys.
       
    90 
       
    91     This enum describes state keys for HbAbstractViewItem state values. State value can be accessed using this key.
       
    92 
       
    93     \sa HbAbstractViewItem::transientState()
       
    94 */
       
    95 
       
    96 /*!
       
    97     \deprecated HbAbstractViewItem::FocusKey
       
    98         is deprecated. Please use string based state keys. This key is replaced by "focused".
       
    99 
       
   100     \var HbAbstractViewItem::FocusKey
       
   101          Predefined key for focus state value.
       
   102 */
       
   103 
       
   104 /*!
       
   105     \deprecated HbAbstractViewItem::CheckStateKey
       
   106         is deprecated. Please use string based state keys. This key is replaced by "checkState".
       
   107 
       
   108     \var HbAbstractViewItem::CheckStateKey
       
   109         Predefined key for check state value. Default value is Qt::Unchecked.
       
   110 */
       
   111 
       
   112 /*!
       
   113     \deprecated HbAbstractViewItem::UserKey
       
   114         is deprecated. Please use string based state keys.
       
   115 
       
   116     \var HbAbstractViewItem::UserKey
       
   117          First key that can be used by the derived class for it's own purposes.
       
   118 */
    75 */
   119 
    76 
   120 /*!
    77 /*!
   121     \fn void HbAbstractViewItem::pressed(const QPointF &position)
    78     \fn void HbAbstractViewItem::pressed(const QPointF &position)
   122 
    79 
   129 
    86 
   130 /*!
    87 /*!
   131     \fn void HbAbstractViewItem::released(const QPointF &position)
    88     \fn void HbAbstractViewItem::released(const QPointF &position)
   132 
    89 
   133     This signal is emitted when a touch release event is received for this view item.
    90     This signal is emitted when a touch release event is received for this view item.
       
    91     Released signal is emitted also when user starts panning or flicks the view.
   134     \a position is position of touch event in view item coordinates.
    92     \a position is position of touch event in view item coordinates.
   135 
    93 
   136     \sa HbAbstractViewItem::pressed(const QPointF &position)
    94     \sa HbAbstractViewItem::pressed(const QPointF &position)
   137     \sa HbAbstractViewItem::activated(const QPointF &position)
    95     \sa HbAbstractViewItem::activated(const QPointF &position)
   138 */
    96 */
   245     position = q->mapFromScene(position);
   203     position = q->mapFromScene(position);
   246 
   204 
   247     switch (gesture->state()) {
   205     switch (gesture->state()) {
   248         case Qt::GestureStarted: {
   206         case Qt::GestureStarted: {
   249             HbWidgetFeedback::triggered(q, Hb::InstantPressed, 0);
   207             HbWidgetFeedback::triggered(q, Hb::InstantPressed, 0);
   250             q->setPressed(true);
   208             setPressed(true, true);
   251             emit q->pressed(position);
   209             emit q->pressed(position);
   252 
       
   253             break;
   210             break;
   254         }
   211         }
   255         case Qt::GestureUpdated: {
   212         case Qt::GestureUpdated: {
   256             if (gesture->tapStyleHint() == HbTapGesture::TapAndHold 
   213             if (gesture->tapStyleHint() == HbTapGesture::TapAndHold 
   257                 && mSharedData->mItemView
   214                 && mSharedData->mItemView
   258                 && mSharedData->mItemView->longPressEnabled()) {
   215                 && mSharedData->mItemView->longPressEnabled()) {
   259                 q->setPressed(false);
   216                 setPressed(false, true);
   260                 emit q->longPressed(position);
   217                 QPointer<HbAbstractViewItem> item = q;
   261                 revealItem();
   218                 emit item->longPressed(position);
       
   219                 if (item) {
       
   220                     revealItem();
       
   221                 }
   262             }
   222             }
   263             break;
   223             break;
   264         }
   224         }
   265         case Qt::GestureFinished: {
   225         case Qt::GestureFinished: {
   266             HbWidgetFeedback::triggered(q, Hb::InstantReleased, 0);
   226             HbWidgetFeedback::triggered(q, Hb::InstantReleased, 0);
   267 
   227 
   268             if (gesture->tapStyleHint() == HbTapGesture::Tap 
   228             if (gesture->tapStyleHint() == HbTapGesture::Tap 
   269 			    || (mSharedData->mItemView
   229                 || (mSharedData->mItemView
   270                 && !mSharedData->mItemView->longPressEnabled())) {
   230                 && !mSharedData->mItemView->longPressEnabled())) {
   271                 q->setPressed(false);
   231                 setPressed(false, true);
   272 
   232 
   273                 HbWidgetFeedback::triggered(q, Hb::InstantClicked);
   233                 HbWidgetFeedback::triggered(q, Hb::InstantClicked);
   274                 emit q->activated(position);
   234                 QPointer<HbAbstractViewItem> item = q;
   275                 emit q->released(position);
   235                 emit item->activated(position);
   276                 revealItem();
   236                 // this viewItem may be deleted in the signal handling, so guarded pointer is used to 
       
   237                 // to ensure that the item still exists when item is used
       
   238                 if (item) {
       
   239                     emit item->released(position);
       
   240                     if (item) {
       
   241                         revealItem();
       
   242                     }
       
   243                 }
   277             } else {
   244             } else {
   278                 emit q->released(position);
   245                 emit q->released(position);
   279             }
   246             }
   280 
   247 
   281             break;
   248             break;
   282         }
   249         }
   283         case Qt::GestureCanceled: {
   250         case Qt::GestureCanceled: {
   284             HbWidgetFeedback::triggered(q, Hb::InstantReleased, 0);
       
   285 
   251 
   286             // hides focus immediately
   252             // hides focus immediately
   287             q->setPressed(false, false);
   253             setPressed(false, false);
   288 
   254 
   289             emit q->released(position);
   255             emit q->released(position);
   290             break;
   256             break;
   291         }
   257         }
   292         default:
   258         default:
   302 
   268 
   303     if (mSharedData->mItemView) {
   269     if (mSharedData->mItemView) {
   304         static_cast<HbAbstractItemViewPrivate *>(mSharedData->mItemView->d_func())->revealItem(q, HbAbstractItemView::EnsureVisible);
   270         static_cast<HbAbstractItemViewPrivate *>(mSharedData->mItemView->d_func())->revealItem(q, HbAbstractItemView::EnsureVisible);
   305     }
   271     }
   306 }
   272 }
       
   273 
       
   274 void HbAbstractViewItemPrivate::setPressed(bool pressed, bool animate)
       
   275 {
       
   276     Q_Q(HbAbstractViewItem);
       
   277 
       
   278     if (pressed != mPressed) {
       
   279         mPressed = pressed;
       
   280         q->pressStateChanged(mPressed, animate);
       
   281         if (mPressed) {
       
   282             q->setProperty("state", "pressed");
       
   283         } else {
       
   284             q->setProperty("state", "normal");
       
   285         }
       
   286     }
       
   287 }
       
   288 
   307 
   289 
   308 /*!
   290 /*!
   309     Constructs an abstract view item with the given parent.
   291     Constructs an abstract view item with the given parent.
   310 */
   292 */
   311 HbAbstractViewItem::HbAbstractViewItem(QGraphicsItem *parent) : 
   293 HbAbstractViewItem::HbAbstractViewItem(QGraphicsItem *parent) : 
   390     Q_D( const HbAbstractViewItem );
   372     Q_D( const HbAbstractViewItem );
   391     return d->mIndex;
   373     return d->mIndex;
   392 }
   374 }
   393 
   375 
   394 /*!
   376 /*!
   395     \deprecated HbAbstractViewItem::type() const
       
   396         is deprecated.
       
   397 
       
   398     \reimp
       
   399 */
       
   400 int HbAbstractViewItem::type() const
       
   401 {
       
   402     qWarning("HbAbstractViewItem::type() const is deprecated");
       
   403 
       
   404     return Hb::ItemType_AbstractViewItem;
       
   405 }
       
   406 
       
   407 
       
   408 /*!
       
   409     Sets model \a index where this Abstract view item should retrieve it's content.
   377     Sets model \a index where this Abstract view item should retrieve it's content.
   410 */
   378 */
   411 void HbAbstractViewItem::setModelIndex(const QModelIndex &index)
   379 void HbAbstractViewItem::setModelIndex(const QModelIndex &index)
   412 {
   380 {
   413     Q_D( HbAbstractViewItem );
   381     Q_D( HbAbstractViewItem );
   414     if (d->mIndex != index) {
   382     if (d->mIndex != index) {
   415         d->mIndex = index;
   383         d->mIndex = index;
   416 
   384 
   417         updateChildItems();
   385         updateChildItems();
   418     }
   386     }
   419 }
       
   420 
       
   421 /*!
       
   422     \deprecated HbAbstractViewItem::receivedFocus()
       
   423         is deprecated.
       
   424 
       
   425     Called when item has received focus.
       
   426 */
       
   427 void HbAbstractViewItem::receivedFocus()
       
   428 {
       
   429     qWarning("HbAbstractViewItem::receivedFocus() is deprecated!");
       
   430 
       
   431     Q_D( HbAbstractViewItem );
       
   432     d->mFocused = true;
       
   433 }
       
   434 
       
   435 /*!
       
   436     \deprecated HbAbstractViewItem::lostFocus()
       
   437         is deprecated.
       
   438 
       
   439     Called when item has lost focus.
       
   440 */
       
   441 void HbAbstractViewItem::lostFocus()
       
   442 {
       
   443     qWarning("HbAbstractViewItem::lostFocus() is deprecated!");
       
   444 
       
   445     Q_D( HbAbstractViewItem );
       
   446     d->mFocused = false;
       
   447 }
       
   448 
       
   449 /*!
       
   450     \deprecated HbAbstractViewItem::isFocused() const
       
   451         is deprecated.
       
   452 
       
   453     Retuns true if item is currently focused, otherwise return false.
       
   454 */
       
   455 bool HbAbstractViewItem::isFocused() const
       
   456 {
       
   457     qWarning("HbAbstractViewItem::isFocused() is deprecated!");
       
   458 
       
   459     Q_D( const HbAbstractViewItem );
       
   460     return d->mFocused;
       
   461 }
   387 }
   462 
   388 
   463 /*!
   389 /*!
   464     Returns the saved item's transient state. Transient state can be seen as a state data that is 
   390     Returns the saved item's transient state. Transient state can be seen as a state data that is 
   465     wanted to be preserved but it not meaningful to be stored inside model index because of it's
   391     wanted to be preserved but it not meaningful to be stored inside model index because of it's
   493 void HbAbstractViewItem::setTransientState(const QHash<QString, QVariant> &state)
   419 void HbAbstractViewItem::setTransientState(const QHash<QString, QVariant> &state)
   494 {
   420 {
   495     Q_D( HbAbstractViewItem );
   421     Q_D( HbAbstractViewItem );
   496     d->mFocused = state.value("focused").toBool();
   422     d->mFocused = state.value("focused").toBool();
   497     d->mCheckState = (Qt::CheckState)state.value("checkState").toInt();
   423     d->mCheckState = (Qt::CheckState)state.value("checkState").toInt();
   498 }
       
   499 
       
   500 
       
   501 /*!
       
   502      \deprecated HbAbstractViewItem::state() const
       
   503         is deprecated. Please use HbAbstractViewItem::transientState() instead. 
       
   504 
       
   505     Returns the saved item's transient state. Transient state can be seen as a state data that is 
       
   506     wanted to be preserved but it not meaningful to be stored inside model index because of it's
       
   507     momentary nature. States will be saved inside AbstractItemview and restored when current model index is
       
   508     assigned to certain Abstract view item.
       
   509 */
       
   510 QMap<int,QVariant> HbAbstractViewItem::state() const
       
   511 {
       
   512     qWarning("HbAbstractViewItem::state() const is deprecated");
       
   513     HB_ITEM_STATE_ASSERT;
       
   514     Q_D( const HbAbstractViewItem );
       
   515     QMap<int,QVariant> state;
       
   516 
       
   517     state.insert(FocusKey, d->mFocused);
       
   518     state.insert(CheckStateKey, d->mCheckState);
       
   519 
       
   520     return state;
       
   521 }
       
   522 
       
   523 /*!
       
   524      \deprecated HbAbstractViewItem::setState(const QMap<int,QVariant> &)
       
   525         is deprecated. Please use HbAbstractViewItem::setTransientState(const QHash<QString, QVariant> &state) instead. 
       
   526 
       
   527     Restores the item's transient state using given \a state data.
       
   528 */
       
   529 void HbAbstractViewItem::setState(const QMap<int,QVariant> &state)
       
   530 {
       
   531     qWarning("HbAbstractViewItem::setState(const QMap<int,QVariant> &state) is deprecated");
       
   532     HB_ITEM_STATE_ASSERT;
       
   533     Q_D( HbAbstractViewItem );
       
   534     if (state.contains(FocusKey)) {
       
   535         d->mFocused = state.value(FocusKey).toBool();
       
   536     } else {
       
   537         d->mFocused = false; 
       
   538     }
       
   539 
       
   540     if (state.contains(CheckStateKey)) {
       
   541         d->mCheckState = (Qt::CheckState)state.value(CheckStateKey).toInt();
       
   542     } else {
       
   543         d->mCheckState = Qt::Unchecked;
       
   544     }
       
   545 }
   424 }
   546 
   425 
   547 /*!
   426 /*!
   548     Returns a pointer to HbAbstractViewItem prototype that was used to create this
   427     Returns a pointer to HbAbstractViewItem prototype that was used to create this
   549     view item.
   428     view item.
   609     Check whether \a position is inside the selection area of the given selectionAreaType in the view item.
   488     Check whether \a position is inside the selection area of the given selectionAreaType in the view item.
   610 
   489 
   611     Default selection areas are for
   490     Default selection areas are for
   612     \li HbAbstractViewItem::SingleSelection mode: whole item
   491     \li HbAbstractViewItem::SingleSelection mode: whole item
   613     \li HbAbstractViewItem::MultiSelection mode: whole item.
   492     \li HbAbstractViewItem::MultiSelection mode: whole item.
   614     \li HbAbstractItemView::ContiguousSelection mode: whole item. (Note: HbAbstractItemView::ContiguousSelection is deprecated.)
       
   615     \li HbAbstractItemView::NoSelection mode: none
   493     \li HbAbstractItemView::NoSelection mode: none
   616 
   494 
   617     The \a selectionAreaType tells what kind of selection area is requested.  The parameter value ContiguousSelection returns 
   495     The \a selectionAreaType tells what kind of selection area is requested.  The parameter value ContiguousSelection returns 
   618 	the area where mouse movement will extend the selection to new items. By default this contiguous selection area is 
   496 	the area where mouse movement will extend the selection to new items. By default this contiguous selection area is 
   619 	the HbStyle::P_ItemViewItem_touchmultiselection.
   497 	the HbStyle::P_ItemViewItem_touchmultiselection.
   711         default:
   589         default:
   712             break;
   590             break;
   713     }
   591     }
   714 
   592 
   715     return HbWidget::itemChange(change, value);
   593     return HbWidget::itemChange(change, value);
   716 }
       
   717 
       
   718 /*!
       
   719 
       
   720     \deprecated HbAbstractViewItem::primitive(HbStyle::Primitive)
       
   721        is deprecated.
       
   722 
       
   723   Provides access to primitives of HbAbstractViewItem.
       
   724   \param primitive is the type of the requested primitive. The available primitives are 
       
   725   \c P_ItemViewItem_background
       
   726   \c P_ItemViewItem_frame
       
   727   \c P_ItemViewItem_selection
       
   728   \c P_ItemViewItem_focus
       
   729   \c P_ItemViewItem_touchmultiselection.
       
   730  */
       
   731 QGraphicsItem *HbAbstractViewItem::primitive(HbStyle::Primitive primitive) const
       
   732 {
       
   733     Q_D(const HbAbstractViewItem);
       
   734 
       
   735     if (primitive == HbStyle::P_ItemViewItem_background) {
       
   736         return d->mBackgroundItem;
       
   737     } else if (primitive == HbStyle::P_ItemViewItem_frame) {
       
   738         return d->mFrame;
       
   739     } else if (primitive == HbStyle::P_ItemViewItem_selection) {
       
   740         return d->mSelectionItem;
       
   741     } else if (primitive == HbStyle::P_ItemViewItem_focus) {
       
   742         return d->mFocusItem;
       
   743     } else if (primitive == HbStyle::P_ItemViewItem_touchmultiselection) {
       
   744         return d->mMultiSelectionTouchArea;
       
   745     }
       
   746 
       
   747     return HbWidget::primitive(primitive);
       
   748 }
   594 }
   749 
   595 
   750 /*!
   596 /*!
   751     \reimp
   597     \reimp
   752 
   598 
   906     if (indexFlags & Qt::ItemIsEnabled) {
   752     if (indexFlags & Qt::ItemIsEnabled) {
   907         if (!(itemFlags & QGraphicsItem::ItemIsFocusable)) {
   753         if (!(itemFlags & QGraphicsItem::ItemIsFocusable)) {
   908             itemFlags |= QGraphicsItem::ItemIsFocusable;
   754             itemFlags |= QGraphicsItem::ItemIsFocusable;
   909             setFocusPolicy(sd->mPrototype->focusPolicy());
   755             setFocusPolicy(sd->mPrototype->focusPolicy());
   910             setProperty("state", "normal");
   756             setProperty("state", "normal");
   911         grabGesture(Qt::TapGesture);
   757             grabGesture(Qt::TapGesture);
   912         }
   758         }
   913     } else {
   759     } else {
   914         if (itemFlags & QGraphicsItem::ItemIsFocusable) {
   760         if (itemFlags & QGraphicsItem::ItemIsFocusable) {
   915             itemFlags &= ~QGraphicsItem::ItemIsFocusable;
   761             itemFlags &= ~QGraphicsItem::ItemIsFocusable;
   916             setFocusPolicy(Qt::NoFocus);
   762             setFocusPolicy(Qt::NoFocus);
   917             setProperty("state", "disabled");
   763             setProperty("state", "disabled");
   918         ungrabGesture(Qt::TapGesture);
   764             ungrabGesture(Qt::TapGesture);
   919         }
   765         }
   920     }
   766     }
   921 
   767 
   922     // selection
   768     // selection
   923     HbAbstractItemView::SelectionMode selectionMode = HbAbstractItemView::NoSelection;
   769     HbAbstractItemView::SelectionMode selectionMode = HbAbstractItemView::NoSelection;
   952 
   798 
   953     setFlags(itemFlags);
   799     setFlags(itemFlags);
   954 
   800 
   955     // multiselection area
   801     // multiselection area
   956     if (    itemSelectable 
   802     if (    itemSelectable 
   957         &&  (   selectionMode == HbAbstractItemView::MultiSelection
   803         &&  selectionMode == HbAbstractItemView::MultiSelection) {
   958             ||  selectionMode == HbAbstractItemView::ContiguousSelection)) {
       
   959         if (!d->mMultiSelectionTouchArea) {
   804         if (!d->mMultiSelectionTouchArea) {
   960             d->mItemsChanged = true;
   805             d->mItemsChanged = true;
   961             d->mMultiSelectionTouchArea = style()->createPrimitive(HbStyle::P_ItemViewItem_touchmultiselection, this);
   806             d->mMultiSelectionTouchArea = style()->createPrimitive(HbStyle::P_ItemViewItem_touchmultiselection, this);
   962         }
   807         }
   963     } else if (d->mMultiSelectionTouchArea) {
   808     } else if (d->mMultiSelectionTouchArea) {
  1002     Q_D(const HbAbstractViewItem);
   847     Q_D(const HbAbstractViewItem);
  1003     return d->mCheckState;
   848     return d->mCheckState;
  1004 }
   849 }
  1005 
   850 
  1006 /*!
   851 /*!
  1007     \deprecated HbAbstractViewItem::setPressed(bool, bool)
       
  1008         is deprecated.
       
  1009 
       
  1010     Sets the item press state to \a pressed. Animation is allowed
       
  1011     if \a animate is set as true; otherwise animation should not
       
  1012     be triggered.
       
  1013 
       
  1014     \sa isPressed, pressStateChanged
       
  1015 */
       
  1016 void HbAbstractViewItem::setPressed(bool pressed, bool animate)
       
  1017 {
       
  1018     qWarning("HbAbstractViewItem::setPressed(bool pressed, bool animate) is deprecated!");
       
  1019 
       
  1020     Q_D(HbAbstractViewItem);
       
  1021 
       
  1022     if (pressed != d->mPressed) {
       
  1023         d->mPressed = pressed;
       
  1024         pressStateChanged(d->mPressed, animate);
       
  1025         if (d->mPressed) {
       
  1026             setProperty("state", "pressed");
       
  1027         } else {
       
  1028             setProperty("state", "normal");
       
  1029         }
       
  1030     }
       
  1031 }
       
  1032 
       
  1033 /*!
       
  1034     This function is called whenever item press state changes. \a pressed is new state.
   852     This function is called whenever item press state changes. \a pressed is new state.
  1035 
   853 
  1036     Animation is allowed if \a animate is set as true; otherwise animation should not
   854     Animation is allowed if \a animate is set as true; otherwise animation should not
  1037     be triggered.
   855     be triggered.
  1038 
   856 
  1056         }
   874         }
  1057             
   875             
  1058         HbStyleOptionAbstractViewItem styleOption;
   876         HbStyleOptionAbstractViewItem styleOption;
  1059         initStyleOption(&styleOption);
   877         initStyleOption(&styleOption);
  1060 
   878 
  1061         style()->updatePrimitive(d->mFocusItem, HbStyle::P_ItemViewItem_focus, &styleOption);
   879         if (d->mFocusItem) {
       
   880             style()->updatePrimitive(d->mFocusItem, HbStyle::P_ItemViewItem_focus, &styleOption);
       
   881         }
  1062 
   882 
  1063         if (doAnimate) {
   883         if (doAnimate) {
  1064             HbEffect::cancel(this, "released");
   884             HbEffect::cancel(this, "released");
  1065             HbEffect::cancel(d->mFocusItem, "released");
   885             HbEffect::cancel(d->mFocusItem, "released");
  1066 
   886 
  1082                 HbEffect::start(d->mFocusItem, sd->mItemType + QString("-focus"), "released", this, "_q_animationFinished");
   902                 HbEffect::start(d->mFocusItem, sd->mItemType + QString("-focus"), "released", this, "_q_animationFinished");
  1083                 QCoreApplication::postEvent(this, new QEvent((QEvent::Type)HbAbstractViewItemShared::ViewItemDeferredDeleteEvent));
   903                 QCoreApplication::postEvent(this, new QEvent((QEvent::Type)HbAbstractViewItemShared::ViewItemDeferredDeleteEvent));
  1084             }
   904             }
  1085         }
   905         }
  1086     }
   906     }
  1087 }
       
  1088 
       
  1089 /*!
       
  1090     \deprecated HbAbstractViewItem::isPressed() const
       
  1091         is deprecated.
       
  1092 
       
  1093     Returns true if the item is pressed; otherwise returns false
       
  1094 
       
  1095     \sa setPressed
       
  1096 */
       
  1097 bool HbAbstractViewItem::isPressed() const
       
  1098 {
       
  1099     qWarning("HbAbstractViewItem::isPressed() const is deprecated!");
       
  1100 
       
  1101     Q_D(const HbAbstractViewItem);
       
  1102     return d->mPressed;
       
  1103 }
   907 }
  1104 
   908 
  1105 /*!
   909 /*!
  1106     Returns the model item type that is retrieved from model index.
   910     Returns the model item type that is retrieved from model index.
  1107 */
   911 */
  1143             && d->mBackgroundItem
   947             && d->mBackgroundItem
  1144             && d->mBackgroundItem->isWidget()) {
   948             && d->mBackgroundItem->isWidget()) {
  1145             qgraphicsitem_cast<HbIconItem *>(static_cast<QGraphicsWidget*>(d->mBackgroundItem))->setBrush(d->mBackground.value<QBrush>());
   949             qgraphicsitem_cast<HbIconItem *>(static_cast<QGraphicsWidget*>(d->mBackgroundItem))->setBrush(d->mBackground.value<QBrush>());
  1146         } 
   950         } 
  1147     }
   951     }
  1148 }
       
  1149 
       
  1150 void HbAbstractViewItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
       
  1151 {
       
  1152     HbWidget::mousePressEvent(event);
       
  1153 }
       
  1154 
       
  1155 void HbAbstractViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
       
  1156 {
       
  1157     HbWidget::mouseMoveEvent(event);
       
  1158 }
       
  1159 
       
  1160 void HbAbstractViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
       
  1161 {
       
  1162     HbWidget::mouseReleaseEvent(event);
       
  1163 }
   952 }
  1164 
   953 
  1165 /*!
   954 /*!
  1166     \reimp
   955     \reimp
  1167 */
   956 */