97 |
102 |
98 void HbComboBoxPrivate::createPrimitives( ) |
103 void HbComboBoxPrivate::createPrimitives( ) |
99 { |
104 { |
100 Q_Q( HbComboBox ); |
105 Q_Q( HbComboBox ); |
101 |
106 |
102 mTextItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_text, q ); |
107 mTextItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_text, q ); |
103 HbStyle::setItemName( mTextItem, "combobox_labelfield" ); |
108 HbStyle::setItemName( mTextItem, "combobox_labelfield" ); |
104 |
109 |
105 mBackgroundItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_background, q ); |
110 mBackgroundItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_background, q ); |
106 HbStyle::setItemName( mBackgroundItem, "text_background" ); |
111 HbStyle::setItemName( mBackgroundItem, "text_background" ); |
107 |
112 |
108 mButton = q->style( )->createPrimitive( HbStyle::P_ComboBox_button, q ); |
113 mButton = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_button, q ); |
109 HbStyle::setItemName( mButton, "combobox_button" ); |
114 HbStyle::setItemName( mButton, "combobox_button" ); |
110 |
115 |
111 mButtonTouchAreaItem = q->style( )->createPrimitive( HbStyle::P_ComboBoxButton_toucharea, q ); |
116 mButtonTouchAreaItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBoxButton_toucharea, q ); |
112 |
117 |
113 static_cast<HbTouchArea*>( mButtonTouchAreaItem )->grabGesture( Qt::TapGesture ); |
118 static_cast<HbTouchArea*>( mButtonTouchAreaItem )->grabGesture( Qt::TapGesture ); |
114 } |
119 } |
115 |
120 |
116 void HbComboBoxPrivate::touchAreaPressEvent( ) |
121 void HbComboBoxPrivate::touchAreaPressEvent( ) |
247 QAbstractItemModel *model = mDropDown->mList->model( ); |
285 QAbstractItemModel *model = mDropDown->mList->model( ); |
248 calculateListItemHeight( ); |
286 calculateListItemHeight( ); |
249 qreal totalHeightRequd = model->rowCount( ) * mListItemHeight; |
287 qreal totalHeightRequd = model->rowCount( ) * mListItemHeight; |
250 qreal maxPopupHeight = 0.0; |
288 qreal maxPopupHeight = 0.0; |
251 |
289 |
252 //read the maximum rows in drop down for different orientation from css |
290 //calculate the maximum popup height for different orientation |
253 if( q->mainWindow( )->orientation( ) == Qt::Horizontal ) { |
291 if( q->mainWindow( )->orientation( ) == Qt::Horizontal ) { |
254 if( mDropDownRowsInLandscape == -1 ) { |
|
255 HbStyleParameters params; |
|
256 q->style( )->parameters( params ); |
|
257 params.addParameter( "max-rows-in-dropdown" ); |
|
258 q->polish( params ); |
|
259 mDropDownRowsInLandscape = params.value( "max-rows-in-dropdown" ).toInt( ); |
|
260 } |
|
261 maxPopupHeight = mDropDownRowsInLandscape * mListItemHeight; |
292 maxPopupHeight = mDropDownRowsInLandscape * mListItemHeight; |
262 } else if( q->mainWindow( )->orientation( ) == Qt::Vertical ) { |
293 } else if( q->mainWindow( )->orientation( ) == Qt::Vertical ) { |
263 if( mDropDownRowsInPortrait == -1 ) { |
|
264 HbStyleParameters params; |
|
265 q->style( )->parameters( params ); |
|
266 params.addParameter( "max-rows-in-dropdown" ); |
|
267 q->polish( params ); |
|
268 mDropDownRowsInPortrait = params.value( "max-rows-in-dropdown" ).toInt( ); |
|
269 } |
|
270 maxPopupHeight = mDropDownRowsInPortrait * mListItemHeight; |
294 maxPopupHeight = mDropDownRowsInPortrait * mListItemHeight; |
271 } |
295 } |
272 |
296 |
273 if ( totalHeightRequd < maxPopupHeight ) { |
297 if ( totalHeightRequd < maxPopupHeight ) { |
274 maxPopupHeight = totalHeightRequd; |
298 maxPopupHeight = totalHeightRequd; |
275 } |
299 } |
276 QSizeF popupSize = QSizeF( q->rect( ).width( ), maxPopupHeight ); |
300 QSizeF popupSize = QSizeF( q->rect( ).width( ), maxPopupHeight ); |
277 QPointF popupPos; |
301 QPointF popupPos; |
278 if( !mDropDown->vkbOpened ) { |
302 |
|
303 HbEditorInterface editorInterface( q ); |
|
304 HbVkbHost *host = editorInterface.vkbHost( ); |
|
305 |
|
306 if( host && ( host->keypadStatus( ) == HbVkbHost::HbVkbStatusOpened ) ) { |
|
307 // case when vkb is visible |
|
308 // positioning drop down when vkb is positioned |
|
309 // drop down will come on top/below of combo based upon which side has more space |
|
310 // available |
|
311 QSizeF keyBoardArea = host->keyboardArea( ); |
|
312 QSize screenSize = HbDeviceProfile::profile( q ).logicalSize( ); |
|
313 |
|
314 qreal heightDifference = screenSize.height( ) - keyBoardArea.height( ); |
|
315 qreal topSpace = widgetPos.y( ); |
|
316 qreal bottomSpace = heightDifference - topSpace - q->boundingRect( ).height( ); |
|
317 |
|
318 if( topSpace > bottomSpace ) { |
|
319 //display drop down at top |
|
320 if( widgetPos.y( ) - maxPopupHeight > 0.0 ) { |
|
321 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight ); |
|
322 } else { |
|
323 popupPos = QPointF( widgetPos.x( ), 0.0 ); |
|
324 popupSize.setHeight( topSpace ); |
|
325 } |
|
326 #ifdef HB_EFFECTS |
|
327 if ( !mHasUpEffect ) { |
|
328 mHasUpEffect = true; |
|
329 mHasDownEffect = false; |
|
330 //this Effect will be shown when there is more space in the view bottom. |
|
331 HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); |
|
332 HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); |
|
333 } |
|
334 #endif |
|
335 } else { |
|
336 //display drop down at bottom |
|
337 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) ); |
|
338 if( bottomSpace < maxPopupHeight ) { |
|
339 popupSize.setHeight( bottomSpace ); |
|
340 } |
|
341 #ifdef HB_EFFECTS |
|
342 if ( !mHasDownEffect ) { |
|
343 mHasDownEffect = true; |
|
344 mHasUpEffect = false; |
|
345 //this Effect will be shown when there is more space in the view bottom. |
|
346 HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" ); |
|
347 HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" ); |
|
348 } |
|
349 #endif |
|
350 } |
|
351 } else { |
|
352 //this is the case when vkb is not visible |
|
353 |
279 //position of drop down in both editable and non-editable combobox depends upon |
354 //position of drop down in both editable and non-editable combobox depends upon |
280 //the available space above and below combobox |
355 //the available space above and below combobox |
281 if( ( widgetPos.y( ) + q->rect( ).height( ) + maxPopupHeight) < sceneRect.height( ) ) { |
356 if( ( widgetPos.y( ) + q->rect( ).height( ) + maxPopupHeight) < sceneRect.height( ) ) { |
282 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) ); |
357 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) ); |
283 #ifdef HB_EFFECTS |
358 #ifdef HB_EFFECTS |
284 if ( !mHasDownEffect ) { |
359 if ( !mHasDownEffect ) { |
285 mHasDownEffect = true; |
360 mHasDownEffect = true; |
286 mHasUpEffect = false; |
361 mHasUpEffect = false; |
287 // this is temporary until proper effect theming comes. |
|
288 //this Effect will be shown when there is space in the view bottom. |
362 //this Effect will be shown when there is space in the view bottom. |
289 HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" ); |
363 HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" ); |
290 HbEffectInternal::add( mDropDown, "combo_disappear_downl", "disappear" ); |
364 HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" ); |
291 } |
365 } |
292 #endif |
366 #endif |
293 } else if( widgetPos.y( ) - maxPopupHeight > 0.0 ) { |
367 } else if( widgetPos.y( ) - maxPopupHeight > 0.0 ) { |
294 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight ); |
368 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight ); |
295 #ifdef HB_EFFECTS |
369 #ifdef HB_EFFECTS |
296 if ( !mHasUpEffect ) { |
370 if ( !mHasUpEffect ) { |
297 // this is temporary until proper effect theming comes. |
|
298 //this Effect will be shown when there is no space in the view bottom |
371 //this Effect will be shown when there is no space in the view bottom |
299 mHasUpEffect = true; |
372 mHasUpEffect = true; |
300 mHasDownEffect = false; |
373 mHasDownEffect = false; |
301 HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); |
374 HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); |
302 HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); |
375 HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); |
320 popupPos = QPointF( widgetPos.x( ), sceneRect.height( ) - maxPopupHeight ); |
392 popupPos = QPointF( widgetPos.x( ), sceneRect.height( ) - maxPopupHeight ); |
321 #ifdef HB_EFFECTS |
393 #ifdef HB_EFFECTS |
322 if ( !mHasUpEffect ) { |
394 if ( !mHasUpEffect ) { |
323 mHasUpEffect = true; |
395 mHasUpEffect = true; |
324 mHasDownEffect = false; |
396 mHasDownEffect = false; |
325 // this is temporary until proper effect theming comes. |
|
326 //this Effect will be shown when there is more space in the view bottom. |
397 //this Effect will be shown when there is more space in the view bottom. |
327 HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); |
398 HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); |
328 HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); |
399 HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); |
329 } |
|
330 #endif |
|
331 } |
|
332 } |
|
333 } else { |
|
334 // positioning drop down when vkb is positioned |
|
335 // drop down will come on top/below of combo based upon which side has more space |
|
336 // available |
|
337 HbEditorInterface editorInterface( q ); |
|
338 HbVkbHost *host = editorInterface.vkbHost( ); |
|
339 if ( host ) { |
|
340 QSizeF keyBoardArea = host->keyboardArea( ); |
|
341 QSize screenSize = HbDeviceProfile::profile( q ).logicalSize( ); |
|
342 |
|
343 qreal heightDifference = screenSize.height( ) - keyBoardArea.height( ); |
|
344 qreal topSpace = widgetPos.y( ); |
|
345 qreal bottomSpace = heightDifference - topSpace - q->boundingRect( ).height( ); |
|
346 |
|
347 if( topSpace > bottomSpace ) { |
|
348 //display drop down at top |
|
349 if( widgetPos.y( ) - maxPopupHeight > 0.0 ) { |
|
350 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight ); |
|
351 } else { |
|
352 popupPos = QPointF( widgetPos.x( ), 0.0 ); |
|
353 popupSize.setHeight( topSpace ); |
|
354 } |
|
355 #ifdef HB_EFFECTS |
|
356 if ( !mHasUpEffect ) { |
|
357 mHasUpEffect = true; |
|
358 mHasDownEffect = false; |
|
359 // this is temporary until proper effect theming comes. |
|
360 //this Effect will be shown when there is more space in the view bottom. |
|
361 HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); |
|
362 HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); |
|
363 } |
|
364 #endif |
|
365 } else { |
|
366 //display drop down at bottom |
|
367 popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) ); |
|
368 if( bottomSpace < maxPopupHeight ) { |
|
369 popupSize.setHeight( bottomSpace ); |
|
370 } |
|
371 #ifdef HB_EFFECTS |
|
372 if ( !mHasDownEffect ) { |
|
373 mHasDownEffect = true; |
|
374 mHasUpEffect = false; |
|
375 // this is temporary until proper effect theming comes. |
|
376 //this Effect will be shown when there is more space in the view bottom. |
|
377 HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" ); |
|
378 HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" ); |
|
379 } |
400 } |
380 #endif |
401 #endif |
381 } |
402 } |
382 } |
403 } |
383 } |
404 } |
520 mLineEdit->backgroundItem( )->setVisible( false ); |
550 mLineEdit->backgroundItem( )->setVisible( false ); |
521 } |
551 } |
522 q->setHandlesChildEvents( false ); |
552 q->setHandlesChildEvents( false ); |
523 mLineEdit->setReadOnly( false ); |
553 mLineEdit->setReadOnly( false ); |
524 mLineEdit->setCursorVisibility( Hb::TextCursorVisible ); |
554 mLineEdit->setCursorVisibility( Hb::TextCursorVisible ); |
525 mLineEdit->setLongPressEnabled( ); |
|
526 q->repolish( ); |
555 q->repolish( ); |
527 q->connect( mLineEdit, SIGNAL( textChanged ( QString ) ), |
556 q->connect( mLineEdit, SIGNAL( textChanged ( QString ) ), |
528 q, SLOT( _q_textChanged( QString ) ) ); |
557 q, SLOT( _q_textChanged( QString ) ) ); |
529 setCompletion( true ); |
558 setCompletion( true ); |
530 } else { |
559 } else { |
531 q->disconnect( mLineEdit, SIGNAL( textChanged ( QString ) ), |
560 q->disconnect( mLineEdit, SIGNAL( textChanged ( QString ) ), |
532 q, SLOT( _q_textChanged( QString ) ) ); |
561 q, SLOT( _q_textChanged( QString ) ) ); |
533 q->setHandlesChildEvents( true ); |
562 q->setHandlesChildEvents( true ); |
534 mLineEdit->setReadOnly( true ); |
563 mLineEdit->setReadOnly( true ); |
535 mLineEdit->setLongPressEnabled( false ); |
|
536 setCompletion( false ); |
564 setCompletion( false ); |
537 mLineEdit->setCursorVisibility( Hb::TextCursorHidden ); |
565 mLineEdit->setCursorVisibility( Hb::TextCursorHidden ); |
538 if( mModel && mModel->rowCount( ) ) { |
566 if( mModel && mModel->rowCount( ) ) { |
539 QModelIndex mi = mModel->index( 0, 0 ); |
567 QModelIndex mi = mModel->index( 0, 0 ); |
540 if( mi.isValid( ) ) { |
568 if( mi.isValid( ) ) { |