Commit 5f544b4d authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Added the CppFunctionsFilter to QuickOpen

In the GUI this is currently called "Methods" with the shortcut 'm'.
parent a908e673
/***************************************************************************
**
** 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()
{
}
/***************************************************************************
**
** 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
......@@ -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);
......
......@@ -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 \
......
......@@ -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;
}
......
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