src/hbwidgets/itemviews/hbabstractviewitem.cpp
changeset 6 c3690ec91ef8
parent 5 627c4a0fd0e7
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    72     To support multiple Abstractview items within single AbstractItemview, you must also provide an implementation of canSetModelIndex().
    72     To support multiple Abstractview items within single AbstractItemview, you must also provide an implementation of canSetModelIndex().
    73 
    73 
    74     If derived abstract view item has transient state information that is not meaningful to store within model index (child item cursor 
    74     If derived abstract view item has transient state information that is not meaningful to store within model index (child item cursor 
    75     position selection areas etc.) this information can be supplied to transient state model. Transient state model is maintained 
    75     position selection areas etc.) this information can be supplied to transient state model. Transient state model is maintained 
    76     internally by abstract item view. 
    76     internally by abstract item view. 
    77 */
    77 
       
    78 
       
    79     \primitives
       
    80     \primitive{background} HbIconItem representing the item background. This primitive exists in cases the model's Qt::BackgroundRole returns HbIcon or QBrush for this item.
       
    81     \primitive{frame} HbFrameItem representing the background frame of the item. This primitive exists if background primitive does not exist and the model's Qt::BackgroundRole returns HbFrameBackground or there is a default frame set with the setDefaultFrame(). An item can have either the frame or the background primitive, but not the both at the same time.
       
    82     \primitive{selection-icon} HbIconItem representing the checkbox in the multi selection mode.
       
    83     \primitive{multiselection-toucharea} HbTouchArea used in extending the touch area of the selection-icon. 
       
    84 */
       
    85 
       
    86 /*!
       
    87     \enum HbAbstractViewItem::SelectionAreaType
       
    88 
       
    89     Enumeration specifies selection area types. 
       
    90     
       
    91     Multiselection selection mode may operate in contiguous selection mode, in which items are selected 
       
    92     or deselected by panning over items. Normal multiselection functionality is available also in this mode.
       
    93     Location of touch down gesture determines whether contiguous selection mode is activated.
       
    94 
       
    95     \sa HbAbstractViewItem::selectionAreaContains(const QPointF &position, SelectionAreaType selectionAreaType) const
       
    96 */
       
    97 
       
    98 /*!
       
    99     \var HbAbstractViewItem::SingleSelection
       
   100 
       
   101     Selection area for single selection mode.
       
   102 
       
   103     \sa HbAbstractViewItem::selectionAreaContains(const QPointF &position, SelectionAreaType selectionAreaType) const
       
   104 */
       
   105 
       
   106 
       
   107 /*!
       
   108     \var HbAbstractViewItem::MultiSelection
       
   109 
       
   110     Selection area for multiple selection mode.
       
   111 
       
   112     \sa HbAbstractViewItem::selectionAreaContains(const QPointF &position, SelectionAreaType selectionAreaType) const
       
   113 */
       
   114 
       
   115 
       
   116 /*!
       
   117     \var HbAbstractViewItem::ContiguousSelection
       
   118 
       
   119     Selection area for contiguous selection mode. 
       
   120 
       
   121     \sa HbAbstractViewItem::selectionAreaContains(const QPointF &position, SelectionAreaType selectionAreaType) const
       
   122 */
       
   123 
    78 
   124 
    79 /*!
   125 /*!
    80     \fn void HbAbstractViewItem::pressed(const QPointF &position)
   126     \fn void HbAbstractViewItem::pressed(const QPointF &position)
    81 
   127 
    82     This signal is emitted when a touch down event is received for this view item.
   128     This signal is emitted when a touch down event is received for this view item.
   153 
   199 
   154         mSharedData->mCloneItems.append(q);
   200         mSharedData->mCloneItems.append(q);
   155     }
   201     }
   156 }
   202 }
   157 
   203 
       
   204 /*!
       
   205     Returns Hb::ModelItemType of this view item.
       
   206 
       
   207     \sa Hb::ModelItemType
       
   208 */
   158 int HbAbstractViewItemPrivate::modelItemType() const
   209 int HbAbstractViewItemPrivate::modelItemType() const
   159 {
   210 {
   160     return mIndex.data(Hb::ItemTypeRole).toInt();
   211     return mIndex.data(Hb::ItemTypeRole).toInt();
   161 }
   212 }
   162 
   213 
   515     Check whether \a position is inside the selection area of the given selectionAreaType in the view item.
   566     Check whether \a position is inside the selection area of the given selectionAreaType in the view item.
   516 
   567 
   517     Default selection areas are for
   568     Default selection areas are for
   518     \li HbAbstractViewItem::SingleSelection mode: whole item
   569     \li HbAbstractViewItem::SingleSelection mode: whole item
   519     \li HbAbstractViewItem::MultiSelection mode: whole item.
   570     \li HbAbstractViewItem::MultiSelection mode: whole item.
   520     \li HbAbstractItemView::NoSelection mode: none
   571     \li HbAbstractViewItem::ContiguousSelection mode: area of HbStyle::P_ItemViewItem_touchmultiselection icon.
   521 
   572 
   522     The \a selectionAreaType tells what kind of selection area is requested.  The parameter value ContiguousSelection returns 
   573     The \a selectionAreaType tells what kind of selection area is requested.  The parameter value ContiguousSelection returns 
   523 	the area where mouse movement will extend the selection to new items. By default this contiguous selection area is 
   574     the area where mouse movement will extend the selection to new items. By default this contiguous selection area is 
   524 	the HbStyle::P_ItemViewItem_touchmultiselection.
   575     the HbStyle::P_ItemViewItem_touchmultiselection.
   525     
   576     
   526 */
   577 */
   527 bool HbAbstractViewItem::selectionAreaContains(const QPointF &position, SelectionAreaType selectionAreaType) const
   578 bool HbAbstractViewItem::selectionAreaContains(const QPointF &position, SelectionAreaType selectionAreaType) const
   528 {
   579 {
   529     Q_D(const HbAbstractViewItem);
   580     Q_D(const HbAbstractViewItem);
   611                 QGraphicsLayout *parentLayout = static_cast<QGraphicsLayout *>(parentLayoutItem);
   662                 QGraphicsLayout *parentLayout = static_cast<QGraphicsLayout *>(parentLayoutItem);
   612                 parentLayout->invalidate();
   663                 parentLayout->invalidate();
   613             }
   664             }
   614             break;
   665             break;
   615         }
   666         }
       
   667         case ItemEnabledHasChanged: {
       
   668             updateChildItems();
       
   669             break;
       
   670         }
   616         default:
   671         default:
   617             break;
   672             break;
   618     }
   673     }
   619 
   674 
   620     return HbWidget::itemChange(change, value);
   675     return HbWidget::itemChange(change, value);
   621 }
   676 }
   622 
   677 
   623 /*!
   678 /*!
   624     \reimp
   679     \reimp
   625 
   680 
   626     To optimise loading css/xml definitions to take place only once, this function should be
   681     To optimize loading css/xml definitions to take place only once, this function should be
   627     called only after other primitives (child items) has been created.
   682     called only after other primitives (child items) has been created.
   628 
   683 
   629 */
   684 */
   630 void HbAbstractViewItem::updatePrimitives()
   685 void HbAbstractViewItem::updatePrimitives()
   631 {
   686 {
   774     } 
   829     } 
   775 
   830 
   776     GraphicsItemFlags itemFlags = flags();
   831     GraphicsItemFlags itemFlags = flags();
   777     Qt::ItemFlags indexFlags = d->mIndex.flags();
   832     Qt::ItemFlags indexFlags = d->mIndex.flags();
   778 
   833 
   779     if (indexFlags & Qt::ItemIsEnabled) {
   834     if ((indexFlags & Qt::ItemIsEnabled) && sd->mItemView && sd->mItemView->isEnabled()) {
   780         if (!(itemFlags & QGraphicsItem::ItemIsFocusable)) {
   835         if (!(itemFlags & QGraphicsItem::ItemIsFocusable)) {
   781             itemFlags |= QGraphicsItem::ItemIsFocusable;
   836             itemFlags |= QGraphicsItem::ItemIsFocusable;
   782             setFocusPolicy(sd->mPrototype->focusPolicy());
   837             setFocusPolicy(sd->mPrototype->focusPolicy());
   783             setProperty("state", "normal");
   838             setProperty("state", "normal");
   784             grabGesture(Qt::TapGesture);
   839             grabGesture(Qt::TapGesture);