forked from qt-creator/qt-creator
Separate scope in classes quickopen filter
The scope of the classes is now separated and displayed in the second column, and not included in the search.
This commit is contained in:
@@ -40,7 +40,8 @@ using namespace CPlusPlus;
|
||||
using namespace CppTools::Internal;
|
||||
|
||||
SearchSymbols::SearchSymbols():
|
||||
symbolsToSearchFor(Classes | Functions | Enums)
|
||||
symbolsToSearchFor(Classes | Functions | Enums),
|
||||
separateScope(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -49,6 +50,11 @@ void SearchSymbols::setSymbolsToSearchFor(SymbolTypes types)
|
||||
symbolsToSearchFor = types;
|
||||
}
|
||||
|
||||
void SearchSymbols::setSeparateScope(bool separateScope)
|
||||
{
|
||||
this->separateScope = separateScope;
|
||||
}
|
||||
|
||||
QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString &scope)
|
||||
{
|
||||
QString previousScope = switchScope(scope);
|
||||
@@ -73,13 +79,12 @@ bool SearchSymbols::visit(Enum *symbol)
|
||||
return false;
|
||||
|
||||
QString name = symbolName(symbol);
|
||||
QString previousScope = switchScope(name);
|
||||
QIcon icon = icons.iconForSymbol(symbol);
|
||||
QString scopedName = scopedSymbolName(name);
|
||||
QString previousScope = switchScope(scopedName);
|
||||
appendItem(separateScope ? name : scopedName,
|
||||
separateScope ? previousScope : QString(),
|
||||
ModelItemInfo::Enum, symbol);
|
||||
Scope *members = symbol->members();
|
||||
items.append(ModelItemInfo(name, QString(), ModelItemInfo::Enum,
|
||||
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
|
||||
symbol->line(),
|
||||
icon));
|
||||
for (unsigned i = 0; i < members->symbolCount(); ++i) {
|
||||
accept(members->symbolAt(i));
|
||||
}
|
||||
@@ -93,18 +98,18 @@ bool SearchSymbols::visit(Function *symbol)
|
||||
return false;
|
||||
|
||||
QString name = symbolName(symbol);
|
||||
QString type = overview.prettyType(symbol->type());
|
||||
QIcon icon = icons.iconForSymbol(symbol);
|
||||
items.append(ModelItemInfo(name, type, ModelItemInfo::Method,
|
||||
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
|
||||
symbol->line(),
|
||||
icon));
|
||||
QString scopedName = scopedSymbolName(name);
|
||||
QString type = overview.prettyType(symbol->type(),
|
||||
separateScope ? symbol->name() : 0);
|
||||
appendItem(separateScope ? type : scopedName,
|
||||
separateScope ? _scope : type,
|
||||
ModelItemInfo::Method, symbol);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SearchSymbols::visit(Namespace *symbol)
|
||||
{
|
||||
QString name = symbolName(symbol);
|
||||
QString name = findOrInsert(scopedSymbolName(symbol));
|
||||
QString previousScope = switchScope(name);
|
||||
Scope *members = symbol->members();
|
||||
for (unsigned i = 0; i < members->symbolCount(); ++i) {
|
||||
@@ -118,12 +123,9 @@ bool SearchSymbols::visit(Namespace *symbol)
|
||||
bool SearchSymbols::visit(Declaration *symbol)
|
||||
{
|
||||
if (symbol->type()->isFunction()) {
|
||||
QString name = symbolName(symbol);
|
||||
QString name = scopedSymbolName(symbol);
|
||||
QString type = overview.prettyType(symbol->type());
|
||||
//QIcon icon = ...;
|
||||
items.append(ModelItemInfo(name, type, ModelItemInfo::Method,
|
||||
QString::fromUtf8(symbol->fileName(), symbol->line()),
|
||||
symbol->line()));
|
||||
appendItems(name, type, ModelItemInfo::Method, symbol->fileName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -135,12 +137,11 @@ bool SearchSymbols::visit(Class *symbol)
|
||||
return false;
|
||||
|
||||
QString name = symbolName(symbol);
|
||||
QString previousScope = switchScope(name);
|
||||
QIcon icon = icons.iconForSymbol(symbol);
|
||||
items.append(ModelItemInfo(name, QString(), ModelItemInfo::Class,
|
||||
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
|
||||
symbol->line(),
|
||||
icon));
|
||||
QString scopedName = scopedSymbolName(name);
|
||||
QString previousScope = switchScope(scopedName);
|
||||
appendItem(separateScope ? name : scopedName,
|
||||
separateScope ? previousScope : QString(),
|
||||
ModelItemInfo::Class, symbol);
|
||||
Scope *members = symbol->members();
|
||||
for (unsigned i = 0; i < members->symbolCount(); ++i) {
|
||||
accept(members->symbolAt(i));
|
||||
@@ -149,11 +150,22 @@ bool SearchSymbols::visit(Class *symbol)
|
||||
return false;
|
||||
}
|
||||
|
||||
QString SearchSymbols::symbolName(const Symbol *symbol) const
|
||||
QString SearchSymbols::scopedSymbolName(const QString &symbolName) const
|
||||
{
|
||||
QString name = _scope;
|
||||
if (! name.isEmpty())
|
||||
name += QLatin1String("::");
|
||||
name += symbolName;
|
||||
return name;
|
||||
}
|
||||
|
||||
QString SearchSymbols::scopedSymbolName(const Symbol *symbol) const
|
||||
{
|
||||
return scopedSymbolName(symbolName(symbol));
|
||||
}
|
||||
|
||||
QString SearchSymbols::symbolName(const Symbol *symbol) const
|
||||
{
|
||||
QString symbolName = overview.prettyName(symbol->name());
|
||||
if (symbolName.isEmpty()) {
|
||||
QString type;
|
||||
@@ -176,6 +188,17 @@ QString SearchSymbols::symbolName(const Symbol *symbol) const
|
||||
symbolName += type;
|
||||
symbolName += QLatin1String(">");
|
||||
}
|
||||
name += symbolName;
|
||||
return name;
|
||||
return symbolName;
|
||||
}
|
||||
|
||||
void SearchSymbols::appendItem(const QString &name,
|
||||
const QString &info,
|
||||
ModelItemInfo::ItemType type,
|
||||
const CPlusPlus::Symbol *symbol)
|
||||
{
|
||||
const QIcon icon = icons.iconForSymbol(symbol);
|
||||
items.append(ModelItemInfo(name, info, type,
|
||||
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
|
||||
symbol->line(),
|
||||
icon));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user