Cleaned up initial playlist and added playlist song verse activate
[kworship.git] / kworship / css / KwCssStyleStates.h
blobc009965d5a0bf91d90573d348f3293a6088a2353
1 #ifndef _KwCssStyleStates_h_
2 #define _KwCssStyleStates_h_
4 /**
5 * @file KwCssStyleStates.h
6 * @brief Set of cascading style property states.
7 * @author James Hogan <james@albanarts.com>
8 */
10 #include "KwCssStyle.h"
12 #include <QHash>
14 #include <cassert>
16 class KwCssAbstractStyleState;
18 /// Set of cascading style properties.
19 class KwCssStyleStates
21 public:
24 * Constructors + destructors
27 /// Default constructor.
28 KwCssStyleStates();
30 /// Copy constructor.
31 KwCssStyleStates(const KwCssStyleStates& other);
33 /// Destructor.
34 virtual ~KwCssStyleStates();
37 * Main interface
40 /// Clear all states.
41 void clear();
43 /// Get a state.
44 const KwCssAbstractStyleState* getRawStyle(QString name) const;
46 /// Get the value of a state.
47 template <typename T>
48 T getStyle(QString name) const
50 const KwCssAbstractStyleState* rawStyle = getRawStyle(name);
51 if (0 != rawStyle)
53 const KwCssStyleState<T>* style = dynamic_cast<const KwCssStyleState<T>*>(rawStyle);
54 assert(0 != style &&"style with incorrect type");
55 if (0 != style)
57 return style->getValue();
60 return T();
64 * Operators
67 /// Copy assignment operator.
68 KwCssStyleStates& operator = (const KwCssStyleStates& other);
70 /// Index into styles mapping.
71 KwCssAbstractStyleState*& operator [] (QString name);
73 private:
76 * Types
79 /// Dictionary of strings to styles.
80 typedef QHash<QString, KwCssAbstractStyleState*> StyleStateDictionary;
83 * Variables
86 /// The style properties.
87 StyleStateDictionary m_styleStates;
91 #endif // _KwCssStyleStates_h_