src/hbwidgets/widgets/hbgroupboxheadingwidget_p.cpp
changeset 7 923ff622b8b9
parent 6 c3690ec91ef8
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
    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
    36 #ifdef HB_GESTURE_FW
    37 #include <hbtapgesture.h>
    37 #include <hbtapgesture.h>
       
    38 #include <hbnamespace_p.h>
    38 #include <QGesture>
    39 #include <QGesture>
       
    40 #include <QGraphicsScene>
    39 #endif 
    41 #endif 
    40 
    42 
    41 #include <QGraphicsSceneMouseEvent>
    43 #include <QGraphicsSceneMouseEvent>
    42 
    44 
    43 /*
    45 /*
    77     init
    79     init
    78 */
    80 */
    79 void HbGroupBoxHeadingWidget::init( )
    81 void HbGroupBoxHeadingWidget::init( )
    80 {
    82 {
    81     createPrimitives( );
    83     createPrimitives( );
    82     if ( groupBoxType == GroupBoxCollapsingContainer ){
       
    83         createConnection( );    
       
    84     }
       
    85 #ifdef HB_GESTURE_FW
    84 #ifdef HB_GESTURE_FW
    86     grabGesture( Qt::TapGesture );
    85     grabGesture( Qt::TapGesture );
    87 #endif 
    86 #endif 
    88 }
    87 }
    89 
    88 
   195     internal
   194     internal
   196     Sets the groupbox heading widgets text
   195     Sets the groupbox heading widgets text
   197 */
   196 */
   198 void HbGroupBoxHeadingWidget::setHeading( const QString &text )
   197 void HbGroupBoxHeadingWidget::setHeading( const QString &text )
   199 {
   198 {
   200     if( headingText == text ) 
   199     if( headingText != text ){
   201         return;
   200         headingText = text;
   202 
   201 
   203     headingText = text;
   202         HbStyleOptionGroupBox groupBoxOption;
   204 
   203         initStyleOption( &groupBoxOption );
   205     HbStyleOptionGroupBox groupBoxOption;
   204         if ( groupBoxType == GroupBoxCollapsingContainer ) {
   206     initStyleOption( &groupBoxOption );
   205             style( )->updatePrimitive( mTextItem , HbStyle::P_GroupBoxHeading_text , &groupBoxOption );
   207     if ( groupBoxType == GroupBoxCollapsingContainer ) {
   206         }
   208         style( )->updatePrimitive( mTextItem , HbStyle::P_GroupBoxHeading_text , &groupBoxOption );
   207         else {
   209     }
   208            style( )->updatePrimitive( mTextItem , HbStyle::P_GroupBoxMarquee_text , &groupBoxOption );
   210     else {
   209         }
   211        style( )->updatePrimitive( mTextItem , HbStyle::P_GroupBoxMarquee_text , &groupBoxOption );
       
   212     }
   210     }
   213 }
   211 }
   214 
   212 
   215 /*!
   213 /*!
   216     internal
   214     internal
   217     Sets marquee for groupbox heading
   215     Sets marquee for groupbox heading
   218 */
   216 */
   219 void HbGroupBoxHeadingWidget::setMarqueeHeading( bool marquee )
   217 void HbGroupBoxHeadingWidget::setMarqueeHeading( bool marquee )
   220 {
   218 {
   221     if( marqueeEnabled == marquee )
   219     if( marqueeEnabled != marquee ){
   222         return;
   220         marqueeEnabled  = marquee;
   223 
   221 
   224     marqueeEnabled  = marquee;
   222         HbStyleOptionGroupBox groupBoxOption;
   225 
   223         initStyleOption( &groupBoxOption );
   226     HbStyleOptionGroupBox groupBoxOption;
   224         style()->updatePrimitive( mTextItem, HbStyle::P_GroupBoxMarquee_text, &groupBoxOption);
   227     initStyleOption( &groupBoxOption );
   225     }
   228     style()->updatePrimitive( mTextItem, HbStyle::P_GroupBoxMarquee_text, &groupBoxOption);
       
   229 }
   226 }
   230 
   227 
   231 /*!
   228 /*!
   232 
   229 
   233     \deprecated HbGroupBoxHeadingWidget::primitive(HbStyle::Primitive)
   230     \deprecated HbGroupBoxHeadingWidget::primitive(HbStyle::Primitive)
   280     \reimp
   277     \reimp
   281  */
   278  */
   282 QVariant HbGroupBoxHeadingWidget::itemChange( GraphicsItemChange change, const QVariant &value )
   279 QVariant HbGroupBoxHeadingWidget::itemChange( GraphicsItemChange change, const QVariant &value )
   283 {
   280 {
   284     switch ( change ) {
   281     switch ( change ) {
   285         case ItemVisibleHasChanged: {
   282         case ItemVisibleChange: 
   286             /*if (value.toBool() == true){
   283         case ItemSceneHasChanged: 
   287                 if (mTextItem) {
       
   288                     HbStyleOptionGroupBox groupBoxOption;
       
   289                     initStyleOption(&groupBoxOption);
       
   290                     style()->updatePrimitive( mTextItem, HbStyle::P_GroupBoxHeading_text, &groupBoxOption);
       
   291                 }
       
   292             }*/
       
   293             }
       
   294             break;
       
   295 
       
   296         case ItemSceneHasChanged: {
       
   297             if(!value.isNull())
       
   298 
       
   299 
       
   300             updatePrimitives();
   284             updatePrimitives();
   301             }
   285             break;
   302             break;
       
   303 
       
   304         case ItemChildAddedChange:
   286         case ItemChildAddedChange:
   305         case ItemChildRemovedChange:
   287         case ItemChildRemovedChange:
   306             repolish();
   288             repolish();
   307             break;
   289             break;
   308         default:
   290         default:
   385 {
   367 {
   386     if(HbTapGesture *tap = qobject_cast<HbTapGesture*>( event->gesture( Qt::TapGesture ) ) ) {
   368     if(HbTapGesture *tap = qobject_cast<HbTapGesture*>( event->gesture( Qt::TapGesture ) ) ) {
   387         switch( tap->state() ) {
   369         switch( tap->state() ) {
   388         case Qt::GestureStarted:  //
   370         case Qt::GestureStarted:  //
   389             {
   371             {
       
   372                 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),Qt::TapGesture);
       
   373                 if (!tap->property(HbPrivate::ThresholdRect.latin1()).toRect().isValid()) {
       
   374                     tap->setProperty(HbPrivate::ThresholdRect.latin1(), mapRectToScene(boundingRect()).toRect());
       
   375                 }
       
   376 
   390                 if ( !(groupBox->isCollapsable( )) ){
   377                 if ( !(groupBox->isCollapsable( )) ){
   391                     event->ignore( tap );
   378                     event->ignore( tap );
   392                     return;
   379                     return;
   393                 }
   380                 }
   394                 if ( groupBox->isCollapsable( ) ) {
   381                 if ( groupBox->isCollapsable( ) ) {
   409             }
   396             }
   410 
   397 
   411             break;
   398             break;
   412         case Qt::GestureCanceled: // Reset state
   399         case Qt::GestureCanceled: // Reset state
   413             {
   400             {
       
   401                 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant());
       
   402 
   414                 headingPressed = false;
   403                 headingPressed = false;
   415 
   404 
   416                 HbStyleOptionGroupBox groupBoxOption;
   405                 HbStyleOptionGroupBox groupBoxOption;
   417                 initStyleOption( &groupBoxOption );
   406                 initStyleOption( &groupBoxOption );
   418                 style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
   407                 style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption );
   420                 setProperty( "state", "normal" );
   409                 setProperty( "state", "normal" );
   421                 break;
   410                 break;
   422             }
   411             }
   423         case Qt::GestureFinished: // emit clicked
   412         case Qt::GestureFinished: // emit clicked
   424             {
   413             {
       
   414                 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant());
       
   415 
   425                 if ( groupBox->isCollapsable( ) ) {
   416                 if ( groupBox->isCollapsable( ) ) {
   426                     HbWidgetFeedback::triggered( this, Hb::InstantReleased, Hb::ModifierCollapsedItem );
   417                     HbWidgetFeedback::triggered( this, Hb::InstantReleased, Hb::ModifierCollapsedItem );
   427                 } else {
   418                 } else {
   428                     HbWidgetFeedback::triggered( this, Hb::InstantReleased );
   419                     HbWidgetFeedback::triggered( this, Hb::InstantReleased );
   429                 }
   420                 }