Convertion to CSS-like format of style sheets at top level (criteria, not styles)
[kworship.git] / kworship / css / KwCssStyleRule.h
blob5377f705fff55249c3c7b4d4d14b327aa1924a97
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 _KwCssStyleRule_h_
21 #define _KwCssStyleRule_h_
23 /**
24 * @file KwCssStyleRule.h
25 * @brief Rule for apply cascading styles.
26 * @author James Hogan <james@albanarts.com>
29 #include "KwCssScopeKey.h"
30 #include "KwCssStyles.h"
32 #include "CountedReference.h"
34 #include <QString>
35 #include <QStringList>
36 #include <QSet>
37 #include <QList>
39 /// Rule for apply cascading styles.
40 class KwCssStyleRule
42 public:
45 * Types
48 /// List of keys.
49 typedef QList<KwCssScopeKey> KeyList;
51 /// Set of strings.
52 typedef QSet<QString> StringSet;
55 * Constructors + destructors
58 /// Default constructor.
59 KwCssStyleRule();
61 /// Destructor.
62 virtual ~KwCssStyleRule();
65 * Main interface.
68 /// Set the set of critieria keys.
69 void setCriteriaKeys(const KeyList& keys);
71 /// Set the set of required classes.
72 void setCriteriaClasses(const StringSet& classes);
74 /// Set a style.
75 void setRawStyle(QString name, KwCssAbstractStyle* style);
77 /// Set a style of a particular type.
78 template <typename T>
79 void setStyle(QString name, const T& value)
81 m_styles->setStyle<T>(name, value);
85 * Accessors
88 /// Get the list of criteria keys.
89 KeyList& getCriteriaKeys();
91 /// Get the set of criteria classes.
92 StringSet& getCriteriaClasses();
94 /// Get the list of included styles.
95 const StringSet& getIncludedStyles() const;
97 /// Get the styles.
98 const ReferenceCountedExtension<KwCssStyles>* getStyles() const;
100 /// Convert to CSS-like format.
101 QString toString() const;
103 private:
106 * Matching criteria
109 /// List of (sequences of scope keys to match in order).
110 KeyList m_criteriaKeys;
112 /// Classes required to match.
113 StringSet m_criteriaClasses;
116 * Variables
119 /// Names of included classes.
120 StringSet m_includedStyles;
122 /// The styles.
123 Reference<ReferenceCountedExtension<KwCssStyles> > m_styles;
126 #endif // _KwCssStyleRule_h_