104 mGroupBoxType = type; |
106 mGroupBoxType = type; |
105 |
107 |
106 // set the type and makes necesary primitive creation/deletion |
108 // set the type and makes necesary primitive creation/deletion |
107 switch(mGroupBoxType) { |
109 switch(mGroupBoxType) { |
108 case GroupBoxSimpleLabel: |
110 case GroupBoxSimpleLabel: |
109 { |
111 { |
110 if(mHeadingWidget){ |
112 mHeadingWidget->setType(type); |
111 mHeadingWidget->setType(type); |
|
112 mHeadingWidget->setVisible(true); |
|
113 |
|
114 }else{ |
|
115 createHeadingWidget(); |
|
116 } |
|
117 |
|
118 if(mContentWidget){ |
|
119 mContentWidget->setVisible(false); |
|
120 HbStyle::setItemName( mContentWidget , ""); |
|
121 } |
|
122 |
|
123 } |
113 } |
124 break; |
114 break; |
125 case GroupBoxRichLabel: |
115 case GroupBoxRichLabel: |
126 { |
116 { |
127 if(mHeadingWidget){ |
|
128 mHeadingWidget->setVisible(false); |
|
129 |
|
130 } |
|
131 if(mContentWidget){ |
|
132 mContentWidget->setType(type); |
117 mContentWidget->setType(type); |
133 mContentWidget->setVisible(true); |
|
134 HbStyle::setItemName( mContentWidget , "contentwidget"); |
118 HbStyle::setItemName( mContentWidget , "contentwidget"); |
135 }else{ |
|
136 createContentWidget(); |
|
137 } |
|
138 |
|
139 } |
119 } |
140 break; |
120 break; |
141 case GroupBoxCollapsingContainer: |
121 case GroupBoxCollapsingContainer: |
142 { |
122 { |
143 if((mHeadingWidget)){ |
|
144 mHeadingWidget->setType(type); |
123 mHeadingWidget->setType(type); |
145 mHeadingWidget->setVisible(true); |
|
146 }else{ |
|
147 createHeadingWidget(); |
|
148 } |
|
149 |
|
150 if(mContentWidget){ |
|
151 mContentWidget->setType(type); |
124 mContentWidget->setType(type); |
152 if(!q->isCollapsed()){ |
125 if(!q->isCollapsed()){ |
153 mContentWidget->setVisible(true); |
126 mContentWidget->setVisible(true); |
154 HbStyle::setItemName( mContentWidget , "contentwidget"); |
127 HbStyle::setItemName( mContentWidget , "contentwidget"); |
155 }else{ |
128 }else{ |
156 mContentWidget->setVisible(false); |
129 mContentWidget->setVisible(false); |
157 HbStyle::setItemName( mContentWidget , ""); |
130 HbStyle::setItemName( mContentWidget , ""); |
158 } |
131 } |
159 }else{ |
|
160 createContentWidget(); |
|
161 } |
|
162 } |
132 } |
163 break; |
133 break; |
164 default: |
134 default: |
165 break; |
135 break; |
166 } |
136 } |
305 @beta |
275 @beta |
306 |
276 |
307 Sets the groupbox heading |
277 Sets the groupbox heading |
308 |
278 |
309 Note: heading property is valid for simpleLabel & collapsing container type. |
279 Note: heading property is valid for simpleLabel & collapsing container type. |
|
280 In case of collapsing container, |
|
281 if empty heading is set on runtime Groupbox will change to RichLabel. |
310 For Collapsing container, |
282 For Collapsing container, |
311 if body content is collapsible ,heading will appear along with Disclosure indicator. |
283 if body content is collapsible ,heading will appear along with Disclosure indicator. |
312 If heading is set on richLabel type groupBox, it will be ignored |
284 If heading is set on richLabel type groupBox, it will be ignored |
313 |
285 |
314 \sa heading |
286 \sa heading |
315 */ |
287 */ |
316 void HbGroupBox::setHeading( const QString &text ) |
288 void HbGroupBox::setHeading( const QString &text ) |
317 { |
289 { |
318 Q_D( HbGroupBox ); |
290 Q_D( HbGroupBox ); |
319 |
291 |
320 if(!d->mHeadingWidget) |
292 if( !text.isEmpty() ){ |
321 d->createHeadingWidget(); |
293 if( !d->mHeadingWidget ){ |
322 |
294 d->createHeadingWidget( ); |
323 d->mHeadingWidget->setHeading(text); |
295 } |
324 |
296 d->mHeadingWidget->setHeading( text ); |
325 if(d->mContentWidget){ |
297 if( d->mContentWidget ){ |
326 d->setGroupBoxType(GroupBoxCollapsingContainer); |
298 d->setGroupBoxType(GroupBoxCollapsingContainer); |
327 }else |
299 }else { |
328 d->setGroupBoxType(GroupBoxSimpleLabel); |
300 d->setGroupBoxType(GroupBoxSimpleLabel); |
|
301 } |
|
302 }else{ |
|
303 if( d->mHeadingWidget ){ |
|
304 delete d->mHeadingWidget; |
|
305 d->mHeadingWidget = 0; |
|
306 if( d->mContentWidget ) { |
|
307 d->setGroupBoxType( GroupBoxRichLabel ); |
|
308 }else{ |
|
309 d->setGroupBoxType( GroupBoxTypeUnknown ); |
|
310 } |
|
311 } |
|
312 } |
|
313 repolish(); |
329 } |
314 } |
330 |
315 |
331 /*! |
316 /*! |
332 @beta |
317 @beta |
333 |
318 |
363 void HbGroupBox::setCollapsable( bool collapsable ) |
348 void HbGroupBox::setCollapsable( bool collapsable ) |
364 { |
349 { |
365 Q_D( HbGroupBox ); |
350 Q_D( HbGroupBox ); |
366 |
351 |
367 if(d->mGroupBoxType == GroupBoxCollapsingContainer){ |
352 if(d->mGroupBoxType == GroupBoxCollapsingContainer){ |
368 if(d->mHeadingWidget->collapsable == collapsable) |
353 if(d->collapsable == collapsable) |
369 { |
354 { |
370 return; |
355 return; |
371 } |
356 } |
372 d->mHeadingWidget->collapsable = collapsable; |
357 d->collapsable = collapsable; |
373 |
358 |
374 d->mHeadingWidget->createPrimitives(); |
359 d->mHeadingWidget->createPrimitives(); |
375 |
360 |
376 // make it expand otherwise groupBox can't be expanded at all, after this scenario |
361 // make it expand otherwise groupBox can't be collapsed at all, after this scenario |
377 if(!collapsable && d->mHeadingWidget->collapsed){ |
362 if(!collapsable && d->collapsed){ |
378 d->mContentWidget->setVisible(true); |
363 d->mContentWidget->setVisible(true); |
379 HbStyle::setItemName( d->mContentWidget , "contentwidget"); |
364 HbStyle::setItemName( d->mContentWidget , "contentwidget"); |
380 d->mHeadingWidget->collapsed = false; |
365 d->collapsed = false; |
381 } |
366 } |
382 d->mHeadingWidget->updatePrimitives(); |
367 d->mHeadingWidget->updatePrimitives(); |
383 repolish(); |
368 repolish(); |
384 } |
369 } |
385 } |
370 } |
422 */ |
407 */ |
423 void HbGroupBox::setCollapsed( bool collapsed ) |
408 void HbGroupBox::setCollapsed( bool collapsed ) |
424 { |
409 { |
425 Q_D( HbGroupBox ); |
410 Q_D( HbGroupBox ); |
426 if(d->mGroupBoxType == GroupBoxCollapsingContainer){ |
411 if(d->mGroupBoxType == GroupBoxCollapsingContainer){ |
427 if( d->mContentWidget && d->mHeadingWidget->collapsable) { |
412 if( d->mContentWidget && d->collapsable) { |
428 if ( d->mHeadingWidget->collapsed == collapsed ) |
413 if ( d->collapsed == collapsed ) |
429 return; |
414 return; |
430 |
415 |
431 d->mHeadingWidget->collapsed = collapsed; |
416 d->collapsed = collapsed; |
432 |
417 |
433 #ifdef HB_EFFECTS |
418 #ifdef HB_EFFECTS |
434 HbEffectInternal::add(HB_GROUPBOX_TYPE,"groupbox_expand", "expand"); |
419 HbEffectInternal::add(HB_GROUPBOX_TYPE,"groupbox_expand", "expand"); |
435 //HbEffectInternal::add(HB_GROUPBOX_TYPE,"groupbox_collapse", "collapse"); |
420 //HbEffectInternal::add(HB_GROUPBOX_TYPE,"groupbox_collapse", "collapse"); |
436 #endif |
421 #endif |
437 |
422 |
438 if ( d->mHeadingWidget->collapsed ) { |
423 if ( d->collapsed ) { |
439 #ifdef HB_EFFECTS |
424 #ifdef HB_EFFECTS |
440 HbEffect::start( d->mContentWidget, HB_GROUPBOX_TYPE, "collapse"); |
425 HbEffect::start( d->mContentWidget, HB_GROUPBOX_TYPE, "collapse"); |
441 #endif |
426 #endif |
442 HbStyle::setItemName( d->mContentWidget , ""); |
427 HbStyle::setItemName( d->mContentWidget , ""); |
443 d->mContentWidget->setVisible(false); |
428 d->mContentWidget->setVisible(false); |
521 |
506 |
522 Groupbox can set only one content widget at a time. |
507 Groupbox can set only one content widget at a time. |
523 Ownership of the content widget is transferred to groupbox. |
508 Ownership of the content widget is transferred to groupbox. |
524 |
509 |
525 If \a widget to set is NULL then content is removed. |
510 If \a widget to set is NULL then content is removed. |
|
511 And Groupbox type is changed to simpleLabel , if heading is present. |
526 |
512 |
527 contentWidget is valid only for richLabel & collapsing container type. |
513 contentWidget is valid only for richLabel & collapsing container type. |
528 If content Widget is set on simpleLabel type groupBox, it will be ignored |
514 If content Widget is set on simpleLabel type groupBox, it will be ignored |
529 |
515 |
530 Note: |
516 Note: |
539 Q_D( HbGroupBox ); |
525 Q_D( HbGroupBox ); |
540 |
526 |
541 if(!d->mContentWidget) |
527 if(!d->mContentWidget) |
542 d->createContentWidget(); |
528 d->createContentWidget(); |
543 |
529 |
544 d->mContentWidget->setContentWidget(widget); |
530 if(widget){ |
545 |
531 d->mContentWidget->setContentWidget(widget); |
546 if(d->mHeadingWidget){ |
532 if(d->mHeadingWidget){ |
547 d->setGroupBoxType(GroupBoxCollapsingContainer); |
533 d->setGroupBoxType(GroupBoxCollapsingContainer); |
548 }else |
534 }else |
549 d->setGroupBoxType(GroupBoxRichLabel); |
535 d->setGroupBoxType(GroupBoxRichLabel); |
550 |
536 |
551 // collapsed property is set before setContentWidget |
537 // collapsed property is set before setContentWidget |
552 if ( d->mGroupBoxType == GroupBoxCollapsingContainer && d->mHeadingWidget->collapsed ) { |
538 if ( d->mGroupBoxType == GroupBoxCollapsingContainer && d->collapsed ) { |
553 d->mContentWidget->setVisible(false); |
539 d->mContentWidget->setVisible(false); |
554 HbStyle::setItemName( d->mContentWidget , ""); |
540 HbStyle::setItemName( d->mContentWidget , ""); |
|
541 } |
|
542 // update content widget primitve |
|
543 d->mContentWidget->updatePrimitives(); |
|
544 |
|
545 }else{ |
|
546 delete d->mContentWidget; |
|
547 d->mContentWidget = 0; |
|
548 if(d->mHeadingWidget){ |
|
549 d->setGroupBoxType(GroupBoxSimpleLabel); |
|
550 }else{ |
|
551 d->setGroupBoxType(GroupBoxTypeUnknown); |
|
552 } |
555 } |
553 } |
556 // update content widget primitve |
|
557 d->mContentWidget->updatePrimitives(); |
|
558 repolish(); |
554 repolish(); |
559 } |
555 } |
560 |
556 |
561 /*! |
557 /*! |
562 @beta |
558 @beta |
610 return 0; |
606 return 0; |
611 } |
607 } |
612 |
608 |
613 /*! |
609 /*! |
614 \reimp |
610 \reimp |
|
611 */ |
|
612 |
|
613 QSizeF HbGroupBox::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const |
|
614 { |
|
615 Q_D( const HbGroupBox ); |
|
616 |
|
617 //group box will have size zero in case contentwidget and heading not their. |
|
618 if( !d->mHeadingWidget && !d->mContentWidget ) |
|
619 return QSizeF( 0.f, 0.f ); |
|
620 return HbWidget::sizeHint(which, constraint); |
|
621 } |
|
622 |
|
623 |
|
624 /*! |
|
625 \reimp |
615 */ |
626 */ |
616 void HbGroupBox::updatePrimitives() |
627 void HbGroupBox::updatePrimitives() |
617 { |
628 { |
618 Q_D( const HbGroupBox ); |
629 Q_D( const HbGroupBox ); |
619 |
630 |