Commit 4e76b54d authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Use QFlags for indicating symbols to search for

parent 923bfa52
......@@ -40,13 +40,13 @@ using namespace CPlusPlus;
using namespace CppTools::Internal;
SearchSymbols::SearchSymbols():
symbolsToSearchFor(ClassesMethodsFunctionsAndEnums)
symbolsToSearchFor(Classes | Functions | Enums)
{
}
void SearchSymbols::setSymbolsToSearchFor(SymbolType type)
void SearchSymbols::setSymbolsToSearchFor(SymbolTypes types)
{
symbolsToSearchFor = type;
symbolsToSearchFor = types;
}
QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString &scope)
......@@ -69,7 +69,7 @@ QString SearchSymbols::switchScope(const QString &scope)
bool SearchSymbols::visit(Enum *symbol)
{
if (symbolsToSearchFor != ClassesMethodsFunctionsAndEnums)
if (!(symbolsToSearchFor & Enums))
return false;
QString name = symbolName(symbol);
......@@ -89,7 +89,7 @@ bool SearchSymbols::visit(Enum *symbol)
bool SearchSymbols::visit(Function *symbol)
{
if (symbolsToSearchFor != ClassesMethodsFunctionsAndEnums)
if (!(symbolsToSearchFor & Functions))
return false;
QString name = symbolName(symbol);
......@@ -131,6 +131,9 @@ bool SearchSymbols::visit(Declaration *symbol)
bool SearchSymbols::visit(Class *symbol)
{
if (!(symbolsToSearchFor & Classes))
return false;
QString name = symbolName(symbol);
QString previousScope = switchScope(name);
QIcon icon = icons.iconForSymbol(symbol);
......
......@@ -80,15 +80,16 @@ class SearchSymbols: public std::unary_function<CPlusPlus::Document::Ptr, QList<
protected CPlusPlus::SymbolVisitor
{
public:
// TODO: Probably should use QFlags
enum SymbolType {
Classes,
ClassesMethodsFunctionsAndEnums
Classes = 0x1,
Functions = 0x2,
Enums = 0x4
};
Q_DECLARE_FLAGS(SymbolTypes, SymbolType)
SearchSymbols();
void setSymbolsToSearchFor(SymbolType type);
void setSymbolsToSearchFor(SymbolTypes types);
QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc)
{ return operator()(doc, QString()); }
......@@ -117,9 +118,11 @@ private:
CPlusPlus::Overview overview;
CPlusPlus::Icons icons;
QList<ModelItemInfo> items;
SymbolType symbolsToSearchFor;
SymbolTypes symbolsToSearchFor;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(SearchSymbols::SymbolTypes)
} // namespace Internal
} // namespace CppTools
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment