src/hbwidgets/widgets/hbcombobox.cpp
changeset 3 11d3954df52a
parent 2 06ff229162e9
child 5 627c4a0fd0e7
--- a/src/hbwidgets/widgets/hbcombobox.cpp	Fri May 14 16:09:54 2010 +0300
+++ b/src/hbwidgets/widgets/hbcombobox.cpp	Thu May 27 13:10:59 2010 +0300
@@ -47,9 +47,9 @@
     in a way that takes up the minimum amount of screen space.
 
     A combobox is a selection widget that displays the currently selected item,
-    and can provides a drop-down list that permits selecting an item.
+    and provides a drop-down list that permits selecting an item.
     
-    A HbComboBox with currently Selected item
+    A HbComboBox with currently selected item
     \image html noneditablecombobox.png.
 
 
@@ -57,71 +57,68 @@
     \image html comboboxdropdownlist.png.
 
 
-    HbComboBox are of two types. 
+    HbComboBox are of two types:
 
-    Editable:
+    1: Editable:
 
-    If the comboBox is set to editable, touching the ComboBox label field invokes the VKB in
-    touch environments or accepts input from an attached keyboard.
-    choosing an element from the ComboBox dropdown list replaces the label 
-    area with the chosen item.
-    on touching button area of the comboBox launches the drop-down list to select
-    the list of options 
-    ( button area in comboBox behaves same in both editable and Non Editable comboBox ).
+    If combobox is set to editable, tapping on combobox label field invokes the VKB in
+    touch environments or accepts input from an attached keyboard. Tapping on 
+    button area of combobox launches dropdown list. Choosing an element from 
+    the combobox dropdown list replaces the label with the chosen item. Touch events on
+    combobox button behaves same in both editable and non-editable combobox.
 
-    Non Editable:
+    2: Non Editable:
     
-    If the comboBox is set to Non Editable widget that displays the currently selected item
-    in the label field of ComboBox.
-    Touching the comboBox label field or button area of the comboBox will opens
-    the drop-down list to select an item from list of options.
+    If the combobox is set to non-editable then even tapping on label field will launch 
+    drop down unlike editable combobox. Tapping on combobox button area behaves in 
+    same way as in editable combobox.
 
-    By Default comboBox is Non Editable. 
+    By default combobox is non-editable. 
 
-    Application is responsible for setting the model to the HbComboBox,
-    If no model is set, the drop down list cannot be displayed at all.
+    Application is responsible for setting the model in combobox. If no model is set or model
+    set is empty then drop down list will not be displayed at all. Combobox owns the model set 
+    by application.
 
-    HbComboBox owns the model set by the Application.
+    The number of rows to be displayed in HbComboBox drop down can be configured by overriding
+    HbComboBox css. By default number of items in drop down is 8 in portrait mode and 5 in
+    landscape mode.
 
-    HbComboBox provides three signals:
+    HbComboBox provides four signals:
 
     \li currentIndexChanged( index ) is emitted when the current selection in the combobox is
-    changed by user interaction. If application is setting a index/text then this signal is
-    not emmitted. In case of an editable combobox on combobox loosing focus if the current
-    selection has changed then this signal is emitted with the new model index.
+    changed either by user interaction or programmatically.
 
     \li currentIndexChanged( const QString& ) is emitted when the curret selection in the combobox
     is changed by user interaction. If application is setting a differnet index/text
-    then this signal is not emmitted. 
-    In case of an editable combobox on combobox loosing focus if the current selection
-    has changed then this signal is emitted with the new string.
+    then this signal is not emmitted.
+
+    \li editTextChanged( const QString& ) is emitted when text is changed in editable combobox.
 
-    \li editTextChanged( QString& ) is emitted when combobox looses focus and user has typed a text
-    for which there is no matching item found in the model with the text typed by the user.
+    \li editingFinished( ) is emitted either because editable combobox lost focus or Return/Enter 
+    is pressed.
 
-    The following is an example of how to create a model and adding item to the created model.
-    How to set the model on the HbcomboBox.
-    Here the model is ownership transfer to the widget.
+    The following is an example of how to create a model and adding item in the model.
+    HbComboBox takes ownership of model.
     \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,37}
 
-    An example how to add strings into HbComboBox and setting currentIndex.
-    HbComboBox will creates the model internally if model is not created.
+    An example of how to add strings in HbComboBox and setting currentIndex.
+    HbComboBox will creates model internally if model is not created.
     \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,38}
 
-    An example how to add stringsList into HbComboBox and setting currentIndex.
+    An example of how to add stringsList into HbComboBox and setting currentIndex.
     HbComboBox will creates the model internally if model is not created.
     \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,39}
 
-    An example how to insert String at index into HbComboBox.
+    An example of how to insert string at some index in HbComboBox.
     HbComboBox will creates the model internally if model is not created.
     \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,40}
 
-    An example how to insert StringList at index into HbComboBox.
+    An example of how to insert StringList at index into HbComboBox.
     HbComboBox will creates the model internally if model is not created.
     \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,41}
 
-    An example how to set the items into HbComboBox.
-    HbComboBox will replces the existing model.
+    An example of how to set the items into HbComboBox.
+    HbComboBox will replace the existing model.
     \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,42}
 
 */
@@ -136,7 +133,7 @@
     Q_D( HbComboBox );
     d->init( );
     updatePrimitives( );
-    setProperty("state", "normal");
+    setProperty( "state", "normal" );
 }
 
 /*!
@@ -155,14 +152,15 @@
     Q_D( HbComboBox );
     d->init( );
     updatePrimitives( );
-    setProperty("state", "normal");
+    setProperty( "state", "normal" );
 }
 
 /*!
     @beta
+
     \property HbComboBox::items
-    \brief list of comboBox items
-    It replaces the existing list.
+
+    It replaces the existing list with \a texts.
 */
 void HbComboBox::setItems( const QStringList &texts )
 {  
@@ -182,44 +180,46 @@
 
 /*!
     @beta
+
     This property holds the list added in the combobox.
     By default, for an empty combo box, this property has a empty StringList. 
  */
 QStringList HbComboBox::items( ) const
 {
     Q_D( const HbComboBox );
-    if( d->mModel && d->mModel->rowCount( )) {
+    if( d->mModel && d->mModel->rowCount( ) ) {
         QStringList list;
-        int rowCount = d->mModel->rowCount();
-        for(int i = 0; i < rowCount; i++)
-        {
-            list<<( d->mModel->data( d->mModel->index( i, 0 ) ) ).toString();
+        int rowCount = d->mModel->rowCount( );
+        for(int i = 0; i < rowCount; i++) {
+            list<<( d->mModel->data( d->mModel->index( i, 0 ) ) ).toString( );
         }
         return list;
     } else {
-      return QStringList();
+      return QStringList( );
     }
 }
 
 /*!
     @alpha
-    Sets the \a icon for the item on the given \a index in the combobox.
-    this API will not work if applcation sets the model as QStringlistModel.
+
+    Sets \a icon for the item at the given \a index in the combobox.
+    This API will not work if applcation sets the model as QStringListModel.
 */
 void HbComboBox::setItemIcon( int index, const HbIcon &icon )
 {
-    Q_D(const HbComboBox);
-    if(d->mModel) {
+    Q_D( const HbComboBox );
+    if( d->mModel ) {
         QModelIndex item = d->mModel->index( index, 0 );
-        if ( item.isValid( ) ) {        
-            d->mModel->setData( item, icon.qicon(), Qt::DecorationRole );
+        if ( item.isValid( ) ) {
+            d->mModel->setData( item, icon.qicon( ), Qt::DecorationRole );
         }
     }
 }
 
 /*!
     @alpha
-    returns the HbIcon for the given \a index in the combobox.
+
+    Returns HbIcon at \a index in the combobox.
 */
 HbIcon HbComboBox::itemIcon( int index ) const
 {
@@ -235,8 +235,9 @@
 
 /*!
     @beta
-    Returns the data for the given \a role in the given \a index in the
-    combobox, or QVariant::Invalid if there is no data for this role.
+
+    Either returns the \a role data at this \a index in HbComboBox, or QVariant::Invalid 
+    if there is no data for this role.
 */
 QVariant HbComboBox::itemData( int index, int role ) const
 {
@@ -245,14 +246,15 @@
         QModelIndex mi = d->mModel->index( index, 0 );
         if( mi.isValid ( ) ) {
             return d->mModel->data( mi, role );
-        } 
+        }
     }
     return QVariant( );
 }
 
 /*!
     @beta
-    Sets the data \a role for the item on the given \a index in the combobox
+
+    Sets the \a role data for the item at the given \a index in HbComboBox
     to the specified \a value.
 */
 void HbComboBox::setItemData( int index, const QVariant &value, int role )
@@ -267,14 +269,15 @@
 }
 
 /*!
-    @proto
-    This case is valid only for Editable comboBox
-    Returns the validator that is used to constraint text input to the
-    combobox and returns NULL if it is invalid.
+    @beta
+
+    This API is valid only for editable combobox.
+    Either returns the validator that is used to constraint text input in
+    combobox or returns NULL if it is invalid.
 
     \sa editable
 */
-const HbValidator *HbComboBox::validator() const
+const HbValidator *HbComboBox::validator( ) const
 {
     Q_D( const HbComboBox );
     if( d->mEditable) {
@@ -284,25 +287,28 @@
 }
 
 /*!
-    @proto
-    This case is only valid for the Editable comboBox.
-    Sets the \a validator to use instead of the current validator.
+    @beta
+
+    This API is only valid for the editable combobox.
+    Sets the \a validator to be used in editable combobox.
 */
 void HbComboBox::setValidator( HbValidator *validator )
 {
     Q_D( HbComboBox );
     if( d->mEditable ) {
-        disconnect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), 
+        disconnect( d->mLineEdit, SIGNAL( textChanged ( QString ) ),
             this, SLOT( _q_textChanged( QString ) ) );
         d->mLineEdit->setValidator( validator );
-        connect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), 
+        connect( d->mLineEdit, SIGNAL( textChanged ( QString ) ),
             this, SLOT( _q_textChanged( QString ) ) );
     }
 }
 
 /*!
-    This property holds the number of items in the combobox.
-    By default, for an empty combo box, this property has a value of 0.
+    @beta
+
+    This property holds the number of items in combobox.
+    For an empty combo box, this property is equal to 0.
  */
 int HbComboBox::count( ) const
 {
@@ -315,10 +321,12 @@
 
 /*!
     @beta
+
     Sets the model to \a model 
-    comboBox Owns the model set by the Application.
+    Ownership of \a model is taken by HbComboBox.
     It replaces the old model if exists.
-    please do not pass 0(NULL) as \a model instead call clear() to clear the contens of the model.
+    Do not pass 0(NULL) as \a model to clear contents of model instead call clear( ).
+    \sa clear
  */
 void HbComboBox::setModel( QAbstractItemModel * model )
 {
@@ -334,7 +342,8 @@
 
 /*!
     @beta
-    Returns model that view is currently presenting.
+
+    Returns current model.
  */
 QAbstractItemModel* HbComboBox::model( ) const
 {
@@ -344,6 +353,7 @@
 
 /*!
     @beta
+
     Sets current index to \a index.
     By default no item is selected.
  */
@@ -360,7 +370,8 @@
 
 /*!
     @beta
-    Returns index of current item and returns -1 for invalid current index.
+
+    Either returns index of current item if valid or else returns -1 for invalid current index.
  */
 int HbComboBox::currentIndex( ) const
 {
@@ -370,6 +381,7 @@
 
 /*!
     @beta
+
     \fn int HbComboBox::findText(const QString &text, Qt::MatchFlags 
                                       flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const
 
@@ -380,20 +392,23 @@
 */
 
 /*!
+    @beta
+
     Returns the index of the item containing the given \a data for the
-    given \a role; otherwise returns -1.
+    given \a role if valid, otherwise returns -1.
 
     The \a flags specify how the items in the combobox are searched.
 */
 int HbComboBox::findData( const QVariant &data, int role, Qt::MatchFlags flags ) const
 {
     Q_D( const HbComboBox );
-    if(d->mModel) {
+    if( d->mModel ) {
         QModelIndexList result;
         QModelIndex start = d->mModel->index( 0, 0 );
         result = d->mModel->match( start, role, data, 1, flags );
-        if ( result.isEmpty( ) )
+        if ( result.isEmpty( ) ) {
             return -1;
+        }
         return result.first( ).row( );
     }
     return -1;
@@ -401,26 +416,29 @@
 
 /*!
     @beta
-    This is specific to the Editable comboBox only.
-    Sets the text in the combobox's text edit 
+
+    This API is valid for editable combobox.
+    Sets the \a text in editable combobox's line edit.
  */
 void HbComboBox::setEditText( const QString &text )
 {
     Q_D( HbComboBox );
     if( d->mEditable ) {
-        disconnect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), 
+        disconnect( d->mLineEdit, SIGNAL( textChanged ( QString ) ),
             this, SLOT( _q_textChanged( QString ) ) );
         d->mLineEdit->setText( text );
-        connect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), 
+        connect( d->mLineEdit, SIGNAL( textChanged ( QString ) ),
             this, SLOT( _q_textChanged( QString ) ) );
     }
 }
 
 /*!
     @beta
+
     \property HbComboBox::currentText
-    \brief the text of the current item
-     combo box with model count \0 returns an empty string.
+
+    In case of non-editable combobox it returns the text at current index.
+    In case of editable combobox it returns the text in line edit.
 */
 QString HbComboBox::currentText( ) const
 {
@@ -436,8 +454,9 @@
 
 /*!
     @beta
-    Removes the item at the given index from the combobox.
-    This will update the current index if the index is removed. 
+
+    Removes the item at the given \a index from HbComboBox.
+    If \a index passed is current index then current index will be updated accordingly.
  */
 void HbComboBox::removeItem( int index )
 {
@@ -446,11 +465,11 @@
         int rowCount = d->mModel->rowCount( );
         if( index >=0 && index < rowCount ) {
             bool currentText = false;
-            if ( d->mModel->index(index, 0) == d->mCurrentIndex ) {
+            if ( d->mModel->index( index, 0 ) == d->mCurrentIndex ) {
                 currentText = true;
                 d->mModel->removeRow( index );
-            } else if( d->mCurrentIndex.row() > index ) {
-                 int row = d->mCurrentIndex.row();
+            } else if( d->mCurrentIndex.row( ) > index ) {
+                 int row = d->mCurrentIndex.row( );
                  d->mModel->removeRow( index );
                  d->mCurrentIndex = d->mModel->index( --row, 0 );
                  d->currentIndexChanged( d->mCurrentIndex );
@@ -459,35 +478,38 @@
             }
             if( d->mModel->rowCount( ) == 0 ) {
                 if( d->mEditable ) {
-                    clearEditText();
+                    clearEditText( );
                 } else {
                     if( d->mLineEdit ) {
-                        d->mLineEdit->setText( QString() );
+                        d->mLineEdit->setText( QString( ) );
                     } else {
-                        d->mText.clear();
+                        d->mText.clear( );
                         HbStyleOptionComboBox comboBoxOption;
-                        initStyleOption(&comboBoxOption);
-                        style()->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption);
+                        initStyleOption( &comboBoxOption );
+                        style( )->updatePrimitive(
+                            d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption );
                     }
                 }
+                d->mCurrentIndex = QModelIndex();
                 return;
             }
             if( currentText ) {
                 d->mCurrentIndex = d->mModel->index( 0, 0 );
                 if( d->mEditable ) {
                     disconnect(d->mLineEdit, SIGNAL( textChanged ( QString ) ),
-                                 this, SLOT( _q_textChanged( QString ) ) );
+                        this, SLOT( _q_textChanged( QString ) ) );
                     d->mLineEdit->setText( d->mModel->data( d->mCurrentIndex ).toString( ) );
                     connect(d->mLineEdit, SIGNAL( textChanged ( QString ) ), 
-                                 this, SLOT( _q_textChanged( QString ) ) );
+                        this, SLOT( _q_textChanged( QString ) ) );
                 } else {
                     if( d->mLineEdit ) {
-                        d->mLineEdit->setText( QString() );
+                        d->mLineEdit->setText( QString( ) );
                     } else {
                         d->mText = d->mModel->data( d->mCurrentIndex ).toString( );
                         HbStyleOptionComboBox comboBoxOption;
-                        initStyleOption(&comboBoxOption);
-                        style()->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption);
+                        initStyleOption( &comboBoxOption );
+                        style( )->updatePrimitive(
+                            d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption);
                     }
                 }
                 d->currentIndexChanged( d->mCurrentIndex );
@@ -503,7 +525,7 @@
 {
     Q_UNUSED( event )
     Q_D( HbComboBox );
-    if ( d->mDropDown && d->mDropDown->isVisible() ){
+    if ( d->mDropDown && d->mDropDown->isVisible( ) ) {
         d->positionDropDown( );
     }
 }
@@ -555,7 +577,7 @@
 {
     Q_D( const HbComboBox );
 
-    switch( primitive ){
+    switch( primitive ) {
         case HbStyle::P_ComboBox_text:
             return d->mTextItem;
         case HbStyle::P_ComboBox_background:
@@ -569,11 +591,14 @@
     }
 }
 
+/*!
+    \reimp
+ */
 void HbComboBox::initStyleOption( HbStyleOptionComboBox *option )const
 {
-    Q_D( const HbComboBox );    
+    Q_D( const HbComboBox );
     option->text = d->mText;
-    HbWidget::initStyleOption( option );  
+    HbWidget::initStyleOption( option );
 }
 
 /*!
@@ -581,7 +606,7 @@
  */
 void HbComboBox::updatePrimitives( )
 {
-    Q_D( HbComboBox );    
+    Q_D( HbComboBox );
     HbStyleOption styleOption;
     HbWidget::initStyleOption( &styleOption );
     if ( d->mIsDown ) {
@@ -597,24 +622,25 @@
 
 /*!
     @beta
-    Clears the combobox, removes all items from model. 
+
+    Removes all items from model. 
  */
 void HbComboBox::clear( )
 {
     Q_D( HbComboBox );
     if( d->mModel ) {
-        d->mModel->removeRows(0, d->mModel->rowCount());
+        d->mModel->removeRows( 0, d->mModel->rowCount( ) );
         d->mCurrentIndex = QModelIndex( );
         if( d->mEditable ) {
-            clearEditText();
+            clearEditText( );
         } else {
             if( d->mLineEdit ) {
-                d->mLineEdit->setText( QString() );
+                d->mLineEdit->setText( QString( ) );
             } else {
-                d->mText.clear();
+                d->mText.clear( );
                 HbStyleOptionComboBox comboBoxOption;
-                initStyleOption(&comboBoxOption);
-                style()->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption);
+                initStyleOption( &comboBoxOption );
+                style( )->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption );
             }
         }
     }
@@ -622,7 +648,9 @@
 
 /*!
     @beta
-    Clears the contents of the line edit used for editing in the combobox.
+
+    This API is valid only for editable combobox.
+    Clears the contents of line edit in editable combobox.
  */
 void HbComboBox::clearEditText( )
 {
@@ -638,24 +666,28 @@
 
 /*!
     @beta
+
     \property HbComboBox::editable
-    \brief Set editable the property of the combobox.
-    True, Editable, user can type in the combobox to search for items from 
-    the list of items. Shows the prediction. If user types a text which does not match
-    to any items in the model then slection is not changed.
-    False, Non editable user canot enter text using keyboard.
+    
+    If \a editable is true then combobox will be editable else it will be
+    non-editable.
+
+    \sa isEditable
  */
 void HbComboBox::setEditable( bool editable )
 {
     Q_D( HbComboBox ); 
     d->setEditable( editable );
-    setProperty("state", "normal");
+    setProperty( "state", "normal" );
 }
 
 /*!
     @beta
-    Returns whether or not the combobox is editable
-    True if editable, else false
+
+    Returns combobox is editable or not. If editable then returns true else returns
+    false.
+
+    \sa setEditable
  */
 bool HbComboBox::isEditable( ) const
 {
@@ -665,20 +697,25 @@
 
 /*!
     @beta
-    Adds an item to the combobox with the given text,
-    and containing the specified userData (stored in the Qt::UserRole).
-    The item is appended to the list of existing items.
+
+    Adds an item in combobox with the given \a text, containing the specified \a userData 
+    (stored in the Qt::UserRole). The item is appended to the list of existing items.
+
+    \sa insertItem
  */
-void HbComboBox::addItem( const QString &text, const QVariant &userData)
+void HbComboBox::addItem( const QString &text, const QVariant &userData )
 {
     insertItem( count( ), text, userData );
 }
 
 /*!
     @beta
-    Adds an item to the combobox with the given icon and text,
-    and containing the specified userData (stored in the Qt::UserRole). 
+
+    Adds an item in combobox with the given \a icon and \a text,
+    and containing the specified \a userData (stored in the Qt::UserRole). 
     The item is appended to the list of existing items.
+
+    \sa insertItem
  */
 void HbComboBox::addItem( const HbIcon &icon, const QString &text, const QVariant &userData )
 {
@@ -687,33 +724,39 @@
 
 /*!
     @beta
-    Adds each of the strings in the given texts to the combobox.
+
+    Adds each of the strings in the given \a texts to combobox.
     Each item is appended to the list of existing items in turn.
+
+    \sa insertItem
  */
 void HbComboBox::addItems( const QStringList &texts )
 {
-    insertItems( count(), texts );
+    insertItems( count( ), texts );
 }
 
 
 /*!
     @beta
-    Inserts the text into the combobox at the given index.
+
+    Inserts the \a text in combobox at the given \a index.
     If the index is equal to or higher than the total number of items, 
     the new item is appended to the list of existing items.
     If the index is zero or negative, the new item is prepended to the list of existing items.
+
+    \sa addItems addItem
  */
 void HbComboBox::insertItem( int index, const QString &text, const QVariant &userData )
 {
     Q_D( HbComboBox );
-    if( text.isNull( ) ){
+    if( text.isNull( ) ) {
         return;
     }
     if( !d->mModel ) {
-        QStandardItemModel* model = new QStandardItemModel(this );
+        QStandardItemModel* model = new QStandardItemModel( this );
         setModel( model );
     }
-    if (  !d->mModel->rowCount( ) ) {
+    if ( !d->mModel->rowCount( ) ) {
         d->mModel->insertRow( 0 );
         d->mModel->insertColumn( 0 );
         if( d->mModel->index( 0, 0 ).isValid( ) ) {
@@ -733,97 +776,21 @@
             }
         } else if(index <= 0) {
             d->mModel->insertRow( 0 );
-            d->mModel->setData( d->mModel->index(0,0), text, Qt::DisplayRole );
+            d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole );
             if( userData.isValid( ) ) {
                 d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole );
             }
-            if( d->mCurrentIndex.row() >= 0 ) {
-                d->mCurrentIndex = d->mModel->index(d->mCurrentIndex.row()+1, 0);
-                d->currentIndexChanged(d->mCurrentIndex);
+            if( d->mCurrentIndex.row( ) >= 0 ) {
+                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0);
+                d->currentIndexChanged( d->mCurrentIndex );
             }
         } else {
            d->mModel->insertRow( index );
            d->mModel->setData( d->mModel->index( index, 0 ), text, Qt::DisplayRole );
            if( userData.isValid( ) ) {
-                d->mModel->setData( d->mModel->index( index, 0 ), userData, Qt::UserRole );                
-            }
-           if( d->mCurrentIndex.row() <= index ) {
-                d->mCurrentIndex = d->mModel->index(d->mCurrentIndex.row()+1, 0);
-                d->currentIndexChanged(d->mCurrentIndex);
-            }
-        }
-    }
-}
-
-/*!
-    @beta
-    Inserts the text and icon into the combobox at the given index.
-    If the index is equal to or higher than the total number of items, 
-    the new item is appended to the list of existing items.
-    If the index is zero or negative, the new item is prepended to the list of existing items.
- */
-void HbComboBox::insertItem( int index, const HbIcon &icon, const QString &text, const QVariant &userData)
-{
-    Q_D( HbComboBox );
-    if( text.isEmpty( ) ){
-        return;
-    }
-
-    if( !d->mModel ) {
-        QStandardItemModel* model = new QStandardItemModel( this );
-        setModel( model );
-    }
-    if (  !d->mModel->rowCount( ) ) {
-        d->mModel->insertRow( 0 );
-        d->mModel->insertColumn( 0 );
-        if( d->mModel->index( 0, 0 ).isValid( ) ) {
-            d->mModel->setData( d->mModel->index(0,0), text, Qt::DisplayRole );
-            setCurrentIndex( 0 );
-        }
-        if(!icon.isNull() && d->mModel->index( 0, 0 ).isValid( ) ) {
-            d->mModel->setData(d->mModel->index( 0, 0 ), icon.qicon( ), Qt::DecorationRole);
-        }
-        if( userData.isValid( ) && d->mModel->index( 0, 0 ).isValid( ) ) {
-            d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole );                
-        }
-    } else {
-        int rowCount = d->mModel->rowCount( );
-        if( index >= rowCount ) {
-            d->mModel->insertRow( rowCount );
-            d->mModel->setData( d->mModel->index( rowCount, 0 ), text, Qt::DisplayRole );
-            if(!icon.isNull()) {
-                d->mModel->setData( d->mModel->index( rowCount, 0 ), icon, Qt::DecorationRole );
-            }
-            if( userData.isValid( ) ) {
-                d->mModel->setData( d->mModel->index( rowCount, 0 ), userData, Qt::UserRole );
-            }
-            if( d->mCurrentIndex.row() == index ) {
-                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 );
-                d->currentIndexChanged( d->mCurrentIndex );
-            }
-        } else if(index <= 0) {
-            d->mModel->insertRow( 0 );
-            d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole );
-            if(!icon.isNull()) {
-                d->mModel->setData(d->mModel->index( 0, 0 ), icon, Qt::DecorationRole);
-            }
-            if( userData.isValid( ) ) {
-                d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole );
-            }
-            if( d->mCurrentIndex.row() >= 0 ) {
-                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0);
-                d->currentIndexChanged( d->mCurrentIndex );
-            }
-        } else {
-            d->mModel->insertRow( index );
-            d->mModel->setData( d->mModel->index( index, 0 ), text, Qt::DisplayRole );
-            if(!icon.isNull( ) ) {
-                d->mModel->setData( d->mModel->index( index, 0 ), icon, Qt::DecorationRole );
-            }
-            if( userData.isValid( ) ) {
                 d->mModel->setData( d->mModel->index( index, 0 ), userData, Qt::UserRole );
             }
-            if( d->mCurrentIndex.row() <= index ) {
+           if( d->mCurrentIndex.row( ) >= index ) {
                 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0);
                 d->currentIndexChanged( d->mCurrentIndex );
             }
@@ -833,7 +800,88 @@
 
 /*!
     @beta
-    Inserts the strings from the list into the combobox as separate items, starting at the index.
+
+    Inserts the \a text and \a icon into the combobox at the given \a index.
+    If the index is equal to or higher than the total number of items, 
+    the new item is appended to the list of existing items.
+    If the index is zero or negative, the new item is prepended to the list of existing items.
+
+    \sa insertItem
+ */
+void HbComboBox::insertItem( int index, const HbIcon &icon,
+    const QString &text, const QVariant &userData )
+{
+    Q_D( HbComboBox );
+    if( text.isEmpty( ) ) {
+        return;
+    }
+
+    if( !d->mModel ) {
+        QStandardItemModel* model = new QStandardItemModel( this );
+        setModel( model );
+    }
+    if ( !d->mModel->rowCount( ) ) {
+        d->mModel->insertRow( 0 );
+        d->mModel->insertColumn( 0 );
+        if( d->mModel->index( 0, 0 ).isValid( ) ) {
+            d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole );
+            setCurrentIndex( 0 );
+        }
+        if( !icon.isNull( ) && d->mModel->index( 0, 0 ).isValid( ) ) {
+            d->mModel->setData( d->mModel->index( 0, 0 ), icon.qicon( ), Qt::DecorationRole );
+        }
+        if( userData.isValid( ) && d->mModel->index( 0, 0 ).isValid( ) ) {
+            d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole );
+        }
+    } else {
+        int rowCount = d->mModel->rowCount( );
+        if( index >= rowCount ) {
+            d->mModel->insertRow( rowCount );
+            d->mModel->setData( d->mModel->index( rowCount, 0 ), text, Qt::DisplayRole );
+            if( !icon.isNull( ) ) {
+                d->mModel->setData( d->mModel->index( rowCount, 0 ), icon, Qt::DecorationRole );
+            }
+            if( userData.isValid( ) ) {
+                d->mModel->setData( d->mModel->index( rowCount, 0 ), userData, Qt::UserRole );
+            }
+            if( d->mCurrentIndex.row( ) == index ) {
+                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 );
+                d->currentIndexChanged( d->mCurrentIndex );
+            }
+        } else if( index <= 0 ) {
+            d->mModel->insertRow( 0 );
+            d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole );
+            if( !icon.isNull( ) ) {
+                d->mModel->setData( d->mModel->index( 0, 0 ), icon, Qt::DecorationRole );
+            }
+            if( userData.isValid( ) ) {
+                d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole );
+            }
+            if( d->mCurrentIndex.row( ) >= 0 ) {
+                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 );
+                d->currentIndexChanged( d->mCurrentIndex );
+            }
+        } else {
+            d->mModel->insertRow( index );
+            d->mModel->setData( d->mModel->index( index, 0 ), text, Qt::DisplayRole );
+            if( !icon.isNull( ) ) {
+                d->mModel->setData( d->mModel->index( index, 0 ), icon, Qt::DecorationRole );
+            }
+            if( userData.isValid( ) ) {
+                d->mModel->setData( d->mModel->index( index, 0 ), userData, Qt::UserRole );
+            }
+            if( d->mCurrentIndex.row( ) <= index ) {
+                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 );
+                d->currentIndexChanged( d->mCurrentIndex );
+            }
+        }
+    }
+}
+
+/*!
+    @beta
+
+    Inserts the strings in \a texts into combobox as separate items, starting at the given \a index.
     If the index is equal to or higher than the total number of items, 
     the new item is appended to the list of existing items.
     If the index is zero or negative, the new item is prepended to the list of existing items.
@@ -847,11 +895,11 @@
     }
     if ( !d->mModel->rowCount( ) ) {
         int textCount = texts.count( );
-        for( int i = 0; i < textCount; i++)
-        {
+        for( int i = 0; i < textCount; i++) {
             d->mModel->insertRow( i );
-            if( i == 0)
+            if( i == 0) {
                 d->mModel->insertColumn( 0 );
+            }
             if( d->mModel->index( i, 0 ).isValid( ) ) {
                 d->mModel->setData( d->mModel->index( i, 0 ),  texts.at( i ), Qt::DisplayRole );
                 if( i == 0) {
@@ -859,7 +907,7 @@
                 }
             }
         }
-    }  else {
+    } else {
         int rowCount = -1;
         rowCount = d->mModel->rowCount( );
         int textCount = texts.count( );
@@ -869,8 +917,8 @@
             for ( int i = rowCount; i < ( rowCount + textCount ); i++ ) {
                 d->mModel->setData ( d->mModel->index( i, 0 ), texts.at( temp++ ) );
             }
-            if( d->mCurrentIndex.row() == index ) {
-                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + textCount, 0);
+            if( d->mCurrentIndex.row( ) == index ) {
+                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + textCount, 0 );
                 d->currentIndexChanged( d->mCurrentIndex );
             }
         } else if( index <= 0 ) {
@@ -878,8 +926,8 @@
             for ( int i = 0; i < textCount; i++ ) {
                 d->mModel->setData( d->mModel->index( i, 0 ), texts.at( i ) );
             }
-            if( d->mCurrentIndex.row() >= 0 ) {
-                d->mCurrentIndex = d->mModel->index(d->mCurrentIndex.row() + textCount, 0);
+            if( d->mCurrentIndex.row( ) >= 0 ) {
+                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + textCount, 0 );
                 d->currentIndexChanged( d->mCurrentIndex );
             }
         } else {
@@ -888,8 +936,8 @@
             for ( int i = index; i < ( textCount + index ); i++ ) {
                 d->mModel->setData( d->mModel->index( i, 0 ), texts.at( temp++ ) );
             }
-            if( d->mCurrentIndex.row() <= index ) {
-                d->mCurrentIndex = d->mModel->index(d->mCurrentIndex.row() + textCount, 0);
+            if( d->mCurrentIndex.row( ) <= index ) {
+                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + textCount, 0 );
                 d->currentIndexChanged( d->mCurrentIndex );
             }
         }
@@ -898,14 +946,17 @@
 
 /*!
     @beta
-    Returns the text for the given index in the combobox.
+
+    Returns text at given \a index in combobox.
+
+    \sa setItemText
  */
 QString HbComboBox::itemText( int index ) const
 {
     Q_D( const HbComboBox );
-    if(d->mModel) {
+    if( d->mModel ) {
         QModelIndex mi = d->mModel->index( index, 0 );
-        if( mi.isValid() ) {
+        if( mi.isValid( ) ) {
             return d->itemText( mi );
         }
      }
@@ -914,27 +965,30 @@
 
 /*!
     @beta
-    Sets the text for the item on the given index in the combobox.
+
+    Sets the \a text for item at given \a index in combobox.
+
+    \sa itemText
  */
 void HbComboBox::setItemText( int index, const QString &text )
 {
     Q_D( HbComboBox );
-    if (d->mModel) {
+    if ( d->mModel ) {
         QModelIndex item = d->mModel->index( index, 0 );
         if ( item.isValid( ) ) {
-            if(d->mModel->setData( item, text, Qt::EditRole )) {
-                if(d->mCurrentIndex.row() == index) {
+            if( d->mModel->setData( item, text, Qt::EditRole ) ) {
+                if( d->mCurrentIndex.row( ) == index ) {
                     if( d->mLineEdit ) {
                         d->mLineEdit->setText( text );
-                    } else {                    
+                    } else {
                         d->mText = text ;
                         HbStyleOptionComboBox comboBoxOption;
-                        initStyleOption(&comboBoxOption);
-                        style()->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption);
+                        initStyleOption( &comboBoxOption );
+                        style( )->updatePrimitive(
+                            d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption );
                     }
                 }
             }
-            
         }
     }
 }
@@ -946,26 +1000,27 @@
 {
     Q_D( HbComboBox );
     bool accepted = false;
-    if ( !isEnabled() ) {
+    if ( !isEnabled( ) ) {
         return false ;
     }
-    if(obj == static_cast<HbTouchArea*>(d->mButtonTouchAreaItem)) {
-        if(event->type() == QEvent::Gesture ) {
+    if( obj == static_cast<HbTouchArea*>( d->mButtonTouchAreaItem ) ) {
+        if( event->type( ) == QEvent::Gesture ) {
             QGestureEvent *gestureEvent = static_cast<QGestureEvent *>( event );
-            if(gestureEvent->gesture(Qt::TapGesture)) {
-                HbTapGesture *tap = static_cast<HbTapGesture *>(gestureEvent->gesture(Qt::TapGesture));
-                switch(tap->state()) {
+            if( gestureEvent->gesture( Qt::TapGesture ) ) {
+                HbTapGesture *tap =
+                    static_cast<HbTapGesture *>( gestureEvent->gesture( Qt::TapGesture ) );
+                switch( tap->state( ) ) {
                 case Qt::GestureStarted:
                     {
                         d->touchAreaPressEvent( );
                         accepted = true;
                         break;
-                    }                
+                    }
                 case Qt::GestureCanceled:
                     {
                         d->mIsDown = false;
-                        updatePrimitives();
-                        setProperty("state", "normal");
+                        updatePrimitives( );
+                        setProperty( "state", "normal" );
                         accepted = true;
                         break;
                     }
@@ -990,7 +1045,7 @@
  */
 void HbComboBox::changeEvent( QEvent *event )
 {
-    switch ( event->type( ) ){
+    switch ( event->type( ) ) {
         case QEvent::EnabledChange:
             updatePrimitives( );
             break;