1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
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. *
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. *
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 _KwCssScopeKey_h_
21 #define _KwCssScopeKey_h_
24 * @file KwCssScopeKey.h
25 * @brief Scope type and name pair.
26 * @author James Hogan <james@albanarts.com>
29 #include <kdemacros.h>
35 /// Scope type and name pair.
36 class KDE_EXPORT KwCssScopeKey
44 /// Scope type name type.
45 typedef QString ScopeTypeName
;
47 /// Scope type identifier type.
48 typedef int ScopeTypeId
;
51 typedef QString ScopeName
;
54 * Static scope type registration
57 /// Register a type of scope.
58 static ScopeTypeId
registerScopeType(ScopeTypeName typeName
);
60 /// Get the id for a scope type name.
61 static ScopeTypeId
getScopeTypeId(ScopeTypeName typeName
);
63 /// Get the name for a scope type id.
64 static ScopeTypeName
getScopeTypeName(ScopeTypeId typeId
);
66 /// Find whether a scope type id is valid.
67 static bool isScopeTypeValid(ScopeTypeId typeId
);
75 /// Mapping from scope type names to ids.
76 typedef QHash
<ScopeTypeName
,ScopeTypeId
> ScopeTypeNameIdMapping
;
78 /// Mapping from scope type ids to names.
79 typedef QVector
<ScopeTypeName
> ScopeTypeIdNameMapping
;
86 static ScopeTypeId s_lastValidTypeId
;
88 /// Scope type names to scope type ids.
89 static ScopeTypeNameIdMapping s_scopeTypeNameToId
;
91 /// Scope type id to scope type name.
92 static ScopeTypeIdNameMapping s_scopeTypeIdToName
;
97 * Constructors + destructors
100 /// Primary constructor.
101 KwCssScopeKey(ScopeTypeName typeId
, ScopeName name
= "");
103 /// Primary constructor.
104 KwCssScopeKey(ScopeTypeId typeId
, ScopeName name
= "");
106 /// Non virtual destructor.
113 /// Find whether the type part of the key is specified.
114 bool isTypeSpecified() const;
116 /// Get the scope type id.
117 ScopeTypeId
getTypeId() const;
119 /// Get the scope type name.
120 ScopeTypeName
getTypeName() const;
122 /// Find whether the name part of the key is specified.
123 bool isNameSpecified() const;
125 /// Get the scope name.
126 ScopeName
getName() const;
135 ScopeTypeId m_typeId
;
142 #endif // _KwCssScopeKey_h_