45 |
47 |
46 A HbComboBox provides a means of presenting a list of options to the user |
48 A HbComboBox provides a means of presenting a list of options to the user |
47 in a way that takes up the minimum amount of screen space. |
49 in a way that takes up the minimum amount of screen space. |
48 |
50 |
49 A combobox is a selection widget that displays the currently selected item, |
51 A combobox is a selection widget that displays the currently selected item, |
50 and can provides a drop-down list that permits selecting an item. |
52 and provides a drop-down list that permits selecting an item. |
51 |
53 |
52 A HbComboBox with currently Selected item |
54 A HbComboBox with currently selected item |
53 \image html noneditablecombobox.png. |
55 \image html noneditablecombobox.png. |
54 |
56 |
55 |
57 |
56 A HbComboBox with drop-down list to select an item from list of options |
58 A HbComboBox with drop-down list to select an item from list of options |
57 \image html comboboxdropdownlist.png. |
59 \image html comboboxdropdownlist.png. |
58 |
60 |
59 |
61 |
60 HbComboBox are of two types. |
62 HbComboBox are of two types: |
61 |
63 |
62 Editable: |
64 1: Editable: |
63 |
65 |
64 If the comboBox is set to editable, touching the ComboBox label field invokes the VKB in |
66 If combobox is set to editable, tapping on combobox label field invokes the VKB in |
65 touch environments or accepts input from an attached keyboard. |
67 touch environments or accepts input from an attached keyboard. Tapping on |
66 choosing an element from the ComboBox dropdown list replaces the label |
68 button area of combobox launches dropdown list. Choosing an element from |
67 area with the chosen item. |
69 the combobox dropdown list replaces the label with the chosen item. Touch events on |
68 on touching button area of the comboBox launches the drop-down list to select |
70 combobox button behaves same in both editable and non-editable combobox. |
69 the list of options |
71 |
70 ( button area in comboBox behaves same in both editable and Non Editable comboBox ). |
72 2: Non Editable: |
71 |
|
72 Non Editable: |
|
73 |
73 |
74 If the comboBox is set to Non Editable widget that displays the currently selected item |
74 If the combobox is set to non-editable then even tapping on label field will launch |
75 in the label field of ComboBox. |
75 drop down unlike editable combobox. Tapping on combobox button area behaves in |
76 Touching the comboBox label field or button area of the comboBox will opens |
76 same way as in editable combobox. |
77 the drop-down list to select an item from list of options. |
77 |
78 |
78 By default combobox is non-editable. |
79 By Default comboBox is Non Editable. |
79 |
80 |
80 Application is responsible for setting the model in combobox. If no model is set or model |
81 Application is responsible for setting the model to the HbComboBox, |
81 set is empty then drop down list will not be displayed at all. Combobox owns the model set |
82 If no model is set, the drop down list cannot be displayed at all. |
82 by application. |
83 |
83 |
84 HbComboBox owns the model set by the Application. |
84 The number of rows to be displayed in HbComboBox drop down can be configured by overriding |
85 |
85 HbComboBox css. By default number of items in drop down is 8 in portrait mode and 5 in |
86 HbComboBox provides three signals: |
86 landscape mode. |
|
87 |
|
88 HbComboBox provides four signals: |
87 |
89 |
88 \li currentIndexChanged( index ) is emitted when the current selection in the combobox is |
90 \li currentIndexChanged( index ) is emitted when the current selection in the combobox is |
89 changed by user interaction. If application is setting a index/text then this signal is |
91 changed either by user interaction or programmatically. |
90 not emmitted. In case of an editable combobox on combobox loosing focus if the current |
|
91 selection has changed then this signal is emitted with the new model index. |
|
92 |
92 |
93 \li currentIndexChanged( const QString& ) is emitted when the curret selection in the combobox |
93 \li currentIndexChanged( const QString& ) is emitted when the curret selection in the combobox |
94 is changed by user interaction. If application is setting a differnet index/text |
94 is changed by user interaction. If application is setting a differnet index/text |
95 then this signal is not emmitted. |
95 then this signal is not emmitted. |
96 In case of an editable combobox on combobox loosing focus if the current selection |
96 |
97 has changed then this signal is emitted with the new string. |
97 \li editTextChanged( const QString& ) is emitted when text is changed in editable combobox. |
98 |
98 |
99 \li editTextChanged( QString& ) is emitted when combobox looses focus and user has typed a text |
99 \li editingFinished( ) is emitted either because editable combobox lost focus or Return/Enter |
100 for which there is no matching item found in the model with the text typed by the user. |
100 is pressed. |
101 |
101 |
102 The following is an example of how to create a model and adding item to the created model. |
102 The following is an example of how to create a model and adding item in the model. |
103 How to set the model on the HbcomboBox. |
103 HbComboBox takes ownership of model. |
104 Here the model is ownership transfer to the widget. |
|
105 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,37} |
104 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,37} |
106 |
105 |
107 An example how to add strings into HbComboBox and setting currentIndex. |
106 An example of how to add strings in HbComboBox and setting currentIndex. |
108 HbComboBox will creates the model internally if model is not created. |
107 HbComboBox will creates model internally if model is not created. |
109 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,38} |
108 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,38} |
110 |
109 |
111 An example how to add stringsList into HbComboBox and setting currentIndex. |
110 An example of how to add stringsList into HbComboBox and setting currentIndex. |
112 HbComboBox will creates the model internally if model is not created. |
111 HbComboBox will creates the model internally if model is not created. |
113 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,39} |
112 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,39} |
114 |
113 |
115 An example how to insert String at index into HbComboBox. |
114 An example of how to insert string at some index in HbComboBox. |
116 HbComboBox will creates the model internally if model is not created. |
115 HbComboBox will creates the model internally if model is not created. |
117 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,40} |
116 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,40} |
118 |
117 |
119 An example how to insert StringList at index into HbComboBox. |
118 An example of how to insert StringList at index into HbComboBox. |
120 HbComboBox will creates the model internally if model is not created. |
119 HbComboBox will creates the model internally if model is not created. |
121 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,41} |
120 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,41} |
122 |
121 |
123 An example how to set the items into HbComboBox. |
122 An example of how to set the items into HbComboBox. |
124 HbComboBox will replces the existing model. |
123 HbComboBox will replace the existing model. |
125 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,42} |
124 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,42} |
126 |
125 |
127 */ |
126 */ |
128 |
127 |
129 |
128 |
180 setModel( model ); |
179 setModel( model ); |
181 } |
180 } |
182 |
181 |
183 /*! |
182 /*! |
184 @beta |
183 @beta |
|
184 |
185 This property holds the list added in the combobox. |
185 This property holds the list added in the combobox. |
186 By default, for an empty combo box, this property has a empty StringList. |
186 By default, for an empty combo box, this property has a empty StringList. |
187 */ |
187 */ |
188 QStringList HbComboBox::items( ) const |
188 QStringList HbComboBox::items( ) const |
189 { |
189 { |
190 Q_D( const HbComboBox ); |
190 Q_D( const HbComboBox ); |
191 if( d->mModel && d->mModel->rowCount( )) { |
191 if( d->mModel && d->mModel->rowCount( ) ) { |
192 QStringList list; |
192 QStringList list; |
193 int rowCount = d->mModel->rowCount(); |
193 int rowCount = d->mModel->rowCount( ); |
194 for(int i = 0; i < rowCount; i++) |
194 for(int i = 0; i < rowCount; i++) { |
195 { |
195 list<<( d->mModel->data( d->mModel->index( i, 0 ) ) ).toString( ); |
196 list<<( d->mModel->data( d->mModel->index( i, 0 ) ) ).toString(); |
|
197 } |
196 } |
198 return list; |
197 return list; |
199 } else { |
198 } else { |
200 return QStringList(); |
199 return QStringList( ); |
201 } |
200 } |
202 } |
201 } |
203 |
202 |
204 /*! |
203 /*! |
205 @alpha |
204 @alpha |
206 Sets the \a icon for the item on the given \a index in the combobox. |
205 |
207 this API will not work if applcation sets the model as QStringlistModel. |
206 Sets \a icon for the item at the given \a index in the combobox. |
|
207 This API will not work if applcation sets the model as QStringListModel. |
208 */ |
208 */ |
209 void HbComboBox::setItemIcon( int index, const HbIcon &icon ) |
209 void HbComboBox::setItemIcon( int index, const HbIcon &icon ) |
210 { |
210 { |
211 Q_D(const HbComboBox); |
211 Q_D( const HbComboBox ); |
212 if(d->mModel) { |
212 if( d->mModel ) { |
213 QModelIndex item = d->mModel->index( index, 0 ); |
213 QModelIndex item = d->mModel->index( index, 0 ); |
214 if ( item.isValid( ) ) { |
214 if ( item.isValid( ) ) { |
215 d->mModel->setData( item, icon.qicon(), Qt::DecorationRole ); |
215 d->mModel->setData( item, icon.qicon( ), Qt::DecorationRole ); |
216 } |
216 } |
217 } |
217 } |
218 } |
218 } |
219 |
219 |
220 /*! |
220 /*! |
221 @alpha |
221 @alpha |
222 returns the HbIcon for the given \a index in the combobox. |
222 |
|
223 Returns HbIcon at \a index in the combobox. |
223 */ |
224 */ |
224 HbIcon HbComboBox::itemIcon( int index ) const |
225 HbIcon HbComboBox::itemIcon( int index ) const |
225 { |
226 { |
226 Q_D( const HbComboBox ); |
227 Q_D( const HbComboBox ); |
227 if( d->mModel ) { |
228 if( d->mModel ) { |
265 } |
268 } |
266 } |
269 } |
267 } |
270 } |
268 |
271 |
269 /*! |
272 /*! |
270 @proto |
273 @beta |
271 This case is valid only for Editable comboBox |
274 |
272 Returns the validator that is used to constraint text input to the |
275 This API is valid only for editable combobox. |
273 combobox and returns NULL if it is invalid. |
276 Either returns the validator that is used to constraint text input in |
|
277 combobox or returns NULL if it is invalid. |
274 |
278 |
275 \sa editable |
279 \sa editable |
276 */ |
280 */ |
277 const HbValidator *HbComboBox::validator() const |
281 const HbValidator *HbComboBox::validator( ) const |
278 { |
282 { |
279 Q_D( const HbComboBox ); |
283 Q_D( const HbComboBox ); |
280 if( d->mEditable) { |
284 if( d->mEditable) { |
281 return d->mLineEdit->validator( ); |
285 return d->mLineEdit->validator( ); |
282 } |
286 } |
283 return 0; |
287 return 0; |
284 } |
288 } |
285 |
289 |
286 /*! |
290 /*! |
287 @proto |
291 @beta |
288 This case is only valid for the Editable comboBox. |
292 |
289 Sets the \a validator to use instead of the current validator. |
293 This API is only valid for the editable combobox. |
|
294 Sets the \a validator to be used in editable combobox. |
290 */ |
295 */ |
291 void HbComboBox::setValidator( HbValidator *validator ) |
296 void HbComboBox::setValidator( HbValidator *validator ) |
292 { |
297 { |
293 Q_D( HbComboBox ); |
298 Q_D( HbComboBox ); |
294 if( d->mEditable ) { |
299 if( d->mEditable ) { |
295 disconnect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
300 disconnect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
296 this, SLOT( _q_textChanged( QString ) ) ); |
301 this, SLOT( _q_textChanged( QString ) ) ); |
297 d->mLineEdit->setValidator( validator ); |
302 d->mLineEdit->setValidator( validator ); |
298 connect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
303 connect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
299 this, SLOT( _q_textChanged( QString ) ) ); |
304 this, SLOT( _q_textChanged( QString ) ) ); |
300 } |
305 } |
301 } |
306 } |
302 |
307 |
303 /*! |
308 /*! |
304 This property holds the number of items in the combobox. |
309 @beta |
305 By default, for an empty combo box, this property has a value of 0. |
310 |
|
311 This property holds the number of items in combobox. |
|
312 For an empty combo box, this property is equal to 0. |
306 */ |
313 */ |
307 int HbComboBox::count( ) const |
314 int HbComboBox::count( ) const |
308 { |
315 { |
309 Q_D( const HbComboBox ); |
316 Q_D( const HbComboBox ); |
310 if( d->mModel ) { |
317 if( d->mModel ) { |
358 } |
369 } |
359 } |
370 } |
360 |
371 |
361 /*! |
372 /*! |
362 @beta |
373 @beta |
363 Returns index of current item and returns -1 for invalid current index. |
374 |
|
375 Either returns index of current item if valid or else returns -1 for invalid current index. |
364 */ |
376 */ |
365 int HbComboBox::currentIndex( ) const |
377 int HbComboBox::currentIndex( ) const |
366 { |
378 { |
367 Q_D( const HbComboBox ); |
379 Q_D( const HbComboBox ); |
368 return d->mCurrentIndex.row( ); |
380 return d->mCurrentIndex.row( ); |
369 } |
381 } |
370 |
382 |
371 /*! |
383 /*! |
372 @beta |
384 @beta |
|
385 |
373 \fn int HbComboBox::findText(const QString &text, Qt::MatchFlags |
386 \fn int HbComboBox::findText(const QString &text, Qt::MatchFlags |
374 flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const |
387 flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const |
375 |
388 |
376 Returns the index of the item containing the given \a text; otherwise |
389 Returns the index of the item containing the given \a text; otherwise |
377 returns -1. |
390 returns -1. |
378 |
391 |
379 The \a flags specify how the items in the combobox are searched. |
392 The \a flags specify how the items in the combobox are searched. |
380 */ |
393 */ |
381 |
394 |
382 /*! |
395 /*! |
|
396 @beta |
|
397 |
383 Returns the index of the item containing the given \a data for the |
398 Returns the index of the item containing the given \a data for the |
384 given \a role; otherwise returns -1. |
399 given \a role if valid, otherwise returns -1. |
385 |
400 |
386 The \a flags specify how the items in the combobox are searched. |
401 The \a flags specify how the items in the combobox are searched. |
387 */ |
402 */ |
388 int HbComboBox::findData( const QVariant &data, int role, Qt::MatchFlags flags ) const |
403 int HbComboBox::findData( const QVariant &data, int role, Qt::MatchFlags flags ) const |
389 { |
404 { |
390 Q_D( const HbComboBox ); |
405 Q_D( const HbComboBox ); |
391 if(d->mModel) { |
406 if( d->mModel ) { |
392 QModelIndexList result; |
407 QModelIndexList result; |
393 QModelIndex start = d->mModel->index( 0, 0 ); |
408 QModelIndex start = d->mModel->index( 0, 0 ); |
394 result = d->mModel->match( start, role, data, 1, flags ); |
409 result = d->mModel->match( start, role, data, 1, flags ); |
395 if ( result.isEmpty( ) ) |
410 if ( result.isEmpty( ) ) { |
396 return -1; |
411 return -1; |
|
412 } |
397 return result.first( ).row( ); |
413 return result.first( ).row( ); |
398 } |
414 } |
399 return -1; |
415 return -1; |
400 } |
416 } |
401 |
417 |
402 /*! |
418 /*! |
403 @beta |
419 @beta |
404 This is specific to the Editable comboBox only. |
420 |
405 Sets the text in the combobox's text edit |
421 This API is valid for editable combobox. |
|
422 Sets the \a text in editable combobox's line edit. |
406 */ |
423 */ |
407 void HbComboBox::setEditText( const QString &text ) |
424 void HbComboBox::setEditText( const QString &text ) |
408 { |
425 { |
409 Q_D( HbComboBox ); |
426 Q_D( HbComboBox ); |
410 if( d->mEditable ) { |
427 if( d->mEditable ) { |
411 disconnect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
428 disconnect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
412 this, SLOT( _q_textChanged( QString ) ) ); |
429 this, SLOT( _q_textChanged( QString ) ) ); |
413 d->mLineEdit->setText( text ); |
430 d->mLineEdit->setText( text ); |
414 connect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
431 connect( d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
415 this, SLOT( _q_textChanged( QString ) ) ); |
432 this, SLOT( _q_textChanged( QString ) ) ); |
416 } |
433 } |
417 } |
434 } |
418 |
435 |
419 /*! |
436 /*! |
420 @beta |
437 @beta |
|
438 |
421 \property HbComboBox::currentText |
439 \property HbComboBox::currentText |
422 \brief the text of the current item |
440 |
423 combo box with model count \0 returns an empty string. |
441 In case of non-editable combobox it returns the text at current index. |
|
442 In case of editable combobox it returns the text in line edit. |
424 */ |
443 */ |
425 QString HbComboBox::currentText( ) const |
444 QString HbComboBox::currentText( ) const |
426 { |
445 { |
427 Q_D( const HbComboBox ); |
446 Q_D( const HbComboBox ); |
428 if( d->mEditable ) { |
447 if( d->mEditable ) { |
434 } |
453 } |
435 } |
454 } |
436 |
455 |
437 /*! |
456 /*! |
438 @beta |
457 @beta |
439 Removes the item at the given index from the combobox. |
458 |
440 This will update the current index if the index is removed. |
459 Removes the item at the given \a index from HbComboBox. |
|
460 If \a index passed is current index then current index will be updated accordingly. |
441 */ |
461 */ |
442 void HbComboBox::removeItem( int index ) |
462 void HbComboBox::removeItem( int index ) |
443 { |
463 { |
444 Q_D( HbComboBox ); |
464 Q_D( HbComboBox ); |
445 if( d->mModel ) { |
465 if( d->mModel ) { |
446 int rowCount = d->mModel->rowCount( ); |
466 int rowCount = d->mModel->rowCount( ); |
447 if( index >=0 && index < rowCount ) { |
467 if( index >=0 && index < rowCount ) { |
448 bool currentText = false; |
468 bool currentText = false; |
449 if ( d->mModel->index(index, 0) == d->mCurrentIndex ) { |
469 if ( d->mModel->index( index, 0 ) == d->mCurrentIndex ) { |
450 currentText = true; |
470 currentText = true; |
451 d->mModel->removeRow( index ); |
471 d->mModel->removeRow( index ); |
452 } else if( d->mCurrentIndex.row() > index ) { |
472 } else if( d->mCurrentIndex.row( ) > index ) { |
453 int row = d->mCurrentIndex.row(); |
473 int row = d->mCurrentIndex.row( ); |
454 d->mModel->removeRow( index ); |
474 d->mModel->removeRow( index ); |
455 d->mCurrentIndex = d->mModel->index( --row, 0 ); |
475 d->mCurrentIndex = d->mModel->index( --row, 0 ); |
456 d->currentIndexChanged( d->mCurrentIndex ); |
476 d->currentIndexChanged( d->mCurrentIndex ); |
457 } else { |
477 } else { |
458 d->mModel->removeRow( index ); |
478 d->mModel->removeRow( index ); |
459 } |
479 } |
460 if( d->mModel->rowCount( ) == 0 ) { |
480 if( d->mModel->rowCount( ) == 0 ) { |
461 if( d->mEditable ) { |
481 if( d->mEditable ) { |
462 clearEditText(); |
482 clearEditText( ); |
463 } else { |
483 } else { |
464 if( d->mLineEdit ) { |
484 if( d->mLineEdit ) { |
465 d->mLineEdit->setText( QString() ); |
485 d->mLineEdit->setText( QString( ) ); |
466 } else { |
486 } else { |
467 d->mText.clear(); |
487 d->mText.clear( ); |
468 HbStyleOptionComboBox comboBoxOption; |
488 HbStyleOptionComboBox comboBoxOption; |
469 initStyleOption(&comboBoxOption); |
489 initStyleOption( &comboBoxOption ); |
470 style()->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption); |
490 style( )->updatePrimitive( |
|
491 d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption ); |
471 } |
492 } |
472 } |
493 } |
|
494 d->mCurrentIndex = QModelIndex(); |
473 return; |
495 return; |
474 } |
496 } |
475 if( currentText ) { |
497 if( currentText ) { |
476 d->mCurrentIndex = d->mModel->index( 0, 0 ); |
498 d->mCurrentIndex = d->mModel->index( 0, 0 ); |
477 if( d->mEditable ) { |
499 if( d->mEditable ) { |
478 disconnect(d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
500 disconnect(d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
479 this, SLOT( _q_textChanged( QString ) ) ); |
501 this, SLOT( _q_textChanged( QString ) ) ); |
480 d->mLineEdit->setText( d->mModel->data( d->mCurrentIndex ).toString( ) ); |
502 d->mLineEdit->setText( d->mModel->data( d->mCurrentIndex ).toString( ) ); |
481 connect(d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
503 connect(d->mLineEdit, SIGNAL( textChanged ( QString ) ), |
482 this, SLOT( _q_textChanged( QString ) ) ); |
504 this, SLOT( _q_textChanged( QString ) ) ); |
483 } else { |
505 } else { |
484 if( d->mLineEdit ) { |
506 if( d->mLineEdit ) { |
485 d->mLineEdit->setText( QString() ); |
507 d->mLineEdit->setText( QString( ) ); |
486 } else { |
508 } else { |
487 d->mText = d->mModel->data( d->mCurrentIndex ).toString( ); |
509 d->mText = d->mModel->data( d->mCurrentIndex ).toString( ); |
488 HbStyleOptionComboBox comboBoxOption; |
510 HbStyleOptionComboBox comboBoxOption; |
489 initStyleOption(&comboBoxOption); |
511 initStyleOption( &comboBoxOption ); |
490 style()->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption); |
512 style( )->updatePrimitive( |
|
513 d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption); |
491 } |
514 } |
492 } |
515 } |
493 d->currentIndexChanged( d->mCurrentIndex ); |
516 d->currentIndexChanged( d->mCurrentIndex ); |
494 } |
517 } |
495 } |
518 } |
636 } |
665 } |
637 } |
666 } |
638 |
667 |
639 /*! |
668 /*! |
640 @beta |
669 @beta |
|
670 |
641 \property HbComboBox::editable |
671 \property HbComboBox::editable |
642 \brief Set editable the property of the combobox. |
672 |
643 True, Editable, user can type in the combobox to search for items from |
673 If \a editable is true then combobox will be editable else it will be |
644 the list of items. Shows the prediction. If user types a text which does not match |
674 non-editable. |
645 to any items in the model then slection is not changed. |
675 |
646 False, Non editable user canot enter text using keyboard. |
676 \sa isEditable |
647 */ |
677 */ |
648 void HbComboBox::setEditable( bool editable ) |
678 void HbComboBox::setEditable( bool editable ) |
649 { |
679 { |
650 Q_D( HbComboBox ); |
680 Q_D( HbComboBox ); |
651 d->setEditable( editable ); |
681 d->setEditable( editable ); |
652 setProperty("state", "normal"); |
682 if (!editable ) { |
653 } |
683 setProperty( "state", "normal" ); |
654 |
684 } |
655 /*! |
685 } |
656 @beta |
686 |
657 Returns whether or not the combobox is editable |
687 /*! |
658 True if editable, else false |
688 @beta |
|
689 |
|
690 Returns combobox is editable or not. If editable then returns true else returns |
|
691 false. |
|
692 |
|
693 \sa setEditable |
659 */ |
694 */ |
660 bool HbComboBox::isEditable( ) const |
695 bool HbComboBox::isEditable( ) const |
661 { |
696 { |
662 Q_D( const HbComboBox ); |
697 Q_D( const HbComboBox ); |
663 return d->mEditable; |
698 return d->mEditable; |
664 } |
699 } |
665 |
700 |
666 /*! |
701 /*! |
667 @beta |
702 @beta |
668 Adds an item to the combobox with the given text, |
703 |
669 and containing the specified userData (stored in the Qt::UserRole). |
704 Adds an item in combobox with the given \a text, containing the specified \a userData |
|
705 (stored in the Qt::UserRole). The item is appended to the list of existing items. |
|
706 |
|
707 \sa insertItem |
|
708 */ |
|
709 void HbComboBox::addItem( const QString &text, const QVariant &userData ) |
|
710 { |
|
711 insertItem( count( ), text, userData ); |
|
712 } |
|
713 |
|
714 /*! |
|
715 @beta |
|
716 |
|
717 Adds an item in combobox with the given \a icon and \a text, |
|
718 and containing the specified \a userData (stored in the Qt::UserRole). |
670 The item is appended to the list of existing items. |
719 The item is appended to the list of existing items. |
671 */ |
720 |
672 void HbComboBox::addItem( const QString &text, const QVariant &userData) |
721 \sa insertItem |
673 { |
|
674 insertItem( count( ), text, userData ); |
|
675 } |
|
676 |
|
677 /*! |
|
678 @beta |
|
679 Adds an item to the combobox with the given icon and text, |
|
680 and containing the specified userData (stored in the Qt::UserRole). |
|
681 The item is appended to the list of existing items. |
|
682 */ |
722 */ |
683 void HbComboBox::addItem( const HbIcon &icon, const QString &text, const QVariant &userData ) |
723 void HbComboBox::addItem( const HbIcon &icon, const QString &text, const QVariant &userData ) |
684 { |
724 { |
685 insertItem( count( ), icon, text, userData ); |
725 insertItem( count( ), icon, text, userData ); |
686 } |
726 } |
687 |
727 |
688 /*! |
728 /*! |
689 @beta |
729 @beta |
690 Adds each of the strings in the given texts to the combobox. |
730 |
|
731 Adds each of the strings in the given \a texts to combobox. |
691 Each item is appended to the list of existing items in turn. |
732 Each item is appended to the list of existing items in turn. |
|
733 |
|
734 \sa insertItem |
692 */ |
735 */ |
693 void HbComboBox::addItems( const QStringList &texts ) |
736 void HbComboBox::addItems( const QStringList &texts ) |
694 { |
737 { |
695 insertItems( count(), texts ); |
738 insertItems( count( ), texts ); |
696 } |
739 } |
697 |
740 |
698 |
741 |
699 /*! |
742 /*! |
700 @beta |
743 @beta |
701 Inserts the text into the combobox at the given index. |
744 |
|
745 Inserts the \a text in combobox at the given \a index. |
702 If the index is equal to or higher than the total number of items, |
746 If the index is equal to or higher than the total number of items, |
703 the new item is appended to the list of existing items. |
747 the new item is appended to the list of existing items. |
704 If the index is zero or negative, the new item is prepended to the list of existing items. |
748 If the index is zero or negative, the new item is prepended to the list of existing items. |
|
749 |
|
750 \sa addItems addItem |
705 */ |
751 */ |
706 void HbComboBox::insertItem( int index, const QString &text, const QVariant &userData ) |
752 void HbComboBox::insertItem( int index, const QString &text, const QVariant &userData ) |
707 { |
753 { |
708 Q_D( HbComboBox ); |
754 Q_D( HbComboBox ); |
709 if( text.isNull( ) ){ |
755 if( text.isNull( ) ) { |
710 return; |
756 return; |
711 } |
757 } |
712 if( !d->mModel ) { |
758 if( !d->mModel ) { |
713 QStandardItemModel* model = new QStandardItemModel(this ); |
759 QStandardItemModel* model = new QStandardItemModel( this ); |
714 setModel( model ); |
760 setModel( model ); |
715 } |
761 } |
716 if ( !d->mModel->rowCount( ) ) { |
762 if ( !d->mModel->rowCount( ) ) { |
717 d->mModel->insertRow( 0 ); |
763 d->mModel->insertRow( 0 ); |
718 d->mModel->insertColumn( 0 ); |
764 d->mModel->insertColumn( 0 ); |
719 if( d->mModel->index( 0, 0 ).isValid( ) ) { |
765 if( d->mModel->index( 0, 0 ).isValid( ) ) { |
720 d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole ); |
766 d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole ); |
721 if( userData.isValid( ) ) { |
767 if( userData.isValid( ) ) { |
731 if( userData.isValid( ) ) { |
777 if( userData.isValid( ) ) { |
732 d->mModel->setData( d->mModel->index( rowCount, 0 ), userData, Qt::UserRole ); |
778 d->mModel->setData( d->mModel->index( rowCount, 0 ), userData, Qt::UserRole ); |
733 } |
779 } |
734 } else if(index <= 0) { |
780 } else if(index <= 0) { |
735 d->mModel->insertRow( 0 ); |
781 d->mModel->insertRow( 0 ); |
736 d->mModel->setData( d->mModel->index(0,0), text, Qt::DisplayRole ); |
782 d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole ); |
737 if( userData.isValid( ) ) { |
783 if( userData.isValid( ) ) { |
738 d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole ); |
784 d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole ); |
739 } |
785 } |
740 if( d->mCurrentIndex.row() >= 0 ) { |
786 if( d->mCurrentIndex.row( ) >= 0 ) { |
741 d->mCurrentIndex = d->mModel->index(d->mCurrentIndex.row()+1, 0); |
787 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0); |
742 d->currentIndexChanged(d->mCurrentIndex); |
788 d->currentIndexChanged( d->mCurrentIndex ); |
743 } |
789 } |
744 } else { |
790 } else { |
745 d->mModel->insertRow( index ); |
791 d->mModel->insertRow( index ); |
746 d->mModel->setData( d->mModel->index( index, 0 ), text, Qt::DisplayRole ); |
792 d->mModel->setData( d->mModel->index( index, 0 ), text, Qt::DisplayRole ); |
747 if( userData.isValid( ) ) { |
793 if( userData.isValid( ) ) { |
748 d->mModel->setData( d->mModel->index( index, 0 ), userData, Qt::UserRole ); |
794 d->mModel->setData( d->mModel->index( index, 0 ), userData, Qt::UserRole ); |
749 } |
795 } |
750 if( d->mCurrentIndex.row() <= index ) { |
796 if( d->mCurrentIndex.row( ) >= index ) { |
751 d->mCurrentIndex = d->mModel->index(d->mCurrentIndex.row()+1, 0); |
797 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0); |
752 d->currentIndexChanged(d->mCurrentIndex); |
798 d->currentIndexChanged( d->mCurrentIndex ); |
753 } |
799 } |
754 } |
800 } |
755 } |
801 } |
756 } |
802 } |
757 |
803 |
758 /*! |
804 /*! |
759 @beta |
805 @beta |
760 Inserts the text and icon into the combobox at the given index. |
806 |
|
807 Inserts the \a text and \a icon into the combobox at the given \a index. |
761 If the index is equal to or higher than the total number of items, |
808 If the index is equal to or higher than the total number of items, |
762 the new item is appended to the list of existing items. |
809 the new item is appended to the list of existing items. |
763 If the index is zero or negative, the new item is prepended to the list of existing items. |
810 If the index is zero or negative, the new item is prepended to the list of existing items. |
764 */ |
811 |
765 void HbComboBox::insertItem( int index, const HbIcon &icon, const QString &text, const QVariant &userData) |
812 \sa insertItem |
766 { |
813 */ |
767 Q_D( HbComboBox ); |
814 void HbComboBox::insertItem( int index, const HbIcon &icon, |
768 if( text.isEmpty( ) ){ |
815 const QString &text, const QVariant &userData ) |
|
816 { |
|
817 Q_D( HbComboBox ); |
|
818 if( text.isEmpty( ) ) { |
769 return; |
819 return; |
770 } |
820 } |
771 |
821 |
772 if( !d->mModel ) { |
822 if( !d->mModel ) { |
773 QStandardItemModel* model = new QStandardItemModel( this ); |
823 QStandardItemModel* model = new QStandardItemModel( this ); |
774 setModel( model ); |
824 setModel( model ); |
775 } |
825 } |
776 if ( !d->mModel->rowCount( ) ) { |
826 if ( !d->mModel->rowCount( ) ) { |
777 d->mModel->insertRow( 0 ); |
827 d->mModel->insertRow( 0 ); |
778 d->mModel->insertColumn( 0 ); |
828 d->mModel->insertColumn( 0 ); |
779 if( d->mModel->index( 0, 0 ).isValid( ) ) { |
829 if( d->mModel->index( 0, 0 ).isValid( ) ) { |
780 d->mModel->setData( d->mModel->index(0,0), text, Qt::DisplayRole ); |
830 d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole ); |
781 setCurrentIndex( 0 ); |
831 setCurrentIndex( 0 ); |
782 } |
832 } |
783 if(!icon.isNull() && d->mModel->index( 0, 0 ).isValid( ) ) { |
833 if( !icon.isNull( ) && d->mModel->index( 0, 0 ).isValid( ) ) { |
784 d->mModel->setData(d->mModel->index( 0, 0 ), icon.qicon( ), Qt::DecorationRole); |
834 d->mModel->setData( d->mModel->index( 0, 0 ), icon.qicon( ), Qt::DecorationRole ); |
785 } |
835 } |
786 if( userData.isValid( ) && d->mModel->index( 0, 0 ).isValid( ) ) { |
836 if( userData.isValid( ) && d->mModel->index( 0, 0 ).isValid( ) ) { |
787 d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole ); |
837 d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole ); |
788 } |
838 } |
789 } else { |
839 } else { |
790 int rowCount = d->mModel->rowCount( ); |
840 int rowCount = d->mModel->rowCount( ); |
791 if( index >= rowCount ) { |
841 if( index >= rowCount ) { |
792 d->mModel->insertRow( rowCount ); |
842 d->mModel->insertRow( rowCount ); |
793 d->mModel->setData( d->mModel->index( rowCount, 0 ), text, Qt::DisplayRole ); |
843 d->mModel->setData( d->mModel->index( rowCount, 0 ), text, Qt::DisplayRole ); |
794 if(!icon.isNull()) { |
844 if( !icon.isNull( ) ) { |
795 d->mModel->setData( d->mModel->index( rowCount, 0 ), icon, Qt::DecorationRole ); |
845 d->mModel->setData( d->mModel->index( rowCount, 0 ), icon, Qt::DecorationRole ); |
796 } |
846 } |
797 if( userData.isValid( ) ) { |
847 if( userData.isValid( ) ) { |
798 d->mModel->setData( d->mModel->index( rowCount, 0 ), userData, Qt::UserRole ); |
848 d->mModel->setData( d->mModel->index( rowCount, 0 ), userData, Qt::UserRole ); |
799 } |
849 } |
800 if( d->mCurrentIndex.row() == index ) { |
850 if( d->mCurrentIndex.row( ) == index ) { |
801 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 ); |
851 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 ); |
802 d->currentIndexChanged( d->mCurrentIndex ); |
852 d->currentIndexChanged( d->mCurrentIndex ); |
803 } |
853 } |
804 } else if(index <= 0) { |
854 } else if( index <= 0 ) { |
805 d->mModel->insertRow( 0 ); |
855 d->mModel->insertRow( 0 ); |
806 d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole ); |
856 d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole ); |
807 if(!icon.isNull()) { |
857 if( !icon.isNull( ) ) { |
808 d->mModel->setData(d->mModel->index( 0, 0 ), icon, Qt::DecorationRole); |
858 d->mModel->setData( d->mModel->index( 0, 0 ), icon, Qt::DecorationRole ); |
809 } |
859 } |
810 if( userData.isValid( ) ) { |
860 if( userData.isValid( ) ) { |
811 d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole ); |
861 d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole ); |
812 } |
862 } |
813 if( d->mCurrentIndex.row() >= 0 ) { |
863 if( d->mCurrentIndex.row( ) >= 0 ) { |
814 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0); |
864 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 ); |
815 d->currentIndexChanged( d->mCurrentIndex ); |
865 d->currentIndexChanged( d->mCurrentIndex ); |
816 } |
866 } |
817 } else { |
867 } else { |
818 d->mModel->insertRow( index ); |
868 d->mModel->insertRow( index ); |
819 d->mModel->setData( d->mModel->index( index, 0 ), text, Qt::DisplayRole ); |
869 d->mModel->setData( d->mModel->index( index, 0 ), text, Qt::DisplayRole ); |
820 if(!icon.isNull( ) ) { |
870 if( !icon.isNull( ) ) { |
821 d->mModel->setData( d->mModel->index( index, 0 ), icon, Qt::DecorationRole ); |
871 d->mModel->setData( d->mModel->index( index, 0 ), icon, Qt::DecorationRole ); |
822 } |
872 } |
823 if( userData.isValid( ) ) { |
873 if( userData.isValid( ) ) { |
824 d->mModel->setData( d->mModel->index( index, 0 ), userData, Qt::UserRole ); |
874 d->mModel->setData( d->mModel->index( index, 0 ), userData, Qt::UserRole ); |
825 } |
875 } |
826 if( d->mCurrentIndex.row() <= index ) { |
876 if( d->mCurrentIndex.row( ) <= index ) { |
827 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0); |
877 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 ); |
828 d->currentIndexChanged( d->mCurrentIndex ); |
878 d->currentIndexChanged( d->mCurrentIndex ); |
829 } |
879 } |
830 } |
880 } |
831 } |
881 } |
832 } |
882 } |
833 |
883 |
834 /*! |
884 /*! |
835 @beta |
885 @beta |
836 Inserts the strings from the list into the combobox as separate items, starting at the index. |
886 |
|
887 Inserts the strings in \a texts into combobox as separate items, starting at the given \a index. |
837 If the index is equal to or higher than the total number of items, |
888 If the index is equal to or higher than the total number of items, |
838 the new item is appended to the list of existing items. |
889 the new item is appended to the list of existing items. |
839 If the index is zero or negative, the new item is prepended to the list of existing items. |
890 If the index is zero or negative, the new item is prepended to the list of existing items. |
840 */ |
891 */ |
841 void HbComboBox::insertItems( int index, const QStringList &texts ) |
892 void HbComboBox::insertItems( int index, const QStringList &texts ) |
845 QStandardItemModel* model = new QStandardItemModel( this ); |
896 QStandardItemModel* model = new QStandardItemModel( this ); |
846 setModel( model ); |
897 setModel( model ); |
847 } |
898 } |
848 if ( !d->mModel->rowCount( ) ) { |
899 if ( !d->mModel->rowCount( ) ) { |
849 int textCount = texts.count( ); |
900 int textCount = texts.count( ); |
850 for( int i = 0; i < textCount; i++) |
901 for( int i = 0; i < textCount; i++) { |
851 { |
|
852 d->mModel->insertRow( i ); |
902 d->mModel->insertRow( i ); |
853 if( i == 0) |
903 if( i == 0) { |
854 d->mModel->insertColumn( 0 ); |
904 d->mModel->insertColumn( 0 ); |
|
905 } |
855 if( d->mModel->index( i, 0 ).isValid( ) ) { |
906 if( d->mModel->index( i, 0 ).isValid( ) ) { |
856 d->mModel->setData( d->mModel->index( i, 0 ), texts.at( i ), Qt::DisplayRole ); |
907 d->mModel->setData( d->mModel->index( i, 0 ), texts.at( i ), Qt::DisplayRole ); |
857 if( i == 0) { |
908 if( i == 0) { |
858 setCurrentIndex( 0 ); |
909 setCurrentIndex( 0 ); |
859 } |
910 } |
860 } |
911 } |
861 } |
912 } |
862 } else { |
913 } else { |
863 int rowCount = -1; |
914 int rowCount = -1; |
864 rowCount = d->mModel->rowCount( ); |
915 rowCount = d->mModel->rowCount( ); |
865 int textCount = texts.count( ); |
916 int textCount = texts.count( ); |
866 if ( index >= rowCount ) { |
917 if ( index >= rowCount ) { |
867 d->mModel->insertRows( rowCount, textCount ); |
918 d->mModel->insertRows( rowCount, textCount ); |
868 int temp = 0; |
919 int temp = 0; |
869 for ( int i = rowCount; i < ( rowCount + textCount ); i++ ) { |
920 for ( int i = rowCount; i < ( rowCount + textCount ); i++ ) { |
870 d->mModel->setData ( d->mModel->index( i, 0 ), texts.at( temp++ ) ); |
921 d->mModel->setData ( d->mModel->index( i, 0 ), texts.at( temp++ ) ); |
871 } |
922 } |
872 if( d->mCurrentIndex.row() == index ) { |
923 if( d->mCurrentIndex.row( ) == index ) { |
873 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + textCount, 0); |
924 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + textCount, 0 ); |
874 d->currentIndexChanged( d->mCurrentIndex ); |
925 d->currentIndexChanged( d->mCurrentIndex ); |
875 } |
926 } |
876 } else if( index <= 0 ) { |
927 } else if( index <= 0 ) { |
877 d->mModel->insertRows( 0, textCount ); |
928 d->mModel->insertRows( 0, textCount ); |
878 for ( int i = 0; i < textCount; i++ ) { |
929 for ( int i = 0; i < textCount; i++ ) { |
879 d->mModel->setData( d->mModel->index( i, 0 ), texts.at( i ) ); |
930 d->mModel->setData( d->mModel->index( i, 0 ), texts.at( i ) ); |
880 } |
931 } |
881 if( d->mCurrentIndex.row() >= 0 ) { |
932 if( d->mCurrentIndex.row( ) >= 0 ) { |
882 d->mCurrentIndex = d->mModel->index(d->mCurrentIndex.row() + textCount, 0); |
933 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + textCount, 0 ); |
883 d->currentIndexChanged( d->mCurrentIndex ); |
934 d->currentIndexChanged( d->mCurrentIndex ); |
884 } |
935 } |
885 } else { |
936 } else { |
886 d->mModel->insertRows( index, texts.count( ) ); |
937 d->mModel->insertRows( index, texts.count( ) ); |
887 int temp = 0; |
938 int temp = 0; |
888 for ( int i = index; i < ( textCount + index ); i++ ) { |
939 for ( int i = index; i < ( textCount + index ); i++ ) { |
889 d->mModel->setData( d->mModel->index( i, 0 ), texts.at( temp++ ) ); |
940 d->mModel->setData( d->mModel->index( i, 0 ), texts.at( temp++ ) ); |
890 } |
941 } |
891 if( d->mCurrentIndex.row() <= index ) { |
942 if( d->mCurrentIndex.row( ) <= index ) { |
892 d->mCurrentIndex = d->mModel->index(d->mCurrentIndex.row() + textCount, 0); |
943 d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + textCount, 0 ); |
893 d->currentIndexChanged( d->mCurrentIndex ); |
944 d->currentIndexChanged( d->mCurrentIndex ); |
894 } |
945 } |
895 } |
946 } |
896 } |
947 } |
897 } |
948 } |
898 |
949 |
899 /*! |
950 /*! |
900 @beta |
951 @beta |
901 Returns the text for the given index in the combobox. |
952 |
|
953 Returns text at given \a index in combobox. |
|
954 |
|
955 \sa setItemText |
902 */ |
956 */ |
903 QString HbComboBox::itemText( int index ) const |
957 QString HbComboBox::itemText( int index ) const |
904 { |
958 { |
905 Q_D( const HbComboBox ); |
959 Q_D( const HbComboBox ); |
906 if(d->mModel) { |
960 if( d->mModel ) { |
907 QModelIndex mi = d->mModel->index( index, 0 ); |
961 QModelIndex mi = d->mModel->index( index, 0 ); |
908 if( mi.isValid() ) { |
962 if( mi.isValid( ) ) { |
909 return d->itemText( mi ); |
963 return d->itemText( mi ); |
910 } |
964 } |
911 } |
965 } |
912 return QString( ); |
966 return QString( ); |
913 } |
967 } |
914 |
968 |
915 /*! |
969 /*! |
916 @beta |
970 @beta |
917 Sets the text for the item on the given index in the combobox. |
971 |
|
972 Sets the \a text for item at given \a index in combobox. |
|
973 |
|
974 \sa itemText |
918 */ |
975 */ |
919 void HbComboBox::setItemText( int index, const QString &text ) |
976 void HbComboBox::setItemText( int index, const QString &text ) |
920 { |
977 { |
921 Q_D( HbComboBox ); |
978 Q_D( HbComboBox ); |
922 if (d->mModel) { |
979 if ( d->mModel ) { |
923 QModelIndex item = d->mModel->index( index, 0 ); |
980 QModelIndex item = d->mModel->index( index, 0 ); |
924 if ( item.isValid( ) ) { |
981 if ( item.isValid( ) ) { |
925 if(d->mModel->setData( item, text, Qt::EditRole )) { |
982 if( d->mModel->setData( item, text, Qt::EditRole ) ) { |
926 if(d->mCurrentIndex.row() == index) { |
983 if( d->mCurrentIndex.row( ) == index ) { |
927 if( d->mLineEdit ) { |
984 if( d->mLineEdit ) { |
928 d->mLineEdit->setText( text ); |
985 d->mLineEdit->setText( text ); |
929 } else { |
986 } else { |
930 d->mText = text ; |
987 d->mText = text ; |
931 HbStyleOptionComboBox comboBoxOption; |
988 HbStyleOptionComboBox comboBoxOption; |
932 initStyleOption(&comboBoxOption); |
989 initStyleOption( &comboBoxOption ); |
933 style()->updatePrimitive( d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption); |
990 style( )->updatePrimitive( |
|
991 d->mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption ); |
934 } |
992 } |
935 } |
993 } |
936 } |
994 } |
937 |
995 } |
938 } |
996 } |
939 } |
997 } |
|
998 |
|
999 bool HbComboBox::eventFilter( QObject *obj, QEvent *event ) |
|
1000 { |
|
1001 return HbWidget::eventFilter(obj,event); |
940 } |
1002 } |
941 |
1003 |
942 /*! |
1004 /*! |
943 reimplementation. |
1005 reimplementation. |
944 */ |
1006 */ |
945 bool HbComboBox::eventFilter( QObject* obj, QEvent* event ) |
1007 void HbComboBox::gestureEvent(QGestureEvent *event) |
946 { |
1008 { |
947 Q_D( HbComboBox ); |
1009 Q_D( HbComboBox ); |
948 bool accepted = false; |
1010 |
949 if ( !isEnabled() ) { |
1011 if (!isEnabled()) { |
950 return false ; |
1012 return; |
951 } |
1013 } |
952 if(obj == static_cast<HbTouchArea*>(d->mButtonTouchAreaItem)) { |
1014 if(event->gesture(Qt::TapGesture)) { |
953 if(event->type() == QEvent::Gesture ) { |
1015 HbTapGesture *tap = |
954 QGestureEvent *gestureEvent = static_cast<QGestureEvent *>( event ); |
1016 static_cast<HbTapGesture *>(event->gesture(Qt::TapGesture)); |
955 if(gestureEvent->gesture(Qt::TapGesture)) { |
1017 switch(tap->state()) { |
956 HbTapGesture *tap = static_cast<HbTapGesture *>(gestureEvent->gesture(Qt::TapGesture)); |
1018 case Qt::GestureStarted: { |
957 switch(tap->state()) { |
1019 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),Qt::TapGesture); |
958 case Qt::GestureStarted: |
1020 if (!tap->property(HbPrivate::ThresholdRect.latin1()).toRect().isValid()) { |
959 { |
1021 tap->setProperty(HbPrivate::ThresholdRect.latin1(), mapRectToScene(boundingRect()).toRect()); |
960 d->touchAreaPressEvent( ); |
|
961 accepted = true; |
|
962 break; |
|
963 } |
|
964 case Qt::GestureCanceled: |
|
965 { |
|
966 d->mIsDown = false; |
|
967 updatePrimitives(); |
|
968 setProperty("state", "normal"); |
|
969 accepted = true; |
|
970 break; |
|
971 } |
|
972 case Qt::GestureFinished: |
|
973 { |
|
974 d->touchAreaReleaseEvent( ); |
|
975 accepted = true; |
|
976 break; |
|
977 //TODO :: move else part here |
|
978 } |
|
979 default: |
|
980 break; |
|
981 } |
1022 } |
982 } |
1023 |
983 } |
1024 d->touchAreaPressEvent(); |
984 } |
1025 break; |
985 return accepted; |
1026 } |
|
1027 case Qt::GestureCanceled: { |
|
1028 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant()); |
|
1029 |
|
1030 d->mIsDown = false; |
|
1031 updatePrimitives(); |
|
1032 setProperty( "state", "normal" ); |
|
1033 break; |
|
1034 } |
|
1035 case Qt::GestureFinished: { |
|
1036 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant()); |
|
1037 |
|
1038 d->touchAreaReleaseEvent(); |
|
1039 break; |
|
1040 //TODO :: move else part here |
|
1041 } |
|
1042 default: |
|
1043 break; |
|
1044 } |
|
1045 } |
986 } |
1046 } |
987 |
1047 |
988 /*! |
1048 /*! |
989 \reimp |
1049 \reimp |
990 */ |
1050 */ |
|
1051 QVariant HbComboBox::itemChange( GraphicsItemChange change, const QVariant & value ) |
|
1052 { |
|
1053 Q_D( HbComboBox ); |
|
1054 switch( change ) { |
|
1055 case QGraphicsItem::ItemScenePositionHasChanged: |
|
1056 if( ( d->mDropDown ) && ( d->mDropDown->mList ) && ( d->mDropDown->isVisible( ) ) ) { |
|
1057 d->positionDropDown( ); |
|
1058 } |
|
1059 break; |
|
1060 default: |
|
1061 break; |
|
1062 } |
|
1063 return HbWidget::itemChange( change, value ); |
|
1064 } |
|
1065 |
|
1066 /*! |
|
1067 \reimp |
|
1068 */ |
991 void HbComboBox::changeEvent( QEvent *event ) |
1069 void HbComboBox::changeEvent( QEvent *event ) |
992 { |
1070 { |
993 switch ( event->type( ) ){ |
1071 switch ( event->type( ) ) { |
994 case QEvent::EnabledChange: |
1072 case QEvent::EnabledChange: |
995 updatePrimitives( ); |
1073 updatePrimitives( ); |
996 break; |
1074 break; |
997 default: |
1075 default: |
998 break; |
1076 break; |
999 } |
1077 } |
1000 HbWidget::changeEvent( event ); |
1078 HbWidget::changeEvent( event ); |
1001 } |
1079 } |
1002 |
1080 |
|
1081 |
1003 // End of file |
1082 // End of file |
1004 |
1083 |
1005 |
1084 |