diff --git a/src/libs/cplusplus/Icons.cpp b/src/libs/cplusplus/Icons.cpp index 2efa8b3337547e7a8160edaab5a8c81a4fdc992c..a3bb5a38ef3514579bbe920ca228307fcfd94ff1 100644 --- a/src/libs/cplusplus/Icons.cpp +++ b/src/libs/cplusplus/Icons.cpp @@ -58,6 +58,21 @@ Icons::Icons() } QIcon Icons::iconForSymbol(const Symbol *symbol) const +{ + return iconForType(iconTypeForSymbol(symbol)); +} + +QIcon Icons::keywordIcon() const +{ + return _keywordIcon; +} + +QIcon Icons::macroIcon() const +{ + return _macroIcon; +} + +Icons::IconType Icons::iconTypeForSymbol(const Symbol *symbol) { FullySpecifiedType symbolType = symbol->type(); if (symbol->isFunction() || (symbol->isDeclaration() && symbolType && @@ -69,58 +84,89 @@ QIcon Icons::iconForSymbol(const Symbol *symbol) const if (function->isSlot()) { if (function->isPublic()) { - return _slotPublicIcon; + return SlotPublicIconType; } else if (function->isProtected()) { - return _slotProtectedIcon; + return SlotProtectedIconType; } else if (function->isPrivate()) { - return _slotPrivateIcon; + return SlotPrivateIconType; } } else if (function->isSignal()) { - return _signalIcon; + return SignalIconType; } else if (symbol->isPublic()) { - return _funcPublicIcon; + return FuncPublicIconType; } else if (symbol->isProtected()) { - return _funcProtectedIcon; + return FuncProtectedIconType; } else if (symbol->isPrivate()) { - return _funcPrivateIcon; + return FuncPrivateIconType; } } else if (symbol->scope() && symbol->scope()->isEnumScope()) { - return _enumeratorIcon; + return EnumeratorIconType; } else if (symbol->isDeclaration() || symbol->isArgument()) { if (symbol->isPublic()) { - return _varPublicIcon; + return VarPublicIconType; } else if (symbol->isProtected()) { - return _varProtectedIcon; + return VarProtectedIconType; } else if (symbol->isPrivate()) { - return _varPrivateIcon; + return VarPrivateIconType; } } else if (symbol->isEnum()) { - return _enumIcon; + return EnumIconType; } else if (symbol->isClass() || symbol->isForwardClassDeclaration()) { - return _classIcon; + return ClassIconType; } else if (symbol->isObjCClass() || symbol->isObjCForwardClassDeclaration()) { - return _classIcon; + return ClassIconType; } else if (symbol->isObjCProtocol() || symbol->isObjCForwardProtocolDeclaration()) { - return _classIcon; + return ClassIconType; } else if (symbol->isObjCMethod()) { - return _funcPublicIcon; + return FuncPublicIconType; } else if (symbol->isNamespace()) { - return _namespaceIcon; + return NamespaceIconType; } else if (symbol->isUsingNamespaceDirective() || symbol->isUsingDeclaration()) { // TODO: Might be nice to have a different icons for these things - return _namespaceIcon; + return NamespaceIconType; } - return QIcon(); -} - -QIcon Icons::keywordIcon() const -{ - return _keywordIcon; + return UnknownIconType; } -QIcon Icons::macroIcon() const +QIcon Icons::iconForType(IconType type) const { - return _macroIcon; + switch(type) { + case ClassIconType: + return _classIcon; + case EnumIconType: + return _enumIcon; + case EnumeratorIconType: + return _enumeratorIcon; + case FuncPublicIconType: + return _funcPublicIcon; + case FuncProtectedIconType: + return _funcProtectedIcon; + case FuncPrivateIconType: + return _funcPrivateIcon; + case NamespaceIconType: + return _namespaceIcon; + case VarPublicIconType: + return _varPublicIcon; + case VarProtectedIconType: + return _varProtectedIcon; + case VarPrivateIconType: + return _varPrivateIcon; + case SignalIconType: + return _signalIcon; + case SlotPublicIconType: + return _slotPublicIcon; + case SlotProtectedIconType: + return _slotProtectedIcon; + case SlotPrivateIconType: + return _slotPrivateIcon; + case KeywordIconType: + return _keywordIcon; + case MacroIconType: + return _macroIcon; + default: + break; + } + return QIcon(); } diff --git a/src/libs/cplusplus/Icons.h b/src/libs/cplusplus/Icons.h index 4fd0d694239cce43357b00d730eccff3dfc78519..79c2ff965605a202a22551ee625779403c60d7a0 100644 --- a/src/libs/cplusplus/Icons.h +++ b/src/libs/cplusplus/Icons.h @@ -48,6 +48,29 @@ public: QIcon keywordIcon() const; QIcon macroIcon() const; + enum IconType { + ClassIconType = 0, + EnumIconType, + EnumeratorIconType, + FuncPublicIconType, + FuncProtectedIconType, + FuncPrivateIconType, + NamespaceIconType, + VarPublicIconType, + VarProtectedIconType, + VarPrivateIconType, + SignalIconType, + SlotPublicIconType, + SlotProtectedIconType, + SlotPrivateIconType, + KeywordIconType, + MacroIconType, + UnknownIconType + }; + + static IconType iconTypeForSymbol(const Symbol *symbol); + QIcon iconForType(IconType type) const; + private: QIcon _classIcon; QIcon _enumIcon;