forked from qt-creator/qt-creator
Move and cleanup search specific API to SearchResult class
Change-Id: I7e64701e8833ad38b9ac01d316bd00302602a390 Rubber-stamped-by: Daniel Teske Reviewed-on: http://codereview.qt.nokia.com/4179 Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -162,7 +162,7 @@ public:
|
|||||||
CppFindReferences::CppFindReferences(CppModelManagerInterface *modelManager)
|
CppFindReferences::CppFindReferences(CppModelManagerInterface *modelManager)
|
||||||
: QObject(modelManager),
|
: QObject(modelManager),
|
||||||
_modelManager(modelManager),
|
_modelManager(modelManager),
|
||||||
_resultWindow(Find::SearchResultWindow::instance())
|
m_currentSearch(0)
|
||||||
{
|
{
|
||||||
m_watcher.setPendingResultsLimit(1);
|
m_watcher.setPendingResultsLimit(1);
|
||||||
connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int)));
|
connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int)));
|
||||||
@@ -227,9 +227,9 @@ static void find_helper(QFutureInterface<Usage> &future,
|
|||||||
|
|
||||||
void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context)
|
void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context)
|
||||||
{
|
{
|
||||||
Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchOnly);
|
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly);
|
||||||
|
|
||||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
|
||||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
|
|
||||||
findAll_helper(symbol, context);
|
findAll_helper(symbol, context);
|
||||||
@@ -242,14 +242,14 @@ void CppFindReferences::renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus:
|
|||||||
const QString textToReplace = replacement.isEmpty()
|
const QString textToReplace = replacement.isEmpty()
|
||||||
? QString::fromUtf8(id->chars(), id->size()) : replacement;
|
? QString::fromUtf8(id->chars(), id->size()) : replacement;
|
||||||
|
|
||||||
Find::SearchResult *search = _resultWindow->startNewSearch(
|
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(
|
||||||
Find::SearchResultWindow::SearchAndReplace, QLatin1String("CppEditor"));
|
Find::SearchResultWindow::SearchAndReplace, QLatin1String("CppEditor"));
|
||||||
_resultWindow->setTextToReplace(textToReplace);
|
m_currentSearch->setTextToReplace(textToReplace);
|
||||||
|
|
||||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
|
||||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
|
|
||||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
||||||
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
||||||
|
|
||||||
findAll_helper(symbol, context);
|
findAll_helper(symbol, context);
|
||||||
@@ -261,7 +261,7 @@ void CppFindReferences::findAll_helper(Symbol *symbol, const LookupContext &cont
|
|||||||
if (! (symbol && symbol->identifier()))
|
if (! (symbol && symbol->identifier()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_resultWindow->popup(true);
|
Find::SearchResultWindow::instance()->popup(true);
|
||||||
|
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
|
const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ void CppFindReferences::findAll_helper(Symbol *symbol, const LookupContext &cont
|
|||||||
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
|
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
|
||||||
CppTools::Constants::TASK_SEARCH);
|
CppTools::Constants::TASK_SEARCH);
|
||||||
|
|
||||||
connect(progress, SIGNAL(clicked()), _resultWindow, SLOT(popup()));
|
connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
||||||
@@ -284,7 +284,7 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
|||||||
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items);
|
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items);
|
||||||
if (!fileNames.isEmpty()) {
|
if (!fileNames.isEmpty()) {
|
||||||
_modelManager->updateSourceFiles(fileNames);
|
_modelManager->updateSourceFiles(fileNames);
|
||||||
_resultWindow->hide();
|
Find::SearchResultWindow::instance()->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ void CppFindReferences::displayResults(int first, int last)
|
|||||||
{
|
{
|
||||||
for (int index = first; index != last; ++index) {
|
for (int index = first; index != last; ++index) {
|
||||||
Usage result = m_watcher.future().resultAt(index);
|
Usage result = m_watcher.future().resultAt(index);
|
||||||
_resultWindow->addResult(result.path,
|
m_currentSearch->addResult(result.path,
|
||||||
result.line,
|
result.line,
|
||||||
result.lineText,
|
result.lineText,
|
||||||
result.col,
|
result.col,
|
||||||
@@ -302,7 +302,8 @@ void CppFindReferences::displayResults(int first, int last)
|
|||||||
|
|
||||||
void CppFindReferences::searchFinished()
|
void CppFindReferences::searchFinished()
|
||||||
{
|
{
|
||||||
_resultWindow->finishSearch();
|
m_currentSearch->finishSearch();
|
||||||
|
m_currentSearch = 0;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,11 +414,11 @@ static void findMacroUses_helper(QFutureInterface<Usage> &future,
|
|||||||
|
|
||||||
void CppFindReferences::findMacroUses(const Macro ¯o)
|
void CppFindReferences::findMacroUses(const Macro ¯o)
|
||||||
{
|
{
|
||||||
Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchOnly);
|
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly);
|
||||||
|
|
||||||
_resultWindow->popup(true);
|
Find::SearchResultWindow::instance()->popup(true);
|
||||||
|
|
||||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
|
||||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
|
|
||||||
const Snapshot snapshot = _modelManager->snapshot();
|
const Snapshot snapshot = _modelManager->snapshot();
|
||||||
@@ -427,7 +428,7 @@ void CppFindReferences::findMacroUses(const Macro ¯o)
|
|||||||
{
|
{
|
||||||
// ### FIXME: Encoding?
|
// ### FIXME: Encoding?
|
||||||
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
|
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
|
||||||
_resultWindow->addResult(macro.fileName(), macro.line(),
|
m_currentSearch->addResult(macro.fileName(), macro.line(),
|
||||||
source.mid(macro.offset(), macro.length()), 0, macro.length());
|
source.mid(macro.offset(), macro.length()), 0, macro.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +439,7 @@ void CppFindReferences::findMacroUses(const Macro ¯o)
|
|||||||
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
|
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
|
||||||
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
|
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
|
||||||
CppTools::Constants::TASK_SEARCH);
|
CppTools::Constants::TASK_SEARCH);
|
||||||
connect(progress, SIGNAL(clicked()), _resultWindow, SLOT(popup()));
|
connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DependencyTable CppFindReferences::updateDependencyTable(CPlusPlus::Snapshot snapshot)
|
DependencyTable CppFindReferences::updateDependencyTable(CPlusPlus::Snapshot snapshot)
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||||
|
|
||||||
namespace Find {
|
namespace Find {
|
||||||
class SearchResultWindow;
|
|
||||||
struct SearchResultItem;
|
struct SearchResultItem;
|
||||||
|
class SearchResult;
|
||||||
} // namespace Find
|
} // namespace Find
|
||||||
|
|
||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
@@ -92,7 +92,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<CPlusPlus::CppModelManagerInterface> _modelManager;
|
QPointer<CPlusPlus::CppModelManagerInterface> _modelManager;
|
||||||
Find::SearchResultWindow *_resultWindow;
|
Find::SearchResult *m_currentSearch;
|
||||||
QFutureWatcher<CPlusPlus::Usage> m_watcher;
|
QFutureWatcher<CPlusPlus::Usage> m_watcher;
|
||||||
|
|
||||||
mutable QMutex m_depsLock;
|
mutable QMutex m_depsLock;
|
||||||
|
|||||||
@@ -102,10 +102,11 @@ namespace {
|
|||||||
|
|
||||||
SymbolsFindFilter::SymbolsFindFilter(CppModelManager *manager)
|
SymbolsFindFilter::SymbolsFindFilter(CppModelManager *manager)
|
||||||
: m_manager(manager),
|
: m_manager(manager),
|
||||||
m_isRunning(false),
|
m_isRunning(false),
|
||||||
m_enabled(true),
|
m_enabled(true),
|
||||||
m_symbolsToSearch(SearchSymbols::AllTypes),
|
m_currentSearch(0),
|
||||||
m_scope(SearchProjectsOnly)
|
m_symbolsToSearch(SearchSymbols::AllTypes),
|
||||||
|
m_scope(SearchProjectsOnly)
|
||||||
{
|
{
|
||||||
// for disabling while parser is running
|
// for disabling while parser is running
|
||||||
connect(Core::ICore::instance()->progressManager(), SIGNAL(taskStarted(QString)),
|
connect(Core::ICore::instance()->progressManager(), SIGNAL(taskStarted(QString)),
|
||||||
@@ -154,8 +155,8 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
|
|||||||
m_isRunning = true;
|
m_isRunning = true;
|
||||||
emit changed();
|
emit changed();
|
||||||
Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
|
Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
|
||||||
Find::SearchResult *result = window->startNewSearch();
|
m_currentSearch = window->startNewSearch();
|
||||||
connect(result, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
|
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
window->popup(true);
|
window->popup(true);
|
||||||
|
|
||||||
m_search.setSymbolsToSearchFor(m_symbolsToSearch);
|
m_search.setSymbolsToSearchFor(m_symbolsToSearch);
|
||||||
@@ -179,17 +180,16 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
|
|||||||
|
|
||||||
void SymbolsFindFilter::addResults(int begin, int end)
|
void SymbolsFindFilter::addResults(int begin, int end)
|
||||||
{
|
{
|
||||||
Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
|
|
||||||
QList<Find::SearchResultItem> items;
|
QList<Find::SearchResultItem> items;
|
||||||
for (int i = begin; i < end; ++i)
|
for (int i = begin; i < end; ++i)
|
||||||
items << m_watcher.resultAt(i);
|
items << m_watcher.resultAt(i);
|
||||||
window->addResults(items, Find::SearchResultWindow::AddSorted);
|
m_currentSearch->addResults(items, Find::SearchResult::AddSorted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolsFindFilter::finish()
|
void SymbolsFindFilter::finish()
|
||||||
{
|
{
|
||||||
Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
|
m_currentSearch->finishSearch();
|
||||||
window->finishSearch();
|
m_currentSearch = 0;
|
||||||
m_isRunning = false;
|
m_isRunning = false;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ private:
|
|||||||
bool m_isRunning;
|
bool m_isRunning;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
QFutureWatcher<Find::SearchResultItem> m_watcher;
|
QFutureWatcher<Find::SearchResultItem> m_watcher;
|
||||||
|
Find::SearchResult *m_currentSearch;
|
||||||
SearchSymbols::SymbolTypes m_symbolsToSearch;
|
SearchSymbols::SymbolTypes m_symbolsToSearch;
|
||||||
SearchSymbols m_search;
|
SearchSymbols m_search;
|
||||||
SearchScope m_scope;
|
SearchScope m_scope;
|
||||||
|
|||||||
@@ -336,19 +336,19 @@ QSet<SearchResultTreeItem *> SearchResultTreeModel::addPath(const QStringList &p
|
|||||||
return pathNodes;
|
return pathNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultTreeModel::addResultsToCurrentParent(const QList<SearchResultItem> &items, SearchResultWindow::AddMode mode)
|
void SearchResultTreeModel::addResultsToCurrentParent(const QList<SearchResultItem> &items, SearchResult::AddMode mode)
|
||||||
{
|
{
|
||||||
if (!m_currentParent)
|
if (!m_currentParent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mode == SearchResultWindow::AddOrdered) {
|
if (mode == SearchResult::AddOrdered) {
|
||||||
// this is the mode for e.g. text search
|
// this is the mode for e.g. text search
|
||||||
beginInsertRows(m_currentIndex, m_currentParent->childrenCount(), m_currentParent->childrenCount() + items.count());
|
beginInsertRows(m_currentIndex, m_currentParent->childrenCount(), m_currentParent->childrenCount() + items.count());
|
||||||
foreach (const SearchResultItem &item, items) {
|
foreach (const SearchResultItem &item, items) {
|
||||||
m_currentParent->appendChild(item);
|
m_currentParent->appendChild(item);
|
||||||
}
|
}
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
} else if (mode == SearchResultWindow::AddSorted) {
|
} else if (mode == SearchResult::AddSorted) {
|
||||||
foreach (const SearchResultItem &item, items) {
|
foreach (const SearchResultItem &item, items) {
|
||||||
SearchResultTreeItem *existingItem;
|
SearchResultTreeItem *existingItem;
|
||||||
const int insertionIndex = m_currentParent->insertionIndex(item, &existingItem);
|
const int insertionIndex = m_currentParent->insertionIndex(item, &existingItem);
|
||||||
@@ -386,7 +386,7 @@ static bool lessThanByPath(const SearchResultItem &a, const SearchResultItem &b)
|
|||||||
* Adds the search result to the list of results, creating nodes for the path when
|
* Adds the search result to the list of results, creating nodes for the path when
|
||||||
* necessary.
|
* necessary.
|
||||||
*/
|
*/
|
||||||
QList<QModelIndex> SearchResultTreeModel::addResults(const QList<SearchResultItem> &items, SearchResultWindow::AddMode mode)
|
QList<QModelIndex> SearchResultTreeModel::addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode)
|
||||||
{
|
{
|
||||||
QSet<SearchResultTreeItem *> pathNodes;
|
QSet<SearchResultTreeItem *> pathNodes;
|
||||||
QList<SearchResultItem> sortedItems = items;
|
QList<SearchResultItem> sortedItems = items;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
QModelIndex next(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const;
|
QModelIndex next(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const;
|
||||||
QModelIndex prev(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const;
|
QModelIndex prev(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const;
|
||||||
|
|
||||||
QList<QModelIndex> addResults(const QList<SearchResultItem> &items, SearchResultWindow::AddMode mode);
|
QList<QModelIndex> addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
|
||||||
|
|
||||||
QModelIndex find(const QRegExp &expr, const QModelIndex &index,
|
QModelIndex find(const QRegExp &expr, const QModelIndex &index,
|
||||||
QTextDocument::FindFlags flags, bool *wrapped = 0);
|
QTextDocument::FindFlags flags, bool *wrapped = 0);
|
||||||
@@ -84,7 +84,7 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QModelIndex index(SearchResultTreeItem *item) const;
|
QModelIndex index(SearchResultTreeItem *item) const;
|
||||||
void addResultsToCurrentParent(const QList<SearchResultItem> &items, SearchResultWindow::AddMode mode);
|
void addResultsToCurrentParent(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
|
||||||
QSet<SearchResultTreeItem *> addPath(const QStringList &path);
|
QSet<SearchResultTreeItem *> addPath(const QStringList &path);
|
||||||
QVariant data(const SearchResultTreeItem *row, int role) const;
|
QVariant data(const SearchResultTreeItem *row, int role) const;
|
||||||
bool setCheckState(const QModelIndex &idx, Qt::CheckState checkState, bool firstCall = true);
|
bool setCheckState(const QModelIndex &idx, Qt::CheckState checkState, bool firstCall = true);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ void SearchResultTreeView::clear()
|
|||||||
m_model->clear();
|
m_model->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultTreeView::addResults(const QList<Find::SearchResultItem> &items, Find::SearchResultWindow::AddMode mode)
|
void SearchResultTreeView::addResults(const QList<Find::SearchResultItem> &items, Find::SearchResult::AddMode mode)
|
||||||
{
|
{
|
||||||
QList<QModelIndex> addedParents = m_model->addResults(items, mode);
|
QList<QModelIndex> addedParents = m_model->addResults(items, mode);
|
||||||
if (m_autoExpandResults && !addedParents.isEmpty()) {
|
if (m_autoExpandResults && !addedParents.isEmpty()) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
void setTextEditorFont(const QFont &font);
|
void setTextEditorFont(const QFont &font);
|
||||||
|
|
||||||
SearchResultTreeModel *model() const;
|
SearchResultTreeModel *model() const;
|
||||||
void addResults(const QList<Find::SearchResultItem> &items, SearchResultWindow::AddMode mode);
|
void addResults(const QList<Find::SearchResultItem> &items, SearchResult::AddMode mode);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void jumpToSearchResult(const SearchResultItem &item);
|
void jumpToSearchResult(const SearchResultItem &item);
|
||||||
|
|||||||
@@ -414,8 +414,7 @@ SearchResultWindow *SearchResultWindow::instance()
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void SearchResultWindow::setTextToReplace(const QString &textToReplace)
|
\fn void SearchResultWindow::setTextToReplace(const QString &textToReplace)
|
||||||
\brief Sets the value in the UI element that allows the user to type
|
\internal
|
||||||
the text that should replace text in search results to \a textToReplace.
|
|
||||||
*/
|
*/
|
||||||
void SearchResultWindow::setTextToReplace(const QString &textToReplace)
|
void SearchResultWindow::setTextToReplace(const QString &textToReplace)
|
||||||
{
|
{
|
||||||
@@ -424,7 +423,7 @@ void SearchResultWindow::setTextToReplace(const QString &textToReplace)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QString SearchResultWindow::textToReplace() const
|
\fn QString SearchResultWindow::textToReplace() const
|
||||||
\brief Returns the text that should replace the text in search results.
|
\internal
|
||||||
*/
|
*/
|
||||||
QString SearchResultWindow::textToReplace() const
|
QString SearchResultWindow::textToReplace() const
|
||||||
{
|
{
|
||||||
@@ -534,8 +533,7 @@ SearchResult *SearchResultWindow::startNewSearch(SearchMode searchOrSearchAndRep
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void SearchResultWindow::finishSearch()
|
\fn void SearchResultWindow::finishSearch()
|
||||||
\brief Notifies the search result window that the current search
|
\internal
|
||||||
has finished, and the UI should reflect that.
|
|
||||||
*/
|
*/
|
||||||
void SearchResultWindow::finishSearch()
|
void SearchResultWindow::finishSearch()
|
||||||
{
|
{
|
||||||
@@ -582,16 +580,6 @@ bool SearchResultWindow::isEmpty() const
|
|||||||
return (d->m_searchResultTreeView->model()->rowCount() < 1);
|
return (d->m_searchResultTreeView->model()->rowCount() < 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn int SearchResultWindow::numberOfResults() const
|
|
||||||
Returns the number of search results currently shown in the search
|
|
||||||
results window.
|
|
||||||
*/
|
|
||||||
int SearchResultWindow::numberOfResults() const
|
|
||||||
{
|
|
||||||
return d->m_itemCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn bool SearchResultWindow::hasFocus()
|
\fn bool SearchResultWindow::hasFocus()
|
||||||
\internal
|
\internal
|
||||||
@@ -653,15 +641,7 @@ void SearchResultWindow::handleJumpToSearchResult(const SearchResultItem &item)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText, int searchTermStart, int searchTermLength, const QVariant &userData)
|
\fn void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText, int searchTermStart, int searchTermLength, const QVariant &userData)
|
||||||
\brief Adds a single result line to the search results.
|
\internal
|
||||||
|
|
||||||
The \a fileName, \a lineNumber and \a rowText are shown in the result line.
|
|
||||||
\a searchTermStart and \a searchTermLength specify the region that
|
|
||||||
should be visually marked (string position and length in \a rowText).
|
|
||||||
You can attach arbitrary \a userData to the search result, which can
|
|
||||||
be used e.g. when reacting to the signals of the SearchResult for your search.
|
|
||||||
|
|
||||||
\sa addResults()
|
|
||||||
*/
|
*/
|
||||||
void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText,
|
void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText,
|
||||||
int searchTermStart, int searchTermLength, const QVariant &userData)
|
int searchTermStart, int searchTermLength, const QVariant &userData)
|
||||||
@@ -674,17 +654,14 @@ void SearchResultWindow::addResult(const QString &fileName, int lineNumber, cons
|
|||||||
item.textMarkLength = searchTermLength;
|
item.textMarkLength = searchTermLength;
|
||||||
item.useTextEditorFont = true;
|
item.useTextEditorFont = true;
|
||||||
item.userData = userData;
|
item.userData = userData;
|
||||||
addResults(QList<SearchResultItem>() << item, AddOrdered);
|
addResults(QList<SearchResultItem>() << item, SearchResult::AddOrdered);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void SearchResultWindow::addResults(QList<SearchResultItem> &items, AddMode mode)
|
\fn void SearchResultWindow::addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode)
|
||||||
\brief Adds all of the given search result \a items to the search
|
\internal
|
||||||
results window.
|
|
||||||
|
|
||||||
\sa addResult()
|
|
||||||
*/
|
*/
|
||||||
void SearchResultWindow::addResults(QList<SearchResultItem> &items, AddMode mode)
|
void SearchResultWindow::addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode)
|
||||||
{
|
{
|
||||||
bool firstItems = (d->m_itemCount == 0);
|
bool firstItems = (d->m_itemCount == 0);
|
||||||
d->m_itemCount += items.size();
|
d->m_itemCount += items.size();
|
||||||
@@ -845,6 +822,93 @@ bool SearchResultWindow::canNavigate()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void SearchResult::setUserData(const QVariant &data)
|
||||||
|
\brief Attach some random \a data to this search, that you can use later.
|
||||||
|
|
||||||
|
\sa userData()
|
||||||
|
*/
|
||||||
|
void SearchResult::setUserData(const QVariant &data)
|
||||||
|
{
|
||||||
|
m_userData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void SearchResult::userData()
|
||||||
|
\brief Return the data that was attached to this search by calling setUserData().
|
||||||
|
|
||||||
|
\sa setUserData()
|
||||||
|
*/
|
||||||
|
QVariant SearchResult::userData() const
|
||||||
|
{
|
||||||
|
return m_userData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QString SearchResult::textToReplace() const
|
||||||
|
\brief Returns the text that should replace the text in search results.
|
||||||
|
*/
|
||||||
|
QString SearchResult::textToReplace() const
|
||||||
|
{
|
||||||
|
// TODO: should point to associated SearchResultWidget
|
||||||
|
return SearchResultWindow::instance()->textToReplace();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void SearchResult::addResult(const QString &fileName, int lineNumber, const QString &rowText, int searchTermStart, int searchTermLength, const QVariant &userData)
|
||||||
|
\brief Adds a single result line to the search results.
|
||||||
|
|
||||||
|
The \a fileName, \a lineNumber and \a rowText are shown in the result line.
|
||||||
|
\a searchTermStart and \a searchTermLength specify the region that
|
||||||
|
should be visually marked (string position and length in \a rowText).
|
||||||
|
You can attach arbitrary \a userData to the search result, which can
|
||||||
|
be used e.g. when reacting to the signals of the SearchResult for your search.
|
||||||
|
|
||||||
|
\sa addResults()
|
||||||
|
*/
|
||||||
|
void SearchResult::addResult(const QString &fileName, int lineNumber, const QString &lineText,
|
||||||
|
int searchTermStart, int searchTermLength, const QVariant &userData)
|
||||||
|
{
|
||||||
|
// TODO: should point to associated SearchResultWidget
|
||||||
|
SearchResultWindow::instance()->addResult(fileName, lineNumber, lineText,
|
||||||
|
searchTermStart, searchTermLength, userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void SearchResult::addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode)
|
||||||
|
\brief Adds all of the given search result \a items to the search
|
||||||
|
results window.
|
||||||
|
|
||||||
|
\sa addResult()
|
||||||
|
*/
|
||||||
|
void SearchResult::addResults(const QList<SearchResultItem> &items, AddMode mode)
|
||||||
|
{
|
||||||
|
// TODO: should point to associated SearchResultWidget
|
||||||
|
SearchResultWindow::instance()->addResults(items, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void SearchResult::finishSearch()
|
||||||
|
\brief Notifies the search result window that the current search
|
||||||
|
has finished, and the UI should reflect that.
|
||||||
|
*/
|
||||||
|
void SearchResult::finishSearch()
|
||||||
|
{
|
||||||
|
// TODO: should point to associated SearchResultWidget
|
||||||
|
SearchResultWindow::instance()->finishSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void SearchResult::setTextToReplace(const QString &textToReplace)
|
||||||
|
\brief Sets the value in the UI element that allows the user to type
|
||||||
|
the text that should replace text in search results to \a textToReplace.
|
||||||
|
*/
|
||||||
|
void SearchResult::setTextToReplace(const QString &textToReplace)
|
||||||
|
{
|
||||||
|
// TODO: should point to associated SearchResultWidget
|
||||||
|
SearchResultWindow::instance()->setTextToReplace(textToReplace);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Find
|
} // namespace Find
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,21 @@ class FIND_EXPORT SearchResult : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setUserData(const QVariant &data) { m_userData = data; }
|
enum AddMode {
|
||||||
QVariant userData() const { return m_userData; }
|
AddSorted,
|
||||||
|
AddOrdered
|
||||||
|
};
|
||||||
|
|
||||||
|
void setUserData(const QVariant &data);
|
||||||
|
QVariant userData() const;
|
||||||
|
QString textToReplace() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void addResult(const QString &fileName, int lineNumber, const QString &lineText,
|
||||||
|
int searchTermStart, int searchTermLength, const QVariant &userData = QVariant());
|
||||||
|
void addResults(const QList<SearchResultItem> &items, AddMode mode);
|
||||||
|
void finishSearch();
|
||||||
|
void setTextToReplace(const QString &textToReplace);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activated(const Find::SearchResultItem &item);
|
void activated(const Find::SearchResultItem &item);
|
||||||
@@ -113,10 +126,6 @@ public:
|
|||||||
SearchAndReplace
|
SearchAndReplace
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AddMode {
|
|
||||||
AddSorted,
|
|
||||||
AddOrdered
|
|
||||||
};
|
|
||||||
|
|
||||||
SearchResultWindow();
|
SearchResultWindow();
|
||||||
virtual ~SearchResultWindow();
|
virtual ~SearchResultWindow();
|
||||||
@@ -129,7 +138,6 @@ public:
|
|||||||
int priorityInStatusBar() const;
|
int priorityInStatusBar() const;
|
||||||
void visibilityChanged(bool visible);
|
void visibilityChanged(bool visible);
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
int numberOfResults() const;
|
|
||||||
bool hasFocus();
|
bool hasFocus();
|
||||||
bool canFocus();
|
bool canFocus();
|
||||||
void setFocus();
|
void setFocus();
|
||||||
@@ -142,20 +150,12 @@ public:
|
|||||||
|
|
||||||
void setTextEditorFont(const QFont &font);
|
void setTextEditorFont(const QFont &font);
|
||||||
|
|
||||||
void setTextToReplace(const QString &textToReplace);
|
|
||||||
QString textToReplace() const;
|
|
||||||
|
|
||||||
// search result object only lives till next startnewsearch call
|
// search result object only lives till next startnewsearch call
|
||||||
SearchResult *startNewSearch(SearchMode searchOrSearchAndReplace = SearchOnly,
|
SearchResult *startNewSearch(SearchMode searchOrSearchAndReplace = SearchOnly,
|
||||||
const QString &cfgGroup = QString());
|
const QString &cfgGroup = QString());
|
||||||
|
|
||||||
void addResults(QList<SearchResultItem> &items, AddMode mode);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clearContents();
|
void clearContents();
|
||||||
void addResult(const QString &fileName, int lineNumber, const QString &lineText,
|
|
||||||
int searchTermStart, int searchTermLength, const QVariant &userData = QVariant());
|
|
||||||
void finishSearch();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleExpandCollapseToolButton(bool checked);
|
void handleExpandCollapseToolButton(bool checked);
|
||||||
@@ -165,6 +165,15 @@ private slots:
|
|||||||
void hideNoUndoWarning();
|
void hideNoUndoWarning();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// TODO: move to the new SearchResultWidget
|
||||||
|
void addResult(const QString &fileName, int lineNumber, const QString &lineText,
|
||||||
|
int searchTermStart, int searchTermLength, const QVariant &userData);
|
||||||
|
void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode); // TODO: move to SearchResultWidget)
|
||||||
|
void finishSearch();
|
||||||
|
void setTextToReplace(const QString &textToReplace);
|
||||||
|
QString textToReplace() const;
|
||||||
|
|
||||||
|
|
||||||
void setShowReplaceUI(bool show);
|
void setShowReplaceUI(bool show);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
@@ -174,6 +183,7 @@ private:
|
|||||||
|
|
||||||
Internal::SearchResultWindowPrivate *d;
|
Internal::SearchResultWindowPrivate *d;
|
||||||
static SearchResultWindow *m_instance;
|
static SearchResultWindow *m_instance;
|
||||||
|
friend class SearchResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Find
|
} // namespace Find
|
||||||
|
|||||||
@@ -52,10 +52,9 @@ using namespace ProjectExplorer;
|
|||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
|
||||||
AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin, SearchResultWindow *resultWindow)
|
AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin)
|
||||||
: BaseFileFind(resultWindow),
|
: m_plugin(plugin),
|
||||||
m_plugin(plugin),
|
m_configWidget(0)
|
||||||
m_configWidget(0)
|
|
||||||
{
|
{
|
||||||
connect(m_plugin, SIGNAL(fileListChanged()), this, SIGNAL(changed()));
|
connect(m_plugin, SIGNAL(fileListChanged()), this, SIGNAL(changed()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class AllProjectsFind : public TextEditor::BaseFileFind
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AllProjectsFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow);
|
AllProjectsFind(ProjectExplorerPlugin *plugin);
|
||||||
|
|
||||||
QString id() const;
|
QString id() const;
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ using namespace ProjectExplorer;
|
|||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
|
||||||
CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin, SearchResultWindow *resultWindow)
|
CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin)
|
||||||
: AllProjectsFind(plugin, resultWindow),
|
: AllProjectsFind(plugin),
|
||||||
m_plugin(plugin)
|
m_plugin(plugin)
|
||||||
{
|
{
|
||||||
connect(m_plugin, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
|
connect(m_plugin, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class CurrentProjectFind : public AllProjectsFind
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CurrentProjectFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow);
|
CurrentProjectFind(ProjectExplorerPlugin *plugin);
|
||||||
|
|
||||||
QString id() const;
|
QString id() const;
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
|||||||
@@ -400,12 +400,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
ProcessStepFactory *processStepFactory = new ProcessStepFactory;
|
ProcessStepFactory *processStepFactory = new ProcessStepFactory;
|
||||||
addAutoReleasedObject(processStepFactory);
|
addAutoReleasedObject(processStepFactory);
|
||||||
|
|
||||||
AllProjectsFind *allProjectsFind = new AllProjectsFind(this,
|
AllProjectsFind *allProjectsFind = new AllProjectsFind(this);
|
||||||
Find::SearchResultWindow::instance());
|
|
||||||
addAutoReleasedObject(allProjectsFind);
|
addAutoReleasedObject(allProjectsFind);
|
||||||
|
|
||||||
CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this,
|
CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this);
|
||||||
Find::SearchResultWindow::instance());
|
|
||||||
addAutoReleasedObject(currentProjectFind);
|
addAutoReleasedObject(currentProjectFind);
|
||||||
|
|
||||||
addAutoReleasedObject(new LocalApplicationRunControlFactory);
|
addAutoReleasedObject(new LocalApplicationRunControlFactory);
|
||||||
|
|||||||
@@ -774,8 +774,8 @@ public:
|
|||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
FindReferences::FindReferences(QObject *parent)
|
FindReferences::FindReferences(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent),
|
||||||
, _resultWindow(Find::SearchResultWindow::instance())
|
m_currentSearch(0)
|
||||||
{
|
{
|
||||||
m_watcher.setPendingResultsLimit(1);
|
m_watcher.setPendingResultsLimit(1);
|
||||||
connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int)));
|
connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int)));
|
||||||
@@ -904,31 +904,30 @@ void FindReferences::displayResults(int first, int last)
|
|||||||
Usage dummy = m_watcher.future().resultAt(0);
|
Usage dummy = m_watcher.future().resultAt(0);
|
||||||
QString replacement = dummy.path;
|
QString replacement = dummy.path;
|
||||||
|
|
||||||
Find::SearchResult *search;
|
|
||||||
if (replacement.isEmpty()) {
|
if (replacement.isEmpty()) {
|
||||||
search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchOnly);
|
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly);
|
||||||
} else {
|
} else {
|
||||||
search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
|
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
|
||||||
_resultWindow->setTextToReplace(replacement);
|
m_currentSearch->setTextToReplace(replacement);
|
||||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
||||||
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
||||||
}
|
}
|
||||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
|
||||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
_resultWindow->popup(true);
|
Find::SearchResultWindow::instance()->popup(true);
|
||||||
|
|
||||||
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
|
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
|
||||||
Core::FutureProgress *progress = progressManager->addTask(
|
Core::FutureProgress *progress = progressManager->addTask(
|
||||||
m_watcher.future(), tr("Searching"),
|
m_watcher.future(), tr("Searching"),
|
||||||
QmlJSEditor::Constants::TASK_SEARCH);
|
QmlJSEditor::Constants::TASK_SEARCH);
|
||||||
connect(progress, SIGNAL(clicked()), _resultWindow, SLOT(popup()));
|
connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup()));
|
||||||
|
|
||||||
++first;
|
++first;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = first; index != last; ++index) {
|
for (int index = first; index != last; ++index) {
|
||||||
Usage result = m_watcher.future().resultAt(index);
|
Usage result = m_watcher.future().resultAt(index);
|
||||||
_resultWindow->addResult(result.path,
|
m_currentSearch->addResult(result.path,
|
||||||
result.line,
|
result.line,
|
||||||
result.lineText,
|
result.lineText,
|
||||||
result.col,
|
result.col,
|
||||||
@@ -938,7 +937,8 @@ void FindReferences::displayResults(int first, int last)
|
|||||||
|
|
||||||
void FindReferences::searchFinished()
|
void FindReferences::searchFinished()
|
||||||
{
|
{
|
||||||
_resultWindow->finishSearch();
|
m_currentSearch->finishSearch();
|
||||||
|
m_currentSearch = 0;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -973,5 +973,5 @@ void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Fin
|
|||||||
if (!changedUnsavedEditors.isEmpty())
|
if (!changedUnsavedEditors.isEmpty())
|
||||||
QmlJS::ModelManagerInterface::instance()->updateSourceFiles(changedUnsavedEditors, false);
|
QmlJS::ModelManagerInterface::instance()->updateSourceFiles(changedUnsavedEditors, false);
|
||||||
|
|
||||||
_resultWindow->hide();
|
Find::SearchResultWindow::instance()->hide();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#include <QtCore/QMutex>
|
#include <QtCore/QMutex>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QPointer>
|
|
||||||
#include <QtCore/QFuture>
|
#include <QtCore/QFuture>
|
||||||
#include <QtCore/QFutureWatcher>
|
#include <QtCore/QFutureWatcher>
|
||||||
#include <utils/filesearch.h>
|
#include <utils/filesearch.h>
|
||||||
@@ -44,8 +43,8 @@
|
|||||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||||
|
|
||||||
namespace Find {
|
namespace Find {
|
||||||
class SearchResultWindow;
|
|
||||||
struct SearchResultItem;
|
struct SearchResultItem;
|
||||||
|
class SearchResult;
|
||||||
} // namespace Find
|
} // namespace Find
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
@@ -90,7 +89,7 @@ private Q_SLOTS:
|
|||||||
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Find::SearchResultWindow *_resultWindow;
|
Find::SearchResult *m_currentSearch;
|
||||||
QFutureWatcher<Usage> m_watcher;
|
QFutureWatcher<Usage> m_watcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,9 @@ using namespace Utils;
|
|||||||
using namespace Find;
|
using namespace Find;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
|
||||||
BaseFileFind::BaseFileFind(SearchResultWindow *resultWindow)
|
BaseFileFind::BaseFileFind()
|
||||||
: m_resultWindow(resultWindow),
|
: m_currentSearch(0),
|
||||||
|
m_currentSearchCount(0),
|
||||||
m_isSearching(false),
|
m_isSearching(false),
|
||||||
m_resultLabel(0),
|
m_resultLabel(0),
|
||||||
m_filterCombo(0)
|
m_filterCombo(0)
|
||||||
@@ -115,20 +116,22 @@ void BaseFileFind::runNewSearch(const QString &txt, Find::FindFlags findFlags,
|
|||||||
if (m_filterCombo)
|
if (m_filterCombo)
|
||||||
updateComboEntries(m_filterCombo, true);
|
updateComboEntries(m_filterCombo, true);
|
||||||
m_watcher.setFuture(QFuture<FileSearchResultList>());
|
m_watcher.setFuture(QFuture<FileSearchResultList>());
|
||||||
SearchResult *result = m_resultWindow->startNewSearch(searchMode,
|
m_currentSearchCount = 0;
|
||||||
searchMode == SearchResultWindow::SearchAndReplace
|
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(searchMode,
|
||||||
? QString::fromLatin1("TextEditor")
|
searchMode == SearchResultWindow::SearchAndReplace
|
||||||
: QString());
|
? QString::fromLatin1("TextEditor")
|
||||||
|
: QString());
|
||||||
|
m_currentSearch->setTextToReplace(txt);
|
||||||
QVariantList searchParameters;
|
QVariantList searchParameters;
|
||||||
searchParameters << qVariantFromValue(txt) << qVariantFromValue(findFlags);
|
searchParameters << qVariantFromValue(txt) << qVariantFromValue(findFlags);
|
||||||
result->setUserData(searchParameters);
|
m_currentSearch->setUserData(searchParameters);
|
||||||
connect(result, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
|
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
if (searchMode == SearchResultWindow::SearchAndReplace) {
|
if (searchMode == SearchResultWindow::SearchAndReplace) {
|
||||||
connect(result, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
||||||
this, SLOT(doReplace(QString,QList<Find::SearchResultItem>)));
|
this, SLOT(doReplace(QString,QList<Find::SearchResultItem>)));
|
||||||
}
|
}
|
||||||
connect(result, SIGNAL(visibilityChanged(bool)), this, SLOT(hideHighlightAll(bool)));
|
connect(m_currentSearch, SIGNAL(visibilityChanged(bool)), this, SLOT(hideHighlightAll(bool)));
|
||||||
m_resultWindow->popup(true);
|
Find::SearchResultWindow::instance()->popup(true);
|
||||||
if (findFlags & Find::FindRegularExpression) {
|
if (findFlags & Find::FindRegularExpression) {
|
||||||
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
|
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
|
||||||
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
|
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
|
||||||
@@ -141,7 +144,7 @@ void BaseFileFind::runNewSearch(const QString &txt, Find::FindFlags findFlags,
|
|||||||
tr("Search"),
|
tr("Search"),
|
||||||
Constants::TASK_SEARCH);
|
Constants::TASK_SEARCH);
|
||||||
progress->setWidget(createProgressWidget());
|
progress->setWidget(createProgressWidget());
|
||||||
connect(progress, SIGNAL(clicked()), m_resultWindow, SLOT(popup()));
|
connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseFileFind::findAll(const QString &txt, Find::FindFlags findFlags)
|
void BaseFileFind::findAll(const QString &txt, Find::FindFlags findFlags)
|
||||||
@@ -161,7 +164,7 @@ void BaseFileFind::doReplace(const QString &text,
|
|||||||
Core::FileManager *fileManager = Core::ICore::instance()->fileManager();
|
Core::FileManager *fileManager = Core::ICore::instance()->fileManager();
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
fileManager->notifyFilesChangedInternally(files);
|
fileManager->notifyFilesChangedInternally(files);
|
||||||
m_resultWindow->hide();
|
Find::SearchResultWindow::instance()->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,14 +182,16 @@ void BaseFileFind::displayResult(int index) {
|
|||||||
item.userData = result.regexpCapturedTexts;
|
item.userData = result.regexpCapturedTexts;
|
||||||
items << item;
|
items << item;
|
||||||
}
|
}
|
||||||
m_resultWindow->addResults(items, Find::SearchResultWindow::AddOrdered);
|
m_currentSearch->addResults(items, Find::SearchResult::AddOrdered);
|
||||||
|
m_currentSearchCount += items.count();
|
||||||
if (m_resultLabel)
|
if (m_resultLabel)
|
||||||
m_resultLabel->setText(tr("%1 found").arg(m_resultWindow->numberOfResults()));
|
m_resultLabel->setText(tr("%1 found").arg(m_currentSearchCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseFileFind::searchFinished()
|
void BaseFileFind::searchFinished()
|
||||||
{
|
{
|
||||||
m_resultWindow->finishSearch();
|
m_currentSearch->finishSearch();
|
||||||
|
m_currentSearch = 0;
|
||||||
m_isSearching = false;
|
m_isSearching = false;
|
||||||
m_resultLabel = 0;
|
m_resultLabel = 0;
|
||||||
emit changed();
|
emit changed();
|
||||||
@@ -202,7 +207,7 @@ QWidget *BaseFileFind::createProgressWidget()
|
|||||||
f.setPointSizeF(StyleHelper::sidebarFontSize());
|
f.setPointSizeF(StyleHelper::sidebarFontSize());
|
||||||
m_resultLabel->setFont(f);
|
m_resultLabel->setFont(f);
|
||||||
m_resultLabel->setPalette(StyleHelper::sidebarFontPalette(m_resultLabel->palette()));
|
m_resultLabel->setPalette(StyleHelper::sidebarFontPalette(m_resultLabel->palette()));
|
||||||
m_resultLabel->setText(tr("%1 found").arg(m_resultWindow->numberOfResults()));
|
m_resultLabel->setText(tr("%1 found").arg(m_currentSearchCount));
|
||||||
return m_resultLabel;
|
return m_resultLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ namespace Utils {
|
|||||||
class FileIterator;
|
class FileIterator;
|
||||||
}
|
}
|
||||||
namespace Find {
|
namespace Find {
|
||||||
class SearchResultWindow;
|
|
||||||
struct SearchResultItem;
|
struct SearchResultItem;
|
||||||
class IFindSupport;
|
class IFindSupport;
|
||||||
}
|
}
|
||||||
@@ -65,7 +64,7 @@ class TEXTEDITOR_EXPORT BaseFileFind : public Find::IFindFilter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseFileFind(Find::SearchResultWindow *resultWindow);
|
explicit BaseFileFind();
|
||||||
~BaseFileFind();
|
~BaseFileFind();
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
@@ -101,7 +100,8 @@ private:
|
|||||||
void runNewSearch(const QString &txt, Find::FindFlags findFlags,
|
void runNewSearch(const QString &txt, Find::FindFlags findFlags,
|
||||||
Find::SearchResultWindow::SearchMode searchMode);
|
Find::SearchResultWindow::SearchMode searchMode);
|
||||||
|
|
||||||
Find::SearchResultWindow *m_resultWindow;
|
Find::SearchResult *m_currentSearch;
|
||||||
|
int m_currentSearchCount;
|
||||||
|
|
||||||
QFutureWatcher<Utils::FileSearchResultList> m_watcher;
|
QFutureWatcher<Utils::FileSearchResultList> m_watcher;
|
||||||
bool m_isSearching;
|
bool m_isSearching;
|
||||||
|
|||||||
@@ -47,9 +47,8 @@ using namespace Find;
|
|||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace TextEditor::Internal;
|
using namespace TextEditor::Internal;
|
||||||
|
|
||||||
FindInCurrentFile::FindInCurrentFile(SearchResultWindow *resultWindow)
|
FindInCurrentFile::FindInCurrentFile()
|
||||||
: BaseFileFind(resultWindow),
|
: m_configWidget(0),
|
||||||
m_configWidget(0),
|
|
||||||
m_currentFile(0)
|
m_currentFile(0)
|
||||||
{
|
{
|
||||||
connect(Core::ICore::instance()->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
connect(Core::ICore::instance()->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
#include <coreplugin/ifile.h>
|
#include <coreplugin/ifile.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <find/ifindfilter.h>
|
#include <find/ifindfilter.h>
|
||||||
#include <find/searchresultwindow.h>
|
|
||||||
|
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
@@ -54,7 +53,7 @@ class FindInCurrentFile : public BaseFileFind
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FindInCurrentFile(Find::SearchResultWindow *resultWindow);
|
explicit FindInCurrentFile();
|
||||||
|
|
||||||
QString id() const;
|
QString id() const;
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
|||||||
@@ -45,9 +45,8 @@
|
|||||||
using namespace Find;
|
using namespace Find;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
|
||||||
FindInFiles::FindInFiles(SearchResultWindow *resultWindow)
|
FindInFiles::FindInFiles()
|
||||||
: BaseFileFind(resultWindow),
|
: m_configWidget(0),
|
||||||
m_configWidget(0),
|
|
||||||
m_directory(0)
|
m_directory(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
#include "basefilefind.h"
|
#include "basefilefind.h"
|
||||||
|
|
||||||
#include <find/ifindfilter.h>
|
#include <find/ifindfilter.h>
|
||||||
#include <find/searchresultwindow.h>
|
|
||||||
|
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
@@ -51,7 +50,7 @@ class TEXTEDITOR_EXPORT FindInFiles : public BaseFileFind
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FindInFiles(Find::SearchResultWindow *resultWindow);
|
explicit FindInFiles();
|
||||||
|
|
||||||
QString id() const;
|
QString id() const;
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
|||||||
@@ -182,8 +182,8 @@ void TextEditorPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
updateSearchResultsFont(m_settings->fontSettings());
|
updateSearchResultsFont(m_settings->fontSettings());
|
||||||
|
|
||||||
addAutoReleasedObject(new FindInFiles(Find::SearchResultWindow::instance()));
|
addAutoReleasedObject(new FindInFiles);
|
||||||
addAutoReleasedObject(new FindInCurrentFile(Find::SearchResultWindow::instance()));
|
addAutoReleasedObject(new FindInCurrentFile);
|
||||||
|
|
||||||
Core::VariableManager *vm = Core::VariableManager::instance();
|
Core::VariableManager *vm = Core::VariableManager::instance();
|
||||||
vm->registerVariable(QLatin1String(kCurrentDocumentSelection),
|
vm->registerVariable(QLatin1String(kCurrentDocumentSelection),
|
||||||
|
|||||||
Reference in New Issue
Block a user