src/hbwidgets/dataform/hbdataformheadingwidget_p.cpp
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #include "hbdataformheadingwidget_p.h"
       
    27 
       
    28 #include <hbcombobox.h>
       
    29 #include <hbstyleoptiondataform.h>
       
    30 #include <QGraphicsItem>
       
    31 
       
    32 
       
    33 void HbDataFormHeadingWidget::initStyleOption(HbStyleOptionDataForm *option)
       
    34 {
       
    35     HbWidget::initStyleOption(option);
       
    36     option->heading = mHeading;
       
    37     option->description = mDescription;
       
    38 }
       
    39 
       
    40 HbDataFormHeadingWidget::HbDataFormHeadingWidget(QGraphicsItem* parent):
       
    41     HbWidget(parent),
       
    42     mHeadingItem(0),
       
    43     mDescriptionItem(0),
       
    44     mBackgroundItem(0),
       
    45     mPageCombo(0),
       
    46     mActivePage(-1)
       
    47 {
       
    48 }
       
    49 
       
    50 void HbDataFormHeadingWidget::createPrimitives()
       
    51 {
       
    52     if(!mBackgroundItem) {
       
    53         mBackgroundItem = style()->createPrimitive(HbStyle::P_DataForm_heading_background, this);
       
    54     }
       
    55     if(!mHeading.isEmpty()) {
       
    56         if(!mHeadingItem){
       
    57             mHeadingItem = style()->createPrimitive(HbStyle::P_DataForm_heading, this);
       
    58         }
       
    59     } else {
       
    60         if(mHeadingItem){
       
    61             delete mHeadingItem;
       
    62             mHeadingItem = 0;
       
    63         }
       
    64     }
       
    65 
       
    66     if(!mDescription.isEmpty()) {
       
    67         if(!mDescriptionItem) {
       
    68             mDescriptionItem = style()->createPrimitive(HbStyle::P_DataForm_description, this);
       
    69         }
       
    70     } else {
       
    71         if(mDescriptionItem) {
       
    72             delete mDescriptionItem;
       
    73             mDescriptionItem = 0;
       
    74         }
       
    75     }
       
    76 }
       
    77 
       
    78 void HbDataFormHeadingWidget::updatePrimitives()
       
    79 {
       
    80     HbStyleOptionDataForm dataFormOption;
       
    81     initStyleOption(&dataFormOption);
       
    82 
       
    83     if(mHeadingItem) {
       
    84         style()->updatePrimitive( mHeadingItem, HbStyle::P_DataForm_heading, &dataFormOption);
       
    85     }
       
    86 
       
    87     if(mDescriptionItem) {
       
    88         style()->updatePrimitive( mDescriptionItem, HbStyle::P_DataForm_description,
       
    89             &dataFormOption);
       
    90     }
       
    91     if(mBackgroundItem) {
       
    92         style()->updatePrimitive(
       
    93             mBackgroundItem, HbStyle::P_DataForm_heading_background, &dataFormOption);
       
    94     }
       
    95 }
       
    96 
       
    97 void HbDataFormHeadingWidget::callPolish()
       
    98 {
       
    99     repolish();
       
   100     updatePrimitives();
       
   101 }
       
   102 
       
   103 int HbDataFormHeadingWidget::pageIndex(const QString& page) const
       
   104 {
       
   105     if(mPageCombo) {
       
   106        return mPageCombo->findText(page);
       
   107     }
       
   108     return -1;
       
   109 }
       
   110 
       
   111 void HbDataFormHeadingWidget::updatePageName(int index, const QString& page)
       
   112 {
       
   113     if(index >= 0 && mPageCombo) {       
       
   114         if( mPageCombo->itemText(index) != page)  {          
       
   115             mPageCombo->setItemText(index,page);            
       
   116         }       
       
   117     }      
       
   118 }
       
   119 
       
   120