src/hbwidgets/widgets/hbcombobox_p.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    30 #include <hbdeviceprofile.h>
    30 #include <hbdeviceprofile.h>
    31 #include <hbtoucharea.h>
    31 #include <hbtoucharea.h>
    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.h>
    35 #include <hbstyleoptioncombobox_p.h>
       
    36 #include <hbgraphicsscene.h>
    36 
    37 
    37 #include <QSortFilterProxyModel>
    38 #include <QSortFilterProxyModel>
    38 #include <QGraphicsScene>
       
    39 #include <QCompleter>
    39 #include <QCompleter>
    40 #include <QItemSelectionModel>
    40 #include <QItemSelectionModel>
    41 
    41 
    42 #ifdef HB_EFFECTS
    42 #ifdef HB_EFFECTS
    43 #include <hbeffect.h>
    43 #include <hbeffect.h>
    63     mEditable ( false ),
    63     mEditable ( false ),
    64     mIsDorpdownCreated(false),
    64     mIsDorpdownCreated(false),
    65     mIsDropwnToSceneAdded(false),
    65     mIsDropwnToSceneAdded(false),
    66     mHasDownEffect ( false ),
    66     mHasDownEffect ( false ),
    67     mHasUpEffect (false ),
    67     mHasUpEffect (false ),
    68     mListItemHeight(-1)
    68     mListItemHeight( -1 ),
       
    69     mDropDownRowsInPortrait( -1 ),
       
    70     mDropDownRowsInLandscape( -1 )
    69 {
    71 {
    70 }
    72 }
    71 
    73 
    72 HbComboBoxPrivate::~HbComboBoxPrivate( )
    74 HbComboBoxPrivate::~HbComboBoxPrivate( )
    73 {
    75 {
    74     Q_Q(HbComboBox);
    76     Q_Q(HbComboBox);
    75     if( mButtonTouchAreaItem ) {
    77     if( mButtonTouchAreaItem ) {
    76         static_cast<HbTouchArea*>(mButtonTouchAreaItem)->removeEventFilter( q );
    78         static_cast<HbTouchArea*>( mButtonTouchAreaItem )->removeEventFilter( q );
    77     }
    79     }
    78     if (!q->scene() || !q->scene()->property("destructed").isValid()) {
    80     if ( !q->scene() || !q->scene( )->property( "destructed" ).isValid( ) ) {
    79         if( mDropDown ) {
    81         if( mDropDown ) {
    80             delete mDropDown;
    82             delete mDropDown;
    81             mDropDown = 0;
    83             mDropDown = 0;
    82         }
    84         }
    83     }
    85     }
    90 
    92 
    91 void HbComboBoxPrivate::createPrimitives( )
    93 void HbComboBoxPrivate::createPrimitives( )
    92 {
    94 {
    93     Q_Q( HbComboBox );
    95     Q_Q( HbComboBox );
    94 
    96 
    95 
    97     mTextItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_text, q );
    96     mTextItem = q->style()->createPrimitive( HbStyle::P_ComboBox_text, q );
       
    97     HbStyle::setItemName( mTextItem, "combobox_labelfield" );
    98     HbStyle::setItemName( mTextItem, "combobox_labelfield" );
    98 
    99 
    99     mBackgroundItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_background, q );
   100     mBackgroundItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_background, q );
   100     HbStyle::setItemName( mBackgroundItem, "text_background" );
   101     HbStyle::setItemName( mBackgroundItem, "text_background" );
   101 
   102 
   112 
   113 
   113 void HbComboBoxPrivate::touchAreaPressEvent( )
   114 void HbComboBoxPrivate::touchAreaPressEvent( )
   114 {    
   115 {    
   115     Q_Q( HbComboBox );
   116     Q_Q( HbComboBox );
   116     if (q->count() > 0) {
   117     if (q->count() > 0) {
   117         HbWidgetFeedback::triggered(q, Hb::InstantPressed);
   118         HbWidgetFeedback::triggered( q, Hb::InstantPressed );
   118     }
   119     }
   119     mIsDown = true;
   120     mIsDown = true;
   120     q->updatePrimitives( );
   121     q->updatePrimitives( );
   121     q->setProperty("state", "pressed"); 
   122     q->setProperty( "state", "pressed" ); 
   122 }
   123 }
   123 
   124 
   124 void HbComboBoxPrivate::touchAreaReleaseEvent(  )
   125 void HbComboBoxPrivate::touchAreaReleaseEvent(  )
   125 {
   126 {
   126     Q_Q( HbComboBox );
   127     Q_Q( HbComboBox );
   127     mIsDown = false;
   128     mIsDown = false;
   128     touchAreaClicked();
   129     touchAreaClicked( );
   129     q->updatePrimitives( );
   130     q->updatePrimitives( );
   130     if (q->count() > 0) {
   131     if ( q->count() > 0 ) {
   131         HbWidgetFeedback::triggered(q, Hb::InstantReleased);
   132         HbWidgetFeedback::triggered( q, Hb::InstantReleased );
   132     }
   133     }
   133 
   134 
   134     q->setProperty("state", "normal"); 
   135     q->setProperty( "state", "normal" ); 
   135 }
   136 }
   136 
   137 
   137 void HbComboBoxPrivate::touchAreaClicked( )
   138 void HbComboBoxPrivate::touchAreaClicked( )
   138 {
   139 {
   139     Q_Q( HbComboBox );
   140     Q_Q( HbComboBox );
   140     if ( mModel && mModel->rowCount( ) ) {
   141     if ( mModel && mModel->rowCount( ) ) {
   141         addDropDownToScene();
   142         addDropDownToScene( );
   142         mDropDown->setVisible( true );
   143         mDropDown->setVisible( true );
   143         if( !mDropDown->mList ) {
   144         if( !mDropDown->mList ) {
   144             mDropDown->createList( );
   145             mDropDown->createList( );
   145             mDropDown->mList->setModel( mModel );            
   146             mDropDown->mList->setModel( mModel );            
   146             q->connect( mDropDown->mList, SIGNAL( activated( QModelIndex ) ), q,
   147             q->connect( mDropDown->mList, SIGNAL( activated( QModelIndex ) ), q,
   155         } else {
   156         } else {
   156             if( mDropDown->mList->model( ) != mModel ) {
   157             if( mDropDown->mList->model( ) != mModel ) {
   157                 mDropDown->mList->setModel( mModel );
   158                 mDropDown->mList->setModel( mModel );
   158             }
   159             }
   159             mDropDown->mList->scrollTo( mModel->index( 0, 0 ) );
   160             mDropDown->mList->scrollTo( mModel->index( 0, 0 ) );
   160             mDropDown->mList->setCurrentIndex(mModel->index( 0, 0 ), QItemSelectionModel::Select);
   161             mDropDown->mList->setCurrentIndex( mModel->index( 0, 0 ), QItemSelectionModel::Select );
   161         }
   162         }
   162         #ifdef HB_EFFECTS
   163         #ifdef HB_EFFECTS
   163                HbEffect::start(mDropDown, HB_DROPD0WN_ITEM_TYPE, "appear");
   164             HbEffect::start( mDropDown, HB_DROPD0WN_ITEM_TYPE, "appear" );
   164         #endif
   165         #endif
   165         positionDropDown( );        
   166         positionDropDown( );        
   166     }
   167     }
   167 }
   168 }
   168 
   169 
   171 
   172 
   172 }
   173 }
   173 
   174 
   174 void HbComboBoxPrivate::vkbClosed()
   175 void HbComboBoxPrivate::vkbClosed()
   175 {
   176 {
   176     if( mDropDown->isVisible()) {
   177     if( mDropDown->isVisible( ) ) {
   177         positionDropDown();
   178         positionDropDown( );
   178     }
   179     }
   179 }
   180 }
   180 
   181 
   181 void HbComboBoxPrivate::showPopup( QAbstractItemModel* aModel, QModelIndex aIndex )
   182 void HbComboBoxPrivate::showPopup( QAbstractItemModel *aModel, QModelIndex aIndex )
   182 {    
   183 {    
   183     Q_UNUSED( aModel );
   184     Q_UNUSED( aModel );
   184     Q_UNUSED( aIndex );
   185     Q_UNUSED( aIndex );
   185     Q_Q( HbComboBox );
   186     Q_Q( HbComboBox );
   186     if ( aModel && aModel->rowCount( ) ) {
   187     if ( aModel && aModel->rowCount( ) ) {
   192             
   193             
   193         }
   194         }
   194         mDropDown->mList->setModel( aModel );
   195         mDropDown->mList->setModel( aModel );
   195         if ( aIndex.isValid( ) ) {
   196         if ( aIndex.isValid( ) ) {
   196             mDropDown->mList->scrollTo( aIndex, HbAbstractItemView::PositionAtTop );
   197             mDropDown->mList->scrollTo( aIndex, HbAbstractItemView::PositionAtTop );
   197             mDropDown->mList->setCurrentIndex(mCurrentIndex, QItemSelectionModel::Select);
   198             mDropDown->mList->setCurrentIndex( mCurrentIndex, QItemSelectionModel::Select );
   198         } else {
   199         } else {
   199             mDropDown->mList->scrollTo( aModel->index( 0, 0 ) );
   200             mDropDown->mList->scrollTo( aModel->index( 0, 0 ) );
   200         }
   201         }
   201         positionDropDown( );
   202         positionDropDown( );
   202         mDropDown->setVisible( true );
   203         mDropDown->setVisible( true );
   212     }
   213     }
   213 }
   214 }
   214 
   215 
   215 void HbComboBoxPrivate::calculateListItemHeight()
   216 void HbComboBoxPrivate::calculateListItemHeight()
   216 {
   217 {
   217     if( mListItemHeight == -1 ) {
   218     QAbstractItemModel *model = mDropDown->mList->model( );
   218         QAbstractItemModel *model = mDropDown->mList->model( );
   219     if( mCurrentIndex.isValid( ) && mDropDown->mList->itemByIndex( mCurrentIndex ) ) {
   219         if( mCurrentIndex.isValid( ) && mDropDown->mList->itemByIndex( mCurrentIndex ) ) {
   220         mListItemHeight = mDropDown->mList->itemByIndex( mCurrentIndex )->geometry( ).height( );
   220             mListItemHeight = mDropDown->mList->itemByIndex( mCurrentIndex )->geometry( ).height( );
   221     } else if( model->index( 0, 0 ).isValid() && mDropDown->mList->itemByIndex( model->index( 0, 0 ) ) ) {
   221         } else if( model->index( 0, 0 ).isValid() && mDropDown->mList->itemByIndex( model->index( 0, 0 ) ) ) {
   222         mListItemHeight = mDropDown->mList->itemByIndex( model->index( 0, 0 ) )->geometry( ).height( );
   222             mListItemHeight = mDropDown->mList->itemByIndex( model->index( 0, 0 ) )->geometry( ).height( );
   223     } else {
   223         } else {
   224         HbListViewItem *proto = mDropDown->mList->listItemPrototype( );
   224             HbListViewItem *proto = mDropDown->mList->listItemPrototype();
   225         HbListViewItem *temp = static_cast<HbListViewItem*>( proto->createItem( ) );
   225             HbListViewItem *temp = static_cast<HbListViewItem*>(proto->createItem());
   226         mListItemHeight = temp->effectiveSizeHint( Qt::PreferredSize ).height( );
   226             mListItemHeight = temp->effectiveSizeHint(Qt::PreferredSize).height();
   227         delete temp;
   227             delete temp;
   228         temp = 0;
   228             temp = 0;
       
   229         }
       
   230     }
   229     }
   231 }
   230 }
   232 
   231 
   233 void HbComboBoxPrivate::positionDropDown( )
   232 void HbComboBoxPrivate::positionDropDown( )
   234 {
   233 {
   235     Q_Q( HbComboBox );
   234     Q_Q( HbComboBox );
   236     QRectF popupRect;
   235     QRectF popupRect;
   237     QRectF sceneRect( QPointF( ), HbDeviceProfile::profile( q ).logicalSize( ) );
   236     QRectF sceneRect( QPointF( ), HbDeviceProfile::profile( q ).logicalSize( ) );
   238     QPointF widgetPos = q->scenePos( );
   237     QPointF widgetPos = q->scenePos( );
   239     QAbstractItemModel *model = mDropDown->mList->model( );
   238     QAbstractItemModel *model = mDropDown->mList->model( );
   240     calculateListItemHeight();
   239     calculateListItemHeight( );
   241     qreal totalHeightRequd = model->rowCount( ) * mListItemHeight;
   240     qreal totalHeightRequd = model->rowCount( ) * mListItemHeight;
       
   241     
   242     qreal maxPopupHeight = 0.0;
   242     qreal maxPopupHeight = 0.0;
   243     if(q->mainWindow()->orientation() == Qt::Horizontal ) {
   243     //read the maximum rows in drop down for different orientation from css
   244         maxPopupHeight = 5 * mListItemHeight;
   244     if( q->mainWindow( )->orientation( ) == Qt::Horizontal ){
   245     } else if(q->mainWindow()->orientation() == Qt::Vertical ) {
   245         if( mDropDownRowsInLandscape == -1 ) {
   246         maxPopupHeight = 8 * mListItemHeight;
   246             HbStyleParameters params;
   247     }
   247             q->style( )->parameters( params );
       
   248             params.addParameter( "max-rows-in-dropdown" );
       
   249             q->polish( params );
       
   250             mDropDownRowsInLandscape = params.value( "max-rows-in-dropdown" ).toInt( );
       
   251         }
       
   252         maxPopupHeight = mDropDownRowsInLandscape * mListItemHeight;
       
   253     } else if( q->mainWindow( )->orientation( ) == Qt::Vertical ){
       
   254         if( mDropDownRowsInPortrait == -1 ) {
       
   255             HbStyleParameters params;
       
   256             q->style( )->parameters(params);
       
   257             params.addParameter( "max-rows-in-dropdown" );
       
   258             q->polish( params );
       
   259             mDropDownRowsInPortrait = params.value("max-rows-in-dropdown").toInt();
       
   260         }
       
   261         maxPopupHeight = mDropDownRowsInPortrait * mListItemHeight;
       
   262     }
       
   263     
   248     if ( totalHeightRequd < maxPopupHeight ) {
   264     if ( totalHeightRequd < maxPopupHeight ) {
   249         maxPopupHeight = totalHeightRequd;
   265         maxPopupHeight = totalHeightRequd;
   250     }
   266     }
   251     QSizeF popupSize = QSizeF( q->rect( ).width( ), maxPopupHeight );
   267     QSizeF popupSize = QSizeF( q->rect( ).width( ), maxPopupHeight );
   252     QPointF popupPos;
   268     QPointF popupPos;
   253     if( !mDropDown->vkbOpened ) {
   269     if( !mDropDown->vkbOpened ) {
   254         //position of drop down in both editable and non-editable combobox depends upon
   270         //position of drop down in both editable and non-editable combobox depends upon
   255         //the available space above and below combobox
   271         //the available space above and below combobox
   256         if( (widgetPos.y( ) + q->rect( ).height( ) + maxPopupHeight) < sceneRect.height( ) ) {
   272         if( (widgetPos.y( ) + q->rect( ).height( ) + maxPopupHeight) < sceneRect.height( ) ) {
   257             popupPos = QPointF( widgetPos.x(), widgetPos.y( )+ q->rect( ).height( ) );
   273             popupPos = QPointF( widgetPos.x(), widgetPos.y( ) + q->rect( ).height( ) );
   258             #ifdef HB_EFFECTS
   274             #ifdef HB_EFFECTS
   259                 if ( !mHasDownEffect ) {
   275                 if ( !mHasDownEffect ) {
   260                      mHasDownEffect = true;
   276                      mHasDownEffect = true;
   261                      mHasUpEffect = false;
   277                      mHasUpEffect = false;
   262                      // this is temporary until proper effect theming comes.
   278                      // this is temporary until proper effect theming comes.
   263                      //this Effect will be shown when there is space in the view bottom.
   279                      //this Effect will be shown when there is space in the view bottom.
   264                      HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" );
   280                      HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" );
   265                      HbEffectInternal::add( mDropDown, "combo_disappear_downl", "disappear" );
   281                      HbEffectInternal::add( mDropDown, "combo_disappear_downl", "disappear" );
   266                 }
   282                 }
   267             #endif
   283             #endif
   268         } else if( widgetPos.y() - maxPopupHeight  > 0.0 ) {
   284         } else if( widgetPos.y( ) - maxPopupHeight  > 0.0 ) {
   269             popupPos = QPointF( widgetPos.x(), widgetPos.y()-maxPopupHeight );
   285             popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight );
   270             #ifdef HB_EFFECTS
   286             #ifdef HB_EFFECTS
   271                 if ( !mHasUpEffect ) {
   287                 if ( !mHasUpEffect ) {
   272                      // this is temporary until proper effect theming comes.
   288                      // this is temporary until proper effect theming comes.
   273                      //this Effect will be shown when there is no space in the view bottom
   289                      //this Effect will be shown when there is no space in the view bottom
   274                      mHasUpEffect = true;
   290                      mHasUpEffect = true;
   275                      mHasDownEffect = false;
   291                      mHasDownEffect = false;
   276                      HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" );
   292                      HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" );
   277                      HbEffectInternal::add( mDropDown,  "combo_disappear_up", "disappear" );
   293                      HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" );
   278                 }
   294                 }
   279             #endif
   295             #endif
   280         } else {
   296         } else {
   281             qreal topScreenHeight = sceneRect.height( ) - maxPopupHeight;
   297             qreal topScreenHeight = sceneRect.height( ) - maxPopupHeight;
   282             if( topScreenHeight > sceneRect.height( ) - topScreenHeight ) {
   298             if( topScreenHeight > sceneRect.height( ) - topScreenHeight ) {
   308     } else {
   324     } else {
   309         // positioning drop down when vkb is positioned
   325         // positioning drop down when vkb is positioned
   310         // drop down will come on top/below of combo based upon which side has more space
   326         // drop down will come on top/below of combo based upon which side has more space
   311         // available 
   327         // available 
   312     
   328     
   313         HbEditorInterface editorInterface(q);
   329         HbEditorInterface editorInterface( q );
   314         HbVkbHost *host = editorInterface.vkbHost();
   330         HbVkbHost *host = editorInterface.vkbHost( );
   315         if ( host ) {
   331         if ( host ) {
   316             QSizeF keyBoardArea = host->keyboardArea();
   332             QSizeF keyBoardArea = host->keyboardArea( );
   317             QSize screenSize = HbDeviceProfile::profile(q).logicalSize();
   333             QSize screenSize = HbDeviceProfile::profile( q ).logicalSize( );
   318             
   334             
   319             qreal heightDifference = screenSize.height() - keyBoardArea.height();
   335             qreal heightDifference = screenSize.height( ) - keyBoardArea.height( );
   320             qreal topSpace = widgetPos.y();
   336             qreal topSpace = widgetPos.y( );
   321             qreal bottomSpace = heightDifference - topSpace - q->boundingRect().height();
   337             qreal bottomSpace = heightDifference - topSpace - q->boundingRect( ).height( );
   322 
   338 
   323             if( topSpace > bottomSpace ) {
   339             if( topSpace > bottomSpace ) {
   324                 //display drop down at top
   340                 //display drop down at top
   325                 if( widgetPos.y() - maxPopupHeight  > 0.0 ) {
   341                 if( widgetPos.y( ) - maxPopupHeight  > 0.0 ) {
   326                     popupPos = QPointF( widgetPos.x(), widgetPos.y() - maxPopupHeight );
   342                     popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight );
   327                 } else {
   343                 } else {
   328                     popupPos = QPointF( widgetPos.x(), 0.0 );
   344                     popupPos = QPointF( widgetPos.x( ), 0.0 );
   329                     popupSize.setHeight( topSpace );
   345                     popupSize.setHeight( topSpace );
   330                 }
   346                 }
   331                 #ifdef HB_EFFECTS
   347                 #ifdef HB_EFFECTS
   332                     if ( !mHasUpEffect ) {
   348                     if ( !mHasUpEffect ) {
   333                          mHasUpEffect = true;
   349                          mHasUpEffect = true;
   339                     }
   355                     }
   340                 #endif
   356                 #endif
   341                 
   357                 
   342             } else {
   358             } else {
   343                 //display drop down at bottom
   359                 //display drop down at bottom
   344                 popupPos = QPointF( widgetPos.x(), widgetPos.y( ) + q->rect( ).height( ) );
   360                 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) );
   345                 if( bottomSpace < maxPopupHeight ) {
   361                 if( bottomSpace < maxPopupHeight ) {
   346                     popupSize.setHeight( bottomSpace );
   362                     popupSize.setHeight( bottomSpace );
   347                 }
   363                 }
   348                 #ifdef HB_EFFECTS
   364                 #ifdef HB_EFFECTS
   349                     if ( !mHasDownEffect ) {
   365                     if ( !mHasDownEffect ) {
   360     }
   376     }
   361     mDropDown->setPreferredSize( popupSize );
   377     mDropDown->setPreferredSize( popupSize );
   362     mDropDown->setMinimumSize( popupSize );
   378     mDropDown->setMinimumSize( popupSize );
   363     mDropDown->setMaximumSize( popupSize );
   379     mDropDown->setMaximumSize( popupSize );
   364     mDropDown->setPos(popupPos);
   380     mDropDown->setPos(popupPos);
   365     QGraphicsWidget* p = q;
   381     QGraphicsWidget *p = q;
   366     while(p->parentWidget()) {
   382     while ( p->parentWidget( ) ) {
   367         p = p->parentWidget();
   383         p = p->parentWidget( );
   368     }
   384     }
   369     mDropDown->setZValue( p->zValue( ) + 1 );
   385     mDropDown->setZValue( p->zValue( ) + 1 );
   370 }
   386 }
   371 
   387 
   372 void HbComboBoxPrivate::_q_textChanged( const QModelIndex & aIndex )
   388 void HbComboBoxPrivate::_q_textChanged( const QModelIndex & aIndex )
   377     if( !mEditable ) {        
   393     if( !mEditable ) {        
   378         if( mLineEdit ) {
   394         if( mLineEdit ) {
   379             mLineEdit->setText( mText );
   395             mLineEdit->setText( mText );
   380         } else {
   396         } else {
   381             HbStyleOptionComboBox comboBoxOption;
   397             HbStyleOptionComboBox comboBoxOption;
   382             q->initStyleOption(&comboBoxOption);
   398             q->initStyleOption( &comboBoxOption );
   383             q->style()->updatePrimitive( mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption);
   399             q->style( )->updatePrimitive( mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption);
   384         }
   400         }
   385         mCurrentIndex = aIndex;
   401         mCurrentIndex = aIndex;
   386     } else {
   402     } else {
   387        q->disconnect( mLineEdit, SIGNAL( textChanged ( QString ) ), q,
   403        q->disconnect( mLineEdit, SIGNAL( textChanged ( QString ) ), q,
   388             SLOT( _q_textChanged( QString ) ) );       
   404             SLOT( _q_textChanged( QString ) ) );       
   410 
   426 
   411     if( !aString.isEmpty( ) ) {
   427     if( !aString.isEmpty( ) ) {
   412         if ( mCompleter ) {
   428         if ( mCompleter ) {
   413             mCompleter->setCompletionPrefix( aString );
   429             mCompleter->setCompletionPrefix( aString );
   414             mCompleter->complete( );
   430             mCompleter->complete( );
   415             if( mCompleter->currentRow() == -1 )
   431             if( mCompleter->currentRow() == -1 ) {
   416             {
       
   417                 if (( mDropDown ) && ( mDropDown->isVisible() )) {
   432                 if (( mDropDown ) && ( mDropDown->isVisible() )) {
   418                     mDropDown->setVisible(false);
   433                     mDropDown->setVisible(false);
   419                 }
   434                 }
   420             }
   435             }
   421         }
   436         }
   422     } else {
   437     } else {
   423         showPopup( mModel, mCurrentIndex);
   438         if( mDropDown ) {
       
   439             mDropDown->setVisible(false);
       
   440         }
       
   441         //showPopup( mModel, mCurrentIndex);
   424     }
   442     }
   425     emit q->editTextChanged( aString );
   443     emit q->editTextChanged( aString );
   426 }
   444 }
   427 
   445 
   428 void HbComboBoxPrivate::setModel( QAbstractItemModel * model )
   446 void HbComboBoxPrivate::setModel( QAbstractItemModel * model )
   480     Q_Q(HbComboBox);
   498     Q_Q(HbComboBox);
   481     if( mEditable == editable ) {
   499     if( mEditable == editable ) {
   482         return;
   500         return;
   483     }
   501     }
   484     mEditable = editable;
   502     mEditable = editable;
   485     if( editable )
   503     if( editable ) {        
   486     {        
       
   487         if( mTextItem ) {
   504         if( mTextItem ) {
   488             HbStyle::setItemName( mTextItem, "" );
   505             HbStyle::setItemName( mTextItem, "" );
   489             delete mTextItem;
   506             delete mTextItem;
   490             mTextItem = 0;
   507             mTextItem = 0;
   491             mLineEdit = new HbCustomLineEdit( q, this );
   508             mLineEdit = new HbCustomLineEdit( q, this );
   544     Q_Q( HbComboBox );
   561     Q_Q( HbComboBox );
   545     if( !mIsDropwnToSceneAdded ) {
   562     if( !mIsDropwnToSceneAdded ) {
   546         if ( q->scene( ) ) {
   563         if ( q->scene( ) ) {
   547             q->scene( )->addItem( mDropDown );
   564             q->scene( )->addItem( mDropDown );
   548         }
   565         }
   549         QGraphicsScene *scene1 = mDropDown->scene( );
   566         HbGraphicsScene *scene1 = static_cast<HbGraphicsScene*>( mDropDown->scene( ) );
   550         if( scene1 )
   567         if( scene1 ) {
   551         {
       
   552             scene1->installEventFilter( mDropDown );
   568             scene1->installEventFilter( mDropDown );
   553             //scene1->grabGesture( Qt::TapGesture );
   569             //scene1->grabGesture( Qt::TapGesture );
   554         }
   570         }
   555         mIsDropwnToSceneAdded = true;
   571         mIsDropwnToSceneAdded = true;
   556     }
   572     }
   572             if( mLineEdit ) {
   588             if( mLineEdit ) {
   573                 mLineEdit->setText( mText );
   589                 mLineEdit->setText( mText );
   574             } else {                
   590             } else {                
   575                 HbStyleOptionComboBox comboBoxOption;
   591                 HbStyleOptionComboBox comboBoxOption;
   576                 q->initStyleOption(&comboBoxOption);
   592                 q->initStyleOption(&comboBoxOption);
   577                 q->style()->updatePrimitive( mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption);
   593                 q->style( )->updatePrimitive( mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption );
   578             }
   594             }
   579         }
   595         }
   580         currentIndexChanged( mCurrentIndex );
   596         currentIndexChanged( mCurrentIndex );
   581     }
   597     }
   582 }
   598 }
   608         return result.first( );
   624         return result.first( );
   609     }
   625     }
   610 }
   626 }
   611 
   627 
   612 #include "moc_hbcombobox.cpp"
   628 #include "moc_hbcombobox.cpp"
   613 
       
   614