Files
qt-creator/src/plugins/cpptools/cppfindreferences.h

106 lines
3.4 KiB
C
Raw Normal View History

2009-08-07 13:02:36 +02:00
/**************************************************************************
**
** This file is part of Qt Creator
**
2011-01-11 16:28:15 +01:00
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
2009-08-07 13:02:36 +02:00
**
** Contact: Nokia Corporation (qt-info@nokia.com)
2009-08-07 13:02:36 +02:00
**
**
** GNU Lesser General Public License Usage
**
2011-04-13 08:42:33 +02:00
** 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.
2009-08-07 13:02:36 +02:00
**
2010-12-17 16:01:08 +01:00
** In addition, as a special exception, Nokia gives you certain additional
2011-04-13 08:42:33 +02:00
** rights. These rights are described in the Nokia Qt LGPL Exception
2010-12-17 16:01:08 +01:00
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
2011-04-13 08:42:33 +02:00
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
2010-12-17 16:01:08 +01:00
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
2009-08-07 13:02:36 +02:00
**
**************************************************************************/
#ifndef CPPFINDREFERENCES_H
#define CPPFINDREFERENCES_H
#include <utils/filesearch.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/DependencyTable.h>
#include <cplusplus/FindUsages.h>
#include <QtCore/QMutex>
2009-08-07 13:02:36 +02:00
#include <QtCore/QObject>
#include <QtCore/QPointer>
#include <QtCore/QFuture>
#include <QtCore/QFutureWatcher>
QT_FORWARD_DECLARE_CLASS(QTimer)
2009-08-07 13:02:36 +02:00
namespace Find {
struct SearchResultItem;
class SearchResult;
} // namespace Find
2009-08-07 13:02:36 +02:00
namespace CPlusPlus {
class CppModelManagerInterface;
}
2009-08-07 13:02:36 +02:00
namespace CppTools {
namespace Internal {
2009-08-07 13:02:36 +02:00
class CppFindReferences: public QObject
{
Q_OBJECT
public:
CppFindReferences(CPlusPlus::CppModelManagerInterface *modelManager);
2009-08-07 13:02:36 +02:00
virtual ~CppFindReferences();
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) const;
2009-08-07 13:02:36 +02:00
public:
void findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
void renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context,
const QString &replacement = QString());
2009-08-07 13:02:36 +02:00
void findMacroUses(const CPlusPlus::Macro &macro);
CPlusPlus::DependencyTable updateDependencyTable(CPlusPlus::Snapshot snapshot);
2009-08-07 13:02:36 +02:00
private Q_SLOTS:
2009-12-01 17:07:35 +01:00
void displayResults(int first, int last);
2009-08-07 13:02:36 +02:00
void searchFinished();
void cancel();
void openEditor(const Find::SearchResultItem &item);
2009-10-05 18:02:46 +02:00
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
2009-08-07 13:02:36 +02:00
2009-10-05 15:17:25 +02:00
private:
void findAll_helper(Find::SearchResult *search,
CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
CPlusPlus::DependencyTable dependencyTable() const;
void setDependencyTable(const CPlusPlus::DependencyTable &newTable);
void createWatcher(const QFuture<CPlusPlus::Usage> &future, Find::SearchResult *search);
2009-10-05 15:17:25 +02:00
2009-08-07 13:02:36 +02:00
private:
QPointer<CPlusPlus::CppModelManagerInterface> _modelManager;
QMap<QFutureWatcher<CPlusPlus::Usage> *, QPointer<Find::SearchResult> > m_watchers;
mutable QMutex m_depsLock;
CPlusPlus::DependencyTable m_deps;
2009-08-07 13:02:36 +02:00
};
} // namespace Internal
} // namespace CppTools
2009-08-07 13:02:36 +02:00
#endif // CPPFINDREFERENCES_H