1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
36 #include <FullySpecifiedType.h>
41 using namespace CPlusPlus;
42 using CPlusPlus::Icons;
45 : _classIcon(QLatin1String(":/codemodel/images/class.png")),
46 _enumIcon(QLatin1String(":/codemodel/images/enum.png")),
47 _enumeratorIcon(QLatin1String(":/codemodel/images/enumerator.png")),
48 _funcPublicIcon(QLatin1String(":/codemodel/images/func.png")),
49 _funcProtectedIcon(QLatin1String(":/codemodel/images/func_prot.png")),
50 _funcPrivateIcon(QLatin1String(":/codemodel/images/func_priv.png")),
51 _namespaceIcon(QLatin1String(":/codemodel/images/namespace.png")),
52 _varPublicIcon(QLatin1String(":/codemodel/images/var.png")),
53 _varProtectedIcon(QLatin1String(":/codemodel/images/var_prot.png")),
54 _varPrivateIcon(QLatin1String(":/codemodel/images/var_priv.png")),
55 _signalIcon(QLatin1String(":/codemodel/images/signal.png")),
56 _slotPublicIcon(QLatin1String(":/codemodel/images/slot.png")),
57 _slotProtectedIcon(QLatin1String(":/codemodel/images/slot_prot.png")),
58 _slotPrivateIcon(QLatin1String(":/codemodel/images/slot_priv.png")),
59 _keywordIcon(QLatin1String(":/codemodel/images/keyword.png")),
60 _macroIcon(QLatin1String(":/codemodel/images/macro.png"))
64 QIcon Icons::iconForSymbol(const Symbol *symbol) const
66 return iconForType(iconTypeForSymbol(symbol));
69 QIcon Icons::keywordIcon() const
74 QIcon Icons::macroIcon() const
79 Icons::IconType Icons::iconTypeForSymbol(const Symbol *symbol)
81 if (const Template *templ = symbol->asTemplate()) {
82 if (Symbol *decl = templ->declaration())
83 return iconTypeForSymbol(decl);
86 FullySpecifiedType symbolType = symbol->type();
87 if (symbol->isFunction() || (symbol->isDeclaration() && symbolType &&
88 symbolType->isFunctionType()))
90 const Function *function = symbol->asFunction();
92 function = symbol->type()->asFunctionType();
94 if (function->isSlot()) {
95 if (function->isPublic()) {
96 return SlotPublicIconType;
97 } else if (function->isProtected()) {
98 return SlotProtectedIconType;
99 } else if (function->isPrivate()) {
100 return SlotPrivateIconType;
102 } else if (function->isSignal()) {
103 return SignalIconType;
104 } else if (symbol->isPublic()) {
105 return FuncPublicIconType;
106 } else if (symbol->isProtected()) {
107 return FuncProtectedIconType;
108 } else if (symbol->isPrivate()) {
109 return FuncPrivateIconType;
111 } else if (symbol->enclosingScope() && symbol->enclosingScope()->isEnum()) {
112 return EnumeratorIconType;
113 } else if (symbol->isDeclaration() || symbol->isArgument()) {
114 if (symbol->isPublic()) {
115 return VarPublicIconType;
116 } else if (symbol->isProtected()) {
117 return VarProtectedIconType;
118 } else if (symbol->isPrivate()) {
119 return VarPrivateIconType;
121 } else if (symbol->isEnum()) {
123 } else if (symbol->isClass() || symbol->isForwardClassDeclaration()) {
124 return ClassIconType;
125 } else if (symbol->isObjCClass() || symbol->isObjCForwardClassDeclaration()) {
126 return ClassIconType;
127 } else if (symbol->isObjCProtocol() || symbol->isObjCForwardProtocolDeclaration()) {
128 return ClassIconType;
129 } else if (symbol->isObjCMethod()) {
130 return FuncPublicIconType;
131 } else if (symbol->isNamespace()) {
132 return NamespaceIconType;
133 } else if (symbol->isUsingNamespaceDirective() ||
134 symbol->isUsingDeclaration()) {
135 // TODO: Might be nice to have a different icons for these things
136 return NamespaceIconType;
139 return UnknownIconType;
142 QIcon Icons::iconForType(IconType type) const
149 case EnumeratorIconType:
150 return _enumeratorIcon;
151 case FuncPublicIconType:
152 return _funcPublicIcon;
153 case FuncProtectedIconType:
154 return _funcProtectedIcon;
155 case FuncPrivateIconType:
156 return _funcPrivateIcon;
157 case NamespaceIconType:
158 return _namespaceIcon;
159 case VarPublicIconType:
160 return _varPublicIcon;
161 case VarProtectedIconType:
162 return _varProtectedIcon;
163 case VarPrivateIconType:
164 return _varPrivateIcon;
167 case SlotPublicIconType:
168 return _slotPublicIcon;
169 case SlotProtectedIconType:
170 return _slotProtectedIcon;
171 case SlotPrivateIconType:
172 return _slotPrivateIcon;
173 case KeywordIconType: