src/hbwidgets/widgets/hbcheckbox.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 7 923ff622b8b9
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include <hbcheckbox.h>
    26 #include <hbcheckbox.h>
    27 #include <hbstyleoptioncheckbox.h>
    27 #include <hbstyleoptioncheckbox_p.h>
    28 #include "hbabstractbutton_p.h"
    28 #include "hbabstractbutton_p.h"
    29 #include "hbtooltip.h"
    29 #include "hbtooltip.h"
    30 
    30 
    31 #include <QGraphicsSceneMouseEvent>
    31 #include <QGraphicsSceneMouseEvent>
    32 #include <QGraphicsItem>
    32 #include <QGraphicsItem>
    47 class HbCheckBoxSpacer: public HbWidgetBase
    47 class HbCheckBoxSpacer: public HbWidgetBase
    48 {
    48 {
    49 
    49 
    50 public:
    50 public:
    51     HbCheckBoxSpacer( QGraphicsItem *parent = 0 );
    51     HbCheckBoxSpacer( QGraphicsItem *parent = 0 );
    52     QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
    52     QSizeF sizeHint(  Qt::SizeHint which, const QSizeF &constraint = QSizeF( ) ) const;
    53 };
    53 };
    54 
    54 
    55 HbCheckBoxSpacer::HbCheckBoxSpacer( QGraphicsItem *parent )
    55 HbCheckBoxSpacer::HbCheckBoxSpacer( QGraphicsItem *parent )
    56     : HbWidgetBase( parent )
    56     : HbWidgetBase( parent )
    57 {
    57 {
    58     // seems to be 4.6 only?
    58     // seems to be 4.6 only?
    59     //    setFlag( QGraphicsItem::ItemHasNoContents, true );
    59     //    setFlag( QGraphicsItem::ItemHasNoContents, true );
    60 }
    60 }
    61 
    61 
    62 QSizeF HbCheckBoxSpacer::sizeHint(Qt::SizeHint which, const QSizeF &constraint ) const
    62 QSizeF HbCheckBoxSpacer::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const
    63 {
    63 {
    64     Q_UNUSED( constraint );
    64     Q_UNUSED( constraint );
    65 
    65 
    66     if ( which == Qt::MaximumSize ) {
    66     if ( which == Qt::MaximumSize ) {
    67         return QSizeF( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
    67         return QSizeF( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
    68     }
    68     }
    69     return QSizeF(0.f,0.f);
    69     return QSizeF( 0.f, 0.f );
    70 }
    70 }
    71 
    71 
    72 
    72 
    73 /*
    73 /*
    74   private class
    74   private class
    75 */
    75 */
    76 class HB_AUTOTEST_EXPORT HbCheckBoxPrivate : public HbAbstractButtonPrivate
    76 class HB_AUTOTEST_EXPORT HbCheckBoxPrivate : public HbAbstractButtonPrivate
    77 {
    77 {
    78     Q_DECLARE_PUBLIC(HbCheckBox)
    78     Q_DECLARE_PUBLIC( HbCheckBox )
    79 
    79 
    80 public:
    80 public:
    81     HbCheckBoxPrivate();
    81     HbCheckBoxPrivate( );
    82     virtual ~HbCheckBoxPrivate();
    82     virtual ~HbCheckBoxPrivate( );
    83 
    83 
    84     void createPrimitives();
    84     void createPrimitives( );
    85 
    85 
    86 public:
    86 public:
    87     QString mText;
    87     QString mText;
    88     QGraphicsItem *mTextItem;
    88     QGraphicsItem *mTextItem;
    89     QGraphicsItem *mIconItem;
    89     QGraphicsItem *mIconItem;
    96 
    96 
    97 /*
    97 /*
    98   private class constructor
    98   private class constructor
    99 */
    99 */
   100 HbCheckBoxPrivate::HbCheckBoxPrivate():
   100 HbCheckBoxPrivate::HbCheckBoxPrivate():
   101     mTextItem(0),
   101     mTextItem( 0 ),
   102     mIconItem(0), 
   102     mIconItem( 0 ), 
   103     mTouchArea(0),
   103     mTouchArea( 0 ),
   104     mTristate(false),
   104     mTristate( false ),
   105     mNoChange(false),
   105     mNoChange( false ),
   106     mPublishedState(Qt::Unchecked)
   106     mPublishedState( Qt::Unchecked )
   107 {
   107 {
   108     //adding effect for checkbox
   108     //adding effect for checkbox
   109 #ifdef HB_EFFECTS
   109 #ifdef HB_EFFECTS
   110     HbEffectInternal::add(HB_CHECKBOX_TYPE,"checkbox_selected", "pressed");
   110     HbEffectInternal::add( HB_CHECKBOX_TYPE,"checkbox_selected", "pressed" );
   111 #endif
   111 #endif
   112 }
   112 }
   113 
   113 
   114 /*
   114 /*
   115   private class destructor
   115   private class destructor
   116 */
   116 */
   117 HbCheckBoxPrivate::~HbCheckBoxPrivate()
   117 HbCheckBoxPrivate::~HbCheckBoxPrivate( )
   118 {
   118 {
   119 }
   119 }
   120 
   120 
   121 /*
   121 /*
   122   create primitive
   122   create primitive
   123 */
   123 */
   124 void HbCheckBoxPrivate::createPrimitives()
   124 void HbCheckBoxPrivate::createPrimitives( )
   125 {
   125 {
   126     Q_Q(HbCheckBox);
   126     Q_Q( HbCheckBox );
   127     if(!mTouchArea) {
   127     if( !mTouchArea ) {
   128         mTouchArea = q->style()->createPrimitive(HbStyle::P_CheckBox_toucharea, q);
   128         mTouchArea = q->style( )->createPrimitive( HbStyle::P_CheckBox_toucharea, q );
   129         if(QGraphicsObject *ta = qgraphicsitem_cast<QGraphicsObject*>(mTouchArea)) {
   129         if( QGraphicsObject *ta = qgraphicsitem_cast<QGraphicsObject*>( mTouchArea ) ) {
   130             ta->grabGesture(Qt::TapGesture);
   130             ta->grabGesture( Qt::TapGesture );
   131         }
   131         }
   132     }
   132     }
   133     if (!mTextItem) {
   133     if ( !mTextItem ) {
   134         mTextItem = q->style()->createPrimitive(HbStyle::P_CheckBox_text, q);
   134         mTextItem = q->style( )->createPrimitive( HbStyle::P_CheckBox_text, q );
   135         }
   135         }
   136     if (!mIconItem) {
   136     if ( !mIconItem ) {
   137         mIconItem = q->style()->createPrimitive(HbStyle::P_CheckBox_icon, q);
   137         mIconItem = q->style( )->createPrimitive( HbStyle::P_CheckBox_icon, q );
   138     }
   138     }
   139 }
   139 }
   140 
   140 
   141 /*!
   141 /*!
   142     @beta
   142     @beta
   192     @beta
   192     @beta
   193     Constructor an object of HbCheckBox with default parameters.
   193     Constructor an object of HbCheckBox with default parameters.
   194     By default the state of check box will be Unchecked, text will
   194     By default the state of check box will be Unchecked, text will
   195     be empty and tristate will be false.
   195     be empty and tristate will be false.
   196 */
   196 */
   197 HbCheckBox::HbCheckBox(QGraphicsItem *parent)
   197 HbCheckBox::HbCheckBox( QGraphicsItem *parent )
   198     : HbAbstractButton(*new HbCheckBoxPrivate, parent)
   198     : HbAbstractButton( *new HbCheckBoxPrivate, parent )
   199 {
   199 {
   200     Q_D(HbCheckBox);
   200     Q_D( HbCheckBox );
   201     d->q_ptr = this;
   201     d->q_ptr = this;
   202     setCheckable(true);
   202     setCheckable( true );
   203     d->createPrimitives();
   203     d->createPrimitives( );
   204     // creattion of top and bottom spacer.
   204     // creattion of top and bottom spacer.
   205     HbStyle::setItemName( new HbCheckBoxSpacer(this), "topSpacer" );
   205     HbStyle::setItemName( new HbCheckBoxSpacer( this ), "topSpacer" );
   206     HbStyle::setItemName( new HbCheckBoxSpacer(this), "bottomSpacer" );
   206     HbStyle::setItemName( new HbCheckBoxSpacer( this ), "bottomSpacer" );
   207 #ifdef HB_GESTURE_FW
   207 #ifdef HB_GESTURE_FW
   208     grabGesture(Qt::TapGesture);
   208     grabGesture( Qt::TapGesture );
   209 #endif
   209 #endif
   210 
   210 
   211 }
   211 }
   212 
   212 
   213 /*!
   213 /*!
   214     @beta
   214     @beta
   215     Constructor an object of HbCheckBox with \a text passed.
   215     Constructor an object of HbCheckBox with \a text passed.
   216     By default the state of check box will be Unchecked.
   216     By default the state of check box will be Unchecked.
   217     Tristate will be false by default.
   217     Tristate will be false by default.
   218 */
   218 */
   219 HbCheckBox::HbCheckBox(const QString &text, QGraphicsItem *parent )
   219 HbCheckBox::HbCheckBox( const QString &text, QGraphicsItem *parent )
   220     : HbAbstractButton(*new HbCheckBoxPrivate, parent)
   220     : HbAbstractButton( *new HbCheckBoxPrivate, parent )
   221 {
   221 {
   222     Q_D(HbCheckBox);
   222     Q_D( HbCheckBox );
   223     d->q_ptr = this;
   223     d->q_ptr = this;
   224     d->mText = text;
   224     d->mText = text;
   225     setCheckable(true);
   225     setCheckable( true );
   226     d->createPrimitives();
   226     d->createPrimitives( );
   227     // creattion of top and bottom spacer.
   227     // creattion of top and bottom spacer.
   228     HbStyle::setItemName( new HbCheckBoxSpacer(this), "topSpacer");
   228     HbStyle::setItemName( new HbCheckBoxSpacer(this), "topSpacer");
   229     HbStyle::setItemName( new HbCheckBoxSpacer(this), "bottomSpacer");
   229     HbStyle::setItemName( new HbCheckBoxSpacer(this), "bottomSpacer");
   230 
   230 
   231 }
   231 }
   232 
   232 
   233 /*!
   233 /*!
   234     Destructor.
   234     Destructor.
   235 */
   235 */
   236 HbCheckBox::~HbCheckBox()
   236 HbCheckBox::~HbCheckBox( )
   237 {
   237 {
   238 }
   238 }
   239 
   239 
   240 /*!
   240 /*!
   241     @beta
   241     @beta
   243     UpdatePrimitive is called by this functions once the text is changed.
   243     UpdatePrimitive is called by this functions once the text is changed.
   244     \sa text()
   244     \sa text()
   245 */
   245 */
   246 void HbCheckBox::setText( const QString &text )
   246 void HbCheckBox::setText( const QString &text )
   247 {
   247 {
   248     Q_D(HbCheckBox);
   248     Q_D( HbCheckBox );
   249     if(d->mText != text){
   249     if( d->mText != text ){
   250         d->mText = text;
   250         d->mText = text;
   251         //updatePrimitives();
   251         //updatePrimitives();
   252         if( d->mTextItem ){
   252         if( d->mTextItem ){
   253             HbStyleOptionCheckBox checkBoxOption;
   253             HbStyleOptionCheckBox checkBoxOption;
   254             initStyleOption(&checkBoxOption);
   254             initStyleOption( &checkBoxOption );
   255             style()->updatePrimitive(d->mTextItem, HbStyle::P_CheckBox_text, &checkBoxOption);
   255             style( )->updatePrimitive( d->mTextItem, HbStyle::P_CheckBox_text, &checkBoxOption );
   256         }
   256         }
   257     }    
   257     }    
   258 }
   258 }
   259 
   259 
   260 /*!
   260 /*!
   261     @beta
   261     @beta
   262     Returns the text of checkbox.
   262     Returns the text of checkbox.
   263     \sa setText()
   263     \sa setText()
   264 */
   264 */
   265 QString HbCheckBox::text() const
   265 QString HbCheckBox::text( ) const
   266 {
   266 {
   267     Q_D(const HbCheckBox);
   267     Q_D( const HbCheckBox );
   268     return d->mText;
   268     return d->mText;
   269 }
   269 }
   270 
   270 
   271 /*!
   271 /*!
   272     @beta
   272     @beta
   274     By default tristate is false and checkbox has got only two states.
   274     By default tristate is false and checkbox has got only two states.
   275     \sa isTristate( )
   275     \sa isTristate( )
   276 */
   276 */
   277 void HbCheckBox::setTristate( bool isTristate )
   277 void HbCheckBox::setTristate( bool isTristate )
   278 {
   278 {
   279     Q_D(HbCheckBox);
   279     Q_D( HbCheckBox );
   280     d->mTristate = isTristate;
   280     d->mTristate = isTristate;
   281 }
   281 }
   282 
   282 
   283 /*!
   283 /*!
   284     @beta
   284     @beta
   285     Returns whether tristate is enabled for checkbox or not.
   285     Returns whether tristate is enabled for checkbox or not.
   286     \sa setTristate( )
   286     \sa setTristate( )
   287 */
   287 */
   288 bool HbCheckBox::isTristate( ) const
   288 bool HbCheckBox::isTristate( ) const
   289 {
   289 {
   290     Q_D(const HbCheckBox);
   290     Q_D( const HbCheckBox );
   291     return d->mTristate;
   291     return d->mTristate;
   292 }
   292 }
   293 
   293 
   294 /*!
   294 /*!
   295     @beta
   295     @beta
   296     Returns the current state of HbCheckBox.
   296     Returns the current state of HbCheckBox.
   297 */
   297 */
   298 Qt::CheckState HbCheckBox::checkState() const
   298 Qt::CheckState HbCheckBox::checkState() const
   299 {
   299 {
   300     Q_D(const HbCheckBox);
   300     Q_D( const HbCheckBox );
   301     if (d->mTristate &&  d->mNoChange) {
   301     if ( d->mTristate &&  d->mNoChange ) {
   302         return Qt::PartiallyChecked;
   302         return Qt::PartiallyChecked;
   303     }
   303     }
   304     return d->checked ? Qt::Checked : Qt::Unchecked;
   304     return d->checked ? Qt::Checked : Qt::Unchecked;
   305 }
   305 }
   306 
   306 
   312     Returns the pointer for \a primitive passed.
   312     Returns the pointer for \a primitive passed.
   313     Will return NULL if \a primitive passed is icon because user cannot
   313     Will return NULL if \a primitive passed is icon because user cannot
   314     configure the check and unchecked icons. Style needs to be changed if
   314     configure the check and unchecked icons. Style needs to be changed if
   315     user wants different icons.
   315     user wants different icons.
   316 */
   316 */
   317 QGraphicsItem* HbCheckBox::primitive(HbStyle::Primitive primitive) const
   317 QGraphicsItem *HbCheckBox::primitive( HbStyle::Primitive primitive ) const
   318 {
   318 {
   319     Q_D(const HbCheckBox);
   319     Q_D( const HbCheckBox );
   320 
   320 
   321     switch (primitive) {
   321     switch ( primitive ) {
   322         case HbStyle::P_CheckBox_text:
   322         case HbStyle::P_CheckBox_text:
   323             return d->mTextItem;
   323             return d->mTextItem;
   324         case HbStyle::P_CheckBox_toucharea:
   324         case HbStyle::P_CheckBox_toucharea:
   325             return d->mTouchArea;
   325             return d->mTouchArea;
   326         case HbStyle::P_CheckBox_icon:
   326         case HbStyle::P_CheckBox_icon:
   336     Calls updatePrimitive when state is changed.
   336     Calls updatePrimitive when state is changed.
   337     Emits signal stateChanged(state).
   337     Emits signal stateChanged(state).
   338 */
   338 */
   339 void HbCheckBox::setCheckState( Qt::CheckState state )
   339 void HbCheckBox::setCheckState( Qt::CheckState state )
   340 {
   340 {
   341     Q_D(HbCheckBox);
   341     Q_D( HbCheckBox );
   342     if (state == Qt::PartiallyChecked) {
   342     if (state == Qt::PartiallyChecked) {
   343         d->mTristate = true;
   343         d->mTristate = true;
   344         d->mNoChange = true;
   344         d->mNoChange = true;
   345     } else {
   345     } else {
   346         d->mNoChange = false;
   346         d->mNoChange = false;
   347     }
   347     }
   348     d->blockRefresh = true;
   348     d->blockRefresh = true;
   349     setChecked(state != Qt::Unchecked);
   349     setChecked( state != Qt::Unchecked );
   350     d->blockRefresh = false;
   350     d->blockRefresh = false;
   351     d->refresh();
   351     d->refresh( );
   352 
   352 
   353     if (state != d->mPublishedState) {
   353     if ( state != d->mPublishedState ) {
   354         d->mPublishedState = state;
   354         d->mPublishedState = state;
   355         emit stateChanged(state);
   355         emit stateChanged( state );
   356     }
   356     }
   357 }
   357 }
   358 
   358 
   359 /*!
   359 /*!
   360     Updates the icon and text primitives.
   360     Updates the icon and text primitives.
   361 */
   361 */
   362 void HbCheckBox::updatePrimitives()
   362 void HbCheckBox::updatePrimitives( )
   363 {
   363 {
   364     HbWidget::updatePrimitives();
   364     HbWidget::updatePrimitives( );
   365     Q_D(HbCheckBox);
   365     Q_D( HbCheckBox );
   366 
   366 
   367     HbStyleOptionCheckBox checkBoxOption;
   367     HbStyleOptionCheckBox checkBoxOption;
   368     initStyleOption(&checkBoxOption);
   368     initStyleOption( &checkBoxOption );
   369 
   369 
   370     if (d->mTextItem) {
   370     if ( d->mTextItem ) {
   371         style()->updatePrimitive(d->mTextItem, HbStyle::P_CheckBox_text, &checkBoxOption);
   371         style( )->updatePrimitive( d->mTextItem, HbStyle::P_CheckBox_text, &checkBoxOption );
   372     }
   372     }
   373     if (d->mIconItem) {
   373     if ( d->mIconItem ) {
   374         style()->updatePrimitive(d->mIconItem, HbStyle::P_CheckBox_icon, &checkBoxOption);
   374         style( )->updatePrimitive( d->mIconItem, HbStyle::P_CheckBox_icon, &checkBoxOption );
   375     }
   375     }
   376     if (d->mTouchArea) {
   376     if (d->mTouchArea) {
   377         style()->updatePrimitive(d->mTouchArea, HbStyle::P_CheckBox_toucharea, &checkBoxOption);
   377         style( )->updatePrimitive( d->mTouchArea, HbStyle::P_CheckBox_toucharea, &checkBoxOption );
   378     }
   378     }
   379 }
   379 }
   380 
   380 
   381 /*!
   381 /*!
   382     Initializes the style for check box with the \a option passed.
   382     Initializes the style for check box with the \a option passed.
   383 */
   383 */
   384 void HbCheckBox::initStyleOption(HbStyleOptionCheckBox *option) const
   384 void HbCheckBox::initStyleOption(HbStyleOptionCheckBox *option) const
   385 {
   385 {
   386     Q_D(const HbCheckBox);
   386     Q_D( const HbCheckBox );
   387 
   387 
   388     HbAbstractButton::initStyleOption(option);
   388     HbAbstractButton::initStyleOption( option );
   389 
   389 
   390     Q_ASSERT(option);
   390     Q_ASSERT( option );
   391     option->text = d->mText;
   391     option->text = d->mText;
   392     if (d->mTristate && d->mNoChange){
   392     if ( d->mTristate && d->mNoChange ){
   393         option->state.operator = (QStyle::State_NoChange);
   393         option->state.operator = ( QStyle::State_NoChange );
   394     } else {
   394     } else {
   395         option->state.operator = (d->checked ? QStyle::State_On : QStyle::State_Off);
   395         option->state.operator = ( d->checked ? QStyle::State_On : QStyle::State_Off );
   396     }
   396     }
   397 }
   397 }
   398 
   398 
   399 /*!
   399 /*!
   400     Updates the primitive as per new size.
   400     Updates the primitive as per new size.
   401 */
   401 */
   402 void HbCheckBox::resizeEvent(QGraphicsSceneResizeEvent *event)
   402 void HbCheckBox::resizeEvent( QGraphicsSceneResizeEvent *event )
   403 {
   403 {
   404     HbAbstractButton::resizeEvent(event);
   404     HbAbstractButton::resizeEvent( event );
   405 }
   405 }
   406 
   406 
   407 /*!
   407 /*!
   408   Overloaded hit detection to include touch area
   408   Overloaded hit detection to include touch area
   409  */
   409  */
   410 bool HbCheckBox::hitButton( const QPointF &pos ) const
   410 bool HbCheckBox::hitButton( const QPointF &pos ) const
   411 {
   411 {
   412     Q_D(const HbCheckBox);
   412     Q_D(const HbCheckBox);
   413     QRectF compRect = d->mTouchArea->boundingRect();
   413     QRectF compRect = d->mTouchArea->boundingRect( );
   414     compRect.translate(d->mTouchArea->pos());
   414     compRect.translate( d->mTouchArea->pos( ) );
   415     return compRect.contains(pos);
   415     return compRect.contains( pos );
   416 }
   416 }
   417 
   417 
   418 /*!
   418 /*!
   419     \reimp.
   419     \reimp.
   420 */
   420 */
   421 void HbCheckBox::checkStateSet( )
   421 void HbCheckBox::checkStateSet( )
   422 {
   422 {
   423     Q_D(HbCheckBox);
   423     Q_D(HbCheckBox);
   424     d->mNoChange = false;
   424     d->mNoChange = false;
   425     Qt::CheckState state = checkState();
   425     Qt::CheckState state = checkState( );
   426     if (state != d->mPublishedState) {
   426     if ( state != d->mPublishedState ) {
   427         #ifdef HB_EFFECTS
   427         #ifdef HB_EFFECTS
   428             HbEffect::start(d->mIconItem, HB_CHECKBOX_TYPE, "pressed");
   428             HbEffect::start( d->mIconItem, HB_CHECKBOX_TYPE, "pressed" );
   429         #endif
   429         #endif
   430         d->mPublishedState = state;
   430         d->mPublishedState = state;
   431         emit stateChanged(state);
   431         emit stateChanged( state );
   432     }
   432     }
   433 }
   433 }
   434 
   434 
   435 /*!
   435 /*!
   436     \reimp.
   436     \reimp.
   437 */
   437 */
   438 void HbCheckBox::nextCheckState( )
   438 void HbCheckBox::nextCheckState( )
   439 {
   439 {
   440     if( checkState() == Qt::PartiallyChecked ) {
   440     if( checkState( ) == Qt::PartiallyChecked ) {
   441         HbAbstractButton::nextCheckState();
   441         HbAbstractButton::nextCheckState( );
   442     }
   442     }
   443     HbAbstractButton::nextCheckState();
   443     HbAbstractButton::nextCheckState( );
   444     HbCheckBox::checkStateSet();
   444     HbCheckBox::checkStateSet( );
   445 }
   445 }
   446 
   446 
   447 #ifndef HB_GESTURE_FW
   447 #ifndef HB_GESTURE_FW
   448 /*!
   448 /*!
   449     \reimp.
   449     \reimp.
   450 */
   450 */
   451 void HbCheckBox::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   451 void HbCheckBox::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
   452 {
   452 {
   453     HbAbstractButton::mouseReleaseEvent(event);
   453     HbAbstractButton::mouseReleaseEvent( event );
   454     updatePrimitives();
   454     updatePrimitives();
   455 }
   455 }
   456 
   456 
   457 /*!
   457 /*!
   458     \reimp.
   458     \reimp.
   459 */
   459 */
   460 void HbCheckBox::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
   460 void HbCheckBox::mouseMoveEvent( QGraphicsSceneMouseEvent *event )
   461 {
   461 {
   462     Q_UNUSED(event);
   462     Q_UNUSED( event );
   463     // To show the tooltip on press,move outside and come back to same button.
   463     // To show the tooltip on press,move outside and come back to same button.
   464     // check for hit pos 
   464     // check for hit pos 
   465     bool hit = hitButton( event->pos( ) );
   465     bool hit = hitButton( event->pos( ) );
   466     if ( hit ) {
   466     if ( hit ) {
   467         HbToolTip::showText(toolTip(), this);
   467         HbToolTip::showText( toolTip(), this );
   468     }   
   468     }   
   469 }
   469 }
   470 #endif
   470 #endif
   471 
   471 
   472 #ifdef HB_GESTURE_FW
   472 #ifdef HB_GESTURE_FW
   473 void HbCheckBox::gestureEvent(QGestureEvent *event)
   473 void HbCheckBox::gestureEvent( QGestureEvent *event )
   474 {
   474 {
   475     HbAbstractButton::gestureEvent( event );
   475     HbAbstractButton::gestureEvent( event );
   476 }
   476 }
   477 #endif
   477 #endif
   478 /*!
   478 /*!
   479     \reimp.
   479     \reimp.
   480 */
   480 */
   481 void HbCheckBox::keyPressEvent(QKeyEvent *keyEvent)
   481 void HbCheckBox::keyPressEvent(QKeyEvent *keyEvent)
   482 {
   482 {
   483     switch (keyEvent->key()) {
   483     switch ( keyEvent->key( ) ) {
   484     case Qt::Key_Select:
   484     case Qt::Key_Select:
   485     case Qt::Key_Enter:
   485     case Qt::Key_Enter:
   486     case Qt::Key_Return:
   486     case Qt::Key_Return:
   487             HbAbstractButton::keyPressEvent(keyEvent);
   487             HbAbstractButton::keyPressEvent( keyEvent );
   488         break;
   488         break;
   489     default:
   489     default:
   490             HbAbstractButton::keyPressEvent(keyEvent);
   490             HbAbstractButton::keyPressEvent( keyEvent );
   491     }
   491     }
   492 }
   492 }
   493 
   493 
   494 /*!
   494 /*!
   495     \reimp
   495     \reimp
   496  */
   496  */
   497 QVariant HbCheckBox::itemChange(GraphicsItemChange change, const QVariant &value)
   497 QVariant HbCheckBox::itemChange( GraphicsItemChange change, const QVariant &value )
   498 {
   498 {
   499     switch ( change ) {
   499     switch ( change ) {
   500         case ItemEnabledHasChanged:
   500         case ItemEnabledHasChanged:
   501         case ItemVisibleChange: {
   501         case ItemVisibleChange: {
   502                 updatePrimitives( );
   502                 updatePrimitives( );