src/hbwidgets/widgets/hbcheckbox.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    34 #ifdef HB_EFFECTS
    34 #ifdef HB_EFFECTS
    35 #include "hbeffect.h"
    35 #include "hbeffect.h"
    36 #include "hbeffectinternal_p.h"
    36 #include "hbeffectinternal_p.h"
    37 #endif
    37 #endif
    38 
    38 
       
    39 #ifdef HB_GESTURE_FW
       
    40 #include <hbtapgesture.h>
       
    41 #endif
       
    42 
       
    43 
    39 /*
    44 /*
    40     Spacer class.
    45     Spacer class.
    41 */
    46 */
    42 class HbCheckBoxSpacer: public HbWidgetBase
    47 class HbCheckBoxSpacer: public HbWidgetBase
    43 {
    48 {
   119 void HbCheckBoxPrivate::createPrimitives()
   124 void HbCheckBoxPrivate::createPrimitives()
   120 {
   125 {
   121     Q_Q(HbCheckBox);
   126     Q_Q(HbCheckBox);
   122     if(!mTouchArea) {
   127     if(!mTouchArea) {
   123         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)) {
       
   130             ta->grabGesture(Qt::TapGesture);
       
   131         }
   124     }
   132     }
   125     if (!mTextItem) {
   133     if (!mTextItem) {
   126         mTextItem = q->style()->createPrimitive(HbStyle::P_CheckBox_text, q);
   134         mTextItem = q->style()->createPrimitive(HbStyle::P_CheckBox_text, q);
   127         }
   135         }
   128     if (!mIconItem) {
   136     if (!mIconItem) {
   194     setCheckable(true);
   202     setCheckable(true);
   195     d->createPrimitives();
   203     d->createPrimitives();
   196     // creattion of top and bottom spacer.
   204     // creattion of top and bottom spacer.
   197     HbStyle::setItemName( new HbCheckBoxSpacer(this), "topSpacer" );
   205     HbStyle::setItemName( new HbCheckBoxSpacer(this), "topSpacer" );
   198     HbStyle::setItemName( new HbCheckBoxSpacer(this), "bottomSpacer" );
   206     HbStyle::setItemName( new HbCheckBoxSpacer(this), "bottomSpacer" );
       
   207 #ifdef HB_GESTURE_FW
       
   208     grabGesture(Qt::TapGesture);
       
   209 #endif
   199 
   210 
   200 }
   211 }
   201 
   212 
   202 /*!
   213 /*!
   203     @beta
   214     @beta
   292     }
   303     }
   293     return d->checked ? Qt::Checked : Qt::Unchecked;
   304     return d->checked ? Qt::Checked : Qt::Unchecked;
   294 }
   305 }
   295 
   306 
   296 /*!
   307 /*!
       
   308 
       
   309     \deprecated HbCheckBox::primitive(HbStyle::Primitive)
       
   310         is deprecated.
       
   311 
   297     Returns the pointer for \a primitive passed.
   312     Returns the pointer for \a primitive passed.
   298     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
   299     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
   300     user wants different icons.
   315     user wants different icons.
   301 */
   316 */
   427     }
   442     }
   428     HbAbstractButton::nextCheckState();
   443     HbAbstractButton::nextCheckState();
   429     HbCheckBox::checkStateSet();
   444     HbCheckBox::checkStateSet();
   430 }
   445 }
   431 
   446 
       
   447 #ifndef HB_GESTURE_FW
   432 /*!
   448 /*!
   433     \reimp.
   449     \reimp.
   434 */
   450 */
   435 void HbCheckBox::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   451 void HbCheckBox::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   436 {
   452 {
   449     bool hit = hitButton( event->pos( ) );
   465     bool hit = hitButton( event->pos( ) );
   450     if ( hit ) {
   466     if ( hit ) {
   451         HbToolTip::showText(toolTip(), this);
   467         HbToolTip::showText(toolTip(), this);
   452     }   
   468     }   
   453 }
   469 }
   454 
   470 #endif
       
   471 
       
   472 #ifdef HB_GESTURE_FW
       
   473 void HbCheckBox::gestureEvent(QGestureEvent *event)
       
   474 {
       
   475     HbAbstractButton::gestureEvent( event );
       
   476 }
       
   477 #endif
   455 /*!
   478 /*!
   456     \reimp.
   479     \reimp.
   457 */
   480 */
   458 void HbCheckBox::keyPressEvent(QKeyEvent *keyEvent)
   481 void HbCheckBox::keyPressEvent(QKeyEvent *keyEvent)
   459 {
   482 {