diff options
author | Francois Ferrand <thetypz@gmail.com> | 2012-06-15 11:28:18 +0200 |
---|---|---|
committer | Leandro Melo <leandro.melo@nokia.com> | 2012-08-21 08:58:52 +0200 |
commit | 9c7b96c663ab3234c77a83124ff547f72f52d766 (patch) | |
tree | 8d737bf2ed255a57629260d32ffc87769a6d1981 /src/libs/cplusplus/OverviewModel.cpp | |
parent | a68352f013514aeba8a1d1cc111eea181f035b85 (diff) | |
download | qt-creator-9c7b96c663ab3234c77a83124ff547f72f52d766.tar.gz |
Fix display of templates in outline.
Change-Id: I8b099c8234fac55ef0de17b014c89fbe02534bf4
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
Diffstat (limited to 'src/libs/cplusplus/OverviewModel.cpp')
-rw-r--r-- | src/libs/cplusplus/OverviewModel.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libs/cplusplus/OverviewModel.cpp b/src/libs/cplusplus/OverviewModel.cpp index c79584fbe7..0d5d8b5326 100644 --- a/src/libs/cplusplus/OverviewModel.cpp +++ b/src/libs/cplusplus/OverviewModel.cpp @@ -76,6 +76,10 @@ QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent) Symbol *parentSymbol = static_cast<Symbol *>(parent.internalPointer()); Q_ASSERT(parentSymbol); + if (Template *t = parentSymbol->asTemplate()) + if (Symbol *templateParentSymbol = t->declaration()) + parentSymbol = templateParentSymbol; + Scope *scope = parentSymbol->asScope(); Q_ASSERT(scope != 0); return createIndex(row, 0, scope->memberAt(row)); @@ -89,6 +93,8 @@ QModelIndex OverviewModel::parent(const QModelIndex &child) const return QModelIndex(); if (Scope *scope = symbol->enclosingScope()) { + if (scope->isTemplate() && scope->enclosingScope()) + scope = scope->enclosingScope(); if (scope->enclosingScope()) { QModelIndex index; if (scope->enclosingScope() && scope->enclosingScope()->enclosingScope()) // the parent doesn't have a parent @@ -113,6 +119,10 @@ int OverviewModel::rowCount(const QModelIndex &parent) const Symbol *parentSymbol = static_cast<Symbol *>(parent.internalPointer()); Q_ASSERT(parentSymbol); + if (Template *t = parentSymbol->asTemplate()) + if (Symbol *templateParentSymbol = t->declaration()) + parentSymbol = templateParentSymbol; + if (Scope *parentScope = parentSymbol->asScope()) { if (!parentScope->isFunction() && !parentScope->isObjCMethod()) { return parentScope->memberCount(); @@ -168,6 +178,14 @@ QVariant OverviewModel::data(const QModelIndex &index, int role) const } if (symbol->isObjCPropertyDeclaration()) name = QLatin1String("@property ") + name; + if (Template *t = symbol->asTemplate()) + if (Symbol *templateDeclaration = t->declaration()) { + QStringList parameters; + for (unsigned i = 0; i < t->templateParameterCount(); ++i) + parameters.append(_overview.prettyName(t->templateParameterAt(i)->name())); + name += QLatin1Char('<') + parameters.join(QLatin1String(", ")) + QLatin1Char('>'); + symbol = templateDeclaration; + } if (symbol->isObjCMethod()) { ObjCMethod *method = symbol->asObjCMethod(); if (method->isStatic()) |