src/hbcore/style/hbstyle.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 HbCore 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 "hbstyleoptionslider.h"
       
    27 #include "hbstyleoptionsliderelement_p.h"
       
    28 #include "hbstyleoptionpushbutton.h"
       
    29 #include "hbstyleoptiontoolbutton.h"
       
    30 #include "hbstyleoptiontooltip.h"
       
    31 #include "hbstyleoptionprogressbar.h"
       
    32 #include "hbstyleoptionabstractviewitem.h"
       
    33 #include "hbstyleoptionlistviewitem.h"
       
    34 #include "hbstyleoptionmenuitem.h"
       
    35 #include "hbstyleoptionlabel.h"
       
    36 #include "hbstyleoptionscrollbar.h"
       
    37 #include "hbstyleoptiontoolbarextension.h"
       
    38 #include "hbstyleoptiongridviewitem.h"
       
    39 #include "hbstyleoptioncheckbox.h"
       
    40 #include "hbiconloader_p.h"
       
    41 #include "hbstyleoptiontitlepane.h"
       
    42 #include "hbstyleoptionstatusbar_p.h"
       
    43 #include "hbstyleoptionindicatorgroup.h"
       
    44 #include "hbstyleoptionprogressdialog.h"
       
    45 #include "hbstyleoptionnotificationdialog.h"
       
    46 #include "hbstyleoptiontreeviewitem.h"
       
    47 #include "hbstyleoptioncolorgridviewitem.h"
       
    48 #include "hbstyleoptionmessagebox.h"
       
    49 #include "hbstyleoptionsoftkey.h"   // deprecated
       
    50 #include "hbstyleoptionnavigationbutton.h"
       
    51 #include "hbstyleoptionindicatorbutton.h"
       
    52 #include "hbstyleoptionsignalindicator_p.h"
       
    53 #include "hbstyleoptionbatteryindicator_p.h"
       
    54 #include "hbstyle_p.h"
       
    55 #include "hbstyleloader.h"
       
    56 #include "hbwidgetloader_p.h"
       
    57 #include "hbstyleoptionratingslider.h"
       
    58 #include "hbstyleoptiondataformviewitem.h"
       
    59 #include "hbstyleoptiondatagroup_p.h"
       
    60 #include "hbstyleoptiondatagroupheadingwidget_p.h"
       
    61 #include "hbstyleoptiondataform.h"
       
    62 #include "hbstyleoptiongroupbox.h"
       
    63 #include "hbstyleoptionindexfeedback.h"
       
    64 #include "hbstyleoptioncombobox.h"
       
    65 #include "hbstyleoptioninputdialog.h"
       
    66 
       
    67 #include <hbicon.h>
       
    68 #include <hbstyle.h>
       
    69 #include <hbframedrawer.h>
       
    70 #include <hbiconitem.h>
       
    71 #include <hbiconitem_p.h>
       
    72 #include <hbframeitem.h>
       
    73 #include <hbframedrawer.h>
       
    74 #include <hbframedrawer_p.h>
       
    75 #include <hbframebackground.h>
       
    76 #include <hbprogresstrackitem_p.h>
       
    77 #include <hbslidertrackitem_p.h>
       
    78 #include <hbinstance.h>
       
    79 #include <hbtextitem.h>
       
    80 #include <hbtextitem_p.h>
       
    81 #include <hbmarqueeitem.h>
       
    82 #include <hbmarqueeitem_p.h>
       
    83 #include <hbrichtextitem.h>
       
    84 #include <hbrichtextitem_p.h>
       
    85 #include <hbtoucharea.h>
       
    86 #include <hbindicatorleveliconitem_p.h>
       
    87 
       
    88 #include <hbglobal.h>
       
    89 #include <QPluginLoader>
       
    90 #include <hbstyleinterface.h>
       
    91 #include <hbstyleparameters.h>
       
    92 
       
    93 #include "hbstyleselector_p.h"
       
    94 #include "hblayeredstyleloader_p.h"
       
    95 #include "hbwidgetstyleloader_p.h"
       
    96 #include "hbcssparser_p.h"
       
    97 #include "hbrepeaticonitem_p.h"
       
    98 #include "hbcolortheme_p.h"
       
    99 #include "hbnamespace_p.h"
       
   100 
       
   101 
       
   102 #include "hbmeshlayout_p.h"
       
   103 
       
   104 #include <QGraphicsWidget>
       
   105 #include <hbwidget.h>
       
   106 #include <hbwidgetbase.h>
       
   107 #include "hbdeviceprofile.h"
       
   108 #include "hbrepeatitem_p.h"
       
   109 
       
   110 #include <QDebug>
       
   111 
       
   112 //Uncomment next define in order to get more debug prints.
       
   113 //Similar define exists also in the engine side.
       
   114 //#define HBSTYLE_DEBUG
       
   115 
       
   116 #ifdef HBSTYLE_DEBUG
       
   117 #include <QDebug>
       
   118 #endif
       
   119 
       
   120 /*!
       
   121     @beta
       
   122     @hbcore
       
   123     \class HbStyle
       
   124     \brief HbStyle is the style management class for widgets
       
   125 
       
   126     HbStyle is used for the style management of widgets.
       
   127     It offers methods to create and update styled primitives. Briefly, styled primitives
       
   128     are HbWidgetBase-derived (which is a QGraphicsWidget) classes which draw a certain part of the user interface (for example
       
   129     the button background, or the slider thumb).
       
   130 
       
   131     A widget that chooses to be styled needs to create its primitives
       
   132     by using the createPrimitive method.
       
   133 
       
   134     Whenever the widget's state changes in a way that needs changes in drawing the primitive
       
   135     (such as button pressed down -> change the button background image) then the widget needs to
       
   136     call the updatePrimitive method.
       
   137 
       
   138     Generally primitives should be updated only when a state change occurs. When a widget uses primitives to construct
       
   139     itself it does not need a paint() method at all since primitives (widget's childs) are doing the drawing. 
       
   140     Painting for the primitives occurs from the graphics scene.
       
   141 
       
   142 */
       
   143 
       
   144 
       
   145 
       
   146 // TODO: margins should be defined in layout data once layout specification exists.
       
   147 static const int ItemName = 0xfffe;
       
   148 static const QString STYLE_LOCATION = QLatin1String(":/themes/style/hbdefault/rules/widgets/%w/%w");
       
   149 static const QString COLOR_STYLE_LOCATION = QLatin1String(":/themes/style/hbdefault/rules/widgets/%w/%w_color");
       
   150 static const int TOUCHAREA_ZVALUE = 1000;
       
   151 
       
   152 static const QString GLOBAL_PARAMETERS_LOCATION = QLatin1String(":/themes/style/hbdefault/variables/layout/zoom/0/hbglobalparameters.css");
       
   153 
       
   154 
       
   155 /*!
       
   156 Constructor
       
   157 */
       
   158 HbStyle::HbStyle() :
       
   159     d_ptr(new HbStylePrivate)
       
   160 {
       
   161     Q_D( HbStyle );
       
   162     d->q_ptr = this;
       
   163     QObject::connect(hbInstance->theme(), SIGNAL(changed()), this, SLOT(_q_onThemeChanged()));
       
   164 }
       
   165 
       
   166 /*!
       
   167 Destructor
       
   168 */
       
   169 HbStyle::~HbStyle()
       
   170 {
       
   171     delete d_ptr;
       
   172 }
       
   173 
       
   174 /*!
       
   175     Registers the style plugin with the Style system. This method can be called by a custom widget
       
   176     or application in order to register the style plugin that implements the custom graphics primitives.
       
   177     This method results in loading of the plugin, if the plugin is registered for the first time.
       
   178     It returns the base ID for the primitives implemented by the style plugin. The custom widget
       
   179     can use the range of integers from (BaseID) to (BaseID+count-1) to refer to the custom
       
   180     primitives, where count is the number of primitives supported by the plugin. The style
       
   181     plugin must return the correct number of primitives when the primitiveCount() method is called.
       
   182     In case of errors the method returns < 0. Note also that for each registerPlugin there must be
       
   183     a unregisterPlugin call, the last unregisterPlugin call for a plugin causes the plugin to be unloaded.
       
   184 
       
   185     If the style plugin implementation returns valid path with layout defition files (CSS+WidgetML)
       
   186     from layoutPath() method the layout definitions CSSs gets read when calling registerPlugin().
       
   187 
       
   188     \param pluginName, name of the Plugin library to be dynamically loaded
       
   189     \return int the base ID to be used for the primitives implemented by the style plugin
       
   190     \sa unregisterPlugin()
       
   191  */
       
   192 int HbStyle::registerPlugin(const QString &pluginName)
       
   193 {
       
   194     Q_D( const HbStyle );
       
   195 
       
   196     // check if the plugin is already registered
       
   197     if (d->registeredPlugins.contains(pluginName)) {
       
   198         // increase the reference count
       
   199         d->registeredPlugins.value(pluginName)->refCount++;
       
   200         // return the base ID of the primitives enumeration
       
   201         return d->registeredPlugins.value(pluginName)->primitiveBaseId;
       
   202     }
       
   203 
       
   204     // load the plugin
       
   205     QPluginLoader* loader = new QPluginLoader(pluginName);
       
   206     if (loader == 0)
       
   207         return -1;
       
   208 
       
   209     // get the instance pointer
       
   210     QObject* pluginInstance = loader->instance();
       
   211     if (pluginInstance == 0) {
       
   212         delete loader;
       
   213 
       
   214         // try the additional paths
       
   215         QFileInfo fileInfo( pluginName );
       
   216         foreach( QString additionalPath, hbInstance->libraryPaths() ) {
       
   217             const QDir pluginDir(additionalPath);
       
   218             loader = new QPluginLoader(pluginDir.absoluteFilePath(fileInfo.fileName()));
       
   219             if ( loader ) {
       
   220                 pluginInstance = loader->instance();
       
   221                 if ( !pluginInstance ) {
       
   222                     delete loader;
       
   223                 } else {
       
   224                     break;
       
   225                 }
       
   226             }
       
   227         }
       
   228 
       
   229         if ( !pluginInstance ) {
       
   230             return -1;
       
   231         }
       
   232     }
       
   233 
       
   234     HbStyleInterface *stylePlugin = qobject_cast<HbStyleInterface *>(pluginInstance);
       
   235 
       
   236     int primitiveCount = stylePlugin->primitiveCount();
       
   237     if (primitiveCount <= 0) {
       
   238         delete pluginInstance;
       
   239         delete loader;
       
   240         return -1;
       
   241     }
       
   242 
       
   243     HbStyleInterfaceInfo* info = new HbStyleInterfaceInfo();
       
   244     info->loader = loader;
       
   245     info->primitiveBaseId = d->nextAvailableId;
       
   246 
       
   247     // make entries for the primitives in the hash table
       
   248     for (int i=d->nextAvailableId; i<(d->nextAvailableId+primitiveCount); i++)
       
   249     {
       
   250         d->customPrimitives.insert(i, info);
       
   251     }
       
   252 
       
   253     // make entry for the plugin in the registered plugins hash table
       
   254     HbStylePluginInfo* pluginInfo = new HbStylePluginInfo();
       
   255     pluginInfo->primitiveBaseId = d->nextAvailableId;
       
   256     pluginInfo->primitiveCount = primitiveCount;
       
   257     pluginInfo->refCount = 1;
       
   258 
       
   259     d->registeredPlugins.insert(pluginName, pluginInfo);
       
   260     d->nextAvailableId += primitiveCount;
       
   261 
       
   262     // register associated style files
       
   263     HbWidgetStyleLoader::instance()->addFilePath(
       
   264         stylePlugin->layoutPath(),
       
   265         HbLayeredStyleLoader::Concern_Layouts, 
       
   266         HbLayeredStyleLoader::Priority_Core);
       
   267     d->pluginStylePaths.insert(pluginName, stylePlugin->layoutPath());
       
   268 
       
   269     return pluginInfo->primitiveBaseId;
       
   270 }
       
   271 
       
   272 
       
   273 /*!
       
   274     Un-registers the style plugin.
       
   275     If the reference count becomes zero, the plugin is unloaded and the primitive IDs are de-registered
       
   276     If a client has called registerPlugin() it must unregister the style plugin with this method.
       
   277 
       
   278     \param pluginName, name of the Plugin library
       
   279  */
       
   280 void HbStyle::unregisterPlugin(const QString &pluginName)
       
   281 {
       
   282     Q_D( const HbStyle );
       
   283     if (d->registeredPlugins.contains(pluginName)) {
       
   284         HbStylePluginInfo *info = d->registeredPlugins.value(pluginName);
       
   285         info->refCount--;
       
   286         // unload plugin and remove from list
       
   287         if (info->refCount == 0) {
       
   288             HbStyleInterfaceInfo* styleInfo = d->customPrimitives.value(info->primitiveBaseId);
       
   289             delete styleInfo->loader->instance();
       
   290             delete styleInfo->loader;
       
   291             delete styleInfo;
       
   292             for (int i=info->primitiveBaseId; i< (info->primitiveBaseId+info->primitiveCount); i++) {
       
   293                   d->customPrimitives.remove(i);
       
   294             }
       
   295             d->registeredPlugins.remove(pluginName);
       
   296 
       
   297 	        // unregister associated style files
       
   298             HbWidgetStyleLoader::instance()->removeFilePath(
       
   299                 d->pluginStylePaths.value(pluginName),
       
   300                 HbLayeredStyleLoader::Concern_Layouts, 
       
   301                 HbLayeredStyleLoader::Priority_Core);
       
   302             d->pluginStylePaths.remove(pluginName);
       
   303 
       
   304             if( d->registeredPlugins.count() == 0 ){
       
   305                 // no plugins loaded, can reset the id counter
       
   306                 d->nextAvailableId = HbStyle::P_CustomBase;
       
   307             }
       
   308 
       
   309         }
       
   310     }
       
   311 }
       
   312 
       
   313 
       
   314 /*!
       
   315   Creates instances of primitive graphics items. This method should be used by all widgets that support styling.
       
   316   When changing the style the returned primitives can be replaced with an altered version of the primitives, or with a completely
       
   317   different primitive, to create a custom appearance. This shouldn't cause changes to the widget if the functional design
       
   318   remains the same.
       
   319 
       
   320   This method returns HbWidgetBase objects. A widget can store the returned items as HbWidgetBase. If a widget
       
   321   does not require any functionality from HbWidgetBase then it should store the primitives as QGraphicsItems.
       
   322 
       
   323   \note This method is used to replace the conventional Qt-style paint indirection via drawPrimitive.
       
   324   \sa HbStyle::updatePrimitive method which is to be used in conjunction with this method
       
   325   \sa HbWidgetBase
       
   326   \param primitive, to identify the primitive to create
       
   327   \param parent of the item
       
   328   \return HbWidgetBase is returned.
       
   329  */
       
   330 QGraphicsItem *HbStyle::createPrimitive( HbStyle::Primitive primitive, QGraphicsItem *parent ) const
       
   331 {
       
   332 
       
   333     Q_D( const HbStyle );
       
   334 
       
   335     if (d->customPrimitives.contains(primitive)) {
       
   336         HbStyleInterfaceInfo* info = d->customPrimitives.value(primitive);
       
   337         QObject* pluginInstance = info->loader->instance();
       
   338         HbStyleInterface *stylePlugin = qobject_cast<HbStyleInterface *>(pluginInstance);
       
   339         return stylePlugin->createPrimitive((HbStyle::Primitive)(primitive-info->primitiveBaseId), parent);
       
   340     }
       
   341 
       
   342         switch (primitive){
       
   343             case P_MenuItem_submenuindicator:
       
   344                 {
       
   345                 HbIconItem *item = new HbIconItem(parent);
       
   346                 setItemName(item, QLatin1String("submenu-indicator"));
       
   347                 return item;
       
   348                 }
       
   349 
       
   350             case P_MenuItem_checkindicator:
       
   351                 {
       
   352                 HbIconItem *item = new HbIconItem(parent);
       
   353                 setItemName(item, QLatin1String("check-indicator"));
       
   354                 return item;
       
   355                 }
       
   356 
       
   357             case P_MenuItem_separator:
       
   358                 {
       
   359                 HbIconItem *item = new HbIconItem(parent);
       
   360                 setItemName(item, QLatin1String("separator"));
       
   361                 return item;
       
   362                 }
       
   363             case P_ToolButton_icon:
       
   364             case P_PushButton_icon:
       
   365 			case P_ProgressDialog_icon:
       
   366             case P_CheckBox_icon:
       
   367             case P_GroupBoxHeading_icon:
       
   368             case P_Label_icon:
       
   369             case P_GridViewItem_icon: {
       
   370                 HbIconItem *item = new HbIconItem(HbIcon(),parent);
       
   371                 setItemName(item, QLatin1String("icon"));
       
   372                 return item; 
       
   373                 }
       
   374             case P_DataGroup_icon:
       
   375                 {
       
   376                 HbIconItem *item = new HbIconItem(HbIcon(), parent);
       
   377                 setItemName(item, QLatin1String("dataGroup_Icon"));
       
   378                 return item; 
       
   379                 }
       
   380             case P_DataItem_icon:
       
   381                 {
       
   382                 HbIconItem *item = new HbIconItem(HbIcon(), parent);
       
   383                 setItemName(item, QLatin1String("dataItem_Icon"));
       
   384                 return item; 
       
   385                 }
       
   386             case P_ComboBox_text:
       
   387                 {
       
   388                     HbTextItem *textItem = new HbTextItem(parent);
       
   389                     setItemName(textItem, QLatin1String("combobox_labelfield"));
       
   390                     return  textItem;
       
   391                 }
       
   392             case P_ToolButton_text:
       
   393             case P_CheckBox_text:
       
   394             case P_ProgressDialog_text:
       
   395             case P_PushButton_text:
       
   396                 {
       
   397                 HbTextItem *ti = new HbTextItem(parent);
       
   398                 setItemName(ti, QLatin1String("text"));
       
   399                 return  ti;
       
   400                 }
       
   401             case P_DataGroup_heading:
       
   402                 {
       
   403                 HbTextItem *ti = new HbTextItem(parent);
       
   404                 setItemName(ti, QLatin1String("dataGroup_HeadingLabel"));
       
   405                 return  ti;
       
   406                 }
       
   407             case P_DataGroup_description:
       
   408                 {
       
   409                 HbTextItem *ti = new HbTextItem(parent);
       
   410                 setItemName(ti, QLatin1String("dataGroup_Description"));
       
   411                 return  ti;
       
   412                 }
       
   413             case P_DataForm_heading:
       
   414                 {
       
   415                 HbTextItem *ti = new HbTextItem(parent);
       
   416                 setItemName(ti, QLatin1String("dataForm_Heading"));
       
   417                 //ti->setZValue(2);
       
   418                 return  ti;
       
   419                 }
       
   420             case P_DataForm_description:
       
   421                 {
       
   422                 HbTextItem *ti = new HbTextItem(parent);
       
   423                 setItemName(ti, QLatin1String("dataForm_Desc"));
       
   424                 return  ti;
       
   425                 }
       
   426             case P_PushButton_additionaltext:
       
   427                 {
       
   428                 HbTextItem *ti = new HbTextItem(parent);
       
   429                 setItemName(ti, QLatin1String("additional-text"));
       
   430                 return  ti;
       
   431                 }
       
   432              case P_ProgressBar_toucharea:
       
   433                 {
       
   434                 HbTouchArea *ta = new HbTouchArea(parent);
       
   435                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
       
   436                 setItemName(ta, QLatin1String("toucharea1"));
       
   437 				ta->setZValue(TOUCHAREA_ZVALUE);
       
   438                 return ta;
       
   439                 }
       
   440 			case P_ProgressSliderHandle_toucharea: 
       
   441                 {
       
   442                 HbTouchArea *ta = new HbTouchArea(parent);
       
   443                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
       
   444                 setItemName(ta, QLatin1String("toucharea"));
       
   445 				ta->setZValue(TOUCHAREA_ZVALUE);
       
   446                 if(parent){
       
   447                     parent->setHandlesChildEvents(true); 
       
   448                 }
       
   449                 return ta;
       
   450                 }
       
   451 
       
   452 			case P_ProgressSlider_handle:
       
   453 			    {
       
   454                 HbIconItem *item = new HbIconItem(QLatin1String("qtg_graf_progslider_handle_normal"), parent);
       
   455 				item->setAspectRatioMode(Qt::IgnoreAspectRatio);
       
   456                 return item;									 
       
   457 				}
       
   458             case P_ProgressSlider_handleicon:{
       
   459                 HbIconItem *item = new HbIconItem(QLatin1String("qtg_mono_play"), parent);
       
   460                 return item;
       
   461                 }
       
   462             case P_PushButton_toucharea: // Generic implementation, can add other cases here
       
   463             case P_CheckBox_toucharea:
       
   464             case P_RatingSlider_toucharea:
       
   465 	        case P_SliderElement_touchhandle: 
       
   466                 {
       
   467                 HbTouchArea *ta = new HbTouchArea(parent);
       
   468                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
       
   469                 setItemName(ta, QLatin1String("toucharea"));
       
   470                 if(parent){
       
   471                     parent->setHandlesChildEvents(true); 
       
   472                 }
       
   473                 return ta;
       
   474                 }
       
   475             case P_ScrollBar_toucharea:
       
   476                 {
       
   477                 HbTouchArea *ta = new HbTouchArea(parent);
       
   478                 ta->setFlags(QGraphicsItem::ItemIsFocusable);
       
   479                 setItemName(ta, QLatin1String("toucharea"));
       
   480                 // NOTE:: This is a temporary fix
       
   481                 //if(parent){
       
   482                 //    parent->setHandlesChildEvents(true); 
       
   483                 //}
       
   484                 return ta;
       
   485                 }
       
   486             case P_ComboBoxButton_toucharea:
       
   487                 {
       
   488                 HbTouchArea *ta = new HbTouchArea(parent);
       
   489                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
       
   490                 setItemName(ta, QLatin1String("combobox_button_toucharea"));
       
   491                 /*if(parent){
       
   492                     parent->setHandlesChildEvents(true); 
       
   493                 }*/
       
   494                 return ta;
       
   495                 }
       
   496              case P_TitleBar_toucharea: {
       
   497                 HbTouchArea *ta = new HbTouchArea(parent);
       
   498                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
       
   499                 setItemName(ta, QLatin1String("toucharea"));
       
   500                 return ta;
       
   501                 }
       
   502              case P_SliderElement_touchdecrease:
       
   503              case P_SliderElement_touchincrease:
       
   504              case P_SliderElement_touchgroove:
       
   505                 {
       
   506                 HbTouchArea *ta = new HbTouchArea(parent);
       
   507                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
       
   508                 if(parent){
       
   509                     //parent->setHandlesChildEvents(true); 
       
   510                 }
       
   511                 return ta;
       
   512                 }
       
   513             case P_SliderElement_text:
       
   514             case P_ProgressBar_text:
       
   515             {
       
   516                 HbTextItem *ti = new HbTextItem(parent);
       
   517                 return  ti;
       
   518             }
       
   519             case P_DataItem_label:
       
   520             {
       
   521                 HbTextItem *ti = new HbTextItem(parent);
       
   522                 setItemName(ti, QLatin1String("dataItem_Label"));
       
   523                 return  ti;
       
   524             }
       
   525             case P_DataItem_description:
       
   526             {
       
   527                 HbTextItem *ti = new HbTextItem(parent);
       
   528                 setItemName(ti, QLatin1String("dataItem_Description"));
       
   529                 return  ti;
       
   530             }
       
   531             case P_ProgressBar_mintext:
       
   532             {
       
   533                 HbTextItem *ti = new HbTextItem(parent);
       
   534                 setItemName(ti, QLatin1String("min-text"));
       
   535                 return  ti;
       
   536             }
       
   537             case P_ProgressBar_maxtext:
       
   538             {
       
   539                 HbTextItem *ti = new HbTextItem(parent);
       
   540                 setItemName(ti, QLatin1String("max-text"));
       
   541                 return  ti;
       
   542             }
       
   543             case P_Label_text: {
       
   544                 HbTextItem *ti = new HbTextItem(parent);
       
   545                 setItemName(ti, QLatin1String("text"));
       
   546                 ti->setAlignment(Qt::AlignCenter);
       
   547                 return ti;
       
   548             }
       
   549                 
       
   550             case P_Label_richtext: 
       
   551             {
       
   552                 HbRichTextItem *rti = new HbRichTextItem(parent);
       
   553                 setItemName(rti, QLatin1String("text"));
       
   554                 return rti;
       
   555             }
       
   556 
       
   557             case P_MenuItem_text:
       
   558                 {
       
   559                 HbTextItem *item = new HbTextItem(parent);
       
   560                 setItemName(item, QLatin1String("text"));
       
   561 
       
   562                 return item;
       
   563                 }
       
   564 
       
   565             case P_Slider_thumb:
       
   566                 return new HbIconItem(parent);
       
   567 
       
   568             case P_MenuItem_frame:
       
   569             case P_MenuItem_focus:
       
   570             case P_ScrollBar_groove:
       
   571             case P_ScrollBar_handle:
       
   572             case P_Slider_groove:
       
   573             case P_Popup_background:
       
   574             case P_Popup_background_weak:
       
   575             case P_Popup_heading_frame:
       
   576             case P_NotificationDialog_frame:
       
   577             case P_ToolTip_background:
       
   578             case P_PushButton_focus:
       
   579             case P_ComboBox_background:
       
   580             case P_ToolBarExtension_background:
       
   581             case P_SliderPopup_background:
       
   582             {
       
   583                 HbFrameItem *n = new HbFrameItem(parent);
       
   584                 n->setZValue(-1);
       
   585                 return n;
       
   586             }
       
   587 
       
   588             case P_ProgressBar_frame:
       
   589             {
       
   590                 HbFrameItem *n = new HbFrameItem(parent);
       
   591                 n->setZValue(-1);
       
   592                 setItemName(n, "frame");
       
   593                 return n;
       
   594             }
       
   595 
       
   596             case P_ComboBoxPopup_background:
       
   597             {
       
   598                 HbFrameItem *n = new HbFrameItem(parent);
       
   599                 n->setZValue(-1);
       
   600 				setItemName(n , "dropdown_background");
       
   601                 return n;
       
   602             }
       
   603 
       
   604             case P_TumbleView_background:
       
   605             case P_TumbleView_frame:
       
   606             case P_DateTimePicker_background:
       
   607             case P_DateTimePicker_frame:
       
   608             {
       
   609                 HbFrameItem *n = new HbFrameItem(parent);
       
   610                 n->setZValue(-5);
       
   611                 return n;
       
   612             }
       
   613             case P_TumbleView_highlight:{
       
   614                 //return new HbIconItem(parent);
       
   615                 return new HbFrameItem(parent);//TODO:make it icon once iconitem setGeomoetry works for tumbleview
       
   616             }
       
   617             case P_DateTimePicker_separator:{
       
   618                 //return new HbIconItem(parent);
       
   619                 HbFrameItem *frameItem= new HbFrameItem(parent);//TODO:make it icon once iconitem setGeomoetry works for tumbleview
       
   620                 frameItem->frameDrawer().setFrameGraphicsName("qtg_graf_tumbler_devider");
       
   621                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
   622                 frameItem->setPreferredWidth(2);
       
   623                 return frameItem;
       
   624             }           
       
   625             case P_DataGroup_background :
       
   626             {
       
   627                 HbFrameItem *n = new HbFrameItem(parent);
       
   628                 n->setZValue(-1);
       
   629                 setItemName(n, QLatin1String("dataGroup_Background"));
       
   630                 return n;
       
   631             }
       
   632             case P_DataGroupComboBackground:
       
   633             {
       
   634                 HbFrameItem *n = new HbFrameItem(parent);
       
   635                 n->setZValue(-1);
       
   636                 setItemName(n, QLatin1String("dataGroup_ComboBackground"));
       
   637                 return n;
       
   638             }
       
   639             case P_DataForm_heading_background :
       
   640             {
       
   641                 HbFrameItem *n = new HbFrameItem(parent);
       
   642                 n->setZValue(-1);
       
   643                 setItemName(n, QLatin1String("dataFormHeading_Background"));
       
   644                 return n;
       
   645             }
       
   646             case P_DataItem_background:
       
   647             {
       
   648                 HbFrameItem *n = new HbFrameItem(parent);
       
   649                 n->setZValue(-2);
       
   650                 setItemName(n, QLatin1String("dataItem_Background"));
       
   651                 return n;
       
   652             }
       
   653             case P_GroupBoxContent_background:
       
   654             case P_GroupBoxHeading_background:
       
   655             case P_PushButton_background:
       
   656             {
       
   657                 HbFrameItem *n = new HbFrameItem(parent);
       
   658                 n->setZValue(-1);
       
   659                 setItemName(n, QLatin1String("background"));
       
   660                 return n;
       
   661             }
       
   662             case P_ProgressBar_track:
       
   663             {
       
   664                 HbProgressTrackItem *n = new HbProgressTrackItem(parent);
       
   665                 n->setZValue(-2);
       
   666                 return n;
       
   667             }
       
   668             case P_ProgressBar_slidertrack:
       
   669             {
       
   670                 HbProgressTrackItem *n = new HbProgressTrackItem(parent);
       
   671                 n->setZValue(-1);
       
   672                 return n;
       
   673             }        
       
   674             case P_Slider_progressgroove:
       
   675             {
       
   676                 HbSliderTrackItem *n=new HbSliderTrackItem(parent);
       
   677                 n->setZValue(0);
       
   678                 return n;
       
   679             }
       
   680             case P_ToolButton_frame:
       
   681             {
       
   682                 HbFrameItem *n = new HbFrameItem(parent);
       
   683                 n->setZValue(-1);
       
   684                 setItemName(n, QLatin1String("background"));
       
   685                 return n;
       
   686             }
       
   687             case P_Softkey_background:  // deprecated
       
   688             case P_NavigationButton_background:
       
   689             case P_IndicatorButton_background:
       
   690             case P_IndicatorGroup_background:   // deprecated
       
   691             {
       
   692                 HbIconItem *n = new HbIconItem(HbIcon(), parent);
       
   693                 n->setZValue(-1);
       
   694                 setItemName(n, QLatin1String("background"));
       
   695                 return n;
       
   696             }
       
   697             case P_IndicatorButton_handleindication:
       
   698             {
       
   699                 HbIconItem *n = new HbIconItem(parent);
       
   700                 setItemName(n, QLatin1String("handleindication"));
       
   701                 return n;
       
   702             }
       
   703             case P_IndicatorGroup_icon1:
       
   704             {
       
   705                 HbIconItem *n = new HbIconItem(parent);
       
   706                 n->setFlags(HbIcon::Colorized);
       
   707                 setItemName(n, QLatin1String("icon1"));
       
   708                 return n;
       
   709             }
       
   710             case P_IndicatorGroup_icon2:
       
   711             {
       
   712                 HbIconItem *n = new HbIconItem(parent);
       
   713                 n->setFlags(HbIcon::Colorized);
       
   714                 setItemName(n, QLatin1String("icon2"));
       
   715                 return n;
       
   716             }
       
   717             case P_IndicatorGroup_icon3:
       
   718             {
       
   719                 HbIconItem *n = new HbIconItem(parent);
       
   720                 n->setFlags(HbIcon::Colorized);
       
   721                 setItemName(n, QLatin1String("icon3"));
       
   722                 return n;
       
   723             }
       
   724             case P_IndicatorGroup_icon4:
       
   725             {
       
   726                 HbIconItem *n = new HbIconItem(parent);
       
   727                 n->setFlags(HbIcon::Colorized);
       
   728                 setItemName(n, QLatin1String("icon4"));
       
   729                 return n;
       
   730             }
       
   731             case P_IndicatorGroup_signalicon: // deprecated
       
   732             case P_SignalIndicator_icon:
       
   733             {
       
   734                 HbIconItem *n = new HbIconItem(parent);
       
   735                 n->setFlags(HbIcon::Colorized);
       
   736                 setItemName(n, QLatin1String("icon"));
       
   737                 return n;
       
   738             }
       
   739             case P_SignalLevel_background:
       
   740             {
       
   741                 HbIconItem *n = new HbIconItem(parent);
       
   742                 n->setZValue(-1);
       
   743                 setItemName(n, QLatin1String("background"));
       
   744                 return n;
       
   745             }
       
   746             case P_SignalLevel_icon:
       
   747             {
       
   748                 HbIndicatorLevelIconItem *n = new HbIndicatorLevelIconItem(parent);
       
   749                 setItemName(n, QLatin1String("levelicon"));
       
   750                 return n;
       
   751             }
       
   752             case P_IndicatorGroup_batteryicon: // deprecated
       
   753             case P_BatteryIndicator_icon:
       
   754             {
       
   755                 HbIconItem *n = new HbIconItem(parent);
       
   756                 n->setFlags(HbIcon::Colorized);
       
   757                 setItemName(n, QLatin1String("icon"));
       
   758                 return n;
       
   759             }
       
   760             case P_BatteryLevel_background:
       
   761             {
       
   762                 HbIconItem *n = new HbIconItem(parent);
       
   763                 n->setZValue(-1);
       
   764                 setItemName(n, QLatin1String("background"));
       
   765                 return n;
       
   766             }
       
   767             case P_BatteryLevel_icon:
       
   768             {
       
   769                 HbIndicatorLevelIconItem *n = new HbIndicatorLevelIconItem(parent);
       
   770                 setItemName(n, QLatin1String("levelicon"));
       
   771                 return n;
       
   772             }
       
   773             case P_TitlePane_background:
       
   774                 {
       
   775                     HbFrameItem *n = new HbFrameItem(parent);
       
   776                     n->setZValue(-1);
       
   777                     setItemName(n, QLatin1String("frame"));
       
   778                     return n;
       
   779                 }
       
   780             case P_LineEdit_frame_normal:
       
   781             case P_LineEdit_frame_highlight:
       
   782             case P_TextEdit_frame_normal:
       
   783             case P_TextEdit_frame_highlight:
       
   784             {
       
   785                 HbFrameItem *n = new HbFrameItem(parent);
       
   786                 n->setZValue(-1);
       
   787                 return n;
       
   788             }            
       
   789             case P_GroupBoxMarquee_text:
       
   790             case P_TitlePane_text:
       
   791             {
       
   792                 HbMarqueeItem *n = new HbMarqueeItem(parent);
       
   793                 setItemName(n, QLatin1String("text"));
       
   794                 return n;
       
   795             }
       
   796             case P_TitlePane_icon:
       
   797             {
       
   798                 HbIconItem *n = new HbIconItem(parent);
       
   799                 setItemName(n, QLatin1String("icon"));
       
   800                 return n;
       
   801             }
       
   802             case P_StatusBar_background:
       
   803             {
       
   804                 HbFrameItem *n = new HbFrameItem(parent);
       
   805                 n->setZValue(-1);
       
   806                 setItemName(n, QLatin1String("statusbar"));
       
   807                 return n;
       
   808 			}
       
   809             case P_StatusBar_timetext:
       
   810             {
       
   811                 HbTextItem *textItem = new HbTextItem(parent);
       
   812                 setItemName(textItem, QLatin1String("timetext"));
       
   813                 textItem->setAlignment(Qt::AlignCenter);
       
   814                 return textItem;
       
   815             }
       
   816             case P_Fade_background:
       
   817                 return new HbIconItem(QString(), parent);
       
   818             case P_SliderElement_icon:
       
   819             case P_SliderElement_increase:
       
   820             case P_SliderElement_decrease:
       
   821                 return new HbIconItem(QString(), parent);
       
   822 
       
   823             case P_SliderTickMark_majoricon: {
       
   824                 HbIconItem *iconItem = new HbIconItem(parent);
       
   825                 setItemName(iconItem,QLatin1String("tickmark-majoricon"));
       
   826                 return iconItem;
       
   827             }
       
   828             case P_SliderTickMark_minoricon: {
       
   829                 HbIconItem *iconItem = new HbIconItem(parent);
       
   830                 setItemName(iconItem,QLatin1String("tickmark-minoricon"));
       
   831                 return iconItem;
       
   832             }
       
   833             case P_SliderTickMark_majorlabel: {
       
   834                 HbTextItem *textItem = new HbTextItem(parent);
       
   835                 setItemName(textItem,QLatin1String("tickmark-majorlabel"));
       
   836                 return textItem;
       
   837             }
       
   838             case P_SliderTickMark_minorlabel: {
       
   839                 HbTextItem *textItem = new HbTextItem(parent);
       
   840                 setItemName(textItem,QLatin1String("tickmark-minorlabel"));
       
   841                 return textItem;
       
   842             }
       
   843 
       
   844 
       
   845             case P_ProgressBar_waittrack:
       
   846                 return new HbRepeatIconItem(QLatin1String("qtg_fr_progbar_wait"), parent);
       
   847 
       
   848             case P_RatingSlider_frame:
       
   849                 return  new HbRepeatItem(parent);
       
   850 
       
   851             case P_RatingSlider_track:
       
   852                 return new HbRepeatMaskItem(parent);
       
   853             
       
   854 			case P_RatingSlider_layout:
       
   855                 return new HbWidgetBase(parent);
       
   856 
       
   857             case P_ItemViewItem_checkbox: {
       
   858                 qDebug() << "Primitive P_ItemViewItem_checkbox is deprecated and will cease to exist in the near future.";
       
   859                 HbIconItem *iconItem = new HbIconItem(parent);
       
   860                 setItemName(iconItem, QLatin1String("checkbox-icon"));
       
   861                 return iconItem;
       
   862             }
       
   863 
       
   864             case P_ItemViewItem_radiobutton:
       
   865             case P_ItemViewItem_selection: {
       
   866                 HbIconItem *iconItem = new HbIconItem(parent);
       
   867                 setItemName(iconItem, QLatin1String("selection-icon"));
       
   868                 return iconItem;
       
   869             }
       
   870 
       
   871             case P_Edit_text:{
       
   872                 return 0;
       
   873             }
       
   874             case P_GroupBoxHeading_text:
       
   875             case P_NotificationDialog_text:{
       
   876                 HbTextItem *n = new HbTextItem(parent);
       
   877                 setItemName(n, QLatin1String("text"));
       
   878                 return n;
       
   879             }
       
   880             case P_NotificationDialog_title:{
       
   881                 HbTextItem *n = new HbTextItem(parent);
       
   882                 setItemName(n, QLatin1String("title"));
       
   883                 return n;
       
   884             }
       
   885             case P_NotificationDialog_icon:{
       
   886                 HbIconItem *n = new HbIconItem(QString(), parent);
       
   887                 setItemName(n, QLatin1String("icon"));
       
   888                 return n;
       
   889             }
       
   890             case P_MessageBox_text:{
       
   891                 HbTextItem *rti = new HbTextItem(parent);
       
   892                 return rti;
       
   893             }
       
   894             case P_MessageBox_icon:{
       
   895                 HbIconItem *n = new HbIconItem(QString(), parent);
       
   896                 return n;
       
   897             }
       
   898 
       
   899             case P_ItemViewItem_background: {
       
   900                 HbIconItem *iconItem = new HbIconItem(parent);
       
   901                 setItemName(iconItem, QLatin1String("background"));
       
   902                 return iconItem;
       
   903             }
       
   904 
       
   905             case P_ListViewItem_text: {
       
   906                 HbTextItem *textItem = new HbTextItem(parent);
       
   907                 textItem->setMinimumLines(1);
       
   908                 textItem->setMaximumLines(1);
       
   909                 textItem->setTextWrapping(Hb::TextNoWrap);
       
   910                 return textItem;
       
   911             }
       
   912 
       
   913             case P_ListViewItem_richtext: {
       
   914                 HbRichTextItem *textItem = new HbRichTextItem(parent);
       
   915                 return textItem;
       
   916             }
       
   917 
       
   918             case P_GridViewItem_text: {
       
   919                 HbTextItem *textItem = new HbTextItem(parent);
       
   920                 // caching do not work properly - text is not refreshed immediatelly
       
   921                 //textItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
       
   922                 setItemName(textItem, QLatin1String("text"));
       
   923                 textItem->setMinimumLines(1);
       
   924                 textItem->setMaximumLines(1);
       
   925                 textItem->setTextWrapping(Hb::TextNoWrap);
       
   926                 textItem->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
       
   927                 return textItem;
       
   928             }
       
   929 
       
   930             case P_ListViewItem_icon:
       
   931                 return new HbIconItem(parent);
       
   932 
       
   933             case P_ColorGridViewItem_colorIcon:
       
   934                 return new HbIconItem("qtg_graf_colorpicker_mask", parent);
       
   935             case P_ColorGridViewItem_borderIcon:
       
   936                 return new HbIconItem("qtg_graf_colorpicker_filled", parent);
       
   937             case P_ColorGridViewItem_checkIcon:
       
   938                 return new HbIconItem("qtg_small_tick", parent); // TODO: likely wrong
       
   939 
       
   940             case P_TreeViewItem_expandicon: {
       
   941                 HbIconItem *iconItem = new HbIconItem(parent);
       
   942                 setItemName(iconItem, QLatin1String("subitem-indicator"));
       
   943                 return iconItem;
       
   944             }
       
   945 
       
   946             case P_SelectionControl_selectionstart://fallthrough
       
   947             case P_SelectionControl_selectionend://fallthrough
       
   948             {
       
   949                 HbIconItem *iconItem = new HbIconItem(parent);
       
   950                 switch (primitive) {
       
   951                     case P_SelectionControl_selectionstart:
       
   952                         iconItem->setIconName(QLatin1String("qtg_graf_editor_handle_begin"));
       
   953                         break;
       
   954                     case P_SelectionControl_selectionend:
       
   955                         iconItem->setIconName(QLatin1String("qtg_graf_editor_handle_end"));
       
   956                         break;
       
   957                     default:
       
   958                         qWarning("Unknown HbSelectionControl primitive %i", primitive);
       
   959                         break;
       
   960                 }
       
   961                 setItemName(iconItem, QLatin1String("handle-icon"));
       
   962                 return iconItem;
       
   963             }
       
   964             case P_ComboBox_button: {
       
   965                 HbIconItem *n = new HbIconItem(QString(), parent);
       
   966                 return n;
       
   967             }
       
   968             case P_ItemViewItem_focus: {
       
   969                 HbFrameItem *item = new HbFrameItem(parent);
       
   970                 setItemName(item, QLatin1String("focus-indicator"));
       
   971                 return item;
       
   972             }
       
   973             case P_ItemHighlight_background: 
       
   974                 return new HbFrameItem(parent);
       
   975 
       
   976             case P_ItemViewItem_frame: {
       
   977                 HbFrameItem *item = new HbFrameItem(parent);
       
   978                 setItemName(item,"frame");
       
   979                 return item;
       
   980             }
       
   981             case P_ScrollArea_continuationbottom:
       
   982             {
       
   983                 HbFrameItem *n = new HbFrameItem(parent);
       
   984                 setItemName(n, QLatin1String("continuation-indicator-bottom"));
       
   985                 n->setZValue(-1);
       
   986                 return n;
       
   987             }
       
   988             case P_ScrollArea_continuationtop:
       
   989             {
       
   990                 HbFrameItem *n = new HbFrameItem(parent);
       
   991                 setItemName(n, QLatin1String("continuation-indicator-top"));
       
   992                 n->setZValue(-1);
       
   993                 return n;
       
   994             }
       
   995             case P_ScrollArea_continuationleft:
       
   996             {
       
   997                 HbFrameItem *n = new HbFrameItem(parent);
       
   998                 setItemName(n, QLatin1String("continuation-indicator-left"));
       
   999                 n->setZValue(-1);
       
  1000                 return n;
       
  1001             }
       
  1002             case P_ScrollArea_continuationright:
       
  1003                 {
       
  1004                 HbFrameItem *n = new HbFrameItem(parent);
       
  1005                 setItemName(n, QLatin1String("continuation-indicator-right"));
       
  1006                 n->setZValue(-1);
       
  1007                 return n;
       
  1008             }
       
  1009             case P_ItemViewItem_touchmultiselection:
       
  1010             {
       
  1011                 HbTouchArea *area = new HbTouchArea(parent);
       
  1012                 setItemName(area, "multiselection-toucharea");
       
  1013                 return area;
       
  1014             }
       
  1015             case P_IndexFeedback_popup_text:
       
  1016             {
       
  1017                 HbTextItem *textItem = new HbTextItem(parent);
       
  1018                 textItem->setAlignment(Qt::AlignCenter);
       
  1019                 textItem->setTextWrapping(Hb::TextNoWrap);
       
  1020                 setItemName(textItem, QLatin1String("index-text"));
       
  1021 
       
  1022                 //TODO:: make this a sane value
       
  1023                 textItem->setZValue(4);
       
  1024                 return textItem;
       
  1025             }
       
  1026             case P_IndexFeedback_popup_background:
       
  1027             {
       
  1028                 HbFrameItem *n = new HbFrameItem(parent);
       
  1029                 n->frameDrawer().setFrameGraphicsName("qtg_fr_popup_preview");
       
  1030                 n->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1031                 qreal cornerPieceSize = 0;
       
  1032                 parameter(QLatin1String("hb-param-background-popup-preview"),cornerPieceSize);
       
  1033                 n->frameDrawer().setBorderWidths(cornerPieceSize, cornerPieceSize);
       
  1034                 setItemName(n, QLatin1String("index-background"));
       
  1035                 n->setZValue(3);
       
  1036                 return n;
       
  1037             }
       
  1038             case P_InputDialog_text:
       
  1039             {
       
  1040                 HbTextItem *n = new HbTextItem(parent);
       
  1041                 setItemName(n, QLatin1String("label-1"));
       
  1042                 return n;
       
  1043             }
       
  1044             case P_InputDialog_additional_text:
       
  1045             {
       
  1046                 HbTextItem *n = new HbTextItem(parent);
       
  1047                 setItemName(n, QLatin1String("label-2"));
       
  1048                 return n;
       
  1049             }
       
  1050             default:
       
  1051                 return 0;
       
  1052         }
       
  1053 }
       
  1054 
       
  1055 /*!
       
  1056   Updates the state and content of widget's child primitives. Update for a styled primitive should happen always when
       
  1057   a state change that affects drawing occurs. Such a situation can be for example pressing of a button (change background image), or 
       
  1058   changing a text for a widget having text content. The updatePrimitive() implementation for each primitive element can be considered 
       
  1059   as a part of widget's implementation. Note that it's up to the widget to decide what the styleoption contains and what the updatePrimitive() method 
       
  1060   uses the styleoption data for.
       
  1061   
       
  1062   \sa HbStyle::createPrimitive
       
  1063   \param item Primitive graphicsitem.
       
  1064   \param primitive To identify the primitive to create.
       
  1065   \param option Style option, contains all the information needed to update the primitive, this
       
  1066   information is widget specific and each widget usually has a styleoption. Styleoption may include
       
  1067   information about the widget's state, content etc.
       
  1068  */
       
  1069 void HbStyle::updatePrimitive( QGraphicsItem *item, HbStyle::Primitive primitive, const QStyleOption *option ) const
       
  1070 {
       
  1071     Q_D( const HbStyle );
       
  1072 
       
  1073     if (d->customPrimitives.contains(primitive)) {
       
  1074         HbStyleInterfaceInfo* info = d->customPrimitives.value(primitive);
       
  1075         QObject* pluginInstance = info->loader->instance();
       
  1076         HbStyleInterface *stylePlugin = qobject_cast<HbStyleInterface *>(pluginInstance);
       
  1077         return stylePlugin->updatePrimitive(item, (HbStyle::Primitive)(primitive-info->primitiveBaseId), option);
       
  1078     }
       
  1079 
       
  1080     switch(primitive){
       
  1081             case P_PushButton_icon:
       
  1082                 {
       
  1083                     if (const HbStyleOptionPushButton *opt = 
       
  1084                         qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
       
  1085                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1086                         //iconItem->setIconName(opt->icon.iconName());
       
  1087                         iconItem->setIcon(opt->icon); // with this call iconitem refresh issue is there 
       
  1088                         iconItem->setMode(d->iconMode(opt->state));
       
  1089                         iconItem->setState(d->iconState(opt->state));
       
  1090                     }
       
  1091                 break;
       
  1092                 }
       
  1093             case P_GroupBoxHeading_icon:
       
  1094                 {
       
  1095                     if (const HbStyleOptionGroupBox *opt = 
       
  1096                         qstyleoption_cast<const HbStyleOptionGroupBox*>(option)) {
       
  1097                             HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1098                             if (opt->collapsed) {
       
  1099                                 iconItem->setIconName(QLatin1String("qtg_small_collapse"));
       
  1100                             } else {
       
  1101                                 iconItem->setIconName(QLatin1String("qtg_small_expand"));
       
  1102                             }
       
  1103                     }
       
  1104                     break;
       
  1105                 }
       
  1106             case P_DataGroup_icon:
       
  1107                 {
       
  1108                     if (const HbStyleOptionDataGroupHeadingWidget *opt = 
       
  1109                             qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget*>(option)) {
       
  1110                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1111                         if (opt->expanded) {
       
  1112                             iconItem->setIconName(QLatin1String("qtg_small_expand"));
       
  1113                         } else {
       
  1114                             iconItem->setIconName(QLatin1String("qtg_small_collapse"));
       
  1115                         }
       
  1116                     }
       
  1117                 break;
       
  1118                 }
       
  1119             case P_DataItem_icon:
       
  1120                 {
       
  1121                     const HbStyleOptionDataFormViewItem *opt = qstyleoption_cast<const HbStyleOptionDataFormViewItem *>(option);
       
  1122                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1123                     iconItem->setIcon(opt->icon);
       
  1124                     break;
       
  1125                 }
       
  1126             case P_Label_icon:
       
  1127                 if (const HbStyleOptionLabel *opt = qstyleoption_cast<const HbStyleOptionLabel*>(option)) {
       
  1128                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1129                     iconItem->setIcon(opt->icon);
       
  1130                     if (!opt->icon.isNull()) {
       
  1131                         iconItem->setMode(d->iconMode(opt->state));
       
  1132                         iconItem->setState(d->iconState(opt->state));
       
  1133                         iconItem->setAspectRatioMode(opt->aspectRatioMode);
       
  1134                         iconItem->setAlignment(opt->alignment);
       
  1135                     }
       
  1136                 }
       
  1137                 break;
       
  1138             case P_ToolButton_icon:
       
  1139                 if (const HbStyleOptionToolButton *opt = qstyleoption_cast<const HbStyleOptionToolButton*>(option)) {
       
  1140                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1141                     iconItem->setIcon(opt->icon);
       
  1142                     iconItem->setMode(d->iconMode(opt->state));
       
  1143                     iconItem->setState(d->iconState(opt->state));
       
  1144                 }
       
  1145                 break;
       
  1146             case P_ComboBox_text:
       
  1147                 if (const HbStyleOptionComboBox *opt = qstyleoption_cast<const HbStyleOptionComboBox*>(option)) {
       
  1148                     HbTextItem *comboTextItem = static_cast<HbTextItem*>(item);
       
  1149                     comboTextItem->setText(opt->text);
       
  1150                 }
       
  1151                 break;                
       
  1152             case P_PushButton_text:
       
  1153                 {
       
  1154                     if (const HbStyleOptionPushButton *opt = 
       
  1155                         qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
       
  1156                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1157                         textItem->setText(opt->text);
       
  1158                         //default alignment will come from css,
       
  1159                         //if api flag is set ,then alignment from style is taken.
       
  1160                         if (opt->hasTextAlignment) {
       
  1161                             textItem->setAlignment( opt->textAlignment );                                           
       
  1162                         }                        
       
  1163                         textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  1164                     }
       
  1165                 }
       
  1166                 break;
       
  1167             case P_ProgressDialog_text:
       
  1168                  {
       
  1169                    if (const HbStyleOptionProgressDialog *opt = 
       
  1170 					   qstyleoption_cast<const HbStyleOptionProgressDialog*>(option)) {
       
  1171                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1172                         textItem->setAlignment( opt->textAlignment );
       
  1173 						if (opt->wrap) {
       
  1174 							textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  1175 						 } else {
       
  1176 							 textItem->setTextWrapping(Hb::TextNoWrap);
       
  1177 						}
       
  1178                         textItem->setText(opt->text);						
       
  1179                     }
       
  1180                 break;
       
  1181                 }
       
  1182             case P_PushButton_additionaltext:
       
  1183                 {
       
  1184                     if (const HbStyleOptionPushButton *opt = 
       
  1185                             qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
       
  1186                         HbTextItem *additionalTextItem = static_cast<HbTextItem*>(item);
       
  1187                         additionalTextItem->setText(opt->additionalText);
       
  1188                         //default alignment will come from css,
       
  1189                         //if api flag is set ,then alignment from style is taken.
       
  1190                         if (opt->hasAdditionalTextAlignment) {
       
  1191                             additionalTextItem->setAlignment( opt->additionalTextAlignment );                       
       
  1192                         }                       
       
  1193                         additionalTextItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  1194                     }                    
       
  1195                 }
       
  1196                 break;
       
  1197             case P_PushButton_toucharea:  // Generic implementation, can add other cases here
       
  1198             case P_ComboBoxButton_toucharea:
       
  1199             case P_CheckBox_toucharea:
       
  1200             case P_TitleBar_toucharea:
       
  1201             case P_SliderElement_touchdecrease:
       
  1202             case P_SliderElement_touchincrease:
       
  1203             case P_SliderElement_touchgroove:
       
  1204             case P_SliderElement_touchhandle:
       
  1205             case P_ScrollBar_toucharea:
       
  1206                 {
       
  1207                     HbTouchArea *touchArea = static_cast<HbTouchArea*>(item);
       
  1208                     touchArea->setZValue(TOUCHAREA_ZVALUE);
       
  1209                 }
       
  1210                 break;
       
  1211             case P_DataGroup_heading:
       
  1212                 {
       
  1213                    if (const HbStyleOptionDataGroupHeadingWidget *opt = 
       
  1214                         qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget*>(option)) {
       
  1215                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1216                         textItem->setText(opt->heading);
       
  1217                     }
       
  1218                 break;
       
  1219                 }
       
  1220             case P_DataGroup_description:
       
  1221                 {
       
  1222                    if (const HbStyleOptionDataGroup *opt = 
       
  1223                         qstyleoption_cast<const HbStyleOptionDataGroup*>(option)) {
       
  1224                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1225                         textItem->setText(opt->description);
       
  1226                     }
       
  1227                 break;
       
  1228                 }
       
  1229             case P_DataForm_heading:
       
  1230                 {
       
  1231                    if (const HbStyleOptionDataForm *opt = 
       
  1232                         qstyleoption_cast<const HbStyleOptionDataForm*>(option)) {
       
  1233                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1234                         textItem->setText(opt->heading);
       
  1235                     }
       
  1236                 break;
       
  1237                 }
       
  1238             case P_DataForm_description:
       
  1239                 {
       
  1240                    if (const HbStyleOptionDataForm *opt = 
       
  1241                         qstyleoption_cast<const HbStyleOptionDataForm*>(option)) {
       
  1242                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1243                         HbFontSpec spec(HbFontSpec::Secondary);
       
  1244                         QFont descriptionFont = spec.font();
       
  1245                         descriptionFont.setItalic(true);
       
  1246                         textItem->setFont(descriptionFont);
       
  1247                         textItem->setText(opt->description);
       
  1248                     }
       
  1249                 break;
       
  1250                 }
       
  1251 
       
  1252             case P_DataForm_heading_background: {
       
  1253                 HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1254                 if(!frameItem){
       
  1255                     return;
       
  1256                 }
       
  1257                 frameItem->setZValue(-1.0);
       
  1258                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_form_heading"));
       
  1259                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1260                 break;
       
  1261             }
       
  1262             case P_ToolButton_text:
       
  1263                 if (const HbStyleOptionToolButton *opt = qstyleoption_cast<const HbStyleOptionToolButton*>(option)) {
       
  1264                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1265                     textItem->setText(opt->text);
       
  1266                 }
       
  1267                 break;
       
  1268             case P_ProgressBar_text: {
       
  1269                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {
       
  1270                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1271                     textItem->setAlignment(Qt::AlignCenter);
       
  1272                     textItem->setZValue(100);
       
  1273                     textItem->setText(opt->text);
       
  1274                 }
       
  1275                 break;
       
  1276             }
       
  1277             case P_DataGroup_background: {
       
  1278                 if (const HbStyleOptionDataGroupHeadingWidget *opt = 
       
  1279                     qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget *>(option)) {
       
  1280                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1281 	                if(!frameItem){
       
  1282 	                    return;
       
  1283 	                }
       
  1284                     frameItem->setZValue(-1.0);
       
  1285                     if(opt->pressed) {
       
  1286                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_pressed"));
       
  1287                     } else {
       
  1288                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_parent_normal"));
       
  1289                     }
       
  1290                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1291                     frameItem->setGeometry(opt->rect);
       
  1292                 }
       
  1293                 break;
       
  1294             }
       
  1295             case P_DataGroupComboBackground: {
       
  1296                 HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1297                 if(!frameItem){
       
  1298                     return;
       
  1299                 }
       
  1300                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_parent_normal"));
       
  1301                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1302                 break;
       
  1303             }
       
  1304 
       
  1305             case P_GroupBoxHeading_background: {
       
  1306                 if (const HbStyleOptionGroupBox *opt = qstyleoption_cast<const HbStyleOptionGroupBox *>(option)) {
       
  1307                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1308                 
       
  1309                     if(!frameItem){
       
  1310                         return;
       
  1311                     }
       
  1312                     QString frameGraphicsName;
       
  1313                     if(opt->groupBoxType == HbStyleOptionGroupBox::GroupBoxSimpleLabel)
       
  1314                         frameGraphicsName = QLatin1String("qtg_fr_groupbox");
       
  1315                     else if(opt->groupBoxType == HbStyleOptionGroupBox::GroupBoxCollapsingContainer){
       
  1316                         if (opt->state == QStyle::State_On) {
       
  1317                             frameGraphicsName = QLatin1String("qtg_fr_list_pressed");
       
  1318                         } else if (opt->state == QStyle::State_Off) {
       
  1319                             frameGraphicsName = QLatin1String("qtg_fr_list_parent_normal");
       
  1320                         } else {
       
  1321                             frameGraphicsName = QLatin1String("qtg_fr_list_highlight");
       
  1322                         }
       
  1323                     }
       
  1324                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); 
       
  1325                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
       
  1326                 }
       
  1327                 break;
       
  1328             }
       
  1329 
       
  1330             case P_GroupBoxContent_background: {
       
  1331                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  1332                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1333                 
       
  1334                     if(!frameItem){
       
  1335                         return;
       
  1336                     }
       
  1337 
       
  1338                     QString frameGraphicsName;
       
  1339                     if (opt->state == QStyle::State_On) {
       
  1340                         frameGraphicsName = QLatin1String("qtg_fr_groupbox_pressed");
       
  1341                     } else if (opt->state == QStyle::State_Off) {
       
  1342                         frameGraphicsName = QLatin1String("qtg_fr_groupbox_normal");
       
  1343                     } else {
       
  1344                         frameGraphicsName = QLatin1String("qtg_fr_groupbox_highlight");
       
  1345                     }
       
  1346                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); 
       
  1347                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
       
  1348                 }
       
  1349                 break;
       
  1350             }
       
  1351             
       
  1352             case P_DataItem_background: {
       
  1353                 HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1354                 if(!frameItem){
       
  1355                     return;
       
  1356                 }
       
  1357 
       
  1358                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_normal"));
       
  1359                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1360                 break;
       
  1361             }
       
  1362             case P_DataItem_label: {
       
  1363                 if (const HbStyleOptionDataFormViewItem *opt = qstyleoption_cast<const HbStyleOptionDataFormViewItem *>(option)) {
       
  1364                     HbTextItem *textitem = static_cast<HbTextItem*>( item );
       
  1365                     textitem->setText(opt->label);
       
  1366                 }
       
  1367                 break;
       
  1368             }
       
  1369             case P_DataItem_description: {
       
  1370                 if (const HbStyleOptionDataFormViewItem *opt = qstyleoption_cast<const HbStyleOptionDataFormViewItem *>(option)) {
       
  1371                     HbTextItem *textitem = static_cast<HbTextItem*>( item );
       
  1372                     textitem->setText(opt->description);
       
  1373                 }
       
  1374                 break;
       
  1375             }
       
  1376             case P_PushButton_background: {
       
  1377                 if (const HbStyleOptionPushButton *opt = 
       
  1378                     qstyleoption_cast<const HbStyleOptionPushButton *>(option)) {
       
  1379                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1380                     QString frameGraphicsName;
       
  1381                     QIcon::Mode mode = QIcon::Disabled;
       
  1382                     QIcon::State state = QIcon::Off;
       
  1383                     if (opt->state & QStyle::State_Enabled)
       
  1384                         mode = QIcon::Normal;
       
  1385                     if (opt->state & QStyle::State_Active)
       
  1386                         mode = QIcon::Active;
       
  1387                     if (opt->state & QStyle::State_Selected)
       
  1388                         mode = QIcon::Selected;
       
  1389                     if (opt->state & QStyle::State_On)
       
  1390                         state = QIcon::On;
       
  1391 
       
  1392                     frameItem->setZValue(-1.0);
       
  1393                     if(opt->backgroundFrameDrawer &&!(opt->backgroundFrameDrawer->isNull()))
       
  1394                     {
       
  1395                         frameItem->setFrameDrawer(opt->backgroundFrameDrawer);
       
  1396                     }
       
  1397                     else if (!opt->background.isNull()) {
       
  1398                         QString customName = opt->background.iconName(mode, state);
       
  1399                         frameItem->frameDrawer().setFrameGraphicsName(customName);
       
  1400                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  1401                         break;
       
  1402                     }
       
  1403                     else{
       
  1404                         if (mode == QIcon::Disabled && state == QIcon::Off) {
       
  1405                             frameGraphicsName = QLatin1String("qtg_fr_btn_disabled");
       
  1406                         } else if (mode == QIcon::Normal && state == QIcon::On) {
       
  1407                             if(!opt->isCheckable){
       
  1408                                 frameGraphicsName = QLatin1String("qtg_fr_btn_pressed");
       
  1409                             } else {
       
  1410                                 frameGraphicsName = QLatin1String("qtg_fr_btn_latched");
       
  1411                             }
       
  1412                         } else if (mode == QIcon::Selected && state == QIcon::Off) {
       
  1413                             frameGraphicsName = QLatin1String("qtg_fr_btn_highlight");
       
  1414                         } else {
       
  1415                             frameGraphicsName = QLatin1String("qtg_fr_btn_normal");
       
  1416                         }
       
  1417                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
       
  1418                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1419                     }
       
  1420                 }
       
  1421                 break;
       
  1422             }
       
  1423 
       
  1424             case P_TitlePane_background:{
       
  1425                 const HbStyleOptionTitlePane *opt = qstyleoption_cast<const HbStyleOptionTitlePane *>(option);
       
  1426 
       
  1427                 if (opt) {
       
  1428                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1429                     frameItem->frameDrawer().setFillWholeRect(true);
       
  1430                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  1431                     if (opt->mode == QIcon::Active) {
       
  1432                         if (opt->transparent) {
       
  1433                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_titlebar_trans_pressed"));
       
  1434                         } else {
       
  1435                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_titlebar_pressed"));
       
  1436                         }
       
  1437                     } else if (opt->mode == QIcon::Selected) {
       
  1438                         if (opt->transparent) {
       
  1439                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_titlebar_trans_latched"));
       
  1440                         } else {
       
  1441                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_titlebar_latched"));
       
  1442                         }
       
  1443                     } else {
       
  1444                         if (opt->transparent) {
       
  1445                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_titlebar_trans_normal"));
       
  1446                         } else {
       
  1447                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_titlebar_normal"));
       
  1448                         }
       
  1449                     }
       
  1450                     frameItem->frameDrawer().setFileNameSuffixList(QStringList() << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_cr"));
       
  1451                 }
       
  1452                 break;
       
  1453             }
       
  1454 			case P_StatusBar_background: {
       
  1455                 const HbStyleOptionStatusBar *opt = qstyleoption_cast<const HbStyleOptionStatusBar *>(option);
       
  1456                 if (opt) {
       
  1457 				    HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  1458 				    frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  1459                     if (opt->transparent) {
       
  1460                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_statusbar_trans"));
       
  1461                     } else {
       
  1462                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_statusbar"));
       
  1463                     }
       
  1464                 }
       
  1465                 break;
       
  1466             }
       
  1467 			case P_StatusBar_timetext: {
       
  1468                 if (const HbStyleOptionStatusBar *opt = 
       
  1469                     qstyleoption_cast<const HbStyleOptionStatusBar*>(option)) {
       
  1470                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  1471                     textItem->setText(opt->timeText);
       
  1472                     }
       
  1473 				break;
       
  1474             }
       
  1475             case P_IndicatorGroup_background: { // deprecated
       
  1476                 const HbStyleOptionIndicatorGroup *opt = qstyleoption_cast<const HbStyleOptionIndicatorGroup *>(option);
       
  1477 
       
  1478                 if (opt) {
       
  1479                     HbIconItem *iconItem = static_cast<HbIconItem*>( item );
       
  1480                     iconItem->setAspectRatioMode(Qt::IgnoreAspectRatio);
       
  1481                     if (opt->direction == Qt::LeftToRight) {
       
  1482                         if (opt->mode == QIcon::Active) {
       
  1483                             if (opt->transparent) {
       
  1484                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_pressed_l"));
       
  1485                             } else {
       
  1486                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_pressed_l"));
       
  1487                             }
       
  1488                         } else if (opt->mode == QIcon::Selected) {
       
  1489                             if (opt->transparent) {
       
  1490                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_latched_l"));
       
  1491                             } else {
       
  1492                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_latched_l"));
       
  1493                             }
       
  1494                         } else {
       
  1495                             if (opt->transparent) {
       
  1496                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_normal_l"));
       
  1497                             } else {
       
  1498                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_normal_l"));
       
  1499                             }
       
  1500                         }
       
  1501                     } else {
       
  1502                         if (opt->mode == QIcon::Active) {
       
  1503                             if (opt->transparent) {
       
  1504                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_pressed_r"));
       
  1505                             } else {
       
  1506                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_pressed_r"));
       
  1507                             }
       
  1508                         } else if (opt->mode == QIcon::Selected) {
       
  1509                             if (opt->transparent) {
       
  1510                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_latched_r"));
       
  1511                             } else {
       
  1512                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_latched_r"));
       
  1513                             }
       
  1514                         } else {
       
  1515                             if (opt->transparent) {
       
  1516                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_normal_r"));
       
  1517                             } else {
       
  1518                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_normal_r"));
       
  1519                             }
       
  1520                         }
       
  1521                     }
       
  1522                 }
       
  1523                 break;
       
  1524             }
       
  1525 
       
  1526             case P_IndicatorGroup_icon1: 
       
  1527             case P_IndicatorGroup_icon2: 
       
  1528             case P_IndicatorGroup_icon3: 
       
  1529             case P_IndicatorGroup_icon4: 
       
  1530                 {  
       
  1531                 const HbStyleOptionIndicatorGroup *opt = qstyleoption_cast<const HbStyleOptionIndicatorGroup *>(option);
       
  1532                 if (opt) {
       
  1533                     HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
       
  1534                     iconItem->setIconName(opt->iconName);
       
  1535                 }
       
  1536                 break;
       
  1537             }
       
  1538 
       
  1539             case P_IndicatorButton_handleindication: {  
       
  1540                 const HbStyleOptionIndicatorButton *opt = qstyleoption_cast<const HbStyleOptionIndicatorButton *>(option);
       
  1541                 if (opt) {
       
  1542                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1543                     iconItem->setIconName("qtg_graf_titlebar_minimize");
       
  1544                 }
       
  1545                 break;
       
  1546             }
       
  1547 
       
  1548             case P_SignalIndicator_icon:
       
  1549             case P_IndicatorGroup_signalicon: { // deprecated
       
  1550                 const HbStyleOptionSignalIndicator *opt = qstyleoption_cast<const HbStyleOptionSignalIndicator *>(option);
       
  1551                 if (opt) {
       
  1552                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1553                     switch (opt->networkMode) {
       
  1554                         case 0:
       
  1555                             iconItem->setIconName("qtg_mono_offline");
       
  1556                             break;
       
  1557                         case 1:
       
  1558                             iconItem->setIconName("qtg_status_signal");
       
  1559                             break;
       
  1560                         case 2:
       
  1561                             iconItem->setIconName("qtg_status_wcdma");
       
  1562                             break;
       
  1563                         case 3:
       
  1564                             iconItem->setIconName("qtg_status_wcdma");
       
  1565                             break;
       
  1566                         case 5:
       
  1567                             iconItem->setIconName("qtg_status_wlan");
       
  1568                             break;
       
  1569                         default:
       
  1570                             iconItem->setIconName("qtg_mono_offline");
       
  1571                             break;
       
  1572                     }
       
  1573                 }
       
  1574                 break;
       
  1575             }
       
  1576             case P_SignalLevel_background: {
       
  1577                 if (option) {
       
  1578                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1579                     iconItem->setIconName("qtg_graf_signal_bg");
       
  1580                 }
       
  1581                 break;
       
  1582             }
       
  1583             case P_SignalLevel_icon: {
       
  1584                 const HbStyleOptionSignalIndicator *opt = qstyleoption_cast<const HbStyleOptionSignalIndicator *>(option);
       
  1585                 if (opt) {
       
  1586                     HbIndicatorLevelIconItem *iconItem = static_cast<HbIndicatorLevelIconItem*>(item);
       
  1587                     switch (opt->signalLevel) {
       
  1588                         case HbStyleOptionSignalIndicator::Zero:
       
  1589                             iconItem->setIconName("qtg_graf_signal_bg");
       
  1590                             break;
       
  1591                         case HbStyleOptionSignalIndicator::Low:
       
  1592                             iconItem->setIconName("qtg_graf_signal_low");
       
  1593                             break;
       
  1594                         case HbStyleOptionSignalIndicator::Medium:
       
  1595                             iconItem->setIconName("qtg_graf_signal_medium");
       
  1596                             break;
       
  1597                         case HbStyleOptionSignalIndicator::Full:
       
  1598                             iconItem->setIconName("qtg_graf_signal_full");
       
  1599                             break;
       
  1600                         default:
       
  1601                             iconItem->setIconName("qtg_graf_signal_bg");
       
  1602                             break;
       
  1603                     }
       
  1604                     iconItem->setValue(opt->signalValue);
       
  1605                     iconItem->setDirection(HbIndicatorLevelIconItem::LeftToRight);
       
  1606                 }
       
  1607                 break;
       
  1608             }
       
  1609             case P_BatteryIndicator_icon:
       
  1610             case P_IndicatorGroup_batteryicon: { // deprecated
       
  1611                 if (option) {
       
  1612                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1613                     iconItem->setIconName("qtg_status_battery");
       
  1614                 }
       
  1615                 break;
       
  1616             }
       
  1617             case P_BatteryLevel_background: {
       
  1618                 if (option) {
       
  1619                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1620                     iconItem->setIconName("qtg_graf_battery_bg");
       
  1621                 }
       
  1622                 break;
       
  1623             }
       
  1624             case P_BatteryLevel_icon: {
       
  1625                 const HbStyleOptionBatteryIndicator *opt = qstyleoption_cast<const HbStyleOptionBatteryIndicator *>(option);
       
  1626                 if (opt) {
       
  1627                     HbIndicatorLevelIconItem *iconItem = static_cast<HbIndicatorLevelIconItem*>(item);
       
  1628                     switch (opt->batteryLevel) {
       
  1629                         case HbStyleOptionBatteryIndicator::Zero:
       
  1630                             iconItem->setIconName("qtg_graf_battery_bg");
       
  1631                             break;
       
  1632                         case HbStyleOptionBatteryIndicator::Low:
       
  1633                             iconItem->setIconName("qtg_graf_battery_low");
       
  1634                             break;
       
  1635                         case HbStyleOptionBatteryIndicator::Medium:
       
  1636                             iconItem->setIconName("qtg_graf_battery_medium");
       
  1637                             break;
       
  1638                         case HbStyleOptionBatteryIndicator::Full:
       
  1639                             iconItem->setIconName("qtg_graf_battery_full");
       
  1640                             break;
       
  1641                         default:
       
  1642                             iconItem->setIconName("qtg_graf_battery_bg");
       
  1643                             break;
       
  1644                     }
       
  1645                     iconItem->setValue(opt->batteryValue);
       
  1646                     iconItem->setDirection(HbIndicatorLevelIconItem::RightToLeft);
       
  1647                 }
       
  1648                 break;
       
  1649             }
       
  1650             case P_Softkey_background:{ // deprecated
       
  1651                 const HbStyleOptionSoftKey *opt = qstyleoption_cast<const HbStyleOptionSoftKey *>(option);
       
  1652 
       
  1653                 if (opt) {
       
  1654 
       
  1655                     switch (opt->mKey)
       
  1656                         {
       
  1657                         case Hb::PrimarySoftKey:
       
  1658                             // does not exist...
       
  1659                             break;
       
  1660                         case Hb::SecondarySoftKey:
       
  1661                             {
       
  1662                                 if (opt) {
       
  1663                                     HbIconItem *iconItem = static_cast<HbIconItem*>( item );
       
  1664                                     if (opt->direction == Qt::LeftToRight) {
       
  1665                                         if (opt->transparent) {
       
  1666                                             if (opt->mode == QIcon::Active) {
       
  1667                                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_pressed_r"));
       
  1668                                             } else {
       
  1669                                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_normal_r"));
       
  1670                                             }
       
  1671                                         } else {
       
  1672                                             if (opt->mode == QIcon::Active) {
       
  1673                                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_pressed_r"));
       
  1674                                             } else {
       
  1675                                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_normal_r"));
       
  1676                                             }
       
  1677                                          }
       
  1678                                     } else {
       
  1679                                         if (opt->transparent) {
       
  1680                                             if (opt->mode == QIcon::Active) {
       
  1681                                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_pressed_l"));
       
  1682                                             } else {
       
  1683                                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_normal_l"));
       
  1684                                             }
       
  1685                                         } else {
       
  1686                                             if (opt->mode == QIcon::Active) {
       
  1687                                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_pressed_l"));
       
  1688                                             } else {
       
  1689                                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_normal_l"));
       
  1690                                             }
       
  1691                                          }
       
  1692                                     }
       
  1693                                 }
       
  1694                             }
       
  1695                             break;
       
  1696                         case Hb::MiddleSoftKey:
       
  1697                             // does not exist...
       
  1698                             break;
       
  1699                         default:
       
  1700                             break;
       
  1701                         }
       
  1702                 }
       
  1703                 break;
       
  1704             }
       
  1705 
       
  1706             case P_NavigationButton_background: {
       
  1707                 const HbStyleOptionNavigationButton *opt = qstyleoption_cast<const HbStyleOptionNavigationButton *>(option);
       
  1708                     if (opt) {
       
  1709                         HbIconItem *iconItem = static_cast<HbIconItem*>( item );
       
  1710                         iconItem->setAspectRatioMode(Qt::IgnoreAspectRatio);
       
  1711                         if (opt->direction == Qt::LeftToRight) {
       
  1712                             if (opt->transparent) {
       
  1713                                 if (opt->mode == QIcon::Active) {
       
  1714                                     iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_pressed_r"));
       
  1715                                 } else {
       
  1716                                     iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_normal_r"));
       
  1717                                 }
       
  1718                             } else {
       
  1719                                 if (opt->mode == QIcon::Active) {
       
  1720                                     iconItem->setIconName(QLatin1String("qtg_fr_titlebar_pressed_r"));
       
  1721                                 } else {
       
  1722                                     iconItem->setIconName(QLatin1String("qtg_fr_titlebar_normal_r"));
       
  1723                                 }
       
  1724                              }
       
  1725                         } else {
       
  1726                             if (opt->transparent) {
       
  1727                                 if (opt->mode == QIcon::Active) {
       
  1728                                     iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_pressed_l"));
       
  1729                                 } else {
       
  1730                                     iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_normal_l"));
       
  1731                                 }
       
  1732                             } else {
       
  1733                                 if (opt->mode == QIcon::Active) {
       
  1734                                     iconItem->setIconName(QLatin1String("qtg_fr_titlebar_pressed_l"));
       
  1735                                 } else {
       
  1736                                     iconItem->setIconName(QLatin1String("qtg_fr_titlebar_normal_l"));
       
  1737                                 }
       
  1738                              }
       
  1739                         }
       
  1740                     }
       
  1741                 break;
       
  1742             }
       
  1743 
       
  1744             case P_IndicatorButton_background: {
       
  1745                 const HbStyleOptionIndicatorButton *opt = qstyleoption_cast<const HbStyleOptionIndicatorButton *>(option);
       
  1746                 if (opt) {
       
  1747                     HbIconItem *iconItem = static_cast<HbIconItem*>( item );
       
  1748                     iconItem->setAspectRatioMode(Qt::IgnoreAspectRatio);
       
  1749                     if (opt->direction == Qt::LeftToRight) {
       
  1750                         if (opt->mode == QIcon::Active) {
       
  1751                             if (opt->transparent) {
       
  1752                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_pressed_l"));
       
  1753                             } else {
       
  1754                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_pressed_l"));
       
  1755                             }
       
  1756                         } else if (opt->mode == QIcon::Selected) {
       
  1757                             if (opt->transparent) {
       
  1758                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_latched_l"));
       
  1759                             } else {
       
  1760                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_latched_l"));
       
  1761                             }
       
  1762                         } else {
       
  1763                             if (opt->transparent) {
       
  1764                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_normal_l"));
       
  1765                             } else {
       
  1766                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_normal_l"));
       
  1767                             }
       
  1768                         }
       
  1769                     } else {
       
  1770                         if (opt->mode == QIcon::Active) {
       
  1771                             if (opt->transparent) {
       
  1772                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_pressed_r"));
       
  1773                             } else {
       
  1774                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_pressed_r"));
       
  1775                             }
       
  1776                         } else if (opt->mode == QIcon::Selected) {
       
  1777                             if (opt->transparent) {
       
  1778                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_latched_r"));
       
  1779                             } else {
       
  1780                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_latched_r"));
       
  1781                             }
       
  1782                         } else {
       
  1783                             if (opt->transparent) {
       
  1784                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_trans_normal_r"));
       
  1785                             } else {
       
  1786                                 iconItem->setIconName(QLatin1String("qtg_fr_titlebar_normal_r"));
       
  1787                             }
       
  1788                         }
       
  1789                     }
       
  1790                 }
       
  1791                 break;
       
  1792             }
       
  1793 
       
  1794             case P_TitlePane_text: {
       
  1795                 const HbStyleOptionTitlePane *opt = qstyleoption_cast<const HbStyleOptionTitlePane *>(option);
       
  1796 
       
  1797                 if (opt) {
       
  1798                     HbMarqueeItem *marqueeItem = static_cast<HbMarqueeItem*>( item );
       
  1799                     if (marqueeItem) {
       
  1800                         marqueeItem->setText(opt->caption);
       
  1801                         marqueeItem->startAnimation();
       
  1802                     }
       
  1803                 }
       
  1804                 break;
       
  1805             }
       
  1806 
       
  1807             case P_TitlePane_icon: {
       
  1808                 const HbStyleOptionTitlePane *opt = qstyleoption_cast<const HbStyleOptionTitlePane *>(option);
       
  1809                 if (opt) {
       
  1810                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  1811                     iconItem->setIconName("qgn_indi_input_arrow_down");
       
  1812                 }
       
  1813                 break;
       
  1814             }
       
  1815             case P_GroupBoxMarquee_text: {
       
  1816                 if (const HbStyleOptionGroupBox *opt = qstyleoption_cast<const HbStyleOptionGroupBox *>(option)) {
       
  1817                     HbMarqueeItem *marqueeItem = static_cast<HbMarqueeItem*>( item );
       
  1818                     if(marqueeItem){
       
  1819                         marqueeItem->setText(opt->heading);
       
  1820                         if(opt->marqueeEnabled){
       
  1821                             if(!marqueeItem->isAnimating()){
       
  1822                                 marqueeItem->setLoopCount(-1);
       
  1823                                 marqueeItem->startAnimation();
       
  1824                             }
       
  1825                         }else
       
  1826                         {
       
  1827                             marqueeItem->stopAnimation();
       
  1828                         }
       
  1829                     }
       
  1830                 }
       
  1831                 break;
       
  1832             }
       
  1833             case P_GroupBoxHeading_text: {
       
  1834                 if (const HbStyleOptionGroupBox *opt = qstyleoption_cast<const HbStyleOptionGroupBox *>(option)) {
       
  1835                     HbTextItem *textItem = static_cast<HbTextItem*>( item );
       
  1836                     if(textItem){
       
  1837                         textItem->setText(opt->heading);
       
  1838                     }
       
  1839                 }
       
  1840                 break;
       
  1841             }
       
  1842             case P_PushButton_focus: {
       
  1843                 if (const HbStyleOptionPushButton *opt = 
       
  1844                         qstyleoption_cast<const HbStyleOptionPushButton *>(option)) {
       
  1845                      HbFrameItem *iconItem  = static_cast<HbFrameItem*>(item);
       
  1846                      iconItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_btn_highlight"));
       
  1847                      int margin = 4;
       
  1848                      QRectF focusRect  = opt->rect.adjusted(-margin , -margin , margin , margin);
       
  1849                      iconItem->setGeometry(focusRect);
       
  1850                      iconItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1851                  }
       
  1852                 break;
       
  1853             }
       
  1854             case P_ToolButton_frame:{
       
  1855                 const HbStyleOptionToolButton *opt = qstyleoption_cast<const HbStyleOptionToolButton *>(option);
       
  1856                 HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  1857                 frameItem->frameDrawer().setFillWholeRect(true);
       
  1858                 frameItem->setGeometry(opt->rect);
       
  1859                 if (opt->orientation == Qt::Vertical) {
       
  1860                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  1861                 } else {
       
  1862                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  1863                 }
       
  1864 
       
  1865                 QStringList list;
       
  1866                 QString frameGraphicsFooter;
       
  1867                 QIcon::Mode mode = d->iconMode(opt->state);
       
  1868                 QIcon::State state = d->iconState(opt->state);
       
  1869 
       
  1870                 if (!opt->customBackground.isNull()) {
       
  1871                     QString customName = opt->customBackground.iconName(mode, state);
       
  1872                     frameItem->frameDrawer().setFrameGraphicsName(customName);
       
  1873                     break;
       
  1874                 }
       
  1875 
       
  1876                 if (!opt->toolBarPosition) {
       
  1877                     QString frameGraphicsName;
       
  1878                     if (mode == QIcon::Disabled && state == QIcon::Off) {
       
  1879                         frameGraphicsName = QLatin1String("qtg_fr_btn_disabled");
       
  1880                     } else if (mode == QIcon::Normal && state == QIcon::On) {
       
  1881                         if(!opt->isCheckable){
       
  1882                             frameGraphicsName = QLatin1String("qtg_fr_btn_pressed");
       
  1883                         } else {
       
  1884                             frameGraphicsName = QLatin1String("qtg_fr_btn_latched");
       
  1885                         }
       
  1886                     } else if (mode == QIcon::Selected && state == QIcon::Off) {
       
  1887                         frameGraphicsName = QLatin1String("qtg_fr_btn_highlight");
       
  1888                     } else {
       
  1889                         frameGraphicsName = QLatin1String("qtg_fr_btn_normal");
       
  1890                     }
       
  1891                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
       
  1892                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1893                     break;
       
  1894                 }
       
  1895                 // For toolbar:
       
  1896 
       
  1897                 QString frameGraphicsHeader;
       
  1898                 if (!opt->useSecondaryGraphics){
       
  1899                     frameGraphicsHeader = opt->orientation == Qt::Vertical ? QLatin1String("qtg_fr_tb_h_"):
       
  1900                                                                              QLatin1String("qtg_fr_tb_v_");
       
  1901                 }else {
       
  1902                     frameGraphicsHeader = QLatin1String("qtg_fr_popup_sk_");
       
  1903                     frameItem->frameDrawer().setMirroringMode(HbIcon::LayoutDirection);
       
  1904                 }
       
  1905 
       
  1906                 switch (opt->toolBarPosition) {
       
  1907                     case HbStyleOptionToolButton::TB_OnlyOne:
       
  1908                         if (opt->orientation == Qt::Vertical) {
       
  1909                             list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_r");                                                        
       
  1910                         } else {
       
  1911                             list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_b");                            
       
  1912                         }
       
  1913                         break;
       
  1914                     case HbStyleOptionToolButton::TB_Beginning:
       
  1915                         if (opt->orientation == Qt::Vertical) {
       
  1916                             list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_cr");
       
  1917                         } else {
       
  1918                             list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_cb");
       
  1919                         }
       
  1920                         break;
       
  1921                     case HbStyleOptionToolButton::TB_Middle:
       
  1922                         if (opt->orientation == Qt::Vertical) {
       
  1923                             list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_cr");
       
  1924                         } else {
       
  1925                             list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_cb");
       
  1926                         }
       
  1927                         break;
       
  1928                     case HbStyleOptionToolButton::TB_End:
       
  1929                         if (opt->orientation == Qt::Vertical) {
       
  1930                             list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_r");
       
  1931                         } else {
       
  1932                             list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_b");
       
  1933                         }
       
  1934                         break;
       
  1935                     default:
       
  1936 
       
  1937                         break;                       
       
  1938                 }
       
  1939                 frameItem->frameDrawer().setFileNameSuffixList(list);
       
  1940                 if (mode == QIcon::Disabled && state == QIcon::Off) {
       
  1941                     frameGraphicsFooter = QLatin1String("disabled");
       
  1942                 } else if (mode == QIcon::Normal && state == QIcon::On) {
       
  1943                     if(!opt->isCheckable) {
       
  1944                         frameGraphicsFooter = QLatin1String("pressed");
       
  1945                     } else {
       
  1946                         frameGraphicsFooter = QLatin1String("latched");
       
  1947                     }
       
  1948                 } else if (mode == QIcon::Selected && state == QIcon::Off) {
       
  1949                     frameGraphicsFooter = QLatin1String("highlight");
       
  1950                 } else {
       
  1951                     frameGraphicsFooter = QLatin1String("normal");
       
  1952                 }
       
  1953 
       
  1954                 frameItem->frameDrawer().setFrameGraphicsName(QString ("%0%1").arg(frameGraphicsHeader).arg(frameGraphicsFooter));
       
  1955 
       
  1956                 break;
       
  1957             }
       
  1958 
       
  1959 
       
  1960 
       
  1961             case P_SliderTickMark_majoricon: {
       
  1962                  if (const HbStyleOptionSlider *opt = 
       
  1963                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
       
  1964                         HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
       
  1965                         iconItem->setMode(d->iconMode(opt->state));
       
  1966                         if ( opt->orientation ==Qt::Horizontal ){
       
  1967                             iconItem->setIconName( "qtg_graf_slider_h_tick_major" );
       
  1968                         } else {
       
  1969                             iconItem->setIconName ( "qtg_graf_slider_v_tick_major" );
       
  1970                         }
       
  1971                         iconItem->setState(d->iconState(opt->state));
       
  1972                     }
       
  1973                  break;
       
  1974                                              
       
  1975              }
       
  1976 
       
  1977             case P_SliderTickMark_minoricon: {
       
  1978                  if (const HbStyleOptionSlider *opt = 
       
  1979                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
       
  1980                         HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
       
  1981                         iconItem->setMode(d->iconMode(opt->state));
       
  1982                         if ( opt->orientation ==Qt::Horizontal ){
       
  1983                             iconItem->setIconName( "qtg_graf_slider_h_tick_minor" );
       
  1984                         } else {
       
  1985                             iconItem->setIconName ( "qtg_graf_slider_v_tick_minor" );
       
  1986                         }
       
  1987                         iconItem->setState(d->iconState(opt->state));
       
  1988                     }
       
  1989                  break;
       
  1990                                              
       
  1991              }                                             
       
  1992 
       
  1993             case P_SliderTickMark_majorlabel: {
       
  1994                  if (const HbStyleOptionSlider *opt = 
       
  1995                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
       
  1996                         HbTextItem *textItem = qgraphicsitem_cast<HbTextItem*>(item);
       
  1997  
       
  1998                         textItem->setText( opt->text );
       
  1999 
       
  2000                     }
       
  2001                  break;
       
  2002                                              
       
  2003              }
       
  2004 
       
  2005             case P_SliderTickMark_minorlabel: {
       
  2006                  if (const HbStyleOptionSlider *opt = 
       
  2007                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
       
  2008                         HbTextItem *textItem = qgraphicsitem_cast<HbTextItem*>(item);
       
  2009                          textItem->setText( opt->text );
       
  2010                     }
       
  2011                  break;
       
  2012                                              
       
  2013              }                                             
       
  2014 
       
  2015             case P_Slider_progressgroove: {
       
  2016                 if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider *>(option))  {
       
  2017                     HbSliderTrackItem* frameItem = static_cast<HbSliderTrackItem*>(item);
       
  2018                     if(!frameItem->isVisible()) {
       
  2019                         break;
       
  2020                     }
       
  2021                     if(opt->orientation == Qt::Horizontal){
       
  2022                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2023                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_slider_h_filled"));
       
  2024                         frameItem->setInverted(opt->upsideDown);
       
  2025                     }
       
  2026                     else{
       
  2027                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2028                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_slider_v_filled"));
       
  2029                         frameItem->setInverted(!opt->upsideDown);
       
  2030                         frameItem->frameDrawer().setMirroringMode(HbIcon::Prevented);       
       
  2031                     }
       
  2032                     frameItem->frameDrawer().setFillWholeRect(true);
       
  2033                     frameItem->setMaximum(opt->maximum);
       
  2034                     frameItem->setMinimum(opt->minimum);
       
  2035                     frameItem->setValue(opt->sliderValue);
       
  2036                     frameItem->setOrientation(opt->orientation);
       
  2037                     frameItem->setSpan( opt->span );
       
  2038                     frameItem->update();
       
  2039                 }
       
  2040                 break;
       
  2041             }
       
  2042             case P_Slider_groove:{
       
  2043 
       
  2044                 if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider *>(option)) {
       
  2045                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  2046                     HbFrameDrawer::FrameType type(HbFrameDrawer::Undefined);
       
  2047                     QString name;
       
  2048 
       
  2049                     if (opt->orientation == Qt::Horizontal) {
       
  2050                         type = HbFrameDrawer::ThreePiecesHorizontal;
       
  2051                         if(!opt->groovePressed){
       
  2052                             name = QLatin1String("qtg_fr_slider_h_frame_normal");
       
  2053                         }
       
  2054                         else {
       
  2055                             name = QLatin1String("qtg_fr_slider_h_frame_pressed");
       
  2056                         }
       
  2057                     } else if (opt->orientation == Qt::Vertical) {
       
  2058                         if(!opt->groovePressed){
       
  2059                             name = QLatin1String("qtg_fr_slider_v_frame_normal");
       
  2060                         }
       
  2061                         else {
       
  2062                             name = QLatin1String("qtg_fr_slider_v_frame_pressed");
       
  2063                         }
       
  2064                         type = HbFrameDrawer::ThreePiecesVertical;
       
  2065                     }
       
  2066 
       
  2067                     frameItem->frameDrawer().setFrameGraphicsName(name);
       
  2068                     frameItem->frameDrawer().setFrameType(type);
       
  2069                     frameItem->frameDrawer().setFillWholeRect(true);
       
  2070                     break;
       
  2071                 }
       
  2072             }
       
  2073 
       
  2074             case P_Slider_thumb: {
       
  2075                  if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider *>(option)){
       
  2076                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2077                     // Set pixmap name and bounding rect
       
  2078                     QString thumbPath;
       
  2079                     if(opt->thumbPath.isNull())
       
  2080                     {
       
  2081                         thumbPath=d->logicalName(HbStyle::P_Slider_thumb, option);
       
  2082                     }
       
  2083                     else
       
  2084                     {
       
  2085                         thumbPath=opt->thumbPath;
       
  2086                     }
       
  2087                     iconItem->setIconName(thumbPath);
       
  2088                     iconItem->setAspectRatioMode(Qt::KeepAspectRatio);
       
  2089                  }
       
  2090                 break;
       
  2091             }
       
  2092             case HbStyle::P_SliderElement_increase:
       
  2093                 {
       
  2094                     if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
       
  2095                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2096                         iconItem->setZValue(1.0);
       
  2097                         iconItem->setMode(d->iconMode(opt->state));
       
  2098                         iconItem->setState(d->iconState(opt->state));
       
  2099                         if ( !opt->sliderElementIcon.isNull() ){
       
  2100                             iconItem->setIcon(opt->sliderElementIcon);
       
  2101                         } else if ( opt->sliderType == HbStyleOptionSlider::VolumeType) {
       
  2102                             iconItem->setIconName(QLatin1String("qtg_mono_vol_up"));
       
  2103                         } else if (opt->sliderType == HbStyleOptionSlider::ZoomType) {
       
  2104                             iconItem->setIconName(QLatin1String("qtg_mono_zoom_in"));
       
  2105                         }
       
  2106                     }
       
  2107                 break;
       
  2108                 }
       
  2109             case HbStyle::P_SliderElement_decrease:
       
  2110                 {
       
  2111                     if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
       
  2112                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2113                         iconItem->setZValue(1.0);
       
  2114                         iconItem->setMode(d->iconMode(opt->state));
       
  2115                         iconItem->setState(d->iconState(opt->state));
       
  2116                         if ( !opt->sliderElementIcon.isNull() ){
       
  2117                             iconItem->setIcon(opt->sliderElementIcon);
       
  2118                         } else if ( opt->sliderType == HbStyleOptionSlider::VolumeType) {
       
  2119                             iconItem->setIconName(QLatin1String("qtg_mono_vol_down"));
       
  2120                         } else if (opt->sliderType == HbStyleOptionSlider::ZoomType) {
       
  2121                             iconItem->setIconName(QLatin1String("qtg_mono_zoom_out"));
       
  2122                         }
       
  2123                     }
       
  2124                 break;
       
  2125                 }
       
  2126             case HbStyle::P_SliderElement_icon:
       
  2127                 {
       
  2128                     if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
       
  2129                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2130                         iconItem->setZValue(1.0);
       
  2131                         iconItem->setMode(d->iconMode(opt->state));
       
  2132                         iconItem->setState(d->iconState(opt->state));
       
  2133                         if ( !opt->sliderElementIcon.isNull() ){
       
  2134                             iconItem->setIcon(opt->sliderElementIcon);
       
  2135                         } else if ( opt->sliderType == HbStyleOptionSlider::VolumeType) {
       
  2136                             if( opt->state & QStyle::State_Sunken) {
       
  2137                                 iconItem->setIconName(QLatin1String("qtg_mono_speaker_off"));
       
  2138                             } else {
       
  2139                                 iconItem->setIconName(QLatin1String("qtg_mono_speaker"));
       
  2140                             }
       
  2141                         } 
       
  2142                     }
       
  2143                 break;
       
  2144                 }
       
  2145             case P_SliderElement_text:
       
  2146                 {
       
  2147                    if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
       
  2148                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2149                         textItem->setZValue(1.0);
       
  2150                         textItem->setText(opt->text);
       
  2151                     }
       
  2152                 break;
       
  2153                 }
       
  2154 
       
  2155 
       
  2156             case P_CheckBox_text:
       
  2157                 if (const HbStyleOptionCheckBox *opt = qstyleoption_cast<const HbStyleOptionCheckBox*>(option)) {
       
  2158                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2159                     textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  2160                     textItem->setText(opt->text);
       
  2161                 }
       
  2162                 break;
       
  2163 
       
  2164             case P_CheckBox_icon: {
       
  2165                 if (const HbStyleOptionCheckBox *opt = qstyleoption_cast<const HbStyleOptionCheckBox *>(option)){
       
  2166                     HbIconItem *iconItem = static_cast<HbIconItem *>(item);
       
  2167                     if (opt->state.testFlag(QStyle::State_On)) {
       
  2168                         iconItem->setState(QIcon::On);
       
  2169                         iconItem->setIconName(QLatin1String("qtg_small_selected"));
       
  2170                     } else if (opt->state.testFlag(QStyle::State_Off)) {
       
  2171                         iconItem->setState(QIcon::Off);
       
  2172                         iconItem->setIconName(QLatin1String("qtg_small_unselected"));
       
  2173                     } else if (opt->state.testFlag(QStyle::State_NoChange)) {
       
  2174                         iconItem->setState(QIcon::On);
       
  2175                         iconItem->setIconName(QLatin1String("qtg_small_selected_partial"));
       
  2176                     }
       
  2177                 }
       
  2178                 break;
       
  2179             }
       
  2180             case P_ItemViewItem_radiobutton:
       
  2181             case P_ItemViewItem_checkbox:
       
  2182             case P_ItemViewItem_selection:{
       
  2183                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)){
       
  2184                     HbIconItem *iconItem = static_cast<HbIconItem *>(item);
       
  2185                     iconItem->setAlignment(Qt::AlignCenter);
       
  2186 
       
  2187                     if (opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) {
       
  2188                         if (opt->checkState == Qt::Checked) {
       
  2189                             iconItem->setState(QIcon::On);
       
  2190                             iconItem->setIconName(QLatin1String("qtg_small_radio_selected"));
       
  2191                         } else {
       
  2192                             iconItem->setState(QIcon::Off);
       
  2193                             iconItem->setIconName(QLatin1String("qtg_small_radio_unselected"));
       
  2194                         }
       
  2195                     } else {
       
  2196                         if (opt->checkState == Qt::Checked) {
       
  2197                             iconItem->setState(QIcon::On);
       
  2198                             if (opt->singleSelectionMode) {
       
  2199                                 iconItem->setIconName(QLatin1String("qtg_small_tick"));
       
  2200                             }
       
  2201                             else {
       
  2202                                 iconItem->setIconName(QLatin1String("qtg_small_selected"));
       
  2203                             }
       
  2204                         } else if (opt->checkState == Qt::PartiallyChecked) {
       
  2205                             iconItem->setState(QIcon::On);
       
  2206                             iconItem->setIconName(QLatin1String("qtg_small_selected_partial"));
       
  2207                         } else {
       
  2208                             iconItem->setState(QIcon::Off);
       
  2209                             if (opt->singleSelectionMode) {
       
  2210                                 iconItem->setIconName(QLatin1String(""));
       
  2211                             }
       
  2212                             else {
       
  2213                                 iconItem->setIconName(QLatin1String("qtg_small_unselected"));
       
  2214                             }
       
  2215                         }
       
  2216                     }
       
  2217                 }
       
  2218                 break;
       
  2219             }
       
  2220 
       
  2221             case P_LineEdit_frame_normal:{
       
  2222                 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) {
       
  2223                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_lineedit_normal"));
       
  2224                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2225                 }
       
  2226             break;
       
  2227             }
       
  2228 
       
  2229             case P_LineEdit_frame_highlight:{
       
  2230                 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) {
       
  2231                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_lineedit_highlight"));
       
  2232                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2233                 }
       
  2234             break;
       
  2235             }
       
  2236 
       
  2237             case P_TextEdit_frame_normal:{
       
  2238                 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) {
       
  2239                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_textedit_normal"));
       
  2240                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2241                 }
       
  2242             break;
       
  2243             }
       
  2244 
       
  2245             case P_TextEdit_frame_highlight:{
       
  2246                 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) {
       
  2247                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_textedit_highlight"));
       
  2248                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2249                 }
       
  2250             break;
       
  2251             }
       
  2252 
       
  2253             case P_ComboBox_background:{
       
  2254                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2255                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
       
  2256                     QString frameGraphicsName;
       
  2257                     if (opt->state & QStyle::State_Enabled) {
       
  2258                         if (opt->state & QStyle::State_Sunken) {
       
  2259                             frameGraphicsName = QLatin1String("qtg_fr_combobox_pressed");
       
  2260                         } else {
       
  2261                         	frameGraphicsName = QLatin1String("qtg_fr_combobox_normal");
       
  2262                         }
       
  2263                     } else {                        
       
  2264                         frameGraphicsName = QLatin1String("qtg_fr_combobox_disabled");
       
  2265                     }
       
  2266                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2267                     frameItem->frameDrawer().setFillWholeRect(true);
       
  2268                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
       
  2269                     frameItem->frameDrawer().setMirroringMode ( HbIcon::LayoutDirection );
       
  2270 
       
  2271                 }
       
  2272             break;
       
  2273             }
       
  2274             case P_ComboBox_button:{
       
  2275                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2276                     HbIconItem *iconItem = static_cast<HbIconItem*>( item );
       
  2277                     QString iconGraphicsName;
       
  2278                     if (opt->state & QStyle::State_Enabled) {
       
  2279                         if (opt->state & QStyle::State_Sunken) {
       
  2280                             iconGraphicsName = QLatin1String("qtg_graf_combobox_button_pressed");
       
  2281                         } else {
       
  2282                             iconGraphicsName = QLatin1String("qtg_graf_combobox_button_normal");
       
  2283                         }
       
  2284                     } else {                        
       
  2285                         iconGraphicsName = QLatin1String("qtg_graf_combobox_button_disabled");
       
  2286                     }
       
  2287                     iconItem->setIconName(iconGraphicsName);
       
  2288                     iconItem->setMirroringMode ( HbIcon::LayoutDirection );
       
  2289                     iconItem->setAspectRatioMode( Qt::IgnoreAspectRatio);
       
  2290                 }
       
  2291             break;
       
  2292             }
       
  2293 
       
  2294             case P_Edit_text:{
       
  2295                 break;
       
  2296             }
       
  2297 
       
  2298             case P_MenuItem_frame:{
       
  2299                         HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2300                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2301                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_list_normal"));
       
  2302                     break;
       
  2303                 }
       
  2304             case P_MenuItem_focus:{
       
  2305                         HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2306                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2307                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_list_pressed"));
       
  2308                     break;
       
  2309                 }
       
  2310 
       
  2311             case P_Label_text:
       
  2312                  if (const HbStyleOptionLabel *opt = qstyleoption_cast<const HbStyleOptionLabel*>(option)) {
       
  2313                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2314                     textItem->setAlignment(opt->alignment);
       
  2315                     textItem->setElideMode(opt->elideMode);
       
  2316                     textItem->setTextWrapping(opt->textWrapMode);
       
  2317                     if(!opt->fontSpec.isNull()) {
       
  2318                         textItem->setFontSpec(opt->fontSpec);
       
  2319                     }
       
  2320                     if (opt->color.isValid()) {
       
  2321                         textItem->setTextColor(opt->color);
       
  2322                     }
       
  2323                     textItem->setText(opt->text);
       
  2324                  }
       
  2325                  break;
       
  2326             case P_Label_richtext:
       
  2327                 if (const HbStyleOptionLabel *opt = qstyleoption_cast<const HbStyleOptionLabel*>(option)) {
       
  2328                     HbRichTextItem *textItem = static_cast<HbRichTextItem*>(item);
       
  2329                     textItem->setAlignment(opt->alignment);                    
       
  2330                     textItem->setTextWrapping(opt->textWrapMode);
       
  2331                     if(!opt->fontSpec.isNull()) {
       
  2332                         textItem->setFontSpec(opt->fontSpec);
       
  2333                     }
       
  2334                     if (opt->color.isValid()) {
       
  2335                         textItem->setTextDefaultColor(opt->color);
       
  2336                     }
       
  2337                     textItem->setText(opt->text);
       
  2338                 }
       
  2339                 break;
       
  2340 
       
  2341             case P_MenuItem_submenuindicator:
       
  2342                 if (const HbStyleOptionMenuItem *opt = qstyleoption_cast<const HbStyleOptionMenuItem *>(option)) {
       
  2343                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2344                     Q_UNUSED(opt)
       
  2345                     iconItem->setIconName(QLatin1String("qtg_mono_options_menu"));
       
  2346                 }
       
  2347                 break;
       
  2348 
       
  2349             case P_MenuItem_checkindicator:
       
  2350                 if (const HbStyleOptionMenuItem *opt = qstyleoption_cast<const HbStyleOptionMenuItem *>(option)) {
       
  2351                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2352                     if (opt->checked) {
       
  2353                         iconItem->setIconName(QLatin1String("qtg_small_selected"));
       
  2354                     } else {
       
  2355                         iconItem->setIcon(HbIcon());
       
  2356                     }
       
  2357                 }
       
  2358                 break;
       
  2359 
       
  2360             case P_MenuItem_separator:
       
  2361                 if (const HbStyleOptionMenuItem *opt = qstyleoption_cast<const HbStyleOptionMenuItem *>(option)) {
       
  2362                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2363                     Q_UNUSED(opt)
       
  2364                     iconItem->setAspectRatioMode(Qt::IgnoreAspectRatio);
       
  2365                     iconItem->setAlignment(Qt::AlignCenter);
       
  2366                     iconItem->setIconName(QLatin1String("qtg_graf_popup_separator"));
       
  2367                 }
       
  2368                 break;
       
  2369 
       
  2370             case P_ScrollBar_groove:
       
  2371                 if (const HbStyleOptionScrollBar *opt = qstyleoption_cast<const HbStyleOptionScrollBar *>(option)) {
       
  2372                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2373                     if (opt->interactive) {
       
  2374                         if (opt->groovePressed) {
       
  2375                             if (opt->orientation == Qt::Vertical) {
       
  2376                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2377                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_v_active_frame_pressed"));
       
  2378                             } else {
       
  2379                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2380                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_h_active_frame_pressed"));
       
  2381                             }
       
  2382                         } else {
       
  2383                             if (opt->orientation == Qt::Vertical) {
       
  2384                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2385                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_v_active_frame_normal"));
       
  2386                             } else {
       
  2387                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2388                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_h_active_frame_normal"));
       
  2389                             }
       
  2390                         }
       
  2391                     } else {
       
  2392                         if (opt->orientation == Qt::Vertical) {
       
  2393                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2394                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_v_frame"));
       
  2395                         } else {
       
  2396                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2397                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_h_frame"));
       
  2398                         }
       
  2399                     }
       
  2400 
       
  2401                     frameItem->frameDrawer().setFillWholeRect(true);
       
  2402                 }
       
  2403                 break;
       
  2404 
       
  2405             case P_ScrollBar_handle:
       
  2406                 if (const HbStyleOptionScrollBar *opt = qstyleoption_cast<const HbStyleOptionScrollBar *>(option)) {
       
  2407                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2408                     if (opt->interactive) {
       
  2409                         if (opt->thumbPressed) {
       
  2410                             if (opt->orientation == Qt::Vertical) {
       
  2411                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2412                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_v_active_handle_pressed"));
       
  2413                             } else {
       
  2414                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2415                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_h_active_handle_pressed"));
       
  2416                             }
       
  2417                         } else {
       
  2418                             if (opt->orientation == Qt::Vertical) {
       
  2419                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2420                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_v_active_handle_normal"));
       
  2421                             } else {
       
  2422                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2423                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_h_active_handle_normal"));
       
  2424                             }
       
  2425                         }
       
  2426                     } else {
       
  2427                         if (opt->orientation == Qt::Vertical) {
       
  2428                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2429                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_v_handle"));
       
  2430                         } else {
       
  2431                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2432                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_scroll_h_handle"));
       
  2433                         }
       
  2434                     }
       
  2435                     frameItem->frameDrawer().setFillWholeRect(true);
       
  2436                 }
       
  2437                 break;
       
  2438 
       
  2439             case P_Popup_background:
       
  2440                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2441                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2442                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2443                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup"));
       
  2444                     frameItem->setGeometry(opt->boundingRect);
       
  2445                 }
       
  2446                 break;
       
  2447             case P_Popup_background_weak:
       
  2448                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2449                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2450                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2451                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_secondary"));
       
  2452                     frameItem->setGeometry(opt->boundingRect);
       
  2453                 }
       
  2454                 break;
       
  2455 
       
  2456             case P_Popup_heading_frame:
       
  2457                 if (const HbStyleOptionPopup *opt = qstyleoption_cast<const HbStyleOptionPopup *>(option)) {
       
  2458                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2459                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2460                     frameItem->setGeometry(opt->boundingRect);
       
  2461                     if (opt->headingMode == QIcon::Active) {
       
  2462                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_heading_pressed"));
       
  2463                     } else if (opt->headingMode == QIcon::Selected) {
       
  2464                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_heading_highlight"));
       
  2465                     } else {
       
  2466                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_heading_normal"));
       
  2467                     }
       
  2468                 }
       
  2469                 break;
       
  2470 
       
  2471             case P_ComboBoxPopup_background:
       
  2472                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2473                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2474                         if(!frameItem){
       
  2475                            return;
       
  2476                         }
       
  2477                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2478                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_secondary"));
       
  2479                     frameItem->setGeometry(opt->boundingRect);
       
  2480                 }
       
  2481                 break;
       
  2482 
       
  2483             case P_ToolTip_background:
       
  2484                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2485                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2486                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2487                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_preview"));
       
  2488                     frameItem->setGeometry(opt->boundingRect);
       
  2489                 }
       
  2490                 break;
       
  2491 
       
  2492             case P_NotificationDialog_frame:
       
  2493                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2494                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2495                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2496                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_preview"));
       
  2497                     frameItem->setGeometry(opt->boundingRect);
       
  2498                 }
       
  2499                 break;
       
  2500 
       
  2501             case P_Fade_background:
       
  2502                if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2503                     HbIconItem *iconItem = static_cast<HbIconItem*>( item );
       
  2504                     iconItem->setIconName(QLatin1String("qtg_graf_dimming_image"));
       
  2505                     iconItem->setAspectRatioMode (Qt::IgnoreAspectRatio);
       
  2506                     iconItem->setGeometry(opt->boundingRect);
       
  2507                 }
       
  2508                 break;
       
  2509 
       
  2510             case P_NotificationDialog_text:
       
  2511                 if (const HbStyleOptionNotificationDialog *opt =
       
  2512                         qstyleoption_cast<const HbStyleOptionNotificationDialog *>(option)) {
       
  2513                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2514                     textItem->setAlignment(opt->textAlignment);
       
  2515                     textItem->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
       
  2516                     textItem->setTextWrapping(opt->wrappingText);
       
  2517                     textItem->setText(opt->text);
       
  2518                 }
       
  2519                 break;
       
  2520             case P_NotificationDialog_title:
       
  2521                 if (const HbStyleOptionNotificationDialog *opt =
       
  2522                         qstyleoption_cast<const HbStyleOptionNotificationDialog *>(option)) {
       
  2523                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2524 
       
  2525                     textItem->setAlignment(opt->titleAlignment);
       
  2526                     textItem->setFontSpec(HbFontSpec(HbFontSpec::Primary));
       
  2527                     textItem->setTextWrapping(opt->wrappingTitle);
       
  2528                     textItem->setText(opt->title);
       
  2529                 }
       
  2530                 break;
       
  2531             case P_NotificationDialog_icon:
       
  2532                 if (const HbStyleOptionNotificationDialog *opt =
       
  2533                         qstyleoption_cast<const HbStyleOptionNotificationDialog *>(option)) {
       
  2534                     HbIconItem *icon = static_cast<HbIconItem*>(item);
       
  2535 
       
  2536                     icon->setIcon(opt->icon);
       
  2537                     icon->setAlignment(opt->iconAlignment);
       
  2538                 }
       
  2539                 break;
       
  2540 
       
  2541             case P_ProgressDialog_icon:
       
  2542                 if (const HbStyleOptionProgressDialog *opt = static_cast<const HbStyleOptionProgressDialog *>(option)) {
       
  2543                     HbIconItem *icon = static_cast<HbIconItem*>(item);
       
  2544 
       
  2545                     icon->setIcon(opt->icon);
       
  2546                     icon->setAlignment(opt->iconAlignment);
       
  2547                 }
       
  2548 
       
  2549                 break;
       
  2550 
       
  2551             
       
  2552             case P_MessageBox_text:
       
  2553                 if (const HbStyleOptionMessageBox *opt = static_cast<const HbStyleOptionMessageBox *>(option)) {
       
  2554                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2555                     textItem->setAlignment(opt->textAlignment);
       
  2556 
       
  2557                     if (opt->textWrapping) {
       
  2558                         textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  2559                     } else {
       
  2560                         textItem->setTextWrapping(Hb::TextNoWrap);
       
  2561                     }
       
  2562                     textItem->setText(opt->text);
       
  2563                 }
       
  2564                 break;
       
  2565             case P_MessageBox_icon:
       
  2566 	              
       
  2567                 if (const HbStyleOptionMessageBox *opt = static_cast<const HbStyleOptionMessageBox *>(option)) {
       
  2568                         HbIconItem *icon = static_cast<HbIconItem*>(item);
       
  2569                         HbIcon noteIcon = opt->icon;
       
  2570                         if(noteIcon.isNull()) {
       
  2571                             switch (opt->messageBoxType) {
       
  2572                                 case HbStyleOptionMessageBox::MessageTypeInformation:
       
  2573                                     icon->setIcon(HbIcon(QLatin1String("note_info")));
       
  2574                                     break;
       
  2575                                 case HbStyleOptionMessageBox::MessageTypeQuestion:
       
  2576                                     icon->setIcon(HbIcon(QLatin1String("qtg_large_question_mark")));
       
  2577                                     break;
       
  2578                                 case HbStyleOptionMessageBox::MessageTypeWarning:
       
  2579                                     icon->setIcon(HbIcon(QLatin1String("note_warning")));
       
  2580                                     break;
       
  2581                                 default:
       
  2582                                     break;
       
  2583                             }
       
  2584 									                            
       
  2585                         }
       
  2586 						else {                 
       
  2587                             icon->setIcon(opt->icon);
       
  2588                         }
       
  2589                         icon->setAlignment(opt->iconAlignment);
       
  2590                 }
       
  2591                 break;
       
  2592             case P_ItemViewItem_background:
       
  2593                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
       
  2594                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2595                     iconItem->setZValue(-3.0);
       
  2596 
       
  2597                     if (opt->background.canConvert<HbIcon>()){
       
  2598                         iconItem->setIcon(opt->background.value<HbIcon>());
       
  2599                     } else if (opt->background.canConvert<QBrush>()){
       
  2600                         iconItem->setBrush(opt->background.value<QBrush>());
       
  2601                     }
       
  2602                 }
       
  2603 
       
  2604                 break;
       
  2605             case P_ListViewItem_text:
       
  2606                 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) {
       
  2607                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2608                     
       
  2609                     // needs set word wrapping explicitly, if multiple lines supported
       
  2610                     if (opt->index == 1) {
       
  2611                         Hb::TextWrapping wrapping = Hb::TextNoWrap;
       
  2612                         if (    opt->minimumLines != 1
       
  2613                             ||  opt->maximumLines != 1) {
       
  2614                             wrapping = Hb::TextWordWrap;
       
  2615                         }
       
  2616                         textItem->setTextWrapping(wrapping);
       
  2617                         textItem->setMinimumLines(opt->minimumLines);
       
  2618                         textItem->setMaximumLines(opt->maximumLines);
       
  2619                     }
       
  2620                     setItemName(textItem, QLatin1String("text-") + QString::number(opt->index + 1));
       
  2621                     textItem->setText(opt->content.value<QString>());
       
  2622                 }
       
  2623                 break;
       
  2624             case P_ListViewItem_richtext:
       
  2625                 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) {
       
  2626                     HbRichTextItem *label = static_cast<HbRichTextItem*>(item);
       
  2627                     label->setText(opt->content.value<QString>());
       
  2628 
       
  2629                     setItemName(label, QLatin1String("text-") + QString::number(opt->index + 1));
       
  2630                 }
       
  2631                 break;
       
  2632             case P_ListViewItem_icon:
       
  2633                 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) {
       
  2634                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2635                     
       
  2636                     setItemName(iconItem, QLatin1String("icon-") + QString::number(opt->index + 1));
       
  2637                     iconItem->setZValue(opt->index + 1);
       
  2638 
       
  2639                     if (opt->content.canConvert<HbIcon>()){
       
  2640                         iconItem->setIcon(opt->content.value<HbIcon>());
       
  2641                     } if (opt->content.canConvert<QIcon>()){
       
  2642                         iconItem->setIcon(opt->content.value<QIcon>());
       
  2643                     }
       
  2644                 }
       
  2645                 break;
       
  2646             case P_GridViewItem_icon:
       
  2647                 if (const  HbStyleOptionGridViewItem*opt = qstyleoption_cast<const HbStyleOptionGridViewItem*>(option)) {
       
  2648                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2649                     iconItem->setIcon(opt->icon);
       
  2650                     iconItem->setAlignment(Qt::AlignCenter);
       
  2651                     iconItem->setAspectRatioMode(Qt::KeepAspectRatio);
       
  2652                 }
       
  2653                 break;
       
  2654 
       
  2655             case P_ColorGridViewItem_colorIcon:
       
  2656                 if (const  HbStyleOptionColorGridViewItem* opt = qstyleoption_cast<const HbStyleOptionColorGridViewItem*>(option)) {
       
  2657                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2658                     if(!iconItem)
       
  2659                         return;
       
  2660                     iconItem->setColor(opt->color);
       
  2661                     iconItem->setZValue(iconItem->parentItem()->zValue()+2);
       
  2662                 }
       
  2663                 break;
       
  2664             case P_ColorGridViewItem_borderIcon:
       
  2665                 if (const  HbStyleOptionColorGridViewItem* opt = qstyleoption_cast<const HbStyleOptionColorGridViewItem*>(option)) {
       
  2666                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2667                     if(!iconItem)
       
  2668                         return;
       
  2669                     iconItem->setIconName(opt->borderIcon);
       
  2670                     iconItem->setColor(opt->borderColor);
       
  2671                     iconItem->setZValue(iconItem->parentItem()->zValue()+1);
       
  2672                 }
       
  2673                 break;
       
  2674             case P_ColorGridViewItem_checkIcon:
       
  2675                 if (const  HbStyleOptionColorGridViewItem* opt = qstyleoption_cast<const HbStyleOptionColorGridViewItem*>(option)) {
       
  2676                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2677                     if(!iconItem)
       
  2678                         return;
       
  2679                     Q_UNUSED(opt);
       
  2680                     iconItem->setZValue(iconItem->parentItem()->zValue()+3);
       
  2681                 }
       
  2682                 break;
       
  2683 
       
  2684 
       
  2685             case P_GridViewItem_text:
       
  2686                 if (const  HbStyleOptionGridViewItem*opt = qstyleoption_cast<const HbStyleOptionGridViewItem*>(option)) {
       
  2687                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2688                     textItem->setAlignment(Qt::AlignCenter);
       
  2689                     textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  2690                     textItem->setText(opt->text);
       
  2691                 }
       
  2692                 break;
       
  2693 
       
  2694             case P_ItemHighlight_background:
       
  2695                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2696                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2697                     frameItem->setZValue(-2.0);
       
  2698                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2699                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_highlight"));
       
  2700                     frameItem->setGeometry(opt->boundingRect);
       
  2701                 }
       
  2702                 break;
       
  2703             case P_ToolBarExtension_background:
       
  2704                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2705                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2706                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2707                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_tb_ext"));
       
  2708                     frameItem->setGeometry(opt->boundingRect);
       
  2709                 }
       
  2710                 break;
       
  2711             case P_SliderPopup_background:
       
  2712                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
       
  2713                     Q_UNUSED(opt)
       
  2714                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2715                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2716                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_trans"));
       
  2717                 }
       
  2718                 break;
       
  2719             case P_ProgressBar_frame:
       
  2720                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {
       
  2721                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2722 
       
  2723                     if(opt->isSlider) {
       
  2724                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  2725                         if(opt->orientation == Qt::Horizontal){
       
  2726                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_progslider_unrated"));
       
  2727                         }
       
  2728                         else{
       
  2729                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_vprogslider_unrated"));
       
  2730                         }
       
  2731                     } else {
       
  2732                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2733                         if(opt->orientation == Qt::Horizontal){
       
  2734                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_h_frame"));
       
  2735                         }
       
  2736                         else{
       
  2737                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2738                             // frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_vprogbar_frame"));
       
  2739                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_v_frame"));
       
  2740                         }
       
  2741                     }
       
  2742                     frameItem->frameDrawer().setFillWholeRect(true);
       
  2743                     //frameItem->setZValue(-2.0);
       
  2744                 }
       
  2745                 break;
       
  2746             case P_ProgressBar_track:
       
  2747 
       
  2748                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {
       
  2749                     HbProgressTrackItem* frameItem = static_cast<HbProgressTrackItem*>(item);
       
  2750                     if(!frameItem->isVisible()) {
       
  2751                         break;
       
  2752                     }
       
  2753                     if(opt->isSlider) {
       
  2754                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  2755                         if(opt->orientation == Qt::Horizontal){
       
  2756                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_progslider_rated"));
       
  2757                         }
       
  2758                         else{
       
  2759                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_vprogslider_rated"));
       
  2760                         }
       
  2761                     } else {
       
  2762                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2763                         if(opt->secondoryType){
       
  2764                             if(opt->orientation == Qt::Horizontal){
       
  2765                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_down"));
       
  2766 
       
  2767                             }
       
  2768                             else{
       
  2769 
       
  2770                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2771                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progress_v_frame_second"));
       
  2772                             }
       
  2773                             //frameItem->setZValue(-2.0);
       
  2774                         }
       
  2775                         else{
       
  2776                             if(opt->orientation == Qt::Horizontal){
       
  2777                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_h_filled"));
       
  2778                             }
       
  2779                             else{
       
  2780                                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2781                                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_v_filled"));
       
  2782                             }
       
  2783                         }
       
  2784                     }
       
  2785                     frameItem->frameDrawer().setFillWholeRect(true);
       
  2786                     frameItem->setMaximum(opt->maximum);
       
  2787                     frameItem->setMinimum(opt->minimum);
       
  2788                     frameItem->setValue(opt->progressValue);
       
  2789                     frameItem->setInverted(opt->inverted);
       
  2790                     frameItem->setOrientation(opt->orientation);
       
  2791                     frameItem->update();
       
  2792                 }
       
  2793                 break;
       
  2794             case P_ProgressBar_waittrack:
       
  2795                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {                   
       
  2796                     HbRepeatIconItem *iconItem = static_cast<HbRepeatIconItem*>(item);
       
  2797                     iconItem->setOrientation(opt->orientation);
       
  2798                     if( !iconItem->isVisible() ) {
       
  2799                         break;
       
  2800                     }
       
  2801                     if(opt->orientation == Qt::Horizontal){
       
  2802                         iconItem->setName(QLatin1String("qtg_graf_progbar_h_wait"));
       
  2803                     }
       
  2804                     else{
       
  2805                         iconItem->setName(QLatin1String("qtg_graf_progbar_v_wait"));
       
  2806                     }
       
  2807                     if(opt->stopWaitAnimation){
       
  2808                         iconItem->stopAnimation();
       
  2809                     }
       
  2810 
       
  2811                 /*    HbFrameDrawer drawer("qtg_fr_progbar_mask",HbFrameDrawer::ThreePiecesHorizontal);
       
  2812                     drawer.setFillWholeRect(true);
       
  2813                     QPixmap track(opt->frameRect.size().toSize());
       
  2814                     track.fill(Qt::black);
       
  2815                     QPainter p;
       
  2816                     p.begin(&track);
       
  2817                     drawer.paint(&p, opt->frameRect);
       
  2818                     p.end();
       
  2819                     iconItem->setIconHeight(opt->frameRect.height());//set height of the image drawer
       
  2820                     iconItem->setGeometry(opt->frameRect);//set geometry of QGI
       
  2821                     
       
  2822                     QImage i=track.toImage();
       
  2823                     i.invertPixels();
       
  2824                     iconItem->setMask(QPixmap::fromImage(i));*/
       
  2825                 }
       
  2826                 break;
       
  2827 
       
  2828             case P_ProgressBar_slidertrack:
       
  2829                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {
       
  2830                     HbProgressTrackItem* frameItem = static_cast<HbProgressTrackItem*>(item);
       
  2831 
       
  2832                     if(opt->orientation == Qt::Horizontal){
       
  2833                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  2834                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_h_filled"));
       
  2835                     }
       
  2836                     else{
       
  2837                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
  2838                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_v_filled"));
       
  2839                     }
       
  2840                     frameItem->frameDrawer().setFillWholeRect(true);
       
  2841                     frameItem->setMaximum(opt->maximum);
       
  2842                     frameItem->setMinimum(opt->minimum);
       
  2843                     frameItem->setValue(opt->sliderValue);
       
  2844                     frameItem->setInverted(opt->inverted);
       
  2845                     frameItem->setMaskWidth(opt->maskWidth);//maskWidth != 0 when  progress handle's moving.
       
  2846                     frameItem->setOrientation(opt->orientation);
       
  2847                     frameItem->update();
       
  2848                     //frameItem->setZValue(-1.0);
       
  2849                 }
       
  2850                 break;
       
  2851 
       
  2852             case P_ProgressBar_mintext: {
       
  2853                  if (const HbStyleOptionProgressBar *opt = 
       
  2854                         qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {
       
  2855                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2856                         if(!item) {
       
  2857                             return;
       
  2858                         }
       
  2859                         textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  2860                         textItem->setText(opt->minText);                        	
       
  2861                     }
       
  2862                  break;
       
  2863             }
       
  2864 
       
  2865             case P_ProgressBar_maxtext: {
       
  2866                 if (const HbStyleOptionProgressBar *opt = 
       
  2867                         qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {
       
  2868                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  2869                         if(!item) {
       
  2870                             return;
       
  2871                         }
       
  2872                         textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  2873                         textItem->setText(opt->maxText);                        	
       
  2874                     }
       
  2875                 break;
       
  2876             }
       
  2877 
       
  2878             case P_RatingSlider_frame:{
       
  2879                 if (const HbStyleOptionRatingSlider *opt = qstyleoption_cast<const HbStyleOptionRatingSlider *>(option)) {                   
       
  2880                     HbRepeatItem *repeatItem = static_cast<HbRepeatItem*>(item);
       
  2881                     repeatItem->setRepeatingNumber(opt->noOfStars);
       
  2882                     if(opt->unRatedGraphicsName != QString()){
       
  2883                         repeatItem->setName(opt->unRatedGraphicsName);
       
  2884                     }
       
  2885                     else {
       
  2886                         repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated"));
       
  2887                     }
       
  2888                     repeatItem->setGeometry(opt->boundingRect);
       
  2889                     repeatItem->update();
       
  2890                 }
       
  2891                 break;
       
  2892             }
       
  2893 
       
  2894             case P_RatingSlider_track:{
       
  2895                 if (const HbStyleOptionRatingSlider *opt = qstyleoption_cast<const HbStyleOptionRatingSlider *>(option)) {                   
       
  2896                     HbRepeatMaskItem *repeatItem = static_cast<HbRepeatMaskItem*>(item);
       
  2897                     repeatItem->setMaskValue(opt->progressValue);
       
  2898                     repeatItem->setMaximum(opt->noOfIntervals);
       
  2899                     repeatItem->setInverted(opt->inverted);
       
  2900                     repeatItem->setRepeatingNumber(opt->noOfStars);
       
  2901                     if(opt->ratedGraphicsName != QString()){
       
  2902                         repeatItem->setName(opt->ratedGraphicsName);
       
  2903                     }
       
  2904                     else {
       
  2905                         repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated"));
       
  2906                     }
       
  2907                     repeatItem->setGeometry(opt->boundingRect);
       
  2908                     repeatItem->update();
       
  2909                 }
       
  2910                 break;
       
  2911             }
       
  2912 
       
  2913    		case P_ProgressSlider_handle:
       
  2914 					 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {
       
  2915                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2916 						iconItem->setIconName(QLatin1String("qtg_graf_progslider_handle_normal"));
       
  2917                         Q_UNUSED(opt)
       
  2918 						}
       
  2919 					    break;
       
  2920          case P_ProgressSlider_handleicon:
       
  2921                     if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {
       
  2922                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2923 
       
  2924                         if(!opt->thumbIcon.isNull()) {                           
       
  2925                             HbIcon icon(opt->thumbIcon.iconName());                       
       
  2926                             iconItem->setIconName(opt->thumbIcon.iconName());
       
  2927                         }
       
  2928                         else {
       
  2929                             switch(opt->sliderState) {
       
  2930                             case HbStyleOptionProgressBar::SliderStatePlayNormal:                            
       
  2931                                 iconItem->setIconName(QLatin1String("qtg_mono_play"));
       
  2932                                 break;
       
  2933                             case HbStyleOptionProgressBar::SliderStatePlayPressed:
       
  2934                                 iconItem->setIconName(QLatin1String("qtg_mono_play"));
       
  2935                                 break;
       
  2936                             case HbStyleOptionProgressBar::SliderStatePauseNormal:
       
  2937                                 iconItem->setIconName(QLatin1String("qtg_mono_pause"));
       
  2938                                 break;
       
  2939                             case HbStyleOptionProgressBar::SliderStatePausePressed:
       
  2940                                 iconItem->setIconName(QLatin1String("qtg_mono_pause"));
       
  2941                                 break;
       
  2942                             }
       
  2943                         }
       
  2944                     }
       
  2945 
       
  2946                     break;
       
  2947             case P_QueryInputMode_image:
       
  2948 
       
  2949              /*   if (const HbStyleOptionInputPopup *opt = qstyleoption_cast<const HbStyleOptionInputPopup *>(option)){
       
  2950                     if (HbIconItem *iconItem = static_cast<HbIconItem*>(item)) {
       
  2951                        iconItem->setIcon(*opt->modeIcon);
       
  2952                        iconItem->setPos(opt->editRect.width() - opt->modeIcon->width() - 6,opt->editRect.top()-3);
       
  2953                     }
       
  2954                 }*/
       
  2955                 break;
       
  2956             case P_ItemViewItem_frame: 
       
  2957                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
       
  2958                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  2959                     frameItem->setZValue(-4.0);
       
  2960 
       
  2961                     if (opt->background.canConvert<HbFrameBackground>()) {
       
  2962                         HbFrameBackground frame = opt->background.value<HbFrameBackground>();
       
  2963                         frameItem->frameDrawer().setFrameType(frame.frameType());
       
  2964                         frameItem->frameDrawer().setFrameGraphicsName(frame.frameGraphicsName());
       
  2965                     } else if (opt->viewItemType == Hb::ItemType_TreeViewItem) {
       
  2966                         if (opt->modelItemType == Hb::ParentItem) {
       
  2967                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2968                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? 
       
  2969                                 QLatin1String("qtg_fr_popup_list_parent_normal") : QLatin1String("qtg_fr_list_parent_normal"));
       
  2970                         } else if (opt->modelItemType == Hb::SeparatorItem) {
       
  2971                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2972                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_separator"));
       
  2973                         } else {
       
  2974                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2975                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? 
       
  2976                                 QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal"));
       
  2977                         }
       
  2978                     } else if ( opt->viewItemType == Hb::ItemType_ListViewItem
       
  2979                                 || opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) {
       
  2980                         if (opt->modelItemType == Hb::SeparatorItem) {
       
  2981                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2982                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_separator"));
       
  2983                         } else {
       
  2984                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2985                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? 
       
  2986                                 QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal"));
       
  2987                         }
       
  2988                     } else if (opt->viewItemType == Hb::ItemType_GridViewItem
       
  2989 								|| opt->viewItemType == HbPrivate::ItemType_ColorGridViewItem) {
       
  2990                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  2991                         frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? 
       
  2992                             QLatin1String("qtg_fr_popup_grid_normal") : QLatin1String("qtg_fr_grid_normal"));
       
  2993                     }
       
  2994                     else{
       
  2995                         frameItem->frameDrawer().setFrameGraphicsName(QString());
       
  2996                     }
       
  2997                 }
       
  2998                 break;
       
  2999             case P_ItemViewItem_focus:
       
  3000                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
       
  3001                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
       
  3002                     frameItem->setZValue(-1.0);
       
  3003                     frameItem->setGeometry(opt->boundingRect);
       
  3004 
       
  3005                     if (opt->viewItemType == Hb::ItemType_TreeViewItem
       
  3006                         || opt->viewItemType == Hb::ItemType_ListViewItem
       
  3007                         || opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) {
       
  3008                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  3009                         frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ?
       
  3010                             QLatin1String("qtg_fr_popup_list_pressed") : QLatin1String("qtg_fr_list_pressed"));
       
  3011                     } else if (     opt->viewItemType == Hb::ItemType_GridViewItem
       
  3012                                 ||  opt->viewItemType == HbPrivate::ItemType_ColorGridViewItem) {
       
  3013                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  3014                         frameItem->frameDrawer().setFrameGraphicsName(opt->insidePopup ?
       
  3015                             QLatin1String("qtg_fr_popup_grid_pressed") : QLatin1String("qtg_fr_grid_pressed"));
       
  3016                     } else {
       
  3017                         setItemName(frameItem,QString());
       
  3018                         frameItem->frameDrawer().setFrameGraphicsName(QString());
       
  3019                     }
       
  3020                 }
       
  3021                 break;
       
  3022             case P_SelectionControl_selectionstart://fallthrough
       
  3023             case P_SelectionControl_selectionend://fallthrough
       
  3024             {
       
  3025                 if (HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item)) {
       
  3026                     iconItem->setSize(iconItem->preferredSize());
       
  3027                 }
       
  3028                 break;
       
  3029             }
       
  3030             case P_TreeViewItem_expandicon:
       
  3031                 if (const HbStyleOptionTreeViewItem *opt = qstyleoption_cast<const HbStyleOptionTreeViewItem *>(option)) {
       
  3032                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  3033                     if (opt->expanded) {
       
  3034                         iconItem->setIconName(opt->insidePopup ? QLatin1String("qtg_mono_expand") : QLatin1String("qtg_small_expand"));
       
  3035                     } else {
       
  3036                         iconItem->setIconName(opt->insidePopup ? QLatin1String("qtg_mono_collapse") : QLatin1String("qtg_small_collapse"));
       
  3037                     }
       
  3038                 }
       
  3039                 break;
       
  3040             case P_ScrollArea_continuationbottom:
       
  3041                 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) {
       
  3042                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_list_mask_b"));
       
  3043                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  3044                     frameItem->setZValue(1);
       
  3045                 }
       
  3046                 break;
       
  3047             case P_ScrollArea_continuationtop:
       
  3048                 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) {
       
  3049                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_list_mask_t"));
       
  3050                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  3051                     frameItem->setZValue(1);
       
  3052                 }
       
  3053                 break;
       
  3054             case P_ScrollArea_continuationright:
       
  3055                 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) {
       
  3056                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_list_mask_r"));
       
  3057                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  3058                     frameItem->setZValue(1);
       
  3059                 }
       
  3060                 break;
       
  3061             case P_ScrollArea_continuationleft:
       
  3062                 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) {
       
  3063                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_list_mask_l"));
       
  3064                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  3065                     frameItem->setZValue(1);
       
  3066                 }
       
  3067                 break;
       
  3068 
       
  3069             case P_TumbleView_background:
       
  3070                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
       
  3071                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
       
  3072                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_bg");
       
  3073                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  3074                         frameItem->setZValue(-5);
       
  3075                         //TODO:temp fix, issue with css rule picking in derived class
       
  3076                         //frameItem->setGeometry(opt->boundingRect);
       
  3077                         Q_UNUSED(opt);
       
  3078                     }
       
  3079                 }
       
  3080                 break;
       
  3081             case P_TumbleView_frame: 
       
  3082                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
       
  3083                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
       
  3084                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_overlay");
       
  3085                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  3086                         frameItem->setZValue(-4);
       
  3087                         //TODO:temp fix, issue with css rule picking in derived class
       
  3088                         //frameItem->setGeometry(opt->boundingRect);
       
  3089                         Q_UNUSED(opt);
       
  3090                     }
       
  3091                 }
       
  3092                 break;
       
  3093             case P_TumbleView_highlight:
       
  3094                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
       
  3095                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
       
  3096                         frameItem->frameDrawer().setFrameGraphicsName("qtg_graf_tumbler_highlight_sec");
       
  3097                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  3098                         frameItem->setZValue(2);
       
  3099                         //TODO:temp fix, issue with css rule picking in derived class
       
  3100                         
       
  3101                         //frameItem->setGeometry(0,(opt->boundingRect.height()-frameItem->boundingRect().height())/2,opt->boundingRect.width(),opt->boundingRect.height());
       
  3102                         Q_UNUSED(opt);
       
  3103                     }
       
  3104                     
       
  3105                 }
       
  3106                 break;            
       
  3107             case P_IndexFeedback_popup_text:
       
  3108                 if (const HbStyleOptionIndexFeedback *opt = qstyleoption_cast<const HbStyleOptionIndexFeedback *>(option)) {
       
  3109                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  3110                     textItem->setFontSpec(opt->fontSpec);
       
  3111                     textItem->setGeometry(opt->textRect);
       
  3112                     textItem->setText(opt->text);
       
  3113                 }
       
  3114                 break;
       
  3115             case P_IndexFeedback_popup_background:
       
  3116                 if (const HbStyleOptionIndexFeedback *opt = qstyleoption_cast<const HbStyleOptionIndexFeedback *>(option)) {
       
  3117                     if (HbFrameItem* frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
       
  3118                         frameItem->setGeometry(opt->popupRect);
       
  3119                     }
       
  3120                 }
       
  3121                 break;
       
  3122             case P_DateTimePicker_background:
       
  3123                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
       
  3124                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
       
  3125                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_bg");
       
  3126                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  3127                         frameItem->setZValue(-5);
       
  3128                         //TODO:temp fix, issue with css rule picking in derived class
       
  3129                         //frameItem->setGeometry(opt->boundingRect);
       
  3130                         Q_UNUSED(opt);
       
  3131                     }
       
  3132                 }
       
  3133                 break;
       
  3134             case P_DateTimePicker_frame: 
       
  3135                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
       
  3136                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
       
  3137                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_overlay");
       
  3138                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  3139                         frameItem->setZValue(1);
       
  3140                         //TODO:temp fix, issue with css rule picking in derived class
       
  3141                         //frameItem->setGeometry(opt->boundingRect);
       
  3142                         Q_UNUSED(opt);
       
  3143                     }
       
  3144                 }
       
  3145                 break;
       
  3146             case P_DateTimePicker_separator:
       
  3147                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
       
  3148                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
       
  3149                         frameItem->frameDrawer().setFrameGraphicsName("qtg_graf_tumbler_highlight_pri");
       
  3150                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
       
  3151                         frameItem->setZValue(0);
       
  3152                         //TODO:temp fix, issue with css rule picking in derived class
       
  3153 
       
  3154                         //frameItem->setGeometry(0,(opt->boundingRect.height()-frameItem->boundingRect().height())/2,opt->boundingRect.width(),opt->boundingRect.height());
       
  3155                         Q_UNUSED(opt);
       
  3156                     }
       
  3157 
       
  3158                 }
       
  3159                 break;
       
  3160             case P_InputDialog_text:
       
  3161                 if (const HbStyleOptionInputDialog *opt = 
       
  3162                     qstyleoption_cast<const HbStyleOptionInputDialog*>(option)) {
       
  3163                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  3164                     if(!item) {
       
  3165                         return;
       
  3166                     }
       
  3167                     textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  3168                     textItem->setText(opt->text);                        	
       
  3169                 }
       
  3170                 break;
       
  3171              case P_InputDialog_additional_text:
       
  3172                 if (const HbStyleOptionInputDialog *opt = 
       
  3173                     qstyleoption_cast<const HbStyleOptionInputDialog*>(option)) {
       
  3174                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
       
  3175                     if(!item) {
       
  3176                         return;
       
  3177                     }
       
  3178                     textItem->setTextWrapping(Hb::TextWrapAnywhere);
       
  3179                     textItem->setText(opt->additionalText);                        	
       
  3180                 } 
       
  3181                 break;
       
  3182              default:
       
  3183                 return;
       
  3184     };
       
  3185 }
       
  3186 
       
  3187 /*!
       
  3188   From qstylesheetstyle.cpp (declarations(...))
       
  3189   \internal
       
  3190 */
       
  3191 static HbVector<HbCss::Declaration> declarations(
       
  3192     const HbVector<HbCss::StyleRule> &styleRules,
       
  3193     const QString &part,
       
  3194     const HbDeviceProfile &profile)
       
  3195 {
       
  3196     quint64 pseudoClass(0);
       
  3197 
       
  3198     if ( profile.orientation() == Qt::Horizontal ) {
       
  3199         pseudoClass |= HbCss::PseudoClass_Landscape;
       
  3200     } else {
       
  3201         pseudoClass |= HbCss::PseudoClass_Portrait;
       
  3202     }
       
  3203 
       
  3204     HbVector<HbCss::Declaration> decls;
       
  3205     for (int i = 0; i < styleRules.count(); i++) {
       
  3206         const HbCss::Selector& selector = styleRules.at(i).selectors.at(0);
       
  3207         // Rules with pseudo elements don't cascade. This is an intentional
       
  3208         // diversion for CSS
       
  3209         if (part.compare(selector.pseudoElement(), Qt::CaseInsensitive) != 0)
       
  3210             continue;
       
  3211         quint64 negated = 0;
       
  3212         quint64 cssClass = selector.pseudoClass(&negated);
       
  3213         if ((pseudoClass == HbCss::PseudoClass_Any) || (cssClass == HbCss::PseudoClass_Unspecified)
       
  3214             || ((((cssClass & pseudoClass) == cssClass)) && ((negated & pseudoClass) == 0)))
       
  3215             decls += styleRules.at(i).declarations;
       
  3216     }
       
  3217     return decls;
       
  3218 }
       
  3219 
       
  3220 /*!
       
  3221   used by the polish() method
       
  3222   \internal
       
  3223 */
       
  3224 void HbStylePrivate::polishItem(
       
  3225     const HbVector<HbCss::StyleRule> &styleRules,
       
  3226     HbWidget* widget,
       
  3227     QGraphicsItem *item,
       
  3228     const QString &name,
       
  3229     bool layoutDefined) const
       
  3230 {
       
  3231     if (name.isEmpty() && widget != item) {
       
  3232         return;
       
  3233     }
       
  3234 
       
  3235 #ifdef HBSTYLE_DEBUG
       
  3236     qDebug() << "HbStyle::polish : -- --";
       
  3237     if ( widget == item ) {
       
  3238         qDebug() << "HbStyle::polish : -- polishItem: " << widget->metaObject()->className();
       
  3239     } else if ( item ) {
       
  3240         qDebug() << "HbStyle::polish : -- polishItem: " << name << "(existing item)";
       
  3241     } else {
       
  3242         qDebug() << "HbStyle::polish : -- polishItem: " << name << "(missing item)";
       
  3243     }
       
  3244 #endif
       
  3245 
       
  3246     HbDeviceProfile profile(HbDeviceProfile::profile(widget));
       
  3247 
       
  3248     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, profile);
       
  3249 #ifdef HBSTYLE_DEBUG
       
  3250     qDebug() << "HbStyle::polish : -- Number of maching CSS declarations: " << decl.count();
       
  3251 #endif
       
  3252     HbCss::ValueExtractor extractor(decl, layoutParameters, profile);
       
  3253     HbCss::GeometryValues geomValues;
       
  3254     HbCss::PositionValues posValues;
       
  3255 
       
  3256     bool extracted = extractor.extractGeometry(geomValues);
       
  3257 #ifndef HBSTYLE_DEBUG
       
  3258     Q_UNUSED(extracted);
       
  3259 #endif
       
  3260 #ifdef HBSTYLE_DEBUG
       
  3261     if ( !extracted ) {
       
  3262         qDebug() << "HbStyle::polish : -- No geometry information found";
       
  3263     }
       
  3264 #endif
       
  3265     extracted = extractor.extractPosition(posValues);
       
  3266 #ifdef HBSTYLE_DEBUG
       
  3267     if ( !extracted ) {
       
  3268         qDebug() << "HbStyle::polish : -- No position information found";
       
  3269     }
       
  3270 #endif
       
  3271 
       
  3272     if ( item ) {
       
  3273         if (posValues.mFlags & HbCss::ExtractedZValue) {
       
  3274 #ifdef HBSTYLE_DEBUG
       
  3275             qDebug() << "HbStyle::polish : -- Setting zvalue: " << posValues.mZ;
       
  3276 #endif
       
  3277             item->setZValue(posValues.mZ);
       
  3278         }
       
  3279     }
       
  3280 
       
  3281     QGraphicsWidget *gWidget = (item && item->isWidget())
       
  3282         ? static_cast<QGraphicsWidget*>(item)
       
  3283         : 0;
       
  3284     if ( gWidget ) {
       
  3285         if (posValues.mFlags & HbCss::ExtractedMirroring) {
       
  3286 #ifdef HBSTYLE_DEBUG
       
  3287             qDebug() << "HbStyle::polish : -- Setting mirroring: " << posValues.mMirroring;
       
  3288 #endif
       
  3289             if(posValues.mMirroring){
       
  3290                 gWidget->unsetLayoutDirection();
       
  3291             }else{
       
  3292                 gWidget->setLayoutDirection(Qt::LeftToRight);
       
  3293             }
       
  3294         }
       
  3295     }
       
  3296 
       
  3297     HbWidgetBase *hbWidget = qobject_cast<HbWidgetBase*>(gWidget);
       
  3298     if ( hbWidget ) {
       
  3299         HbWidgetBasePrivate* hbWidget_p = HbWidgetBasePrivate::d_ptr(hbWidget);
       
  3300         QFont font;
       
  3301         HbFontSpec fontSpec;
       
  3302         int dummy;
       
  3303         if (extractor.extractFont(&font, &fontSpec, &dummy)) {
       
  3304             if ( !fontSpec.isNull() ) {
       
  3305                 if ( font == QFont() ) {
       
  3306 #ifdef HBSTYLE_DEBUG
       
  3307                     qDebug() << "HbStyle::polish : -- Setting fontspec: " << fontSpec.role();
       
  3308 #endif
       
  3309                     hbWidget->setFontSpec(fontSpec);
       
  3310                 } else {
       
  3311 #ifdef HBSTYLE_DEBUG
       
  3312                     qDebug() << "HbStyle::polish : -- Setting fontspec with overrides: "
       
  3313                              << fontSpec.role() << font;
       
  3314 #endif
       
  3315                     hbWidget->setFont(fontSpec.font().resolve(font));
       
  3316                 }
       
  3317             } else {
       
  3318 #ifdef HBSTYLE_DEBUG
       
  3319                 qDebug() << "HbStyle::polish : -- Setting explicit font: " << font;
       
  3320 #endif
       
  3321                 hbWidget->setFont(font);
       
  3322             }
       
  3323         }
       
  3324 
       
  3325         HbIconItem* icon = qobject_cast<HbIconItem*>(hbWidget);
       
  3326         if (icon) {
       
  3327             Qt::AspectRatioMode mode;
       
  3328             if (extractor.extractAspectRatioMode(&mode) 
       
  3329 				&& !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode)) {
       
  3330 #ifdef HBSTYLE_DEBUG
       
  3331                 qDebug() << "HbStyle::polish : -- Setting aspect ratio mode: " << mode;
       
  3332 #endif
       
  3333                 icon->setAspectRatioMode(mode);
       
  3334                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode, false);
       
  3335             }
       
  3336             if(!hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconBrush)){
       
  3337                 QBrush brush;
       
  3338                 QString uri;
       
  3339                 HbCss::Repeat repeat = HbCss::Repeat_XY;
       
  3340                 Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft;
       
  3341                 HbCss::Attachment attachment = HbCss::Attachment_Scroll;
       
  3342                 HbCss::Origin origin = HbCss::Origin_Padding;
       
  3343                 HbCss::Origin clip = HbCss::Origin_Border;
       
  3344                 if (extractor.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) {
       
  3345 #ifdef HBSTYLE_DEBUG
       
  3346                     qDebug() << "HbStyle::polish : -- Setting icon background: " << brush;
       
  3347 #endif
       
  3348                     icon->setBrush( brush );
       
  3349                 } else {
       
  3350 #ifdef HBSTYLE_DEBUG
       
  3351                     qDebug() << "HbStyle::polish : -- Resetting icon background";
       
  3352 #endif
       
  3353                     icon->setBrush( QBrush() );
       
  3354                 }
       
  3355                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconBrush, false);
       
  3356             }
       
  3357         }
       
  3358 
       
  3359         HbTextItem* text = qobject_cast<HbTextItem*>(hbWidget);
       
  3360         if (text) {
       
  3361             HbCss::TextValues textValues;
       
  3362             if ( extractor.extractTextValues( textValues ) ) {
       
  3363                 if ( textValues.mFlags & HbCss::ExtractedLineCountMin
       
  3364                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3365 #ifdef HBSTYLE_DEBUG
       
  3366                     qDebug() << "HbStyle::polish : -- Setting text min lines: " << textValues.mLineCountMin;
       
  3367 #endif
       
  3368                     text->setMinimumLines( textValues.mLineCountMin );
       
  3369                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
       
  3370                 }
       
  3371                 if ( textValues.mFlags & HbCss::ExtractedLineCountMax
       
  3372                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax)) {
       
  3373 #ifdef HBSTYLE_DEBUG
       
  3374                     qDebug() << "HbStyle::polish : -- Setting text max lines: " << textValues.mLineCountMax;
       
  3375 #endif
       
  3376                     text->setMaximumLines( textValues.mLineCountMax );
       
  3377                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
       
  3378                 }
       
  3379             }
       
  3380             if ( posValues.mFlags & HbCss::ExtractedTextAlign 
       
  3381                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
       
  3382 #ifdef HBSTYLE_DEBUG
       
  3383                 qDebug() << "HbStyle::polish : -- Setting text alignment: " << posValues.mTextAlignment;
       
  3384 #endif
       
  3385                 text->setAlignment( posValues.mTextAlignment );
       
  3386                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
       
  3387             }
       
  3388             if ( posValues.mFlags & HbCss::ExtractedWrapMode 
       
  3389                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
       
  3390 #ifdef HBSTYLE_DEBUG
       
  3391                 qDebug() << "HbStyle::polish : -- Setting wrap mode : " << posValues.mTextWrapMode;
       
  3392 #endif
       
  3393                 text->setTextWrapping( posValues.mTextWrapMode );
       
  3394                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
       
  3395             }
       
  3396         }
       
  3397 
       
  3398         HbRichTextItem* richtext = qobject_cast<HbRichTextItem*>(hbWidget);
       
  3399         if (richtext) {
       
  3400             if ( posValues.mFlags & HbCss::ExtractedTextAlign
       
  3401                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
       
  3402 #ifdef HBSTYLE_DEBUG
       
  3403                 qDebug() << "HbStyle::polish : -- Setting text alignment: " << posValues.mTextAlignment;
       
  3404 #endif
       
  3405                 richtext->setAlignment( posValues.mTextAlignment );
       
  3406                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
       
  3407             }
       
  3408             if ( posValues.mFlags & HbCss::ExtractedWrapMode 
       
  3409                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
       
  3410 #ifdef HBSTYLE_DEBUG
       
  3411                 qDebug() << "HbStyle::polish : -- Setting wrap mode : " << posValues.mTextWrapMode;
       
  3412 #endif
       
  3413                 richtext->setTextWrapping( posValues.mTextWrapMode );
       
  3414                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
       
  3415             }
       
  3416         }
       
  3417 
       
  3418         HbFrameItem *frame = qobject_cast<HbFrameItem*>(hbWidget);
       
  3419         if (frame && !frame->frameDrawer().d->testBorderApiProtectionFlag()) {
       
  3420             qreal borderWidths[HbCss::NumEdges] = { 0.0,0.0,0.0,0.0 };
       
  3421             QBrush borderColors[HbCss::NumEdges];
       
  3422             HbCss::BorderStyle borderStyles[HbCss::NumEdges];
       
  3423             QSize borderRadii[4];
       
  3424 
       
  3425             if (extractor.extractBorder(borderWidths,borderColors,borderStyles,borderRadii)) {
       
  3426 #ifdef HBSTYLE_DEBUG
       
  3427                 qDebug() << "HbStyle::polish : -- Setting border widths (l,t,r,b):"
       
  3428                     << borderWidths[HbCss::LeftEdge]
       
  3429                     << borderWidths[HbCss::TopEdge]
       
  3430                     << borderWidths[HbCss::RightEdge]
       
  3431                     << borderWidths[HbCss::BottomEdge];
       
  3432 #endif
       
  3433                 frame->frameDrawer().setBorderWidths(
       
  3434                     borderWidths[HbCss::LeftEdge],
       
  3435                     borderWidths[HbCss::TopEdge],
       
  3436                     borderWidths[HbCss::RightEdge],
       
  3437                     borderWidths[HbCss::BottomEdge]);
       
  3438                 frame->frameDrawer().d->setBorderApiProtectionFlag(false);
       
  3439             }
       
  3440         }
       
  3441         if ( hbWidget->inherits( "HbLineEdit" ) ) {
       
  3442             HbCss::TextValues textValues;
       
  3443             if ( extractor.extractTextValues( textValues ) ) {
       
  3444                 if ( textValues.mFlags & HbCss::ExtractedLineCountMin
       
  3445                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3446 #ifdef HBSTYLE_DEBUG
       
  3447                     qDebug() << "HbStyle::polish : -- Setting text min lines: " << textValues.mLineCountMin;
       
  3448 #endif
       
  3449                     hbWidget->setProperty( "minRows", textValues.mLineCountMin );
       
  3450                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
       
  3451                 }
       
  3452                 if ( textValues.mFlags & HbCss::ExtractedLineCountMax
       
  3453                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3454 #ifdef HBSTYLE_DEBUG
       
  3455                     qDebug() << "HbStyle::polish : -- Setting text max lines: " << textValues.mLineCountMax;
       
  3456 #endif
       
  3457                     hbWidget->setProperty( "maxRows", textValues.mLineCountMax );
       
  3458                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
       
  3459                 }
       
  3460             }
       
  3461         }
       
  3462     }
       
  3463 
       
  3464     QGraphicsLayoutItem* lItem = (item && item->isWidget()) ? (QGraphicsLayoutItem*)static_cast<QGraphicsWidget*>(item) : 0;
       
  3465     if ( !lItem ) {
       
  3466         lItem = widget->layoutPrimitive(name);
       
  3467         if ( lItem && !lItem->graphicsItem() ) {
       
  3468             // assume it is spacer
       
  3469             static_cast<HbMeshLayout*>(widget->layout())->setItemId( lItem, name );
       
  3470         }
       
  3471     }
       
  3472     if ( lItem ) {
       
  3473         if ( geomValues.mFlags & HbCss::ExtractedMinW ) {
       
  3474 #ifdef HBSTYLE_DEBUG
       
  3475             qDebug() << "HbStyle::polish : -- Setting minimum width: " << geomValues.mMinW;
       
  3476 #endif
       
  3477             lItem->setMinimumWidth( geomValues.mMinW );
       
  3478         }
       
  3479         if ( geomValues.mFlags & HbCss::ExtractedMinH ) {
       
  3480 #ifdef HBSTYLE_DEBUG
       
  3481             qDebug() << "HbStyle::polish : -- Setting minimum height: " << geomValues.mMinH;
       
  3482 #endif
       
  3483             lItem->setMinimumHeight( geomValues.mMinH );
       
  3484         }
       
  3485         if ( geomValues.mFlags & HbCss::ExtractedPrefW ) {
       
  3486 #ifdef HBSTYLE_DEBUG
       
  3487             qDebug() << "HbStyle::polish : -- Setting preferred width: " << geomValues.mPrefW;
       
  3488 #endif
       
  3489             lItem->setPreferredWidth( geomValues.mPrefW );
       
  3490         }
       
  3491         if ( geomValues.mFlags & HbCss::ExtractedPrefH ) {
       
  3492 #ifdef HBSTYLE_DEBUG
       
  3493             qDebug() << "HbStyle::polish : -- Setting preferred height: " << geomValues.mPrefH;
       
  3494 #endif
       
  3495             lItem->setPreferredHeight( geomValues.mPrefH );
       
  3496         }
       
  3497         if ( geomValues.mFlags & HbCss::ExtractedMaxW ) {
       
  3498 #ifdef HBSTYLE_DEBUG
       
  3499             qDebug() << "HbStyle::polish : -- Setting maximum width: " << geomValues.mMaxW;
       
  3500 #endif
       
  3501             lItem->setMaximumWidth( geomValues.mMaxW );
       
  3502         }
       
  3503         if ( geomValues.mFlags & HbCss::ExtractedMaxH ) {
       
  3504 #ifdef HBSTYLE_DEBUG
       
  3505             qDebug() << "HbStyle::polish : -- Setting maximum height: " << geomValues.mMaxH;
       
  3506 #endif
       
  3507             lItem->setMaximumHeight( geomValues.mMaxH );
       
  3508         }
       
  3509         QSizePolicy itemPol = lItem->sizePolicy();
       
  3510         if ( geomValues.mFlags & HbCss::ExtractedPolHor ) {
       
  3511 #ifdef HBSTYLE_DEBUG
       
  3512             qDebug() << "HbStyle::polish : -- Setting horizontal size policy: " << geomValues.mSizePolicy.horizontalPolicy();
       
  3513 #endif
       
  3514             itemPol.setHorizontalPolicy(geomValues.mSizePolicy.horizontalPolicy());
       
  3515         }
       
  3516         if ( geomValues.mFlags & HbCss::ExtractedPolVer ) {
       
  3517 #ifdef HBSTYLE_DEBUG
       
  3518             qDebug() << "HbStyle::polish : -- Setting vertical size policy: " << geomValues.mSizePolicy.verticalPolicy();
       
  3519 #endif
       
  3520             itemPol.setVerticalPolicy(geomValues.mSizePolicy.verticalPolicy());
       
  3521         }
       
  3522         lItem->setSizePolicy(itemPol);
       
  3523     }
       
  3524 
       
  3525     if (layoutDefined) {
       
  3526         HbMeshLayout *layout = static_cast<HbMeshLayout*>(widget->layout());
       
  3527         if ( layout ) {
       
  3528             if (posValues.mFlags & HbCss::ExtractedLeft) {
       
  3529 #ifdef HBSTYLE_DEBUG
       
  3530                 qDebug() << "HbStyle::polish : -- Setting left override: " << posValues.mLeft;
       
  3531 #endif
       
  3532                 layout->overrideSpacing(name, Hb::LeftEdge, posValues.mLeft);
       
  3533             }
       
  3534             if (posValues.mFlags & HbCss::ExtractedRight) {
       
  3535 #ifdef HBSTYLE_DEBUG
       
  3536                 qDebug() << "HbStyle::polish : -- Setting right override: " << posValues.mRight;
       
  3537 #endif
       
  3538                 layout->overrideSpacing(name, Hb::RightEdge, posValues.mRight);
       
  3539             }
       
  3540             if (posValues.mFlags & HbCss::ExtractedTop) {
       
  3541 #ifdef HBSTYLE_DEBUG
       
  3542                 qDebug() << "HbStyle::polish : -- Setting top override: " << posValues.mTop;
       
  3543 #endif
       
  3544                 layout->overrideSpacing(name, Hb::TopEdge, posValues.mTop);
       
  3545             }
       
  3546             if (posValues.mFlags & HbCss::ExtractedBottom) {
       
  3547 #ifdef HBSTYLE_DEBUG
       
  3548                 qDebug() << "HbStyle::polish : -- Setting bottom override: " << posValues.mBottom;
       
  3549 #endif
       
  3550                 layout->overrideSpacing(name, Hb::BottomEdge, posValues.mBottom);
       
  3551             }
       
  3552             if (posValues.mFlags & HbCss::ExtractedCenterH) {
       
  3553 #ifdef HBSTYLE_DEBUG
       
  3554                 qDebug() << "HbStyle::polish : -- Setting centerh override: " << posValues.mCenterH;
       
  3555 #endif
       
  3556                 layout->overrideSpacing(name, Hb::CenterHEdge, posValues.mCenterH);
       
  3557             }
       
  3558             if (posValues.mFlags & HbCss::ExtractedCenterV) {
       
  3559 #ifdef HBSTYLE_DEBUG
       
  3560                 qDebug() << "HbStyle::polish : -- Setting centerv override: " << posValues.mCenterV;
       
  3561 #endif
       
  3562                 layout->overrideSpacing(name, Hb::CenterVEdge, posValues.mCenterV);
       
  3563             }
       
  3564         }
       
  3565     }
       
  3566 }
       
  3567 
       
  3568 
       
  3569 #define NODEPTR_N(x) HbCss::StyleSelector::NodePtr n = {n.ptr = (void *)x};
       
  3570 /*!
       
  3571     Polishes the appearance of the given \a widget.
       
  3572 
       
  3573     This method should be called only by HbWidget (base class). The inherited
       
  3574     classes should not call this method directly, but use the HbWidget's
       
  3575     polish loop instead.
       
  3576     
       
  3577     This method reads the CSS and WidgetML definition for a given widget and positions
       
  3578     the sub-elements inside it. Note you need to set the names for the sub-elements
       
  3579     with HbStyle::setItemName method before this method is called.
       
  3580 
       
  3581     Note that this method is heavy on the system resources and should be called
       
  3582     absolutely when necessary by the widget.
       
  3583     
       
  3584     \param widget, HbWidget to be polished
       
  3585     \param params, style parameters to be returned to the caller
       
  3586 */
       
  3587 void HbStyle::polish(HbWidget *widget, HbStyleParameters &params)
       
  3588 {
       
  3589     Q_D( HbStyle );
       
  3590 #ifdef HBSTYLE_DEBUG
       
  3591     qDebug() << "HbStyle::polish : -- -- -- --";
       
  3592 #endif
       
  3593     if( !widget ) {
       
  3594         return;
       
  3595     }
       
  3596 #ifdef HBSTYLE_DEBUG
       
  3597     qDebug() << "HbStyle::polish : Polishing" << widget->metaObject()->className();
       
  3598 #endif
       
  3599 
       
  3600     HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Layouts);
       
  3601     if(!styleLoader){
       
  3602 #ifdef HBSTYLE_DEBUG
       
  3603         qDebug() << "HbStyle::polish : HbLayeredStyleLoader returned a null pointer.";
       
  3604 #endif
       
  3605         return;
       
  3606     }
       
  3607     HbDeviceProfile profile(HbDeviceProfile::profile(widget));
       
  3608     NODEPTR_N(widget);
       
  3609 
       
  3610     HbVector<HbCss::StyleRule> styleRules;
       
  3611     QVariant widgetStyleCache = widget->property( HbStyleRulesCacheId::hbStyleRulesForNodeCache );
       
  3612 
       
  3613     if(widgetStyleCache.isValid()) {
       
  3614         QString widgetStyleCacheId = widgetStyleCache.toString();
       
  3615         if (d->styleRulesCache.contains(widgetStyleCacheId)) {
       
  3616             styleRules = d->styleRulesCache.value(widgetStyleCacheId);
       
  3617         } else {
       
  3618             styleRules = styleLoader->styleRulesForNode(n, profile.orientation());
       
  3619             d->styleRulesCache[widgetStyleCacheId] = styleRules;
       
  3620         }
       
  3621     } else {
       
  3622         styleRules = styleLoader->styleRulesForNode(n, profile.orientation());
       
  3623     }
       
  3624 
       
  3625     if (!styleRules.count()) {
       
  3626 #ifdef HBSTYLE_DEBUG
       
  3627         qDebug() << "HbStyle::polish : No style rules found.";
       
  3628 #endif
       
  3629         return;
       
  3630     }
       
  3631     const HbVector<HbCss::Declaration> decl = declarations(styleRules, "", profile);
       
  3632 #ifdef HBSTYLE_DEBUG
       
  3633     qDebug() << "HbStyle::polish : Number of maching CSS declarations: " << decl.count();
       
  3634 #endif
       
  3635     d->ensureLayoutParameters(profile);
       
  3636 
       
  3637     HbCss::ValueExtractor extractor(decl, d->layoutParameters, profile);
       
  3638     QString layoutName;
       
  3639     QString sectionName;
       
  3640 
       
  3641     if ( params.count() ) {
       
  3642 #ifdef HBSTYLE_DEBUG
       
  3643         qDebug() << "HbStyle::polish : Extracting parameters.";
       
  3644 #endif
       
  3645         extractor.extractParameters( params.params(), params.values() );
       
  3646     }
       
  3647 
       
  3648     bool layoutDefined = extractor.extractLayout(&layoutName, &sectionName);
       
  3649 #ifdef HBSTYLE_DEBUG
       
  3650     if (!layoutDefined) {
       
  3651         qDebug() << "HbStyle::polish : Couldn't find layout name for the widget.";
       
  3652     } else {
       
  3653         qDebug() << "HbStyle::polish : Layout name: " << layoutName;
       
  3654     }
       
  3655 #endif
       
  3656 
       
  3657     QStringList meshIds;
       
  3658     HbMeshLayout *meshLayout(0);
       
  3659     if (layoutDefined) {
       
  3660 
       
  3661         QString cachedLayoutName = d->widgetLayoutNames[widget];
       
  3662         bool cached = (cachedLayoutName == layoutName );
       
  3663         if ( !cached ) {
       
  3664 #ifdef HBSTYLE_DEBUG
       
  3665             qDebug() << "LayoutName cache miss.";
       
  3666 #endif
       
  3667             HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
       
  3668             if ( !loader->loadWidgetML(widget, layoutName, sectionName)) {
       
  3669 #ifdef HBSTYLE_DEBUG
       
  3670                 qDebug() << "HbStyle::polish : Failed to load WidgetML";
       
  3671 #endif
       
  3672                 return;       
       
  3673             }
       
  3674             d->widgetLayoutNames[widget] = layoutName;
       
  3675             if (cachedLayoutName.isNull()) {
       
  3676                 // Cached for the first time. Connect to destroyed signal.
       
  3677                 QObject::connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(widgetDestroyed(QObject*)));
       
  3678 #ifdef HBSTYLE_DEBUG
       
  3679                 qDebug() << "Cached first time. Connected to destroy signal.";
       
  3680             } else {
       
  3681                 qDebug() << "Cached nth time.";
       
  3682 #endif
       
  3683             }
       
  3684         }
       
  3685         meshLayout = static_cast<HbMeshLayout*>(widget->layout());
       
  3686         if (cached) {
       
  3687 #ifdef HBSTYLE_DEBUG
       
  3688             qDebug() << "LayoutName cache hit.";
       
  3689 #endif
       
  3690             meshLayout->clearItemIds();
       
  3691         }
       
  3692 
       
  3693         meshLayout->setItemId(meshLayout, "");
       
  3694         meshIds = meshLayout->nodeIds();
       
  3695 
       
  3696     }
       
  3697 
       
  3698     // polish widget and subitems
       
  3699     d->polishItem(styleRules, widget, widget, "", false);
       
  3700     QList<QGraphicsItem*> list = widget->childItems();
       
  3701     foreach (QGraphicsItem* item, list) {
       
  3702         QString name = HbStyle::itemName(item);
       
  3703         if ( meshLayout && !name.isEmpty() ) {
       
  3704             // Assuming that all items with "itemName" are widgets.
       
  3705             meshLayout->setItemId(static_cast<QGraphicsWidget*>(item), name);
       
  3706             // Remove from "meshIds" so that we don't call polishItem
       
  3707             // twice for this item.
       
  3708             meshIds.removeAll(name);
       
  3709         }
       
  3710         d->polishItem(styleRules, widget, item, name, layoutDefined);
       
  3711     }
       
  3712     foreach (QString meshId, meshIds) {
       
  3713         // These are the "missing" mesh items. Need to call polishItem
       
  3714         // for them, too, for getting the mesh anchor spacings right.
       
  3715         // if there are mesh ids, layoutDefined is always true.
       
  3716         if ( !meshId.isEmpty() ) {
       
  3717             d->polishItem(styleRules, widget, 0, meshId, true);
       
  3718         }
       
  3719     }
       
  3720 }
       
  3721 
       
  3722 /*!
       
  3723     updateThemedItems updates themable children items of widget
       
  3724 
       
  3725     \param styleRules, style-rules of the widget
       
  3726     \param variableRules, variable-rules of the widget
       
  3727     \param widget, widget whose themed parameters are supposed to be updated
       
  3728     \param item, graphics item whose themed parameters are supposed to be updated
       
  3729 */
       
  3730 void HbStylePrivate::updateThemedItems( const HbVector<HbCss::StyleRule> &styleRules,
       
  3731     QGraphicsItem *item ) const
       
  3732 {
       
  3733     
       
  3734     QString name = HbStyle::itemName(item);
       
  3735     if (name.isEmpty() ) {
       
  3736         return ;
       
  3737     }
       
  3738   
       
  3739     HbTextItem* text = qgraphicsitem_cast<HbTextItem*>( item );
       
  3740     HbIconItem* iconItem = qgraphicsitem_cast<HbIconItem*>( item );
       
  3741     HbMarqueeItem* marqueeItem = qgraphicsitem_cast<HbMarqueeItem*>( item );
       
  3742     if(! (text || iconItem || marqueeItem ) ){
       
  3743         return;
       
  3744     }
       
  3745     
       
  3746     HbDeviceProfile profile;
       
  3747     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, profile);
       
  3748 
       
  3749 #ifdef HBSTYLE_DEBUG
       
  3750    qDebug() << "HbStyle::updateThemedItems : -- Number of maching CSS declarations: " << decl.count();
       
  3751 #endif
       
  3752    ensureColorParameters();
       
  3753    HbCss::ValueExtractor extractor(decl, colorParameters, profile);
       
  3754    
       
  3755    QColor col;
       
  3756    bool extracted = extractor.extractColor( &col );
       
  3757    //apply the themed color to text-item
       
  3758    if(text) {   
       
  3759 #ifdef HBSTYLE_DEBUG
       
  3760        if ( !extracted ) {
       
  3761             qDebug() << "HbStyle::getColor : -- No color information found";
       
  3762        }
       
  3763 #endif    
       
  3764        if( extracted && col.isValid() && !HbWidgetBasePrivate::d_ptr(text)->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor)){
       
  3765            text->setTextColor(col);
       
  3766            HbWidgetBasePrivate::d_ptr(text)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor, false);
       
  3767        }
       
  3768    }   
       
  3769    if(iconItem){
       
  3770        //applying color to mono-colorised icons from theme
       
  3771        if( extracted && col.isValid()) {
       
  3772            iconItem->setColor( col ); 
       
  3773        }
       
  3774    }
       
  3775    if(marqueeItem){
       
  3776        //applying color to the marquee-item from theme
       
  3777        if(extracted && col.isValid() && !HbWidgetBasePrivate::d_ptr(marqueeItem)->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor)) {
       
  3778            marqueeItem->setTextColor( col ); 
       
  3779            HbWidgetBasePrivate::d_ptr(marqueeItem)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor, false);
       
  3780        }
       
  3781    }
       
  3782 } 
       
  3783  
       
  3784 /*!
       
  3785     HbStyle::updateThemedParams()
       
  3786 
       
  3787     Updates the themable parameters of widget (specially those which are specified in css files)
       
  3788 
       
  3789     \param widget, widget whose themed parameters are supposed to be updated
       
  3790 */
       
  3791 void HbStyle::updateThemedParams(HbWidget *widget)
       
  3792 {
       
  3793     Q_D( HbStyle );
       
  3794 #ifdef HBSTYLE_DEBUG
       
  3795     qDebug() << "HbStyle::updateThemedParams : -- -- -- --";
       
  3796 #endif
       
  3797     if( !widget ) {
       
  3798         return;
       
  3799     }
       
  3800     if(!widget->childItems().count()){
       
  3801         return;
       
  3802     }
       
  3803 #ifdef HBSTYLE_DEBUG
       
  3804     qDebug() << "HbStyle::updateThemedParams : " << widget->metaObject()->className();
       
  3805 #endif
       
  3806 
       
  3807     HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
       
  3808     if(!styleLoader){
       
  3809 #ifdef HBSTYLE_DEBUG
       
  3810         qDebug() << "HbStyle::updateThemedParams : HbLayeredStyleLoader returned a null pointer.";
       
  3811 #endif
       
  3812         return;
       
  3813     }
       
  3814     NODEPTR_N(widget);
       
  3815     HbDeviceProfile profile(HbDeviceProfile::profile(widget));
       
  3816     HbVector<HbCss::StyleRule> styleRules = styleLoader->styleRulesForNode(n, profile.orientation());
       
  3817     if (!styleRules.count()) {
       
  3818 #ifdef HBSTYLE_DEBUG
       
  3819         qDebug() << "HbStyle::updateThemedParams : No style rules found.";
       
  3820 #endif
       
  3821         return;
       
  3822     }
       
  3823   
       
  3824     // update themed items
       
  3825     QList<QGraphicsItem*> list = widget->childItems();
       
  3826     foreach (QGraphicsItem* item, list) {
       
  3827         d->updateThemedItems(styleRules, item);
       
  3828     }
       
  3829 }
       
  3830 
       
  3831 /*!
       
  3832     Checkes whether given widget has orienation specific style 
       
  3833     rules. This can be used for optimizing orientation switch.
       
  3834 */
       
  3835 bool HbStyle::hasOrientationSpecificStyleRules(HbWidget *widget)
       
  3836 {
       
  3837     HbLayeredStyleLoader *styleLoader = 
       
  3838         HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Layouts);
       
  3839     NODEPTR_N(widget);
       
  3840     return styleLoader->hasOrientationSpecificStyleRules(n);
       
  3841 }
       
  3842 
       
  3843 /*!
       
  3844     For clearing caches.
       
  3845 */
       
  3846 void HbStyle::widgetDestroyed(QObject* obj)
       
  3847 {
       
  3848     Q_D( HbStyle );
       
  3849     d->widgetLayoutNames.remove((const QGraphicsWidget *)obj);
       
  3850 }
       
  3851 
       
  3852 /*!
       
  3853 
       
  3854     Sets the item name of a graphics item. Item name is not the same as object name.
       
  3855     It's a textual identifier that uniquely identifies QGraphicsItem's child items.
       
  3856     This method is used to map HbWidget's subelements to sub-elements defined in
       
  3857     CSS/WidgetML layouts.
       
  3858 
       
  3859     Note that polish() method requires widget's children to be set with a correct item name.
       
  3860     \sa HbStyle::polish()
       
  3861 
       
  3862     This method uses QGraphicsItem::setData() with id 0xfffe.
       
  3863 
       
  3864     \param item, graphics item
       
  3865     \param name, name to be set
       
  3866 */
       
  3867 void HbStyle::setItemName( QGraphicsItem *item, const QString &name )
       
  3868 {
       
  3869     if (item) {
       
  3870         item->setData( ItemName, name );
       
  3871     }
       
  3872 }
       
  3873 
       
  3874 /*!
       
  3875 
       
  3876     Returns the item name of a graphics item. Item name is not the same as object name.
       
  3877     It's a textual identifier that uniquely identifies QGraphicsItem's child items.
       
  3878 
       
  3879     \param item, graphics item
       
  3880     \return item name or an empty string if name's not set
       
  3881 */
       
  3882 QString HbStyle::itemName( const QGraphicsItem *item )
       
  3883 {
       
  3884     return item
       
  3885         ? item->data( ItemName ).toString()
       
  3886         : QString();
       
  3887 }
       
  3888 
       
  3889 /*!
       
  3890     Returns a value of a global style parameter. The value is returned in pixels. 
       
  3891 
       
  3892     Available parameters can be found from hbglobalparameters.css. By using these
       
  3893     parameters applications get consistent look.
       
  3894 
       
  3895     \param variable Name of the global parameter.
       
  3896     \param value Returns value of the global parameter.
       
  3897     \param profile Device profile of the used HbMainWindow. Primary display's.
       
  3898             device profile HbDeviceProfile::current() is used if the value is omitted.
       
  3899     \return true if the variable were found.
       
  3900 */
       
  3901 bool HbStyle::parameter(const QString& parameter, qreal& value, const HbDeviceProfile &profile) const
       
  3902 {
       
  3903     HbDeviceProfile effectiveProfile = profile;
       
  3904     if ( effectiveProfile.isNull() ) {
       
  3905         effectiveProfile = HbDeviceProfile::current();
       
  3906     }
       
  3907     Q_D( const HbStyle );
       
  3908     d->ensureLayoutParameters(effectiveProfile);
       
  3909     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
       
  3910     // todo: parsing variable/expression is done here so that there is no need to change API
       
  3911     // also parameters method not changed (this change is done for docml/widgetml parsing)
       
  3912     if (parameter.startsWith("var(") && parameter.endsWith(")")) {
       
  3913         return valueExtractor.extractValue(parameter.mid(4,parameter.length()-5), value);
       
  3914     } else if (parameter.startsWith("-var(") && parameter.endsWith(")")) {
       
  3915         bool retVal = valueExtractor.extractValue(parameter.mid(5,parameter.length()-6), value);
       
  3916         value = -value;
       
  3917         return retVal;
       
  3918     } else if (parameter.startsWith("expr(") && parameter.endsWith(")")) {
       
  3919         QString expressionString = parameter.mid(5,parameter.length()-6);
       
  3920         return valueExtractor.extractExpressionValue(expressionString, value);
       
  3921     } else if (parameter.startsWith("-expr(") && parameter.endsWith(")")) {
       
  3922         QString expressionString = parameter.mid(6,parameter.length()-7);
       
  3923         bool retVal = valueExtractor.extractExpressionValue(expressionString, value);
       
  3924         value = -value;
       
  3925         return retVal;
       
  3926     }
       
  3927 
       
  3928     return valueExtractor.extractValue(parameter, value);    
       
  3929 }
       
  3930 
       
  3931 /*!
       
  3932     Returns copy of all global style parameters. Both names and values 
       
  3933     of the parameters are returned. The values are returned in pixels.
       
  3934 
       
  3935     Available parameters can be found from hbglobalparameters.css. By using these
       
  3936     parameters applications get consistent look. Usage of this API (instead of parameter)
       
  3937     is recommended if an application needs to fetch several parameters in one place.
       
  3938 
       
  3939     \param parameters Contains names and values of all global style parameters.
       
  3940     \param profile Device profile of the used HbMainWindow. Primary display's
       
  3941             device profile HbDeviceProfile::current() is used if the value is omitted.
       
  3942 */
       
  3943 
       
  3944 void HbStyle::parameters(HbStyleParameters &parameters, const HbDeviceProfile &profile) const
       
  3945 {
       
  3946     HbDeviceProfile effectiveProfile = profile;
       
  3947     if ( effectiveProfile.isNull() ) {
       
  3948         effectiveProfile = HbDeviceProfile::current();
       
  3949     }
       
  3950 
       
  3951     Q_D( const HbStyle );
       
  3952     d->ensureLayoutParameters(effectiveProfile);
       
  3953     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
       
  3954     qreal value = 0;
       
  3955     for (int i = 0; i < d->layoutParameters.count(); i++) {
       
  3956         if (valueExtractor.extractValue(d->layoutParameters[i].property, value))
       
  3957             parameters.addParameter(d->layoutParameters[i].property, value);
       
  3958     }
       
  3959 }
       
  3960 
       
  3961 
       
  3962 /*!
       
  3963 \internal
       
  3964 */
       
  3965 HbStylePrivate::HbStylePrivate()
       
  3966 {
       
  3967     nextAvailableId = HbStyle::P_CustomBase;
       
  3968     HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
       
  3969     if(loader){
       
  3970         loader->addFilePath(STYLE_LOCATION, HbLayeredStyleLoader::Concern_Layouts, 
       
  3971                 HbLayeredStyleLoader::Priority_Core);
       
  3972         loader->addFilePath(COLOR_STYLE_LOCATION, HbLayeredStyleLoader::Concern_Colors, 
       
  3973                 HbLayeredStyleLoader::Priority_Core);
       
  3974     }
       
  3975 }
       
  3976 
       
  3977 /*!
       
  3978 \internal
       
  3979 */
       
  3980 HbStylePrivate::~HbStylePrivate()
       
  3981 {
       
  3982     layoutParameters.clear();
       
  3983 	colorParameters.clear();
       
  3984 
       
  3985     HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
       
  3986     if(loader){
       
  3987         loader->removeFilePath(STYLE_LOCATION, HbLayeredStyleLoader::Concern_Layouts, 
       
  3988                 HbLayeredStyleLoader::Priority_Core);
       
  3989         loader->removeFilePath(COLOR_STYLE_LOCATION, HbLayeredStyleLoader::Concern_Colors, 
       
  3990                 HbLayeredStyleLoader::Priority_Core);
       
  3991     }
       
  3992 }
       
  3993 
       
  3994 void HbStylePrivate::_q_onThemeChanged()
       
  3995 {
       
  3996     colorParameters.clear();
       
  3997 }
       
  3998 
       
  3999 /*!
       
  4000 \internal
       
  4001 */
       
  4002 QString HbStylePrivate::logicalName(HbStyle::Primitive primitive, const QStyleOption *option) const
       
  4003 {
       
  4004     switch(primitive){
       
  4005     case HbStyle::P_Slider_thumb:{
       
  4006         const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider *>(option);
       
  4007         QString iconPath;
       
  4008 
       
  4009                 switch (opt->orientation){
       
  4010                 case Qt::Horizontal:{
       
  4011                         if( opt->state&QStyle::State_Sunken)
       
  4012                             iconPath= "qtg_graf_slider_h_handle_pressed";
       
  4013                         else
       
  4014                             iconPath= "qtg_graf_slider_h_handle_normal";
       
  4015                         return (iconPath);
       
  4016                 }
       
  4017                 case Qt::Vertical:{
       
  4018                         if( opt->state&QStyle::State_Sunken)
       
  4019                             iconPath= "qtg_graf_slider_v_handle_pressed";
       
  4020                         else
       
  4021                             iconPath= "qtg_graf_slider_v_handle_normal";
       
  4022                         return (iconPath);
       
  4023                 }
       
  4024                 default: break;
       
  4025         }
       
  4026     }
       
  4027         default: break;
       
  4028     }
       
  4029 
       
  4030 return QString();
       
  4031 }
       
  4032 
       
  4033 /*!
       
  4034 \internal
       
  4035 */
       
  4036 QIcon::Mode HbStylePrivate::iconMode(QStyle::State state) const
       
  4037 {
       
  4038     QIcon::Mode mode = QIcon::Disabled;
       
  4039     if (state & QStyle::State_Enabled)
       
  4040         mode = QIcon::Normal;
       
  4041     if (state & QStyle::State_Active)
       
  4042         mode = QIcon::Active;
       
  4043     if (state & QStyle::State_Selected)
       
  4044         mode = QIcon::Selected;
       
  4045     return mode;
       
  4046 }
       
  4047 
       
  4048 /*!
       
  4049 \internal
       
  4050 */
       
  4051 QIcon::State HbStylePrivate::iconState(QStyle::State state) const
       
  4052 {
       
  4053     QIcon::State icon = QIcon::Off;
       
  4054     if (state & QStyle::State_On)
       
  4055         icon = QIcon::On;
       
  4056     return icon;
       
  4057 }
       
  4058 
       
  4059 /*!
       
  4060 \internal
       
  4061 */
       
  4062 HbStyleInterface *HbStylePrivate::stylePluginInterface( HbStyle::Primitive primitive ) const
       
  4063 {
       
  4064     
       
  4065     if (customPrimitives.contains(primitive)) {
       
  4066         HbStyleInterfaceInfo* info = customPrimitives.value(primitive);
       
  4067         QObject* pluginInstance = info->loader->instance();
       
  4068         HbStyleInterface *stylePlugin = qobject_cast<HbStyleInterface *>(pluginInstance);
       
  4069         return stylePlugin;
       
  4070     }
       
  4071     return 0;
       
  4072 }
       
  4073 
       
  4074 /*!
       
  4075 \internal
       
  4076 */
       
  4077 void HbStylePrivate::ensureLayoutParameters(const HbDeviceProfile &profile) const
       
  4078 {
       
  4079     bool firstParse(layoutParameters.isEmpty());
       
  4080     bool addSpecialParams(firstParse);
       
  4081     if (firstParse) {
       
  4082         HbCss::Parser parser;
       
  4083         parser.init(GLOBAL_PARAMETERS_LOCATION, true);
       
  4084         HbCss::StyleSheet *styleSheet = new(HbCss::StyleSheet);
       
  4085         parser.parse(styleSheet);
       
  4086 
       
  4087         HbStyleSelector selector;
       
  4088         selector.styleSheets.append(styleSheet);
       
  4089         layoutParameters = selector.variableRuleSets();
       
  4090     }
       
  4091     if (!firstParse && (layoutParametersProfileName != profile.name())) {
       
  4092         layoutParameters.remove(layoutParameters.count()-4, 4);
       
  4093         addSpecialParams = true;
       
  4094     }
       
  4095     if (addSpecialParams) {
       
  4096         layoutParametersProfileName = profile.name();
       
  4097         QSizeF pSize = profile.logicalSize();
       
  4098 
       
  4099         {
       
  4100             HbCss::Declaration decl;
       
  4101             decl.property = "hb-param-screen-width";
       
  4102             decl.propertyId = HbCss::UnknownProperty;
       
  4103             HbCss::Value val;
       
  4104             val.type = HbCss::Value::Number;
       
  4105             val.variant = HbVariant((double)pSize.width(),HbMemoryManager::HeapMemory);
       
  4106             decl.values.append(val);
       
  4107             layoutParameters.append(decl);
       
  4108         }
       
  4109         {
       
  4110             HbCss::Declaration decl;
       
  4111             decl.property = "hb-param-screen-height";
       
  4112             decl.propertyId = HbCss::UnknownProperty;
       
  4113             HbCss::Value val;
       
  4114             val.type = HbCss::Value::Number;
       
  4115             val.variant = HbVariant((double)pSize.height(),HbMemoryManager::HeapMemory);
       
  4116             decl.values.append(val);
       
  4117             layoutParameters.append(decl);
       
  4118         }
       
  4119         {
       
  4120             HbCss::Declaration decl;
       
  4121             decl.property = "hb-param-screen-short-edge";
       
  4122             decl.propertyId = HbCss::UnknownProperty;
       
  4123             HbCss::Value val;
       
  4124             val.type = HbCss::Value::Number;
       
  4125             val.variant = HbVariant((double)qMin(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
       
  4126             decl.values.append(val);
       
  4127             layoutParameters.append(decl);
       
  4128         }
       
  4129         {
       
  4130             HbCss::Declaration decl;
       
  4131             decl.property = "hb-param-screen-long-edge";
       
  4132             decl.propertyId = HbCss::UnknownProperty;
       
  4133             HbCss::Value val;
       
  4134             val.type = HbCss::Value::Number;
       
  4135             val.variant = HbVariant((double)qMax(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
       
  4136             decl.values.append(val);
       
  4137             layoutParameters.append(decl);
       
  4138         }
       
  4139     }
       
  4140 
       
  4141 }
       
  4142 
       
  4143 void HbStylePrivate::ensureColorParameters() const
       
  4144 {
       
  4145     if (colorParameters.isEmpty()) {
       
  4146         HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
       
  4147         colorParameters = styleLoader->variableRuleSets();
       
  4148     }
       
  4149 }
       
  4150 
       
  4151 /*!
       
  4152 \internal
       
  4153 */
       
  4154 void HbStylePrivate::clearStyleSheetCaches()
       
  4155 {
       
  4156     widgetLayoutNames.clear();
       
  4157     styleRulesCache.clear();
       
  4158     colorParameters.clear();
       
  4159 }
       
  4160 
       
  4161 #include "moc_hbstyle.cpp"