src/hbwidgets/widgets/hbgroupbox.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    98     Q_Q( HbGroupBox );
    98     Q_Q( HbGroupBox );
    99     
    99     
   100     // set dynamic property based on type
   100     // set dynamic property based on type
   101     q->setProperty("groupBoxType",(int)type);
   101     q->setProperty("groupBoxType",(int)type);
   102 
   102 
   103     if ( mGroupBoxType == type ) 
   103     if ( mGroupBoxType == type ) {
       
   104         q->updatePrimitives();
   104         return;
   105         return;
       
   106     }
   105 
   107 
   106     mGroupBoxType = type;
   108     mGroupBoxType = type;
   107   
   109   
   108     // set the type and makes necesary primitive creation/deletion
   110     // set the type and makes necesary primitive creation/deletion
   109     switch(mGroupBoxType) {
   111     switch(mGroupBoxType) {
   301         }
   303         }
   302     }else{
   304     }else{
   303         if( d->mHeadingWidget ){
   305         if( d->mHeadingWidget ){
   304             delete d->mHeadingWidget;
   306             delete d->mHeadingWidget;
   305             d->mHeadingWidget = 0;
   307             d->mHeadingWidget = 0;
       
   308             HbStyle::setItemName( d->mHeadingWidget, QString());
   306             if( d->mContentWidget ) {
   309             if( d->mContentWidget ) {
   307                 d->setGroupBoxType( GroupBoxRichLabel );
   310                 d->setGroupBoxType( GroupBoxRichLabel );
   308             }else{
   311             }else{
   309                 d->setGroupBoxType( GroupBoxTypeUnknown );
   312                 d->setGroupBoxType( GroupBoxTypeUnknown );
   310             }
   313             }
   311         }        
   314         }        
   312     }
   315     }
   313     repolish();
   316     //repolish();
   314 }
   317 }
   315 
   318 
   316 /*!
   319 /*!
   317     @beta
   320     @beta
   318 
   321 
   431                 #ifdef HB_EFFECTS
   434                 #ifdef HB_EFFECTS
   432                 HbEffect::start( d->mContentWidget, HB_GROUPBOX_TYPE, "expand");  
   435                 HbEffect::start( d->mContentWidget, HB_GROUPBOX_TYPE, "expand");  
   433                 #endif
   436                 #endif
   434                 HbStyle::setItemName( d->mContentWidget , "contentwidget");
   437                 HbStyle::setItemName( d->mContentWidget , "contentwidget");
   435                 d->mContentWidget->setVisible(true);
   438                 d->mContentWidget->setVisible(true);
       
   439                 //polish is needed in case groupbox is collapsed before show.
   436                 repolish();
   440                 repolish();
   437             }
   441             }
   438             d->mHeadingWidget->updatePrimitives();
   442             d->mHeadingWidget->updatePrimitives();
   439             emit toggled( d->collapsed );
   443             emit toggled( d->collapsed );
   440         }
   444         }
   453 bool HbGroupBox::isCollapsed( ) const
   457 bool HbGroupBox::isCollapsed( ) const
   454 {
   458 {
   455     Q_D ( const HbGroupBox );
   459     Q_D ( const HbGroupBox );
   456     if(d->mGroupBoxType == GroupBoxCollapsingContainer)
   460     if(d->mGroupBoxType == GroupBoxCollapsingContainer)
   457         return d->collapsed;
   461         return d->collapsed;
   458 		
   462         
   459     return false;
   463     return false;
   460 }
   464 }
   461 
   465 
   462 /*!
   466 /*!
   463     @beta
   467     @beta
   492 bool HbGroupBox::marqueeHeading( ) const
   496 bool HbGroupBox::marqueeHeading( ) const
   493 {
   497 {
   494     Q_D( const HbGroupBox );
   498     Q_D( const HbGroupBox );
   495     if(d->mHeadingWidget && d->mGroupBoxType == GroupBoxSimpleLabel)
   499     if(d->mHeadingWidget && d->mGroupBoxType == GroupBoxSimpleLabel)
   496         return d->mHeadingWidget->marqueeEnabled;
   500         return d->mHeadingWidget->marqueeEnabled;
   497 		
   501         
   498     return false;
   502     return false;
   499 }
   503 }
   500 
   504 
   501 
   505 
   502 /*!
   506 /*!
   521     \sa contentWidget
   525     \sa contentWidget
   522 */
   526 */
   523 void HbGroupBox::setContentWidget( HbWidget *widget )
   527 void HbGroupBox::setContentWidget( HbWidget *widget )
   524 {
   528 {
   525     Q_D( HbGroupBox );
   529     Q_D( HbGroupBox );
   526    
       
   527     if(!d->mContentWidget)
       
   528         d->createContentWidget();
       
   529     
   530     
       
   531     bool doPolish = false; 
   530     if(widget){
   532     if(widget){
       
   533         // create the mContentWidget if its not there.
       
   534         if(!d->mContentWidget)
       
   535             d->createContentWidget();
       
   536         doPolish = widget != d->mContentWidget->mContent;
   531         d->mContentWidget->setContentWidget(widget);
   537         d->mContentWidget->setContentWidget(widget);
   532         if(d->mHeadingWidget){
   538         if(d->mHeadingWidget){
   533             d->setGroupBoxType(GroupBoxCollapsingContainer);
   539             d->setGroupBoxType(GroupBoxCollapsingContainer);
   534         }else{
   540         }else{
   535             d->setGroupBoxType(GroupBoxRichLabel);
   541             d->setGroupBoxType(GroupBoxRichLabel);
   536         }
   542         }
   537         // update content widget primitve
   543         // update content widget primitve
   538         d->mContentWidget->updatePrimitives();
   544         d->mContentWidget->updatePrimitives();
   539 
   545 
   540     }else{
   546     }else{
   541         delete d->mContentWidget;
   547         // delete mContentWidget if widget is null.
   542         d->mContentWidget = 0;
   548         if( d->mContentWidget ){
   543         if(d->mHeadingWidget){
   549             delete d->mContentWidget;
   544             d->setGroupBoxType(GroupBoxSimpleLabel);
   550             d->mContentWidget = 0;
   545         }else{
   551             HbStyle::setItemName( d->mContentWidget, QString());
   546             d->setGroupBoxType(GroupBoxTypeUnknown);
   552             if(d->mHeadingWidget){
       
   553                 d->setGroupBoxType(GroupBoxSimpleLabel);
       
   554             }else{
       
   555                 d->setGroupBoxType(GroupBoxTypeUnknown);
       
   556             }
   547         }
   557         }
   548     }
   558     }
   549     repolish();
   559     if(doPolish){
       
   560         repolish();
       
   561     }
   550 }
   562 }
   551 
   563 
   552 /*!
   564 /*!
   553     @beta
   565     @beta
   554 
   566 
   555     Returns groupbox content widget
   567     Returns groupbox content widget
   556     
   568     
   557     There is no default content widget.	
   569     There is no default content widget. 
   558 
   570 
   559     GroupBox takes care of the ownership of the content widget being set
   571     GroupBox takes care of the ownership of the content widget being set
   560 
   572 
   561     Note: if \li setContentWidget is called more then once,
   573     Note: if \li setContentWidget is called more then once,
   562     then this will return last set content widget
   574     then this will return last set content widget
   582 QGraphicsItem* HbGroupBox::primitive(HbStyle::Primitive primitive) const
   594 QGraphicsItem* HbGroupBox::primitive(HbStyle::Primitive primitive) const
   583 {
   595 {
   584     Q_D( const HbGroupBox );
   596     Q_D( const HbGroupBox );
   585 
   597 
   586     switch (primitive) {
   598     switch (primitive) {
   587         case HbStyle::P_GroupBoxHeading_icon:
   599         case HbStylePrivate::P_GroupBoxHeading_icon:
   588         case HbStyle::P_GroupBoxHeading_text:
   600         case HbStylePrivate::P_GroupBoxHeading_text:
   589         case HbStyle::P_GroupBoxHeading_background:
   601         case HbStylePrivate::P_GroupBoxHeading_background:
   590              if(d->mHeadingWidget){
   602              if(d->mHeadingWidget){
   591                 return d->mHeadingWidget->primitive(primitive);
   603                 return d->mHeadingWidget->primitive(primitive);
   592                 }
   604                 }
   593             break;
   605             break;
   594         case HbStyle::P_GroupBoxContent_background:
   606         case HbStylePrivate::P_GroupBoxContent_background:
   595             if(d->mContentWidget)
   607             if(d->mContentWidget)
   596                 return d->mContentWidget->primitive(primitive);
   608                 return d->mContentWidget->primitive(primitive);
   597             break;
   609             break;
   598         default:
   610         default:
   599             return 0;
   611             return 0;
   600     }
   612     }
   601     return 0;	
   613     return 0;   
   602 }
   614 }
   603 
   615 
   604 /*!
   616 /*!
   605     \reimp
   617     \reimp
   606 */
   618 */