src/hbcore/style/hbstyle.cpp
branchGCC_SURGE
changeset 15 f378acbc9cfb
parent 7 923ff622b8b9
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
9:730c025d4b77 15:f378acbc9cfb
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
       
    26 #include "hbstyle_p.h"
    26 #include "hbstyleoptionslider_p.h"
    27 #include "hbstyleoptionslider_p.h"
    27 #include "hbstyleoptionsliderelement_p.h"
    28 #include "hbstyleoptionsliderelement_p.h"
    28 #include "hbstyleoptionpushbutton_p.h"
    29 #include "hbstyleoptionpushbutton_p.h"
    29 #include "hbstyleoptiontoolbutton_p.h"
    30 #include "hbstyleoptiontoolbutton_p.h"
    30 #include "hbstyleoptiontooltip_p.h"
    31 #include "hbstyleoptiontooltip_p.h"
    47 #include "hbstyleoptionmessagebox_p.h"
    48 #include "hbstyleoptionmessagebox_p.h"
    48 #include "hbstyleoptionnavigationbutton_p.h"
    49 #include "hbstyleoptionnavigationbutton_p.h"
    49 #include "hbstyleoptionindicatorbutton_p.h"
    50 #include "hbstyleoptionindicatorbutton_p.h"
    50 #include "hbstyleoptionsignalindicator_p.h"
    51 #include "hbstyleoptionsignalindicator_p.h"
    51 #include "hbstyleoptionbatteryindicator_p.h"
    52 #include "hbstyleoptionbatteryindicator_p.h"
    52 #include "hbstyle_p.h"
       
    53 #include "hbstyleloader.h"
    53 #include "hbstyleloader.h"
    54 #include "hbwidgetloader_p.h"
    54 #include "hbwidgetloader_p.h"
    55 #include "hbwidget_p.h"
    55 #include "hbwidget_p.h"
    56 #include "hbstyleoptionratingslider_p.h"
    56 #include "hbstyleoptionratingslider_p.h"
    57 #include "hbstyleoptiondataformviewitem_p.h"
    57 #include "hbstyleoptiondataformviewitem_p.h"
    85 #include <hbrichtextitem_p.h>
    85 #include <hbrichtextitem_p.h>
    86 #include <hbtoucharea.h>
    86 #include <hbtoucharea.h>
    87 #include <hbindicatorleveliconitem_p.h>
    87 #include <hbindicatorleveliconitem_p.h>
    88 
    88 
    89 #include <hbglobal.h>
    89 #include <hbglobal.h>
    90 #include <hbpluginloader_p.h>
       
    91 #include "hbstyleinterface_p.h"
       
    92 #include <hbstyleparameters.h>
    90 #include <hbstyleparameters.h>
    93 
    91 
    94 #include "hbstyleselector_p.h"
    92 #include "hbstyleselector_p.h"
    95 #include "hblayeredstyleloader_p.h"
    93 #include "hblayeredstyleloader_p.h"
    96 #include "hbwidgetstyleloader_p.h"
    94 #include "hbwidgetstyleloader_p.h"
    97 #include "hbcssparser_p.h"
    95 #include "hbcssparser_p.h"
    98 #include "hbrepeaticonitem_p.h"
    96 #include "hbrepeaticonitem_p.h"
    99 #include "hbnamespace_p.h"
    97 #include "hbnamespace_p.h"
   100 
    98 
   101 
    99 
   102 #include "hbmeshlayout_p.h"
   100 #include "hbanchorlayout.h"
       
   101 #include <hbanchor.h>
   103 
   102 
   104 #include <QGraphicsWidget>
   103 #include <QGraphicsWidget>
   105 #include <hbwidget.h>
   104 #include <hbwidget.h>
   106 #include <hbwidgetbase.h>
   105 #include <hbwidgetbase.h>
   107 #include "hbdeviceprofile.h"
   106 #include "hbdeviceprofile.h"
   108 #include "hbrepeatitem_p.h"
   107 #include "hbrepeatitem_p.h"
   109 
   108 
   110 #include <QDebug>
   109 #include <QDebug>
       
   110 #include <QMetaClassInfo>
       
   111 
       
   112 Q_DECLARE_METATYPE(QGraphicsLayout*)
   111 
   113 
   112 //Uncomment next define(s) in order to get more debug prints.
   114 //Uncomment next define(s) in order to get more debug prints.
   113 //Similar define exists also in the engine side.
   115 //Similar define exists also in the engine side.
   114 //#define HBSTYLE_DEBUG
   116 //#define HBSTYLE_DEBUG
   115 
   117 
   130     Whenever the widget's state changes in a way that needs changes in drawing the primitive
   132     Whenever the widget's state changes in a way that needs changes in drawing the primitive
   131     (such as button pressed down -> change the button background image) then the widget needs to
   133     (such as button pressed down -> change the button background image) then the widget needs to
   132     call the updatePrimitive method.
   134     call the updatePrimitive method.
   133 
   135 
   134     Generally primitives should be updated only when a state change occurs. When a widget uses primitives to construct
   136     Generally primitives should be updated only when a state change occurs. When a widget uses primitives to construct
   135     itself it does not need a paint() method at all since primitives (widget's childs) are doing the drawing. 
   137     itself it does not need a paint() method at all since primitives (widget's children) are doing the drawing. 
   136     Painting for the primitives occurs from the graphics scene.
   138     Painting for the primitives occurs from the graphics scene.
   137 
   139 
       
   140     HbStyle has some caching functionality and thus it should not be instantiated explicitly, but 
       
   141     accessed only through HbWidget::style() or HbInstance::style() APIs.
       
   142 
   138 */
   143 */
   139 
   144 
   140 /*!
   145 /*!
   141         
   146 
   142 	    \deprecated P_PushButton_icon
   147 	    \deprecated P_PushButton_icon
   143         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   148         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   144 
   149 
   145 
   150 
   146         \deprecated P_PushButton_text
   151         \deprecated P_PushButton_text
   147         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   152         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   148 
   153 
   149         
   154 
   150         \deprecated P_PushButton_additionaltext
   155         \deprecated P_PushButton_additionaltext
   151         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   156         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   152 
   157 
   153 
   158 
   154         \deprecated P_PushButton_background
   159         \deprecated P_PushButton_background
   344 
   349 
   345 
   350 
   346         \deprecated P_ListViewItem_icon
   351         \deprecated P_ListViewItem_icon
   347         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   352         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   348 
   353 
   349         
   354 
   350         \deprecated P_ItemHighlight_background
   355         \deprecated P_ItemHighlight_background
   351         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   356         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   352 
   357 
   353 
   358 
   354         \deprecated P_ToolBarExtension_background
   359         \deprecated P_ToolBarExtension_background
   400 
   405 
   401 
   406 
   402         \deprecated P_IndicatorGrou\deprecated P_signalicon
   407         \deprecated P_IndicatorGrou\deprecated P_signalicon
   403         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   408         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   404 
   409 
   405    
   410 
   406         \deprecated P_IndicatorGrou\deprecated P_batteryicon
   411         \deprecated P_IndicatorGrou\deprecated P_batteryicon
   407         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   412         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   408 
   413 
   409   
   414 
   410         \deprecated P_SignalIndicator_icon
   415         \deprecated P_SignalIndicator_icon
   411         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   416         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   412 
   417 
   413 
   418 
   414         \deprecated P_SignalLevel_background
   419         \deprecated P_SignalLevel_background
   456 
   461 
   457 
   462 
   458         \deprecated P_ProgressBar_waittrack
   463         \deprecated P_ProgressBar_waittrack
   459         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   464         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   460 
   465 
   461        
   466 
   462         \deprecated P_ProgressBar_mintext
   467         \deprecated P_ProgressBar_mintext
   463         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   468         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   464 
   469 
   465 
   470 
   466         \deprecated P_ProgressBar_maxtext
   471         \deprecated P_ProgressBar_maxtext
   468 
   473 
   469 
   474 
   470         \deprecated P_Softkey_background
   475         \deprecated P_Softkey_background
   471         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   476         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   472 
   477 
   473  
   478 
   474         \deprecated P_NavigationButton_background
   479         \deprecated P_NavigationButton_background
   475         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   480         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   476 
   481 
   477 
   482 
   478         \deprecated P_IndicatorButton_background
   483         \deprecated P_IndicatorButton_background
   484 
   489 
   485 
   490 
   486         \deprecated P_ItemViewItem_frame
   491         \deprecated P_ItemViewItem_frame
   487         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   492         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   488 
   493 
   489    
   494 
   490         \deprecated P_SelectionControl_selectionstart
   495         \deprecated P_SelectionControl_selectionstart
   491         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   496         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   492 
   497 
   493 
   498 
   494         \deprecated P_SelectionControl_selectionend
   499         \deprecated P_SelectionControl_selectionend
   532 
   537 
   533 
   538 
   534         \deprecated P_ProgressSliderHandle_background
   539         \deprecated P_ProgressSliderHandle_background
   535         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   540         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   536 
   541 
   537  
   542 
   538         \deprecated P_ProgressSliderHandle_icon
   543         \deprecated P_ProgressSliderHandle_icon
   539         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   544         is deprecated. HbStyle::Primitive enums are deprecated. Primitives can be accessed by item names using HbWidget::primitive(const QString).
   540 
   545 
   541 
   546 
   542         \deprecated P_ProgressSliderHandle_toucharea
   547         \deprecated P_ProgressSliderHandle_toucharea
   789 static const QString COLOR_STYLE_LOCATION = QLatin1String(":/themes/style/hbdefault/rules/widgets/%w/%w_color");
   794 static const QString COLOR_STYLE_LOCATION = QLatin1String(":/themes/style/hbdefault/rules/widgets/%w/%w_color");
   790 static const int TOUCHAREA_ZVALUE = 1000;
   795 static const int TOUCHAREA_ZVALUE = 1000;
   791 
   796 
   792 static const QString GLOBAL_PARAMETERS_LOCATION = QLatin1String(":/themes/style/hbdefault/variables/layout/zoom/0/hbglobalparameters.css");
   797 static const QString GLOBAL_PARAMETERS_LOCATION = QLatin1String(":/themes/style/hbdefault/variables/layout/zoom/0/hbglobalparameters.css");
   793 
   798 
       
   799 static const char* LAYOUT_PTR_PROPERTY = "HbStyle_layout_ptr";
       
   800 static const char* LAYOUT_NAME_PROPERTY = "HbStyle_layout_name";
       
   801 
       
   802 inline void overrideSpacing( HbAnchorLayout *layout, const QString &name, Hb::Edge edge, qreal val )
       
   803 {
       
   804     if( name.isNull() ) {
       
   805         return;
       
   806     }
       
   807     QList<HbAnchor*> list = layout->anchors();
       
   808     for( int i = 0; i < list.size(); i++ ) {
       
   809         HbAnchor *anchor = list.at(i);
       
   810         if( ( anchor->startNodeId() == name ) && ( anchor->startEdge() == edge ) ) {
       
   811             anchor->setDirection( val < 0 ? HbAnchor::Negative : HbAnchor::Positive );
       
   812             anchor->setPreferredLength( qAbs(val) );
       
   813             if (anchor->anchorId().isEmpty()) {
       
   814                 // assuming it's a fixed anchor
       
   815                 anchor->setSizePolicy( QSizePolicy::Fixed );
       
   816             } else {
       
   817                 // assuming it's a "spacer" and we want to override the minimum length
       
   818                 anchor->setMinimumLength( qAbs(val) );
       
   819             }
       
   820         }
       
   821     }
       
   822 }
   794 
   823 
   795 /*!
   824 /*!
   796 Constructor
   825 Constructor
       
   826 
       
   827 Should not be called explicitly. Use HbWidget::style() or HbInstance::style() instead.
   797 */
   828 */
   798 HbStyle::HbStyle() :
   829 HbStyle::HbStyle() :
   799     d_ptr(new HbStylePrivate)
   830     d_ptr(new HbStylePrivate)
   800 {
   831 {
   801     Q_D( HbStyle );
   832     Q_D( HbStyle );
   802     d->q_ptr = this;
   833     d->q_ptr = this;
   803     QObject::connect(hbInstance->theme(), SIGNAL(changed()), this, SLOT(_q_onThemeChanged()));
       
   804 }
   834 }
   805 
   835 
   806 /*!
   836 /*!
   807 Destructor
   837 Destructor
   808 */
   838 */
   809 HbStyle::~HbStyle()
   839 HbStyle::~HbStyle()
   810 {
   840 {
   811     delete d_ptr;
   841     delete d_ptr;
   812 }
   842 }
   813 
   843 
       
   844 
   814 /*!
   845 /*!
   815 
   846 
   816     \deprecated HbStyle::registerPlugin(const QString&)
   847   \deprecated HbStyle::createPrimitive(HbStyle::Primitive, QGraphicsItem*)
   817     is deprecated. Style plugins are not supported anymore.
       
   818 
       
   819     Registers the style plugin with the Style system. This method can be called by a custom widget
       
   820     or application in order to register the style plugin that implements the custom graphics primitives.
       
   821     This method results in loading of the plugin, if the plugin is registered for the first time.
       
   822     It returns the base ID for the primitives implemented by the style plugin. The custom widget
       
   823     can use the range of integers from (BaseID) to (BaseID+count-1) to refer to the custom
       
   824     primitives, where count is the number of primitives supported by the plugin. The style
       
   825     plugin must return the correct number of primitives when the primitiveCount() method is called.
       
   826     In case of errors the method returns < 0. Note also that for each registerPlugin there must be
       
   827     a unregisterPlugin call, the last unregisterPlugin call for a plugin causes the plugin to be unloaded.
       
   828 
       
   829     If the style plugin implementation returns valid path with layout defition files (CSS+WidgetML)
       
   830     from layoutPath() method the layout definitions CSSs gets read when calling registerPlugin().
       
   831 
       
   832     \param pluginName, name of the Plugin library to be dynamically loaded
       
   833     \return int the base ID to be used for the primitives implemented by the style plugin
       
   834     \sa unregisterPlugin()
       
   835  */
       
   836 int HbStyle::registerPlugin(const QString &pluginName)
       
   837 {
       
   838     Q_D( const HbStyle );
       
   839 
       
   840     // check if the plugin is already registered
       
   841     if (d->registeredPlugins.contains(pluginName)) {
       
   842         // increase the reference count
       
   843         d->registeredPlugins.value(pluginName)->refCount++;
       
   844         // return the base ID of the primitives enumeration
       
   845         return d->registeredPlugins.value(pluginName)->primitiveBaseId;
       
   846     }
       
   847 
       
   848     // load the plugin
       
   849     HbPluginLoader* loader = new HbPluginLoader(pluginName);
       
   850     if (!loader)
       
   851         return -1;
       
   852 
       
   853     // get the instance pointer
       
   854     QObject* pluginInstance = loader->instance();
       
   855     if (!pluginInstance) {
       
   856 
       
   857         // try the additional paths
       
   858         QFileInfo fileInfo(pluginName);
       
   859         foreach (QString additionalPath, hbInstance->libraryPaths()) {
       
   860             const QDir pluginDir(additionalPath);
       
   861             loader->setPluginName(pluginDir.absoluteFilePath(fileInfo.fileName()));
       
   862             pluginInstance = loader->instance();
       
   863             if (pluginInstance) {
       
   864                 break;
       
   865             }
       
   866         }
       
   867 
       
   868         if (!pluginInstance) {
       
   869             delete loader;
       
   870             return -1;
       
   871         }
       
   872     }
       
   873 
       
   874     HbStyleInterface *stylePlugin = qobject_cast<HbStyleInterface *>(pluginInstance);
       
   875 
       
   876     int primitiveCount = stylePlugin->primitiveCount();
       
   877     if (primitiveCount <= 0) {
       
   878         delete pluginInstance;
       
   879         delete loader;
       
   880         return -1;
       
   881     }
       
   882 
       
   883     HbStyleInterfaceInfo* info = new HbStyleInterfaceInfo();
       
   884     info->loader = loader;
       
   885     info->primitiveBaseId = d->nextAvailableId;
       
   886 
       
   887     // make entries for the primitives in the hash table
       
   888     for (int i=d->nextAvailableId; i<(d->nextAvailableId+primitiveCount); i++)
       
   889     {
       
   890         d->customPrimitives.insert(i, info);
       
   891     }
       
   892 
       
   893     // make entry for the plugin in the registered plugins hash table
       
   894     HbStylePluginInfo* pluginInfo = new HbStylePluginInfo();
       
   895     pluginInfo->primitiveBaseId = d->nextAvailableId;
       
   896     pluginInfo->primitiveCount = primitiveCount;
       
   897     pluginInfo->refCount = 1;
       
   898 
       
   899     d->registeredPlugins.insert(pluginName, pluginInfo);
       
   900     d->nextAvailableId += primitiveCount;
       
   901 
       
   902     // register associated style files
       
   903     HbWidgetStyleLoader::instance()->addFilePath(
       
   904         stylePlugin->layoutPath(),
       
   905         HbLayeredStyleLoader::Concern_Layouts, 
       
   906         HbLayeredStyleLoader::Priority_Core);
       
   907     d->pluginStylePaths.insert(pluginName, stylePlugin->layoutPath());
       
   908 
       
   909     return pluginInfo->primitiveBaseId;
       
   910 }
       
   911 
       
   912 
       
   913 /*!
       
   914 
       
   915     \deprecated HbStyle::unregisterPlugin(const QString&)
       
   916     is deprecated. Style plugins are not supported anymore.
       
   917 
       
   918     Un-registers the style plugin.
       
   919     If the reference count becomes zero, the plugin is unloaded and the primitive IDs are de-registered
       
   920     If a client has called registerPlugin() it must unregister the style plugin with this method.
       
   921 
       
   922     \param pluginName, name of the Plugin library
       
   923  */
       
   924 void HbStyle::unregisterPlugin(const QString &pluginName)
       
   925 {
       
   926     Q_D( const HbStyle );
       
   927     if (d->registeredPlugins.contains(pluginName)) {
       
   928         HbStylePluginInfo *info = d->registeredPlugins.value(pluginName);
       
   929         info->refCount--;
       
   930         // unload plugin and remove from list
       
   931         if (info->refCount == 0) {
       
   932             HbStyleInterfaceInfo* styleInfo = d->customPrimitives.value(info->primitiveBaseId);
       
   933             delete styleInfo->loader->instance();
       
   934             delete styleInfo->loader;
       
   935             delete styleInfo;
       
   936             for (int i=info->primitiveBaseId; i< (info->primitiveBaseId+info->primitiveCount); i++) {
       
   937                   d->customPrimitives.remove(i);
       
   938             }
       
   939             d->registeredPlugins.remove(pluginName);
       
   940 
       
   941             // unregister associated style files
       
   942             HbWidgetStyleLoader::instance()->removeFilePath(
       
   943                 d->pluginStylePaths.value(pluginName),
       
   944                 HbLayeredStyleLoader::Concern_Layouts, 
       
   945                 HbLayeredStyleLoader::Priority_Core);
       
   946             d->pluginStylePaths.remove(pluginName);
       
   947 
       
   948             if( d->registeredPlugins.count() == 0 ){
       
   949                 // no plugins loaded, can reset the id counter
       
   950                 d->nextAvailableId = HbStyle::P_CustomBase;
       
   951             }
       
   952 
       
   953         }
       
   954     }
       
   955 }
       
   956 
       
   957 
       
   958 /*!
       
   959 
       
   960   \deprecated HbStyle::createPrimitive(HbStyle::Primitive, QGraphicsItem*) 
       
   961   is deprecated. This method will be replaced with an altered version which will use new base primitive enumerations.
   848   is deprecated. This method will be replaced with an altered version which will use new base primitive enumerations.
   962     
   849 
   963   Creates instances of primitive graphics items. This method should be used by all widgets that support styling.
   850   Creates instances of primitive graphics items. This method should be used by all widgets that support styling.
   964   When changing the style the returned primitives can be replaced with an altered version of the primitives, or with a completely
   851   When changing the style the returned primitives can be replaced with an altered version of the primitives, or with a completely
   965   different primitive, to create a custom appearance. This shouldn't cause changes to the widget if the functional design
   852   different primitive, to create a custom appearance. This shouldn't cause changes to the widget if the functional design
   966   remains the same.
   853   remains the same.
   967 
   854 
   977 
   864 
   978  */
   865  */
   979 QGraphicsItem *HbStyle::createPrimitive( HbStyle::Primitive primitive, QGraphicsItem *parent ) const
   866 QGraphicsItem *HbStyle::createPrimitive( HbStyle::Primitive primitive, QGraphicsItem *parent ) const
   980 {
   867 {
   981 
   868 
   982     Q_D( const HbStyle );
       
   983 
       
   984     if (d->customPrimitives.contains(primitive)) {
       
   985         HbStyleInterfaceInfo* info = d->customPrimitives.value(primitive);
       
   986         QObject* pluginInstance = info->loader->instance();
       
   987         HbStyleInterface *stylePlugin = qobject_cast<HbStyleInterface *>(pluginInstance);
       
   988         return stylePlugin->createPrimitive((HbStyle::Primitive)(primitive-info->primitiveBaseId), parent);
       
   989     }
       
   990 
       
   991         switch (primitive){
   869         switch (primitive){
   992             case P_MenuItem_submenuindicator:
   870             case P_MenuItem_submenuindicator:
   993                 {
   871                 {
   994                 HbIconItem *item = new HbIconItem(parent);
   872                 HbIconItem *item = new HbIconItem(parent);
   995                 setItemName(item, QLatin1String("submenu-indicator"));
   873                 setItemName(item, QLatin1String("submenu-indicator"));
  1012             case P_ToolButton_icon:
   890             case P_ToolButton_icon:
  1013             case P_PushButton_icon:
   891             case P_PushButton_icon:
  1014             case P_ProgressDialog_icon: {
   892             case P_ProgressDialog_icon: {
  1015                 HbIconItem *iconItem = new HbIconItem(HbIcon(),parent);
   893                 HbIconItem *iconItem = new HbIconItem(HbIcon(),parent);
  1016                 setItemName(iconItem, QLatin1String("icon"));
   894                 setItemName(iconItem, QLatin1String("icon"));
  1017                 return iconItem; 
   895                 return iconItem;
  1018                 }
   896                 }
  1019 
   897 
  1020             case P_CheckBox_icon:
   898             case P_CheckBox_icon:
  1021             case P_GroupBoxHeading_icon:
   899             case P_GroupBoxHeading_icon:
  1022             case P_Label_icon:
   900             case P_Label_icon:
  1023             case P_GridViewItem_icon: {
   901             case P_GridViewItem_icon: {
  1024                 HbIconItem *item = q_check_ptr(new HbIconItem(HbIcon(),parent));
   902                 HbIconItem *item = q_check_ptr(new HbIconItem(HbIcon(),parent));
  1025                 setItemName(item, QLatin1String("icon"));
   903                 setItemName(item, QLatin1String("icon"));
  1026                 return item; 
   904                 return item;
  1027                 }
   905                 }
  1028             case P_DataGroup_icon:
   906             case P_DataGroup_icon:
  1029                 {
   907                 {
  1030                 HbIconItem *item = new HbIconItem(HbIcon(), parent);
   908                 HbIconItem *item = new HbIconItem(HbIcon(), parent);
  1031                 setItemName(item, QLatin1String("dataGroup_Icon"));
   909                 setItemName(item, QLatin1String("dataGroup_Icon"));
  1032                 return item; 
   910                 return item;
  1033                 }
   911                 }
  1034             case P_DataItem_icon:
   912             case P_DataItem_icon:
  1035                 {
   913                 {
  1036                 HbIconItem *item = new HbIconItem(HbIcon(), parent);
   914                 HbIconItem *item = new HbIconItem(HbIcon(), parent);
  1037                 setItemName(item, QLatin1String("dataItem_Icon"));
   915                 setItemName(item, QLatin1String("dataItem_Icon"));
  1038                 return item; 
   916                 return item;
  1039                 }
   917                 }
  1040             case P_ComboBox_text:
   918             case P_ComboBox_text:
  1041                 {
   919                 {
  1042                     HbTextItem *textItem = new HbTextItem(parent);
   920                     HbTextItem *textItem = new HbTextItem(parent);
  1043                     setItemName(textItem, QLatin1String("combobox_labelfield"));
   921                     setItemName(textItem, QLatin1String("combobox_labelfield"));
  1094                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
   972                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1095                 setItemName(ta, QLatin1String("toucharea"));
   973                 setItemName(ta, QLatin1String("toucharea"));
  1096                 ta->setZValue(TOUCHAREA_ZVALUE);
   974                 ta->setZValue(TOUCHAREA_ZVALUE);
  1097                 return ta;
   975                 return ta;
  1098                 }
   976                 }
  1099             case P_ProgressSliderHandle_toucharea: 
   977             case P_ProgressSliderHandle_toucharea:
  1100                 {
   978                 {
  1101                 HbTouchArea *ta = new HbTouchArea(parent);
   979                 HbTouchArea *ta = new HbTouchArea(parent);
  1102                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
   980                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1103                 setItemName(ta, QLatin1String("toucharea"));
   981                 setItemName(ta, QLatin1String("toucharea"));
  1104                 ta->setZValue(TOUCHAREA_ZVALUE);
   982                 ta->setZValue(TOUCHAREA_ZVALUE);
  1105                 if(parent){
   983                 if(parent){
  1106                     parent->setHandlesChildEvents(true); 
   984                     parent->setFiltersChildEvents(true);
  1107                 }
   985                 }
  1108                 return ta;
   986                 return ta;
  1109                 }
   987                 }
  1110 
   988 
  1111             case P_ProgressSliderHandle_icon:
   989             case P_ProgressSliderHandle_icon:
  1115                 return item;
   993                 return item;
  1116                 }
   994                 }
  1117             case P_PushButton_toucharea: // Generic implementation, can add other cases here
   995             case P_PushButton_toucharea: // Generic implementation, can add other cases here
  1118             case P_CheckBox_toucharea:
   996             case P_CheckBox_toucharea:
  1119             case P_RatingSlider_toucharea:
   997             case P_RatingSlider_toucharea:
  1120             case P_SliderElement_touchhandle: 
   998             case P_SliderElement_touchhandle:
  1121                 {
   999                 {
  1122                 HbTouchArea *ta = new HbTouchArea(parent);
  1000                 HbTouchArea *ta = new HbTouchArea(parent);
  1123                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1001                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1124                 setItemName(ta, QLatin1String("toucharea"));
  1002                 setItemName(ta, QLatin1String("toucharea"));
  1125                 if(parent){
  1003                 if(parent){
  1126                     parent->setHandlesChildEvents(true); 
  1004                     parent->setFiltersChildEvents(true);
  1127                 }
  1005                 }
  1128                 return ta;
  1006                 return ta;
  1129                 }
  1007                 }
  1130             case P_ScrollBar_toucharea:
  1008             case P_ScrollBar_toucharea:
  1131                 {
  1009                 {
  1132                 HbTouchArea *ta = new HbTouchArea(parent);
  1010                 HbTouchArea *ta = new HbTouchArea(parent);
  1133                 ta->setFlags(QGraphicsItem::ItemIsFocusable);
  1011                 ta->setFlags(QGraphicsItem::ItemIsFocusable);
  1134                 setItemName(ta, QLatin1String("toucharea"));
  1012                 setItemName(ta, QLatin1String("toucharea"));
  1135                 // NOTE:: This is a temporary fix
  1013                 // NOTE:: This is a temporary fix
  1136                 //if(parent){
  1014                 //if(parent){
  1137                 //    parent->setHandlesChildEvents(true); 
  1015                 //    parent->setHandlesChildEvents(true);
  1138                 //}
  1016                 //}
  1139                 return ta;
  1017                 return ta;
  1140                 }
  1018                 }
  1141             case P_ComboBoxButton_toucharea:
  1019             case P_ComboBoxButton_toucharea:
  1142                 {
  1020                 {
  1143                 HbTouchArea *ta = new HbTouchArea(parent);
  1021                 HbTouchArea *ta = new HbTouchArea(parent);
  1144                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1022                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1145                 setItemName(ta, QLatin1String("combobox_button_toucharea"));
  1023                 setItemName(ta, QLatin1String("combobox_button_toucharea"));
  1146                 /*if(parent){
  1024                 if(parent){
  1147                     parent->setHandlesChildEvents(true); 
  1025                     parent->setFiltersChildEvents(true);
  1148                 }*/
  1026                 }
  1149                 return ta;
  1027                 return ta;
  1150                 }
  1028                 }
  1151              case P_TitleBar_toucharea: {
  1029              case P_TitleBar_toucharea: 
       
  1030                 {
  1152                 HbTouchArea *ta = new HbTouchArea(parent);
  1031                 HbTouchArea *ta = new HbTouchArea(parent);
  1153                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1032                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1154                 setItemName(ta, QLatin1String("toucharea"));
  1033                 setItemName(ta, QLatin1String("toucharea"));
       
  1034                 return ta;
       
  1035                 }
       
  1036              case P_IndicatorButton_toucharea:
       
  1037              case P_TitlePane_toucharea:
       
  1038              case P_NavigationButton_toucharea:
       
  1039                 {
       
  1040                 HbTouchArea *ta = new HbTouchArea(parent);
       
  1041                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
       
  1042                 setItemName(ta, QLatin1String("toucharea"));
       
  1043                 if (parent){
       
  1044                     parent->setHandlesChildEvents(true);
       
  1045                 }
  1155                 return ta;
  1046                 return ta;
  1156                 }
  1047                 }
  1157              case P_SliderElement_touchdecrease:
  1048              case P_SliderElement_touchdecrease:
  1158              case P_SliderElement_touchincrease:
  1049              case P_SliderElement_touchincrease:
  1159              case P_SliderElement_touchgroove:
  1050              case P_SliderElement_touchgroove:
  1160                 {
  1051                 {
  1161                 HbTouchArea *ta = new HbTouchArea(parent);
  1052                 HbTouchArea *ta = new HbTouchArea(parent);
  1162                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1053                 ta->setFlag(QGraphicsItem::ItemIsFocusable);
  1163                 if(parent){
  1054                 if(parent){
  1164                     //parent->setHandlesChildEvents(true); 
  1055                     parent->setFiltersChildEvents(true);
  1165                 }
  1056                 }
  1166                 return ta;
  1057                 return ta;
  1167                 }
  1058                 }
  1168             case P_SliderElement_text:
  1059             case P_SliderElement_text:
  1169             case P_ProgressBar_text:
  1060             case P_ProgressBar_text:
  1199                 HbTextItem *ti = new HbTextItem(parent);
  1090                 HbTextItem *ti = new HbTextItem(parent);
  1200                 setItemName(ti, QLatin1String("text"));
  1091                 setItemName(ti, QLatin1String("text"));
  1201                 ti->setAlignment(Qt::AlignCenter);
  1092                 ti->setAlignment(Qt::AlignCenter);
  1202                 return ti;
  1093                 return ti;
  1203             }
  1094             }
  1204                 
  1095 
  1205             case P_Label_richtext: 
  1096             case P_Label_richtext:
  1206             {
  1097             {
  1207                 HbRichTextItem *rti = new HbRichTextItem(parent);
  1098                 HbRichTextItem *rti = new HbRichTextItem(parent);
  1208                 setItemName(rti, QLatin1String("text"));
  1099                 setItemName(rti, QLatin1String("text"));
  1209                 return rti;
  1100                 return rti;
  1210             }
  1101             }
  1242 
  1133 
  1243             case P_ProgressBar_frame:
  1134             case P_ProgressBar_frame:
  1244             {
  1135             {
  1245                 HbFrameItem *n = new HbFrameItem(parent);
  1136                 HbFrameItem *n = new HbFrameItem(parent);
  1246                 n->setZValue(-1);
  1137                 n->setZValue(-1);
       
  1138                 n->frameDrawer().setFillWholeRect(true);
  1247                 setItemName(n, "frame");
  1139                 setItemName(n, "frame");
  1248                 return n;
  1140                 return n;
  1249             }
  1141             }
  1250 
  1142 
  1251             case P_ComboBoxPopup_background:
  1143             case P_ComboBoxPopup_background:
  1271             }
  1163             }
  1272 
  1164 
  1273             case P_DateTimePicker_separator:{
  1165             case P_DateTimePicker_separator:{
  1274                 HbFrameItem *frameItem= new HbFrameItem(parent);//TODO:make it icon once iconitem setGeomoetry works for tumbleview
  1166                 HbFrameItem *frameItem= new HbFrameItem(parent);//TODO:make it icon once iconitem setGeomoetry works for tumbleview
  1275                 return frameItem;
  1167                 return frameItem;
  1276             }           
  1168             }
  1277             case P_DataGroup_background :
  1169             case P_DataGroup_background :
  1278             {
  1170             {
  1279                 HbFrameItem *n = new HbFrameItem(parent);
  1171                 HbFrameItem *n = new HbFrameItem(parent);
  1280                 n->setZValue(-1);
  1172                 n->setZValue(-1);
  1281                 setItemName(n, QLatin1String("dataGroup_Background"));
  1173                 setItemName(n, QLatin1String("dataGroup_Background"));
  1312                 return n;
  1204                 return n;
  1313             }
  1205             }
  1314             case P_ProgressBar_track:
  1206             case P_ProgressBar_track:
  1315             {
  1207             {
  1316                 HbProgressTrackItem *n = new HbProgressTrackItem(parent);
  1208                 HbProgressTrackItem *n = new HbProgressTrackItem(parent);
       
  1209                 n->frameDrawer().setFillWholeRect(true);
  1317                 n->setZValue(-2);
  1210                 n->setZValue(-2);
  1318                 return n;
  1211                 return n;
  1319             }
  1212             }
  1320             case P_ProgressSlider_slidertrack:
  1213             case P_ProgressSlider_slidertrack:
  1321             {
  1214             {
  1346             }
  1239             }
  1347             case P_IndicatorButton_handleindication:
  1240             case P_IndicatorButton_handleindication:
  1348             {
  1241             {
  1349                 HbIconItem *n = new HbIconItem(parent);
  1242                 HbIconItem *n = new HbIconItem(parent);
  1350                 setItemName(n, QLatin1String("handleindication"));
  1243                 setItemName(n, QLatin1String("handleindication"));
       
  1244                 return n;
       
  1245             }
       
  1246             case P_IndicatorButton_eventindication:
       
  1247             {
       
  1248                 HbIconItem *n = new HbIconItem(parent);
       
  1249                 n->setFlags(HbIcon::Colorized);
       
  1250                 setItemName(n, QLatin1String("eventindication"));
  1351                 return n;
  1251                 return n;
  1352             }
  1252             }
  1353             case P_IndicatorGroup_icon1:
  1253             case P_IndicatorGroup_icon1:
  1354             {
  1254             {
  1355                 HbIconItem *n = new HbIconItem(parent);
  1255                 HbIconItem *n = new HbIconItem(parent);
  1431             case P_TextEdit_frame_highlight:
  1331             case P_TextEdit_frame_highlight:
  1432             {
  1332             {
  1433                 HbFrameItem *n = new HbFrameItem(parent);
  1333                 HbFrameItem *n = new HbFrameItem(parent);
  1434                 n->setZValue(-1);
  1334                 n->setZValue(-1);
  1435                 return n;
  1335                 return n;
  1436             }            
  1336             }
  1437             case P_GroupBoxMarquee_text:
  1337             case P_GroupBoxMarquee_text:
  1438             case P_TitlePane_text:
  1338             case P_TitlePane_text:
  1439             {
  1339             {
  1440                 HbMarqueeItem *n = new HbMarqueeItem(parent);
  1340                 HbMarqueeItem *n = new HbMarqueeItem(parent);
  1441                 setItemName(n, QLatin1String("text"));
  1341                 setItemName(n, QLatin1String("text"));
  1496             case P_RatingSlider_frame:
  1396             case P_RatingSlider_frame:
  1497                 return  new HbRepeatItem(parent);
  1397                 return  new HbRepeatItem(parent);
  1498 
  1398 
  1499             case P_RatingSlider_track:
  1399             case P_RatingSlider_track:
  1500                 return new HbRepeatMaskItem(parent);
  1400                 return new HbRepeatMaskItem(parent);
  1501             
  1401 
  1502             case P_RatingSlider_layout: {
  1402             case P_RatingSlider_layout: {
  1503                 HbWidgetBase *layout = new HbWidgetBase(parent);
  1403                 HbWidgetBase *layout = new HbWidgetBase(parent);
  1504                 setItemName(layout, "frame");
  1404                 setItemName(layout, "frame");
  1505                 return layout;
  1405                 return layout;
  1506             }
  1406             }
  1550                 return n;
  1450                 return n;
  1551             }
  1451             }
  1552 
  1452 
  1553             case P_ItemViewItem_background: {
  1453             case P_ItemViewItem_background: {
  1554                 HbIconItem *iconItem = q_check_ptr(new HbIconItem(parent));
  1454                 HbIconItem *iconItem = q_check_ptr(new HbIconItem(parent));
       
  1455                 iconItem->setZValue(-3.0);
  1555                 setItemName(iconItem, QLatin1String("background"));
  1456                 setItemName(iconItem, QLatin1String("background"));
  1556                 return iconItem;
  1457                 return iconItem;
  1557             }
  1458             }
  1558 
  1459 
  1559             case P_ListViewItem_text: {
  1460             case P_ListViewItem_text: {
  1612             case P_ComboBox_button: {
  1513             case P_ComboBox_button: {
  1613                 HbIconItem *n = new HbIconItem(QString(), parent);
  1514                 HbIconItem *n = new HbIconItem(QString(), parent);
  1614                 return n;
  1515                 return n;
  1615             }
  1516             }
  1616             case P_ItemViewItem_focus: {
  1517             case P_ItemViewItem_focus: {
  1617                 HbFrameItem *item = q_check_ptr(new HbFrameItem(parent));
  1518                 HbFrameItem *frameItem = q_check_ptr(new HbFrameItem(parent));
  1618                 //setItemName(item, QLatin1String("focus-indicator"));
  1519                 frameItem->setZValue(-1.0);
  1619                 return item;
  1520                 return frameItem;
  1620             }
  1521             }
  1621             case P_ItemHighlight_background: 
  1522             case P_ItemHighlight_background:
  1622                 return new HbFrameItem(parent);
  1523                 return new HbFrameItem(parent);
  1623 
  1524 
  1624             case P_ItemViewItem_frame: {
  1525             case P_ItemViewItem_frame: {
  1625                 HbFrameItem *item = q_check_ptr(new HbFrameItem(parent));
  1526                 HbFrameItem *item = q_check_ptr(new HbFrameItem(parent));
       
  1527                 item->setZValue(-4.0);
  1626                 setItemName(item,"frame");
  1528                 setItemName(item,"frame");
  1627                 return item;
  1529                 return item;
  1628             }
  1530             }
  1629             case P_ScrollArea_continuationbottom:
  1531             case P_ScrollArea_continuationbottom:
  1630             {
  1532             {
  1704 
  1606 
  1705   \deprecated HbStyle::updatePrimitive(QGraphicsItem*, HbStyle::Primitive, const QStyleOption*)
  1607   \deprecated HbStyle::updatePrimitive(QGraphicsItem*, HbStyle::Primitive, const QStyleOption*)
  1706   is deprecated. This method will be made private and finally removed since primitive updating will be done in the widgets.
  1608   is deprecated. This method will be made private and finally removed since primitive updating will be done in the widgets.
  1707 
  1609 
  1708   Updates the state and content of widget's child primitives. Update for a styled primitive should happen always when
  1610   Updates the state and content of widget's child primitives. Update for a styled primitive should happen always when
  1709   a state change that affects drawing occurs. Such a situation can be for example pressing of a button (change background image), or 
  1611   a state change that affects drawing occurs. Such a situation can be for example pressing of a button (change background image), or
  1710   changing a text for a widget having text content. The updatePrimitive() implementation for each primitive element can be considered 
  1612   changing a text for a widget having text content. The updatePrimitive() implementation for each primitive element can be considered
  1711   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 
  1613   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
  1712   uses the styleoption data for.
  1614   uses the styleoption data for.
  1713   
  1615 
  1714   \sa HbStyle::createPrimitive
  1616   \sa HbStyle::createPrimitive
  1715   \param item Primitive graphicsitem.
  1617   \param item Primitive graphicsitem.
  1716   \param primitive To identify the primitive to create.
  1618   \param primitive To identify the primitive to create.
  1717   \param option Style option, contains all the information needed to update the primitive, this
  1619   \param option Style option, contains all the information needed to update the primitive, this
  1718   information is widget specific and each widget usually has a styleoption. Styleoption may include
  1620   information is widget specific and each widget usually has a styleoption. Styleoption may include
  1720  */
  1622  */
  1721 void HbStyle::updatePrimitive( QGraphicsItem *item, HbStyle::Primitive primitive, const QStyleOption *option ) const
  1623 void HbStyle::updatePrimitive( QGraphicsItem *item, HbStyle::Primitive primitive, const QStyleOption *option ) const
  1722 {
  1624 {
  1723     Q_D( const HbStyle );
  1625     Q_D( const HbStyle );
  1724 
  1626 
  1725     if (d->customPrimitives.contains(primitive)) {
       
  1726         HbStyleInterfaceInfo* info = d->customPrimitives.value(primitive);
       
  1727         QObject* pluginInstance = info->loader->instance();
       
  1728         HbStyleInterface *stylePlugin = qobject_cast<HbStyleInterface *>(pluginInstance);
       
  1729         return stylePlugin->updatePrimitive(item, (HbStyle::Primitive)(primitive-info->primitiveBaseId), option);
       
  1730     }
       
  1731 
       
  1732     switch(primitive){
  1627     switch(primitive){
  1733             case P_PushButton_icon:
  1628             case P_PushButton_icon:
  1734                 {
  1629                 {
  1735                     if (const HbStyleOptionPushButton *opt = 
  1630                     if (const HbStyleOptionPushButton *opt =
  1736                         qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
  1631                         qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
  1737                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  1632                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  1738                         //iconItem->setIconName(opt->icon.iconName());
  1633                         //iconItem->setIconName(opt->icon.iconName());
  1739                         iconItem->setIcon(opt->icon); // with this call iconitem refresh issue is there 
  1634                         iconItem->setIcon(opt->icon); // with this call iconitem refresh issue is there
  1740                         iconItem->setMode(d->iconMode(opt->state));
  1635                         iconItem->setMode(d->iconMode(opt->state));
  1741                         iconItem->setState(d->iconState(opt->state));
  1636                         iconItem->setState(d->iconState(opt->state));
       
  1637                         iconItem->setAlignment(Qt::AlignCenter);
  1742                     }
  1638                     }
  1743                 break;
  1639                 break;
  1744                 }
  1640                 }
  1745             case P_GroupBoxHeading_icon:
  1641             case P_GroupBoxHeading_icon:
  1746                 {
  1642                 {
  1747                     if (const HbStyleOptionGroupBox *opt = 
  1643                     if (const HbStyleOptionGroupBox *opt =
  1748                         qstyleoption_cast<const HbStyleOptionGroupBox*>(option)) {
  1644                         qstyleoption_cast<const HbStyleOptionGroupBox*>(option)) {
  1749                             HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  1645                             HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  1750                             if (opt->collapsed) {
  1646                             if (opt->collapsed) {
  1751                                 iconItem->setIconName(QLatin1String("qtg_small_expand"));
  1647                                 iconItem->setIconName(QLatin1String("qtg_small_expand"));
  1752                             } else {
  1648                             } else {
  1755                     }
  1651                     }
  1756                     break;
  1652                     break;
  1757                 }
  1653                 }
  1758             case P_DataGroup_icon:
  1654             case P_DataGroup_icon:
  1759                 {
  1655                 {
  1760                     if (const HbStyleOptionDataGroupHeadingWidget *opt = 
  1656                     if (const HbStyleOptionDataGroupHeadingWidget *opt =
  1761                             qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget*>(option)) {
  1657                             qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget*>(option)) {
  1762                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  1658                         HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  1763                         if (opt->expanded) {
  1659                         if (opt->expanded) {
  1764                             iconItem->setIconName(QLatin1String("qtg_small_collapse"));
  1660                             iconItem->setIconName(QLatin1String("qtg_small_collapse"));
  1765                         } else {
  1661                         } else {
  1797                 break;
  1693                 break;
  1798             case P_ComboBox_text:
  1694             case P_ComboBox_text:
  1799                 if (const HbStyleOptionComboBox *opt = qstyleoption_cast<const HbStyleOptionComboBox*>(option)) {
  1695                 if (const HbStyleOptionComboBox *opt = qstyleoption_cast<const HbStyleOptionComboBox*>(option)) {
  1800                     HbTextItem *comboTextItem = static_cast<HbTextItem*>(item);
  1696                     HbTextItem *comboTextItem = static_cast<HbTextItem*>(item);
  1801                     comboTextItem->setText(opt->text);
  1697                     comboTextItem->setText(opt->text);
  1802                 }
  1698                     comboTextItem->setTextWrapping(Hb::TextNoWrap);
  1803                 break;                
  1699                 }
       
  1700                 break;
  1804             case P_PushButton_text:
  1701             case P_PushButton_text:
  1805                 {
  1702                 {
  1806                     if (const HbStyleOptionPushButton *opt = 
  1703                     if (const HbStyleOptionPushButton *opt =
  1807                         qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
  1704                         qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
  1808                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1705                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1809                         textItem->setText(opt->text);
  1706                         textItem->setText(opt->text);
  1810                         //default alignment will come from css,
  1707                         //default alignment will come from css,
  1811                         //if api flag is set ,then alignment from style is taken.
  1708                         //if api flag is set ,then alignment from style is taken.
  1812                         if (opt->hasTextAlignment) {
  1709                         if (opt->hasTextAlignment) {
  1813                             textItem->setAlignment( opt->textAlignment );                                           
  1710                             textItem->setAlignment( opt->textAlignment );
  1814                         }                        
  1711                         }
  1815                         textItem->setTextWrapping(Hb::TextWordWrap);
  1712                         textItem->setTextWrapping(Hb::TextWordWrap);
  1816                     }
  1713                     }
  1817                 }
  1714                 }
  1818                 break;
  1715                 break;
  1819             case P_ProgressDialog_text:
  1716             case P_ProgressDialog_text:
  1820                 {
  1717                 {
  1821                     if (const HbStyleOptionProgressDialog *opt = 
  1718                     if (const HbStyleOptionProgressDialog *opt =
  1822                         qstyleoption_cast<const HbStyleOptionProgressDialog*>(option)) {
  1719                         qstyleoption_cast<const HbStyleOptionProgressDialog*>(option)) {
  1823                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1720                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1824                         textItem->setText(opt->text);                       
  1721                         textItem->setText(opt->text);
  1825                     }
  1722                     }
  1826                 break;
  1723                 break;
  1827                 }
  1724                 }
  1828             case P_PushButton_additionaltext:
  1725             case P_PushButton_additionaltext:
  1829                 {
  1726                 {
  1830                     if (const HbStyleOptionPushButton *opt = 
  1727                     if (const HbStyleOptionPushButton *opt =
  1831                             qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
  1728                             qstyleoption_cast<const HbStyleOptionPushButton*>(option)) {
  1832                         HbTextItem *additionalTextItem = static_cast<HbTextItem*>(item);
  1729                         HbTextItem *additionalTextItem = static_cast<HbTextItem*>(item);
  1833                         additionalTextItem->setText(opt->additionalText);
  1730                         additionalTextItem->setText(opt->additionalText);
  1834                         //default alignment will come from css,
  1731                         //default alignment will come from css,
  1835                         //if api flag is set ,then alignment from style is taken.
  1732                         //if api flag is set ,then alignment from style is taken.
  1836                         if (opt->hasAdditionalTextAlignment) {
  1733                         if (opt->hasAdditionalTextAlignment) {
  1837                             additionalTextItem->setAlignment( opt->additionalTextAlignment );                       
  1734                             additionalTextItem->setAlignment( opt->additionalTextAlignment );
  1838                         }                       
  1735                         }
  1839                         additionalTextItem->setTextWrapping(Hb::TextWordWrap);
  1736                         additionalTextItem->setTextWrapping(Hb::TextWordWrap);
  1840                     }                    
  1737                     }
  1841                 }
  1738                 }
  1842                 break;
  1739                 break;
  1843             case P_PushButton_toucharea:  // Generic implementation, can add other cases here
  1740             case P_PushButton_toucharea:  // Generic implementation, can add other cases here
  1844             case P_ComboBoxButton_toucharea:
  1741             case P_ComboBoxButton_toucharea:
  1845             case P_CheckBox_toucharea:
  1742             case P_CheckBox_toucharea:
  1846             case P_TitleBar_toucharea:
  1743             case P_TitleBar_toucharea:
       
  1744             case P_IndicatorButton_toucharea:
       
  1745             case P_TitlePane_toucharea:
       
  1746             case P_NavigationButton_toucharea:
  1847             case P_SliderElement_touchdecrease:
  1747             case P_SliderElement_touchdecrease:
  1848             case P_SliderElement_touchincrease:
  1748             case P_SliderElement_touchincrease:
  1849             case P_SliderElement_touchgroove:
  1749             case P_SliderElement_touchgroove:
  1850             case P_SliderElement_touchhandle:
  1750             case P_SliderElement_touchhandle:
  1851             case P_ScrollBar_toucharea:
  1751             case P_ScrollBar_toucharea:
  1854                     touchArea->setZValue(TOUCHAREA_ZVALUE);
  1754                     touchArea->setZValue(TOUCHAREA_ZVALUE);
  1855                 }
  1755                 }
  1856                 break;
  1756                 break;
  1857             case P_DataGroup_heading:
  1757             case P_DataGroup_heading:
  1858                 {
  1758                 {
  1859                    if (const HbStyleOptionDataGroupHeadingWidget *opt = 
  1759                    if (const HbStyleOptionDataGroupHeadingWidget *opt =
  1860                         qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget*>(option)) {
  1760                         qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget*>(option)) {
  1861                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1761                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1862                         textItem->setText(opt->heading);
  1762                         textItem->setText(opt->heading);
       
  1763                         textItem->setTextWrapping(Hb::TextNoWrap);
  1863                     }
  1764                     }
  1864                 break;
  1765                 break;
  1865                 }
  1766                 }
  1866             case P_DataGroup_description:
  1767             case P_DataGroup_description:
  1867                 {
  1768                 {
  1868                    if (const HbStyleOptionDataGroupHeadingWidget *opt = 
  1769                    if (const HbStyleOptionDataGroupHeadingWidget *opt =
  1869                         qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget*>(option)) {
  1770                         qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget*>(option)) {
  1870                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1771                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1871                         textItem->setText(opt->description);
  1772                         textItem->setText(opt->description);
  1872                     }
  1773                     }
  1873                 break;
  1774                 break;
  1874                 }
  1775                 }
  1875             case P_DataForm_heading:
  1776             case P_DataForm_heading:
  1876                 {
  1777                 {
  1877                    if (const HbStyleOptionDataForm *opt = 
  1778                    if (const HbStyleOptionDataForm *opt =
  1878                         qstyleoption_cast<const HbStyleOptionDataForm*>(option)) {
  1779                         qstyleoption_cast<const HbStyleOptionDataForm*>(option)) {
  1879                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1780                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1880                         textItem->setText(opt->heading);
  1781                         textItem->setText(opt->heading);
  1881                     }
  1782                     }
  1882                 break;
  1783                 break;
  1883                 }
  1784                 }
  1884             case P_DataForm_description:
  1785             case P_DataForm_description:
  1885                 {
  1786                 {
  1886                    if (const HbStyleOptionDataForm *opt = 
  1787                    if (const HbStyleOptionDataForm *opt =
  1887                         qstyleoption_cast<const HbStyleOptionDataForm*>(option)) {
  1788                         qstyleoption_cast<const HbStyleOptionDataForm*>(option)) {
  1888                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1789                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1889                         HbFontSpec spec(HbFontSpec::Secondary);
  1790                         HbFontSpec spec(HbFontSpec::Secondary);
  1890                         QFont descriptionFont = spec.font();
  1791                         QFont descriptionFont = spec.font();
  1891                         descriptionFont.setItalic(true);
  1792                         descriptionFont.setItalic(true);
  1909                 if (const HbStyleOptionToolButton *opt = qstyleoption_cast<const HbStyleOptionToolButton*>(option)) {
  1810                 if (const HbStyleOptionToolButton *opt = qstyleoption_cast<const HbStyleOptionToolButton*>(option)) {
  1910                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1811                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1911                     textItem->setText(opt->text);
  1812                     textItem->setText(opt->text);
  1912                 }
  1813                 }
  1913                 break;
  1814                 break;
  1914             case P_ProgressBar_text: {    
  1815             case P_ProgressBar_text: {
  1915                   if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {    
  1816                   if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {
  1916                       HbTextItem *textItem = static_cast<HbTextItem*>(item);    
  1817                       HbTextItem *textItem = static_cast<HbTextItem*>(item);
  1917                       textItem->setAlignment(Qt::AlignCenter);    
  1818                       textItem->setAlignment(Qt::AlignCenter);
  1918                       textItem->setZValue(100);    
  1819                       textItem->setZValue(100);
  1919                       textItem->setText(opt->text);    
  1820                       textItem->setText(opt->text);
  1920                   }    
  1821                   }
  1921                   break;    
  1822                   break;
  1922               } 
  1823               }
  1923             case P_DataGroup_background: {
  1824             case P_DataGroup_background: {
  1924                 if (const HbStyleOptionDataGroupHeadingWidget *opt = 
  1825                 if (const HbStyleOptionDataGroupHeadingWidget *opt =
  1925                     qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget *>(option)) {
  1826                     qstyleoption_cast<const HbStyleOptionDataGroupHeadingWidget *>(option)) {
  1926                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1827                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1927                     if(!frameItem){
  1828                     if(!frameItem){
  1928                         return;
  1829                         return;
  1929                     }
  1830                     }
       
  1831                     QString frameGraphicsName;
       
  1832                     QIcon::Mode mode = QIcon::Disabled;
       
  1833                     if (opt->state & QStyle::State_Enabled) {
       
  1834                         mode = QIcon::Normal;
       
  1835                     }
       
  1836                     if (opt->state & QStyle::State_Active) {
       
  1837                         mode = QIcon::Active;
       
  1838                     } 
       
  1839                     if (opt->state & QStyle::State_Selected) {
       
  1840                         mode = QIcon::Selected;
       
  1841                     }
  1930                     frameItem->setZValue(-1.0);
  1842                     frameItem->setZValue(-1.0);
  1931                     if(opt->pressed) {
  1843                     if(mode == QIcon::Disabled) {
       
  1844                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_disabled"));
       
  1845                     }                   
       
  1846                     else if(opt->pressed ) {
  1932                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_pressed"));
  1847                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_pressed"));
  1933                     } else {
  1848                     } else {
  1934                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_parent_normal"));
  1849                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_parent_normal"));
  1935                     }
  1850                     }
  1936                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  1851                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  1937                     frameItem->setGeometry(opt->rect);
  1852                     frameItem->setGeometry(opt->rect);
  1938                 }
  1853                 }
  1939                 break;
  1854                 break;
  1940             }
  1855             }
  1941             case P_DataGroupComboBackground: {
  1856             case P_DataGroupComboBackground: {
  1942                 HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1857                 if (const HbStyleOptionDataGroup *opt = qstyleoption_cast<const HbStyleOptionDataGroup *>(option)) {
  1943                 if(!frameItem){
  1858                     QString frameGraphicsName;
  1944                     return;
  1859                     QIcon::Mode mode = QIcon::Disabled;
  1945                 }
  1860                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1946                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_parent_normal"));
  1861                     if(!frameItem){
  1947                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  1862                         return;
       
  1863                     }
       
  1864                     if (opt->state & QStyle::State_Enabled) {
       
  1865                         mode = QIcon::Normal;
       
  1866                     }
       
  1867                     if (opt->state & QStyle::State_Active) {
       
  1868                         mode = QIcon::Active;
       
  1869                     }
       
  1870                     if (opt->state & QStyle::State_Selected) {
       
  1871                         mode = QIcon::Selected;
       
  1872                     }
       
  1873                     if (mode == QIcon::Disabled ) {
       
  1874                             frameGraphicsName = QLatin1String("qtg_fr_list_disabled");
       
  1875                         } else  {
       
  1876                             frameGraphicsName = QLatin1String("qtg_fr_list_parent_normal");
       
  1877                     }
       
  1878                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
       
  1879                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1880                 }
  1948                 break;
  1881                 break;
  1949             }
  1882             }
  1950 
  1883 
  1951             case P_GroupBoxHeading_background: {
  1884             case P_GroupBoxHeading_background: {
  1952                 if (const HbStyleOptionGroupBox *opt = qstyleoption_cast<const HbStyleOptionGroupBox *>(option)) {
  1885                 if (const HbStyleOptionGroupBox *opt = qstyleoption_cast<const HbStyleOptionGroupBox *>(option)) {
  1953                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1886                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1954                 
  1887 
  1955                     if(!frameItem){
  1888                     if(!frameItem){
  1956                         return;
  1889                         return;
  1957                     }
  1890                     }
  1958                     QString frameGraphicsName;
  1891                     QString frameGraphicsName;
  1959                     if(opt->groupBoxType == HbStyleOptionGroupBox::GroupBoxSimpleLabel)
  1892                     if(opt->groupBoxType == HbStyleOptionGroupBox::GroupBoxSimpleLabel)
  1965                             frameGraphicsName = QLatin1String("qtg_fr_list_parent_normal");
  1898                             frameGraphicsName = QLatin1String("qtg_fr_list_parent_normal");
  1966                         } else {
  1899                         } else {
  1967                             frameGraphicsName = QLatin1String("qtg_fr_list_highlight");
  1900                             frameGraphicsName = QLatin1String("qtg_fr_list_highlight");
  1968                         }
  1901                         }
  1969                     }
  1902                     }
  1970                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); 
  1903                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  1971                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
  1904                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
  1972                 }
  1905                 }
  1973                 break;
  1906                 break;
  1974             }
  1907             }
  1975 
  1908 
  1976             case P_GroupBoxContent_background: {
  1909             case P_GroupBoxContent_background: {
  1977                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
  1910                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption *>(option)) {
  1978                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1911                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1979                 
  1912 
  1980                     if(!frameItem){
  1913                     if(!frameItem){
  1981                         return;
  1914                         return;
  1982                     }
  1915                     }
  1983 
  1916 
  1984                     QString frameGraphicsName;
  1917                     QString frameGraphicsName;
  1987                     } else if (opt->state == QStyle::State_Off) {
  1920                     } else if (opt->state == QStyle::State_Off) {
  1988                         frameGraphicsName = QLatin1String("qtg_fr_groupbox_normal");
  1921                         frameGraphicsName = QLatin1String("qtg_fr_groupbox_normal");
  1989                     } else {
  1922                     } else {
  1990                         frameGraphicsName = QLatin1String("qtg_fr_groupbox_highlight");
  1923                         frameGraphicsName = QLatin1String("qtg_fr_groupbox_highlight");
  1991                     }
  1924                     }
  1992                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); 
  1925                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  1993                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
  1926                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
  1994                 }
  1927                 }
  1995                 break;
  1928                 break;
  1996             }
  1929             }
  1997             
  1930 
  1998             case P_DataItem_background: {
  1931             case P_DataItem_background: {
  1999                 HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1932                 if (const HbStyleOptionDataFormViewItem *opt = qstyleoption_cast<const HbStyleOptionDataFormViewItem *>(option)) {
  2000                 if(!frameItem){
  1933                     QString frameGraphicsName;
  2001                     return;
  1934                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  2002                 }
  1935                     if(!frameItem){
  2003 
  1936                         return;
  2004                 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_normal"));
  1937                     } 
  2005                 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  1938                     QIcon::Mode mode = QIcon::Disabled;
       
  1939                     if (opt->state & QStyle::State_Enabled) {
       
  1940                         mode = QIcon::Normal;
       
  1941                     }
       
  1942                     if (opt->state & QStyle::State_Active) {
       
  1943                         mode = QIcon::Active;
       
  1944                     }
       
  1945                     if (opt->state & QStyle::State_Selected) {
       
  1946                         mode = QIcon::Selected;
       
  1947                     }
       
  1948                     if (mode == QIcon::Disabled ) {
       
  1949                             frameGraphicsName = QLatin1String("qtg_fr_list_disabled");
       
  1950                         } else  {
       
  1951                             frameGraphicsName = QLatin1String("qtg_fr_list_parent_normal");
       
  1952                     }
       
  1953                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
       
  1954                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
  1955                 }
  2006                 break;
  1956                 break;
  2007             }
  1957             }
  2008             case P_DataItem_label: {
  1958             case P_DataItem_label: {
  2009                 if (const HbStyleOptionDataFormViewItem *opt = qstyleoption_cast<const HbStyleOptionDataFormViewItem *>(option)) {
  1959                 if (const HbStyleOptionDataFormViewItem *opt = qstyleoption_cast<const HbStyleOptionDataFormViewItem *>(option)) {
  2010                     HbTextItem *textitem = static_cast<HbTextItem*>( item );
  1960                     HbTextItem *textitem = static_cast<HbTextItem*>( item );
  2011                     textitem->setText(opt->label);
  1961                     textitem->setText(opt->label);
       
  1962                     textitem->setTextWrapping(Hb::TextNoWrap);
  2012                 }
  1963                 }
  2013                 break;
  1964                 break;
  2014             }
  1965             }
  2015             case P_DataItem_description: {
  1966             case P_DataItem_description: {
  2016                 if (const HbStyleOptionDataFormViewItem *opt = qstyleoption_cast<const HbStyleOptionDataFormViewItem *>(option)) {
  1967                 if (const HbStyleOptionDataFormViewItem *opt = qstyleoption_cast<const HbStyleOptionDataFormViewItem *>(option)) {
  2018                     textitem->setText(opt->description);
  1969                     textitem->setText(opt->description);
  2019                 }
  1970                 }
  2020                 break;
  1971                 break;
  2021             }
  1972             }
  2022             case P_PushButton_background: {
  1973             case P_PushButton_background: {
  2023                 if (const HbStyleOptionPushButton *opt = 
  1974                 if (const HbStyleOptionPushButton *opt =
  2024                     qstyleoption_cast<const HbStyleOptionPushButton *>(option)) {
  1975                     qstyleoption_cast<const HbStyleOptionPushButton *>(option)) {
  2025                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  1976                     HbFrameItem *frameItem = static_cast<HbFrameItem*>( item );
  2026                     QString frameGraphicsName;
  1977                     QString frameGraphicsName;
  2027                     QIcon::Mode mode = QIcon::Disabled;
  1978                     QIcon::Mode mode = QIcon::Disabled;
  2028                     QIcon::State state = QIcon::Off;
  1979                     QIcon::State state = QIcon::Off;
  2109                     }
  2060                     }
  2110                 }
  2061                 }
  2111                 break;
  2062                 break;
  2112             }
  2063             }
  2113             case P_StatusBar_timetext: {
  2064             case P_StatusBar_timetext: {
  2114                 if (const HbStyleOptionStatusBar *opt = 
  2065                 if (const HbStyleOptionStatusBar *opt =
  2115                     qstyleoption_cast<const HbStyleOptionStatusBar*>(option)) {
  2066                     qstyleoption_cast<const HbStyleOptionStatusBar*>(option)) {
  2116                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  2067                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  2117                     textItem->setText(opt->timeText);
  2068                     textItem->setText(opt->timeText);
  2118                     }
  2069                     }
  2119                 break;
  2070                 break;
  2120             }
  2071             }
  2121             
  2072 
  2122             case P_IndicatorGroup_icon1: 
  2073             case P_IndicatorGroup_icon1:
  2123             case P_IndicatorGroup_icon2: 
  2074             case P_IndicatorGroup_icon2:
  2124             case P_IndicatorGroup_icon3: 
  2075             case P_IndicatorGroup_icon3:
  2125             case P_IndicatorGroup_icon4: 
  2076             case P_IndicatorGroup_icon4:
  2126                 {  
  2077                 {
  2127                 const HbStyleOptionIndicatorGroup *opt = qstyleoption_cast<const HbStyleOptionIndicatorGroup *>(option);
  2078                 const HbStyleOptionIndicatorGroup *opt = qstyleoption_cast<const HbStyleOptionIndicatorGroup *>(option);
  2128                 if (opt) {
  2079                 if (opt) {
  2129                     HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
  2080                     HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
  2130                     iconItem->setIconName(opt->iconName);
  2081                     iconItem->setIconName(opt->iconName);
  2131                 }
  2082                 }
  2132                 break;
  2083                 break;
  2133             }
  2084             }
  2134 
  2085 
  2135             case P_IndicatorButton_handleindication: {  
  2086             case P_IndicatorButton_handleindication: {
  2136                 const HbStyleOptionIndicatorButton *opt = qstyleoption_cast<const HbStyleOptionIndicatorButton *>(option);
  2087                 const HbStyleOptionIndicatorButton *opt = qstyleoption_cast<const HbStyleOptionIndicatorButton *>(option);
  2137                 if (opt) {
  2088                 if (opt) {
  2138                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  2089                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  2139                     iconItem->setIconName("qtg_graf_titlebar_minimize");
  2090                     iconItem->setIconName("qtg_graf_titlebar_minimize");
       
  2091                 }
       
  2092                 break;
       
  2093             }
       
  2094 
       
  2095             case P_IndicatorButton_eventindication: {  
       
  2096                 const HbStyleOptionIndicatorButton *opt = qstyleoption_cast<const HbStyleOptionIndicatorButton *>(option);
       
  2097                 if (opt) {
       
  2098                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
       
  2099                     if (opt->twoIcons) {
       
  2100                         iconItem->setIconName("qtg_mono_new_event");
       
  2101                         iconItem->setVisible(true);
       
  2102                     } else {
       
  2103                         iconItem->setVisible(false);
       
  2104                     }
  2140                 }
  2105                 }
  2141                 break;
  2106                 break;
  2142             }
  2107             }
  2143 
  2108 
  2144             case P_SignalIndicator_icon: {
  2109             case P_SignalIndicator_icon: {
  2307 
  2272 
  2308                 if (opt) {
  2273                 if (opt) {
  2309                     HbMarqueeItem *marqueeItem = static_cast<HbMarqueeItem*>( item );
  2274                     HbMarqueeItem *marqueeItem = static_cast<HbMarqueeItem*>( item );
  2310                     if (marqueeItem) {
  2275                     if (marqueeItem) {
  2311                         marqueeItem->setText(opt->caption);
  2276                         marqueeItem->setText(opt->caption);
  2312                         marqueeItem->startAnimation();
       
  2313                     }
  2277                     }
  2314                 }
  2278                 }
  2315                 break;
  2279                 break;
  2316             }
  2280             }
  2317 
  2281 
  2349                     }
  2313                     }
  2350                 }
  2314                 }
  2351                 break;
  2315                 break;
  2352             }
  2316             }
  2353             case P_PushButton_focus: {
  2317             case P_PushButton_focus: {
  2354                 if (const HbStyleOptionPushButton *opt = 
  2318                 if (const HbStyleOptionPushButton *opt =
  2355                         qstyleoption_cast<const HbStyleOptionPushButton *>(option)) {
  2319                         qstyleoption_cast<const HbStyleOptionPushButton *>(option)) {
  2356                      HbFrameItem *iconItem  = static_cast<HbFrameItem*>(item);
  2320                      HbFrameItem *iconItem  = static_cast<HbFrameItem*>(item);
  2357                      iconItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_btn_highlight"));
  2321                      iconItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_btn_highlight"));
  2358                      int margin = 4;
  2322                      int margin = 4;
  2359                      QRectF focusRect  = opt->rect.adjusted(-margin , -margin , margin , margin);
  2323                      QRectF focusRect  = opt->rect.adjusted(-margin , -margin , margin , margin);
  2433                 }
  2397                 }
  2434 
  2398 
  2435                 switch (opt->toolBarPosition) {
  2399                 switch (opt->toolBarPosition) {
  2436                     case HbStyleOptionToolButton::TB_OnlyOne:
  2400                     case HbStyleOptionToolButton::TB_OnlyOne:
  2437                         if (opt->orientation == Qt::Vertical) {
  2401                         if (opt->orientation == Qt::Vertical) {
  2438                             list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_r");                                                        
  2402                             list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_r");
  2439                         } else {
  2403                         } else {
  2440                             list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_b");                            
  2404                             list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_b");
  2441                         }
  2405                         }
  2442                         break;
  2406                         break;
  2443                     case HbStyleOptionToolButton::TB_Beginning:
  2407                     case HbStyleOptionToolButton::TB_Beginning:
  2444                         if (opt->orientation == Qt::Vertical) {
  2408                         if (opt->orientation == Qt::Vertical) {
  2445                             list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_cr");
  2409                             list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_cr");
  2461                             list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_b");
  2425                             list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_b");
  2462                         }
  2426                         }
  2463                         break;
  2427                         break;
  2464                     default:
  2428                     default:
  2465 
  2429 
  2466                         break;                       
  2430                         break;
  2467                 }
  2431                 }
  2468                 frameItem->frameDrawer().setFileNameSuffixList(list);
  2432                 frameItem->frameDrawer().setFileNameSuffixList(list);
  2469                 if (mode == QIcon::Disabled && state == QIcon::Off) {
  2433                 if (mode == QIcon::Disabled && state == QIcon::Off) {
  2470                     frameGraphicsFooter = QLatin1String("disabled");
  2434                     frameGraphicsFooter = QLatin1String("disabled");
  2471                 } else if (mode == QIcon::Normal && state == QIcon::On) {
  2435                 } else if (mode == QIcon::Normal && state == QIcon::On) {
  2479                 } else {
  2443                 } else {
  2480                     frameGraphicsFooter = QLatin1String("normal");
  2444                     frameGraphicsFooter = QLatin1String("normal");
  2481                 }
  2445                 }
  2482 
  2446 
  2483                 frameItem->frameDrawer().setFrameGraphicsName(QString ("%0%1").arg(frameGraphicsHeader).arg(frameGraphicsFooter));
  2447                 frameItem->frameDrawer().setFrameGraphicsName(QString ("%0%1").arg(frameGraphicsHeader).arg(frameGraphicsFooter));
       
  2448                 frameItem->frameDrawer().setMirroringMode(HbIcon::LayoutDirection);
  2484 
  2449 
  2485                 break;
  2450                 break;
  2486             }
  2451             }
  2487 
  2452 
  2488 
  2453 
  2489 
  2454 
  2490             case P_SliderTickMark_majoricon: {
  2455             case P_SliderTickMark_majoricon: {
  2491                  if (const HbStyleOptionSlider *opt = 
  2456                  if (const HbStyleOptionSlider *opt =
  2492                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
  2457                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
  2493                         HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
  2458                         HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
  2494                         iconItem->setMode(d->iconMode(opt->state));
  2459                         iconItem->setMode(d->iconMode(opt->state));
  2495                         if ( opt->orientation ==Qt::Horizontal ){
  2460                         if ( opt->orientation ==Qt::Horizontal ){
  2496                             iconItem->setIconName( "qtg_graf_slider_h_tick_major" );
  2461                             iconItem->setIconName( "qtg_graf_slider_h_tick_major" );
  2498                             iconItem->setIconName ( "qtg_graf_slider_v_tick_major" );
  2463                             iconItem->setIconName ( "qtg_graf_slider_v_tick_major" );
  2499                         }
  2464                         }
  2500                         iconItem->setState(d->iconState(opt->state));
  2465                         iconItem->setState(d->iconState(opt->state));
  2501                     }
  2466                     }
  2502                  break;
  2467                  break;
  2503                                              
  2468 
  2504              }
  2469              }
  2505 
  2470 
  2506             case P_SliderTickMark_minoricon: {
  2471             case P_SliderTickMark_minoricon: {
  2507                  if (const HbStyleOptionSlider *opt = 
  2472                  if (const HbStyleOptionSlider *opt =
  2508                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
  2473                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
  2509                         HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
  2474                         HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item);
  2510                         iconItem->setMode(d->iconMode(opt->state));
  2475                         iconItem->setMode(d->iconMode(opt->state));
  2511                         if ( opt->orientation ==Qt::Horizontal ){
  2476                         if ( opt->orientation ==Qt::Horizontal ){
  2512                             iconItem->setIconName( "qtg_graf_slider_h_tick_minor" );
  2477                             iconItem->setIconName( "qtg_graf_slider_h_tick_minor" );
  2514                             iconItem->setIconName ( "qtg_graf_slider_v_tick_minor" );
  2479                             iconItem->setIconName ( "qtg_graf_slider_v_tick_minor" );
  2515                         }
  2480                         }
  2516                         iconItem->setState(d->iconState(opt->state));
  2481                         iconItem->setState(d->iconState(opt->state));
  2517                     }
  2482                     }
  2518                  break;
  2483                  break;
  2519                                              
  2484 
  2520              }                                             
  2485              }
  2521 
  2486 
  2522             case P_SliderTickMark_majorlabel: {
  2487             case P_SliderTickMark_majorlabel: {
  2523                  if (const HbStyleOptionSlider *opt = 
  2488                  if (const HbStyleOptionSlider *opt =
  2524                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
  2489                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
  2525                         HbTextItem *textItem = qgraphicsitem_cast<HbTextItem*>(item);
  2490                         HbTextItem *textItem = qgraphicsitem_cast<HbTextItem*>(item);
  2526  
  2491 
  2527                         textItem->setText( opt->text );
  2492                         textItem->setText( opt->text );
  2528 
  2493 
  2529                     }
  2494                     }
  2530                  break;
  2495                  break;
  2531                                              
  2496 
  2532              }
  2497              }
  2533 
  2498 
  2534             case P_SliderTickMark_minorlabel: {
  2499             case P_SliderTickMark_minorlabel: {
  2535                  if (const HbStyleOptionSlider *opt = 
  2500                  if (const HbStyleOptionSlider *opt =
  2536                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
  2501                         qstyleoption_cast<const HbStyleOptionSlider*>(option)) {
  2537                         HbTextItem *textItem = qgraphicsitem_cast<HbTextItem*>(item);
  2502                         HbTextItem *textItem = qgraphicsitem_cast<HbTextItem*>(item);
  2538                          textItem->setText( opt->text );
  2503                          textItem->setText( opt->text );
  2539                     }
  2504                     }
  2540                  break;
  2505                  break;
  2541                                              
  2506 
  2542              }                                             
  2507              }
  2543 
  2508 
  2544             case P_Slider_progressgroove: {
  2509             case P_Slider_progressgroove: {
  2545                 if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider *>(option))  {
  2510                 if (const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider *>(option))  {
  2546                     HbSliderTrackItem* frameItem = static_cast<HbSliderTrackItem*>(item);
  2511                     HbSliderTrackItem* frameItem = static_cast<HbSliderTrackItem*>(item);
  2547                     if(!frameItem->isVisible()) {
  2512                     if(!frameItem->isVisible()) {
  2554                     }
  2519                     }
  2555                     else{
  2520                     else{
  2556                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
  2521                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
  2557                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_slider_v_filled"));
  2522                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_slider_v_filled"));
  2558                         frameItem->setInverted(!opt->upsideDown);
  2523                         frameItem->setInverted(!opt->upsideDown);
  2559                         frameItem->frameDrawer().setMirroringMode(HbIcon::Prevented);       
  2524                         frameItem->frameDrawer().setMirroringMode(HbIcon::Prevented);
  2560                     }
  2525                     }
  2561                     frameItem->frameDrawer().setFillWholeRect(true);
  2526                     frameItem->frameDrawer().setFillWholeRect(true);
  2562                     frameItem->setMaximum(opt->maximum);
  2527                     frameItem->setMaximum(opt->maximum);
  2563                     frameItem->setMinimum(opt->minimum);
  2528                     frameItem->setMinimum(opt->minimum);
  2564                     frameItem->setValue(opt->sliderValue);
  2529                     frameItem->setValue(opt->sliderValue);
  2575                     HbFrameDrawer::FrameType type(HbFrameDrawer::Undefined);
  2540                     HbFrameDrawer::FrameType type(HbFrameDrawer::Undefined);
  2576                     QString name;
  2541                     QString name;
  2577 
  2542 
  2578                     if (opt->orientation == Qt::Horizontal) {
  2543                     if (opt->orientation == Qt::Horizontal) {
  2579                         type = HbFrameDrawer::ThreePiecesHorizontal;
  2544                         type = HbFrameDrawer::ThreePiecesHorizontal;
  2580                         if(!opt->groovePressed){
  2545                         if (opt->state & QStyle::State_Enabled) {
  2581                             name = QLatin1String("qtg_fr_slider_h_frame_normal");
  2546                             if(!opt->groovePressed){
  2582                         }
  2547                                 name = QLatin1String("qtg_fr_slider_h_frame_normal");
  2583                         else {
  2548                             }
  2584                             name = QLatin1String("qtg_fr_slider_h_frame_pressed");
  2549                             else {
       
  2550                                 name = QLatin1String("qtg_fr_slider_h_frame_pressed");
       
  2551                             }
       
  2552                         } else {
       
  2553                                 name = QLatin1String("qtg_fr_slider_h_frame_disabled");
  2585                         }
  2554                         }
  2586                     } else if (opt->orientation == Qt::Vertical) {
  2555                     } else if (opt->orientation == Qt::Vertical) {
  2587                         if(!opt->groovePressed){
  2556                         if (opt->state & QStyle::State_Enabled) {
  2588                             name = QLatin1String("qtg_fr_slider_v_frame_normal");
  2557                             if(!opt->groovePressed){
  2589                         }
  2558                                 name = QLatin1String("qtg_fr_slider_v_frame_normal");
  2590                         else {
  2559                             }
  2591                             name = QLatin1String("qtg_fr_slider_v_frame_pressed");
  2560                             else {
       
  2561                                 name = QLatin1String("qtg_fr_slider_v_frame_pressed");
       
  2562                             }
       
  2563                         } else {
       
  2564                                 name = QLatin1String("qtg_fr_slider_v_frame_disabled");
       
  2565                         
  2592                         }
  2566                         }
  2593                         type = HbFrameDrawer::ThreePiecesVertical;
  2567                         type = HbFrameDrawer::ThreePiecesVertical;
  2594                     }
  2568                     }
  2595 
  2569 
  2596                     frameItem->frameDrawer().setFrameGraphicsName(name);
  2570                     frameItem->frameDrawer().setFrameGraphicsName(name);
  2610                         thumbPath=d->logicalName(HbStyle::P_Slider_thumb, option);
  2584                         thumbPath=d->logicalName(HbStyle::P_Slider_thumb, option);
  2611                     }
  2585                     }
  2612                     else
  2586                     else
  2613                     {
  2587                     {
  2614                         thumbPath=opt->thumbPath;
  2588                         thumbPath=opt->thumbPath;
       
  2589                         iconItem->setAlignment(Qt::AlignCenter);
  2615                     }
  2590                     }
  2616                     iconItem->setIconName(thumbPath);
  2591                     iconItem->setIconName(thumbPath);
  2617                     iconItem->setAspectRatioMode(Qt::KeepAspectRatio);
  2592                     iconItem->setAspectRatioMode(Qt::KeepAspectRatio);
  2618                  }
  2593                  }
  2619                 break;
  2594                 break;
  2665                             if( opt->state & QStyle::State_Sunken) {
  2640                             if( opt->state & QStyle::State_Sunken) {
  2666                                 iconItem->setIconName(QLatin1String("qtg_mono_speaker_off"));
  2641                                 iconItem->setIconName(QLatin1String("qtg_mono_speaker_off"));
  2667                             } else {
  2642                             } else {
  2668                                 iconItem->setIconName(QLatin1String("qtg_mono_speaker"));
  2643                                 iconItem->setIconName(QLatin1String("qtg_mono_speaker"));
  2669                             }
  2644                             }
  2670                         } 
  2645                         }
  2671                     }
  2646                     }
  2672                 break;
  2647                 break;
  2673                 }
  2648                 }
  2674             case P_SliderElement_text:
  2649             case P_SliderElement_text:
  2675                 {
  2650                 {
  2691                 break;
  2666                 break;
  2692 
  2667 
  2693             case P_CheckBox_icon: {
  2668             case P_CheckBox_icon: {
  2694                 if (const HbStyleOptionCheckBox *opt = qstyleoption_cast<const HbStyleOptionCheckBox *>(option)){
  2669                 if (const HbStyleOptionCheckBox *opt = qstyleoption_cast<const HbStyleOptionCheckBox *>(option)){
  2695                     HbIconItem *iconItem = static_cast<HbIconItem *>(item);
  2670                     HbIconItem *iconItem = static_cast<HbIconItem *>(item);
  2696                     if (opt->state.testFlag(QStyle::State_On)) {
  2671                     if (opt->state.testFlag(QStyle::State_Selected) ) {
  2697                         iconItem->setState(QIcon::On);
  2672                         if (opt->state.testFlag(QStyle::State_On)) {
  2698                         iconItem->setIconName(QLatin1String("qtg_small_selected"));
  2673                             iconItem->setState(QIcon::On);
  2699                     } else if (opt->state.testFlag(QStyle::State_Off)) {
  2674                             iconItem->setIconName(QLatin1String("qtg_small_selected_highlight"));
  2700                         iconItem->setState(QIcon::Off);
  2675                         } else if (opt->state.testFlag(QStyle::State_Off)) {
  2701                         iconItem->setIconName(QLatin1String("qtg_small_unselected"));
  2676                             iconItem->setState(QIcon::Off);
  2702                     } else if (opt->state.testFlag(QStyle::State_NoChange)) {
  2677                             iconItem->setIconName(QLatin1String("qtg_small_unselected_highlight"));
  2703                         iconItem->setState(QIcon::On);
  2678                         } else if (opt->state.testFlag(QStyle::State_NoChange)) {
  2704                         iconItem->setIconName(QLatin1String("qtg_small_selected_partial"));
  2679                             iconItem->setState(QIcon::On);
       
  2680                             iconItem->setIconName(QLatin1String("qtg_small_selected_partial"));
       
  2681                         }
       
  2682                     } else {
       
  2683                         if (opt->state.testFlag(QStyle::State_On)) {
       
  2684                             iconItem->setState(QIcon::On);
       
  2685                             iconItem->setIconName(QLatin1String("qtg_small_selected"));
       
  2686                         } else if (opt->state.testFlag(QStyle::State_Off)) {
       
  2687                             iconItem->setState(QIcon::Off);
       
  2688                             iconItem->setIconName(QLatin1String("qtg_small_unselected"));
       
  2689                         } else if (opt->state.testFlag(QStyle::State_NoChange)) {
       
  2690                             iconItem->setState(QIcon::On);
       
  2691                             iconItem->setIconName(QLatin1String("qtg_small_selected_partial"));
       
  2692                         }
  2705                     }
  2693                     }
  2706                 }
  2694                 }
  2707                 break;
  2695                 break;
  2708             }
  2696             }
  2709             case P_ItemViewItem_radiobutton:
  2697             case P_ItemViewItem_radiobutton:
  2793                         if (opt->state & QStyle::State_Sunken) {
  2781                         if (opt->state & QStyle::State_Sunken) {
  2794                             frameGraphicsName = QLatin1String("qtg_fr_combobox_pressed");
  2782                             frameGraphicsName = QLatin1String("qtg_fr_combobox_pressed");
  2795                         } else {
  2783                         } else {
  2796                             frameGraphicsName = QLatin1String("qtg_fr_combobox_normal");
  2784                             frameGraphicsName = QLatin1String("qtg_fr_combobox_normal");
  2797                         }
  2785                         }
  2798                     } else {                        
  2786                     } else {
  2799                         frameGraphicsName = QLatin1String("qtg_fr_combobox_disabled");
  2787                         frameGraphicsName = QLatin1String("qtg_fr_combobox_disabled");
  2800                     }
  2788                     }
  2801                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  2789                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  2802                     frameItem->frameDrawer().setFillWholeRect(true);
  2790                     frameItem->frameDrawer().setFillWholeRect(true);
  2803                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
  2791                     frameItem->frameDrawer().setFrameGraphicsName(frameGraphicsName);
  2814                         if (opt->state & QStyle::State_Sunken) {
  2802                         if (opt->state & QStyle::State_Sunken) {
  2815                             iconGraphicsName = QLatin1String("qtg_graf_combobox_button_pressed");
  2803                             iconGraphicsName = QLatin1String("qtg_graf_combobox_button_pressed");
  2816                         } else {
  2804                         } else {
  2817                             iconGraphicsName = QLatin1String("qtg_graf_combobox_button_normal");
  2805                             iconGraphicsName = QLatin1String("qtg_graf_combobox_button_normal");
  2818                         }
  2806                         }
  2819                     } else {                        
  2807                     } else {
  2820                         iconGraphicsName = QLatin1String("qtg_graf_combobox_button_disabled");
  2808                         iconGraphicsName = QLatin1String("qtg_graf_combobox_button_disabled");
  2821                     }
  2809                     }
  2822                     iconItem->setIconName(iconGraphicsName);
  2810                     iconItem->setIconName(iconGraphicsName);
  2823                     iconItem->setMirroringMode ( HbIcon::LayoutDirection );
  2811                     iconItem->setMirroringMode ( HbIcon::LayoutDirection );
  2824                     iconItem->setAspectRatioMode( Qt::IgnoreAspectRatio);
  2812                     iconItem->setAspectRatioMode( Qt::IgnoreAspectRatio);
  2859                  }
  2847                  }
  2860                  break;
  2848                  break;
  2861             case P_Label_richtext:
  2849             case P_Label_richtext:
  2862                 if (const HbStyleOptionLabel *opt = qstyleoption_cast<const HbStyleOptionLabel*>(option)) {
  2850                 if (const HbStyleOptionLabel *opt = qstyleoption_cast<const HbStyleOptionLabel*>(option)) {
  2863                     HbRichTextItem *textItem = static_cast<HbRichTextItem*>(item);
  2851                     HbRichTextItem *textItem = static_cast<HbRichTextItem*>(item);
  2864                     textItem->setAlignment(opt->alignment);                    
  2852                     textItem->setAlignment(opt->alignment);
  2865                     textItem->setTextWrapping(opt->textWrapMode);
  2853                     textItem->setTextWrapping(opt->textWrapMode);
  2866                     if(!opt->fontSpec.isNull()) {
  2854                     if(!opt->fontSpec.isNull()) {
  2867                         textItem->setFontSpec(opt->fontSpec);
  2855                         textItem->setFontSpec(opt->fontSpec);
  2868                     }
  2856                     }
  2869                     if (opt->color.isValid()) {
  2857                     if (opt->color.isValid()) {
  2883 
  2871 
  2884             case P_MenuItem_checkindicator:
  2872             case P_MenuItem_checkindicator:
  2885                 if (const HbStyleOptionMenuItem *opt = qstyleoption_cast<const HbStyleOptionMenuItem *>(option)) {
  2873                 if (const HbStyleOptionMenuItem *opt = qstyleoption_cast<const HbStyleOptionMenuItem *>(option)) {
  2886                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  2874                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  2887                     if (opt->checked) {
  2875                     if (opt->checked) {
  2888                         iconItem->setIconName(QLatin1String("qtg_small_selected"));
  2876                         iconItem->setIconName(QLatin1String("qtg_small_tick"));
  2889                     } else {
  2877                     } else {
  2890                         iconItem->setIcon(HbIcon());
  2878                         iconItem->setIcon(HbIcon());
  2891                     }
  2879                     }
  2892                 }
  2880                 }
  2893                 break;
  2881                 break;
  3046                 if (const HbStyleOptionNotificationDialog *opt =
  3034                 if (const HbStyleOptionNotificationDialog *opt =
  3047                         qstyleoption_cast<const HbStyleOptionNotificationDialog *>(option)) {
  3035                         qstyleoption_cast<const HbStyleOptionNotificationDialog *>(option)) {
  3048                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3036                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3049                     textItem->setAlignment(opt->textAlignment);
  3037                     textItem->setAlignment(opt->textAlignment);
  3050                     textItem->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
  3038                     textItem->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
  3051                     textItem->setTextWrapping(opt->wrappingText);
  3039                     textItem->setTextWrapping(opt->textTextWrapping);
  3052                     textItem->setText(opt->text);
  3040                     textItem->setText(opt->text);
  3053                 }
  3041                 }
  3054                 break;
  3042                 break;
  3055             case P_NotificationDialog_title:
  3043             case P_NotificationDialog_title:
  3056                 if (const HbStyleOptionNotificationDialog *opt =
  3044                 if (const HbStyleOptionNotificationDialog *opt =
  3057                         qstyleoption_cast<const HbStyleOptionNotificationDialog *>(option)) {
  3045                         qstyleoption_cast<const HbStyleOptionNotificationDialog *>(option)) {
  3058                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3046                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3059 
       
  3060                     textItem->setAlignment(opt->titleAlignment);
  3047                     textItem->setAlignment(opt->titleAlignment);
  3061                     textItem->setFontSpec(HbFontSpec(HbFontSpec::Primary));
  3048                     textItem->setFontSpec(HbFontSpec(HbFontSpec::Primary));
  3062                     textItem->setTextWrapping(opt->wrappingTitle);
  3049                     textItem->setTextWrapping(opt->titleTextWrapping);
       
  3050                     if (opt->titleTextWrapping == Hb::TextNoWrap) {
       
  3051                         textItem->setElideMode(Qt::ElideNone);
       
  3052                     } else {
       
  3053                         textItem->setElideMode(Qt::ElideRight);
       
  3054                     }
  3063                     textItem->setText(opt->title);
  3055                     textItem->setText(opt->title);
  3064                 }
  3056                 }
  3065                 break;
  3057                 break;
  3066             case P_NotificationDialog_icon:
  3058             case P_NotificationDialog_icon:
  3067                 if (const HbStyleOptionNotificationDialog *opt =
  3059                 if (const HbStyleOptionNotificationDialog *opt =
  3109                             icon->setIcon(HbIcon(QLatin1String("qtg_large_warning")));
  3101                             icon->setIcon(HbIcon(QLatin1String("qtg_large_warning")));
  3110                             break;
  3102                             break;
  3111                         default:
  3103                         default:
  3112                             break;
  3104                             break;
  3113                         }
  3105                         }
  3114                     } else {                 
  3106                     } else {
  3115                         icon->setIcon(opt->icon);
  3107                         icon->setIcon(opt->icon);
  3116                     }
  3108                     }
  3117                 }
  3109                 }
  3118                 break;
  3110                 break;
  3119             case P_ListViewItem_text:
  3111             case P_ListViewItem_text:
  3120                 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) {
  3112                 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) {
  3121                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3113                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3122                     
  3114 
  3123                     if (opt->index == 1) {
  3115                     if (opt->index == 1) {
  3124                         if (opt->multilineSecondaryTextSupported) {
  3116                         if (opt->multilineSecondaryTextSupported) {
  3125                             if (opt->minimumLines != -1) {
  3117                             if (opt->minimumLines != -1) {
  3126                                 // min & max secondary text row counts set by app
  3118                                 // min & max secondary text row counts set by app
  3127                                 Hb::TextWrapping wrapping = Hb::TextNoWrap;
  3119                                 Hb::TextWrapping wrapping = Hb::TextNoWrap;
  3161                 }
  3153                 }
  3162                 break;
  3154                 break;
  3163             case P_ListViewItem_icon:
  3155             case P_ListViewItem_icon:
  3164                 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) {
  3156                 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) {
  3165                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  3157                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  3166                     
  3158 
  3167                     setItemName(iconItem, QLatin1String("icon-") + QString::number(opt->index + 1));
  3159                     setItemName(iconItem, QLatin1String("icon-") + QString::number(opt->index + 1));
  3168                     iconItem->setZValue(opt->index + 1);
  3160                     if (iconItem->zValue() != opt->index + 1) {
       
  3161                         iconItem->setZValue(opt->index + 1);
       
  3162                     }
  3169 
  3163 
  3170                     if (opt->content.canConvert<HbIcon>()){
  3164                     if (opt->content.canConvert<HbIcon>()){
  3171                         iconItem->setIcon(opt->content.value<HbIcon>());
  3165                         iconItem->setIcon(opt->content.value<HbIcon>());
  3172                     } if (opt->content.canConvert<QIcon>()){
  3166                     } if (opt->content.canConvert<QIcon>()){
  3173                         iconItem->setIcon(opt->content.value<QIcon>());
  3167                         iconItem->setIcon(opt->content.value<QIcon>());
  3257                       
  3251                       
  3258                         else{
  3252                         else{
  3259                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
  3253                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
  3260                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_v_frame"));
  3254                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_v_frame"));
  3261                         }
  3255                         }
  3262                     frameItem->frameDrawer().setFillWholeRect(true);
  3256                   //  frameItem->frameDrawer().setFillWholeRect(true);
  3263                 }
  3257                 }
  3264                 break;
  3258                 break;
  3265             case P_ProgressBar_track:
  3259             case P_ProgressBar_track:
  3266 
  3260 
  3267                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {
  3261                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {
  3268                     HbProgressTrackItem* frameItem = static_cast<HbProgressTrackItem*>(item);
  3262                     HbProgressTrackItem* frameItem = static_cast<HbProgressTrackItem*>(item);
  3269                     if(!frameItem->isVisible()) {
  3263                     if(!frameItem->isVisible()) {
  3270                         break;
  3264                         break;
  3271                     }
  3265                     }
  3272                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3266                     
  3273                     if(opt->orientation == Qt::Horizontal){
  3267                     if(opt->orientation == Qt::Horizontal){
  3274                                frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_h_filled"));
  3268                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
  3269                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_h_filled"));
  3275                      }
  3270                      }
  3276                      else{
  3271                      else{
  3277                                frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
  3272                                frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
  3278                                frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_v_filled"));
  3273                                frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progbar_v_filled"));
  3279                      }
  3274                      }
  3280                     frameItem->frameDrawer().setFillWholeRect(true);
  3275                     
  3281                     frameItem->setMaximum(opt->maximum);
  3276                     frameItem->setMaximum(opt->maximum);
  3282                     frameItem->setMinimum(opt->minimum);
  3277                     frameItem->setMinimum(opt->minimum);
  3283                     frameItem->setValue(opt->progressValue);
  3278                     frameItem->setValue(opt->progressValue);
  3284                     frameItem->setInverted(opt->inverted);
  3279                     frameItem->setInverted(opt->inverted);
  3285                     //frameItem->setGeometry(opt->rect);
  3280                     //frameItem->setGeometry(opt->rect);
  3286                     frameItem->setOrientation(opt->orientation);
  3281                     frameItem->setOrientation(opt->orientation);
  3287                     frameItem->update();
  3282                     frameItem->update();
  3288                 }
  3283                 }
  3289                 break;
  3284                 break;
  3290             case P_ProgressBar_waittrack:
  3285             case P_ProgressBar_waittrack:
  3291                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {                   
  3286                 if (const HbStyleOptionProgressBar *opt = qstyleoption_cast<const HbStyleOptionProgressBar *>(option)) {
  3292                     HbRepeatIconItem *iconItem = static_cast<HbRepeatIconItem*>(item);
  3287                     HbRepeatIconItem *iconItem = static_cast<HbRepeatIconItem*>(item);
  3293                     iconItem->setOrientation(opt->orientation);
  3288                     iconItem->setOrientation(opt->orientation);
  3294                     if( !iconItem->isVisible() ) {
  3289                     if( !iconItem->isVisible() ) {
  3295                         break;
  3290                         break;
  3296                     }
  3291                     }
  3303                     if(opt->stopWaitAnimation){
  3298                     if(opt->stopWaitAnimation){
  3304                         iconItem->stopAnimation();
  3299                         iconItem->stopAnimation();
  3305                     }
  3300                     }
  3306                     }
  3301                     }
  3307                     break;
  3302                     break;
  3308               
  3303 
  3309             case P_ProgressSlider_frame:
  3304             case P_ProgressSlider_frame:
  3310                 if (const HbStyleOptionProgressSlider *opt = qstyleoption_cast<const HbStyleOptionProgressSlider *>(option)) {
  3305                 if (const HbStyleOptionProgressSlider *opt = qstyleoption_cast<const HbStyleOptionProgressSlider *>(option)) {
  3311                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
  3306                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
  3312                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3307                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3313                    	if (opt->disableState ) { 
  3308                    	if (opt->disableState ) {
  3314                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_frame_disabled"));
  3309                         frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_frame_disabled"));
  3315 					}
  3310 					}
  3316 					else {
  3311 					else {
  3317 					     if(opt->pressedState) {
  3312 					     if(opt->pressedState) {
  3318                                frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_frame_pressed"));
  3313                                frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_frame_pressed"));
  3319                          }
  3314                          }
  3320                          else {
  3315                          else {
  3321                                frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_frame_normal"));
  3316                                frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_frame_normal"));
  3322                          }
  3317                          }
  3323 					}
  3318 					}
  3324                     frameItem->frameDrawer().setFillWholeRect(true);       
  3319                     frameItem->frameDrawer().setFillWholeRect(true);
  3325                     frameItem->update();
  3320                     //frameItem->update();
  3326                     }
  3321                     }
  3327                     break;
  3322                     break;
  3328             case P_ProgressSlider_track: // The ProgressValue Mask
  3323             case P_ProgressSlider_track: // The ProgressValue Mask
  3329                 if (const HbStyleOptionProgressSlider *opt = qstyleoption_cast<const HbStyleOptionProgressSlider *>(option)) {
  3324                 if (const HbStyleOptionProgressSlider *opt = qstyleoption_cast<const HbStyleOptionProgressSlider *>(option)) {
  3330                     HbProgressTrackItem* frameItem = static_cast<HbProgressTrackItem*>(item);
  3325                     HbProgressTrackItem* frameItem = static_cast<HbProgressTrackItem*>(item);
  3331                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3326                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3332                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_loaded"));
  3327 
       
  3328 					if (opt->disableState ) {
       
  3329                          frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_loaded_disabled"));
       
  3330 					}
       
  3331 					else {
       
  3332                          frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_loaded"));
       
  3333 					}
  3333                     frameItem->frameDrawer().setFillWholeRect(true);
  3334                     frameItem->frameDrawer().setFillWholeRect(true);
  3334                     frameItem->setMaximum(opt->maximum);
  3335                     frameItem->setMaximum(opt->maximum);
  3335                     frameItem->setMinimum(opt->minimum);
  3336                     frameItem->setMinimum(opt->minimum);
  3336                     frameItem->setValue(opt->progressValue);
  3337                     frameItem->setValue(opt->progressValue);
  3337                     frameItem->setInverted(opt->inverted);
  3338                     frameItem->setInverted(opt->inverted);
  3338                     frameItem->setOrientation(opt->orientation);
  3339                     frameItem->setOrientation(opt->orientation);
  3339                     frameItem->update();
  3340                     frameItem->update();
  3340                     } 
  3341                     }
  3341                     break;
  3342                     break;
  3342 
  3343 
  3343             case P_ProgressSlider_slidertrack: // The Slider Position Mask
  3344             case P_ProgressSlider_slidertrack: // The Slider Position Mask
  3344                 if (const HbStyleOptionProgressSlider *opt = qstyleoption_cast<const HbStyleOptionProgressSlider *>(option)) {
  3345                 if (const HbStyleOptionProgressSlider *opt = qstyleoption_cast<const HbStyleOptionProgressSlider *>(option)) {
  3345                     HbProgressTrackItem* frameItem = static_cast<HbProgressTrackItem*>(item);
  3346                     HbProgressTrackItem* frameItem = static_cast<HbProgressTrackItem*>(item);
  3346                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3347                     frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3347                     frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_played"));
  3348 					if (opt->disableState ) {
       
  3349                          frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_played_disabled"));
       
  3350 					}
       
  3351 					else {
       
  3352                          frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_progslider_played"));
       
  3353 					}
  3348                     frameItem->frameDrawer().setFillWholeRect(true);
  3354                     frameItem->frameDrawer().setFillWholeRect(true);
  3349                     frameItem->setMaximum(opt->maximum);
  3355                     frameItem->setMaximum(opt->maximum);
  3350                     frameItem->setMinimum(opt->minimum);
  3356                     frameItem->setMinimum(opt->minimum);
  3351                     frameItem->setValue(opt->progressSliderValue);
  3357                     frameItem->setValue(opt->progressSliderValue);
  3352                     frameItem->setInverted(opt->inverted);
  3358                     frameItem->setInverted(opt->inverted);
  3353                     frameItem->setOrientation(opt->orientation);
  3359                     frameItem->setOrientation(opt->orientation);
  3354                     frameItem->update();
  3360                     frameItem->update();
  3355                     } 
  3361                     }
  3356                     break;
  3362                     break;
  3357             case P_ProgressBar_mintext: {
  3363             case P_ProgressBar_mintext: {
  3358                  if (const HbStyleOptionProgressBar *opt = 
  3364                  if (const HbStyleOptionProgressBar *opt =
  3359                         qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {
  3365                         qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {
  3360                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3366                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3361                         if(!item) {
  3367                         if(!item) {
  3362                             return;
  3368                             return;
  3363                         }
  3369                         }
  3364                         textItem->setTextWrapping(Hb::TextWrapAnywhere);
  3370                         textItem->setTextWrapping(Hb::TextWrapAnywhere);
  3365                         textItem->setText(opt->minText);                            
  3371                         textItem->setText(opt->minText);
  3366                     }
  3372                     }
  3367                  break;
  3373                  break;
  3368             }
  3374             }
  3369 
  3375 
  3370             case P_ProgressBar_maxtext: {
  3376             case P_ProgressBar_maxtext: {
  3371                 if (const HbStyleOptionProgressBar *opt = 
  3377                 if (const HbStyleOptionProgressBar *opt =
  3372                         qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {
  3378                         qstyleoption_cast<const HbStyleOptionProgressBar*>(option)) {
  3373                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3379                         HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3374                         if(!item) {
  3380                         if(!item) {
  3375                             return;
  3381                             return;
  3376                         }
  3382                         }
  3377                         textItem->setTextWrapping(Hb::TextWrapAnywhere);
  3383                         textItem->setTextWrapping(Hb::TextWrapAnywhere);
  3378                         textItem->setText(opt->maxText);                            
  3384                         textItem->setText(opt->maxText);
  3379                     }
  3385                     }
  3380                 break;
  3386                 break;
  3381             }
  3387             }
  3382 
  3388 
  3383             case P_RatingSlider_frame:{
  3389             case P_RatingSlider_frame:{
  3384                 if (const HbStyleOptionRatingSlider *opt = qstyleoption_cast<const HbStyleOptionRatingSlider *>(option)) {                   
  3390                 if (const HbStyleOptionRatingSlider *opt = qstyleoption_cast<const HbStyleOptionRatingSlider *>(option)) {
  3385                     HbRepeatItem *repeatItem = static_cast<HbRepeatItem*>(item);
  3391                     HbRepeatItem *repeatItem = static_cast<HbRepeatItem*>(item);
  3386                     repeatItem->setRepeatingNumber(opt->noOfStars);
  3392                     repeatItem->setRepeatingNumber(opt->noOfStars);
  3387                     if(opt->unRatedGraphicsName != QString()){
  3393                     if (!opt->unRatedGraphicsName.isEmpty()) {
  3388                         repeatItem->setName(opt->unRatedGraphicsName);
  3394                         repeatItem->setName(opt->unRatedGraphicsName);
  3389                     }
  3395                     }
  3390                     else {
  3396                     else {
  3391                         repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated"));
  3397                         if(opt->disableState) {
       
  3398                              repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated_disabled"));
       
  3399 
       
  3400                         }
       
  3401                         else {
       
  3402 							if(opt->pressedState) {
       
  3403 
       
  3404 								repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated_pressed"));
       
  3405 							}
       
  3406 							else {
       
  3407                             
       
  3408 								repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated"));
       
  3409 							}
       
  3410                         }
  3392                     }
  3411                     }
  3393                     repeatItem->setGeometry(opt->boundingRect);
  3412                     repeatItem->setGeometry(opt->boundingRect);
  3394                     repeatItem->update();
  3413                     repeatItem->update();
  3395                 }
  3414                 }
  3396                 break;
  3415                 break;
  3397             }
  3416             }
  3398 
  3417 
  3399             case P_RatingSlider_track:{
  3418             case P_RatingSlider_track:{
  3400                 if (const HbStyleOptionRatingSlider *opt = qstyleoption_cast<const HbStyleOptionRatingSlider *>(option)) {                   
  3419                 if (const HbStyleOptionRatingSlider *opt = qstyleoption_cast<const HbStyleOptionRatingSlider *>(option)) {
  3401                     HbRepeatMaskItem *repeatItem = static_cast<HbRepeatMaskItem*>(item);
  3420                     HbRepeatMaskItem *repeatItem = static_cast<HbRepeatMaskItem*>(item);
  3402                     repeatItem->setMaskValue(opt->progressValue);
  3421                     repeatItem->setMaskValue(opt->progressValue);
  3403                     repeatItem->setMaximum(opt->noOfIntervals);
  3422                     repeatItem->setMaximum(opt->noOfIntervals);
  3404                     repeatItem->setInverted(opt->inverted);
  3423                     repeatItem->setInverted(opt->inverted);
  3405                     repeatItem->setRepeatingNumber(opt->noOfStars);
  3424                     repeatItem->setRepeatingNumber(opt->noOfStars);
  3406                     if(opt->ratedGraphicsName != QString()){
  3425                     if (!opt->ratedGraphicsName.isEmpty()) {
  3407                         repeatItem->setName(opt->ratedGraphicsName);
  3426                         repeatItem->setName(opt->ratedGraphicsName);
  3408                     }
  3427                     }
  3409                     else {
  3428                     else {
  3410                         repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated"));
  3429                         if(opt->disableState) {
       
  3430                             repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated_disabled"));
       
  3431 
       
  3432 
       
  3433                         }
       
  3434                         else {
       
  3435 
       
  3436 							if(opt->pressedState) {
       
  3437 
       
  3438 								repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated_pressed"));
       
  3439 							}
       
  3440 							else {
       
  3441 								repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated"));
       
  3442 							}
       
  3443                         }
  3411                     }
  3444                     }
  3412                     repeatItem->setGeometry(opt->boundingRect);
  3445                     repeatItem->setGeometry(opt->boundingRect);
  3413                     repeatItem->update();
  3446                     repeatItem->update();
  3414                 }
  3447                 }
  3415                 break;
  3448                 break;
  3441                 }*/
  3474                 }*/
  3442                 break;
  3475                 break;
  3443             case P_ItemViewItem_background:
  3476             case P_ItemViewItem_background:
  3444                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
  3477                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
  3445                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  3478                     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
  3446                     iconItem->setZValue(-3.0);
       
  3447                     iconItem->setGeometry(opt->boundingRect);
  3479                     iconItem->setGeometry(opt->boundingRect);
  3448                     if (opt->background.canConvert<HbIcon>()){
  3480                     if (opt->background.canConvert<HbIcon>()){
  3449                         iconItem->setIcon(opt->background.value<HbIcon>());
  3481                         iconItem->setIcon(opt->background.value<HbIcon>());
  3450                     } else if (opt->background.canConvert<QBrush>()){
  3482                     } else if (opt->background.canConvert<QBrush>()){
  3451                         iconItem->setBrush(opt->background.value<QBrush>());
  3483                         iconItem->setBrush(opt->background.value<QBrush>());
  3452                     }
  3484                     }
  3453                 }
  3485                 }
  3454 
  3486 
  3455                 break;
  3487                 break;
  3456             case P_ItemViewItem_frame: 
  3488             case P_ItemViewItem_frame:
  3457                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
  3489                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
  3458                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
  3490                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
  3459                     frameItem->setZValue(-4.0);
       
  3460                     frameItem->setGeometry(opt->boundingRect);
  3491                     frameItem->setGeometry(opt->boundingRect);
  3461 
  3492 
  3462                     if (opt->background.canConvert<HbFrameBackground>()) {
  3493                     if (opt->background.canConvert<HbFrameBackground>()) {
  3463                         HbFrameBackground frame = opt->background.value<HbFrameBackground>();
  3494                         HbFrameBackground frame = opt->background.value<HbFrameBackground>();
  3464                         frameItem->frameDrawer().setFrameType(frame.frameType());
  3495                         frameItem->frameDrawer().setFrameType(frame.frameType());
  3465                         frameItem->frameDrawer().setFrameGraphicsName(frame.frameGraphicsName());
  3496                         frameItem->frameDrawer().setFrameGraphicsName(frame.frameGraphicsName());
  3466                     } else if (opt->viewItemType == Hb::ItemType_TreeViewItem) {
  3497                     } else if (opt->viewItemType == Hb::ItemType_TreeViewItem) {
  3467                         if (opt->modelItemType == Hb::ParentItem) {
  3498                         if (opt->modelItemType == Hb::ParentItem) {
  3468                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3499                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3469                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? 
  3500                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ?
  3470                                 QLatin1String("qtg_fr_popup_list_parent_normal") : QLatin1String("qtg_fr_list_parent_normal"));
  3501                                 QLatin1String("qtg_fr_popup_list_parent_normal") : QLatin1String("qtg_fr_list_parent_normal"));
  3471                         } else if (opt->modelItemType == Hb::SeparatorItem) {
  3502                         } else if (opt->modelItemType == Hb::SeparatorItem) {
  3472                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3503                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3473                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_separator"));
  3504                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_separator"));
  3474                         } else {
  3505                         } else {
  3475                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3506                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3476                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? 
  3507                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ?
  3477                                 QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal"));
  3508                                 QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal"));
  3478                         }
  3509                         }
  3479                     } else if ( opt->viewItemType == Hb::ItemType_ListViewItem
  3510                     } else if ( opt->viewItemType == Hb::ItemType_ListViewItem
  3480                                 || opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) {
  3511                                 || opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) {
  3481                         if (opt->modelItemType == Hb::SeparatorItem) {
  3512                         if (opt->modelItemType == Hb::SeparatorItem) {
  3482                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3513                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3483                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_separator"));
  3514                             frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_separator"));
  3484                         } else {
  3515                         } else {
  3485                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3516                             frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3486                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? 
  3517                             frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ?
  3487                                 QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal"));
  3518                                 QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal"));
  3488                         }
  3519                         }
  3489                     } else if (opt->viewItemType == Hb::ItemType_GridViewItem
  3520                     } else if (opt->viewItemType == Hb::ItemType_GridViewItem
  3490                                 || opt->viewItemType == HbPrivate::ItemType_ColorGridViewItem) {
  3521                                 || opt->viewItemType == HbPrivate::ItemType_ColorGridViewItem) {
  3491                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3522                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3492                         frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? 
  3523                         frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ?
  3493                             QLatin1String("qtg_fr_popup_grid_normal") : QLatin1String("qtg_fr_grid_normal"));
  3524                             QLatin1String("qtg_fr_popup_grid_normal") : QLatin1String("qtg_fr_grid_normal"));
  3494                     }
  3525                     }
  3495                     else{
  3526                     else{
  3496                         frameItem->frameDrawer().setFrameGraphicsName(QString());
  3527                         frameItem->frameDrawer().setFrameGraphicsName(QString());
  3497                     }
  3528                     }
  3498                 }
  3529                 }
  3499                 break;
  3530                 break;
  3500             case P_ItemViewItem_focus:
  3531             case P_ItemViewItem_focus:
  3501                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
  3532                 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) {
  3502                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
  3533                     HbFrameItem *frameItem = static_cast<HbFrameItem*>(item);
  3503                     frameItem->setZValue(-1.0);
       
  3504                     frameItem->setGeometry(opt->boundingRect);
  3534                     frameItem->setGeometry(opt->boundingRect);
  3505 
  3535 
  3506                     if (opt->viewItemType == Hb::ItemType_TreeViewItem
  3536                     if (opt->viewItemType == Hb::ItemType_TreeViewItem
  3507                         || opt->viewItemType == Hb::ItemType_ListViewItem
  3537                         || opt->viewItemType == Hb::ItemType_ListViewItem
  3508                         || opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) {
  3538                         || opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) {
  3568                 break;
  3598                 break;
  3569 
  3599 
  3570             case P_TumbleView_background:
  3600             case P_TumbleView_background:
  3571                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
  3601                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
  3572                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
  3602                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
  3573                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_bg");
  3603 
       
  3604                         //Temporary source to avoid introducing new style primitive for selection dialog mark widget background item.
       
  3605                         QGraphicsItem *parent = frameItem->parentItem();
       
  3606                         const QMetaObject *obj = parent->toGraphicsObject()->metaObject();
       
  3607 
       
  3608                         QString className;
       
  3609                         if(obj){
       
  3610                             className = obj->className();
       
  3611                         }
       
  3612                         ///////////////////////////////////////////////////////////
       
  3613                         
       
  3614                         if( !className.compare("HbTumbleView") ){
       
  3615                             frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_bg");
       
  3616                         }
       
  3617                         else if( !className.compare("HbSelectionDialogMarkWidget") )
       
  3618                         {
       
  3619                             frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_groupbox");
       
  3620                         }
  3574                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3621                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3575                         frameItem->setZValue(-5);
  3622                         frameItem->setZValue(-5);
  3576                         //TODO:temp fix, issue with css rule picking in derived class
  3623                         //TODO:temp fix, issue with css rule picking in derived class
  3577                         //frameItem->setGeometry(opt->boundingRect);
  3624                         //frameItem->setGeometry(opt->boundingRect);
  3578                         Q_UNUSED(opt);
  3625                         Q_UNUSED(opt);
  3579                     }
  3626                     }
  3580                 }
  3627                 }
  3581                 break;
  3628                 break;
  3582             case P_TumbleView_frame: 
  3629             case P_TumbleView_frame:
  3583                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
  3630                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
  3584                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
  3631                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
  3585                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_overlay");
  3632                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_overlay");
  3586                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3633                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3587                         frameItem->setZValue(-4);
  3634                         frameItem->setZValue(-4);
  3597                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
  3644                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
  3598                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_highlight_pri");
  3645                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_highlight_pri");
  3599                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3646                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
  3600                         frameItem->setZValue(3);
  3647                         frameItem->setZValue(3);
  3601                         //TODO:temp fix, issue with css rule picking in derived class
  3648                         //TODO:temp fix, issue with css rule picking in derived class
  3602                         
  3649 
  3603                         //frameItem->setGeometry(0,(opt->boundingRect.height()-frameItem->boundingRect().height())/2,opt->boundingRect.width(),opt->boundingRect.height());
  3650                         //frameItem->setGeometry(0,(opt->boundingRect.height()-frameItem->boundingRect().height())/2,opt->boundingRect.width(),opt->boundingRect.height());
  3604                         Q_UNUSED(opt);
  3651                         Q_UNUSED(opt);
  3605                     }
  3652                     }
  3606                     
  3653 
  3607                 }
  3654                 }
  3608                 break;
  3655                 break;
  3609 
  3656 
  3610             case P_IndexFeedback_popup_text:
  3657             case P_IndexFeedback_popup_text:
  3611                 if (const HbStyleOptionIndexFeedback *opt = qstyleoption_cast<const HbStyleOptionIndexFeedback *>(option)) {
  3658                 if (const HbStyleOptionIndexFeedback *opt = qstyleoption_cast<const HbStyleOptionIndexFeedback *>(option)) {
  3632                         //frameItem->setGeometry(opt->boundingRect);
  3679                         //frameItem->setGeometry(opt->boundingRect);
  3633                         Q_UNUSED(opt);
  3680                         Q_UNUSED(opt);
  3634                     }
  3681                     }
  3635                 }
  3682                 }
  3636                 break;
  3683                 break;
  3637             case P_DateTimePicker_frame: 
  3684             case P_DateTimePicker_frame:
  3638                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
  3685                 if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) {
  3639                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
  3686                     if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) {
  3640                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_overlay");
  3687                         frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_overlay");
  3641                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3688                         frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
  3642                         frameItem->setZValue(1);
  3689                         frameItem->setZValue(1);
  3659                     }
  3706                     }
  3660 
  3707 
  3661                 }
  3708                 }
  3662                 break;
  3709                 break;
  3663             case P_InputDialog_text:
  3710             case P_InputDialog_text:
  3664                 if (const HbStyleOptionInputDialog *opt = 
  3711                 if (const HbStyleOptionInputDialog *opt =
  3665                     qstyleoption_cast<const HbStyleOptionInputDialog*>(option)) {
  3712                     qstyleoption_cast<const HbStyleOptionInputDialog*>(option)) {
  3666                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3713                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3667                     if(!item) {
  3714                     if(!item) {
  3668                         return;
  3715                         return;
  3669                     }
  3716                     }
  3670                     textItem->setTextWrapping(Hb::TextWrapAnywhere);
  3717                     textItem->setTextWrapping(Hb::TextWrapAnywhere);
  3671                     textItem->setText(opt->text);                           
  3718                     textItem->setText(opt->text);
  3672                 }
  3719                 }
  3673                 break;
  3720                 break;
  3674              case P_InputDialog_additionaltext:
  3721              case P_InputDialog_additionaltext:
  3675                 if (const HbStyleOptionInputDialog *opt = 
  3722                 if (const HbStyleOptionInputDialog *opt =
  3676                     qstyleoption_cast<const HbStyleOptionInputDialog*>(option)) {
  3723                     qstyleoption_cast<const HbStyleOptionInputDialog*>(option)) {
  3677                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3724                     HbTextItem *textItem = static_cast<HbTextItem*>(item);
  3678                     if(!item) {
  3725                     if(!item) {
  3679                         return;
  3726                         return;
  3680                     }
  3727                     }
  3681                     textItem->setTextWrapping(Hb::TextWrapAnywhere);
  3728                     textItem->setTextWrapping(Hb::TextWrapAnywhere);
  3682                     textItem->setText(opt->additionalText);                         
  3729                     textItem->setText(opt->additionalText);
  3683                 } 
  3730                 }
  3684                 break;
  3731                 break;
       
  3732 
  3685              default:
  3733              default:
  3686                 return;
  3734                 return;
  3687     };
  3735     };
  3688 }
  3736 }
  3689 
  3737 
  3740   used by the polish() method
  3788   used by the polish() method
  3741   \internal
  3789   \internal
  3742 */
  3790 */
  3743 void HbStylePrivate::polishItem(
  3791 void HbStylePrivate::polishItem(
  3744     const HbVector<HbCss::StyleRule> &styleRules,
  3792     const HbVector<HbCss::StyleRule> &styleRules,
  3745     HbWidget* widget,
  3793     HbWidget *widget,
  3746     QGraphicsItem *item,
  3794     QGraphicsItem *item,
  3747     const QString &name,
  3795     const QString &name,
       
  3796     HbDeviceProfile &profile,
  3748     bool layoutDefined) const
  3797     bool layoutDefined) const
  3749 {
  3798 {
  3750     if (name.isEmpty() && widget != item) {
  3799     if (name.isEmpty() && widget != item) {
  3751         return;
  3800         return;
  3752     }
  3801     }
  3760     } else {
  3809     } else {
  3761         qDebug() << "HbStyle::polishItem : -- item name: " << name << "(missing item)";
  3810         qDebug() << "HbStyle::polishItem : -- item name: " << name << "(missing item)";
  3762     }
  3811     }
  3763 #endif
  3812 #endif
  3764 
  3813 
  3765     HbDeviceProfile profile(HbDeviceProfile::profile(widget));
       
  3766 
       
  3767     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, widget, profile);
  3814     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, widget, profile);
  3768 #ifdef HBSTYLE_DEBUG
  3815 #ifdef HBSTYLE_DEBUG
  3769     qDebug() << "HbStyle::polishItem : -- Number of maching CSS declarations: " << decl.count();
  3816     qDebug() << "HbStyle::polishItem : -- Number of matching CSS declarations: " << decl.count();
  3770 #endif
  3817 #endif
  3771     HbCss::ValueExtractor extractor(decl, layoutParameters, profile);
  3818     HbCss::ValueExtractor extractor(decl, layoutParameters, profile);
  3772     HbCss::GeometryValues geomValues;
  3819     HbCss::KnownProperties prop;
  3773     HbCss::PositionValues posValues;
  3820 
  3774 
  3821     if ( !extractor.extractKnownProperties(prop) ) {
  3775     bool extracted = extractor.extractGeometry(geomValues);
  3822 #ifdef HBSTYLE_DEBUG
  3776 #ifndef HBSTYLE_DEBUG
  3823         qDebug() << "HbStyle::polishItem : -- No polish overrides found";
  3777     Q_UNUSED(extracted);
  3824 #endif
  3778 #endif
  3825         return;
  3779 #ifdef HBSTYLE_DEBUG
  3826     }
  3780     if ( !extracted ) {
       
  3781         qDebug() << "HbStyle::polishItem : -- No geometry overrides found";
       
  3782     }
       
  3783 #endif
       
  3784     extracted = extractor.extractPosition(posValues);
       
  3785 #ifdef HBSTYLE_DEBUG
       
  3786     if ( !extracted ) {
       
  3787         qDebug() << "HbStyle::polishItem : -- No position overrides found";
       
  3788     }
       
  3789 #endif
       
  3790 
  3827 
  3791     if ( item ) {
  3828     if ( item ) {
  3792         if (posValues.mFlags & HbCss::ExtractedZValue) {
  3829         if (prop.mFlags & HbCss::ExtractedZValue) {
  3793 #ifdef HBSTYLE_DEBUG
  3830 #ifdef HBSTYLE_DEBUG
  3794             qDebug() << "HbStyle::polishItem : -- Setting zvalue: " << posValues.mZ;
  3831             qDebug() << "HbStyle::polishItem : -- Setting zvalue: " << prop.mZ;
  3795 #endif
  3832 #endif
  3796             item->setZValue(posValues.mZ);
  3833             item->setZValue(prop.mZ);
  3797         }
  3834         }
  3798     }
  3835     }
  3799 
  3836 
  3800     QGraphicsWidget *gWidget = (item && item->isWidget())
  3837     QGraphicsWidget *gWidget = (item && item->isWidget())
  3801         ? static_cast<QGraphicsWidget*>(item)
  3838         ? static_cast<QGraphicsWidget*>(item)
  3802         : 0;
  3839         : 0;
  3803     if ( gWidget ) {
  3840     if ( gWidget ) {
  3804         if (posValues.mFlags & HbCss::ExtractedLayoutDirection) {
  3841         if (prop.mFlags & HbCss::ExtractedLayoutDir) {
  3805 #ifdef HBSTYLE_DEBUG
  3842 #ifdef HBSTYLE_DEBUG
  3806             qDebug() << "HbStyle::polishItem : -- Setting layout direction: " << posValues.mLayoutDirection;
  3843             qDebug() << "HbStyle::polishItem : -- Setting layout direction: " << prop.mLayoutDir;
  3807 #endif
  3844 #endif
  3808             if (posValues.mLayoutDirection == HbCss::LayoutDirection_LeftToRight) {
  3845             if (prop.mLayoutDir == HbCss::LayoutDirection_LeftToRight) {
  3809                 gWidget->setLayoutDirection(Qt::LeftToRight);
  3846                 gWidget->setLayoutDirection(Qt::LeftToRight);
  3810             } else if (posValues.mLayoutDirection == HbCss::LayoutDirection_RightToLeft) {
  3847             } else if (prop.mLayoutDir == HbCss::LayoutDirection_RightToLeft) {
  3811                 gWidget->setLayoutDirection(Qt::RightToLeft);
  3848                 gWidget->setLayoutDirection(Qt::RightToLeft);
  3812             } else {
  3849             } else {
  3813                 gWidget->unsetLayoutDirection();
  3850                 gWidget->unsetLayoutDirection();
  3814             }
  3851             }
  3815         }
  3852         }
  3816     }
  3853     }
  3817 
  3854 
  3818     HbWidgetBase *hbWidget = qobject_cast<HbWidgetBase*>(gWidget);
  3855     HbWidgetBase *hbWidget = qobject_cast<HbWidgetBase*>(gWidget);
  3819     if ( hbWidget ) {
  3856     if ( hbWidget ) {
  3820         HbWidgetBasePrivate* hbWidget_p = HbWidgetBasePrivate::d_ptr(hbWidget);
  3857         HbWidgetBasePrivate* hbWidget_p = HbWidgetBasePrivate::d_ptr(hbWidget);
  3821         QFont font;
  3858         if ( prop.mFlags & HbCss::ExtractedFontSpec ) {
  3822         HbFontSpec fontSpec;
  3859             if ( !(prop.mFlags & HbCss::ExtractedFont) ) {
  3823         int dummy;
  3860 #ifdef HBSTYLE_DEBUG
  3824         if (extractor.extractFont(&font, &fontSpec, &dummy)) {
  3861                 qDebug() << "HbStyle::polishItem : -- Setting fontspec: " << prop.mFontSpec.role() << prop.mFontSpec.textHeight();
  3825             if ( !fontSpec.isNull() ) {
  3862 #endif
  3826                 if ( font == QFont() ) {
  3863                 hbWidget->setFontSpec(prop.mFontSpec);
  3827 #ifdef HBSTYLE_DEBUG
       
  3828                     qDebug() << "HbStyle::polishItem : -- Setting fontspec: " << fontSpec.role();
       
  3829 #endif
       
  3830                     hbWidget->setFontSpec(fontSpec);
       
  3831                 } else {
       
  3832 #ifdef HBSTYLE_DEBUG
       
  3833                     qDebug() << "HbStyle::polishItem : -- Setting fontspec with overrides: "
       
  3834                              << fontSpec.role() << font;
       
  3835 #endif
       
  3836                     hbWidget->setFont(fontSpec.font().resolve(font));
       
  3837                 }
       
  3838             } else {
  3864             } else {
  3839 #ifdef HBSTYLE_DEBUG
  3865 #ifdef HBSTYLE_DEBUG
  3840                 qDebug() << "HbStyle::polishItem : -- Setting explicit font: " << font;
  3866                 qDebug() << "HbStyle::polishItem : -- Setting fontspec with overrides: "
  3841 #endif
  3867                          << prop.mFontSpec.role() << prop.mFontSpec.textHeight() << prop.mFont;
  3842                 hbWidget->setFont(font);
  3868 #endif
  3843             }
  3869                 hbWidget->setFont(prop.mFontSpec.font().resolve(prop.mFont));
       
  3870             }
       
  3871         } else if ( prop.mFlags & HbCss::ExtractedFont ) {
       
  3872 #ifdef HBSTYLE_DEBUG
       
  3873             qDebug() << "HbStyle::polishItem : -- Setting explicit font: " << prop.mFont;
       
  3874 #endif
       
  3875             hbWidget->setFont(prop.mFont);
  3844         }
  3876         }
  3845 
  3877 
  3846         HbIconItem* icon = qobject_cast<HbIconItem*>(hbWidget);
  3878         HbIconItem* icon = qobject_cast<HbIconItem*>(hbWidget);
  3847         if (icon) {
  3879         if (icon) {
  3848             Qt::AspectRatioMode mode;
  3880             if (prop.mFlags & HbCss::ExtractedAspectRatioMode
  3849             if (extractor.extractAspectRatioMode(&mode) 
       
  3850                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode)) {
  3881                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode)) {
  3851 #ifdef HBSTYLE_DEBUG
  3882 #ifdef HBSTYLE_DEBUG
  3852                 qDebug() << "HbStyle::polishItem : -- Setting aspect ratio mode: " << mode;
  3883                 qDebug() << "HbStyle::polishItem : -- Setting aspect ratio mode: " << prop.mAspectRatioMode;
  3853 #endif
  3884 #endif
  3854                 icon->setAspectRatioMode(mode);
  3885                 icon->setAspectRatioMode(prop.mAspectRatioMode);
  3855                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode, false);
  3886                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode, false);
  3856             }
  3887             }
  3857             if(!hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconBrush)){
  3888             if ( prop.mFlags & HbCss::ExtractedAlignment
  3858                 QBrush brush;
  3889                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconAlign)) {
  3859                 QString uri;
  3890 #ifdef HBSTYLE_DEBUG
  3860                 HbCss::Repeat repeat = HbCss::Repeat_XY;
  3891                 qDebug() << "HbStyle::polishItem : -- Setting icon alignment: " << prop.mAlignment;
  3861                 Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft;
  3892 #endif
  3862                 HbCss::Attachment attachment = HbCss::Attachment_Scroll;
  3893                 icon->setAlignment( prop.mAlignment );
  3863                 HbCss::Origin origin = HbCss::Origin_Padding;
  3894                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconAlign, false);
  3864                 HbCss::Origin clip = HbCss::Origin_Border;
       
  3865                 if (extractor.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) {
       
  3866 #ifdef HBSTYLE_DEBUG
       
  3867                     qDebug() << "HbStyle::polishItem : -- Setting icon background: " << brush;
       
  3868 #endif
       
  3869                     icon->setBrush( brush );
       
  3870                 } else {
       
  3871 #ifdef HBSTYLE_DEBUG
       
  3872                     qDebug() << "HbStyle::polishItem : -- Resetting icon background";
       
  3873 #endif
       
  3874                     icon->setBrush( QBrush() );
       
  3875                 }
       
  3876                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconBrush, false);
       
  3877             }
  3895             }
  3878         }
  3896         }
  3879 
  3897 
  3880         HbTextItem* text = qobject_cast<HbTextItem*>(hbWidget);
  3898         HbTextItem* text = qobject_cast<HbTextItem*>(hbWidget);
  3881         if (text) {
  3899         if (text) {
  3882             HbCss::TextValues textValues;
  3900             if ( prop.mFlags & HbCss::ExtractedMinLines
  3883             if ( extractor.extractTextValues( textValues ) ) {
  3901                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
  3884                 if ( textValues.mFlags & HbCss::ExtractedLineCountMin
  3902 #ifdef HBSTYLE_DEBUG
  3885                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
  3903                 qDebug() << "HbStyle::polishItem : -- Setting text min lines: " << prop.mMinLines;
  3886 #ifdef HBSTYLE_DEBUG
  3904 #endif
  3887                     qDebug() << "HbStyle::polishItem : -- Setting text min lines: " << textValues.mLineCountMin;
  3905                 text->setMinimumLines( prop.mMinLines );
  3888 #endif
  3906                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
  3889                     text->setMinimumLines( textValues.mLineCountMin );
  3907             }
  3890                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
  3908             if ( prop.mFlags & HbCss::ExtractedMaxLines
  3891                 }
  3909                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax)) {
  3892                 if ( textValues.mFlags & HbCss::ExtractedLineCountMax
  3910 #ifdef HBSTYLE_DEBUG
  3893                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax)) {
  3911                 qDebug() << "HbStyle::polishItem : -- Setting text max lines: " << prop.mMaxLines;
  3894 #ifdef HBSTYLE_DEBUG
  3912 #endif
  3895                     qDebug() << "HbStyle::polishItem : -- Setting text max lines: " << textValues.mLineCountMax;
  3913                 text->setMaximumLines( prop.mMaxLines );
  3896 #endif
  3914                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
  3897                     text->setMaximumLines( textValues.mLineCountMax );
  3915             }
  3898                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
  3916             if ( prop.mFlags & HbCss::ExtractedAlignment
  3899                 }
       
  3900             }
       
  3901             if ( posValues.mFlags & HbCss::ExtractedTextAlign 
       
  3902                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
  3917                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
  3903 #ifdef HBSTYLE_DEBUG
  3918 #ifdef HBSTYLE_DEBUG
  3904                 qDebug() << "HbStyle::polishItem : -- Setting text alignment: " << posValues.mTextAlignment;
  3919                 qDebug() << "HbStyle::polishItem : -- Setting text alignment: " << prop.mAlignment;
  3905 #endif
  3920 #endif
  3906                 text->setAlignment( posValues.mTextAlignment );
  3921                 text->setAlignment( prop.mAlignment );
  3907                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
  3922                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
  3908             }
  3923             }
  3909             if ( posValues.mFlags & HbCss::ExtractedWrapMode 
  3924             if ( prop.mFlags & HbCss::ExtractedWrapMode
  3910                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
  3925                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
  3911 #ifdef HBSTYLE_DEBUG
  3926 #ifdef HBSTYLE_DEBUG
  3912                 qDebug() << "HbStyle::polishItem : -- Setting wrap mode : " << posValues.mTextWrapMode;
  3927                 qDebug() << "HbStyle::polishItem : -- Setting wrap mode : " << prop.mTextWrapMode;
  3913 #endif
  3928 #endif
  3914                 text->setTextWrapping( posValues.mTextWrapMode );
  3929                 text->setTextWrapping( prop.mTextWrapMode );
  3915                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
  3930                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
  3916             }
  3931             }
  3917         }
  3932         }
  3918 
  3933 
  3919         HbRichTextItem* richtext = qobject_cast<HbRichTextItem*>(hbWidget);
  3934         HbRichTextItem* richtext = qobject_cast<HbRichTextItem*>(hbWidget);
  3920         if (richtext) {
  3935         if (richtext) {
  3921             if ( posValues.mFlags & HbCss::ExtractedTextAlign
  3936             if ( prop.mFlags & HbCss::ExtractedAlignment
  3922                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
  3937                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
  3923 #ifdef HBSTYLE_DEBUG
  3938 #ifdef HBSTYLE_DEBUG
  3924                 qDebug() << "HbStyle::polishItem : -- Setting text alignment: " << posValues.mTextAlignment;
  3939                 qDebug() << "HbStyle::polishItem : -- Setting text alignment: " << prop.mAlignment;
  3925 #endif
  3940 #endif
  3926                 richtext->setAlignment( posValues.mTextAlignment );
  3941                 richtext->setAlignment( prop.mAlignment );
  3927                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
  3942                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
  3928             }
  3943             }
  3929             if ( posValues.mFlags & HbCss::ExtractedWrapMode 
  3944             if ( prop.mFlags & HbCss::ExtractedWrapMode
  3930                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
  3945                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
  3931 #ifdef HBSTYLE_DEBUG
  3946 #ifdef HBSTYLE_DEBUG
  3932                 qDebug() << "HbStyle::polishItem : -- Setting wrap mode : " << posValues.mTextWrapMode;
  3947                 qDebug() << "HbStyle::polishItem : -- Setting wrap mode : " << prop.mTextWrapMode;
  3933 #endif
  3948 #endif
  3934                 richtext->setTextWrapping( posValues.mTextWrapMode );
  3949                 richtext->setTextWrapping( prop.mTextWrapMode );
  3935                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
  3950                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
  3936             }
  3951             }
  3937         }
  3952         }
  3938 
  3953 
  3939         HbFrameItem *frame = qobject_cast<HbFrameItem*>(hbWidget);
  3954         HbFrameItem *frame = qobject_cast<HbFrameItem*>(hbWidget);
  3940         if (frame && !frame->frameDrawer().d->testBorderApiProtectionFlag()) {
  3955         if (frame && !frame->frameDrawer().d->testBorderApiProtectionFlag()) {
  3941             qreal borderWidths[HbCss::NumEdges] = { 0.0,0.0,0.0,0.0 };
  3956             if (prop.mFlags & HbCss::ExtractedBorderWidths) {
  3942             QBrush borderColors[HbCss::NumEdges];
       
  3943             HbCss::BorderStyle borderStyles[HbCss::NumEdges];
       
  3944             QSize borderRadii[4];
       
  3945 
       
  3946             if (extractor.extractBorder(borderWidths,borderColors,borderStyles,borderRadii)) {
       
  3947 #ifdef HBSTYLE_DEBUG
  3957 #ifdef HBSTYLE_DEBUG
  3948                 qDebug() << "HbStyle::polishItem : -- Setting border widths (l,t,r,b):"
  3958                 qDebug() << "HbStyle::polishItem : -- Setting border widths (l,t,r,b):"
  3949                     << borderWidths[HbCss::LeftEdge]
  3959                     << prop.mBorderWidths[HbCss::LeftEdge]
  3950                     << borderWidths[HbCss::TopEdge]
  3960                     << prop.mBorderWidths[HbCss::TopEdge]
  3951                     << borderWidths[HbCss::RightEdge]
  3961                     << prop.mBorderWidths[HbCss::RightEdge]
  3952                     << borderWidths[HbCss::BottomEdge];
  3962                     << prop.mBorderWidths[HbCss::BottomEdge];
  3953 #endif
  3963 #endif
  3954                 frame->frameDrawer().setBorderWidths(
  3964                 frame->frameDrawer().setBorderWidths(
  3955                     borderWidths[HbCss::LeftEdge],
  3965                     prop.mBorderWidths[HbCss::LeftEdge],
  3956                     borderWidths[HbCss::TopEdge],
  3966                     prop.mBorderWidths[HbCss::TopEdge],
  3957                     borderWidths[HbCss::RightEdge],
  3967                     prop.mBorderWidths[HbCss::RightEdge],
  3958                     borderWidths[HbCss::BottomEdge]);
  3968                     prop.mBorderWidths[HbCss::BottomEdge]);
  3959                 frame->frameDrawer().d->setBorderApiProtectionFlag(false);
  3969                 frame->frameDrawer().d->setBorderApiProtectionFlag(false);
  3960             }
  3970             }
  3961         }
  3971         }
  3962         if ( hbWidget->inherits( "HbLineEdit" ) ) {
  3972         if ( hbWidget->inherits( "HbLineEdit" ) ) {
  3963             HbCss::TextValues textValues;
  3973             if ( prop.mFlags & HbCss::ExtractedMinLines
  3964             if ( extractor.extractTextValues( textValues ) ) {
  3974                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
  3965                 if ( textValues.mFlags & HbCss::ExtractedLineCountMin
  3975 #ifdef HBSTYLE_DEBUG
  3966                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
  3976                 qDebug() << "HbStyle::polishItem : -- Setting text min lines: " << prop.mMinLines;
  3967 #ifdef HBSTYLE_DEBUG
  3977 #endif
  3968                     qDebug() << "HbStyle::polishItem : -- Setting text min lines: " << textValues.mLineCountMin;
  3978                 hbWidget->setProperty( "minRows", prop.mMinLines );
  3969 #endif
  3979                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
  3970                     hbWidget->setProperty( "minRows", textValues.mLineCountMin );
  3980             }
  3971                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
  3981             if ( prop.mFlags & HbCss::ExtractedMaxLines
  3972                 }
  3982                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
  3973                 if ( textValues.mFlags & HbCss::ExtractedLineCountMax
  3983 #ifdef HBSTYLE_DEBUG
  3974                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
  3984                 qDebug() << "HbStyle::polishItem : -- Setting text max lines: " << prop.mMaxLines;
  3975 #ifdef HBSTYLE_DEBUG
  3985 #endif
  3976                     qDebug() << "HbStyle::polishItem : -- Setting text max lines: " << textValues.mLineCountMax;
  3986                 hbWidget->setProperty( "maxRows", prop.mMaxLines );
  3977 #endif
  3987                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
  3978                     hbWidget->setProperty( "maxRows", textValues.mLineCountMax );
       
  3979                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
       
  3980                 }
       
  3981             }
  3988             }
  3982         }
  3989         }
  3983     }
  3990     }
  3984 
  3991 
  3985     QGraphicsLayoutItem* lItem = (item && item->isWidget()) ? (QGraphicsLayoutItem*)static_cast<QGraphicsWidget*>(item) : 0;
  3992     QGraphicsLayoutItem* lItem = (item && item->isWidget())
  3986     if ( !lItem ) {
  3993         ? (QGraphicsLayoutItem*)static_cast<QGraphicsWidget*>(item)
  3987         lItem = widget->layoutPrimitive(name);
  3994         : 0;
  3988         if ( lItem && !lItem->graphicsItem() ) {
  3995     if ( lItem ) {
  3989             // assume it is spacer
  3996         if ( prop.mFlags & HbCss::ExtractedMinW ) {
  3990             static_cast<HbMeshLayout*>(widget->layout())->setItemId( lItem, name );
  3997 #ifdef HBSTYLE_DEBUG
       
  3998             qDebug() << "HbStyle::polishItem : -- Setting minimum width: " << prop.mMinW;
       
  3999 #endif
       
  4000             lItem->setMinimumWidth( prop.mMinW );
  3991         }
  4001         }
  3992     }
  4002         if ( prop.mFlags & HbCss::ExtractedMinH ) {
  3993     if ( lItem ) {
  4003 #ifdef HBSTYLE_DEBUG
  3994         if ( geomValues.mFlags & HbCss::ExtractedMinW ) {
  4004             qDebug() << "HbStyle::polishItem : -- Setting minimum height: " << prop.mMinH;
  3995 #ifdef HBSTYLE_DEBUG
  4005 #endif
  3996             qDebug() << "HbStyle::polishItem : -- Setting minimum width: " << geomValues.mMinW;
  4006             lItem->setMinimumHeight( prop.mMinH );
  3997 #endif
       
  3998             lItem->setMinimumWidth( geomValues.mMinW );
       
  3999         }
  4007         }
  4000         if ( geomValues.mFlags & HbCss::ExtractedMinH ) {
  4008         if ( prop.mFlags & HbCss::ExtractedPrefW ) {
  4001 #ifdef HBSTYLE_DEBUG
  4009 #ifdef HBSTYLE_DEBUG
  4002             qDebug() << "HbStyle::polishItem : -- Setting minimum height: " << geomValues.mMinH;
  4010             qDebug() << "HbStyle::polishItem : -- Setting preferred width: " << prop.mPrefW;
  4003 #endif
  4011 #endif
  4004             lItem->setMinimumHeight( geomValues.mMinH );
  4012             lItem->setPreferredWidth( prop.mPrefW );
  4005         }
  4013         }
  4006         if ( geomValues.mFlags & HbCss::ExtractedPrefW ) {
  4014         if ( prop.mFlags & HbCss::ExtractedPrefH ) {
  4007 #ifdef HBSTYLE_DEBUG
  4015 #ifdef HBSTYLE_DEBUG
  4008             qDebug() << "HbStyle::polishItem : -- Setting preferred width: " << geomValues.mPrefW;
  4016             qDebug() << "HbStyle::polishItem : -- Setting preferred height: " << prop.mPrefH;
  4009 #endif
  4017 #endif
  4010             lItem->setPreferredWidth( geomValues.mPrefW );
  4018             lItem->setPreferredHeight( prop.mPrefH );
  4011         }
  4019         }
  4012         if ( geomValues.mFlags & HbCss::ExtractedPrefH ) {
  4020         if ( prop.mFlags & HbCss::ExtractedMaxW ) {
  4013 #ifdef HBSTYLE_DEBUG
  4021 #ifdef HBSTYLE_DEBUG
  4014             qDebug() << "HbStyle::polishItem : -- Setting preferred height: " << geomValues.mPrefH;
  4022             qDebug() << "HbStyle::polishItem : -- Setting maximum width: " << prop.mMaxW;
  4015 #endif
  4023 #endif
  4016             lItem->setPreferredHeight( geomValues.mPrefH );
  4024             lItem->setMaximumWidth( prop.mMaxW );
  4017         }
  4025         }
  4018         if ( geomValues.mFlags & HbCss::ExtractedMaxW ) {
  4026         if ( prop.mFlags & HbCss::ExtractedMaxH ) {
  4019 #ifdef HBSTYLE_DEBUG
  4027 #ifdef HBSTYLE_DEBUG
  4020             qDebug() << "HbStyle::polishItem : -- Setting maximum width: " << geomValues.mMaxW;
  4028             qDebug() << "HbStyle::polishItem : -- Setting maximum height: " << prop.mMaxH;
  4021 #endif
  4029 #endif
  4022             lItem->setMaximumWidth( geomValues.mMaxW );
  4030             lItem->setMaximumHeight( prop.mMaxH );
  4023         }
       
  4024         if ( geomValues.mFlags & HbCss::ExtractedMaxH ) {
       
  4025 #ifdef HBSTYLE_DEBUG
       
  4026             qDebug() << "HbStyle::polishItem : -- Setting maximum height: " << geomValues.mMaxH;
       
  4027 #endif
       
  4028             lItem->setMaximumHeight( geomValues.mMaxH );
       
  4029         }
  4031         }
  4030         QSizePolicy itemPol = lItem->sizePolicy();
  4032         QSizePolicy itemPol = lItem->sizePolicy();
  4031         if ( geomValues.mFlags & HbCss::ExtractedPolHor ) {
  4033         if ( prop.mFlags & HbCss::ExtractedPolHor ) {
  4032 #ifdef HBSTYLE_DEBUG
  4034 #ifdef HBSTYLE_DEBUG
  4033             qDebug() << "HbStyle::polishItem : -- Setting horizontal size policy: " << geomValues.mSizePolicy.horizontalPolicy();
  4035             qDebug() << "HbStyle::polishItem : -- Setting horizontal size policy: " << prop.mSizePolicy.horizontalPolicy();
  4034 #endif
  4036 #endif
  4035             itemPol.setHorizontalPolicy(geomValues.mSizePolicy.horizontalPolicy());
  4037             itemPol.setHorizontalPolicy(prop.mSizePolicy.horizontalPolicy());
  4036         }
  4038         }
  4037         if ( geomValues.mFlags & HbCss::ExtractedPolVer ) {
  4039         if ( prop.mFlags & HbCss::ExtractedPolVer ) {
  4038 #ifdef HBSTYLE_DEBUG
  4040 #ifdef HBSTYLE_DEBUG
  4039             qDebug() << "HbStyle::polishItem : -- Setting vertical size policy: " << geomValues.mSizePolicy.verticalPolicy();
  4041             qDebug() << "HbStyle::polishItem : -- Setting vertical size policy: " << prop.mSizePolicy.verticalPolicy();
  4040 #endif
  4042 #endif
  4041             itemPol.setVerticalPolicy(geomValues.mSizePolicy.verticalPolicy());
  4043             itemPol.setVerticalPolicy(prop.mSizePolicy.verticalPolicy());
  4042         }
  4044         }
  4043         lItem->setSizePolicy(itemPol);
  4045         lItem->setSizePolicy(itemPol);
  4044     }
  4046     }
  4045 
  4047 
  4046     if (layoutDefined) {
  4048     if (layoutDefined) {
  4047         HbMeshLayout *layout = static_cast<HbMeshLayout*>(widget->layout());
  4049         HbAnchorLayout *layout = static_cast<HbAnchorLayout*>(widget->layout());
  4048         if ( layout ) {
  4050         if ( layout ) {
  4049             if (posValues.mFlags & HbCss::ExtractedLeft) {
  4051             if (prop.mFlags & HbCss::ExtractedLeft) {
  4050 #ifdef HBSTYLE_DEBUG
  4052 #ifdef HBSTYLE_DEBUG
  4051                 qDebug() << "HbStyle::polishItem : -- Setting left override: " << posValues.mLeft;
  4053                 qDebug() << "HbStyle::polishItem : -- Setting left override: " << prop.mLeft;
  4052 #endif
  4054 #endif
  4053                 layout->overrideSpacing(name, Hb::LeftEdge, posValues.mLeft);
  4055                 overrideSpacing(layout, name, Hb::LeftEdge, prop.mLeft);
  4054             }
  4056             }
  4055             if (posValues.mFlags & HbCss::ExtractedRight) {
  4057             if (prop.mFlags & HbCss::ExtractedRight) {
  4056 #ifdef HBSTYLE_DEBUG
  4058 #ifdef HBSTYLE_DEBUG
  4057                 qDebug() << "HbStyle::polishItem : -- Setting right override: " << posValues.mRight;
  4059                 qDebug() << "HbStyle::polishItem : -- Setting right override: " << prop.mRight;
  4058 #endif
  4060 #endif
  4059                 layout->overrideSpacing(name, Hb::RightEdge, posValues.mRight);
  4061                 overrideSpacing(layout, name, Hb::RightEdge, prop.mRight);
  4060             }
  4062             }
  4061             if (posValues.mFlags & HbCss::ExtractedTop) {
  4063             if (prop.mFlags & HbCss::ExtractedTop) {
  4062 #ifdef HBSTYLE_DEBUG
  4064 #ifdef HBSTYLE_DEBUG
  4063                 qDebug() << "HbStyle::polishItem : -- Setting top override: " << posValues.mTop;
  4065                 qDebug() << "HbStyle::polishItem : -- Setting top override: " << prop.mTop;
  4064 #endif
  4066 #endif
  4065                 layout->overrideSpacing(name, Hb::TopEdge, posValues.mTop);
  4067                 overrideSpacing(layout, name, Hb::TopEdge, prop.mTop);
  4066             }
  4068             }
  4067             if (posValues.mFlags & HbCss::ExtractedBottom) {
  4069             if (prop.mFlags & HbCss::ExtractedBottom) {
  4068 #ifdef HBSTYLE_DEBUG
  4070 #ifdef HBSTYLE_DEBUG
  4069                 qDebug() << "HbStyle::polishItem : -- Setting bottom override: " << posValues.mBottom;
  4071                 qDebug() << "HbStyle::polishItem : -- Setting bottom override: " << prop.mBottom;
  4070 #endif
  4072 #endif
  4071                 layout->overrideSpacing(name, Hb::BottomEdge, posValues.mBottom);
  4073                 overrideSpacing(layout, name, Hb::BottomEdge, prop.mBottom);
  4072             }
  4074             }
  4073             if (posValues.mFlags & HbCss::ExtractedCenterH) {
  4075             if (prop.mFlags & HbCss::ExtractedCenterH) {
  4074 #ifdef HBSTYLE_DEBUG
  4076 #ifdef HBSTYLE_DEBUG
  4075                 qDebug() << "HbStyle::polishItem : -- Setting centerh override: " << posValues.mCenterH;
  4077                 qDebug() << "HbStyle::polishItem : -- Setting centerh override: " << prop.mCenterH;
  4076 #endif
  4078 #endif
  4077                 layout->overrideSpacing(name, Hb::CenterHEdge, posValues.mCenterH);
  4079                 overrideSpacing(layout, name, Hb::CenterHEdge, prop.mCenterH);
  4078             }
  4080             }
  4079             if (posValues.mFlags & HbCss::ExtractedCenterV) {
  4081             if (prop.mFlags & HbCss::ExtractedCenterV) {
  4080 #ifdef HBSTYLE_DEBUG
  4082 #ifdef HBSTYLE_DEBUG
  4081                 qDebug() << "HbStyle::polishItem : -- Setting centerv override: " << posValues.mCenterV;
  4083                 qDebug() << "HbStyle::polishItem : -- Setting centerv override: " << prop.mCenterV;
  4082 #endif
  4084 #endif
  4083                 layout->overrideSpacing(name, Hb::CenterVEdge, posValues.mCenterV);
  4085                 overrideSpacing(layout, name, Hb::CenterVEdge, prop.mCenterV);
  4084             }
  4086             }
  4085         }
  4087         }
  4086     }
  4088     }
  4087 }
  4089 }
       
  4090 
       
  4091 void HbStylePrivate::polishAnchor(
       
  4092     const HbVector<HbCss::StyleRule> &styleRules,
       
  4093     HbWidget *widget,
       
  4094     HbAnchor *anchor,
       
  4095     HbDeviceProfile &profile) const
       
  4096 {
       
  4097 #ifdef HBSTYLE_DEBUG
       
  4098     qDebug() << "HbStyle::polish : -- --";
       
  4099     qDebug() << "HbStyle::polishAnchor : -- anchor id: " << anchor->anchorId();
       
  4100 #endif
       
  4101 
       
  4102     const HbVector<HbCss::Declaration> decl = declarations(styleRules, anchor->anchorId(), widget, profile);
       
  4103 #ifdef HBSTYLE_DEBUG
       
  4104     qDebug() << "HbStyle::polishAnchor : -- Number of matching CSS declarations: " << decl.count();
       
  4105 #endif
       
  4106     HbCss::ValueExtractor extractor(decl, layoutParameters, profile);
       
  4107     HbCss::KnownProperties prop;
       
  4108 
       
  4109     if ( !extractor.extractKnownProperties(prop) ) {
       
  4110 #ifdef HBSTYLE_DEBUG
       
  4111         qDebug() << "HbStyle::polishAnchor : -- No polish overrides found";
       
  4112 #endif
       
  4113         return;
       
  4114     }
       
  4115 
       
  4116 
       
  4117     if ( prop.mFlags & HbCss::ExtractedMinH || prop.mFlags & HbCss::ExtractedMinW ) {
       
  4118         qreal minLength = prop.mFlags & HbCss::ExtractedMinH ? prop.mMinH : prop.mMinW;
       
  4119 #ifdef HBSTYLE_DEBUG
       
  4120         qDebug() << "HbStyle::polishAnchor : -- Setting minimum length: " << minLength;
       
  4121 #endif
       
  4122         anchor->setMinimumLength( minLength );
       
  4123     }
       
  4124     if ( prop.mFlags & HbCss::ExtractedPrefH || prop.mFlags & HbCss::ExtractedPrefW ) {
       
  4125         qreal prefLength = prop.mFlags & HbCss::ExtractedPrefH ? prop.mPrefH : prop.mPrefW;
       
  4126 #ifdef HBSTYLE_DEBUG
       
  4127         qDebug() << "HbStyle::polishAnchor : -- Setting preferred length: " << prefLength;
       
  4128 #endif
       
  4129         anchor->setPreferredLength( prefLength );
       
  4130     }
       
  4131     if ( prop.mFlags & HbCss::ExtractedMaxH || prop.mFlags & HbCss::ExtractedMaxW ) {
       
  4132         qreal maxLength = prop.mFlags & HbCss::ExtractedMaxH ? prop.mMaxH : prop.mMaxW;
       
  4133 #ifdef HBSTYLE_DEBUG
       
  4134         qDebug() << "HbStyle::polishAnchor : -- Setting maximum length: " << maxLength;
       
  4135 #endif
       
  4136         anchor->setMaximumLength( maxLength );
       
  4137     }
       
  4138     if ( prop.mFlags & HbCss::ExtractedPolVer || prop.mFlags & HbCss::ExtractedPolHor ) {
       
  4139         QSizePolicy::Policy policy = prop.mFlags & HbCss::ExtractedPolVer
       
  4140             ? prop.mSizePolicy.verticalPolicy() : prop.mSizePolicy.horizontalPolicy();
       
  4141 #ifdef HBSTYLE_DEBUG
       
  4142         qDebug() << "HbStyle::polishAnchor : -- Setting size policy: " << policy;
       
  4143 #endif
       
  4144         anchor->setSizePolicy( policy );
       
  4145     }
       
  4146     if ( prop.mFlags & HbCss::ExtractedAnchorDir ) {
       
  4147 #ifdef HBSTYLE_DEBUG
       
  4148         qDebug() << "HbStyle::polishAnchor : -- Setting anchor direction: " << prop.mAnchorDir;
       
  4149 #endif
       
  4150         anchor->setDirection( prop.mAnchorDir );
       
  4151     }
       
  4152 }
       
  4153 
  4088 
  4154 
  4089 
  4155 
  4090 #define NODEPTR_N(x) HbCss::StyleSelector::NodePtr n = {n.ptr = (void *)x};
  4156 #define NODEPTR_N(x) HbCss::StyleSelector::NodePtr n = {n.ptr = (void *)x};
  4091 /*!
  4157 /*!
  4092     Polishes the appearance of the given \a widget.
  4158     Polishes the appearance of the given \a widget.
  4093 
  4159 
  4094     This method should be called only by HbWidget (base class). The inherited
  4160     This method should be called only by HbWidget (base class). The inherited
  4095     classes should not call this method directly, but use the HbWidget's
  4161     classes should not call this method directly, but use the HbWidget's
  4096     polish loop instead.
  4162     polish loop instead.
  4097     
  4163 
  4098     This method reads the CSS and WidgetML definition for a given widget and positions
  4164     This method reads the CSS and WidgetML definition for a given widget and positions
  4099     the sub-elements inside it. Note you need to set the names for the sub-elements
  4165     the sub-elements inside it. Note you need to set the names for the sub-elements
  4100     with HbStyle::setItemName method before this method is called.
  4166     with HbStyle::setItemName method before this method is called.
  4101 
  4167 
  4102     Note that this method is heavy on the system resources and should be called
  4168     Note that this method is heavy on the system resources and should be called
  4103     absolutely when necessary by the widget.
  4169     absolutely when necessary by the widget.
  4104     
  4170 
  4105     \param widget, HbWidget to be polished
  4171     \param widget, HbWidget to be polished
  4106     \param params, style parameters to be returned to the caller
  4172     \param params, style parameters to be returned to the caller
  4107 */
  4173 */
  4108 void HbStyle::polish(HbWidget *widget, HbStyleParameters &params)
  4174 void HbStyle::polish(HbWidget *widget, HbStyleParameters &params)
  4109 {
  4175 {
  4149     if (!styleRules.count()) {
  4215     if (!styleRules.count()) {
  4150         return;
  4216         return;
  4151     }
  4217     }
  4152     const HbVector<HbCss::Declaration> decl = declarations(styleRules, "", widget, profile);
  4218     const HbVector<HbCss::Declaration> decl = declarations(styleRules, "", widget, profile);
  4153 #ifdef HBSTYLE_DEBUG
  4219 #ifdef HBSTYLE_DEBUG
  4154     qDebug() << "HbStyle::polish : Number of maching CSS declarations: " << decl.count();
  4220     qDebug() << "HbStyle::polish : Number of matching CSS declarations: " << decl.count();
  4155 #endif
  4221 #endif
  4156     d->ensureLayoutParameters(profile);
  4222     d->ensureLayoutParameters(profile);
  4157 
  4223 
  4158     HbCss::ValueExtractor extractor(decl, d->layoutParameters, profile);
  4224     HbCss::ValueExtractor extractor(decl, d->layoutParameters, profile);
  4159     QString layoutName;
  4225     QString layoutName;
  4160     QString sectionName;
  4226     QString sectionName;
  4161 
  4227 
  4162     if ( params.count() ) {
  4228     if ( params.count() ) {
  4163 #ifdef HBSTYLE_DEBUG
  4229 #ifdef HBSTYLE_DEBUG
  4164         qDebug() << "HbStyle::polish : Extracting parameters.";
  4230         qDebug() << "HbStyle::polish : Extracting custom properties.";
  4165 #endif
  4231 #endif
  4166         extractor.extractParameters( params.params(), params.values() );
  4232         extractor.extractCustomProperties( params.keys(), params.values() );
  4167     }
  4233     }
  4168 
  4234 
  4169     bool layoutDefined = extractor.extractLayout(&layoutName, &sectionName);
  4235     bool layoutDefined = extractor.extractLayout(layoutName, sectionName);
  4170 #ifdef HBSTYLE_DEBUG
  4236 #ifdef HBSTYLE_DEBUG
  4171     if (!layoutDefined) {
  4237     if (!layoutDefined) {
  4172         qDebug() << "HbStyle::polish : Couldn't find layout name for the widget.";
  4238         qDebug() << "HbStyle::polish : Couldn't find layout name for the widget.";
  4173     } else {
  4239     } else {
  4174         qDebug() << "HbStyle::polish : Layout name: " << layoutName;
  4240         qDebug() << "HbStyle::polish : Layout name: " << layoutName;
  4175     }
  4241     }
  4176 #endif
  4242 #endif
  4177 
  4243 
  4178     QStringList meshIds;
  4244     QStringList nodeIds;
  4179     HbMeshLayout *meshLayout(0);
  4245     HbAnchorLayout *anchorLayout(0);
  4180     if (layoutDefined) {
  4246     if (layoutDefined) {
  4181 
  4247 
  4182         QString cachedLayoutName = widgetLayoutNames[widget];
  4248         // check that we do not override the user defined layout
  4183         bool cached = (cachedLayoutName == layoutName );
  4249         const QVariant layoutPtrByStyleV = widget->property( LAYOUT_PTR_PROPERTY );
  4184         if ( !cached ) {
  4250         const QGraphicsLayout *layoutPtrByStyle = layoutPtrByStyleV.isValid() ? layoutPtrByStyleV.value<QGraphicsLayout*>() : 0;
  4185 #ifdef HBSTYLE_DEBUG
  4251         const QGraphicsLayout *existingLayoutPtr = widget->layout();
  4186             qDebug() << "LayoutName cache miss.";
  4252 
  4187 #endif
  4253         if ( existingLayoutPtr && (existingLayoutPtr!=layoutPtrByStyle) ) {
  4188             HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
  4254             // widget has a layout, but it is not created by the style -> we cannot override.
  4189             if ( !loader->loadWidgetML(widget, layoutName, sectionName)) {
  4255 #ifdef HBSTYLE_DEBUG
  4190 #ifdef HBSTYLE_DEBUG
  4256             qDebug() << "HbStyle::polish : layout overridden by user";
  4191                 qDebug() << "HbStyle::polish : Failed to load WidgetML";
  4257 #endif // HBSTYLE_DEBUG
  4192 #endif
  4258         } else {
  4193                 return;       
  4259             const QVariant existingLayoutNameV = widget->property( LAYOUT_NAME_PROPERTY );
  4194             }
  4260             const QString existingLayoutName = existingLayoutNameV.isValid() ? existingLayoutNameV.toString() : QString();
  4195             widgetLayoutNames[widget] = layoutName;
  4261             const bool cached = (existingLayoutName == layoutName );
  4196             if (cachedLayoutName.isNull()) {
  4262             if ( !cached ) {
  4197                 // Cached for the first time. Connect to destroyed signal.
  4263 #ifdef HBSTYLE_DEBUG
  4198                 QObject::connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(widgetDestroyed(QObject*)));
  4264                 qDebug() << "LayoutName cache miss.";
  4199 #ifdef HBSTYLE_DEBUG
  4265 #endif
  4200                 qDebug() << "Cached first time. Connected to destroy signal.";
  4266                 HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
  4201             } else {
  4267                 if ( !loader->loadWidgetML(widget, layoutName, sectionName)) {
  4202                 qDebug() << "Cached nth time.";
  4268 #ifdef HBSTYLE_DEBUG
  4203 #endif
  4269                     qDebug() << "HbStyle::polish : Failed to load WidgetML";
  4204             }
  4270 #endif
       
  4271                     return;
       
  4272                 }
       
  4273                 const QVariant ptrVariant = QVariant::fromValue( widget->layout() );
       
  4274                 widget->setProperty( LAYOUT_PTR_PROPERTY, ptrVariant );
       
  4275                 widget->setProperty( LAYOUT_NAME_PROPERTY, QVariant( layoutName ) );
       
  4276             }
       
  4277 
       
  4278             anchorLayout = static_cast<HbAnchorLayout*>(widget->layout());
       
  4279             if (cached) {
       
  4280 #ifdef HBSTYLE_DEBUG
       
  4281                 qDebug() << "LayoutName cache hit.";
       
  4282 #endif
       
  4283                 anchorLayout->removeMappings();
       
  4284             }
       
  4285 
       
  4286             anchorLayout->setMapping(anchorLayout, "");
       
  4287             nodeIds = anchorLayout->nodeIds();
  4205         }
  4288         }
  4206         meshLayout = static_cast<HbMeshLayout*>(widget->layout());
       
  4207         if (cached) {
       
  4208 #ifdef HBSTYLE_DEBUG
       
  4209             qDebug() << "LayoutName cache hit.";
       
  4210 #endif
       
  4211             meshLayout->clearItemIds();
       
  4212         }
       
  4213 
       
  4214         meshLayout->setItemId(meshLayout, "");
       
  4215         meshIds = meshLayout->nodeIds();
       
  4216 
       
  4217     }
  4289     }
  4218 
  4290 
  4219     // polish widget and subitems
  4291     // polish widget and subitems
  4220     d->polishItem(styleRules, widget, widget, "", false);
  4292     d->polishItem(styleRules, widget, widget, "", profile, false);
  4221     QList<QGraphicsItem*> list = widget->childItems();
  4293     QList<QGraphicsItem*> list = widget->childItems();
  4222     foreach (QGraphicsItem* item, list) {
  4294     foreach (QGraphicsItem* item, list) {
  4223         QString name = HbStyle::itemName(item);
  4295         QString name = HbStyle::itemName(item);
  4224         if ( meshLayout && !name.isEmpty() ) {
  4296         if ( anchorLayout && !name.isEmpty() ) {
  4225             // Assuming that all items with "itemName" are widgets.
  4297             // Assuming that all items with "itemName" are widgets.
  4226             meshLayout->setItemId(static_cast<QGraphicsWidget*>(item), name);
  4298             anchorLayout->setMapping(static_cast<QGraphicsWidget*>(item), name);
  4227             // Remove from "meshIds" so that we don't call polishItem
  4299             // Remove from "nodeIds" so that we don't call polishItem
  4228             // twice for this item.
  4300             // twice for this item.
  4229             meshIds.removeAll(name);
  4301             nodeIds.removeAll(name);
  4230         }
  4302         }
  4231         d->polishItem(styleRules, widget, item, name, layoutDefined);
  4303         d->polishItem(styleRules, widget, item, name, profile, layoutDefined);
  4232     }
  4304     }
  4233     foreach (QString meshId, meshIds) {
  4305     foreach (QString nodeId, nodeIds) {
  4234         // These are the "missing" mesh items. Need to call polishItem
  4306         // These are the "missing" anchor items. Need to call polishItem
  4235         // for them, too, for getting the mesh anchor spacings right.
  4307         // for them, too, for getting the anchor spacings right.
  4236         // if there are mesh ids, layoutDefined is always true.
  4308         // if there are anchor node ids, layoutDefined is always true.
  4237         if ( !meshId.isEmpty() ) {
  4309         if ( !nodeId.isEmpty() ) {
  4238             d->polishItem(styleRules, widget, 0, meshId, true);
  4310             d->polishItem(styleRules, widget, 0, nodeId, profile, true);
       
  4311         }
       
  4312     }
       
  4313     if ( anchorLayout ) {
       
  4314         QList<HbAnchor*> anchors = anchorLayout->anchors();
       
  4315         foreach (HbAnchor* anchor, anchors) {
       
  4316             if ( !anchor->anchorId().isEmpty() ) {
       
  4317                 d->polishAnchor(styleRules, widget, anchor, profile);
       
  4318             }
  4239         }
  4319         }
  4240     }
  4320     }
  4241 }
  4321 }
  4242 
  4322 
  4243 /*!
  4323 /*!
  4246     \param styleRules, style-rules of the widget
  4326     \param styleRules, style-rules of the widget
  4247     \param variableRules, variable-rules of the widget
  4327     \param variableRules, variable-rules of the widget
  4248     \param widget, widget whose themed parameters are supposed to be updated
  4328     \param widget, widget whose themed parameters are supposed to be updated
  4249     \param item, graphics item whose themed parameters are supposed to be updated
  4329     \param item, graphics item whose themed parameters are supposed to be updated
  4250 */
  4330 */
  4251 void HbStylePrivate::updateThemedItems( const HbVector<HbCss::StyleRule> &styleRules,
  4331 void HbStylePrivate::updateThemedItems(
  4252     QGraphicsItem *item ) const
  4332     const HbVector<HbCss::StyleRule> &styleRules,
       
  4333     QGraphicsItem *item,
       
  4334     HbDeviceProfile &profile) const
  4253 {
  4335 {
  4254     
  4336 
  4255     QString name = HbStyle::itemName(item);
  4337     QString name = HbStyle::itemName(item);
  4256     if (name.isEmpty() ) {
  4338     if (name.isEmpty() ) {
  4257         return;
  4339         return;
  4258     }
  4340     }
  4259   
  4341 
  4260     HbTextItem* text = qgraphicsitem_cast<HbTextItem*>( item );
  4342     HbTextItem* text = qgraphicsitem_cast<HbTextItem*>( item );
       
  4343     HbRichTextItem* richtext = qgraphicsitem_cast<HbRichTextItem*>( item );
  4261     HbIconItem* iconItem = qgraphicsitem_cast<HbIconItem*>( item );
  4344     HbIconItem* iconItem = qgraphicsitem_cast<HbIconItem*>( item );
  4262     HbMarqueeItem* marqueeItem = qgraphicsitem_cast<HbMarqueeItem*>( item );
  4345     HbMarqueeItem* marqueeItem = qgraphicsitem_cast<HbMarqueeItem*>( item );
  4263     if(! (text || iconItem || marqueeItem ) ){
  4346     if(! (text || richtext || iconItem || marqueeItem ) ){
  4264         return;
  4347         return;
  4265     }
  4348     }
  4266     
  4349 
  4267     HbDeviceProfile profile;
       
  4268     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, 0, profile);
  4350     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, 0, profile);
  4269 
  4351 
  4270 #ifdef HBSTYLE_DEBUG
  4352 #ifdef HBSTYLE_DEBUG
  4271    qDebug() << "HbStyle::updateThemedItems : -- Number of maching CSS declarations: " << decl.count();
  4353    qDebug() << "HbStyle::updateThemedItems : -- Number of matching CSS declarations: " << decl.count();
  4272 #endif
  4354 #endif
  4273    ensureColorParameters();
  4355 
  4274    HbCss::ValueExtractor extractor(decl, colorParameters, profile);
  4356    HbCss::ValueExtractor extractor(decl, profile);
  4275    
  4357 
  4276     QColor col;
  4358     QColor col;
  4277     bool extracted = extractor.extractColor( &col );
  4359     bool extracted = extractor.extractColor( col );
  4278     if (!extracted || !col.isValid()) {
  4360     if (!extracted || !col.isValid()) {
  4279         // Setting non black or white default color to make it visisble in black or white theme
  4361         // Setting non black or white default color to make it visisble in black or white theme
  4280         col.setRgb(255,0,255);
  4362         col.setRgb(255,0,255);
  4281     }
  4363     }
  4282    //apply the themed color to text-item
  4364    //apply the themed color to text-item
  4283     if(text) {   
  4365     if(text) {
  4284 #ifdef HBSTYLE_DEBUG
  4366 #ifdef HBSTYLE_DEBUG
  4285         if ( !extracted ) {
  4367         if ( !extracted ) {
  4286             qDebug() << "HbStyle::getColor : -- No color information found";
  4368             qDebug() << "HbStyle::getColor : -- No color information found";
  4287         }
  4369         }
  4288 #endif    
  4370 #endif
  4289         if ( !HbWidgetBasePrivate::d_ptr(text)->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor ) ){
  4371         if ( !HbWidgetBasePrivate::d_ptr(text)->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor ) ){
  4290             text->setTextColor(col);
  4372             text->setTextColor(col);
  4291             HbWidgetBasePrivate::d_ptr(text)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor, false);
  4373             HbWidgetBasePrivate::d_ptr(text)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor, false);
  4292         }
  4374         }
  4293     }   
  4375     }
  4294     if(iconItem){
  4376 
  4295         //applying color to mono-colorised icons from theme
  4377     if(richtext) {
  4296         iconItem->setColor( col );
  4378 #ifdef HBSTYLE_DEBUG
       
  4379         if ( !extracted ) {
       
  4380             qDebug() << "HbStyle::getColor : -- No color information found";
       
  4381         }
       
  4382 #endif
       
  4383         if ( !HbWidgetBasePrivate::d_ptr(richtext)->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor ) ){
       
  4384             richtext->setTextDefaultColor(col);
       
  4385             HbWidgetBasePrivate::d_ptr(richtext)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor, false);
       
  4386         }
       
  4387     }
       
  4388 
       
  4389     if (iconItem) {
       
  4390         // Applying color to mono-colorised icons from theme. Using setColor()
       
  4391         // here would be wrong. It would lead to loosing the user-supplied color
       
  4392         // in some cases so use the special setThemedColor() instead.
       
  4393         HbIconItemPrivate::d_ptr(iconItem)->setThemedColor( col );
  4297     }
  4394     }
  4298     if(marqueeItem){
  4395     if(marqueeItem){
  4299         //applying color to the marquee-item from theme
  4396         //applying color to the marquee-item from theme
  4300         if(!HbWidgetBasePrivate::d_ptr(marqueeItem)->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor)) {
  4397         if(!HbWidgetBasePrivate::d_ptr(marqueeItem)->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor)) {
  4301             marqueeItem->setTextColor( col ); 
  4398             marqueeItem->setTextColor( col );
  4302             HbWidgetBasePrivate::d_ptr(marqueeItem)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor, false);
  4399             HbWidgetBasePrivate::d_ptr(marqueeItem)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextColor, false);
  4303         }
  4400         }
  4304     }
  4401     }
  4305 }
  4402 }
  4306  
  4403 
  4307 /*!
  4404 /*!
  4308     HbStyle::updateThemedParams()
  4405     HbStyle::updateThemedParams()
  4309 
  4406 
  4310     Updates the themable parameters of widget (specially those which are specified in css files)
  4407     Updates the themable parameters of widget (specially those which are specified in css files)
  4311 
  4408 
  4341 #ifdef HBSTYLE_DEBUG
  4438 #ifdef HBSTYLE_DEBUG
  4342         qDebug() << "HbStyle::updateThemedParams : No style rules found.";
  4439         qDebug() << "HbStyle::updateThemedParams : No style rules found.";
  4343 #endif
  4440 #endif
  4344         return;
  4441         return;
  4345     }
  4442     }
  4346   
  4443 
  4347     // update themed items
  4444     // update themed items
  4348     QList<QGraphicsItem*> list = widget->childItems();
  4445     QList<QGraphicsItem*> list = widget->childItems();
  4349     foreach (QGraphicsItem* item, list) {
  4446     foreach (QGraphicsItem* item, list) {
  4350         d->updateThemedItems(styleRules, item);
  4447         d->updateThemedItems(styleRules, item, profile);
  4351     }
  4448     }
  4352 }
  4449 }
  4353 
  4450 
  4354 /*!
  4451 /*!
  4355     Checkes whether given widget has orienation specific style 
  4452     Checkes whether given widget has orienation specific style
  4356     rules. This can be used for optimizing orientation switch.
  4453     rules. This can be used for optimizing orientation switch.
  4357 */
  4454 */
  4358 bool HbStyle::hasOrientationSpecificStyleRules(HbWidget *widget)
  4455 bool HbStyle::hasOrientationSpecificStyleRules(HbWidget *widget)
  4359 {
  4456 {
  4360     HbLayeredStyleLoader *styleLoader = 
  4457     HbLayeredStyleLoader *styleLoader =
  4361         HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Layouts);
  4458         HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Layouts);
  4362     NODEPTR_N(widget);
  4459     NODEPTR_N(widget);
  4363     return styleLoader->hasOrientationSpecificStyleRules(n);
  4460     return styleLoader->hasOrientationSpecificStyleRules(n);
  4364 }
  4461 }
  4365 
  4462 
  4366 /*!
  4463 /*!
  4367     For clearing caches.
  4464     For clearing caches.
  4368 */
  4465 */
  4369 void HbStyle::widgetDestroyed(QObject* obj)
  4466 void HbStyle::widgetDestroyed(QObject* obj)
  4370 {
  4467 {
  4371     widgetLayoutNames.remove((const QGraphicsWidget *)obj);
  4468     Q_UNUSED( obj );
  4372 }
  4469 }
  4373 
  4470 
  4374 /*!
  4471 /*!
  4375 
  4472 
  4376     Sets the item name of a graphics item. Item name is not the same as object name.
  4473     Sets the item name of a graphics item. Item name is not the same as object name.
  4386     \param item, graphics item
  4483     \param item, graphics item
  4387     \param name, name to be set
  4484     \param name, name to be set
  4388 */
  4485 */
  4389 void HbStyle::setItemName( QGraphicsItem *item, const QString &name )
  4486 void HbStyle::setItemName( QGraphicsItem *item, const QString &name )
  4390 {
  4487 {
  4391     if (item && itemName(item) != name) {
  4488     QString originalName = itemName(item);
       
  4489     if (item && originalName != name) {
  4392         item->setData( ItemName, name );
  4490         item->setData( ItemName, name );
  4393         QGraphicsItem* parent = item->parentItem();
  4491         QGraphicsItem* parent = item->parentItem();
  4394         QGraphicsLayoutItem* lItem = (item->isWidget()) ? (QGraphicsLayoutItem*)static_cast<QGraphicsWidget*>(item) : 0;
  4492         QGraphicsLayoutItem* lItem = (item->isWidget()) ? (QGraphicsLayoutItem*)static_cast<QGraphicsWidget*>(item) : 0;
  4395         if (lItem && parent && parent->isWidget()) {
  4493         if (lItem && parent && parent->isWidget()) {
  4396             QGraphicsWidget* parentW = static_cast<QGraphicsWidget*>(parent);
  4494             QGraphicsWidget* parentW = static_cast<QGraphicsWidget*>(parent);
  4397             if ( parentW->layout() && widgetLayoutNames.contains(parentW) ) {
  4495             const QVariant layoutPtrByStyleV = parentW->property( LAYOUT_PTR_PROPERTY );
  4398                 HbMeshLayout* layout = static_cast<HbMeshLayout*>(parentW->layout());
  4496             const QGraphicsLayout *layoutPtrByStyle = layoutPtrByStyleV.isValid() ? layoutPtrByStyleV.value<QGraphicsLayout*>() : 0;
       
  4497             if ( parentW->layout() && (parentW->layout()==layoutPtrByStyle)) {
       
  4498                 HbAnchorLayout* layout = static_cast<HbAnchorLayout*>(parentW->layout());
  4399                 if ( layout->indexOf(lItem) != -1 ) {
  4499                 if ( layout->indexOf(lItem) != -1 ) {
  4400                     layout->setItemId(lItem, name.isEmpty() ? QString() : name);
  4500                     if( name.isEmpty() ) {
       
  4501                         layout->removeMapping(originalName);
       
  4502                     } else {
       
  4503                         if ( !originalName.isEmpty() ) {
       
  4504                             layout->removeMapping(originalName);
       
  4505                         }
       
  4506                         layout->setMapping(lItem, name);
       
  4507                     }
  4401                 }
  4508                 }
  4402             }
  4509             }
  4403         }
  4510         }
  4404     }
  4511     }
  4405 }
  4512 }
  4418         ? item->data( ItemName ).toString()
  4525         ? item->data( ItemName ).toString()
  4419         : QString();
  4526         : QString();
  4420 }
  4527 }
  4421 
  4528 
  4422 /*!
  4529 /*!
  4423     Returns a value of a global style parameter. The value is returned in pixels. 
  4530     Returns a value of a global style parameter. The value is returned in pixels.
  4424 
  4531 
  4425     Available parameters can be found from hbglobalparameters.css. By using these
  4532     Available parameters can be found from hbglobalparameters.css. By using these
  4426     parameters applications get consistent look.
  4533     parameters applications get consistent look.
  4427 
  4534 
  4428     \param variable Name of the global parameter.
  4535     \param param Name of the global parameter.
  4429     \param value Returns value of the global parameter.
  4536     \param value Returns value of the global parameter.
  4430     \param profile Device profile of the used HbMainWindow. Primary display's.
  4537     \param profile Device profile of the used HbMainWindow. Primary display's.
  4431             device profile HbDeviceProfile::current() is used if the value is omitted.
  4538             device profile HbDeviceProfile::current() is used if the value is omitted.
  4432     \return true if the variable were found.
  4539     \return true if the variable was found.
  4433 */
  4540 */
  4434 bool HbStyle::parameter(const QString& parameter, qreal& value, const HbDeviceProfile &profile) const
  4541 bool HbStyle::parameter(const QString& param, qreal& value, const HbDeviceProfile &profile) const
  4435 {
  4542 {
  4436     HbDeviceProfile effectiveProfile = profile;
  4543     HbDeviceProfile effectiveProfile = profile;
  4437     if ( effectiveProfile.isNull() ) {
  4544     if ( effectiveProfile.isNull() ) {
  4438         effectiveProfile = HbDeviceProfile::current();
  4545         effectiveProfile = HbDeviceProfile::current();
  4439     }
  4546     }
  4440     Q_D( const HbStyle );
  4547     Q_D( const HbStyle );
  4441     d->ensureLayoutParameters(effectiveProfile);
  4548     d->ensureLayoutParameters(effectiveProfile);
  4442     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
  4549     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
  4443     // todo: parsing variable/expression is done here so that there is no need to change API
  4550     // todo: parsing variable/expression is done here so that there is no need to change API
  4444     // also parameters method not changed (this change is done for docml/widgetml parsing)
  4551     // also parameters method not changed (this change is done for docml/widgetml parsing)
  4445     if (parameter.startsWith("var(") && parameter.endsWith(")")) {
  4552     if (param.startsWith(QLatin1String("var(")) && param.endsWith(QLatin1String(")"))) {
  4446         return valueExtractor.extractValue(parameter.mid(4,parameter.length()-5), value);
  4553         return valueExtractor.extractVariableValue(param.mid(4,param.length()-5), value);
  4447     } else if (parameter.startsWith("-var(") && parameter.endsWith(")")) {
  4554     } else if (param.startsWith(QLatin1String("-var(")) && param.endsWith(QLatin1String(")"))) {
  4448         bool retVal = valueExtractor.extractValue(parameter.mid(5,parameter.length()-6), value);
  4555         bool retVal = valueExtractor.extractVariableValue(param.mid(5,param.length()-6), value);
  4449         value = -value;
  4556         value = -value;
  4450         return retVal;
  4557         return retVal;
  4451     } else if (parameter.startsWith("expr(") && parameter.endsWith(")")) {
  4558     } else if (param.startsWith(QLatin1String("expr(")) && param.endsWith(QLatin1String(")"))) {
  4452         QString expressionString = parameter.mid(5,parameter.length()-6);
  4559         QString expressionString = param.mid(5,param.length()-6);
  4453         return valueExtractor.extractExpressionValue(expressionString, value);
  4560         return valueExtractor.extractExpressionValue(expressionString, value);
  4454     } else if (parameter.startsWith("-expr(") && parameter.endsWith(")")) {
  4561     } else if (param.startsWith(QLatin1String("-expr(")) && param.endsWith(QLatin1String(")"))) {
  4455         QString expressionString = parameter.mid(6,parameter.length()-7);
  4562         QString expressionString = param.mid(6,param.length()-7);
  4456         bool retVal = valueExtractor.extractExpressionValue(expressionString, value);
  4563         bool retVal = valueExtractor.extractExpressionValue(expressionString, value);
  4457         value = -value;
  4564         value = -value;
  4458         return retVal;
  4565         return retVal;
  4459     }
  4566     }
  4460 
  4567 
  4461     return valueExtractor.extractValue(parameter, value);    
  4568     return valueExtractor.extractVariableValue(param, value);
  4462 }
  4569 }
  4463 
  4570 
  4464 /*!
  4571 /*!
  4465     Returns copy of all global style parameters. Both names and values 
  4572     Returns copy of all global style parameters. Both names and values
  4466     of the parameters are returned. The values are returned in pixels.
  4573     of the parameters are returned. The values are returned in pixels.
  4467 
  4574 
  4468     Available parameters can be found from hbglobalparameters.css. By using these
  4575     Available parameters can be found from hbglobalparameters.css. By using these
  4469     parameters applications get consistent look. Usage of this API (instead of parameter)
  4576     parameters applications get consistent look. Usage of this API (instead of parameter)
  4470     is recommended if an application needs to fetch several parameters in one place.
  4577     is recommended if an application needs to fetch several parameters in one place.
  4471 
  4578 
  4472     \param parameters Contains names and values of all global style parameters.
  4579     \param params Contains names and values of all global style parameters.
  4473     \param profile Device profile of the used HbMainWindow. Primary display's
  4580     \param profile Device profile of the used HbMainWindow. Primary display's
  4474             device profile HbDeviceProfile::current() is used if the value is omitted.
  4581             device profile HbDeviceProfile::current() is used if the value is omitted.
  4475 */
  4582 */
  4476 
  4583 
  4477 void HbStyle::parameters(HbStyleParameters &parameters, const HbDeviceProfile &profile) const
  4584 void HbStyle::parameters(HbStyleParameters &params, const HbDeviceProfile &profile) const
  4478 {
  4585 {
  4479     HbDeviceProfile effectiveProfile = profile;
  4586     HbDeviceProfile effectiveProfile = profile;
  4480     if ( effectiveProfile.isNull() ) {
  4587     if ( effectiveProfile.isNull() ) {
  4481         effectiveProfile = HbDeviceProfile::current();
  4588         effectiveProfile = HbDeviceProfile::current();
  4482     }
  4589     }
  4485     d->ensureLayoutParameters(effectiveProfile);
  4592     d->ensureLayoutParameters(effectiveProfile);
  4486     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
  4593     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
  4487     qreal value = 0;
  4594     qreal value = 0;
  4488     QHash<QString, HbCss::Declaration>::const_iterator i = d->layoutParameters.constBegin();
  4595     QHash<QString, HbCss::Declaration>::const_iterator i = d->layoutParameters.constBegin();
  4489     while (i != d->layoutParameters.constEnd()) {
  4596     while (i != d->layoutParameters.constEnd()) {
  4490         if (valueExtractor.extractValue(i.key(), value)) {
  4597         if (valueExtractor.extractVariableValue(i.key(), value)) {
  4491             parameters.addParameter(i.key(), value);
  4598             params.addParameter(i.key(), value);
  4492         }
  4599         }
  4493         ++i;
  4600         ++i;
  4494     }
  4601     }
       
  4602 }
       
  4603 
       
  4604 /*!
       
  4605     Returns values for widget specific style parameters. The names of the parameters
       
  4606     are passed in with \a params.
       
  4607 
       
  4608     This method should be used only if you need to access widget specific parameters out
       
  4609     of the polish loop. It is more efficient to use HbWidget::polish(HbStyleParameters &params)
       
  4610     if you don't need to access the parameters before the (first) polish event.
       
  4611 
       
  4612     \param parameters, style parameters to be returned to the caller
       
  4613     \param widget, HbWidget to be polished
       
  4614     \sa HbStyle::polish, HbStyle::parameters and HbWidget::polish
       
  4615 */
       
  4616 void HbStyle::widgetParameters(HbStyleParameters &params, HbWidget* widget) const
       
  4617 {
       
  4618     Q_D( const HbStyle );
       
  4619     if( !widget || !params.count() ) {
       
  4620         return;
       
  4621     }
       
  4622 #ifdef HBSTYLE_DEBUG
       
  4623     qDebug() << "HbStyle::widgetParameters : Parameters for" << widget->metaObject()->className();
       
  4624 #endif
       
  4625 
       
  4626     HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Layouts);
       
  4627     if(!styleLoader){
       
  4628 #ifdef HBSTYLE_DEBUG
       
  4629         qDebug() << "HbStyle::widgetParameters : HbLayeredStyleLoader returned a null pointer.";
       
  4630 #endif
       
  4631         return;
       
  4632     }
       
  4633     HbDeviceProfile profile(HbDeviceProfile::profile(widget));
       
  4634     NODEPTR_N(widget);
       
  4635 
       
  4636     HbVector<HbCss::StyleRule> styleRules = styleLoader->styleRulesForNode(n, profile.orientation());
       
  4637 
       
  4638 #ifdef HBSTYLE_DEBUG
       
  4639     qDebug() << "HbStyle::widgetParameters : Number of style rules:" << styleRules.count();
       
  4640 #endif
       
  4641     if (!styleRules.count()) {
       
  4642         return;
       
  4643     }
       
  4644     const HbVector<HbCss::Declaration> decl = declarations(styleRules, "", widget, profile);
       
  4645 #ifdef HBSTYLE_DEBUG
       
  4646     qDebug() << "HbStyle::widgetParameters : Number of matching CSS declarations: " << decl.count();
       
  4647 #endif
       
  4648     d->ensureLayoutParameters(profile);
       
  4649 
       
  4650     HbCss::ValueExtractor extractor(decl, d->layoutParameters, profile);
       
  4651     extractor.extractCustomProperties( params.keys(), params.values() );
  4495 }
  4652 }
  4496 
  4653 
  4497 
  4654 
  4498 /*!
  4655 /*!
  4499 \internal
  4656 \internal
  4500 */
  4657 */
  4501 HbStylePrivate::HbStylePrivate()
  4658 HbStylePrivate::HbStylePrivate()
  4502 {
  4659 {
  4503     nextAvailableId = HbStyle::P_CustomBase;
       
  4504     HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
  4660     HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
  4505     if(loader){
  4661     if(loader){
  4506         loader->addFilePath(STYLE_LOCATION, HbLayeredStyleLoader::Concern_Layouts, 
  4662         loader->addFilePath(STYLE_LOCATION, HbLayeredStyleLoader::Concern_Layouts,
  4507                 HbLayeredStyleLoader::Priority_Core);
  4663                 HbLayeredStyleLoader::Priority_Core);
  4508         loader->addFilePath(COLOR_STYLE_LOCATION, HbLayeredStyleLoader::Concern_Colors, 
  4664         loader->addFilePath(COLOR_STYLE_LOCATION, HbLayeredStyleLoader::Concern_Colors,
  4509                 HbLayeredStyleLoader::Priority_Core);
  4665                 HbLayeredStyleLoader::Priority_Core);
  4510     }
  4666     }
  4511 }
  4667 }
  4512 
  4668 
  4513 /*!
  4669 /*!
  4514 \internal
  4670 \internal
  4515 */
  4671 */
  4516 HbStylePrivate::~HbStylePrivate()
  4672 HbStylePrivate::~HbStylePrivate()
  4517 {
  4673 {
  4518     layoutParameters.clear();
  4674     layoutParameters.clear();
  4519     colorParameters.clear();
       
  4520 
  4675 
  4521     HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
  4676     HbWidgetStyleLoader *loader = HbWidgetStyleLoader::instance();
  4522     if(loader){
  4677     if(loader){
  4523         loader->removeFilePath(STYLE_LOCATION, HbLayeredStyleLoader::Concern_Layouts, 
  4678         loader->removeFilePath(STYLE_LOCATION, HbLayeredStyleLoader::Concern_Layouts,
  4524                 HbLayeredStyleLoader::Priority_Core);
  4679                 HbLayeredStyleLoader::Priority_Core);
  4525         loader->removeFilePath(COLOR_STYLE_LOCATION, HbLayeredStyleLoader::Concern_Colors, 
  4680         loader->removeFilePath(COLOR_STYLE_LOCATION, HbLayeredStyleLoader::Concern_Colors,
  4526                 HbLayeredStyleLoader::Priority_Core);
  4681                 HbLayeredStyleLoader::Priority_Core);
  4527     }
  4682     }
  4528 }
       
  4529 
       
  4530 void HbStylePrivate::_q_onThemeChanged()
       
  4531 {
       
  4532     colorParameters.clear();
       
  4533 }
  4683 }
  4534 
  4684 
  4535 /*!
  4685 /*!
  4536 \internal
  4686 \internal
  4537 */
  4687 */
  4538 QString HbStylePrivate::logicalName(HbStyle::Primitive primitive, const QStyleOption *option) const
  4688 QString HbStylePrivate::logicalName(HbStyle::Primitive primitive, const QStyleOption *option) const
  4539 {
  4689 {
  4540     switch(primitive){
  4690     switch (primitive) {
  4541     case HbStyle::P_Slider_thumb:{
  4691 
       
  4692     case HbStyle::P_Slider_thumb: {
  4542         const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider *>(option);
  4693         const HbStyleOptionSlider *opt = qstyleoption_cast<const HbStyleOptionSlider *>(option);
  4543         QString iconPath;
  4694         if (opt) {
  4544 
  4695             QString iconPath;
  4545                 switch (opt->orientation){
  4696             switch (opt->orientation) {
  4546                 case Qt::Horizontal:{
  4697 
  4547                         if( opt->state&QStyle::State_Sunken)
  4698             case Qt::Horizontal:
  4548                             iconPath= "qtg_graf_slider_h_handle_pressed";
  4699                 if (opt->state & QStyle::State_Sunken)
  4549                         else
  4700                     iconPath = "qtg_graf_slider_h_handle_pressed";
  4550                             iconPath= "qtg_graf_slider_h_handle_normal";
  4701                 else
  4551                         return (iconPath);
  4702                     iconPath = "qtg_graf_slider_h_handle_normal";
  4552                 }
  4703                 return iconPath;
  4553                 case Qt::Vertical:{
  4704 
  4554                         if( opt->state&QStyle::State_Sunken)
  4705             case Qt::Vertical:
  4555                             iconPath= "qtg_graf_slider_v_handle_pressed";
  4706                 if (opt->state & QStyle::State_Sunken)
  4556                         else
  4707                     iconPath = "qtg_graf_slider_v_handle_pressed";
  4557                             iconPath= "qtg_graf_slider_v_handle_normal";
  4708                 else
  4558                         return (iconPath);
  4709                     iconPath = "qtg_graf_slider_v_handle_normal";
  4559                 }
  4710                 return iconPath;
  4560                 default: break;
  4711 
       
  4712             default:
       
  4713                 break;
       
  4714 
       
  4715             }
  4561         }
  4716         }
  4562     }
  4717     }
  4563         default: break;
  4718 
  4564     }
  4719     default:
  4565 
  4720         break;
  4566 return QString();
  4721 
       
  4722     }
       
  4723 
       
  4724     return QString();
  4567 }
  4725 }
  4568 
  4726 
  4569 /*!
  4727 /*!
  4570 \internal
  4728 \internal
  4571 */
  4729 */
  4590     if (state & QStyle::State_On)
  4748     if (state & QStyle::State_On)
  4591         icon = QIcon::On;
  4749         icon = QIcon::On;
  4592     return icon;
  4750     return icon;
  4593 }
  4751 }
  4594 
  4752 
  4595 /*!
       
  4596 \internal
       
  4597 */
       
  4598 HbStyleInterface *HbStylePrivate::stylePluginInterface( HbStyle::Primitive primitive ) const
       
  4599 {
       
  4600     
       
  4601     if (customPrimitives.contains(primitive)) {
       
  4602         HbStyleInterfaceInfo* info = customPrimitives.value(primitive);
       
  4603         QObject* pluginInstance = info->loader->instance();
       
  4604         HbStyleInterface *stylePlugin = qobject_cast<HbStyleInterface *>(pluginInstance);
       
  4605         return stylePlugin;
       
  4606     }
       
  4607     return 0;
       
  4608 }
       
  4609 
  4753 
  4610 /*!
  4754 /*!
  4611 \internal
  4755 \internal
  4612 */
  4756 */
  4613 void HbStylePrivate::ensureLayoutParameters(const HbDeviceProfile &profile) const
  4757 void HbStylePrivate::ensureLayoutParameters(const HbDeviceProfile &profile) const
  4615     bool firstParse(layoutParameters.isEmpty());
  4759     bool firstParse(layoutParameters.isEmpty());
  4616     bool addSpecialParams(firstParse);
  4760     bool addSpecialParams(firstParse);
  4617     if (firstParse) {
  4761     if (firstParse) {
  4618         HbCss::Parser parser;
  4762         HbCss::Parser parser;
  4619         parser.init(GLOBAL_PARAMETERS_LOCATION, true);
  4763         parser.init(GLOBAL_PARAMETERS_LOCATION, true);
  4620         HbCss::StyleSheet *styleSheet = new(HbCss::StyleSheet);
  4764         HbCss::StyleSheet *styleSheet = HbMemoryUtils::create<HbCss::StyleSheet>(HbMemoryManager::HeapMemory);
  4621         parser.parse(styleSheet);
  4765         parser.parse(styleSheet);
  4622 
  4766 
  4623         HbStyleSelector selector;
  4767         HbStyleSelector selector;
  4624         selector.styleSheets.append(styleSheet);
  4768         selector.styleSheets.append(styleSheet);
  4625         selector.variableRuleSets(&layoutParameters);
  4769         selector.variableRuleSets(&layoutParameters);
  4632         QSizeF pSize = profile.logicalSize();
  4776         QSizeF pSize = profile.logicalSize();
  4633 
  4777 
  4634         {
  4778         {
  4635             HbCss::Declaration decl;
  4779             HbCss::Declaration decl;
  4636             decl.property = "hb-param-screen-width";
  4780             decl.property = "hb-param-screen-width";
  4637             decl.propertyId = HbCss::UnknownProperty;
  4781             decl.propertyId = HbCss::Property_Unknown;
  4638             HbCss::Value val;
  4782             HbCss::Value val;
  4639             val.type = HbCss::Value::Number;
  4783             val.type = HbCss::Value::Number;
  4640             val.variant = HbVariant((double)pSize.width(),HbMemoryManager::HeapMemory);
  4784             val.variant = HbVariant((double)pSize.width(),HbMemoryManager::HeapMemory);
  4641             decl.values.append(val);
  4785             decl.values.append(val);
  4642             layoutParameters.insert(decl.property, decl);
  4786             layoutParameters.insert(decl.property, decl);
  4643         }
  4787         }
  4644         {
  4788         {
  4645             HbCss::Declaration decl;
  4789             HbCss::Declaration decl;
  4646             decl.property = "hb-param-screen-height";
  4790             decl.property = "hb-param-screen-height";
  4647             decl.propertyId = HbCss::UnknownProperty;
  4791             decl.propertyId = HbCss::Property_Unknown;
  4648             HbCss::Value val;
  4792             HbCss::Value val;
  4649             val.type = HbCss::Value::Number;
  4793             val.type = HbCss::Value::Number;
  4650             val.variant = HbVariant((double)pSize.height(),HbMemoryManager::HeapMemory);
  4794             val.variant = HbVariant((double)pSize.height(),HbMemoryManager::HeapMemory);
  4651             decl.values.append(val);
  4795             decl.values.append(val);
  4652             layoutParameters.insert(decl.property, decl);
  4796             layoutParameters.insert(decl.property, decl);
  4653         }
  4797         }
  4654         {
  4798         {
  4655             HbCss::Declaration decl;
  4799             HbCss::Declaration decl;
  4656             decl.property = "hb-param-screen-short-edge";
  4800             decl.property = "hb-param-screen-short-edge";
  4657             decl.propertyId = HbCss::UnknownProperty;
  4801             decl.propertyId = HbCss::Property_Unknown;
  4658             HbCss::Value val;
  4802             HbCss::Value val;
  4659             val.type = HbCss::Value::Number;
  4803             val.type = HbCss::Value::Number;
  4660             val.variant = HbVariant((double)qMin(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
  4804             val.variant = HbVariant((double)qMin(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
  4661             decl.values.append(val);
  4805             decl.values.append(val);
  4662             layoutParameters.insert(decl.property, decl);
  4806             layoutParameters.insert(decl.property, decl);
  4663         }
  4807         }
  4664         {
  4808         {
  4665             HbCss::Declaration decl;
  4809             HbCss::Declaration decl;
  4666             decl.property = "hb-param-screen-long-edge";
  4810             decl.property = "hb-param-screen-long-edge";
  4667             decl.propertyId = HbCss::UnknownProperty;
  4811             decl.propertyId = HbCss::Property_Unknown;
  4668             HbCss::Value val;
  4812             HbCss::Value val;
  4669             val.type = HbCss::Value::Number;
  4813             val.type = HbCss::Value::Number;
  4670             val.variant = HbVariant((double)qMax(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
  4814             val.variant = HbVariant((double)qMax(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
  4671             decl.values.append(val);
  4815             decl.values.append(val);
  4672             layoutParameters.insert(decl.property, decl);
  4816             layoutParameters.insert(decl.property, decl);
  4673         }
  4817         }
  4674     }
  4818     }
  4675 }
  4819 }
  4676 
  4820 
  4677 void HbStylePrivate::ensureColorParameters() const
       
  4678 {
       
  4679     if (colorParameters.isEmpty()) {
       
  4680         HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
       
  4681         styleLoader->variableRuleSets(&colorParameters);
       
  4682     }
       
  4683 }
       
  4684 
       
  4685 /*!
  4821 /*!
  4686 \internal
  4822 \internal
  4687 */
  4823 */
  4688 void HbStylePrivate::clearStyleSheetCaches()
  4824 void HbStylePrivate::clearStyleSheetCaches()
  4689 {
  4825 {
  4690     widgetLayoutNames.clear();
       
  4691     styleRulesCache.clear();
  4826     styleRulesCache.clear();
  4692     colorParameters.clear();
       
  4693 }
  4827 }
  4694 
  4828 
  4695 HbWidgetBasePrivate *HbStylePrivate::widgetBasePrivate(HbWidgetBase *widgetBase) const
  4829 HbWidgetBasePrivate *HbStylePrivate::widgetBasePrivate(HbWidgetBase *widgetBase) const
  4696 {
  4830 {
  4697     return HbWidgetBasePrivate::d_ptr(widgetBase);
  4831     return HbWidgetBasePrivate::d_ptr(widgetBase);
  4698 }
  4832 }
  4699 
  4833 
  4700 
       
  4701 #include "moc_hbstyle.cpp"
  4834 #include "moc_hbstyle.cpp"