2010-09-24 14:05:34 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-09-24 14:05:34 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-09-24 14:05:34 +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.
|
2010-09-24 14:05:34 +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
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-09-24 14:05:34 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef QMLJSFINDREFERENCES_H
|
|
|
|
|
#define QMLJSFINDREFERENCES_H
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QMutex>
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
#include <QtCore/QFuture>
|
|
|
|
|
#include <QtCore/QFutureWatcher>
|
2011-09-09 16:10:57 +02:00
|
|
|
#include <QtCore/QPointer>
|
2010-09-24 14:05:34 +02:00
|
|
|
#include <utils/filesearch.h>
|
|
|
|
|
#include <qmljs/qmljsdocument.h>
|
|
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QTimer)
|
|
|
|
|
|
|
|
|
|
namespace Find {
|
|
|
|
|
struct SearchResultItem;
|
2011-09-02 11:51:31 +02:00
|
|
|
class SearchResult;
|
2011-02-04 09:52:39 +01:00
|
|
|
} // namespace Find
|
2010-09-24 14:05:34 +02:00
|
|
|
|
|
|
|
|
namespace QmlJSEditor {
|
|
|
|
|
|
|
|
|
|
class FindReferences: public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
class Usage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Usage()
|
|
|
|
|
: line(0), col(0), len(0) {}
|
|
|
|
|
|
|
|
|
|
Usage(const QString &path, const QString &lineText, int line, int col, int len)
|
|
|
|
|
: path(path), lineText(lineText), line(line), col(col), len(len) {}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
QString path;
|
|
|
|
|
QString lineText;
|
|
|
|
|
int line;
|
|
|
|
|
int col;
|
|
|
|
|
int len;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FindReferences(QObject *parent = 0);
|
|
|
|
|
virtual ~FindReferences();
|
|
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void changed();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void findUsages(const QString &fileName, quint32 offset);
|
2011-07-11 12:53:05 +02:00
|
|
|
void renameUsages(const QString &fileName, quint32 offset,
|
|
|
|
|
const QString &replacement = QString());
|
2010-09-24 14:05:34 +02:00
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
|
void displayResults(int first, int last);
|
|
|
|
|
void searchFinished();
|
2011-09-09 08:46:51 +02:00
|
|
|
void cancel();
|
2010-09-24 14:05:34 +02:00
|
|
|
void openEditor(const Find::SearchResultItem &item);
|
2011-07-11 12:53:05 +02:00
|
|
|
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
2010-09-24 14:05:34 +02:00
|
|
|
|
|
|
|
|
private:
|
2011-09-09 16:10:57 +02:00
|
|
|
QPointer<Find::SearchResult> m_currentSearch;
|
2010-09-24 14:05:34 +02:00
|
|
|
QFutureWatcher<Usage> m_watcher;
|
|
|
|
|
};
|
|
|
|
|
|
2011-02-04 09:52:39 +01:00
|
|
|
} // namespace QmlJSEditor
|
2010-09-24 14:05:34 +02:00
|
|
|
|
|
|
|
|
#endif // QMLJSFINDREFERENCES_H
|