equal
deleted
inserted
replaced
159 /*! |
159 /*! |
160 @beta |
160 @beta |
161 |
161 |
162 \property HbComboBox::items |
162 \property HbComboBox::items |
163 |
163 |
164 It replaces the existing list with \a texts. |
164 It replaces the existing list with \a texts. If \a texts passed is empty then this function |
|
165 clears the model and returns. |
|
166 |
|
167 \sa clear() |
165 */ |
168 */ |
166 void HbComboBox::setItems( const QStringList &texts ) |
169 void HbComboBox::setItems( const QStringList &texts ) |
167 { |
170 { |
168 if ( texts.isEmpty( ) ) { |
171 if ( texts.isEmpty( ) ) { |
|
172 //if string list passed is empty then clear the current items in combobox |
|
173 clear(); |
169 return; |
174 return; |
170 } |
175 } |
171 QStandardItemModel* model = new QStandardItemModel( this ); |
176 QStandardItemModel* model = new QStandardItemModel( this ); |
172 int textCount = texts.count( ); |
177 int textCount = texts.count( ); |
173 for( int i = 0; i < textCount; i++ ) |
178 for( int i = 0; i < textCount; i++ ) |
485 d->mLineEdit->setText( QString( ) ); |
490 d->mLineEdit->setText( QString( ) ); |
486 } else { |
491 } else { |
487 d->mText.clear( ); |
492 d->mText.clear( ); |
488 HbStyleOptionComboBox comboBoxOption; |
493 HbStyleOptionComboBox comboBoxOption; |
489 initStyleOption( &comboBoxOption ); |
494 initStyleOption( &comboBoxOption ); |
490 style( )->updatePrimitive( |
495 HbStylePrivate::updatePrimitive( |
491 d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption ); |
496 d->mTextItem, HbStylePrivate::P_ComboBox_text, &comboBoxOption ); |
492 } |
497 } |
493 } |
498 } |
494 d->mCurrentIndex = QModelIndex(); |
499 d->mCurrentIndex = QModelIndex(); |
495 return; |
500 return; |
496 } |
501 } |
507 d->mLineEdit->setText( QString( ) ); |
512 d->mLineEdit->setText( QString( ) ); |
508 } else { |
513 } else { |
509 d->mText = d->mModel->data( d->mCurrentIndex ).toString( ); |
514 d->mText = d->mModel->data( d->mCurrentIndex ).toString( ); |
510 HbStyleOptionComboBox comboBoxOption; |
515 HbStyleOptionComboBox comboBoxOption; |
511 initStyleOption( &comboBoxOption ); |
516 initStyleOption( &comboBoxOption ); |
512 style( )->updatePrimitive( |
517 HbStylePrivate::updatePrimitive( |
513 d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption); |
518 d->mTextItem, HbStylePrivate::P_ComboBox_text, &comboBoxOption); |
514 } |
519 } |
515 } |
520 } |
516 d->currentIndexChanged( d->mCurrentIndex ); |
521 d->currentIndexChanged( d->mCurrentIndex ); |
517 } |
522 } |
518 } |
523 } |
577 QGraphicsItem* HbComboBox::primitive( HbStyle::Primitive primitive ) const |
582 QGraphicsItem* HbComboBox::primitive( HbStyle::Primitive primitive ) const |
578 { |
583 { |
579 Q_D( const HbComboBox ); |
584 Q_D( const HbComboBox ); |
580 |
585 |
581 switch( primitive ) { |
586 switch( primitive ) { |
582 case HbStyle::P_ComboBox_text: |
587 case HbStylePrivate::P_ComboBox_text: |
583 return d->mTextItem; |
588 return d->mTextItem; |
584 case HbStyle::P_ComboBox_background: |
589 case HbStylePrivate::P_ComboBox_background: |
585 return d->mBackgroundItem; |
590 return d->mBackgroundItem; |
586 case HbStyle::P_ComboBox_button: |
591 case HbStylePrivate::P_ComboBox_button: |
587 return d->mButton; |
592 return d->mButton; |
588 case HbStyle::P_ComboBoxButton_toucharea: |
593 case HbStylePrivate::P_ComboBoxButton_toucharea: |
589 return d->mButtonTouchAreaItem; |
594 return d->mButtonTouchAreaItem; |
590 default: |
595 default: |
591 return 0; |
596 return 0; |
592 } |
597 } |
593 } |
598 } |
612 HbWidget::initStyleOption( &styleOption ); |
617 HbWidget::initStyleOption( &styleOption ); |
613 if ( d->mIsDown ) { |
618 if ( d->mIsDown ) { |
614 styleOption.state |= QStyle::State_Sunken; |
619 styleOption.state |= QStyle::State_Sunken; |
615 } |
620 } |
616 if ( d->mBackgroundItem ) { |
621 if ( d->mBackgroundItem ) { |
617 style( )->updatePrimitive( |
622 HbStylePrivate::updatePrimitive( |
618 d->mBackgroundItem, HbStyle::P_ComboBox_background, &styleOption ); |
623 d->mBackgroundItem, HbStylePrivate::P_ComboBox_background, &styleOption ); |
619 style( )->updatePrimitive( |
624 HbStylePrivate::updatePrimitive( |
620 d->mButton, HbStyle::P_ComboBox_button, &styleOption ); |
625 d->mButton, HbStylePrivate::P_ComboBox_button, &styleOption ); |
621 } |
626 } |
622 } |
627 } |
623 |
628 |
624 /*! |
629 /*! |
625 @beta |
630 @beta |
639 d->mLineEdit->setText( QString( ) ); |
644 d->mLineEdit->setText( QString( ) ); |
640 } else { |
645 } else { |
641 d->mText.clear( ); |
646 d->mText.clear( ); |
642 HbStyleOptionComboBox comboBoxOption; |
647 HbStyleOptionComboBox comboBoxOption; |
643 initStyleOption( &comboBoxOption ); |
648 initStyleOption( &comboBoxOption ); |
644 style( )->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption ); |
649 HbStylePrivate::updatePrimitive( d->mTextItem, HbStylePrivate::P_ComboBox_text, &comboBoxOption ); |
645 } |
650 } |
646 } |
651 } |
647 } |
652 } |
648 } |
653 } |
649 |
654 |
985 d->mLineEdit->setText( text ); |
990 d->mLineEdit->setText( text ); |
986 } else { |
991 } else { |
987 d->mText = text ; |
992 d->mText = text ; |
988 HbStyleOptionComboBox comboBoxOption; |
993 HbStyleOptionComboBox comboBoxOption; |
989 initStyleOption( &comboBoxOption ); |
994 initStyleOption( &comboBoxOption ); |
990 style( )->updatePrimitive( |
995 HbStylePrivate::updatePrimitive( |
991 d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption ); |
996 d->mTextItem, HbStylePrivate::P_ComboBox_text, &comboBoxOption ); |
992 } |
997 } |
993 } |
998 } |
994 } |
999 } |
995 } |
1000 } |
996 } |
1001 } |