Commit 20c4f523 authored by Erik Verbruggen's avatar Erik Verbruggen

C++: pass ModelItemInfo around wrapped in a QSharedPointer.

Change-Id: I36162ea589ad01cf2ba79fc931732422fc1e6983
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent f26d6a76
...@@ -1919,11 +1919,11 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa ...@@ -1919,11 +1919,11 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
QList<Core::LocatorFilterEntry> matches = classesFilter->matchesFor(dummyInterface, className); QList<Core::LocatorFilterEntry> matches = classesFilter->matchesFor(dummyInterface, className);
bool classExists = false; bool classExists = false;
foreach (const Core::LocatorFilterEntry &entry, matches) { foreach (const Core::LocatorFilterEntry &entry, matches) {
const ModelItemInfo info = entry.internalData.value<ModelItemInfo>(); ModelItemInfo::Ptr info = entry.internalData.value<ModelItemInfo::Ptr>();
if (info.symbolName != className) if (info->symbolName() != className)
continue; continue;
classExists = true; classExists = true;
const QString &fileName = info.fileName; const QString &fileName = info->fileName();
const QFileInfo fileInfo(fileName); const QFileInfo fileInfo(fileName);
// find the shortest way to include fileName given the includePaths // find the shortest way to include fileName given the includePaths
......
...@@ -125,19 +125,19 @@ public: ...@@ -125,19 +125,19 @@ public:
break; break;
if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->fileName())) { if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->fileName())) {
QVector<Core::SearchResultItem> resultItems; QVector<Core::SearchResultItem> resultItems;
QList<ModelItemInfo> modelInfos = search(it.value()); QList<ModelItemInfo::Ptr> modelInfos = search(it.value());
foreach (const ModelItemInfo &info, modelInfos) { foreach (const ModelItemInfo::Ptr &info, modelInfos) {
int index = matcher.indexIn(info.symbolName); int index = matcher.indexIn(info->symbolName());
if (index != -1) { if (index != -1) {
QString text = info.symbolName; QString text = info->symbolName();
QString scope = info.symbolScope; QString scope = info->symbolScope();
if (info.type == ModelItemInfo::Function) { if (info->type() == ModelItemInfo::Function) {
QString name; QString name;
info.unqualifiedNameAndScope(info.symbolName, &name, &scope); info->unqualifiedNameAndScope(info->symbolName(), &name, &scope);
text = name + info.symbolType; text = name + info->symbolType();
} else if (info.type == ModelItemInfo::Declaration){ } else if (info->type() == ModelItemInfo::Declaration){
text = ModelItemInfo::representDeclaration(info.symbolName, text = ModelItemInfo::representDeclaration(info->symbolName(),
info.symbolType); info->symbolType());
} }
Core::SearchResultItem item; Core::SearchResultItem item;
...@@ -145,7 +145,7 @@ public: ...@@ -145,7 +145,7 @@ public:
item.text = text; item.text = text;
item.textMarkPos = -1; item.textMarkPos = -1;
item.textMarkLength = 0; item.textMarkLength = 0;
item.icon = info.icon; item.icon = info->icon();
item.lineNumber = -1; item.lineNumber = -1;
item.userData = qVariantFromValue(info); item.userData = qVariantFromValue(info);
resultItems << item; resultItems << item;
......
...@@ -45,18 +45,18 @@ CppClassesFilter::~CppClassesFilter() ...@@ -45,18 +45,18 @@ CppClassesFilter::~CppClassesFilter()
{ {
} }
QList<QList<CppTools::ModelItemInfo> > CppClassesFilter::itemsToMatchUserInputAgainst() const QList<QList<ModelItemInfo::Ptr> > CppClassesFilter::itemsToMatchUserInputAgainst() const
{ {
return QList<QList<CppTools::ModelItemInfo> >() << m_data->classes(); return QList<QList<CppTools::ModelItemInfo::Ptr> >() << m_data->classes();
} }
Core::LocatorFilterEntry CppClassesFilter::filterEntryFromModelItemInfo(const ModelItemInfo &info) Core::LocatorFilterEntry CppClassesFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
{ {
const QVariant id = qVariantFromValue(info); const QVariant id = qVariantFromValue(info);
Core::LocatorFilterEntry filterEntry(this, info.symbolName, id, info.icon); Core::LocatorFilterEntry filterEntry(this, info->symbolName(), id, info->icon());
filterEntry.extraInfo = info.symbolScope.isEmpty() filterEntry.extraInfo = info->symbolScope().isEmpty()
? info.shortNativeFilePath() ? info->shortNativeFilePath()
: info.symbolScope; : info->symbolScope();
return filterEntry; return filterEntry;
} }
...@@ -45,8 +45,8 @@ public: ...@@ -45,8 +45,8 @@ public:
~CppClassesFilter(); ~CppClassesFilter();
private: private:
QList<QList<CppTools::ModelItemInfo> > itemsToMatchUserInputAgainst() const; QList<QList<CppTools::ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info); Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
}; };
} // namespace CppTools } // namespace CppTools
......
...@@ -84,28 +84,28 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor( ...@@ -84,28 +84,28 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
foreach (const ModelItemInfo & info, m_itemsOfCurrentDoc) foreach (ModelItemInfo::Ptr info, m_itemsOfCurrentDoc) {
{
if (future.isCanceled()) if (future.isCanceled())
break; break;
QString matchString = info.symbolName; QString matchString = info->symbolName();
if (info.type == ModelItemInfo::Declaration) if (info->type() == ModelItemInfo::Declaration)
matchString = ModelItemInfo::representDeclaration(info.symbolName, info.symbolType); matchString = ModelItemInfo::representDeclaration(info->symbolName(),
else if (info.type == ModelItemInfo::Function) info->symbolType());
matchString += info.symbolType; else if (info->type() == ModelItemInfo::Function)
matchString += info->symbolType();
if ((hasWildcard && regexp.exactMatch(matchString)) if ((hasWildcard && regexp.exactMatch(matchString))
|| (!hasWildcard && matcher.indexIn(matchString) != -1)) || (!hasWildcard && matcher.indexIn(matchString) != -1))
{ {
QVariant id = qVariantFromValue(info); QVariant id = qVariantFromValue(info);
QString name = matchString; QString name = matchString;
QString extraInfo = info.symbolScope; QString extraInfo = info->symbolScope();
if (info.type == ModelItemInfo::Function) { if (info->type() == ModelItemInfo::Function) {
if (info.unqualifiedNameAndScope(matchString, &name, &extraInfo)) if (info->unqualifiedNameAndScope(matchString, &name, &extraInfo))
name += info.symbolType; name += info->symbolType();
} }
Core::LocatorFilterEntry filterEntry(this, name, id, info.icon); Core::LocatorFilterEntry filterEntry(this, name, id, info->icon());
filterEntry.extraInfo = extraInfo; filterEntry.extraInfo = extraInfo;
if (matchString.startsWith(entry, caseSensitivityForPrefix)) if (matchString.startsWith(entry, caseSensitivityForPrefix))
...@@ -123,8 +123,8 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor( ...@@ -123,8 +123,8 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
void CppCurrentDocumentFilter::accept(Core::LocatorFilterEntry selection) const void CppCurrentDocumentFilter::accept(Core::LocatorFilterEntry selection) const
{ {
ModelItemInfo info = qvariant_cast<CppTools::ModelItemInfo>(selection.internalData); ModelItemInfo::Ptr info = qvariant_cast<CppTools::ModelItemInfo::Ptr>(selection.internalData);
Core::EditorManager::openEditorAt(info.fileName, info.line, info.column); Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
} }
void CppCurrentDocumentFilter::refresh(QFutureInterface<void> &future) void CppCurrentDocumentFilter::refresh(QFutureInterface<void> &future)
......
...@@ -61,7 +61,7 @@ private slots: ...@@ -61,7 +61,7 @@ private slots:
private: private:
CppModelManager * m_modelManager; CppModelManager * m_modelManager;
QString m_currentFileName; QString m_currentFileName;
QList<ModelItemInfo> m_itemsOfCurrentDoc; QList<ModelItemInfo::Ptr> m_itemsOfCurrentDoc;
SearchSymbols search; SearchSymbols search;
}; };
......
...@@ -44,22 +44,22 @@ CppFunctionsFilter::~CppFunctionsFilter() ...@@ -44,22 +44,22 @@ CppFunctionsFilter::~CppFunctionsFilter()
{ {
} }
QList<QList<CppTools::ModelItemInfo> > CppFunctionsFilter::itemsToMatchUserInputAgainst() const QList<QList<CppTools::ModelItemInfo::Ptr> > CppFunctionsFilter::itemsToMatchUserInputAgainst() const
{ {
return QList<QList<CppTools::ModelItemInfo> >() << m_data->functions(); return QList<QList<CppTools::ModelItemInfo::Ptr> >() << m_data->functions();
} }
Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info) Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
{ {
const QVariant id = qVariantFromValue(info); const QVariant id = qVariantFromValue(info);
QString name = info.symbolName; QString name = info->symbolName();
QString extraInfo = info.symbolScope; QString extraInfo = info->symbolScope();
info.unqualifiedNameAndScope(name, &name, &extraInfo); info->unqualifiedNameAndScope(name, &name, &extraInfo);
if (extraInfo.isEmpty()) if (extraInfo.isEmpty())
extraInfo = info.shortNativeFilePath(); extraInfo = info->shortNativeFilePath();
Core::LocatorFilterEntry filterEntry(this, name + info.symbolType, id, info.icon); Core::LocatorFilterEntry filterEntry(this, name + info->symbolType(), id, info->icon());
filterEntry.extraInfo = extraInfo; filterEntry.extraInfo = extraInfo;
return filterEntry; return filterEntry;
......
...@@ -45,8 +45,8 @@ public: ...@@ -45,8 +45,8 @@ public:
~CppFunctionsFilter(); ~CppFunctionsFilter();
private: private:
QList<QList<ModelItemInfo> > itemsToMatchUserInputAgainst() const; QList<QList<ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info); Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
}; };
} // namespace Internal } // namespace Internal
......
...@@ -53,19 +53,19 @@ CppLocatorData::CppLocatorData(CppModelManager *modelManager) ...@@ -53,19 +53,19 @@ CppLocatorData::CppLocatorData(CppModelManager *modelManager)
this, SLOT(onAboutToRemoveFiles(QStringList))); this, SLOT(onAboutToRemoveFiles(QStringList)));
} }
QList<ModelItemInfo> CppLocatorData::enums() QList<ModelItemInfo::Ptr> CppLocatorData::enums()
{ {
flushPendingDocument(true); flushPendingDocument(true);
return allModelItemInfos(m_allEnums); return allModelItemInfos(m_allEnums);
} }
QList<ModelItemInfo> CppLocatorData::classes() QList<ModelItemInfo::Ptr> CppLocatorData::classes()
{ {
flushPendingDocument(true); flushPendingDocument(true);
return allModelItemInfos(m_allClasses); return allModelItemInfos(m_allClasses);
} }
QList<ModelItemInfo> CppLocatorData::functions() QList<ModelItemInfo::Ptr> CppLocatorData::functions()
{ {
flushPendingDocument(true); flushPendingDocument(true);
return allModelItemInfos(m_allFunctions); return allModelItemInfos(m_allFunctions);
...@@ -120,15 +120,15 @@ void CppLocatorData::flushPendingDocument(bool force) ...@@ -120,15 +120,15 @@ void CppLocatorData::flushPendingDocument(bool force)
foreach (CPlusPlus::Document::Ptr doc, m_pendingDocuments) { foreach (CPlusPlus::Document::Ptr doc, m_pendingDocuments) {
const QString fileName = findOrInsertFilePath(doc->fileName()); const QString fileName = findOrInsertFilePath(doc->fileName());
QList<ModelItemInfo> resultsEnums; QList<ModelItemInfo::Ptr> resultsEnums;
QList<ModelItemInfo> resultsClasses; QList<ModelItemInfo::Ptr> resultsClasses;
QList<ModelItemInfo> resultsFunctions; QList<ModelItemInfo::Ptr> resultsFunctions;
const int sizeHint = m_allEnums[fileName].size() + m_allClasses[fileName].size() const int sizeHint = m_allEnums[fileName].size() + m_allClasses[fileName].size()
+ m_allFunctions[fileName].size() + 10; + m_allFunctions[fileName].size() + 10;
const QList<ModelItemInfo> results = m_search(doc, sizeHint); const QList<ModelItemInfo::Ptr> results = m_search(doc, sizeHint);
foreach (const ModelItemInfo &info, results) { foreach (ModelItemInfo::Ptr info, results) {
switch (info.type) { switch (info->type()) {
case ModelItemInfo::Enum: case ModelItemInfo::Enum:
resultsEnums.append(info); resultsEnums.append(info);
break; break;
...@@ -152,11 +152,11 @@ void CppLocatorData::flushPendingDocument(bool force) ...@@ -152,11 +152,11 @@ void CppLocatorData::flushPendingDocument(bool force)
m_pendingDocuments.reserve(MaxPendingDocuments); m_pendingDocuments.reserve(MaxPendingDocuments);
} }
QList<ModelItemInfo> CppLocatorData::allModelItemInfos(const QHash<QString, QList<ModelItemInfo::Ptr> CppLocatorData::allModelItemInfos(const QHash<QString,
QList<ModelItemInfo> > &items) const QList<ModelItemInfo::Ptr>> &items) const
{ {
QList<ModelItemInfo> result; QList<ModelItemInfo::Ptr> result;
QHashIterator<QString, QList<ModelItemInfo> > it(items); QHashIterator<QString, QList<ModelItemInfo::Ptr> > it(items);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
result.append(it.value()); result.append(it.value());
......
...@@ -49,9 +49,9 @@ class CppLocatorData : public QObject ...@@ -49,9 +49,9 @@ class CppLocatorData : public QObject
public: public:
explicit CppLocatorData(CppModelManager *modelManager); explicit CppLocatorData(CppModelManager *modelManager);
QList<ModelItemInfo> enums(); QList<ModelItemInfo::Ptr> enums();
QList<ModelItemInfo> classes(); QList<ModelItemInfo::Ptr> classes();
QList<ModelItemInfo> functions(); QList<ModelItemInfo::Ptr> functions();
private slots: private slots:
void onDocumentUpdated(const CPlusPlus::Document::Ptr &document); void onDocumentUpdated(const CPlusPlus::Document::Ptr &document);
...@@ -59,8 +59,8 @@ private slots: ...@@ -59,8 +59,8 @@ private slots:
private: private:
void flushPendingDocument(bool force); void flushPendingDocument(bool force);
QList<ModelItemInfo> allModelItemInfos(const QHash<QString, QList<ModelItemInfo::Ptr> allModelItemInfos(
QList<ModelItemInfo> > &items) const; const QHash<QString, QList<ModelItemInfo::Ptr>> &items) const;
QString findOrInsertFilePath(const QString &path) QString findOrInsertFilePath(const QString &path)
{ return m_strings.insert(path); } { return m_strings.insert(path); }
...@@ -71,9 +71,9 @@ private: ...@@ -71,9 +71,9 @@ private:
StringTable &m_strings; // Used to avoid QString duplication StringTable &m_strings; // Used to avoid QString duplication
SearchSymbols m_search; SearchSymbols m_search;
QHash<QString, QList<ModelItemInfo> > m_allEnums; QHash<QString, QList<ModelItemInfo::Ptr> > m_allEnums;
QHash<QString, QList<ModelItemInfo> > m_allClasses; QHash<QString, QList<ModelItemInfo::Ptr> > m_allClasses;
QHash<QString, QList<ModelItemInfo> > m_allFunctions; QHash<QString, QList<ModelItemInfo::Ptr> > m_allFunctions;
mutable QMutex m_pendingDocumentsMutex; mutable QMutex m_pendingDocumentsMutex;
QVector<CPlusPlus::Document::Ptr> m_pendingDocuments; QVector<CPlusPlus::Document::Ptr> m_pendingDocuments;
......
...@@ -47,13 +47,14 @@ CppLocatorFilter::~CppLocatorFilter() ...@@ -47,13 +47,14 @@ CppLocatorFilter::~CppLocatorFilter()
{ {
} }
Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info) Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
{ {
const QVariant id = qVariantFromValue(info); const QVariant id = qVariantFromValue(info);
Core::LocatorFilterEntry filterEntry(this, info.scopedSymbolName(), id, info.icon); Core::LocatorFilterEntry filterEntry(this, info->scopedSymbolName(), id, info->icon());
filterEntry.extraInfo = info.type == ModelItemInfo::Class || info.type == ModelItemInfo::Enum if (info->type() == ModelItemInfo::Class || info->type() == ModelItemInfo::Enum)
? info.shortNativeFilePath() filterEntry.extraInfo = info->shortNativeFilePath();
: info.symbolType; else
filterEntry.extraInfo = info->symbolType();
return filterEntry; return filterEntry;
} }
...@@ -63,9 +64,9 @@ void CppLocatorFilter::refresh(QFutureInterface<void> &future) ...@@ -63,9 +64,9 @@ void CppLocatorFilter::refresh(QFutureInterface<void> &future)
Q_UNUSED(future) Q_UNUSED(future)
} }
QList<QList<CppTools::ModelItemInfo> > CppLocatorFilter::itemsToMatchUserInputAgainst() const QList<QList<CppTools::ModelItemInfo::Ptr> > CppLocatorFilter::itemsToMatchUserInputAgainst() const
{ {
return QList<QList<CppTools::ModelItemInfo> >() return QList<QList<CppTools::ModelItemInfo::Ptr> >()
<< m_data->classes() << m_data->classes()
<< m_data->functions() << m_data->functions()
<< m_data->enums(); << m_data->enums();
...@@ -77,7 +78,8 @@ static bool compareLexigraphically(const Core::LocatorFilterEntry &a, ...@@ -77,7 +78,8 @@ static bool compareLexigraphically(const Core::LocatorFilterEntry &a,
return a.displayName < b.displayName; return a.displayName < b.displayName;
} }
QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry) QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(
QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry)
{ {
QString entry = trimWildcards(origEntry); QString entry = trimWildcards(origEntry);
QList<Core::LocatorFilterEntry> goodEntries; QList<Core::LocatorFilterEntry> goodEntries;
...@@ -91,12 +93,13 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Co ...@@ -91,12 +93,13 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Co
bool hasColonColon = entry.contains(QLatin1String("::")); bool hasColonColon = entry.contains(QLatin1String("::"));
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
const QList<QList<CppTools::ModelItemInfo> > itemLists = itemsToMatchUserInputAgainst(); const QList<QList<CppTools::ModelItemInfo::Ptr> > itemLists = itemsToMatchUserInputAgainst();
foreach (const QList<CppTools::ModelItemInfo> &items, itemLists) { foreach (const QList<CppTools::ModelItemInfo::Ptr> &items, itemLists) {
foreach (const ModelItemInfo &info, items) { foreach (ModelItemInfo::Ptr info, items) {
if (future.isCanceled()) if (future.isCanceled())
break; break;
const QString matchString = hasColonColon ? info.scopedSymbolName() : info.symbolName; const QString matchString = hasColonColon ? info->scopedSymbolName()
: info->symbolName();
if ((hasWildcard && regexp.exactMatch(matchString)) if ((hasWildcard && regexp.exactMatch(matchString))
|| (!hasWildcard && matcher.indexIn(matchString) != -1)) { || (!hasWildcard && matcher.indexIn(matchString) != -1)) {
const Core::LocatorFilterEntry filterEntry = filterEntryFromModelItemInfo(info); const Core::LocatorFilterEntry filterEntry = filterEntryFromModelItemInfo(info);
...@@ -119,6 +122,6 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Co ...@@ -119,6 +122,6 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Co
void CppLocatorFilter::accept(Core::LocatorFilterEntry selection) const void CppLocatorFilter::accept(Core::LocatorFilterEntry selection) const
{ {
ModelItemInfo info = qvariant_cast<CppTools::ModelItemInfo>(selection.internalData); ModelItemInfo::Ptr info = qvariant_cast<CppTools::ModelItemInfo::Ptr>(selection.internalData);
Core::EditorManager::openEditorAt(info.fileName, info.line, info.column); Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
} }
...@@ -48,13 +48,14 @@ public: ...@@ -48,13 +48,14 @@ public:
CppLocatorFilter(CppLocatorData *locatorData); CppLocatorFilter(CppLocatorData *locatorData);
~CppLocatorFilter(); ~CppLocatorFilter();
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry); QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry);
void accept(Core::LocatorFilterEntry selection) const; void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future); void refresh(QFutureInterface<void> &future);
private: protected:
virtual QList<QList<ModelItemInfo> > itemsToMatchUserInputAgainst() const; virtual QList<QList<ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
virtual Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info); virtual Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
protected: protected:
CppLocatorData *m_data; CppLocatorData *m_data;
......
...@@ -53,7 +53,8 @@ void SearchSymbols::setSymbolsToSearchFor(const SymbolTypes &types) ...@@ -53,7 +53,8 @@ void SearchSymbols::setSymbolsToSearchFor(const SymbolTypes &types)
symbolsToSearchFor = types; symbolsToSearchFor = types;
} }
QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, int sizeHint, const QString &scope) QList<ModelItemInfo::Ptr> SearchSymbols::operator()(Document::Ptr doc, int sizeHint,
const QString &scope)
{ {
QString previousScope = switchScope(scope); QString previousScope = switchScope(scope);
items.clear(); items.clear();
...@@ -62,7 +63,7 @@ QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, int sizeHint, ...@@ -62,7 +63,7 @@ QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, int sizeHint,
accept(doc->globalSymbolAt(i)); accept(doc->globalSymbolAt(i));
} }
(void) switchScope(previousScope); (void) switchScope(previousScope);
QList<ModelItemInfo> result = items; QList<ModelItemInfo::Ptr> result = items;
strings.scheduleGC(); strings.scheduleGC();
items.clear(); items.clear();
m_paths.clear(); m_paths.clear();
...@@ -288,12 +289,12 @@ void SearchSymbols::appendItem(const QString &symbolName, const QString &symbolT ...@@ -288,12 +289,12 @@ void SearchSymbols::appendItem(const QString &symbolName, const QString &symbolT
} }
const QIcon icon = icons.iconForSymbol(symbol); const QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(findOrInsert(symbolName), items.append(ModelItemInfo::create(findOrInsert(symbolName),
findOrInsert(symbolType), findOrInsert(symbolType),
findOrInsert(symbolScope), findOrInsert(symbolScope),
itemType, itemType,
findOrInsert(path), findOrInsert(path),
symbol->line(), symbol->line(),
symbol->column() - 1, // 1-based vs 0-based column symbol->column() - 1, // 1-based vs 0-based column
icon)); icon));
} }
...@@ -43,22 +43,21 @@ ...@@ -43,22 +43,21 @@
#include <QIcon> #include <QIcon>
#include <QString> #include <QString>
#include <QSet> #include <QSet>
#include <QSharedPointer>
#include <QHash> #include <QHash>
#include <functional> #include <functional>
namespace CppTools { namespace CppTools {
struct CPPTOOLS_EXPORT ModelItemInfo class CPPTOOLS_EXPORT ModelItemInfo
{ {
enum ItemType { Enum, Class, Function, Declaration }; Q_DISABLE_COPY(ModelItemInfo)
ModelItemInfo() public:
: type(Declaration), enum ItemType { Enum, Class, Function, Declaration };
line(0),
column(0)
{ }
private: