src/hbwidgets/widgets/hbcombobox_p.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    32 #include <hbmainwindow.h>
    32 #include <hbmainwindow.h>
    33 #include <hbview.h>
    33 #include <hbview.h>
    34 #include <hbtextitem.h>
    34 #include <hbtextitem.h>
    35 #include <hbstyleoptioncombobox_p.h>
    35 #include <hbstyleoptioncombobox_p.h>
    36 #include <hbgraphicsscene.h>
    36 #include <hbgraphicsscene.h>
       
    37 #include <hbinputeditorinterface.h>
    37 
    38 
    38 #include <QSortFilterProxyModel>
    39 #include <QSortFilterProxyModel>
    39 #include <QCompleter>
    40 #include <QCompleter>
    40 #include <QItemSelectionModel>
    41 #include <QItemSelectionModel>
    41 #include <QApplication>
    42 #include <QApplication>
    82 
    83 
    83     if ( !mDropDown ) {
    84     if ( !mDropDown ) {
    84         return;
    85         return;
    85     }
    86     }
    86 
    87 
    87     if ( !mDropDown->scene() || !mDropDown->scene( )->property( "destructed" ).isValid( ) ) {
    88     //if drop down is added to scene then remove it from scene so that scene does not deletes
    88         delete mDropDown;
    89     //drop down again
    89         mDropDown = 0;
    90     if( mDropDown->scene() ) {
    90     }
    91         q->scene()->removeItem(mDropDown);
       
    92     }
       
    93 
       
    94     delete mDropDown;
       
    95     mDropDown = 0;
    91 }
    96 }
    92 
    97 
    93 void HbComboBoxPrivate::init( )
    98 void HbComboBoxPrivate::init( )
    94 {
    99 {
    95     createPrimitives( );
   100     createPrimitives( );
    97 
   102 
    98 void HbComboBoxPrivate::createPrimitives( )
   103 void HbComboBoxPrivate::createPrimitives( )
    99 {
   104 {
   100     Q_Q( HbComboBox );
   105     Q_Q( HbComboBox );
   101 
   106 
   102     mTextItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_text, q );
   107     mTextItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_text, q );
   103     HbStyle::setItemName( mTextItem, "combobox_labelfield" );
   108     HbStyle::setItemName( mTextItem, "combobox_labelfield" );
   104 
   109 
   105     mBackgroundItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_background, q );
   110     mBackgroundItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_background, q );
   106     HbStyle::setItemName( mBackgroundItem, "text_background" );
   111     HbStyle::setItemName( mBackgroundItem, "text_background" );
   107 
   112 
   108     mButton = q->style( )->createPrimitive( HbStyle::P_ComboBox_button, q );
   113     mButton = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_button, q );
   109     HbStyle::setItemName( mButton, "combobox_button" );
   114     HbStyle::setItemName( mButton, "combobox_button" );
   110 
   115 
   111     mButtonTouchAreaItem = q->style( )->createPrimitive( HbStyle::P_ComboBoxButton_toucharea, q );
   116     mButtonTouchAreaItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBoxButton_toucharea, q );
   112 
   117 
   113     static_cast<HbTouchArea*>( mButtonTouchAreaItem )->grabGesture( Qt::TapGesture );
   118     static_cast<HbTouchArea*>( mButtonTouchAreaItem )->grabGesture( Qt::TapGesture );
   114 }
   119 }
   115 
   120 
   116 void HbComboBoxPrivate::touchAreaPressEvent( )
   121 void HbComboBoxPrivate::touchAreaPressEvent( )
   119     if ( q->count( ) > 0 ) {
   124     if ( q->count( ) > 0 ) {
   120         HbWidgetFeedback::triggered( q, Hb::InstantPressed );
   125         HbWidgetFeedback::triggered( q, Hb::InstantPressed );
   121     }
   126     }
   122     mIsDown = true;
   127     mIsDown = true;
   123     q->updatePrimitives( );
   128     q->updatePrimitives( );
   124     q->setProperty( "state", "pressed" );
   129     //Update the state only when valid model is there
       
   130     if ( mModel && mModel->rowCount( ) ) {
       
   131         q->setProperty( "state", "pressed" );
       
   132     }
   125 }
   133 }
   126 
   134 
   127 void HbComboBoxPrivate::touchAreaReleaseEvent(  )
   135 void HbComboBoxPrivate::touchAreaReleaseEvent(  )
   128 {
   136 {
   129     Q_Q( HbComboBox );
   137     Q_Q( HbComboBox );
   165             }
   173             }
   166             mDropDown->mList->scrollTo( mModel->index( 0, 0 ) );
   174             mDropDown->mList->scrollTo( mModel->index( 0, 0 ) );
   167             mDropDown->mList->setCurrentIndex( 
   175             mDropDown->mList->setCurrentIndex( 
   168                 mModel->index( 0, 0 ), QItemSelectionModel::Select );
   176                 mModel->index( 0, 0 ), QItemSelectionModel::Select );
   169         }
   177         }
       
   178         positionDropDown( );
   170         #ifdef HB_EFFECTS
   179         #ifdef HB_EFFECTS
   171         HbEffect::start( mDropDown, HB_DROPD0WN_ITEM_TYPE, "appear" );
   180         HbEffect::start( mDropDown, HB_DROPD0WN_ITEM_TYPE, "appear" );
   172         #endif
   181         #endif
   173         positionDropDown( );
       
   174     }
   182     }
   175 }
   183 }
   176 
   184 
   177 void HbComboBoxPrivate::vkbOpened( )
   185 void HbComboBoxPrivate::vkbOpened( )
   178 {
   186 {
   202             mDropDown->mList->setCurrentIndex( mCurrentIndex, QItemSelectionModel::Select );
   210             mDropDown->mList->setCurrentIndex( mCurrentIndex, QItemSelectionModel::Select );
   203         } else {
   211         } else {
   204             mDropDown->mList->scrollTo( aModel->index( 0, 0 ) );
   212             mDropDown->mList->scrollTo( aModel->index( 0, 0 ) );
   205         }
   213         }
   206         positionDropDown( );
   214         positionDropDown( );
   207         mDropDown->setVisible( true );
   215         if( !mDropDown->isVisible( ) ) {
       
   216             mDropDown->setVisible( true );
       
   217             #ifdef HB_EFFECTS
       
   218             HbEffect::start( mDropDown, HB_DROPD0WN_ITEM_TYPE, "appear" );
       
   219             #endif
       
   220         }
   208     }
   221     }
   209 }
   222 }
   210 
   223 
   211 void HbComboBoxPrivate::createDropDown( )
   224 void HbComboBoxPrivate::createDropDown( )
   212 {
   225 {
   236         delete temp;
   249         delete temp;
   237         temp = 0;
   250         temp = 0;
   238     }
   251     }
   239 }
   252 }
   240 
   253 
       
   254 void HbComboBoxPrivate::resetGeometryChangeFlag( )
       
   255 {
       
   256     Q_Q( HbComboBox );
       
   257     QGraphicsWidget *p = q;
       
   258     if( widgetGeometryChange.count() > 0 ) {
       
   259         while ( p->parentWidget( ) ) {
       
   260             p = p->parentWidget( );
       
   261             if ( !widgetGeometryChange.value( p ) ) {
       
   262                 //if earlier geometry change flag was disabled then disable this flag
       
   263                 p->setFlag( QGraphicsItem::ItemSendsGeometryChanges, false );
       
   264             }
       
   265         }
       
   266         widgetGeometryChange.clear();
       
   267     }
       
   268 }
       
   269 
       
   270 void HbComboBoxPrivate::showDismissEffect( )
       
   271 {
       
   272     #ifdef HB_EFFECTS
       
   273     HbEffect::start( mDropDown, HB_DROPD0WN_ITEM_TYPE, "disappear", mDropDown, "dismissEffectFinished" );
       
   274     #else
       
   275     mDropDown->setVisible( false );
       
   276     #endif
       
   277 }
       
   278 
   241 void HbComboBoxPrivate::positionDropDown( )
   279 void HbComboBoxPrivate::positionDropDown( )
   242 {
   280 {
   243     Q_Q( HbComboBox );
   281     Q_Q( HbComboBox );
   244     QRectF popupRect;
   282     QRectF popupRect;
   245     QRectF sceneRect( QPointF( ), HbDeviceProfile::profile( q ).logicalSize( ) );
   283     QRectF sceneRect( QPointF( ), HbDeviceProfile::profile( q ).logicalSize( ) );
   247     QAbstractItemModel *model = mDropDown->mList->model( );
   285     QAbstractItemModel *model = mDropDown->mList->model( );
   248     calculateListItemHeight( );
   286     calculateListItemHeight( );
   249     qreal totalHeightRequd = model->rowCount( ) * mListItemHeight;
   287     qreal totalHeightRequd = model->rowCount( ) * mListItemHeight;
   250     qreal maxPopupHeight = 0.0;
   288     qreal maxPopupHeight = 0.0;
   251 
   289 
   252     //read the maximum rows in drop down for different orientation from css
   290     //calculate the maximum popup height for different orientation
   253     if( q->mainWindow( )->orientation( ) == Qt::Horizontal ) {
   291     if( q->mainWindow( )->orientation( ) == Qt::Horizontal ) {
   254         if( mDropDownRowsInLandscape == -1 ) {
       
   255             HbStyleParameters params;
       
   256             q->style( )->parameters( params );
       
   257             params.addParameter( "max-rows-in-dropdown" );
       
   258             q->polish( params );
       
   259             mDropDownRowsInLandscape = params.value( "max-rows-in-dropdown" ).toInt( );
       
   260         }
       
   261         maxPopupHeight = mDropDownRowsInLandscape * mListItemHeight;
   292         maxPopupHeight = mDropDownRowsInLandscape * mListItemHeight;
   262     } else if( q->mainWindow( )->orientation( ) == Qt::Vertical ) {
   293     } else if( q->mainWindow( )->orientation( ) == Qt::Vertical ) {
   263         if( mDropDownRowsInPortrait == -1 ) {
       
   264             HbStyleParameters params;
       
   265             q->style( )->parameters( params );
       
   266             params.addParameter( "max-rows-in-dropdown" );
       
   267             q->polish( params );
       
   268             mDropDownRowsInPortrait = params.value( "max-rows-in-dropdown" ).toInt( );
       
   269         }
       
   270         maxPopupHeight = mDropDownRowsInPortrait * mListItemHeight;
   294         maxPopupHeight = mDropDownRowsInPortrait * mListItemHeight;
   271     }
   295     }
   272 
   296 
   273     if ( totalHeightRequd < maxPopupHeight ) {
   297     if ( totalHeightRequd < maxPopupHeight ) {
   274         maxPopupHeight = totalHeightRequd;
   298         maxPopupHeight = totalHeightRequd;
   275     }
   299     }
   276     QSizeF popupSize = QSizeF( q->rect( ).width( ), maxPopupHeight );
   300     QSizeF popupSize = QSizeF( q->rect( ).width( ), maxPopupHeight );
   277     QPointF popupPos;
   301     QPointF popupPos;
   278     if( !mDropDown->vkbOpened ) {
   302 
       
   303     HbEditorInterface editorInterface( q );
       
   304     HbVkbHost *host = editorInterface.vkbHost( );
       
   305 
       
   306     if( host && ( host->keypadStatus( ) == HbVkbHost::HbVkbStatusOpened ) ) {
       
   307         // case when vkb is visible
       
   308         // positioning drop down when vkb is positioned
       
   309         // drop down will come on top/below of combo based upon which side has more space
       
   310         // available 
       
   311         QSizeF keyBoardArea = host->keyboardArea( );
       
   312         QSize screenSize = HbDeviceProfile::profile( q ).logicalSize( );
       
   313 
       
   314         qreal heightDifference = screenSize.height( ) - keyBoardArea.height( );
       
   315         qreal topSpace = widgetPos.y( );
       
   316         qreal bottomSpace = heightDifference - topSpace - q->boundingRect( ).height( );
       
   317 
       
   318         if( topSpace > bottomSpace ) {
       
   319             //display drop down at top
       
   320             if( widgetPos.y( ) - maxPopupHeight  > 0.0 ) {
       
   321                 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight );
       
   322             } else {
       
   323                 popupPos = QPointF( widgetPos.x( ), 0.0 );
       
   324                 popupSize.setHeight( topSpace );
       
   325             }
       
   326             #ifdef HB_EFFECTS
       
   327             if ( !mHasUpEffect ) {
       
   328                  mHasUpEffect = true;
       
   329                  mHasDownEffect = false;
       
   330                  //this Effect will be shown when there is more space in the view bottom.
       
   331                  HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" );
       
   332                  HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" );
       
   333             }
       
   334             #endif
       
   335         } else {
       
   336             //display drop down at bottom
       
   337             popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) );
       
   338             if( bottomSpace < maxPopupHeight ) {
       
   339                 popupSize.setHeight( bottomSpace );
       
   340             }
       
   341             #ifdef HB_EFFECTS
       
   342             if ( !mHasDownEffect ) {
       
   343                 mHasDownEffect = true;
       
   344                 mHasUpEffect = false;
       
   345                 //this Effect will be shown when there is more space in the view bottom.
       
   346                 HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" );
       
   347                 HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" );
       
   348             }
       
   349             #endif
       
   350         }
       
   351     } else {
       
   352         //this is the case when vkb is not visible
       
   353 
   279         //position of drop down in both editable and non-editable combobox depends upon
   354         //position of drop down in both editable and non-editable combobox depends upon
   280         //the available space above and below combobox
   355         //the available space above and below combobox
   281         if( ( widgetPos.y( ) + q->rect( ).height( ) + maxPopupHeight) < sceneRect.height( ) ) {
   356         if( ( widgetPos.y( ) + q->rect( ).height( ) + maxPopupHeight) < sceneRect.height( ) ) {
   282             popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) );
   357             popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) );
   283             #ifdef HB_EFFECTS
   358             #ifdef HB_EFFECTS
   284             if ( !mHasDownEffect ) {
   359             if ( !mHasDownEffect ) {
   285                  mHasDownEffect = true;
   360                  mHasDownEffect = true;
   286                  mHasUpEffect = false;
   361                  mHasUpEffect = false;
   287                  // this is temporary until proper effect theming comes.
       
   288                  //this Effect will be shown when there is space in the view bottom.
   362                  //this Effect will be shown when there is space in the view bottom.
   289                  HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" );
   363                  HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" );
   290                  HbEffectInternal::add( mDropDown, "combo_disappear_downl", "disappear" );
   364                  HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" );
   291             }
   365             }
   292             #endif
   366             #endif
   293         } else if( widgetPos.y( ) - maxPopupHeight  > 0.0 ) {
   367         } else if( widgetPos.y( ) - maxPopupHeight  > 0.0 ) {
   294             popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight );
   368             popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight );
   295             #ifdef HB_EFFECTS
   369             #ifdef HB_EFFECTS
   296             if ( !mHasUpEffect ) {
   370             if ( !mHasUpEffect ) {
   297                  // this is temporary until proper effect theming comes.
       
   298                  //this Effect will be shown when there is no space in the view bottom
   371                  //this Effect will be shown when there is no space in the view bottom
   299                  mHasUpEffect = true;
   372                  mHasUpEffect = true;
   300                  mHasDownEffect = false;
   373                  mHasDownEffect = false;
   301                  HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" );
   374                  HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" );
   302                  HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" );
   375                  HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" );
   308                 popupPos = QPointF( widgetPos.x( ), 0.0 );
   381                 popupPos = QPointF( widgetPos.x( ), 0.0 );
   309                 #ifdef HB_EFFECTS
   382                 #ifdef HB_EFFECTS
   310                 if ( !mHasDownEffect ) {
   383                 if ( !mHasDownEffect ) {
   311                     mHasDownEffect = true;
   384                     mHasDownEffect = true;
   312                     mHasUpEffect = false;
   385                     mHasUpEffect = false;
   313                     // this is temporary until proper effect theming comes.
       
   314                     //this Effect will be shown when there is more space in the view bottom.
   386                     //this Effect will be shown when there is more space in the view bottom.
   315                     HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" );
   387                     HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" );
   316                     HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" );
   388                     HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" );
   317                 }
   389                 }
   318                 #endif
   390                 #endif
   320                 popupPos = QPointF( widgetPos.x( ), sceneRect.height( ) - maxPopupHeight );
   392                 popupPos = QPointF( widgetPos.x( ), sceneRect.height( ) - maxPopupHeight );
   321                 #ifdef HB_EFFECTS
   393                 #ifdef HB_EFFECTS
   322                 if ( !mHasUpEffect ) {
   394                 if ( !mHasUpEffect ) {
   323                      mHasUpEffect = true;
   395                      mHasUpEffect = true;
   324                      mHasDownEffect = false;
   396                      mHasDownEffect = false;
   325                      // this is temporary until proper effect theming comes.
       
   326                      //this Effect will be shown when there is more space in the view bottom.
   397                      //this Effect will be shown when there is more space in the view bottom.
   327                      HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" );
   398                      HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" );
   328                      HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" );
   399                      HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" );
   329                 }
       
   330                 #endif
       
   331             }
       
   332         }
       
   333     } else {
       
   334         // positioning drop down when vkb is positioned
       
   335         // drop down will come on top/below of combo based upon which side has more space
       
   336         // available 
       
   337         HbEditorInterface editorInterface( q );
       
   338         HbVkbHost *host = editorInterface.vkbHost( );
       
   339         if ( host ) {
       
   340             QSizeF keyBoardArea = host->keyboardArea( );
       
   341             QSize screenSize = HbDeviceProfile::profile( q ).logicalSize( );
       
   342 
       
   343             qreal heightDifference = screenSize.height( ) - keyBoardArea.height( );
       
   344             qreal topSpace = widgetPos.y( );
       
   345             qreal bottomSpace = heightDifference - topSpace - q->boundingRect( ).height( );
       
   346 
       
   347             if( topSpace > bottomSpace ) {
       
   348                 //display drop down at top
       
   349                 if( widgetPos.y( ) - maxPopupHeight  > 0.0 ) {
       
   350                     popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight );
       
   351                 } else {
       
   352                     popupPos = QPointF( widgetPos.x( ), 0.0 );
       
   353                     popupSize.setHeight( topSpace );
       
   354                 }
       
   355                 #ifdef HB_EFFECTS
       
   356                 if ( !mHasUpEffect ) {
       
   357                      mHasUpEffect = true;
       
   358                      mHasDownEffect = false;
       
   359                      // this is temporary until proper effect theming comes.
       
   360                      //this Effect will be shown when there is more space in the view bottom.
       
   361                      HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" );
       
   362                      HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" );
       
   363                 }
       
   364                 #endif
       
   365             } else {
       
   366                 //display drop down at bottom
       
   367                 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) );
       
   368                 if( bottomSpace < maxPopupHeight ) {
       
   369                     popupSize.setHeight( bottomSpace );
       
   370                 }
       
   371                 #ifdef HB_EFFECTS
       
   372                 if ( !mHasDownEffect ) {
       
   373                     mHasDownEffect = true;
       
   374                     mHasUpEffect = false;
       
   375                     // this is temporary until proper effect theming comes.
       
   376                     //this Effect will be shown when there is more space in the view bottom.
       
   377                     HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" );
       
   378                     HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" );
       
   379                 }
   400                 }
   380                 #endif
   401                 #endif
   381             }
   402             }
   382         }
   403         }
   383     }
   404     }
   386     mDropDown->setMaximumSize( popupSize );
   407     mDropDown->setMaximumSize( popupSize );
   387     mDropDown->setPos( popupPos );
   408     mDropDown->setPos( popupPos );
   388     QGraphicsWidget *p = q;
   409     QGraphicsWidget *p = q;
   389     while ( p->parentWidget( ) ) {
   410     while ( p->parentWidget( ) ) {
   390         p = p->parentWidget( );
   411         p = p->parentWidget( );
       
   412         //cache the original geometry change flag of parent widget
       
   413         QGraphicsItem::GraphicsItemFlags itemFlags = p->flags( );
       
   414         bool geometryFlagEnabled =  itemFlags & QGraphicsItem::ItemSendsGeometryChanges;
       
   415         widgetGeometryChange.insert(p, geometryFlagEnabled);
       
   416 
       
   417         //This flag is being set since geometry change notification is required for properly
       
   418         //positioning drop down when its visible and combobox position is changed for example
       
   419         //when orientation change happens.
       
   420         p->setFlag( QGraphicsItem::ItemSendsGeometryChanges );
   391     }
   421     }
   392     mDropDown->setZValue( p->zValue( ) + 1 );
   422     mDropDown->setZValue( p->zValue( ) + 1 );
   393 }
   423 }
   394 
   424 
   395 void HbComboBoxPrivate::_q_textChanged( const QModelIndex & aIndex )
   425 void HbComboBoxPrivate::_q_textChanged( const QModelIndex & aIndex )
   401         if( mLineEdit ) {
   431         if( mLineEdit ) {
   402             mLineEdit->setText( mText );
   432             mLineEdit->setText( mText );
   403         } else {
   433         } else {
   404             HbStyleOptionComboBox comboBoxOption;
   434             HbStyleOptionComboBox comboBoxOption;
   405             q->initStyleOption( &comboBoxOption );
   435             q->initStyleOption( &comboBoxOption );
   406             q->style( )->updatePrimitive( mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption );
   436             HbStylePrivate::updatePrimitive( mTextItem, HbStylePrivate::P_ComboBox_text, &comboBoxOption );
   407         }
   437         }
   408         mCurrentIndex = aIndex;
   438         mCurrentIndex = aIndex;
   409     } else {
   439     } else {
   410        q->disconnect( mLineEdit, SIGNAL( textChanged ( QString ) ), q,
   440        q->disconnect( mLineEdit, SIGNAL( textChanged ( QString ) ), q,
   411            SLOT( _q_textChanged( QString ) ) );
   441            SLOT( _q_textChanged( QString ) ) );
   413        mCurrentIndex = findData( mText );
   443        mCurrentIndex = findData( mText );
   414        q->connect( mLineEdit, SIGNAL( textChanged ( QString ) ), q, 
   444        q->connect( mLineEdit, SIGNAL( textChanged ( QString ) ), q, 
   415            SLOT( _q_textChanged( QString ) ) );
   445            SLOT( _q_textChanged( QString ) ) );
   416     }
   446     }
   417     if ( mDropDown->isVisible( ) ) {
   447     if ( mDropDown->isVisible( ) ) {
   418         mDropDown->setVisible( false );
   448         showDismissEffect( );
   419         q->setProperty( "state", "normal" );
   449         q->setProperty( "state", "normal" );
   420     }
   450     }
   421     currentIndexChanged( mCurrentIndex );
   451     currentIndexChanged( mCurrentIndex );
   422 }
   452 }
   423 
   453 
   442                 }
   472                 }
   443             }
   473             }
   444         }
   474         }
   445     } else {
   475     } else {
   446         if( mDropDown ) {
   476         if( mDropDown ) {
   447             mDropDown->setVisible( false );
   477             showDismissEffect( );
   448         }
   478         }
   449         //showPopup( mModel, mCurrentIndex);
   479         //showPopup( mModel, mCurrentIndex);
   450     }
   480     }
   451     emit q->editTextChanged( aString );
   481     emit q->editTextChanged( aString );
   452 }
   482 }
   520             mLineEdit->backgroundItem( )->setVisible( false );
   550             mLineEdit->backgroundItem( )->setVisible( false );
   521         }
   551         }
   522         q->setHandlesChildEvents( false );
   552         q->setHandlesChildEvents( false );
   523         mLineEdit->setReadOnly( false );
   553         mLineEdit->setReadOnly( false );
   524         mLineEdit->setCursorVisibility( Hb::TextCursorVisible );
   554         mLineEdit->setCursorVisibility( Hb::TextCursorVisible );
   525         mLineEdit->setLongPressEnabled( );
       
   526         q->repolish( );
   555         q->repolish( );
   527         q->connect( mLineEdit, SIGNAL( textChanged ( QString ) ),
   556         q->connect( mLineEdit, SIGNAL( textChanged ( QString ) ),
   528             q, SLOT( _q_textChanged( QString ) ) );
   557             q, SLOT( _q_textChanged( QString ) ) );
   529         setCompletion( true );
   558         setCompletion( true );
   530     } else {
   559     } else {
   531         q->disconnect( mLineEdit, SIGNAL( textChanged ( QString ) ),
   560         q->disconnect( mLineEdit, SIGNAL( textChanged ( QString ) ),
   532             q, SLOT( _q_textChanged( QString ) ) );
   561             q, SLOT( _q_textChanged( QString ) ) );
   533         q->setHandlesChildEvents( true );
   562         q->setHandlesChildEvents( true );
   534         mLineEdit->setReadOnly( true );
   563         mLineEdit->setReadOnly( true );
   535         mLineEdit->setLongPressEnabled( false );
       
   536         setCompletion( false );
   564         setCompletion( false );
   537         mLineEdit->setCursorVisibility( Hb::TextCursorHidden );
   565         mLineEdit->setCursorVisibility( Hb::TextCursorHidden );
   538         if( mModel && mModel->rowCount( ) ) {
   566         if( mModel && mModel->rowCount( ) ) {
   539             QModelIndex mi = mModel->index( 0, 0 );
   567             QModelIndex mi = mModel->index( 0, 0 );
   540             if( mi.isValid( ) ) {
   568             if( mi.isValid( ) ) {
   598             if( mLineEdit ) {
   626             if( mLineEdit ) {
   599                 mLineEdit->setText( mText );
   627                 mLineEdit->setText( mText );
   600             } else {
   628             } else {
   601                 HbStyleOptionComboBox comboBoxOption;
   629                 HbStyleOptionComboBox comboBoxOption;
   602                 q->initStyleOption(&comboBoxOption);
   630                 q->initStyleOption(&comboBoxOption);
   603                 q->style( )->updatePrimitive(
   631                 HbStylePrivate::updatePrimitive(
   604                     mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption );
   632                     mTextItem, HbStylePrivate::P_ComboBox_text, &comboBoxOption );
   605             }
   633             }
   606         }
   634         }
   607         currentIndexChanged( mCurrentIndex );
   635         currentIndexChanged( mCurrentIndex );
   608     }
   636     }
   609 }
   637 }