src/hbwidgets/widgets/hbgroupboxcontentwidget_p.cpp
changeset 7 923ff622b8b9
parent 3 11d3954df52a
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
    30 #include <hbwidgetfeedback.h>
    30 #include <hbwidgetfeedback.h>
    31 #ifdef HB_GESTURE_FW
    31 #ifdef HB_GESTURE_FW
    32 #include <hbtapgesture.h>
    32 #include <hbtapgesture.h>
    33 #include <hbtapandholdgesture.h>
    33 #include <hbtapandholdgesture.h>
    34 #include <QGesture>
    34 #include <QGesture>
    35 #endif 
    35 #include <QGraphicsScene>
       
    36 #endif
    36 
    37 
    37 /*
    38 /*
    38     internal
    39     internal
    39 
    40 
    40     constructs HbGroupBoxContentWidget
    41     constructs HbGroupBoxContentWidget
   121 void HbGroupBoxContentWidget::setType(GroupBoxType type)
   122 void HbGroupBoxContentWidget::setType(GroupBoxType type)
   122 {
   123 {
   123     if( groupBoxType != type ){
   124     if( groupBoxType != type ){
   124         groupBoxType = type;
   125         groupBoxType = type;
   125         // set dynamic properties for type
   126         // set dynamic properties for type
   126         if(groupBoxType == GroupBoxCollapsingContainer)
   127         if(groupBoxType == GroupBoxCollapsingContainer){
   127             setProperty("groupBoxType",3);
   128             setProperty("groupBoxType",3);
   128         else if(groupBoxType == GroupBoxRichLabel)
   129         }
       
   130         else if(groupBoxType == GroupBoxRichLabel){
       
   131             contentPressed = false;
   129             setProperty("groupBoxType",2);
   132             setProperty("groupBoxType",2);
   130 
   133         }
   131         if(groupBoxType != GroupBoxSimpleLabel){
   134         if(groupBoxType != GroupBoxSimpleLabel){
   132            createPrimitives();
   135            createPrimitives();
   133            //createConnection();
   136            //createConnection();
   134         }
   137         }
   135     }
   138     }
   140 
   143 
   141     Sets HbGroupBoxContentWidget content
   144     Sets HbGroupBoxContentWidget content
   142 */
   145 */
   143 void HbGroupBoxContentWidget::setContentWidget( HbWidget *widget )
   146 void HbGroupBoxContentWidget::setContentWidget( HbWidget *widget )
   144 {
   147 {
   145     if ( widget == mContent ) {
   148     if ( widget != mContent ) {      
   146         return;
   149         // delete old content set
   147     }
   150         if ( mContent ) {
   148 
   151             delete mContent; 
   149     // delete old content set
   152             mContent = 0;
   150     if ( mContent ) {
   153         }
   151         delete mContent; 
   154         mContent = widget;
   152         mContent = 0;
   155         style()->setItemName( mContent , "content" );
   153     }
   156         mContent->setParentItem( this);
   154      // if NULL widget is passed don't do anything
       
   155     if ( !widget   ) {
       
   156         return;
       
   157     }
       
   158 
       
   159     mContent = widget;
       
   160     style()->setItemName( mContent , "content" );
       
   161     mContent->setParentItem( this);
       
   162 
       
   163     if(groupBoxType == GroupBoxRichLabel){
       
   164         contentPressed = false;
       
   165     }
   157     }
   166 }
   158 }
   167 
   159 
   168 /*!
   160 /*!
   169     Returns the pointer for \a primitive passed.
   161     Returns the pointer for \a primitive passed.
   201     {
   193     {
   202         case ItemChildAddedChange:
   194         case ItemChildAddedChange:
   203         case ItemChildRemovedChange:
   195         case ItemChildRemovedChange:
   204             repolish();
   196             repolish();
   205              break;
   197              break;
   206         case ItemSceneHasChanged:		
   198         case ItemSceneHasChanged:
       
   199         case ItemVisibleChange:
   207             updatePrimitives();
   200             updatePrimitives();
   208             break;
   201             break;
   209         default:
   202         default:
   210             break;
   203             break;
   211     }
   204     }
   274 void HbGroupBoxContentWidget::gestureEvent(QGestureEvent *event)
   267 void HbGroupBoxContentWidget::gestureEvent(QGestureEvent *event)
   275 {
   268 {
   276     if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
   269     if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
   277         switch(tap->state()) {
   270         switch(tap->state()) {
   278         case Qt::GestureStarted:  //
   271         case Qt::GestureStarted:  //
       
   272             scene()->setProperty(HbPrivate::OverridingGesture.latin1(),Qt::TapGesture);
       
   273             if (!tap->property(HbPrivate::ThresholdRect.latin1()).toRect().isValid()) {
       
   274                 tap->setProperty(HbPrivate::ThresholdRect.latin1(), mapRectToScene(boundingRect()).toRect());
       
   275             }
       
   276 
   279             contentPressed=true;
   277             contentPressed=true;
   280             updatePrimitives();
   278             updatePrimitives();
   281             break;
   279             break;
   282         case Qt::GestureCanceled: // Reset state
   280         case Qt::GestureCanceled: // Reset state
       
   281             scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant());
       
   282 
   283             contentPressed=false;
   283             contentPressed=false;
   284             updatePrimitives();
   284             updatePrimitives();
   285             break;
   285             break;
   286         case Qt::GestureUpdated:
   286         case Qt::GestureUpdated:
   287             if(tap->tapStyleHint() == HbTapGesture::TapAndHold) {
   287             if(tap->tapStyleHint() == HbTapGesture::TapAndHold) {
   288                 emit longPress(event->mapToGraphicsScene(tap->position()));
   288                 emit longPress(event->mapToGraphicsScene(tap->position()));
   289             }
   289             }
   290             break;
   290             break;
   291         case Qt::GestureFinished: // emit clicked
   291         case Qt::GestureFinished: // emit clicked
       
   292             scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant());
   292             contentPressed=false;
   293             contentPressed=false;
   293             updatePrimitives();
   294             updatePrimitives();
   294             if(tap->tapStyleHint() == HbTapGesture::Tap) {
   295             if(tap->tapStyleHint() == HbTapGesture::Tap) {
   295                 emit clicked();
   296                 emit clicked();
   296             }
   297             }