src/hbwidgets/widgets/hbcombobox_p.cpp
changeset 6 c3690ec91ef8
parent 3 11d3954df52a
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    75 {
    75 {
    76     Q_Q( HbComboBox );
    76     Q_Q( HbComboBox );
    77     if( mButtonTouchAreaItem ) {
    77     if( mButtonTouchAreaItem ) {
    78         static_cast<HbTouchArea*>( mButtonTouchAreaItem )->removeEventFilter( q );
    78         static_cast<HbTouchArea*>( mButtonTouchAreaItem )->removeEventFilter( q );
    79     }
    79     }
    80     if ( !q->scene( ) || !q->scene( )->property( "destructed" ).isValid( ) ) {
    80 
    81         if( mDropDown ) {
    81     if ( !mDropDown ) {
    82             delete mDropDown;
    82         return;
    83             mDropDown = 0;
    83     }
    84         }
    84 
       
    85     if ( !mDropDown->scene() || !mDropDown->scene( )->property( "destructed" ).isValid( ) ) {
       
    86         delete mDropDown;
       
    87         mDropDown = 0;
    85     }
    88     }
    86 }
    89 }
    87 
    90 
    88 void HbComboBoxPrivate::init( )
    91 void HbComboBoxPrivate::init( )
    89 {
    92 {
   129     q->updatePrimitives( );
   132     q->updatePrimitives( );
   130     if ( q->count( ) > 0 ) {
   133     if ( q->count( ) > 0 ) {
   131         HbWidgetFeedback::triggered( q, Hb::InstantReleased );
   134         HbWidgetFeedback::triggered( q, Hb::InstantReleased );
   132     }
   135     }
   133 
   136 
   134     q->setProperty( "state", "normal" ); 
       
   135 }
   137 }
   136 
   138 
   137 void HbComboBoxPrivate::touchAreaClicked( )
   139 void HbComboBoxPrivate::touchAreaClicked( )
   138 {
   140 {
   139     Q_Q( HbComboBox );
   141     Q_Q( HbComboBox );
   140     if ( mModel && mModel->rowCount( ) ) {
   142     if ( mModel && mModel->rowCount( ) ) {
   141         addDropDownToScene( );
   143         addDropDownToScene( );
   142         mDropDown->setVisible( true );
   144         mDropDown->setVisible( true );
       
   145         q->setProperty( "state", "latched" );
   143         if( !mDropDown->mList ) {
   146         if( !mDropDown->mList ) {
   144             mDropDown->createList( );
   147             mDropDown->createList( );
   145             mDropDown->mList->setModel( mModel );
   148             mDropDown->mList->setModel( mModel );
   146             q->connect( mDropDown->mList, SIGNAL( activated( QModelIndex ) ), q,
   149             q->connect( mDropDown->mList, SIGNAL( activated( QModelIndex ) ), q,
   147                 SLOT( _q_textChanged( QModelIndex ) ) );
   150                 SLOT( _q_textChanged( QModelIndex ) ) );
   201     }
   204     }
   202 }
   205 }
   203 
   206 
   204 void HbComboBoxPrivate::createDropDown( )
   207 void HbComboBoxPrivate::createDropDown( )
   205 {
   208 {
       
   209     Q_Q ( HbComboBox );
   206     if( !mIsDorpdownCreated ) {
   210     if( !mIsDorpdownCreated ) {
   207         mDropDown = new HbComboDropDown( this );
   211         mDropDown = new HbComboDropDown( this );
   208         mIsDorpdownCreated = true;
   212         mIsDorpdownCreated = true;
   209         mDropDown->setVisible( false );
   213         mDropDown->setVisible( false );
       
   214         q->setProperty( "state", "normal" );
   210     }
   215     }
   211 }
   216 }
   212 
   217 
   213 void HbComboBoxPrivate::calculateListItemHeight( )
   218 void HbComboBoxPrivate::calculateListItemHeight( )
   214 {
   219 {
   405        q->connect( mLineEdit, SIGNAL( textChanged ( QString ) ), q, 
   410        q->connect( mLineEdit, SIGNAL( textChanged ( QString ) ), q, 
   406            SLOT( _q_textChanged( QString ) ) );
   411            SLOT( _q_textChanged( QString ) ) );
   407     }
   412     }
   408     if ( mDropDown->isVisible( ) ) {
   413     if ( mDropDown->isVisible( ) ) {
   409         mDropDown->setVisible( false );
   414         mDropDown->setVisible( false );
       
   415         q->setProperty( "state", "normal" );
   410     }
   416     }
   411     currentIndexChanged( mCurrentIndex );
   417     currentIndexChanged( mCurrentIndex );
   412 }
   418 }
   413 
   419 
   414 void HbComboBoxPrivate::_q_textCompleted( const QModelIndex & aIndex )
   420 void HbComboBoxPrivate::_q_textCompleted( const QModelIndex & aIndex )
   445 {
   451 {
   446     Q_Q ( HbComboBox );
   452     Q_Q ( HbComboBox );
   447     createDropDown( );    
   453     createDropDown( );    
   448     if ( mDropDown->isVisible( ) ) {
   454     if ( mDropDown->isVisible( ) ) {
   449         mDropDown->setVisible( false );
   455         mDropDown->setVisible( false );
       
   456         q->setProperty( "state", "normal" );
   450     }
   457     }
   451     q->clear( );
   458     q->clear( );
   452     delete mModel;
   459     delete mModel;
   453     mModel = model;
   460     mModel = model;
   454     mModel->setParent( q );
   461     mModel->setParent( q );