src/hbwidgets/widgets/hbgroupbox.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include <hbgroupbox.h>
    26 #include "hbgroupbox.h"
    27 #include "hbgroupbox_p.h"
    27 #include "hbgroupbox_p.h"
    28 #include "hbgroupboxheadingwidget_p.h"
    28 #include "hbgroupboxheadingwidget_p.h"
    29 #include "hbgroupboxcontentwidget_p.h"
    29 #include "hbgroupboxcontentwidget_p.h"
    30 #include <hbstyle.h>
    30 #include <hbstyle.h>
    31 #include <hbstyleoption.h>
    31 #include <hbstyleoption_p.h>
    32 
    32 
    33 #ifdef HB_EFFECTS
    33 #ifdef HB_EFFECTS
    34 #include <hbeffect.h>
    34 #include <hbeffect.h>
    35 #include "hbeffectinternal_p.h"
    35 #include "hbeffectinternal_p.h"
    36 #define HB_GROUPBOX_TYPE "HB_GROUPBOX"
    36 #define HB_GROUPBOX_TYPE "HB_GROUPBOX"
    49     private class constructor     
    49     private class constructor     
    50 */
    50 */
    51 HbGroupBoxPrivate::HbGroupBoxPrivate()
    51 HbGroupBoxPrivate::HbGroupBoxPrivate()
    52     :HbWidgetPrivate(),
    52     :HbWidgetPrivate(),
    53     mContentWidget( 0 ),
    53     mContentWidget( 0 ),
    54     mHeadingWidget( 0 )
    54     mHeadingWidget( 0 ),
       
    55     mGroupBoxType( GroupBoxTypeUnknown )
    55 {
    56 {
    56 }
    57 }
    57 
    58 
    58 /*
    59 /*
    59     private class destructor
    60     private class destructor
   105     // set the type and makes necesary primitive creation/deletion
   106     // set the type and makes necesary primitive creation/deletion
   106     switch(mGroupBoxType) {
   107     switch(mGroupBoxType) {
   107         case GroupBoxSimpleLabel:
   108         case GroupBoxSimpleLabel:
   108             {
   109             {
   109             if(mHeadingWidget){
   110             if(mHeadingWidget){
   110 				mHeadingWidget->setType(type);				
   111                 mHeadingWidget->setType(type);				
   111                 mHeadingWidget->setVisible(true);
   112                 mHeadingWidget->setVisible(true);
   112              
   113              
   113             }else{
   114             }else{
   114                 createHeadingWidget();
   115                 createHeadingWidget();
   115             }
   116             }
   126             if(mHeadingWidget){
   127             if(mHeadingWidget){
   127                 mHeadingWidget->setVisible(false);
   128                 mHeadingWidget->setVisible(false);
   128 
   129 
   129             }
   130             }
   130             if(mContentWidget){
   131             if(mContentWidget){
   131 				mContentWidget->setType(type);
   132                 mContentWidget->setType(type);
   132                 mContentWidget->setVisible(true);
   133                 mContentWidget->setVisible(true);
   133                 HbStyle::setItemName( mContentWidget , "contentwidget");
   134                 HbStyle::setItemName( mContentWidget , "contentwidget");
   134             }else{
   135             }else{
   135                 createContentWidget();
   136                 createContentWidget();
   136             }
   137             }
   138             }
   139             }
   139             break;
   140             break;
   140         case GroupBoxCollapsingContainer:
   141         case GroupBoxCollapsingContainer:
   141             {
   142             {
   142             if((mHeadingWidget)){
   143             if((mHeadingWidget)){
   143 				mHeadingWidget->setType(type);
   144                 mHeadingWidget->setType(type);
   144                 mHeadingWidget->setVisible(true);                
   145                 mHeadingWidget->setVisible(true);                
   145             }else{
   146             }else{
   146                 createHeadingWidget();
   147                 createHeadingWidget();
   147             }
   148             }
   148 
   149 
   149             if(mContentWidget){
   150             if(mContentWidget){
   150                 mContentWidget->setType(type);
   151                 mContentWidget->setType(type);
   151                 if(!q->isCollapsed()){
   152                 if(!q->isCollapsed()){
   152                     mContentWidget->setVisible(true);
   153                     mContentWidget->setVisible(true);
   153                     HbStyle::setItemName( mContentWidget , "contentwidget");
   154                     HbStyle::setItemName( mContentWidget , "contentwidget");
   154 				}else{
   155                 }else{
   155 					mContentWidget->setVisible(false);
   156                     mContentWidget->setVisible(false);
   156 					HbStyle::setItemName( mContentWidget , "");
   157                     HbStyle::setItemName( mContentWidget , "");
   157                 }
   158                 }
   158             }else{
   159             }else{
   159                 createContentWidget();
   160                 createContentWidget();
   160             }
   161             }
   161             }
   162             }
   280 {
   281 {
   281     Q_D( HbGroupBox );
   282     Q_D( HbGroupBox );
   282     d->q_ptr = this;
   283     d->q_ptr = this;
   283 }
   284 }
   284 
   285 
   285 /*! Constructs a group box with the given \a title and \a parent.
       
   286 
       
   287     \deprecated HbGroupBox::HbGroupBox(const QString&, QGraphicsItem*)
       
   288         is deprecated.This version of overloaded constructor is deprecated and cease to exist in the near future    
       
   289  */
       
   290 HbGroupBox::HbGroupBox(const QString &titleText, QGraphicsItem *parent )
       
   291     : HbWidget(*new HbGroupBoxPrivate, parent)
       
   292 {
       
   293     Q_UNUSED(titleText);
       
   294     Q_UNUSED(parent);
       
   295     qDebug() << "this version of constructor is deprecated and will cease to exist in the near future."; 
       
   296 }
       
   297 
       
   298 /*!
   286 /*!
   299     protected constructor for derived class
   287     protected constructor for derived class
   300 */
   288 */
   301 HbGroupBox::HbGroupBox(HbGroupBoxPrivate &dd, QGraphicsItem *parent)
   289 HbGroupBox::HbGroupBox(HbGroupBoxPrivate &dd, QGraphicsItem *parent)
   302     :HbWidget( dd, parent )
   290     :HbWidget( dd, parent )
   583 HbWidget* HbGroupBox::contentWidget( ) const
   571 HbWidget* HbGroupBox::contentWidget( ) const
   584 {
   572 {
   585     Q_D( const HbGroupBox );
   573     Q_D( const HbGroupBox );
   586     if(d->mContentWidget && d->mGroupBoxType != GroupBoxSimpleLabel)
   574     if(d->mContentWidget && d->mGroupBoxType != GroupBoxSimpleLabel)
   587         return d->mContentWidget->mContent; 
   575         return d->mContentWidget->mContent; 
   588     return NULL;
   576     return 0;
   589 }
   577 }
   590 
   578 
   591 /*!
   579 /*!
   592 
   580 
   593     \deprecated HbGroupBox::primitive(HbStyle::Primitive)
   581     \deprecated HbGroupBox::primitive(HbStyle::Primitive)
   611         case HbStyle::P_GroupBoxContent_background:
   599         case HbStyle::P_GroupBoxContent_background:
   612             if(d->mContentWidget)
   600             if(d->mContentWidget)
   613                 return d->mContentWidget->primitive(primitive);
   601                 return d->mContentWidget->primitive(primitive);
   614             break;
   602             break;
   615         default:
   603         default:
   616             return NULL;
   604             return 0;
   617     }
   605     }
   618     return NULL;	
   606     return 0;	
   619 }
   607 }
   620 
   608 
   621 /*!
   609 /*!
   622     \reimp
   610     \reimp
   623  */
   611  */
   630 
   618 
   631     if(d->mContentWidget)
   619     if(d->mContentWidget)
   632         d->mContentWidget->updatePrimitives();
   620         d->mContentWidget->updatePrimitives();
   633 }
   621 }
   634 
   622 
   635 /*! 
       
   636     Sets the group box title text
       
   637 
       
   638     There is no default title text.
       
   639 
       
   640     Note: titletext property is valid for simpleLabel & collapsing container type
       
   641     If titletext is set on richLabel type groupBox, it will be ignored
       
   642 
       
   643     \deprecated HbGroupBox::setTitleText(const QString&)
       
   644         is deprecated.Please use HbGroupBox::setHeading(const QString&) instead
       
   645 
       
   646     \sa titleText
       
   647 */
       
   648 void HbGroupBox::setTitleText( const QString &text )
       
   649 {
       
   650     qDebug() << "This API is deprecated, please use HbGroupBox::setHeading( const QString &text ) instead.";
       
   651     setHeading(text);  
       
   652 }
       
   653 
       
   654 /*! 
       
   655     Returns title text shown on group box
       
   656 
       
   657     Note: If the groupBox type is RichLabel, then this will return NULL string
       
   658 
       
   659     \deprecated HbGroupBox::titleText() const
       
   660         is deprecated. Please use HbGroupBox::heading() const instead
       
   661 
       
   662     \sa setTitleText 
       
   663 */
       
   664 QString HbGroupBox::titleText( ) const
       
   665 {
       
   666     qDebug() << "This API is deprecated, please use HbGroupBox::heading( ) instead.";
       
   667     return heading();
       
   668 }
       
   669 
       
   670 /*! 
       
   671     Sets the group box title widget
       
   672 
       
   673     There is no default title widget.
       
   674 
       
   675     Note: 1)if user set title text after this  \li setTitleText then,title widget will be set to null .
       
   676      Either title text or title widget can be set, both cant se set.
       
   677      2) GroupBox takes ownership of titlewidget and deletes the old title widget
       
   678 
       
   679      \deprecated HbGroupBox::setTitleWidget(HbWidget*) 
       
   680         is deprecated. TitleWidget concept is removed. GroupBox nomore supports widget in the heading part
       
   681 
       
   682      \sa setTitleText \sa titleWidget
       
   683  */
       
   684 void HbGroupBox::setTitleWidget( HbWidget* widget )
       
   685 {
       
   686    Q_UNUSED(widget);
       
   687    qDebug() << "This API is deprecated and will cease to exist in the near future.";
       
   688 }
       
   689 
       
   690 /*! 
       
   691     Returns group box title widget
       
   692 
       
   693     There is no default title widget.
       
   694 
       
   695     Note: If title text is set, then this will return HbLabel
       
   696 
       
   697     \deprecated HbGroupBox::titleWidget() const
       
   698         is deprecated. TitleWidget concept is removed. GroupBox nomore supports widget in the heading part
       
   699 
       
   700     \sa setTitleWidget
       
   701  */
       
   702 HbWidget* HbGroupBox::titleWidget( ) const
       
   703 {
       
   704     qDebug() << "This API is deprecated and will cease to exist in the near future.";
       
   705     return NULL;
       
   706 }
       
   707 
       
   708 /*! 
       
   709     Returns the alignment of the group box title.
       
   710 
       
   711     The default alignment is Qt::AlignLeft.
       
   712 
       
   713     \deprecated HbGroupBox::textAlignment() const
       
   714         is deprecated. GroupBox heading will always be left aligned
       
   715 
       
   716     \sa Qt::Alignment
       
   717  */
       
   718 Qt::Alignment HbGroupBox::textAlignment() const
       
   719 {
       
   720     qDebug() << "This API is deprecated and will cease to exist in the near future.";
       
   721     return NULL;
       
   722 }
       
   723 
       
   724 /*! 
       
   725     Sets the alignment of the group box title.
       
   726 
       
   727     Most styles place the title at the top of the frame. The horizontal
       
   728     alignment of the title can be specified using single values from
       
   729     the following list:
       
   730 
       
   731     \list
       
   732     \i Qt::AlignLeft aligns the title text on the left-hand side .
       
   733     \i Qt::AlignRight aligns the title text on the right-hand side .
       
   734     \i Qt::AlignHCenter aligns the title text with the horizontal center of the group box.
       
   735     \endlist
       
   736 
       
   737     The default alignment is Qt::AlignLeft.
       
   738 
       
   739     Note: This API will not work if heading is set as widget \li setTitleWidget
       
   740     This alignment is only of heading text \li setTitleText
       
   741 
       
   742     \deprecated HbGroupBox::setTextAlignment(QFlags<Qt::AlignmentFlag>)
       
   743         is deprecated. GroupBox heading will always be left aligned.
       
   744 
       
   745     \sa Qt::Alignment
       
   746  */
       
   747 void HbGroupBox::setTextAlignment(Qt::Alignment alignment)
       
   748 {
       
   749     Q_UNUSED(alignment);
       
   750     qDebug() << "This API is deprecated and will cease to exist in the near future.";
       
   751 }
       
   752 
       
   753 #include "moc_hbgroupbox.cpp"
   623 #include "moc_hbgroupbox.cpp"