Basic import of styles from xionworx into css system
[kworship.git] / kworship / css / KwCssStyleRule.h
blobbe5bf0c1778116d09b7a81f7ca3824ad1e103df4
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 <kdemacros.h>
36 #include <QString>
37 #include <QStringList>
38 #include <QSet>
39 #include <QList>
41 /// Rule for apply cascading styles.
42 class KDE_EXPORT KwCssStyleRule
44 public:
47 * Types
50 /// List of keys.
51 typedef QList<KwCssScopeKey> KeyList;
53 /// Set of strings.
54 typedef QSet<QString> StringSet;
57 * Constructors + destructors
60 /// Default constructor.
61 KwCssStyleRule();
63 /// Destructor.
64 virtual ~KwCssStyleRule();
67 * Main interface.
70 /// Set the set of critieria keys.
71 void setCriteriaKeys(const KeyList& keys);
73 /// Set the set of required classes.
74 void setCriteriaClasses(const StringSet& classes);
76 /// Set the set of included classes.
77 void setIncludedStyles(const StringSet& includes);
79 /// Set a style.
80 void setRawStyle(const QString& name, KwCssAbstractStyle* style);
82 /// Set a style of a particular type.
83 template <typename T>
84 void setStyle(const QString& name, const T& value)
86 m_styles->setStyle<T>(name, value);
90 * Accessors
93 /// Get the list of criteria keys.
94 KeyList& getCriteriaKeys();
96 /// Get the set of criteria classes.
97 StringSet& getCriteriaClasses();
99 /// Get the list of included styles.
100 const StringSet& getIncludedStyles() const;
102 /// Get the styles.
103 ReferenceCountedExtension<KwCssStyles>* getStyles() const;
105 /// Convert to CSS-like format.
106 QString toString() const;
108 private:
111 * Matching criteria
114 /// List of (sequences of scope keys to match in order).
115 KeyList m_criteriaKeys;
117 /// Classes required to match.
118 StringSet m_criteriaClasses;
121 * Variables
124 /// Names of included classes.
125 StringSet m_includedStyles;
127 /// The styles.
128 Reference<ReferenceCountedExtension<KwCssStyles> > m_styles;
131 #endif // _KwCssStyleRule_h_