diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2008-12-09 17:15:00 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2008-12-09 17:19:35 +0100 |
commit | 5f544b4daf99356baf3535cf0b776b8cf5789b48 (patch) | |
tree | 035b9ad12b32454dacd9c24e349c0697006fc75f | |
parent | a908e6737c5995bac68daf94d76fa1d0fb0a46bd (diff) | |
download | qt-creator-5f544b4daf99356baf3535cf0b776b8cf5789b48.tar.gz |
Added the CppFunctionsFilter to QuickOpen
In the GUI this is currently called "Methods" with the shortcut 'm'.
-rw-r--r-- | src/plugins/cpptools/cppfunctionsfilter.cpp | 50 | ||||
-rw-r--r-- | src/plugins/cpptools/cppfunctionsfilter.h | 58 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptools.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptools.pro | 7 | ||||
-rw-r--r-- | src/plugins/cpptools/searchsymbols.cpp | 17 |
5 files changed, 129 insertions, 5 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/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 47f540c6dd..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; } |