diff --git a/src/plugins/clangcodemodel/clangsymbolsearcher.cpp b/src/plugins/clangcodemodel/clangsymbolsearcher.cpp
index a8512d53a893334f2c82d3b660e93f1e95eed7e4..990e3b22a793f011232bb5fe58fdbdc5ddcb6e1b 100644
--- a/src/plugins/clangcodemodel/clangsymbolsearcher.cpp
+++ b/src/plugins/clangcodemodel/clangsymbolsearcher.cpp
@@ -88,12 +88,12 @@ void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
         }
         ++symbolNr;
 
-        CppTools::ModelItemInfo info;
+        CppTools::IndexItem info;
 
         switch (s.m_kind) {
         case Symbol::Enum:
             if (m_parameters.types & SymbolSearcher::Enums) {
-                info.type = CppTools::ModelItemInfo::Enum;
+                info.type = CppTools::IndexItem::Enum;
                 info.symbolType = QLatin1String("enum");
                 break;
             } else {
@@ -101,7 +101,7 @@ void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
             }
         case Symbol::Class:
             if (m_parameters.types & SymbolSearcher::Classes) {
-                info.type = CppTools::ModelItemInfo::Class;
+                info.type = CppTools::IndexItem::Class;
                 info.symbolType = QLatin1String("class");
                 break;
             } else {
@@ -112,14 +112,14 @@ void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
         case Symbol::Constructor:
         case Symbol::Destructor:
             if (m_parameters.types & SymbolSearcher::Functions) {
-                info.type = CppTools::ModelItemInfo::Function;
+                info.type = CppTools::IndexItem::Function;
                 break;
             } else {
                 continue;
             }
         case Symbol::Declaration:
             if (m_parameters.types & SymbolSearcher::Declarations) {
-                info.type = CppTools::ModelItemInfo::Declaration;
+                info.type = CppTools::IndexItem::Declaration;
                 break;
             } else {
                 continue;
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index d519dda25712495190107281fd4616d588231160..918d44889cd6263b52691394a11163e20db680d3 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -1920,7 +1920,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
     QList<Core::LocatorFilterEntry> matches = classesFilter->matchesFor(dummyInterface, className);
     bool classExists = false;
     foreach (const Core::LocatorFilterEntry &entry, matches) {
-        ModelItemInfo::Ptr info = entry.internalData.value<ModelItemInfo::Ptr>();
+        IndexItem::Ptr info = entry.internalData.value<IndexItem::Ptr>();
         if (info->symbolName() != className)
             continue;
         classExists = true;
diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp
index 2977eb2ac77c4fe6c6a0e01a077a1103dcff2105..ccad1e0e73f1b1d27f1d62c9bf61eb347777138a 100644
--- a/src/plugins/cpptools/builtinindexingsupport.cpp
+++ b/src/plugins/cpptools/builtinindexingsupport.cpp
@@ -125,16 +125,16 @@ public:
                 break;
             if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->fileName())) {
                 QVector<Core::SearchResultItem> resultItems;
-                search(it.value())->visitAllChildren([&](const ModelItemInfo::Ptr &info) {
+                search(it.value())->visitAllChildren([&](const IndexItem::Ptr &info) {
                     if (matcher.indexIn(info->symbolName()) != -1) {
                         QString text = info->symbolName();
                         QString scope = info->symbolScope();
-                        if (info->type() == ModelItemInfo::Function) {
+                        if (info->type() == IndexItem::Function) {
                             QString name;
                             info->unqualifiedNameAndScope(info->symbolName(), &name, &scope);
                             text = name + info->symbolType();
-                        } else if (info->type() == ModelItemInfo::Declaration){
-                            text = ModelItemInfo::representDeclaration(info->symbolName(),
+                        } else if (info->type() == IndexItem::Declaration){
+                            text = IndexItem::representDeclaration(info->symbolName(),
                                                                        info->symbolType());
                         }
 
diff --git a/src/plugins/cpptools/cppclassesfilter.cpp b/src/plugins/cpptools/cppclassesfilter.cpp
index 2f9eb3809cbb391d48b8269132683bdde7b79080..5835b4346b56851c89812993498b6ecc6bf438e8 100644
--- a/src/plugins/cpptools/cppclassesfilter.cpp
+++ b/src/plugins/cpptools/cppclassesfilter.cpp
@@ -45,12 +45,12 @@ CppClassesFilter::~CppClassesFilter()
 {
 }
 
-QList<QList<ModelItemInfo::Ptr> > CppClassesFilter::itemsToMatchUserInputAgainst() const
+QList<QList<IndexItem::Ptr> > CppClassesFilter::itemsToMatchUserInputAgainst() const
 {
-    return QList<QList<CppTools::ModelItemInfo::Ptr> >() << m_data->classes();
+    return QList<QList<CppTools::IndexItem::Ptr> >() << m_data->classes();
 }
 
-Core::LocatorFilterEntry CppClassesFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
+Core::LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
 {
     const QVariant id = qVariantFromValue(info);
     Core::LocatorFilterEntry filterEntry(this, info->symbolName(), id, info->icon());
diff --git a/src/plugins/cpptools/cppclassesfilter.h b/src/plugins/cpptools/cppclassesfilter.h
index 09c70bb0cba0cd7a014f9a03432471f5a22bbc4e..446a90b7cae47a64f79b01f223148f8d703c927b 100644
--- a/src/plugins/cpptools/cppclassesfilter.h
+++ b/src/plugins/cpptools/cppclassesfilter.h
@@ -45,8 +45,8 @@ public:
     ~CppClassesFilter();
 
 private:
-    QList<QList<CppTools::ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
-    Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
+    QList<QList<CppTools::IndexItem::Ptr> > itemsToMatchUserInputAgainst() const;
+    Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info);
 };
 
 } // namespace CppTools
diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
index 685950ed46da34204e0ca927c5bc05518a71343e..ef3242c15d86623e216c4cb349b631e87de8fada 100644
--- a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
+++ b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
@@ -79,22 +79,22 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
         Snapshot snapshot = m_modelManager->snapshot();
         Document::Ptr thisDocument = snapshot.document(m_currentFileName);
         if (thisDocument)
-            search(thisDocument)->visitAllChildren([&](const ModelItemInfo::Ptr &info){
+            search(thisDocument)->visitAllChildren([&](const IndexItem::Ptr &info){
                 m_itemsOfCurrentDoc.append(info);
             });
     }
 
     const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
 
-    foreach (ModelItemInfo::Ptr info, m_itemsOfCurrentDoc) {
+    foreach (IndexItem::Ptr info, m_itemsOfCurrentDoc) {
         if (future.isCanceled())
             break;
 
         QString matchString = info->symbolName();
-        if (info->type() == ModelItemInfo::Declaration)
-            matchString = ModelItemInfo::representDeclaration(info->symbolName(),
-                                                              info->symbolType());
-        else if (info->type() == ModelItemInfo::Function)
+        if (info->type() == IndexItem::Declaration)
+            matchString = IndexItem::representDeclaration(info->symbolName(),
+                                                          info->symbolType());
+        else if (info->type() == IndexItem::Function)
             matchString += info->symbolType();
 
         if ((hasWildcard && regexp.exactMatch(matchString))
@@ -103,7 +103,7 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
             QVariant id = qVariantFromValue(info);
             QString name = matchString;
             QString extraInfo = info->symbolScope();
-            if (info->type() == ModelItemInfo::Function) {
+            if (info->type() == IndexItem::Function) {
                 if (info->unqualifiedNameAndScope(matchString, &name, &extraInfo))
                     name += info->symbolType();
             }
@@ -125,7 +125,7 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
 
 void CppCurrentDocumentFilter::accept(Core::LocatorFilterEntry selection) const
 {
-    ModelItemInfo::Ptr info = qvariant_cast<CppTools::ModelItemInfo::Ptr>(selection.internalData);
+    IndexItem::Ptr info = qvariant_cast<CppTools::IndexItem::Ptr>(selection.internalData);
     Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
 }
 
diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.h b/src/plugins/cpptools/cppcurrentdocumentfilter.h
index 0b24fe4ee4f3546045bbe38d1ff41e32f493d342..06b9633d715e8a73f4c925efd2dc3dca449ea5c7 100644
--- a/src/plugins/cpptools/cppcurrentdocumentfilter.h
+++ b/src/plugins/cpptools/cppcurrentdocumentfilter.h
@@ -61,7 +61,7 @@ private slots:
 private:
     CppModelManager * m_modelManager;
     QString m_currentFileName;
-    QList<ModelItemInfo::Ptr> m_itemsOfCurrentDoc;
+    QList<IndexItem::Ptr> m_itemsOfCurrentDoc;
     SearchSymbols search;
 };
 
diff --git a/src/plugins/cpptools/cppfunctionsfilter.cpp b/src/plugins/cpptools/cppfunctionsfilter.cpp
index 069829c35307699fd69851a2d4e0f6c367e8ecdc..ecdb8a971cfd1bfff17861a7abe133b7efdae2e8 100644
--- a/src/plugins/cpptools/cppfunctionsfilter.cpp
+++ b/src/plugins/cpptools/cppfunctionsfilter.cpp
@@ -45,12 +45,12 @@ CppFunctionsFilter::~CppFunctionsFilter()
 {
 }
 
-QList<QList<CppTools::ModelItemInfo::Ptr> > CppFunctionsFilter::itemsToMatchUserInputAgainst() const
+QList<QList<CppTools::IndexItem::Ptr> > CppFunctionsFilter::itemsToMatchUserInputAgainst() const
 {
-    return QList<QList<CppTools::ModelItemInfo::Ptr> >() << m_data->functions();
+    return QList<QList<CppTools::IndexItem::Ptr> >() << m_data->functions();
 }
 
-Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
+Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
 {
     const QVariant id = qVariantFromValue(info);
 
diff --git a/src/plugins/cpptools/cppfunctionsfilter.h b/src/plugins/cpptools/cppfunctionsfilter.h
index de30197792c1ab2a2513b42aab354687a8033bf3..ba0f9d49dbdcc2c370c6a792752d146249c462a9 100644
--- a/src/plugins/cpptools/cppfunctionsfilter.h
+++ b/src/plugins/cpptools/cppfunctionsfilter.h
@@ -45,8 +45,8 @@ public:
     ~CppFunctionsFilter();
 
 private:
-    QList<QList<ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
-    Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
+    QList<QList<IndexItem::Ptr> > itemsToMatchUserInputAgainst() const;
+    Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info);
 };
 
 } // namespace Internal
diff --git a/src/plugins/cpptools/cpplocatordata.cpp b/src/plugins/cpptools/cpplocatordata.cpp
index 27fdb4703d781cbd920d7002407709b90f46f2bd..986834274dbfb512604b0e6bb50a48843edc949b 100644
--- a/src/plugins/cpptools/cpplocatordata.cpp
+++ b/src/plugins/cpptools/cpplocatordata.cpp
@@ -53,22 +53,22 @@ CppLocatorData::CppLocatorData(CppModelManager *modelManager)
             this, SLOT(onAboutToRemoveFiles(QStringList)));
 }
 
-QList<ModelItemInfo::Ptr> CppLocatorData::enums()
+QList<IndexItem::Ptr> CppLocatorData::enums()
 {
     flushPendingDocument(true);
-    return allModelItemInfos(m_allEnums);
+    return allIndexItems(m_allEnums);
 }
 
-QList<ModelItemInfo::Ptr> CppLocatorData::classes()
+QList<IndexItem::Ptr> CppLocatorData::classes()
 {
     flushPendingDocument(true);
-    return allModelItemInfos(m_allClasses);
+    return allIndexItems(m_allClasses);
 }
 
-QList<ModelItemInfo::Ptr> CppLocatorData::functions()
+QList<IndexItem::Ptr> CppLocatorData::functions()
 {
     flushPendingDocument(true);
-    return allModelItemInfos(m_allFunctions);
+    return allIndexItems(m_allFunctions);
 }
 
 void CppLocatorData::onDocumentUpdated(const CPlusPlus::Document::Ptr &document)
@@ -120,21 +120,19 @@ void CppLocatorData::flushPendingDocument(bool force)
     foreach (CPlusPlus::Document::Ptr doc, m_pendingDocuments) {
         const QString fileName = findOrInsertFilePath(doc->fileName());
 
-        QList<ModelItemInfo::Ptr> resultsEnums;
-        QList<ModelItemInfo::Ptr> resultsClasses;
-        QList<ModelItemInfo::Ptr> resultsFunctions;
+        QList<IndexItem::Ptr> resultsEnums;
+        QList<IndexItem::Ptr> resultsClasses;
+        QList<IndexItem::Ptr> resultsFunctions;
 
-        const int sizeHint = m_allEnums[fileName].size() + m_allClasses[fileName].size()
-                + m_allFunctions[fileName].size() + 10;
-        m_search(doc, sizeHint)->visitAllChildren([&](const ModelItemInfo::Ptr &info) {
+        m_search(doc)->visitAllChildren([&](const IndexItem::Ptr &info) {
             switch (info->type()) {
-            case ModelItemInfo::Enum:
+            case IndexItem::Enum:
                 resultsEnums.append(info);
                 break;
-            case ModelItemInfo::Class:
+            case IndexItem::Class:
                 resultsClasses.append(info);
                 break;
-            case ModelItemInfo::Function:
+            case IndexItem::Function:
                 resultsFunctions.append(info);
                 break;
             default:
@@ -151,11 +149,11 @@ void CppLocatorData::flushPendingDocument(bool force)
     m_pendingDocuments.reserve(MaxPendingDocuments);
 }
 
-QList<ModelItemInfo::Ptr> CppLocatorData::allModelItemInfos(const QHash<QString,
-                                                            QList<ModelItemInfo::Ptr>> &items) const
+QList<IndexItem::Ptr> CppLocatorData::allIndexItems(
+        const QHash<QString, QList<IndexItem::Ptr>> &items) const
 {
-    QList<ModelItemInfo::Ptr> result;
-    QHashIterator<QString, QList<ModelItemInfo::Ptr> > it(items);
+    QList<IndexItem::Ptr> result;
+    QHashIterator<QString, QList<IndexItem::Ptr> > it(items);
     while (it.hasNext()) {
         it.next();
         result.append(it.value());
diff --git a/src/plugins/cpptools/cpplocatordata.h b/src/plugins/cpptools/cpplocatordata.h
index eb85e52df739716bd893360cea88244cd2538409..0feda706c4f8fe75b069a99c77b31a7158cdd0e8 100644
--- a/src/plugins/cpptools/cpplocatordata.h
+++ b/src/plugins/cpptools/cpplocatordata.h
@@ -49,9 +49,9 @@ class CppLocatorData : public QObject
 public:
     explicit CppLocatorData(CppModelManager *modelManager);
 
-    QList<ModelItemInfo::Ptr> enums();
-    QList<ModelItemInfo::Ptr> classes();
-    QList<ModelItemInfo::Ptr> functions();
+    QList<IndexItem::Ptr> enums();
+    QList<IndexItem::Ptr> classes();
+    QList<IndexItem::Ptr> functions();
 
 private slots:
     void onDocumentUpdated(const CPlusPlus::Document::Ptr &document);
@@ -59,8 +59,7 @@ private slots:
 
 private:
     void flushPendingDocument(bool force);
-    QList<ModelItemInfo::Ptr> allModelItemInfos(
-            const QHash<QString, QList<ModelItemInfo::Ptr>> &items) const;
+    QList<IndexItem::Ptr> allIndexItems(const QHash<QString, QList<IndexItem::Ptr>> &items) const;
 
     QString findOrInsertFilePath(const QString &path)
     { return m_strings.insert(path); }
@@ -71,9 +70,9 @@ private:
     StringTable &m_strings; // Used to avoid QString duplication
 
     SearchSymbols m_search;
-    QHash<QString, QList<ModelItemInfo::Ptr> > m_allEnums;
-    QHash<QString, QList<ModelItemInfo::Ptr> > m_allClasses;
-    QHash<QString, QList<ModelItemInfo::Ptr> > m_allFunctions;
+    QHash<QString, QList<IndexItem::Ptr> > m_allEnums;
+    QHash<QString, QList<IndexItem::Ptr> > m_allClasses;
+    QHash<QString, QList<IndexItem::Ptr> > m_allFunctions;
 
     mutable QMutex m_pendingDocumentsMutex;
     QVector<CPlusPlus::Document::Ptr> m_pendingDocuments;
diff --git a/src/plugins/cpptools/cpplocatorfilter.cpp b/src/plugins/cpptools/cpplocatorfilter.cpp
index c5d5af9e517e11bd67d44ad1ef4cca810f84e218..3c967c4d32fd3e447f27e5ca1b27eda00e635c2e 100644
--- a/src/plugins/cpptools/cpplocatorfilter.cpp
+++ b/src/plugins/cpptools/cpplocatorfilter.cpp
@@ -48,11 +48,11 @@ CppLocatorFilter::~CppLocatorFilter()
 {
 }
 
-Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
+Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
 {
     const QVariant id = qVariantFromValue(info);
     Core::LocatorFilterEntry filterEntry(this, info->scopedSymbolName(), id, info->icon());
-    if (info->type() == ModelItemInfo::Class || info->type() == ModelItemInfo::Enum)
+    if (info->type() == IndexItem::Class || info->type() == IndexItem::Enum)
         filterEntry.extraInfo = info->shortNativeFilePath();
     else
         filterEntry.extraInfo = info->symbolType();
@@ -65,9 +65,9 @@ void CppLocatorFilter::refresh(QFutureInterface<void> &future)
     Q_UNUSED(future)
 }
 
-QList<QList<CppTools::ModelItemInfo::Ptr> > CppLocatorFilter::itemsToMatchUserInputAgainst() const
+QList<QList<CppTools::IndexItem::Ptr> > CppLocatorFilter::itemsToMatchUserInputAgainst() const
 {
-    return QList<QList<CppTools::ModelItemInfo::Ptr> >()
+    return QList<QList<CppTools::IndexItem::Ptr> >()
         << m_data->classes()
         << m_data->functions()
         << m_data->enums();
@@ -94,16 +94,16 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(
     bool hasColonColon = entry.contains(QLatin1String("::"));
     const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
 
-    const QList<QList<CppTools::ModelItemInfo::Ptr> > itemLists = itemsToMatchUserInputAgainst();
-    foreach (const QList<CppTools::ModelItemInfo::Ptr> &items, itemLists) {
-        foreach (ModelItemInfo::Ptr info, items) {
+    const QList<QList<CppTools::IndexItem::Ptr> > itemLists = itemsToMatchUserInputAgainst();
+    foreach (const QList<CppTools::IndexItem::Ptr> &items, itemLists) {
+        foreach (IndexItem::Ptr info, items) {
             if (future.isCanceled())
                 break;
             const QString matchString = hasColonColon ? info->scopedSymbolName()
                                                       : info->symbolName();
             if ((hasWildcard && regexp.exactMatch(matchString))
                 || (!hasWildcard && matcher.indexIn(matchString) != -1)) {
-                const Core::LocatorFilterEntry filterEntry = filterEntryFromModelItemInfo(info);
+                const Core::LocatorFilterEntry filterEntry = filterEntryFromIndexItem(info);
                 if (matchString.startsWith(entry, caseSensitivityForPrefix))
                     betterEntries.append(filterEntry);
                 else
@@ -123,6 +123,6 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(
 
 void CppLocatorFilter::accept(Core::LocatorFilterEntry selection) const
 {
-    ModelItemInfo::Ptr info = qvariant_cast<CppTools::ModelItemInfo::Ptr>(selection.internalData);
+    IndexItem::Ptr info = qvariant_cast<CppTools::IndexItem::Ptr>(selection.internalData);
     Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
 }
diff --git a/src/plugins/cpptools/cpplocatorfilter.h b/src/plugins/cpptools/cpplocatorfilter.h
index 527e3f050b2c01199b254c0cf8c6470aada4c99d..07d5ce5fb2378abb5da4d94813505758d965ce98 100644
--- a/src/plugins/cpptools/cpplocatorfilter.h
+++ b/src/plugins/cpptools/cpplocatorfilter.h
@@ -54,8 +54,8 @@ public:
     void refresh(QFutureInterface<void> &future);
 
 protected:
-    virtual QList<QList<ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
-    virtual Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
+    virtual QList<QList<IndexItem::Ptr> > itemsToMatchUserInputAgainst() const;
+    virtual Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info);
 
 protected:
     CppLocatorData *m_data;
diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro
index 485c947a7fee64bbca1ba13a36b19d6bd1ea8ec7..e528f3e3d6caab44085700dfd30c15b806887466 100644
--- a/src/plugins/cpptools/cpptools.pro
+++ b/src/plugins/cpptools/cpptools.pro
@@ -50,6 +50,7 @@ HEADERS += \
     doxygengenerator.h \
     functionutils.h \
     includeutils.h \
+    indexitem.h \
     insertionpointlocator.h \
     searchsymbols.h \
     stringtable.h \
@@ -103,6 +104,7 @@ SOURCES += \
     doxygengenerator.cpp \
     functionutils.cpp \
     includeutils.cpp \
+    indexitem.cpp \
     insertionpointlocator.cpp \
     searchsymbols.cpp \
     stringtable.cpp \
diff --git a/src/plugins/cpptools/cpptools.qbs b/src/plugins/cpptools/cpptools.qbs
index f74a840566d73815a54155ce0a2766a380d477e9..53fc46f23c0c491403db96b1a81621784598c9f0 100644
--- a/src/plugins/cpptools/cpptools.qbs
+++ b/src/plugins/cpptools/cpptools.qbs
@@ -71,6 +71,7 @@ QtcPlugin {
         "doxygengenerator.cpp", "doxygengenerator.h",
         "functionutils.cpp", "functionutils.h",
         "includeutils.cpp", "includeutils.h",
+        "indexitem.cpp", "indexitem.h",
         "insertionpointlocator.cpp", "insertionpointlocator.h",
         "searchsymbols.cpp", "searchsymbols.h",
         "stringtable.cpp", "stringtable.h",
diff --git a/src/plugins/cpptools/indexitem.cpp b/src/plugins/cpptools/indexitem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66784975d0f342f45bd05236ea3de5b10a387619
--- /dev/null
+++ b/src/plugins/cpptools/indexitem.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "indexitem.h"
+
+#include <utils/fileutils.h>
+
+using namespace CppTools;
+
+QString IndexItem::shortNativeFilePath() const
+{
+    return Utils::FileUtils::shortNativePath(Utils::FileName::fromString(m_fileName));
+}
+
+void IndexItem::squeeze()
+{
+    m_children.squeeze();
+    for (int i = 0, ei = m_children.size(); i != ei; ++i)
+        m_children[i]->squeeze();
+}
+
+void IndexItem::visitAllChildren(std::function<void (const IndexItem::Ptr &)> f) const
+{
+    foreach (const IndexItem::Ptr &child, m_children) {
+        f(child);
+        if (!child->m_children.isEmpty())
+            child->visitAllChildren(f);
+    }
+}
diff --git a/src/plugins/cpptools/indexitem.h b/src/plugins/cpptools/indexitem.h
new file mode 100644
index 0000000000000000000000000000000000000000..2ebf070f4baead724e25b92cdeda7dd3d9691f9a
--- /dev/null
+++ b/src/plugins/cpptools/indexitem.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CPPTOOLS_INDEXITEM_H
+#define CPPTOOLS_INDEXITEM_H
+
+#include "cpptools_global.h"
+
+#include <utils/function.h>
+
+#include <QIcon>
+#include <QSharedPointer>
+#include <QMetaType>
+
+namespace CppTools {
+
+class CPPTOOLS_EXPORT IndexItem
+{
+    Q_DISABLE_COPY(IndexItem)
+
+public:
+    enum ItemType { Enum, Class, Function, Declaration };
+
+private:
+    IndexItem(const QString &symbolName,
+                  const QString &symbolType,
+                  const QString &symbolScope,
+                  ItemType type,
+                  const QString &fileName,
+                  int line,
+                  int column,
+                  const QIcon &icon)
+        : m_symbolName(symbolName),
+          m_symbolType(symbolType),
+          m_symbolScope(symbolScope),
+          m_fileName(fileName),
+          m_icon(icon),
+          m_type(type),
+          m_line(line),
+          m_column(column)
+    {}
+
+    IndexItem(const QString &fileName, int sizeHint)
+        : m_fileName(fileName)
+        , m_type(Declaration)
+        , m_line(0)
+        , m_column(0)
+    { m_children.reserve(sizeHint); }
+
+public:
+    typedef QSharedPointer<IndexItem> Ptr;
+    static Ptr create(const QString &symbolName,
+                      const QString &symbolType,
+                      const QString &symbolScope,
+                      ItemType type,
+                      const QString &fileName,
+                      int line,
+                      int column,
+                      const QIcon &icon)
+    {
+        return Ptr(new IndexItem(
+                       symbolName, symbolType, symbolScope, type, fileName, line, column, icon));
+    }
+
+    static Ptr create(const QString &fileName, int sizeHint)
+    {
+        return Ptr(new IndexItem(fileName, sizeHint));
+    }
+
+    QString scopedSymbolName() const
+    {
+        return m_symbolScope.isEmpty()
+                ? m_symbolName
+                : m_symbolScope +  QLatin1String("::") + m_symbolName;
+    }
+
+    bool unqualifiedNameAndScope(const QString &defaultName, QString *name, QString *scope) const
+    {
+        *name = defaultName;
+        *scope = m_symbolScope;
+        const QString qualifiedName = scopedSymbolName();
+        const int colonColonPosition = qualifiedName.lastIndexOf(QLatin1String("::"));
+        if (colonColonPosition != -1) {
+            *name = qualifiedName.mid(colonColonPosition + 2);
+            *scope = qualifiedName.left(colonColonPosition);
+            return true;
+        }
+        return false;
+    }
+
+    static QString representDeclaration(const QString &name, const QString &type)
+    {
+        if (type.isEmpty())
+            return QString();
+
+        const QString padding = type.endsWith(QLatin1Char('*'))
+            ? QString()
+            : QString(QLatin1Char(' '));
+        return type + padding + name;
+    }
+
+    QString shortNativeFilePath() const;
+
+    QString symbolName() const { return m_symbolName; }
+    QString symbolType() const { return m_symbolType; }
+    QString symbolScope() const { return m_symbolScope; }
+    QString fileName() const { return m_fileName; }
+    QIcon icon() const { return m_icon; }
+    ItemType type() const { return m_type; }
+    int line() const { return m_line; }
+    int column() const { return m_column; }
+
+    void addChild(IndexItem::Ptr childItem) { m_children.append(childItem); }
+    void squeeze();
+
+    void visitAllChildren(std::function<void (const IndexItem::Ptr &)> f) const;
+
+private:
+    QString m_symbolName; // as found in the code, therefore might be qualified
+    QString m_symbolType;
+    QString m_symbolScope;
+    QString m_fileName;
+    QIcon m_icon;
+    ItemType m_type;
+    int m_line;
+    int m_column;
+    QVector<IndexItem::Ptr> m_children;
+};
+
+} // CppTools namespace
+
+Q_DECLARE_METATYPE(CppTools::IndexItem::Ptr)
+
+#endif // CPPTOOLS_INDEXITEM_H
diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp
index 49bc13ce8d8815a09e693718d8b13403ce506dfd..0fe83a1a41dbb4c9ffbb8a01f44c26bef2e95248 100644
--- a/src/plugins/cpptools/searchsymbols.cpp
+++ b/src/plugins/cpptools/searchsymbols.cpp
@@ -38,7 +38,7 @@
 using namespace CPlusPlus;
 using namespace CppTools;
 
-typedef Utils::ScopedSwap<ModelItemInfo::Ptr> ScopedModelItemInfoPtr;
+typedef Utils::ScopedSwap<IndexItem::Ptr> ScopedIndexItemPtr;
 typedef Utils::ScopedSwap<QString> ScopedScope;
 
 SearchSymbols::SymbolTypes SearchSymbols::AllTypes =
@@ -58,19 +58,19 @@ void SearchSymbols::setSymbolsToSearchFor(const SymbolTypes &types)
     symbolsToSearchFor = types;
 }
 
-ModelItemInfo::Ptr SearchSymbols::operator()(Document::Ptr doc, int sizeHint, const QString &scope)
+IndexItem::Ptr SearchSymbols::operator()(Document::Ptr doc, const QString &scope)
 {
-    ModelItemInfo::Ptr root = ModelItemInfo::create(findOrInsert(doc->fileName()), sizeHint);
+    IndexItem::Ptr root = IndexItem::create(findOrInsert(doc->fileName()), 100);
 
     { // RAII scope
-        ScopedModelItemInfoPtr parentRaii(_parent, root);
+        ScopedIndexItemPtr parentRaii(_parent, root);
         QString newScope = scope;
         ScopedScope scopeRaii(_scope, newScope);
 
-        QTC_ASSERT(_parent, return ModelItemInfo::Ptr());
-        QTC_ASSERT(root, return ModelItemInfo::Ptr());
+        QTC_ASSERT(_parent, return IndexItem::Ptr());
+        QTC_ASSERT(root, return IndexItem::Ptr());
         QTC_ASSERT(_parent->fileName() == findOrInsert(doc->fileName()),
-                   return ModelItemInfo::Ptr());
+                   return IndexItem::Ptr());
 
         for (unsigned i = 0, ei = doc->globalSymbolCount(); i != ei; ++i)
             accept(doc->globalSymbolAt(i));
@@ -89,11 +89,10 @@ bool SearchSymbols::visit(Enum *symbol)
         return false;
 
     QString name = overview.prettyName(symbol->name());
-    ModelItemInfo::Ptr newParent =
-            addChildItem(name, QString(), _scope, ModelItemInfo::Enum, symbol);
+    IndexItem::Ptr newParent = addChildItem(name, QString(), _scope, IndexItem::Enum, symbol);
     if (!newParent)
         newParent = _parent;
-    ScopedModelItemInfoPtr parentRaii(_parent, newParent);
+    ScopedIndexItemPtr parentRaii(_parent, newParent);
 
     QString newScope = scopedSymbolName(name, symbol);
     ScopedScope scopeRaii(_scope, newScope);
@@ -110,7 +109,7 @@ bool SearchSymbols::visit(Function *symbol)
         return false;
     QString name = overview.prettyName(symbol->name());
     QString type = overview.prettyType(symbol->type());
-    addChildItem(name, type, _scope, ModelItemInfo::Function, symbol);
+    addChildItem(name, type, _scope, IndexItem::Function, symbol);
     return false;
 }
 
@@ -144,8 +143,8 @@ bool SearchSymbols::visit(Declaration *symbol)
         QString name = overview.prettyName(symbol->name());
         QString type = overview.prettyType(symbol->type());
         addChildItem(name, type, _scope,
-                     symbol->type()->asFunctionType() ? ModelItemInfo::Function
-                                                      : ModelItemInfo::Declaration,
+                     symbol->type()->asFunctionType() ? IndexItem::Function
+                                                      : IndexItem::Declaration,
                      symbol);
     }
 
@@ -156,12 +155,12 @@ bool SearchSymbols::visit(Class *symbol)
 {
     QString name = overview.prettyName(symbol->name());
 
-    ModelItemInfo::Ptr newParent;
+    IndexItem::Ptr newParent;
     if (symbolsToSearchFor & SymbolSearcher::Classes)
-        newParent = addChildItem(name, QString(), _scope, ModelItemInfo::Class, symbol);
+        newParent = addChildItem(name, QString(), _scope, IndexItem::Class, symbol);
     if (!newParent)
         newParent = _parent;
-    ScopedModelItemInfoPtr parentRaii(_parent, newParent);
+    ScopedIndexItemPtr parentRaii(_parent, newParent);
 
     QString newScope = scopedSymbolName(name, symbol);
     ScopedScope scopeRaii(_scope, newScope);
@@ -291,13 +290,12 @@ QString SearchSymbols::scopeName(const QString &name, const Symbol *symbol) cons
     }
 }
 
-ModelItemInfo::Ptr SearchSymbols::addChildItem(const QString &symbolName, const QString &symbolType,
-                                               const QString &symbolScope,
-                                               ModelItemInfo::ItemType itemType,
-                                               Symbol *symbol)
+IndexItem::Ptr SearchSymbols::addChildItem(const QString &symbolName, const QString &symbolType,
+                                           const QString &symbolScope, IndexItem::ItemType itemType,
+                                           Symbol *symbol)
 {
     if (!symbol->name() || symbol->isGenerated())
-        return ModelItemInfo::Ptr();
+        return IndexItem::Ptr();
 
     QString path = m_paths.value(symbol->fileId(), QString());
     if (path.isEmpty()) {
@@ -306,30 +304,14 @@ ModelItemInfo::Ptr SearchSymbols::addChildItem(const QString &symbolName, const
     }
 
     const QIcon icon = icons.iconForSymbol(symbol);
-    ModelItemInfo::Ptr newItem = ModelItemInfo::create(findOrInsert(symbolName),
-                                                       findOrInsert(symbolType),
-                                                       findOrInsert(symbolScope),
-                                                       itemType,
-                                                       findOrInsert(path),
-                                                       symbol->line(),
-                                                       symbol->column() - 1, // 1-based vs 0-based column
-                                                       icon);
+    IndexItem::Ptr newItem = IndexItem::create(findOrInsert(symbolName),
+                                               findOrInsert(symbolType),
+                                               findOrInsert(symbolScope),
+                                               itemType,
+                                               findOrInsert(path),
+                                               symbol->line(),
+                                               symbol->column() - 1, // 1-based vs 0-based column
+                                               icon);
     _parent->addChild(newItem);
     return newItem;
 }
-
-void ModelItemInfo::squeeze()
-{
-    m_children.squeeze();
-    for (int i = 0, ei = m_children.size(); i != ei; ++i)
-        m_children[i]->squeeze();
-}
-
-void ModelItemInfo::visitAllChildren(std::function<void (const ModelItemInfo::Ptr &)> f) const
-{
-    foreach (const ModelItemInfo::Ptr &child, m_children) {
-        f(child);
-        if (!child->m_children.isEmpty())
-            child->visitAllChildren(f);
-    }
-}
diff --git a/src/plugins/cpptools/searchsymbols.h b/src/plugins/cpptools/searchsymbols.h
index 3e05bb3ef056980079c3c83b3146d3d5b49033bf..c4306bfb96ee6a543236250f8ae910ede806bc0c 100644
--- a/src/plugins/cpptools/searchsymbols.h
+++ b/src/plugins/cpptools/searchsymbols.h
@@ -32,137 +32,19 @@
 
 #include "cpptools_global.h"
 #include "cppindexingsupport.h"
+#include "indexitem.h"
 #include "stringtable.h"
 
 #include <cplusplus/CppDocument.h>
 #include <cplusplus/Icons.h>
 #include <cplusplus/Overview.h>
 
-#include <utils/fileutils.h>
-#include <utils/function.h>
-
-#include <QIcon>
 #include <QString>
 #include <QSet>
-#include <QSharedPointer>
 #include <QHash>
 
 namespace CppTools {
 
-class CPPTOOLS_EXPORT ModelItemInfo
-{
-    Q_DISABLE_COPY(ModelItemInfo)
-
-public:
-    enum ItemType { Enum, Class, Function, Declaration };
-
-private:
-    ModelItemInfo(const QString &symbolName,
-                  const QString &symbolType,
-                  const QString &symbolScope,
-                  ItemType type,
-                  const QString &fileName,
-                  int line,
-                  int column,
-                  const QIcon &icon)
-        : m_symbolName(symbolName),
-          m_symbolType(symbolType),
-          m_symbolScope(symbolScope),
-          m_fileName(fileName),
-          m_icon(icon),
-          m_type(type),
-          m_line(line),
-          m_column(column)
-    {}
-
-    ModelItemInfo(const QString &fileName, int sizeHint)
-        : m_fileName(fileName)
-        , m_type(Declaration)
-        , m_line(0)
-        , m_column(0)
-    { m_children.reserve(sizeHint); }
-
-public:
-    typedef QSharedPointer<ModelItemInfo> Ptr;
-    static Ptr create(const QString &symbolName,
-                      const QString &symbolType,
-                      const QString &symbolScope,
-                      ItemType type,
-                      const QString &fileName,
-                      int line,
-                      int column,
-                      const QIcon &icon)
-    {
-        return Ptr(new ModelItemInfo(
-                       symbolName, symbolType, symbolScope, type, fileName, line, column, icon));
-    }
-
-    static Ptr create(const QString &fileName, int sizeHint)
-    {
-        return Ptr(new ModelItemInfo(fileName, sizeHint));
-    }
-
-    QString scopedSymbolName() const
-    {
-        return m_symbolScope.isEmpty()
-                ? m_symbolName
-                : m_symbolScope +  QLatin1String("::") + m_symbolName;
-    }
-
-    bool unqualifiedNameAndScope(const QString &defaultName, QString *name, QString *scope) const
-    {
-        *name = defaultName;
-        *scope = m_symbolScope;
-        const QString qualifiedName = scopedSymbolName();
-        const int colonColonPosition = qualifiedName.lastIndexOf(QLatin1String("::"));
-        if (colonColonPosition != -1) {
-            *name = qualifiedName.mid(colonColonPosition + 2);
-            *scope = qualifiedName.left(colonColonPosition);
-            return true;
-        }
-        return false;
-    }
-
-    static QString representDeclaration(const QString &name, const QString &type)
-    {
-        if (type.isEmpty())
-            return QString();
-
-        const QString padding = type.endsWith(QLatin1Char('*'))
-            ? QString()
-            : QString(QLatin1Char(' '));
-        return type + padding + name;
-    }
-
-    QString shortNativeFilePath() const
-    { return Utils::FileUtils::shortNativePath(Utils::FileName::fromString(m_fileName)); }
-
-    QString symbolName() const { return m_symbolName; }
-    QString symbolType() const { return m_symbolType; }
-    QString symbolScope() const { return m_symbolScope; }
-    QString fileName() const { return m_fileName; }
-    QIcon icon() const { return m_icon; }
-    ItemType type() const { return m_type; }
-    int line() const { return m_line; }
-    int column() const { return m_column; }
-
-    void addChild(ModelItemInfo::Ptr childItem) { m_children.append(childItem); }
-    void squeeze();
-
-    void visitAllChildren(std::function<void (const ModelItemInfo::Ptr &)> f) const;
-
-private:
-    QString m_symbolName; // as found in the code, therefore might be qualified
-    QString m_symbolType;
-    QString m_symbolScope;
-    QString m_fileName;
-    QIcon m_icon;
-    ItemType m_type;
-    int m_line;
-    int m_column;
-    QVector<ModelItemInfo::Ptr> m_children;
-};
-
 class SearchSymbols: protected CPlusPlus::SymbolVisitor
 {
 public:
@@ -174,10 +56,10 @@ public:
 
     void setSymbolsToSearchFor(const SymbolTypes &types);
 
-    ModelItemInfo::Ptr operator()(CPlusPlus::Document::Ptr doc, int sizeHint = 500)
-    { return operator()(doc, sizeHint, QString()); }
+    IndexItem::Ptr operator()(CPlusPlus::Document::Ptr doc)
+    { return operator()(doc, QString()); }
 
-    ModelItemInfo::Ptr operator()(CPlusPlus::Document::Ptr doc, int sizeHint, const QString &scope);
+    IndexItem::Ptr operator()(CPlusPlus::Document::Ptr doc, const QString &scope);
 
 protected:
     using SymbolVisitor::visit;
@@ -213,11 +95,9 @@ protected:
     QString scopedSymbolName(const QString &symbolName, const CPlusPlus::Symbol *symbol) const;
     QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const;
     QString scopeName(const QString &name, const CPlusPlus::Symbol *symbol) const;
-    ModelItemInfo::Ptr addChildItem(const QString &symbolName,
-                                    const QString &symbolType,
-                                    const QString &symbolScope,
-                                    ModelItemInfo::ItemType type,
-                                    CPlusPlus::Symbol *symbol);
+    IndexItem::Ptr addChildItem(const QString &symbolName, const QString &symbolType,
+                                const QString &symbolScope, IndexItem::ItemType type,
+                                CPlusPlus::Symbol *symbol);
 
 private:
     QString findOrInsert(const QString &s)
@@ -225,7 +105,7 @@ private:
 
     Internal::StringTable &strings;            // Used to avoid QString duplication
 
-    ModelItemInfo::Ptr _parent;
+    IndexItem::Ptr _parent;
     QString _scope;
     CPlusPlus::Overview overview;
     CPlusPlus::Icons icons;
@@ -236,6 +116,5 @@ private:
 } // namespace CppTools
 
 Q_DECLARE_OPERATORS_FOR_FLAGS(CppTools::SearchSymbols::SymbolTypes)
-Q_DECLARE_METATYPE(CppTools::ModelItemInfo::Ptr)
 
 #endif // SEARCHSYMBOLS_H
diff --git a/src/plugins/cpptools/symbolsfindfilter.cpp b/src/plugins/cpptools/symbolsfindfilter.cpp
index 1b5ae8d76cd3eab28c492467d627779b5d907221..2b55a83e02a5c55f14bc895b67c78fdf63f8fd11 100644
--- a/src/plugins/cpptools/symbolsfindfilter.cpp
+++ b/src/plugins/cpptools/symbolsfindfilter.cpp
@@ -181,9 +181,9 @@ void SymbolsFindFilter::finish()
 
 void SymbolsFindFilter::openEditor(const Core::SearchResultItem &item)
 {
-    if (!item.userData.canConvert<ModelItemInfo::Ptr>())
+    if (!item.userData.canConvert<IndexItem::Ptr>())
         return;
-    ModelItemInfo::Ptr info = item.userData.value<ModelItemInfo::Ptr>();
+    IndexItem::Ptr info = item.userData.value<IndexItem::Ptr>();
     EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
 }