src/hbcore/style/hbstylevalue.h
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #ifndef HBSTYLEVALUE_H
    26 #ifndef HBSTYLEVALUE_H
    27 #define HBSTYLEVALUE_H
    27 #define HBSTYLEVALUE_H
    28 
    28 
       
    29 #include <QString>
       
    30 #include <QVariant>
       
    31 #include <hbicon.h>
    29 
    32 
    30 template<typename T>
    33 template<typename T>
    31 class HbStyleValue
    34 class HbStyleValue
    32 {
    35 {
    33 public:
    36 public:
    36 
    39 
    37     bool isSet() const;
    40     bool isSet() const;
    38     T value() const;
    41     T value() const;
    39     operator T() const;
    42     operator T() const;
    40     void operator=(const T &value);
    43     void operator=(const T &value);
       
    44     bool operator!=(const T &value) const;
       
    45     bool operator==(const T &value) const;
       
    46     void clear();
    41 
    47 
    42 private:
    48 private:
    43     bool mSet;
    49     bool mSet;
    44     T mVal;
    50     T mVal;
    45 };
    51 };
    79 {
    85 {
    80     mVal = value;
    86     mVal = value;
    81     mSet = true;
    87     mSet = true;
    82 }
    88 }
    83 
    89 
       
    90 template<typename T>
       
    91 void HbStyleValue<T>::clear()
       
    92 {
       
    93     mSet = false;
       
    94 }
       
    95 
       
    96 template<typename T>
       
    97 bool HbStyleValue<T>::operator!=(const T &value) const
       
    98 {
       
    99     if (!mSet) {
       
   100         return true;
       
   101     }
       
   102     return mVal!=value;
       
   103 }
       
   104 
       
   105 template<typename T>
       
   106 bool HbStyleValue<T>::operator==(const T &value) const
       
   107 {
       
   108     return !(*this!=value);
       
   109 }
       
   110 
       
   111 template<typename T>
       
   112 bool operator!=(const T &value, const HbStyleValue<T> &other)
       
   113 {
       
   114     return other!=value;
       
   115 }
       
   116 
       
   117 template<typename T>
       
   118 inline bool operator==(const T &value, const HbStyleValue<T> &other)
       
   119 {
       
   120     return !(other!=value);
       
   121 }
       
   122 
       
   123 template<>
       
   124 inline void HbStyleValue<QString>::clear()
       
   125 {
       
   126     mSet = false;
       
   127     mVal.clear();
       
   128 }
       
   129 
       
   130 template<>
       
   131 inline void HbStyleValue<QVariant>::clear()
       
   132 {
       
   133     mSet = false;
       
   134     mVal.clear();
       
   135 }
       
   136 
       
   137 template<>
       
   138 inline void HbStyleValue<HbIcon>::clear()
       
   139 {
       
   140     mSet = false;
       
   141     mVal.clear();
       
   142 }
       
   143 
    84 #endif // HBSTYLEVALUE_H
   144 #endif // HBSTYLEVALUE_H