6 * @brief Cascading style scope.
7 * @author James Hogan <james@albanarts.com>
10 #include "KwCssScopeKey.h"
11 #include "KwCssStyleSheet.h"
12 #include "KwCssStyles.h"
13 #include "KwCssStyleStates.h"
15 #include <QStringList>
20 class KwCssStyleSheet
;
22 /// Cascading style scope.
28 * Constructors + destructors
31 /// Primary constructor.
32 KwCssScope(KwCssScope
* parent
= 0);
35 virtual ~KwCssScope();
41 /// Add a stylesheet for this scope.
42 void addStyleSheet(KwCssStyleSheet
* styleSheet
);
44 /// Set an explicit style.
46 void setExplicitStyle(QString name
, const T
& value
)
48 m_styles
.setStyle
<T
>(name
, value
);
52 /// Add a class to this scope.
53 void addClass(QString className
);
55 /// Get all the styles included in this scope.
56 const KwCssStyleStates
& getStyles() const;
58 /// Recalculate all styles.
59 void recalculateStyles();
65 /// Get the type id corresponding to this type.
66 virtual KwCssScopeKey::ScopeTypeId
getTypeId() const;
72 /// Get explicit styles.
73 const KwCssStyles
& getExplicitStyles() const;
75 /// Get the scope's key.
76 KwCssScopeKey
getKey() const;
78 /// Find whether a scope key matches this scope.
79 bool isKeyMatching(KwCssScopeKey key
) const;
85 /// Set the parent scope.
86 void setParentScope(KwCssScope
* parent
);
95 typedef QSet
<KwCssScope
*> ScopeSet
;
98 typedef QSet
<QString
> StringSet
;
100 /// List of style sheets.
101 typedef QList
<KwCssStyleSheet
*> StyleSheetList
;
108 KwCssScope
* m_parentScope
;
110 /// Set of child scopes.
111 ScopeSet m_childScopes
;
113 /// Name of the scope.
114 KwCssScopeKey::ScopeName m_name
;
120 /// Classes enabled by default in this scope.
124 StyleSheetList m_styleSheets
;
126 /// Explicit style overrides.
127 KwCssStyles m_styles
;
134 KwCssStyleStates m_cachedStyles
;
136 /// Cached stylesheet accumulation.
137 KwCssStyleSheet m_cachedStyleSheet
;
139 /// Cached total class list.
140 StringSet m_cachedClasses
;
143 #endif // _KwCssScope_h_