src/hbwidgets/widgets/hbcombobox.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    28 #include <hbcombobox.h>
    28 #include <hbcombobox.h>
    29 #include <hblistview.h>
    29 #include <hblistview.h>
    30 #include <hbtoucharea.h>
    30 #include <hbtoucharea.h>
    31 #include <hbtextitem.h>
    31 #include <hbtextitem.h>
    32 #include <hbstyleoptioncombobox.h>
    32 #include <hbstyleoptioncombobox.h>
    33 
       
    34 #include <QGraphicsSceneMouseEvent>
       
    35 #include <QStandardItemModel>
    33 #include <QStandardItemModel>
    36 #include <QDebug>
    34 #include <QDebug>
       
    35 
       
    36 #include <hbtapgesture.h>
       
    37 
    37 
    38 
    38 /*!
    39 /*!
    39     @beta
    40     @beta
    40     @hbwidgets
    41     @hbwidgets
    41     \class HbComboBox
    42     \class HbComboBox
   566         event->accept( );
   567         event->accept( );
   567     }
   568     }
   568 }
   569 }
   569 
   570 
   570 /*!
   571 /*!
       
   572 
       
   573     \deprecated HbComboBox::primitive(HbStyle::Primitive)
       
   574         is deprecated.
       
   575 
   571     \reimp
   576     \reimp
   572  */
   577  */
   573 QGraphicsItem* HbComboBox::primitive( HbStyle::Primitive primitive ) const
   578 QGraphicsItem* HbComboBox::primitive( HbStyle::Primitive primitive ) const
   574 {
   579 {
   575     Q_D( const HbComboBox );
   580     Q_D( const HbComboBox );
   576 
   581 
   577     switch( primitive ){
   582     switch( primitive ){
       
   583         case HbStyle::P_ComboBox_text:
       
   584             return d->mTextItem;
   578         case HbStyle::P_ComboBox_background:
   585         case HbStyle::P_ComboBox_background:
   579             return d->mBackgroundItem;
   586             return d->mBackgroundItem;
       
   587         case HbStyle::P_ComboBox_button:
       
   588             return d->mButton;
   580         case HbStyle::P_ComboBoxButton_toucharea:
   589         case HbStyle::P_ComboBoxButton_toucharea:
   581             return d->mButtonTouchAreaItem;
   590             return d->mButtonTouchAreaItem;
   582         default:
   591         default:
   583             return 0;
   592             return 0;
   584     }
   593     }
   955 }
   964 }
   956 
   965 
   957 /*!
   966 /*!
   958     reimplementation. 
   967     reimplementation. 
   959 */
   968 */
   960 bool HbComboBox::eventFilter( QObject *obj, QEvent *event )
   969 bool HbComboBox::eventFilter( QObject* obj, QEvent* event )
   961 {
   970 {
   962     Q_D( HbComboBox );
   971     Q_D( HbComboBox );
   963     bool accepted = false;  
   972     bool accepted = false;
       
   973     if ( !isEnabled() ) {
       
   974         return false ;
       
   975     }
   964     if(obj == static_cast<HbTouchArea*>(d->mButtonTouchAreaItem)) {
   976     if(obj == static_cast<HbTouchArea*>(d->mButtonTouchAreaItem)) {
   965         if( (event->type() == QEvent::GraphicsSceneMousePress ) || 
   977         if(event->type() == QEvent::Gesture ) {
   966                 (event->type() == QEvent::GraphicsSceneMouseDoubleClick ) ) {
   978             QGestureEvent *gestureEvent = static_cast<QGestureEvent *>( event );
   967             if( static_cast<HbTouchArea*>(d->mButtonTouchAreaItem)->rect( ).contains( 
   979             if(gestureEvent->gesture(Qt::TapGesture)) {
   968                         static_cast<QGraphicsSceneMouseEvent *>( event )->pos( ) ) ){
   980                 HbTapGesture *tap = static_cast<HbTapGesture *>(gestureEvent->gesture(Qt::TapGesture));
   969                 d->touchAreaPressEvent( );
   981                 switch(tap->state()) {
   970                 accepted = true;
   982                 case Qt::GestureStarted:
   971             }
   983                     {
   972         }else if( event->type() == QEvent::GraphicsSceneMouseRelease ) {
   984                         d->touchAreaPressEvent( );
   973              if( static_cast<HbTouchArea*>(d->mButtonTouchAreaItem)->rect( ).contains(
   985                         accepted = true;
   974                         static_cast<QGraphicsSceneMouseEvent *>( event )->pos( ) ) ){
   986                         break;
   975                     d->touchAreaReleaseEvent( );
   987                     }                
   976                     accepted = true;
   988                 case Qt::GestureCanceled:
   977              } else if (d->mIsDown) {
   989                     {
   978                  d->mIsDown = false;
   990                         d->mIsDown = false;
   979                  updatePrimitives( );
   991                         updatePrimitives();
   980              }
   992                         setProperty("state", "normal");
       
   993                         accepted = true;
       
   994                         break;
       
   995                     }
       
   996                 case Qt::GestureFinished:
       
   997                     {
       
   998                         d->touchAreaReleaseEvent( );
       
   999                         accepted = true;
       
  1000                         break;
       
  1001                         //TODO :: move else part here
       
  1002                     }
       
  1003                 default:
       
  1004                     break;
       
  1005                 }
       
  1006             }
   981         }
  1007         }
   982     }
  1008     }
   983     return accepted;
  1009     return accepted;
   984 }
  1010 }
   985 
  1011