CppFindReferences::CppFindReferences(CppModelManagerInterface *modelManager)
: QObject(modelManager),
_modelManager(modelManager),
- _resultWindow(Find::SearchResultWindow::instance())
+ m_currentSearch(0)
{
m_watcher.setPendingResultsLimit(1);
connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int)));
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)));
findAll_helper(symbol, context);
const QString textToReplace = replacement.isEmpty()
? QString::fromUtf8(id->chars(), id->size()) : replacement;
- Find::SearchResult *search = _resultWindow->startNewSearch(
+ m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(
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)));
- connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
+ connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
findAll_helper(symbol, context);
if (! (symbol && symbol->identifier()))
return;
- _resultWindow->popup(true);
+ Find::SearchResultWindow::instance()->popup(true);
const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
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,
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items);
if (!fileNames.isEmpty()) {
_modelManager->updateSourceFiles(fileNames);
- _resultWindow->hide();
+ Find::SearchResultWindow::instance()->hide();
}
}
{
for (int index = first; index != last; ++index) {
Usage result = m_watcher.future().resultAt(index);
- _resultWindow->addResult(result.path,
+ m_currentSearch->addResult(result.path,
result.line,
result.lineText,
result.col,
void CppFindReferences::searchFinished()
{
- _resultWindow->finishSearch();
+ m_currentSearch->finishSearch();
+ m_currentSearch = 0;
emit changed();
}
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)));
const Snapshot snapshot = _modelManager->snapshot();
{
// ### FIXME: Encoding?
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());
}
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
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)
QT_FORWARD_DECLARE_CLASS(QTimer)
namespace Find {
- class SearchResultWindow;
struct SearchResultItem;
+ class SearchResult;
} // namespace Find
namespace CPlusPlus {
private:
QPointer<CPlusPlus::CppModelManagerInterface> _modelManager;
- Find::SearchResultWindow *_resultWindow;
+ Find::SearchResult *m_currentSearch;
QFutureWatcher<CPlusPlus::Usage> m_watcher;
mutable QMutex m_depsLock;
SymbolsFindFilter::SymbolsFindFilter(CppModelManager *manager)
: m_manager(manager),
- m_isRunning(false),
- m_enabled(true),
- m_symbolsToSearch(SearchSymbols::AllTypes),
- m_scope(SearchProjectsOnly)
+ m_isRunning(false),
+ m_enabled(true),
+ m_currentSearch(0),
+ m_symbolsToSearch(SearchSymbols::AllTypes),
+ m_scope(SearchProjectsOnly)
{
// for disabling while parser is running
connect(Core::ICore::instance()->progressManager(), SIGNAL(taskStarted(QString)),
m_isRunning = true;
emit changed();
Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
- Find::SearchResult *result = window->startNewSearch();
- connect(result, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
+ m_currentSearch = window->startNewSearch();
+ connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
window->popup(true);
m_search.setSymbolsToSearchFor(m_symbolsToSearch);
void SymbolsFindFilter::addResults(int begin, int end)
{
- Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
QList<Find::SearchResultItem> items;
for (int i = begin; i < end; ++i)
items << m_watcher.resultAt(i);
- window->addResults(items, Find::SearchResultWindow::AddSorted);
+ m_currentSearch->addResults(items, Find::SearchResult::AddSorted);
}
void SymbolsFindFilter::finish()
{
- Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
- window->finishSearch();
+ m_currentSearch->finishSearch();
+ m_currentSearch = 0;
m_isRunning = false;
emit changed();
}
bool m_isRunning;
bool m_enabled;
QFutureWatcher<Find::SearchResultItem> m_watcher;
+ Find::SearchResult *m_currentSearch;
SearchSymbols::SymbolTypes m_symbolsToSearch;
SearchSymbols m_search;
SearchScope m_scope;
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)
return;
- if (mode == SearchResultWindow::AddOrdered) {
+ if (mode == SearchResult::AddOrdered) {
// this is the mode for e.g. text search
beginInsertRows(m_currentIndex, m_currentParent->childrenCount(), m_currentParent->childrenCount() + items.count());
foreach (const SearchResultItem &item, items) {
m_currentParent->appendChild(item);
}
endInsertRows();
- } else if (mode == SearchResultWindow::AddSorted) {
+ } else if (mode == SearchResult::AddSorted) {
foreach (const SearchResultItem &item, items) {
SearchResultTreeItem *existingItem;
const int insertionIndex = m_currentParent->insertionIndex(item, &existingItem);
* Adds the search result to the list of results, creating nodes for the path when
* 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;
QList<SearchResultItem> sortedItems = items;
QModelIndex next(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,
QTextDocument::FindFlags flags, bool *wrapped = 0);
private:
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);
QVariant data(const SearchResultTreeItem *row, int role) const;
bool setCheckState(const QModelIndex &idx, Qt::CheckState checkState, bool firstCall = true);
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);
if (m_autoExpandResults && !addedParents.isEmpty()) {
void setTextEditorFont(const QFont &font);
SearchResultTreeModel *model() const;
- void addResults(const QList<Find::SearchResultItem> &items, SearchResultWindow::AddMode mode);
+ void addResults(const QList<Find::SearchResultItem> &items, SearchResult::AddMode mode);
signals:
void jumpToSearchResult(const SearchResultItem &item);
/*!
\fn void SearchResultWindow::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.
+ \internal
*/
void SearchResultWindow::setTextToReplace(const QString &textToReplace)
{
/*!
\fn QString SearchResultWindow::textToReplace() const
- \brief Returns the text that should replace the text in search results.
+ \internal
*/
QString SearchResultWindow::textToReplace() const
{
/*!
\fn void SearchResultWindow::finishSearch()
- \brief Notifies the search result window that the current search
- has finished, and the UI should reflect that.
+ \internal
*/
void SearchResultWindow::finishSearch()
{
}
/*!
- \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()
\internal
*/
/*!
\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.
-
- 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()
+ \internal
*/
void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText,
int searchTermStart, int searchTermLength, const QVariant &userData)
item.textMarkLength = searchTermLength;
item.useTextEditorFont = true;
item.userData = userData;
- addResults(QList<SearchResultItem>() << item, AddOrdered);
+ addResults(QList<SearchResultItem>() << item, SearchResult::AddOrdered);
}
/*!
- \fn void SearchResultWindow::addResults(QList<SearchResultItem> &items, AddMode mode)
- \brief Adds all of the given search result \a items to the search
- results window.
-
- \sa addResult()
+ \fn void SearchResultWindow::addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode)
+ \internal
*/
-void SearchResultWindow::addResults(QList<SearchResultItem> &items, AddMode mode)
+void SearchResultWindow::addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode)
{
bool firstItems = (d->m_itemCount == 0);
d->m_itemCount += items.size();
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
Q_OBJECT
public:
- void setUserData(const QVariant &data) { m_userData = data; }
- QVariant userData() const { return m_userData; }
+ enum AddMode {
+ 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:
void activated(const Find::SearchResultItem &item);
SearchAndReplace
};
- enum AddMode {
- AddSorted,
- AddOrdered
- };
SearchResultWindow();
virtual ~SearchResultWindow();
int priorityInStatusBar() const;
void visibilityChanged(bool visible);
bool isEmpty() const;
- int numberOfResults() const;
bool hasFocus();
bool canFocus();
void setFocus();
void setTextEditorFont(const QFont &font);
- void setTextToReplace(const QString &textToReplace);
- QString textToReplace() const;
-
// search result object only lives till next startnewsearch call
SearchResult *startNewSearch(SearchMode searchOrSearchAndReplace = SearchOnly,
const QString &cfgGroup = QString());
- void addResults(QList<SearchResultItem> &items, AddMode mode);
-
public slots:
void clearContents();
- void addResult(const QString &fileName, int lineNumber, const QString &lineText,
- int searchTermStart, int searchTermLength, const QVariant &userData = QVariant());
- void finishSearch();
private slots:
void handleExpandCollapseToolButton(bool checked);
void hideNoUndoWarning();
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 readSettings();
void writeSettings();
Internal::SearchResultWindowPrivate *d;
static SearchResultWindow *m_instance;
+ friend class SearchResult;
};
} // namespace Find
using namespace ProjectExplorer::Internal;
using namespace TextEditor;
-AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin, SearchResultWindow *resultWindow)
- : BaseFileFind(resultWindow),
- m_plugin(plugin),
- m_configWidget(0)
+AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin)
+ : m_plugin(plugin),
+ m_configWidget(0)
{
connect(m_plugin, SIGNAL(fileListChanged()), this, SIGNAL(changed()));
}
Q_OBJECT
public:
- AllProjectsFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow);
+ AllProjectsFind(ProjectExplorerPlugin *plugin);
QString id() const;
QString displayName() const;
using namespace ProjectExplorer::Internal;
using namespace TextEditor;
-CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin, SearchResultWindow *resultWindow)
- : AllProjectsFind(plugin, resultWindow),
+CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin)
+ : AllProjectsFind(plugin),
m_plugin(plugin)
{
connect(m_plugin, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
Q_OBJECT
public:
- CurrentProjectFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow);
+ CurrentProjectFind(ProjectExplorerPlugin *plugin);
QString id() const;
QString displayName() const;
ProcessStepFactory *processStepFactory = new ProcessStepFactory;
addAutoReleasedObject(processStepFactory);
- AllProjectsFind *allProjectsFind = new AllProjectsFind(this,
- Find::SearchResultWindow::instance());
+ AllProjectsFind *allProjectsFind = new AllProjectsFind(this);
addAutoReleasedObject(allProjectsFind);
- CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this,
- Find::SearchResultWindow::instance());
+ CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this);
addAutoReleasedObject(currentProjectFind);
addAutoReleasedObject(new LocalApplicationRunControlFactory);
} // end of anonymous namespace
FindReferences::FindReferences(QObject *parent)
- : QObject(parent)
- , _resultWindow(Find::SearchResultWindow::instance())
+ : QObject(parent),
+ m_currentSearch(0)
{
m_watcher.setPendingResultsLimit(1);
connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int)));
Usage dummy = m_watcher.future().resultAt(0);
QString replacement = dummy.path;
- Find::SearchResult *search;
if (replacement.isEmpty()) {
- search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchOnly);
+ m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly);
} else {
- search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
- _resultWindow->setTextToReplace(replacement);
- connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
+ m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
+ m_currentSearch->setTextToReplace(replacement);
+ connect(m_currentSearch, SIGNAL(replaceButtonClicked(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)));
- _resultWindow->popup(true);
+ Find::SearchResultWindow::instance()->popup(true);
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
Core::FutureProgress *progress = progressManager->addTask(
m_watcher.future(), tr("Searching"),
QmlJSEditor::Constants::TASK_SEARCH);
- connect(progress, SIGNAL(clicked()), _resultWindow, SLOT(popup()));
+ connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup()));
++first;
}
for (int index = first; index != last; ++index) {
Usage result = m_watcher.future().resultAt(index);
- _resultWindow->addResult(result.path,
+ m_currentSearch->addResult(result.path,
result.line,
result.lineText,
result.col,
void FindReferences::searchFinished()
{
- _resultWindow->finishSearch();
+ m_currentSearch->finishSearch();
+ m_currentSearch = 0;
emit changed();
}
if (!changedUnsavedEditors.isEmpty())
QmlJS::ModelManagerInterface::instance()->updateSourceFiles(changedUnsavedEditors, false);
- _resultWindow->hide();
+ Find::SearchResultWindow::instance()->hide();
}
#include <QtCore/QMutex>
#include <QtCore/QObject>
-#include <QtCore/QPointer>
#include <QtCore/QFuture>
#include <QtCore/QFutureWatcher>
#include <utils/filesearch.h>
QT_FORWARD_DECLARE_CLASS(QTimer)
namespace Find {
- class SearchResultWindow;
struct SearchResultItem;
+ class SearchResult;
} // namespace Find
namespace QmlJSEditor {
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
private:
- Find::SearchResultWindow *_resultWindow;
+ Find::SearchResult *m_currentSearch;
QFutureWatcher<Usage> m_watcher;
};
using namespace Find;
using namespace TextEditor;
-BaseFileFind::BaseFileFind(SearchResultWindow *resultWindow)
- : m_resultWindow(resultWindow),
+BaseFileFind::BaseFileFind()
+ : m_currentSearch(0),
+ m_currentSearchCount(0),
m_isSearching(false),
m_resultLabel(0),
m_filterCombo(0)
if (m_filterCombo)
updateComboEntries(m_filterCombo, true);
m_watcher.setFuture(QFuture<FileSearchResultList>());
- SearchResult *result = m_resultWindow->startNewSearch(searchMode,
- searchMode == SearchResultWindow::SearchAndReplace
- ? QString::fromLatin1("TextEditor")
- : QString());
+ m_currentSearchCount = 0;
+ m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(searchMode,
+ searchMode == SearchResultWindow::SearchAndReplace
+ ? QString::fromLatin1("TextEditor")
+ : QString());
+ m_currentSearch->setTextToReplace(txt);
QVariantList searchParameters;
searchParameters << qVariantFromValue(txt) << qVariantFromValue(findFlags);
- result->setUserData(searchParameters);
- connect(result, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
+ m_currentSearch->setUserData(searchParameters);
+ connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
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>)));
}
- connect(result, SIGNAL(visibilityChanged(bool)), this, SLOT(hideHighlightAll(bool)));
- m_resultWindow->popup(true);
+ connect(m_currentSearch, SIGNAL(visibilityChanged(bool)), this, SLOT(hideHighlightAll(bool)));
+ Find::SearchResultWindow::instance()->popup(true);
if (findFlags & Find::FindRegularExpression) {
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
tr("Search"),
Constants::TASK_SEARCH);
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)
Core::FileManager *fileManager = Core::ICore::instance()->fileManager();
if (!files.isEmpty()) {
fileManager->notifyFilesChangedInternally(files);
- m_resultWindow->hide();
+ Find::SearchResultWindow::instance()->hide();
}
}
item.userData = result.regexpCapturedTexts;
items << item;
}
- m_resultWindow->addResults(items, Find::SearchResultWindow::AddOrdered);
+ m_currentSearch->addResults(items, Find::SearchResult::AddOrdered);
+ m_currentSearchCount += items.count();
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()
{
- m_resultWindow->finishSearch();
+ m_currentSearch->finishSearch();
+ m_currentSearch = 0;
m_isSearching = false;
m_resultLabel = 0;
emit changed();
f.setPointSizeF(StyleHelper::sidebarFontSize());
m_resultLabel->setFont(f);
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;
}
class FileIterator;
}
namespace Find {
-class SearchResultWindow;
struct SearchResultItem;
class IFindSupport;
}
Q_OBJECT
public:
- explicit BaseFileFind(Find::SearchResultWindow *resultWindow);
+ explicit BaseFileFind();
~BaseFileFind();
bool isEnabled() const;
void runNewSearch(const QString &txt, Find::FindFlags findFlags,
Find::SearchResultWindow::SearchMode searchMode);
- Find::SearchResultWindow *m_resultWindow;
+ Find::SearchResult *m_currentSearch;
+ int m_currentSearchCount;
QFutureWatcher<Utils::FileSearchResultList> m_watcher;
bool m_isSearching;
using namespace TextEditor;
using namespace TextEditor::Internal;
-FindInCurrentFile::FindInCurrentFile(SearchResultWindow *resultWindow)
- : BaseFileFind(resultWindow),
- m_configWidget(0),
+FindInCurrentFile::FindInCurrentFile()
+ : m_configWidget(0),
m_currentFile(0)
{
connect(Core::ICore::instance()->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
#include <coreplugin/ifile.h>
#include <coreplugin/editormanager/ieditor.h>
#include <find/ifindfilter.h>
-#include <find/searchresultwindow.h>
#include <QtCore/QPointer>
#include <QtGui/QLabel>
Q_OBJECT
public:
- explicit FindInCurrentFile(Find::SearchResultWindow *resultWindow);
+ explicit FindInCurrentFile();
QString id() const;
QString displayName() const;
using namespace Find;
using namespace TextEditor;
-FindInFiles::FindInFiles(SearchResultWindow *resultWindow)
- : BaseFileFind(resultWindow),
- m_configWidget(0),
+FindInFiles::FindInFiles()
+ : m_configWidget(0),
m_directory(0)
{
}
#include "basefilefind.h"
#include <find/ifindfilter.h>
-#include <find/searchresultwindow.h>
#include <QtCore/QPointer>
#include <QtGui/QLabel>
Q_OBJECT
public:
- explicit FindInFiles(Find::SearchResultWindow *resultWindow);
+ explicit FindInFiles();
QString id() const;
QString displayName() const;
updateSearchResultsFont(m_settings->fontSettings());
- addAutoReleasedObject(new FindInFiles(Find::SearchResultWindow::instance()));
- addAutoReleasedObject(new FindInCurrentFile(Find::SearchResultWindow::instance()));
+ addAutoReleasedObject(new FindInFiles);
+ addAutoReleasedObject(new FindInCurrentFile);
Core::VariableManager *vm = Core::VariableManager::instance();
vm->registerVariable(QLatin1String(kCurrentDocumentSelection),