Commit 33650ac9 authored by Roberto Raggi's avatar Roberto Raggi

Reuse the strings

parent 444e2fd4
...@@ -129,3 +129,11 @@ void CppLocatorFilter::accept(Locator::FilterEntry selection) const ...@@ -129,3 +129,11 @@ void CppLocatorFilter::accept(Locator::FilterEntry selection) const
ModelItemInfo info = qvariant_cast<CppTools::Internal::ModelItemInfo>(selection.internalData); ModelItemInfo info = qvariant_cast<CppTools::Internal::ModelItemInfo>(selection.internalData);
TextEditor::BaseTextEditor::openEditorAt(info.fileName, info.line, info.column); TextEditor::BaseTextEditor::openEditorAt(info.fileName, info.line, info.column);
} }
void CppLocatorFilter::reset()
{
m_searchList.clear();
m_previousResults.clear();
m_previousEntry.clear();
m_forceNewSearchList = true;
}
...@@ -52,6 +52,8 @@ public: ...@@ -52,6 +52,8 @@ public:
void accept(Locator::FilterEntry selection) const; void accept(Locator::FilterEntry selection) const;
void refresh(QFutureInterface<void> &future); void refresh(QFutureInterface<void> &future);
void reset();
protected: protected:
SearchSymbols search; SearchSymbols search;
...@@ -64,8 +66,8 @@ private: ...@@ -64,8 +66,8 @@ private:
QHash<QString, QList<ModelItemInfo> > m_searchList; QHash<QString, QList<ModelItemInfo> > m_searchList;
QList<ModelItemInfo> m_previousResults; QList<ModelItemInfo> m_previousResults;
bool m_forceNewSearchList;
QString m_previousEntry; QString m_previousEntry;
bool m_forceNewSearchList;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <Scope.h> #include <Scope.h>
#include <Names.h> #include <Names.h>
#include <cplusplus/LookupContext.h> #include <cplusplus/LookupContext.h>
#include <QDebug>
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppTools::Internal; using namespace CppTools::Internal;
...@@ -67,8 +68,11 @@ QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString ...@@ -67,8 +68,11 @@ QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString
accept(doc->globalSymbolAt(i)); accept(doc->globalSymbolAt(i));
} }
(void) switchScope(previousScope); (void) switchScope(previousScope);
QList<ModelItemInfo> result = items;
strings.clear(); strings.clear();
return items; items.clear();
m_paths.clear();
return result;
} }
QString SearchSymbols::switchScope(const QString &scope) QString SearchSymbols::switchScope(const QString &scope)
...@@ -124,7 +128,7 @@ bool SearchSymbols::visit(Function *symbol) ...@@ -124,7 +128,7 @@ bool SearchSymbols::visit(Function *symbol)
bool SearchSymbols::visit(Namespace *symbol) bool SearchSymbols::visit(Namespace *symbol)
{ {
QString name = findOrInsert(scopedSymbolName(symbol)); QString name = scopedSymbolName(symbol);
QString previousScope = switchScope(name); QString previousScope = switchScope(name);
for (unsigned i = 0; i < symbol->memberCount(); ++i) { for (unsigned i = 0; i < symbol->memberCount(); ++i) {
accept(symbol->memberAt(i)); accept(symbol->memberAt(i));
...@@ -216,7 +220,7 @@ void SearchSymbols::appendItem(const QString &name, ...@@ -216,7 +220,7 @@ void SearchSymbols::appendItem(const QString &name,
QStringList fullyQualifiedName; QStringList fullyQualifiedName;
foreach (const Name *name, LookupContext::fullyQualifiedName(symbol)) foreach (const Name *name, LookupContext::fullyQualifiedName(symbol))
fullyQualifiedName.append(overview.prettyName(name)); fullyQualifiedName.append(findOrInsert(overview.prettyName(name)));
QString path = m_paths.value(symbol->fileId(), QString()); QString path = m_paths.value(symbol->fileId(), QString());
if (path.isEmpty()) { if (path.isEmpty()) {
...@@ -225,7 +229,7 @@ void SearchSymbols::appendItem(const QString &name, ...@@ -225,7 +229,7 @@ void SearchSymbols::appendItem(const QString &name,
} }
const QIcon icon = icons.iconForSymbol(symbol); const QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, info, type, items.append(ModelItemInfo(findOrInsert(name), findOrInsert(info), type,
fullyQualifiedName, fullyQualifiedName,
path, path,
symbol->line(), symbol->line(),
......
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