Writing of basic layout info to zionworx files
[kworship.git] / kworship / css / KwCssStyleStates.h
blob88403cf503b7fda406c1df7815bbcc5837ba9c40
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _KwCssStyleStates_h_
21 #define _KwCssStyleStates_h_
23 /**
24 * @file KwCssStyleStates.h
25 * @brief Set of cascading style property states.
26 * @author James Hogan <james@albanarts.com>
29 #include "KwCssStyle.h"
31 #include <kdemacros.h>
33 #include <QHash>
35 #include <cassert>
37 class KwCssAbstractStyleState;
39 /// Set of cascading style properties.
40 class KDE_EXPORT KwCssStyleStates
42 public:
45 * Constructors + destructors
48 /// Default constructor.
49 KwCssStyleStates();
51 /// Copy constructor.
52 KwCssStyleStates(const KwCssStyleStates& other);
54 /// Destructor.
55 virtual ~KwCssStyleStates();
58 * Main interface
61 /// Clear all states.
62 void clear();
64 /// Get a state.
65 const KwCssAbstractStyleState* getRawStyle(QString name) const;
67 /// Get the value of a state.
68 template <typename T>
69 T getStyle(QString name) const
71 const KwCssAbstractStyleState* rawStyle = getRawStyle(name);
72 if (0 != rawStyle)
74 const KwCssStyleState<T>* style = dynamic_cast<const KwCssStyleState<T>*>(rawStyle);
75 assert(0 != style &&"style with incorrect type");
76 if (0 != style)
78 return style->getValue();
81 return T();
85 * Operators
88 /// Copy assignment operator.
89 KwCssStyleStates& operator = (const KwCssStyleStates& other);
91 /// Index into styles mapping.
92 KwCssAbstractStyleState*& operator [] (QString name);
94 private:
97 * Types
100 /// Dictionary of strings to styles.
101 typedef QHash<QString, KwCssAbstractStyleState*> StyleStateDictionary;
104 * Variables
107 /// The style properties.
108 StyleStateDictionary m_styleStates;
112 #endif // _KwCssStyleStates_h_