src/hbwidgets/widgets/hbgroupbox.cpp
changeset 3 11d3954df52a
parent 2 06ff229162e9
child 6 c3690ec91ef8
equal deleted inserted replaced
2:06ff229162e9 3:11d3954df52a
    87     HbStyle::setItemName( mContentWidget , "contentwidget");
    87     HbStyle::setItemName( mContentWidget , "contentwidget");
    88 }
    88 }
    89 
    89 
    90 /*!
    90 /*!
    91     \internal
    91     \internal
    92     Sets the group box type
    92     Sets the groupbox type
    93 */
    93 */
    94 void HbGroupBoxPrivate::setGroupBoxType( GroupBoxType type )
    94 void HbGroupBoxPrivate::setGroupBoxType( GroupBoxType type )
    95 {
    95 {
    96     Q_Q( HbGroupBox );
    96     Q_Q( HbGroupBox );
    97     
    97     
   169     q->repolish();
   169     q->repolish();
   170 }
   170 }
   171 
   171 
   172 
   172 
   173 /*!
   173 /*!
   174     @alpha
   174     @beta
   175     @hbwidgets
   175     @hbwidgets
   176     \class HbGroupBox
   176     \class HbGroupBox
   177 
   177 
   178     \brief HbGroupBox shows the user that a set of controls belong together.
   178     \brief HbGroupBox shows the user that a set of controls belong together.
   179     
   179     
   180     HbGroupBox is a container that provides the following : 
   180     HbGroupBox is a container, which can have following Elementes: 
   181 
   181 
   182     \li Heading: text only
   182     \li Heading: A heading contains one row text and disclosure indicator if the disclosure mechanism is on.
   183     \li Body content: arbitrary content (any HbWidget)
   183     \li Body content: Can have arbitrary content (any HbWidget)and application is responsible for its layout.
   184     \li Disclosure mechanism: expands and collapses the body content;
   184     \li Disclosure Indicator: Indicates the expands and collapses state of body;
   185 
   185 
   186     There are three types of GroupBox:
   186     There are three types of GroupBox:
   187 
   187 
   188     \li Simple Label - it's only function is to show relationship between items.
   188     \li Simple Label - Simple Label is to indicate the users position in the application hierarchy 
   189     simple Label shows a heading with marquee, no disclosure mechanism, and 
   189     or to display a textual label and its noninteractive. 
   190     no body content. Marquee is disabled by default.Also it is not focusable. 
   190     Simple Label has a heading text with marquee, no disclosure mechanism, and 
       
   191     no body content.Simple label only has heading element. 
       
   192     Marquee is disabled by default, can be enabled using setMarqueeHeading () .Also it is not focusable. 
   191 
   193 
   192     Example usage: For SimpleLabel type groupbox
   194     Example usage: For SimpleLabel type groupbox
   193     \code
   195     \code
   194     // create groupBox and set only heading; without any body content
   196     // create groupBox and set only heading; without any body content
   195     HbGroupBox *simpleLabel = new HbGroupBox();
   197     HbGroupBox *simpleLabel = new HbGroupBox();
   196     simpleLabel->setHeading("Simple label groupBox comes with marquee disabled by default");
   198     simpleLabel->setHeading("Simple label groupBox comes with marquee disabled by default");
       
   199     //to make marqee enabled
       
   200     simpleLabel->setMarqueeHeading(true);
   197     \endcode 
   201     \endcode 
   198     
   202     
   199     \image html simpleLabelgroupbox.png A SimpleLabel groupbox
   203     \image html simpleLabelgroupbox.png A SimpleLabel groupbox
   200 
   204 
   201 
   205 
   202     \li Rich Label - does not show a heading and all content is in the body area 
   206     \li Rich Label - Rich label can contain dynamic content,which themselves can be interactive,or informative
   203     with no marquee and no disclosure control.Body Content must describe its own behavior and layout. 
   207     with no heading ,no marquee and no disclosure control.Body Content must describe its own behavior and layout. 
   204 
   208 
   205     Example usage: For RichLabel type groupbox
   209     Example usage: For RichLabel type groupbox
   206     \code
   210     \code
   207     // create groupBox and set only content; without any heading
   211     // create groupBox and set only content; without any heading
   208     HbGroupBox *richHeading = new HbGroupBox();
   212     HbGroupBox *richLabel = new HbGroupBox();
   209     // content widget can be any HbWidget
   213     HbPushButton *button = new HbPushButton(HbIcon(QString("qtg_large_info")),"Ovi");
   210     // layouting and interaction behaviour inside Content widget is application's responsiblity
       
   211     HbPushButton *button = new HbPushButton(HbIcon(":/icons/ovi.png"),"Ovi");
       
   212     button->setAdditionalText("Launch Ovi Music store");
   214     button->setAdditionalText("Launch Ovi Music store");
   213     button->setOrientation(Qt::Vertical);
   215     richLabel->setContentWidget(button);
   214     button->setTextAlignment(Qt::AlignLeft);
   216     mainlayout->addItem(richLabel);
   215     richHeading->setContentWidget(button);
       
   216     \endcode 
   217     \endcode 
   217 
   218 
   218     \image html richLabelgroupbox.png A RichLabel groupbox.
   219     \image html richLabelgroupbox.png A RichLabel groupbox.
   219     In RichLabel type, groupbox provides background for body content.
   220     In RichLabel type, groupbox provides background for body content.
   220 
   221 
   221     \li Collapsing container - also allows the user to show or hide the content of the groupBox.
   222     \li Collapsing container - Collapsing container allows the user to show or hide the content of the groupBox.
   222     It always has a heading and body content; optionally has a disclosure mechanism.
   223     It always has a heading and body content; optionally has a disclosure mechanism.
   223     The heading does not marquee.The collapse/expand disclosure mechanism is located 
   224     The heading does not marquee.The body content must describe its own behavior and layout.
   224     in the heading and is the chief utility of this type of group box.
   225     The collapse/expand disclosure mechanism is located in the heading and is the chief utility of this type of groupbox.
   225 
   226 
   226     If disclosure mechanism is Off, then heading will appear without expand/collapse indication icon 
   227     If disclosure mechanism is Off,then heading will appear without expand/collapse indication icon 
   227     heading.Also the user will not be able to expand/collapse the body content.
   228     heading.Also the user will not be able to expand/collapse the body content.
   228 
   229 
   229     Example usage:For collapsingContainer groupbox
   230     Example usage:For collapsingContainer groupbox
   230     \code    
   231     \code    
   231     // create groupBox and set both heading and content
   232     // create groupBox and set both heading and content
   239     \endcode
   240     \endcode
   240 
   241 
   241     \image html collapsableContainergroupbox.png A Collapsing container groupbox.
   242     \image html collapsableContainergroupbox.png A Collapsing container groupbox.
   242 
   243 
   243     In this type, groupBox body content can be expanded/collapsed, 
   244     In this type, groupBox body content can be expanded/collapsed, 
   244     depending on whether or not the group box is collapsed.
   245     depending on whether or not the groupbox is collapsed.
   245 
   246 
   246     CollapsingContainer type groupBox comes with disclosure mechanism On by default.
   247     CollapsingContainer type groupBox comes with disclosure mechanism On by default.
   247 
   248 
   248     Setting heading and body content decides type of the groupbox.
   249     Setting heading and body content decides type of the groupbox.
   249 
   250 
   260 /*!
   261 /*!
   261     \fn void HbGroupBox::clicked()
   262     \fn void HbGroupBox::clicked()
   262 
   263 
   263     This signal is emitted only in case of richLabel and collapsing container groupbox,
   264     This signal is emitted only in case of richLabel and collapsing container groupbox,
   264     whenever click happened on body content.If the body content set is an interactive widget
   265     whenever click happened on body content.If the body content set is an interactive widget
   265     and consumes mouse press event, then clicked signal will not get emitted from groupBox in that case.
   266     and consumes mouse press event, then in that case clicked signal will not get emitted from groupBox.
   266  */
   267  */
   267 
   268 
   268 /*!
   269 /*!
   269     \fn void HbGroupBox::toggled(bool)
   270     \fn void HbGroupBox::toggled(bool)
   270 
   271 
   271     This signal is emitted only in case of collapsing container groupbox,
   272     This signal is emitted only in case of collapsing container groupbox,
   272     whenever groupbox is collapsed/expanded
   273     whenever groupbox is collapsed/expanded
   273  */
   274  */
   274 
   275 
   275 /*!
   276 /*!
   276     @alpha
   277     @beta
   277     Constructs a group box with the given \a parent.
   278     Constructs a groupbox with the given \a parent.
   278 */
   279 */
   279 HbGroupBox::HbGroupBox( QGraphicsItem *parent)
   280 HbGroupBox::HbGroupBox( QGraphicsItem *parent)
   280     : HbWidget(*new HbGroupBoxPrivate, parent)
   281     : HbWidget(*new HbGroupBoxPrivate, parent)
   281 {
   282 {
   282     Q_D( HbGroupBox );
   283     Q_D( HbGroupBox );
   292     Q_D( HbGroupBox );
   293     Q_D( HbGroupBox );
   293     d->q_ptr = this;
   294     d->q_ptr = this;
   294 }
   295 }
   295 
   296 
   296 /*!
   297 /*!
   297     Destructs the group box.
   298     Destructs the groupbox.
   298 */
   299 */
   299 HbGroupBox::~HbGroupBox()
   300 HbGroupBox::~HbGroupBox()
   300 {
   301 {
   301 }
   302 }
   302 
   303 
   303 /*!
   304 /*!
   304     @alpha
   305     @beta
   305     
   306     
   306     Sets the group box heading
   307     Sets the groupbox heading
   307 
   308 
   308     Note: heading property is valid for simpleLabel & collapsing container type.
   309     Note: heading property is valid for simpleLabel & collapsing container type.
       
   310     For Collapsing container,
       
   311     if body content is collapsible ,heading will appear along with Disclosure indicator.
   309     If heading is set on richLabel type groupBox, it will be ignored
   312     If heading is set on richLabel type groupBox, it will be ignored
   310 
   313 
   311     \sa heading
   314     \sa heading
   312 */
   315 */
   313 void HbGroupBox::setHeading( const QString &text )
   316 void HbGroupBox::setHeading( const QString &text )
   324     }else
   327     }else
   325         d->setGroupBoxType(GroupBoxSimpleLabel);
   328         d->setGroupBoxType(GroupBoxSimpleLabel);
   326 }
   329 }
   327 
   330 
   328 /*!
   331 /*!
   329     @alpha
   332     @beta
   330 
   333 
   331     Returns text shown on the groupBox heading.
   334     Returns text shown on the groupBox heading.
   332 
   335 
   333     There is no default heading string set.
   336     There is no default heading string set.
   334 
   337 
   344         return d->mHeadingWidget->headingText;
   347         return d->mHeadingWidget->headingText;
   345     return QString();
   348     return QString();
   346 }
   349 }
   347 
   350 
   348 /*!
   351 /*!
   349     @alpha
   352     @beta
   350 
   353 
   351     Sets whether the groupbox is collapsable or not
   354     Sets whether the groupbox is collapsable or not
   352 
   355 
   353     If this property is true, then disclosure mechanism is On.    
   356     If this property is true, then disclosure mechanism is On.    
   354 
   357 
   380         repolish();
   383         repolish();
   381     }
   384     }
   382 }
   385 }
   383 
   386 
   384 /*!
   387 /*!
   385     @alpha
   388     @beta
   386 
   389 
   387     Returns whether the groupbox is collapsable or not
   390     Returns whether the groupbox is collapsable or not
   388 
   391 
   389     By default, group boxes are collapsable.
   392     By default, groupbox is collapsable.
   390 
   393 
   391     \sa setCollapsable
   394     \sa setCollapsable
   392 */
   395 */
   393 bool HbGroupBox::isCollapsable( ) const
   396 bool HbGroupBox::isCollapsable( ) const
   394 {
   397 {
   397         return d->mHeadingWidget->collapsable;
   400         return d->mHeadingWidget->collapsable;
   398     return false;
   401     return false;
   399 }
   402 }
   400 
   403 
   401 /*!
   404 /*!
   402     @alpha
   405     @beta
   403 
   406 
   404     Sets whether the groupbox collapsed or expanded
   407     Sets whether the groupbox collapsed or expanded
   405 
   408 
   406     If the groupbox is collapsed,the group box's content widget are hidden; 
   409     If the groupbox is collapsed,the groupbox's content widget are hidden; 
   407     otherwise they will be visible
   410     otherwise they will be visible
   408 
   411 
   409     setCollapsed on groupbox will emit signal toggled( bool ) 
   412     setCollapsed on groupbox will emit signal toggled( bool ) 
   410     upon collapse\expand of content widget
   413     upon collapse\expand of content widget
   411 
   414 
   412     Only collapsable groupboxes can be collapsed. (i.e)this API will not do anything 
   415     Only collapsable groupbox can be collapsed. (i.e)this API will not do anything 
   413     if group box is not collapsable.By default, group boxes are not collapsed.
   416     if groupbox is not collapsable.By default, groupbox is not collapsed.
   414 
   417 
   415     Note: collapsed property is valid only for collapsing container type.
   418     Note: collapsed property is valid only for collapsing container type.
   416     If collapsed is set on simpleLabel or richLabel type groupBox, it will be ignored
   419     If collapsed is set on simpleLabel or richLabel type groupBox, it will be ignored
   417 
   420 
   418     \sa isCollapsed \sa setCollapsable
   421     \sa isCollapsed \sa setCollapsable
   447                 d->mContentWidget->setVisible(true);
   450                 d->mContentWidget->setVisible(true);
   448             }
   451             }
   449             d->mHeadingWidget->updatePrimitives();
   452             d->mHeadingWidget->updatePrimitives();
   450             emit toggled( d->mHeadingWidget->collapsed );
   453             emit toggled( d->mHeadingWidget->collapsed );
   451         }
   454         }
   452     }
   455         repolish();
   453 }
   456     }    
   454 
   457 }
   455 /*!
   458 
   456     @alpha
   459 /*!
   457 
   460     @beta
   458     Returns whether the group box is collapsed or expanded
   461 
   459 
   462     Returns whether the groupbox is collapsed or expanded
   460     By default, groupboxes are not collapsed.
   463 
       
   464     By default, groupbox is not collapsed.
   461      
   465      
   462     \sa setCollapsed \sa setCollapsable
   466     \sa setCollapsed \sa setCollapsable
   463 */
   467 */
   464 bool HbGroupBox::isCollapsed( ) const
   468 bool HbGroupBox::isCollapsed( ) const
   465 {
   469 {
   469 		
   473 		
   470     return false;
   474     return false;
   471 }
   475 }
   472 
   476 
   473 /*!
   477 /*!
   474     @alpha
   478     @beta
   475 
   479 
   476     Enables the marquee for heading if marqueeHeading is true, otherwise the 
   480     Enables the marquee for heading if marqueeHeading is true, otherwise the 
   477     heading will not marquee.
   481     heading will not marquee.
   478 
   482 
   479     Note: marqueeHeading property is valid  only for simpleLabel type.
   483     Note: marqueeHeading property is valid  only for simpleLabel type.
   489     }
   493     }
   490 
   494 
   491 }
   495 }
   492 
   496 
   493 /*!
   497 /*!
   494     @alpha
   498     @beta
   495 
   499 
   496     Returns true if marquee is enabled for  groupbox heading; 
   500     Returns true if marquee is enabled for  groupbox heading; 
   497     otherwise returns false.
   501     otherwise returns false.
   498 
   502 
   499     The default value is false.
   503     The default value is false.
   509     return false;
   513     return false;
   510 }
   514 }
   511 
   515 
   512 
   516 
   513 /*!
   517 /*!
   514     @alpha
   518     @beta
   515 
   519 
   516     Sets the groupbox content widget
   520     Sets the groupbox content widget
   517 
   521 
   518     Groupbox can set only one content widget at a time.
   522     Groupbox can set only one content widget at a time.
   519     Ownership of the content widget is transferred to groupbox.
   523     Ownership of the content widget is transferred to groupbox.
   553     d->mContentWidget->updatePrimitives();
   557     d->mContentWidget->updatePrimitives();
   554     repolish();
   558     repolish();
   555 }
   559 }
   556 
   560 
   557 /*!
   561 /*!
   558     @alpha
   562     @beta
   559 
   563 
   560     Returns groupbox content widget
   564     Returns groupbox content widget
   561     
   565     
   562     There is no default content widget.	
   566     There is no default content widget.	
   563 
   567