summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools
diff options
context:
space:
mode:
authormae <qtc-committer@nokia.com>2008-12-10 11:50:35 +0100
committermae <qtc-committer@nokia.com>2008-12-10 11:50:35 +0100
commit39ad48c3b7dec95b5dcb867567eb053c89bb44ca (patch)
treebf80dcd077c6ebcb55e4b6bd7702e17e7a8609f3 /src/plugins/cpptools
parent1931304da1b59fcc396b3a550d0c9817ba73f8af (diff)
parent9c9308b91b116138ed5cc7753cf59eefd5a86db9 (diff)
downloadqt-creator-39ad48c3b7dec95b5dcb867567eb053c89bb44ca.tar.gz
Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r--src/plugins/cpptools/cppfunctionsfilter.cpp50
-rw-r--r--src/plugins/cpptools/cppfunctionsfilter.h58
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp8
-rw-r--r--src/plugins/cpptools/cppquickopenfilter.cpp9
-rw-r--r--src/plugins/cpptools/cpptools.cpp2
-rw-r--r--src/plugins/cpptools/cpptools.pro7
-rw-r--r--src/plugins/cpptools/searchsymbols.cpp22
7 files changed, 146 insertions, 10 deletions
diff --git a/src/plugins/cpptools/cppfunctionsfilter.cpp b/src/plugins/cpptools/cppfunctionsfilter.cpp
new file mode 100644
index 0000000000..61bb8e2d00
--- /dev/null
+++ b/src/plugins/cpptools/cppfunctionsfilter.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception
+** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+
+#include "cppfunctionsfilter.h"
+
+using namespace CppTools::Internal;
+
+CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager)
+ : CppQuickOpenFilter(manager, editorManager)
+{
+ setShortcutString("m");
+ setIncludedByDefault(false);
+
+ search.setSymbolsToSearchFor(SearchSymbols::Functions);
+ search.setSeparateScope(true);
+}
+
+CppFunctionsFilter::~CppFunctionsFilter()
+{
+}
diff --git a/src/plugins/cpptools/cppfunctionsfilter.h b/src/plugins/cpptools/cppfunctionsfilter.h
new file mode 100644
index 0000000000..6e48d65b26
--- /dev/null
+++ b/src/plugins/cpptools/cppfunctionsfilter.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception
+** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+
+#ifndef CPPFUNCTIONSFILTER_H
+#define CPPFUNCTIONSFILTER_H
+
+#include <cppquickopenfilter.h>
+
+namespace CppTools {
+namespace Internal {
+
+class CppFunctionsFilter : public CppQuickOpenFilter
+{
+ Q_OBJECT
+
+public:
+ CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager);
+ ~CppFunctionsFilter();
+
+ QString trName() const { return tr("Methods"); }
+ QString name() const { return QLatin1String("Methods"); }
+ Priority priority() const { return Medium; }
+};
+
+} // namespace Internal
+} // namespace CppTools
+
+#endif // CPPFUNCTIONSFILTER_H
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 5111aa3199..40888d99f3 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -390,17 +390,17 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
} else {
Document::Ptr previousDoc = switchDocument(Document::create(fileName));
- const QByteArray previousFile = env.current_file;
+ const QByteArray previousFile = env.currentFile;
const unsigned previousLine = env.currentLine;
- env.current_file = QByteArray(m_currentDoc->translationUnit()->fileName(),
- m_currentDoc->translationUnit()->fileNameLength());
+ env.currentFile = QByteArray(m_currentDoc->translationUnit()->fileName(),
+ m_currentDoc->translationUnit()->fileNameLength());
QByteArray preprocessedCode;
m_proc(contents, &preprocessedCode);
//qDebug() << preprocessedCode;
- env.current_file = previousFile;
+ env.currentFile = previousFile;
env.currentLine = previousLine;
m_currentDoc->setSource(preprocessedCode);
diff --git a/src/plugins/cpptools/cppquickopenfilter.cpp b/src/plugins/cpptools/cppquickopenfilter.cpp
index a1f1a9b371..ac69c9cc6d 100644
--- a/src/plugins/cpptools/cppquickopenfilter.cpp
+++ b/src/plugins/cpptools/cppquickopenfilter.cpp
@@ -75,6 +75,12 @@ void CppQuickOpenFilter::refresh(QFutureInterface<void> &future)
Q_UNUSED(future);
}
+static bool compareLexigraphically(const QuickOpen::FilterEntry &a,
+ const QuickOpen::FilterEntry &b)
+{
+ return a.displayName < b.displayName;
+}
+
QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &origEntry)
{
QString entry = trimWildcards(origEntry);
@@ -109,6 +115,9 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig
}
}
+ if (entries.size() < 1000)
+ qSort(entries.begin(), entries.end(), compareLexigraphically);
+
return entries;
}
diff --git a/src/plugins/cpptools/cpptools.cpp b/src/plugins/cpptools/cpptools.cpp
index 957f0cae9b..5e9f6dca45 100644
--- a/src/plugins/cpptools/cpptools.cpp
+++ b/src/plugins/cpptools/cpptools.cpp
@@ -34,6 +34,7 @@
#include "cpptools.h"
#include "cppclassesfilter.h"
#include "cppcodecompletion.h"
+#include "cppfunctionsfilter.h"
#include "cpphoverhandler.h"
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
@@ -89,6 +90,7 @@ bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *)
m_core->editorManager());
addAutoReleasedObject(quickOpenFilter);
addAutoReleasedObject(new CppClassesFilter(m_modelManager, m_core->editorManager()));
+ addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, m_core->editorManager()));
// Menus
Core::IActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS);
diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro
index 92905e42ef..74112379e3 100644
--- a/src/plugins/cpptools/cpptools.pro
+++ b/src/plugins/cpptools/cpptools.pro
@@ -10,15 +10,16 @@ unix:QMAKE_CXXFLAGS_DEBUG += -O3
INCLUDEPATH += .
DEFINES += CPPTOOLS_LIBRARY
CONFIG += help
-
HEADERS += cpptools_global.h \
cppquickopenfilter.h \
cppclassesfilter.h \
- searchsymbols.h
+ searchsymbols.h \
+ cppfunctionsfilter.h
SOURCES += cppquickopenfilter.cpp \
cpptoolseditorsupport.cpp \
cppclassesfilter.cpp \
- searchsymbols.cpp
+ searchsymbols.cpp \
+ cppfunctionsfilter.cpp
# Input
SOURCES += cpptools.cpp \
diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp
index 308449ab58..2669ea7bc7 100644
--- a/src/plugins/cpptools/searchsymbols.cpp
+++ b/src/plugins/cpptools/searchsymbols.cpp
@@ -35,6 +35,7 @@
#include <Literals.h>
#include <Scope.h>
+#include <Names.h>
using namespace CPlusPlus;
using namespace CppTools::Internal;
@@ -97,12 +98,24 @@ bool SearchSymbols::visit(Function *symbol)
if (!(symbolsToSearchFor & Functions))
return false;
+ QString extraScope;
+ if (Name *name = symbol->name()) {
+ if (QualifiedNameId *nameId = name->asQualifiedNameId()) {
+ if (nameId->nameCount() > 1) {
+ extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2));
+ }
+ }
+ }
+ QString fullScope = _scope;
+ if (!_scope.isEmpty() && !extraScope.isEmpty())
+ fullScope += QLatin1String("::");
+ fullScope += extraScope;
QString name = symbolName(symbol);
QString scopedName = scopedSymbolName(name);
QString type = overview.prettyType(symbol->type(),
- separateScope ? symbol->name() : 0);
+ separateScope ? symbol->identity() : 0);
appendItem(separateScope ? type : scopedName,
- separateScope ? _scope : type,
+ separateScope ? fullScope : type,
ModelItemInfo::Method, symbol);
return false;
}
@@ -153,7 +166,7 @@ bool SearchSymbols::visit(Class *symbol)
QString SearchSymbols::scopedSymbolName(const QString &symbolName) const
{
QString name = _scope;
- if (! name.isEmpty())
+ if (!name.isEmpty())
name += QLatin1String("::");
name += symbolName;
return name;
@@ -196,6 +209,9 @@ void SearchSymbols::appendItem(const QString &name,
ModelItemInfo::ItemType type,
const Symbol *symbol)
{
+ if (!symbol->name())
+ return;
+
const QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, info, type,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),