src/hbcore/theme/hbcssthemeinterface_p.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 3 11d3954df52a
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    44  */
    44  */
    45 void HbCssThemeInterface::initialise(const QMap<int,QString> & list,bool loadAllFiles,
    45 void HbCssThemeInterface::initialise(const QMap<int,QString> & list,bool loadAllFiles,
    46                                      bool enableBinarySupport)
    46                                      bool enableBinarySupport)
    47 {
    47 {
    48     int handle;
    48     int handle;
       
    49     flushVariableCache();
    49     HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
    50     HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
    50     
    51     
    51     //first unload the layers, for which the contents are different after theme change
    52     //first unload the layers, for which the contents are different after theme change
    52     if (handles.size() != 0)  {
    53     if (handles.size() != 0)  {
    53         QMap<int,HbLayeredStyleLoader::LayerPriority>::const_iterator itr;
    54         QMap<int,HbLayeredStyleLoader::LayerPriority>::const_iterator itr;
    83  */
    84  */
    84 void HbCssThemeInterface::flush()
    85 void HbCssThemeInterface::flush()
    85 {
    86 {
    86     HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
    87     HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
    87     loader->clear();
    88     loader->clear();
       
    89     flushVariableCache();
       
    90 }
       
    91 
       
    92 void HbCssThemeInterface::flushVariableCache()
       
    93 {
       
    94     mVariables.clear();
    88 }
    95 }
    89 
    96 
    90 /*!
    97 /*!
    91  * \fn HbCssThemeInterface::findAttribute(const QGraphicsWidget* w, QString attribute)
    98  * \fn HbCssThemeInterface::findAttribute(const QGraphicsWidget* w, QString attribute)
    92  * Function for finding an attribute
    99  * Function for finding an attribute
   101     StyleSelector::NodePtr n;
   108     StyleSelector::NodePtr n;
   102     n.ptr = (void *)w;
   109     n.ptr = (void *)w;
   103     HbCss::Value value;
   110     HbCss::Value value;
   104 
   111 
   105     HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
   112     HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
   106 	HbDeviceProfile profile(HbDeviceProfile::profile(w));
   113     HbDeviceProfile profile(HbDeviceProfile::profile(w));
   107 	HbCss::ValueExtractor valueExtractor(loader->declarationsForNode(n, profile.orientation()), true);
   114     HbCss::ValueExtractor valueExtractor(loader->declarationsForNode(n, profile.orientation()), true);
   108     valueExtractor.extractValue (attribute, value);
   115     valueExtractor.extractValue(attribute, value);
   109     
   116     
   110 
       
   111     if ( value.type == Value::Variable) {
   117     if ( value.type == Value::Variable) {
   112         value = findVariable ( value.variant.toString ());
   118         value = findVariable ( value.variant.toString ());
   113     }
   119     }
   114 
   120 
   115     return value;
   121     return value;
   122  * \return list of values.
   128  * \return list of values.
   123  */
   129  */
   124 HbCss::Value HbCssThemeInterface::findVariable(
   130 HbCss::Value HbCssThemeInterface::findVariable(
   125         const QString& variableName) const
   131         const QString& variableName) const
   126 {
   132 {
   127     HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
   133     if ( mVariables.isEmpty() ) {
   128     HbCss::Value val;
   134         HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors);
       
   135         loader->variableRuleSets(&mVariables);
       
   136     }
       
   137 
   129     HbCss::Value value;
   138     HbCss::Value value;
   130 
   139     HbCss::ValueExtractor valueExtractor(mVariables, true);
   131     HbCss::ValueExtractor valueExtractor(loader->variableRuleSets(),true);
   140     valueExtractor.extractValue(variableName, value);
   132     valueExtractor.extractValue (variableName, value);
       
   133 
   141 
   134     //for varibale cascading support
   142     //for varibale cascading support
   135     if ( value.type == Value::Variable){
   143     if ( value.type == Value::Variable){
   136         value = findVariable ( value.variant.toString ());
   144         value = findVariable ( value.variant.toString ());
   137     }
   145     }