Cleaned up initial playlist and added playlist song verse activate
[kworship.git] / kworship / css / KwCssStyles.cpp
blob314f5bcb396dc783b587fc277dc62d29f7f398e8
1 /**
2 * @file KwCssStyles.cpp
3 * @brief Set of cascading style properties.
4 * @author James Hogan <james@albanarts.com>
5 */
7 #include "KwCssStyles.h"
8 #include "KwCssStyleStates.h"
9 #include "KwCssAbstractStyle.h"
10 #include "KwCssAbstractStyleState.h"
13 * Constructors + destructors
16 /// Default constructor.
17 KwCssStyles::KwCssStyles()
18 : m_styles()
22 /// Copy constructor.
23 KwCssStyles::KwCssStyles(const KwCssStyles& other)
24 : m_styles()
26 StyleDictionary::const_iterator it;
27 for (it = other.m_styles.begin(); it != other.m_styles.end(); ++it)
29 m_styles[it.key()] = (*it)->duplicate();
33 /// Destructor.
34 KwCssStyles::~KwCssStyles()
36 StyleDictionary::iterator it;
37 for (it = m_styles.begin(); it != m_styles.end(); ++it)
39 delete *it;
44 * Main interface
47 /// Set a style.
48 void KwCssStyles::setRawStyle(QString name, KwCssAbstractStyle* style)
50 // Delete previous value
51 StyleDictionary::iterator it = m_styles.find(name);
52 if (it != m_styles.end())
54 delete *it;
56 // Set new value
57 m_styles[name] = style;
61 * Operators
64 /// Apply styles.
65 KwCssStyleStates& operator << (KwCssStyleStates& states, const KwCssStyles& styles)
67 // go through styles, adjusting the states
68 KwCssStyles::StyleDictionary::const_iterator it;
69 for (it = styles.m_styles.begin(); it != styles.m_styles.end(); ++it)
71 KwCssAbstractStyleState*& state = states[it.key()];
72 if (0 == state)
74 state = (*it)->getNewState();
76 (*state) << (*it);
78 return states;