src/hbwidgets/dataform/hbdataformviewitem.cpp
changeset 6 c3690ec91ef8
parent 3 11d3954df52a
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 
    26 #include "hbdataformviewitem.h"
    27 #include <hbdataformviewitem.h>
    27 #include "hbdataformviewitem_p.h"
    28 #include <hbstyleoptiondataformviewitem_p.h>
       
    29 
    28 
    30 #include "hbdataformmodelitem_p.h"
    29 #include "hbdataformmodelitem_p.h"
    31 #include "hbdataformviewitem_p.h"
       
    32 #include "hbdataform_p.h"
    30 #include "hbdataform_p.h"
    33 #include "hbdatagroup_p.h"
    31 #include "hbdatagroup_p.h"
    34 
    32 #include "hbstyleoptiondataformviewitem_p.h"
    35 #include "hbtapgesture.h"
    33 
       
    34 #include <hbtapgesture.h>
    36 
    35 
    37 #ifdef HB_EFFECTS
    36 #ifdef HB_EFFECTS
    38 #include "hbeffect.h"
    37 #include "hbeffect.h"
    39 #include "hbeffectinternal_p.h"
    38 #include "hbeffectinternal_p.h"
    40 #define HB_DATAFORMVIEWITEM_TYPE "HB_DATAFORMVIEWITEM"
    39 #define HB_DATAFORMVIEWITEM_TYPE "HB_DATAFORMVIEWITEM"
    69     
    68     
    70     If HbDataFormViewItem represents a GroupItem then it can be expanded and collapsed. 
    69     If HbDataFormViewItem represents a GroupItem then it can be expanded and collapsed. 
    71     If group is expanded then all the child items are shown.
    70     If group is expanded then all the child items are shown.
    72 
    71 
    73     If user wants to create a custom data item then he has to derive from this class and set that
    72     If user wants to create a custom data item then he has to derive from this class and set that
    74     as a protoype for HbDataForm using HbAbstractItemView::setItemPrototype API. While creating
    73     as a prototype for HbDataForm using HbAbstractItemView::setItemPrototype API. While creating
    75     data for custom data items user should pass value greater than or equal to 
    74     data for custom data items user should pass value greater than or equal to 
    76     DataItemType::CustomItemBase. When visualization is created and if data item type is
    75     DataItemType::CustomItemBase. When visualization is created and if data item type is
    77     custom item then createCustomWidget() is called. User has to override this API and pass the
    76     custom item then createCustomWidget() is called. User has to override this API and pass the
    78     custom widget which he wants to show in data item. Below is the code snippet:
    77     custom widget which he wants to show in data item. Below is the code snippet:
    79 
    78 
   238     restore( );
   237     restore( );
   239 
   238 
   240     // Establish Signal Connections set in HbDataFormModel to th contentWidget of this item
   239     // Establish Signal Connections set in HbDataFormModel to th contentWidget of this item
   241     HbDataFormPrivate::d_ptr(
   240     HbDataFormPrivate::d_ptr(
   242         static_cast<HbDataForm*>(d->mSharedData->mItemView))->makeConnection(
   241         static_cast<HbDataForm*>(d->mSharedData->mItemView))->makeConnection(
   243         d->mIndex.operator const QModelIndex & ());
   242         d->mIndex.operator const QModelIndex & (),d->mContentWidget);
       
   243     //update only the background primitive
       
   244     HbStyleOptionDataFormViewItem options;
       
   245     initStyleOption(&options);
       
   246     if( d->mBackgroundItem ) {
       
   247         style()->updatePrimitive(
       
   248             d->mBackgroundItem, HbStyle::P_DataItem_background, &options );
       
   249     }
       
   250 
   244 }
   251 }
   245 
   252 
   246 /*!
   253 /*!
   247     \protected constructor
   254     \protected constructor
   248 */
   255 */
   364     @beta
   371     @beta
   365 
   372 
   366     This is a virtual function which by default returns NULL. This function must be overridden
   373     This is a virtual function which by default returns NULL. This function must be overridden
   367     in case user wants to create a data item of type custom item. The user is supposed to pass
   374     in case user wants to create a data item of type custom item. The user is supposed to pass
   368     the widget which he wants to display in data item.
   375     the widget which he wants to display in data item.
       
   376     If content widget grabs pan gesture and user wants data form to be scrollable even panning
       
   377     is done on disabled content widget then user is supposed to ungrab pan gesture when content 
       
   378     widget is disabled. And again grab pan gesture when state of content widget is changed to 
       
   379     enabled.
   369 */
   380 */
   370 HbWidget* HbDataFormViewItem::createCustomWidget()
   381 HbWidget* HbDataFormViewItem::createCustomWidget()
   371 {
   382 {
   372     return 0;
   383     return 0;
   373 }
   384 }
   484     if( d->mIndex.isValid( ) ) {
   495     if( d->mIndex.isValid( ) ) {
   485         emit itemShown( d->mIndex.operator const QModelIndex & ( ) );
   496         emit itemShown( d->mIndex.operator const QModelIndex & ( ) );
   486     }
   497     }
   487 }
   498 }
   488 
   499 
       
   500 /*!
       
   501     \reimp
       
   502  */
       
   503 QVariant HbDataFormViewItem::itemChange( GraphicsItemChange change, const QVariant &value )
       
   504 {
       
   505     Q_D( HbDataFormViewItem );
       
   506     switch ( static_cast<HbPrivate::HbItemChangeValues>( change ) ) {
       
   507     case QGraphicsItem::ItemEnabledHasChanged: {
       
   508             HbStyleOptionDataFormViewItem options;
       
   509             initStyleOption(&options);
       
   510             if( d->mBackgroundItem ) {
       
   511                 style()->updatePrimitive(
       
   512                 d->mBackgroundItem, HbStyle::P_DataItem_background, &options );
       
   513             }
       
   514             //We are skipping call to abstractviewitem::itemChange here because updateChildItems is 
       
   515             //called in that function which will again create data view item primitives.
       
   516             return HbWidget::itemChange( change, value );
       
   517         }
       
   518         default:
       
   519             break;
       
   520   }
       
   521     return HbAbstractViewItem::itemChange( change, value );
       
   522 }
       
   523 
   489 #include "moc_hbdataformviewitem.cpp"
   524 #include "moc_hbdataformviewitem.cpp"
   490 
   525