2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "Icons.h"
|
|
|
|
|
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <cplusplus/FullySpecifiedType.h>
|
|
|
|
|
#include <cplusplus/Scope.h>
|
|
|
|
|
#include <cplusplus/Symbols.h>
|
|
|
|
|
#include <cplusplus/Type.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace CPlusPlus;
|
|
|
|
|
using CPlusPlus::Icons;
|
|
|
|
|
|
2016-04-06 10:08:01 +02:00
|
|
|
QIcon Icons::iconForSymbol(const Symbol *symbol)
|
2010-07-16 11:18:29 +02:00
|
|
|
{
|
|
|
|
|
return iconForType(iconTypeForSymbol(symbol));
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-06 10:08:01 +02:00
|
|
|
QIcon Icons::keywordIcon()
|
2010-07-16 11:18:29 +02:00
|
|
|
{
|
2016-04-06 10:08:01 +02:00
|
|
|
return iconForType(KeywordIconType);
|
2010-07-16 11:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
2016-04-06 10:08:01 +02:00
|
|
|
QIcon Icons::macroIcon()
|
2010-07-16 11:18:29 +02:00
|
|
|
{
|
2016-04-06 10:08:01 +02:00
|
|
|
return iconForType(MacroIconType);
|
2010-07-16 11:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Icons::IconType Icons::iconTypeForSymbol(const Symbol *symbol)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-08-13 18:10:36 +02:00
|
|
|
if (const Template *templ = symbol->asTemplate()) {
|
|
|
|
|
if (Symbol *decl = templ->declaration())
|
|
|
|
|
return iconTypeForSymbol(decl);
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-09 17:44:06 +01:00
|
|
|
FullySpecifiedType symbolType = symbol->type();
|
|
|
|
|
if (symbol->isFunction() || (symbol->isDeclaration() && symbolType &&
|
|
|
|
|
symbolType->isFunctionType()))
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-05 12:21:18 +01:00
|
|
|
const Function *function = symbol->asFunction();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!function)
|
2009-02-09 17:44:06 +01:00
|
|
|
function = symbol->type()->asFunctionType();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (function->isSlot()) {
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (function->isPublic())
|
2010-07-16 11:18:29 +02:00
|
|
|
return SlotPublicIconType;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else if (function->isProtected())
|
2010-07-16 11:18:29 +02:00
|
|
|
return SlotProtectedIconType;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else if (function->isPrivate())
|
2010-07-16 11:18:29 +02:00
|
|
|
return SlotPrivateIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (function->isSignal()) {
|
2010-07-16 11:18:29 +02:00
|
|
|
return SignalIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (symbol->isPublic()) {
|
2014-10-30 19:43:48 +03:00
|
|
|
return symbol->isStatic() ? FuncPublicStaticIconType : FuncPublicIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (symbol->isProtected()) {
|
2014-10-30 19:43:48 +03:00
|
|
|
return symbol->isStatic() ? FuncProtectedStaticIconType : FuncProtectedIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (symbol->isPrivate()) {
|
2014-10-30 19:43:48 +03:00
|
|
|
return symbol->isStatic() ? FuncPrivateStaticIconType : FuncPrivateIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-08-26 16:16:22 +02:00
|
|
|
} else if (symbol->enclosingScope() && symbol->enclosingScope()->isEnum()) {
|
2010-07-16 11:18:29 +02:00
|
|
|
return EnumeratorIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (symbol->isDeclaration() || symbol->isArgument()) {
|
2014-10-30 19:43:48 +03:00
|
|
|
if (symbol->isPublic()) {
|
|
|
|
|
return symbol->isStatic() ? VarPublicStaticIconType : VarPublicIconType;
|
|
|
|
|
} else if (symbol->isProtected()) {
|
|
|
|
|
return symbol->isStatic() ? VarProtectedStaticIconType : VarProtectedIconType;
|
|
|
|
|
} else if (symbol->isPrivate()) {
|
|
|
|
|
return symbol->isStatic() ? VarPrivateStaticIconType : VarPrivateIconType;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (symbol->isEnum()) {
|
2010-07-16 11:18:29 +02:00
|
|
|
return EnumIconType;
|
2015-02-24 11:33:39 +01:00
|
|
|
} else if (symbol->isForwardClassDeclaration()) {
|
|
|
|
|
return ClassIconType; // TODO: Store class key in ForwardClassDeclaration
|
|
|
|
|
} else if (const Class *klass = symbol->asClass()) {
|
|
|
|
|
return klass->isStruct() ? StructIconType : ClassIconType;
|
2009-07-28 16:34:15 +02:00
|
|
|
} else if (symbol->isObjCClass() || symbol->isObjCForwardClassDeclaration()) {
|
2010-07-16 11:18:29 +02:00
|
|
|
return ClassIconType;
|
2009-07-28 16:34:15 +02:00
|
|
|
} else if (symbol->isObjCProtocol() || symbol->isObjCForwardProtocolDeclaration()) {
|
2010-07-16 11:18:29 +02:00
|
|
|
return ClassIconType;
|
2009-08-05 18:30:18 +02:00
|
|
|
} else if (symbol->isObjCMethod()) {
|
2010-07-16 11:18:29 +02:00
|
|
|
return FuncPublicIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (symbol->isNamespace()) {
|
2010-07-16 11:18:29 +02:00
|
|
|
return NamespaceIconType;
|
2013-04-04 11:27:06 +04:00
|
|
|
} else if (symbol->isTypenameArgument()) {
|
|
|
|
|
return ClassIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (symbol->isUsingNamespaceDirective() ||
|
|
|
|
|
symbol->isUsingDeclaration()) {
|
|
|
|
|
// TODO: Might be nice to have a different icons for these things
|
2010-07-16 11:18:29 +02:00
|
|
|
return NamespaceIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 11:18:29 +02:00
|
|
|
return UnknownIconType;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2016-04-06 10:08:01 +02:00
|
|
|
QIcon Icons::iconForType(IconType type)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-11-28 20:44:03 +02:00
|
|
|
switch (type) {
|
2016-04-06 10:08:01 +02:00
|
|
|
case ClassIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/class.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case StructIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/struct.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case EnumIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/enum.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case EnumeratorIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/enumerator.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case FuncPublicIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/func.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case FuncProtectedIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/func_prot.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case FuncPrivateIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/func_priv.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case FuncPublicStaticIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/func_st.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case FuncProtectedStaticIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/func_prot_st.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case FuncPrivateStaticIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/func_priv_st.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case NamespaceIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/namespace.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case VarPublicIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/var.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case VarProtectedIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/var_prot.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case VarPrivateIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/var_priv.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case VarPublicStaticIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/var_st.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case VarProtectedStaticIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/var_prot_st.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case VarPrivateStaticIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/var_priv_st.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case SignalIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/signal.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case SlotPublicIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/slot.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case SlotProtectedIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/slot_prot.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case SlotPrivateIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/slot_priv.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case KeywordIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/keyword.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
case MacroIconType: {
|
|
|
|
|
const static QIcon icon(QLatin1String(":/codemodel/images/macro.png"));
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
2010-07-16 11:18:29 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return QIcon();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|