src/hbwidgets/widgets/hbgroupboxheadingwidget_p.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    31 #ifdef HB_EFFECTS
    31 #ifdef HB_EFFECTS
    32 #include <hbeffect.h>
    32 #include <hbeffect.h>
    33 #include "hbeffectinternal_p.h"
    33 #include "hbeffectinternal_p.h"
    34 #define HB_GROUPBOX_HEADING_TYPE "HB_GROUPBOX_HEADING"
    34 #define HB_GROUPBOX_HEADING_TYPE "HB_GROUPBOX_HEADING"
    35 #endif
    35 #endif
       
    36 #ifdef HB_GESTURE_FW
       
    37 #include <hbtapgesture.h>
       
    38 #include <QGesture>
       
    39 #endif 
    36 
    40 
    37 #include <QGraphicsSceneMouseEvent>
    41 #include <QGraphicsSceneMouseEvent>
    38 
    42 
    39 /*
    43 /*
    40     internal
    44     internal
    73     internal
    77     internal
    74     init
    78     init
    75 */
    79 */
    76 void HbGroupBoxHeadingWidget::init()
    80 void HbGroupBoxHeadingWidget::init()
    77 {
    81 {
       
    82 
    78     createPrimitives();
    83     createPrimitives();
    79 	
    84 	
    80     if(groupBoxType == GroupBoxCollapsingContainer){
    85     if(groupBoxType == GroupBoxCollapsingContainer){
    81         createConnection();    
    86         createConnection();    
    82     }
    87     }
       
    88 #ifdef HB_GESTURE_FW
       
    89     grabGesture(Qt::TapGesture);
       
    90 #endif 
    83 }
    91 }
    84 
    92 
    85 /*
    93 /*
    86   create primitives
    94   create primitives
    87 */
    95 */
   222     initStyleOption(&groupBoxOption);
   230     initStyleOption(&groupBoxOption);
   223     style()->updatePrimitive( mTextItem, HbStyle::P_GroupBoxMarquee_text, &groupBoxOption);
   231     style()->updatePrimitive( mTextItem, HbStyle::P_GroupBoxMarquee_text, &groupBoxOption);
   224 }
   232 }
   225 
   233 
   226 /*!
   234 /*!
       
   235 
       
   236     \deprecated HbGroupBoxHeadingWidget::primitive(HbStyle::Primitive)
       
   237         is deprecated.
       
   238 
   227     Returns the pointer for \a primitive passed.
   239     Returns the pointer for \a primitive passed.
   228     Will return NULL if \a primitive passed is invalid
   240     Will return NULL if \a primitive passed is invalid
   229 */
   241 */
   230 QGraphicsItem* HbGroupBoxHeadingWidget::primitive(HbStyle::Primitive primitive) const
   242 QGraphicsItem* HbGroupBoxHeadingWidget::primitive(HbStyle::Primitive primitive) const
   231 {
   243 {
   304 /*!
   316 /*!
   305     \reimp
   317     \reimp
   306  */
   318  */
   307 void HbGroupBoxHeadingWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
   319 void HbGroupBoxHeadingWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
   308 {
   320 {
       
   321 #ifdef HB_GESTURE_FW
       
   322     Q_UNUSED(event)
       
   323 #else 
   309     HbWidget::mousePressEvent( event );
   324     HbWidget::mousePressEvent( event );
   310     if ( !collapsable ){
   325     if ( !collapsable ){
   311         event->ignore();
   326         event->ignore();
   312         return;
   327         return;
   313     }
   328     }
   314 
   329 
   315     if (collapsable) {
   330     if (groupBoxType == GroupBoxCollapsingContainer) {
   316         HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierCollapsedItem);
   331         HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierCollapsedItem);
   317     }
   332     }
   318     else {
   333     else {
   319         HbWidgetFeedback::triggered(this, Hb::InstantPressed);
   334         HbWidgetFeedback::triggered(this, Hb::InstantPressed);
   320     }
   335     }
   326     HbStyleOptionGroupBox groupBoxOption;
   341     HbStyleOptionGroupBox groupBoxOption;
   327     initStyleOption(&groupBoxOption);
   342     initStyleOption(&groupBoxOption);
   328     style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
   343     style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
   329 
   344 
   330     setProperty("state", "pressed");
   345     setProperty("state", "pressed");
       
   346 #endif  
   331 }
   347 }
   332 
   348 
   333 /*!
   349 /*!
   334     \reimp
   350     \reimp
   335  */
   351  */
   336 void HbGroupBoxHeadingWidget::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
   352 void HbGroupBoxHeadingWidget::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
   337 {
   353 {
       
   354 #ifdef HB_GESTURE_FW
       
   355     Q_UNUSED(event)
       
   356 #else 
   338     HbWidget::mouseReleaseEvent( event );
   357     HbWidget::mouseReleaseEvent( event );
   339 
   358 
   340     if (collapsable) {
   359     if (groupBoxType == GroupBoxCollapsingContainer) {
   341         HbWidgetFeedback::triggered(this, Hb::InstantReleased, Hb::ModifierCollapsedItem);
   360         HbWidgetFeedback::triggered(this, Hb::InstantReleased, Hb::ModifierCollapsedItem);
   342     }
   361     }
   343     else {
   362     else {
   344         HbWidgetFeedback::triggered(this, Hb::InstantReleased);
   363         HbWidgetFeedback::triggered(this, Hb::InstantReleased);
   345     }
   364     }
   358     HbStyleOptionGroupBox groupBoxOption;
   377     HbStyleOptionGroupBox groupBoxOption;
   359     initStyleOption(&groupBoxOption);
   378     initStyleOption(&groupBoxOption);
   360     style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
   379     style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
   361 
   380 
   362     setProperty("state", "normal");
   381     setProperty("state", "normal");
   363 }
   382 #endif 
   364 
   383 }
       
   384 
       
   385 #ifdef HB_GESTURE_FW
       
   386 void HbGroupBoxHeadingWidget::gestureEvent(QGestureEvent *event)
       
   387 {
       
   388     if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
       
   389         switch(tap->state()) {
       
   390         case Qt::GestureStarted:  //
       
   391             {
       
   392                 if ( !collapsable ){
       
   393                     event->ignore(tap);
       
   394                     return;
       
   395                 }
       
   396                 if (collapsable) {
       
   397                     HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierCollapsedItem);
       
   398                 }
       
   399                 else {
       
   400                     HbWidgetFeedback::triggered(this, Hb::InstantPressed);
       
   401                 }
       
   402 
       
   403                 // background primitive updation, upon mouse press
       
   404                 headingPressed = true;
       
   405 
       
   406                 HbStyleOptionGroupBox groupBoxOption;
       
   407                 initStyleOption(&groupBoxOption);
       
   408                 style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
       
   409 
       
   410                 setProperty("state", "pressed");
       
   411             }
       
   412 
       
   413             break;
       
   414         case Qt::GestureCanceled: // Reset state
       
   415             {
       
   416                 headingPressed = false;
       
   417 
       
   418                 HbStyleOptionGroupBox groupBoxOption;
       
   419                 initStyleOption(&groupBoxOption);
       
   420                 style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
       
   421 
       
   422                 setProperty("state", "normal");
       
   423                 break;
       
   424             }
       
   425         case Qt::GestureFinished: // emit clicked
       
   426             {
       
   427                 if (collapsable) {
       
   428                     HbWidgetFeedback::triggered(this, Hb::InstantReleased, Hb::ModifierCollapsedItem);
       
   429                 } else {
       
   430                     HbWidgetFeedback::triggered(this, Hb::InstantReleased);
       
   431                 }
       
   432 
       
   433                 if ( this->isUnderMouse() ) {
       
   434                     if ( mIconItem && mIconItem->isUnderMouse() ) {
       
   435 #ifdef HB_EFFECTS
       
   436                         HbEffect::start( mIconItem, HB_GROUPBOX_HEADING_TYPE, "iconclick");
       
   437 #endif
       
   438                     }
       
   439                     emit clicked(!collapsed);
       
   440                 }
       
   441                 // background primitive updation, upon mouse release
       
   442                 headingPressed = false;
       
   443 
       
   444                 HbStyleOptionGroupBox groupBoxOption;
       
   445                 initStyleOption(&groupBoxOption);
       
   446                 style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
       
   447 
       
   448                 setProperty("state", "normal");
       
   449             }
       
   450             break;
       
   451         default:
       
   452             break;
       
   453         }
       
   454     }
       
   455 }
       
   456 #endif 
       
   457 
       
   458