forked from qt-creator/qt-creator
Show warning with continue/cancel in case of many search results
Task-number: QTCREATORBUG-6116 Change-Id: I57a66b8989f1cc4137b02df370704dfe43d392ac Reviewed-by: Robert Löhning <robert.loehning@nokia.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -208,6 +208,8 @@ void runFileSearch(QFutureInterface<FileSearchResultList> &future,
|
|||||||
if (!future.isCanceled())
|
if (!future.isCanceled())
|
||||||
future.setProgressValueAndText(files->currentProgress(), msgFound(searchTerm, numMatches, numFilesSearched));
|
future.setProgressValueAndText(files->currentProgress(), msgFound(searchTerm, numMatches, numFilesSearched));
|
||||||
delete files;
|
delete files;
|
||||||
|
if (future.isPaused())
|
||||||
|
future.waitForResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runFileSearchRegExp(QFutureInterface<FileSearchResultList> &future,
|
void runFileSearchRegExp(QFutureInterface<FileSearchResultList> &future,
|
||||||
@@ -290,6 +292,8 @@ void runFileSearchRegExp(QFutureInterface<FileSearchResultList> &future,
|
|||||||
if (!future.isCanceled())
|
if (!future.isCanceled())
|
||||||
future.setProgressValueAndText(files->currentProgress(), msgFound(searchTerm, numMatches, numFilesSearched));
|
future.setProgressValueAndText(files->currentProgress(), msgFound(searchTerm, numMatches, numFilesSearched));
|
||||||
delete files;
|
delete files;
|
||||||
|
if (future.isPaused())
|
||||||
|
future.waitForResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ void InfoBarEntry::setCancelButtonInfo(QObject *_object, const char *_member)
|
|||||||
cancelButtonPressMember = _member;
|
cancelButtonPressMember = _member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InfoBarEntry::setCancelButtonInfo(const QString &_cancelButtonText, QObject *_object, const char *_member)
|
||||||
|
{
|
||||||
|
cancelButtonText = _cancelButtonText;
|
||||||
|
cancelObject = _object;
|
||||||
|
cancelButtonPressMember = _member;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void InfoBar::addInfo(const InfoBarEntry &info)
|
void InfoBar::addInfo(const InfoBarEntry &info)
|
||||||
{
|
{
|
||||||
@@ -169,15 +176,22 @@ void InfoBarDisplay::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QToolButton *infoWidgetCloseButton = new QToolButton;
|
QToolButton *infoWidgetCloseButton = new QToolButton;
|
||||||
infoWidgetCloseButton->setAutoRaise(true);
|
|
||||||
infoWidgetCloseButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLEAR)));
|
|
||||||
infoWidgetCloseButton->setToolTip(tr("Close"));
|
|
||||||
infoWidgetCloseButton->setProperty("infoId", info.id);
|
infoWidgetCloseButton->setProperty("infoId", info.id);
|
||||||
connect(infoWidgetCloseButton, SIGNAL(clicked()), SLOT(cancelButtonClicked()));
|
|
||||||
|
|
||||||
|
// need to connect to cancelObjectbefore connecting to cancelButtonClicked,
|
||||||
|
// because the latter removes the button and with it any connect
|
||||||
if (info.cancelObject)
|
if (info.cancelObject)
|
||||||
connect(infoWidgetCloseButton, SIGNAL(clicked()),
|
connect(infoWidgetCloseButton, SIGNAL(clicked()),
|
||||||
info.cancelObject, info.cancelButtonPressMember);
|
info.cancelObject, info.cancelButtonPressMember);
|
||||||
|
connect(infoWidgetCloseButton, SIGNAL(clicked()), SLOT(cancelButtonClicked()));
|
||||||
|
|
||||||
|
if (info.cancelButtonText.isEmpty()) {
|
||||||
|
infoWidgetCloseButton->setAutoRaise(true);
|
||||||
|
infoWidgetCloseButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLEAR)));
|
||||||
|
infoWidgetCloseButton->setToolTip(tr("Close"));
|
||||||
|
} else {
|
||||||
|
infoWidgetCloseButton->setText(info.cancelButtonText);
|
||||||
|
}
|
||||||
|
|
||||||
hbox->addWidget(infoWidgetCloseButton);
|
hbox->addWidget(infoWidgetCloseButton);
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
InfoBarEntry(const InfoBarEntry &other) { *this = other; }
|
InfoBarEntry(const InfoBarEntry &other) { *this = other; }
|
||||||
void setCustomButtonInfo(const QString &_buttonText, QObject *_object, const char *_member);
|
void setCustomButtonInfo(const QString &_buttonText, QObject *_object, const char *_member);
|
||||||
void setCancelButtonInfo(QObject *_object, const char *_member);
|
void setCancelButtonInfo(QObject *_object, const char *_member);
|
||||||
|
void setCancelButtonInfo(const QString &_cancelButtonText, QObject *_object, const char *_member);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString id;
|
QString id;
|
||||||
@@ -60,6 +61,7 @@ private:
|
|||||||
QString buttonText;
|
QString buttonText;
|
||||||
QObject *object;
|
QObject *object;
|
||||||
const char *buttonPressMember;
|
const char *buttonPressMember;
|
||||||
|
QString cancelButtonText;
|
||||||
QObject *cancelObject;
|
QObject *cancelObject;
|
||||||
const char *cancelButtonPressMember;
|
const char *cancelButtonPressMember;
|
||||||
friend class InfoBar;
|
friend class InfoBar;
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ public:
|
|||||||
QList<Usage> operator()(const QString &fileName)
|
QList<Usage> operator()(const QString &fileName)
|
||||||
{
|
{
|
||||||
QList<Usage> usages;
|
QList<Usage> usages;
|
||||||
|
if (future->isPaused())
|
||||||
|
future->waitForResume();
|
||||||
if (future->isCanceled())
|
if (future->isCanceled())
|
||||||
return usages;
|
return usages;
|
||||||
const Identifier *symbolId = symbol->identifier();
|
const Identifier *symbolId = symbol->identifier();
|
||||||
@@ -145,6 +147,8 @@ public:
|
|||||||
usages = process.usages();
|
usages = process.usages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (future->isPaused())
|
||||||
|
future->waitForResume();
|
||||||
return usages;
|
return usages;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -252,6 +256,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
|
|||||||
search->setTextToReplace(replacement);
|
search->setTextToReplace(replacement);
|
||||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
||||||
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
||||||
|
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||||
search->setSearchAgainSupported(true);
|
search->setSearchAgainSupported(true);
|
||||||
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
||||||
CppFindReferencesParameters parameters;
|
CppFindReferencesParameters parameters;
|
||||||
@@ -293,7 +298,7 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search)
|
|||||||
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()), Find::SearchResultWindow::instance(), SLOT(popup()));
|
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
||||||
@@ -511,6 +516,16 @@ void CppFindReferences::cancel()
|
|||||||
watcher->cancel();
|
watcher->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CppFindReferences::setPaused(bool paused)
|
||||||
|
{
|
||||||
|
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||||
|
QTC_ASSERT(search, return);
|
||||||
|
QFutureWatcher<Usage> *watcher = m_watchers.key(search);
|
||||||
|
QTC_ASSERT(watcher, return);
|
||||||
|
if (!paused || watcher->isRunning()) // guard against pausing when the search is finished
|
||||||
|
watcher->setPaused(paused);
|
||||||
|
}
|
||||||
|
|
||||||
void CppFindReferences::openEditor(const Find::SearchResultItem &item)
|
void CppFindReferences::openEditor(const Find::SearchResultItem &item)
|
||||||
{
|
{
|
||||||
if (item.path.size() > 0) {
|
if (item.path.size() > 0) {
|
||||||
@@ -545,6 +560,8 @@ public:
|
|||||||
QList<Usage> operator()(const QString &fileName)
|
QList<Usage> operator()(const QString &fileName)
|
||||||
{
|
{
|
||||||
QList<Usage> usages;
|
QList<Usage> usages;
|
||||||
|
if (future->isPaused())
|
||||||
|
future->waitForResume();
|
||||||
if (future->isCanceled())
|
if (future->isCanceled())
|
||||||
return usages;
|
return usages;
|
||||||
|
|
||||||
@@ -566,6 +583,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (future->isPaused())
|
||||||
|
future->waitForResume();
|
||||||
return usages;
|
return usages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,6 +657,7 @@ void CppFindReferences::findMacroUses(const Macro ¯o)
|
|||||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
||||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
||||||
|
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||||
|
|
||||||
const Snapshot snapshot = _modelManager->snapshot();
|
const Snapshot snapshot = _modelManager->snapshot();
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
|
const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
|
||||||
@@ -662,7 +682,7 @@ void CppFindReferences::findMacroUses(const Macro ¯o)
|
|||||||
Core::ProgressManager *progressManager = Core::ICore::progressManager();
|
Core::ProgressManager *progressManager = Core::ICore::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()), Find::SearchResultWindow::instance(), SLOT(popup()));
|
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DependencyTable CppFindReferences::updateDependencyTable(CPlusPlus::Snapshot snapshot)
|
DependencyTable CppFindReferences::updateDependencyTable(CPlusPlus::Snapshot snapshot)
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ private Q_SLOTS:
|
|||||||
void displayResults(int first, int last);
|
void displayResults(int first, int last);
|
||||||
void searchFinished();
|
void searchFinished();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
void setPaused(bool paused);
|
||||||
void openEditor(const Find::SearchResultItem &item);
|
void openEditor(const Find::SearchResultItem &item);
|
||||||
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
||||||
void searchAgain();
|
void searchAgain();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "cpptoolsconstants.h"
|
#include "cpptoolsconstants.h"
|
||||||
|
|
||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
|
#include <coreplugin/progressmanager/futureprogress.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <find/textfindconstants.h>
|
#include <find/textfindconstants.h>
|
||||||
#include <utils/runextensions.h>
|
#include <utils/runextensions.h>
|
||||||
@@ -77,7 +78,11 @@ namespace {
|
|||||||
findString = QString::fromLatin1("\\b%1\\b").arg(findString);
|
findString = QString::fromLatin1("\\b%1\\b").arg(findString);
|
||||||
QRegExp matcher(findString, (parameters.flags & Find::FindCaseSensitively
|
QRegExp matcher(findString, (parameters.flags & Find::FindCaseSensitively
|
||||||
? Qt::CaseSensitive : Qt::CaseInsensitive));
|
? Qt::CaseSensitive : Qt::CaseInsensitive));
|
||||||
while (it != snapshot.end() && !future.isCanceled()) {
|
while (it != snapshot.end()) {
|
||||||
|
if (future.isPaused())
|
||||||
|
future.waitForResume();
|
||||||
|
if (future.isCanceled())
|
||||||
|
break;
|
||||||
if (fileNames.isEmpty() || fileNames.contains(it.value()->fileName())) {
|
if (fileNames.isEmpty() || fileNames.contains(it.value()->fileName())) {
|
||||||
QVector<Find::SearchResultItem> resultItems;
|
QVector<Find::SearchResultItem> resultItems;
|
||||||
QList<ModelItemInfo> modelInfos = search(it.value());
|
QList<ModelItemInfo> modelInfos = search(it.value());
|
||||||
@@ -104,6 +109,8 @@ namespace {
|
|||||||
++progress;
|
++progress;
|
||||||
future.setProgressValue(progress);
|
future.setProgressValue(progress);
|
||||||
}
|
}
|
||||||
|
if (future.isPaused())
|
||||||
|
future.waitForResume();
|
||||||
}
|
}
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
||||||
@@ -144,6 +151,16 @@ void SymbolsFindFilter::cancel()
|
|||||||
watcher->cancel();
|
watcher->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SymbolsFindFilter::setPaused(bool paused)
|
||||||
|
{
|
||||||
|
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||||
|
QTC_ASSERT(search, return);
|
||||||
|
QFutureWatcher<Find::SearchResultItem> *watcher = m_watchers.key(search);
|
||||||
|
QTC_ASSERT(watcher, return);
|
||||||
|
if (!paused || watcher->isRunning()) // guard against pausing when the search is finished
|
||||||
|
watcher->setPaused(paused);
|
||||||
|
}
|
||||||
|
|
||||||
Find::FindFlags SymbolsFindFilter::supportedFindFlags() const
|
Find::FindFlags SymbolsFindFilter::supportedFindFlags() const
|
||||||
{
|
{
|
||||||
return Find::FindCaseSensitively | Find::FindRegularExpression | Find::FindWholeWords;
|
return Find::FindCaseSensitively | Find::FindRegularExpression | Find::FindWholeWords;
|
||||||
@@ -157,6 +174,7 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
|
|||||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
||||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
||||||
|
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||||
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
||||||
connect(this, SIGNAL(enabledChanged(bool)), search, SLOT(setSearchAgainEnabled(bool)));
|
connect(this, SIGNAL(enabledChanged(bool)), search, SLOT(setSearchAgainEnabled(bool)));
|
||||||
window->popup(true);
|
window->popup(true);
|
||||||
@@ -190,9 +208,10 @@ void SymbolsFindFilter::startSearch(Find::SearchResult *search)
|
|||||||
watcher->setFuture(QtConcurrent::run<Find::SearchResultItem, SymbolsFindParameters,
|
watcher->setFuture(QtConcurrent::run<Find::SearchResultItem, SymbolsFindParameters,
|
||||||
CPlusPlus::Snapshot, QSet<QString> >(runSearch, parameters,
|
CPlusPlus::Snapshot, QSet<QString> >(runSearch, parameters,
|
||||||
m_manager->snapshot(), projectFileNames));
|
m_manager->snapshot(), projectFileNames));
|
||||||
Core::ICore::progressManager()->addTask(watcher->future(),
|
Core::FutureProgress *progress = Core::ICore::progressManager()->addTask(watcher->future(),
|
||||||
tr("Searching"),
|
tr("Searching"),
|
||||||
Find::Constants::TASK_SEARCH);
|
Find::Constants::TASK_SEARCH);
|
||||||
|
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolsFindFilter::addResults(int begin, int end)
|
void SymbolsFindFilter::addResults(int begin, int end)
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ private slots:
|
|||||||
void addResults(int begin, int end);
|
void addResults(int begin, int end);
|
||||||
void finish();
|
void finish();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
void setPaused(bool paused);
|
||||||
void onTaskStarted(const QString &type);
|
void onTaskStarted(const QString &type);
|
||||||
void onAllTasksFinished(const QString &type);
|
void onAllTasksFinished(const QString &type);
|
||||||
void searchAgain();
|
void searchAgain();
|
||||||
|
|||||||
@@ -47,6 +47,10 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
static const int SEARCHRESULT_WARNING_LIMIT = 200000;
|
||||||
|
static const char UNDO_WARNING_ID[] = "warninglabel";
|
||||||
|
static const char SIZE_WARNING_ID[] = "sizeWarningLabel";
|
||||||
|
|
||||||
namespace Find {
|
namespace Find {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -77,6 +81,8 @@ using namespace Find::Internal;
|
|||||||
SearchResultWidget::SearchResultWidget(QWidget *parent) :
|
SearchResultWidget::SearchResultWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_count(0),
|
m_count(0),
|
||||||
|
m_sizeWarningActive(false),
|
||||||
|
m_sizeWarningOverridden(false),
|
||||||
m_isShowingReplaceUI(false),
|
m_isShowingReplaceUI(false),
|
||||||
m_searchAgainSupported(false)
|
m_searchAgainSupported(false)
|
||||||
{
|
{
|
||||||
@@ -182,6 +188,12 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
|
|||||||
connect(m_replaceButton, SIGNAL(clicked()), this, SLOT(handleReplaceButton()));
|
connect(m_replaceButton, SIGNAL(clicked()), this, SLOT(handleReplaceButton()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SearchResultWidget::~SearchResultWidget()
|
||||||
|
{
|
||||||
|
if (m_sizeWarningActive)
|
||||||
|
cancelAfterSizeWarning();
|
||||||
|
}
|
||||||
|
|
||||||
void SearchResultWidget::setInfo(const QString &label, const QString &toolTip, const QString &term)
|
void SearchResultWidget::setInfo(const QString &label, const QString &toolTip, const QString &term)
|
||||||
{
|
{
|
||||||
m_label->setText(label);
|
m_label->setText(label);
|
||||||
@@ -210,9 +222,10 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search
|
|||||||
bool firstItems = (m_count == 0);
|
bool firstItems = (m_count == 0);
|
||||||
m_count += items.size();
|
m_count += items.size();
|
||||||
m_searchResultTreeView->addResults(items, mode);
|
m_searchResultTreeView->addResults(items, mode);
|
||||||
|
updateMatchesFoundLabel();
|
||||||
if (firstItems) {
|
if (firstItems) {
|
||||||
if (showWarningMessage()) {
|
if (showWarningMessage()) {
|
||||||
Core::InfoBarEntry info(QLatin1String("warninglabel"), tr("This change cannot be undone."));
|
Core::InfoBarEntry info(QLatin1String(UNDO_WARNING_ID), tr("This change cannot be undone."));
|
||||||
info.setCustomButtonInfo(tr("Do not warn again"), this, SLOT(hideNoUndoWarning()));
|
info.setCustomButtonInfo(tr("Do not warn again"), this, SLOT(hideNoUndoWarning()));
|
||||||
m_infoBar.addInfo(info);
|
m_infoBar.addInfo(info);
|
||||||
}
|
}
|
||||||
@@ -227,10 +240,21 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search
|
|||||||
}
|
}
|
||||||
m_searchResultTreeView->selectionModel()->select(m_searchResultTreeView->model()->index(0, 0, QModelIndex()), QItemSelectionModel::Select);
|
m_searchResultTreeView->selectionModel()->select(m_searchResultTreeView->model()->index(0, 0, QModelIndex()), QItemSelectionModel::Select);
|
||||||
emit navigateStateChanged();
|
emit navigateStateChanged();
|
||||||
|
} else if (m_count > SEARCHRESULT_WARNING_LIMIT && !m_sizeWarningOverridden && !m_sizeWarningActive) {
|
||||||
|
m_sizeWarningActive = true;
|
||||||
|
emit paused(true);
|
||||||
|
Core::InfoBarEntry info(QLatin1String(SIZE_WARNING_ID),
|
||||||
|
tr("The search resulted in more than %1 items, do you still want to continue?")
|
||||||
|
.arg(SEARCHRESULT_WARNING_LIMIT));
|
||||||
|
info.setCancelButtonInfo(tr("Cancel"), this, SLOT(cancelAfterSizeWarning()));
|
||||||
|
info.setCustomButtonInfo(tr("Continue"), this, SLOT(continueAfterSizeWarning()));
|
||||||
|
m_infoBar.addInfo(info);
|
||||||
|
emit requestPopup(false/*no focus*/);
|
||||||
}
|
}
|
||||||
updateMatchesFoundLabel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int SearchResultWidget::count() const
|
int SearchResultWidget::count() const
|
||||||
{
|
{
|
||||||
return m_count;
|
return m_count;
|
||||||
@@ -345,6 +369,10 @@ void SearchResultWidget::restart()
|
|||||||
m_replaceButton->setEnabled(false);
|
m_replaceButton->setEnabled(false);
|
||||||
m_searchResultTreeView->clear();
|
m_searchResultTreeView->clear();
|
||||||
m_count = 0;
|
m_count = 0;
|
||||||
|
if (m_sizeWarningActive)
|
||||||
|
m_infoBar.removeInfo(QLatin1String(SIZE_WARNING_ID));
|
||||||
|
m_sizeWarningActive = false;
|
||||||
|
m_sizeWarningOverridden = false;
|
||||||
m_cancelButton->setVisible(true);
|
m_cancelButton->setVisible(true);
|
||||||
m_searchAgainButton->setVisible(false);
|
m_searchAgainButton->setVisible(false);
|
||||||
m_messageWidget->setVisible(false);
|
m_messageWidget->setVisible(false);
|
||||||
@@ -365,6 +393,10 @@ void SearchResultWidget::setSearchAgainEnabled(bool enabled)
|
|||||||
|
|
||||||
void SearchResultWidget::finishSearch(bool canceled)
|
void SearchResultWidget::finishSearch(bool canceled)
|
||||||
{
|
{
|
||||||
|
if (m_sizeWarningActive)
|
||||||
|
m_infoBar.removeInfo(QLatin1String(SIZE_WARNING_ID));
|
||||||
|
m_sizeWarningActive = false;
|
||||||
|
m_sizeWarningOverridden = false;
|
||||||
m_replaceTextEdit->setEnabled(m_count > 0);
|
m_replaceTextEdit->setEnabled(m_count > 0);
|
||||||
m_replaceButton->setEnabled(m_count > 0);
|
m_replaceButton->setEnabled(m_count > 0);
|
||||||
m_cancelButton->setVisible(false);
|
m_cancelButton->setVisible(false);
|
||||||
@@ -372,10 +404,32 @@ void SearchResultWidget::finishSearch(bool canceled)
|
|||||||
m_searchAgainButton->setVisible(m_searchAgainSupported);
|
m_searchAgainButton->setVisible(m_searchAgainSupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchResultWidget::sendRequestPopup()
|
||||||
|
{
|
||||||
|
emit requestPopup(true/*focus*/);
|
||||||
|
}
|
||||||
|
|
||||||
void SearchResultWidget::hideNoUndoWarning()
|
void SearchResultWidget::hideNoUndoWarning()
|
||||||
{
|
{
|
||||||
setShowWarningMessage(false);
|
setShowWarningMessage(false);
|
||||||
m_infoBar.clear();
|
m_infoBar.removeInfo(QLatin1String(UNDO_WARNING_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchResultWidget::continueAfterSizeWarning()
|
||||||
|
{
|
||||||
|
m_sizeWarningOverridden = true;
|
||||||
|
m_sizeWarningActive = false;
|
||||||
|
m_infoBar.removeInfo(QLatin1String(SIZE_WARNING_ID));
|
||||||
|
emit paused(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchResultWidget::cancelAfterSizeWarning()
|
||||||
|
{
|
||||||
|
m_infoBar.removeInfo(QLatin1String(SIZE_WARNING_ID));
|
||||||
|
m_sizeWarningOverridden = true;
|
||||||
|
m_sizeWarningActive = false;
|
||||||
|
emit cancelled();
|
||||||
|
emit paused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultWidget::handleJumpToSearchResult(const SearchResultItem &item)
|
void SearchResultWidget::handleJumpToSearchResult(const SearchResultItem &item)
|
||||||
@@ -396,6 +450,9 @@ void SearchResultWidget::handleReplaceButton()
|
|||||||
void SearchResultWidget::cancel()
|
void SearchResultWidget::cancel()
|
||||||
{
|
{
|
||||||
m_cancelButton->setVisible(false);
|
m_cancelButton->setVisible(false);
|
||||||
|
if (m_sizeWarningActive)
|
||||||
|
cancelAfterSizeWarning();
|
||||||
|
else
|
||||||
emit cancelled();
|
emit cancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class SearchResultWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SearchResultWidget(QWidget *parent = 0);
|
explicit SearchResultWidget(QWidget *parent = 0);
|
||||||
|
~SearchResultWidget();
|
||||||
|
|
||||||
void setInfo(const QString &label, const QString &toolTip, const QString &term);
|
void setInfo(const QString &label, const QString &toolTip, const QString &term);
|
||||||
|
|
||||||
@@ -91,19 +92,24 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void finishSearch(bool canceled);
|
void finishSearch(bool canceled);
|
||||||
|
void sendRequestPopup();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activated(const Find::SearchResultItem &item);
|
void activated(const Find::SearchResultItem &item);
|
||||||
void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems);
|
void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems);
|
||||||
void searchAgainRequested();
|
void searchAgainRequested();
|
||||||
void cancelled();
|
void cancelled();
|
||||||
|
void paused(bool paused);
|
||||||
void restarted();
|
void restarted();
|
||||||
void visibilityChanged(bool visible);
|
void visibilityChanged(bool visible);
|
||||||
|
void requestPopup(bool focus);
|
||||||
|
|
||||||
void navigateStateChanged();
|
void navigateStateChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void hideNoUndoWarning();
|
void hideNoUndoWarning();
|
||||||
|
void continueAfterSizeWarning();
|
||||||
|
void cancelAfterSizeWarning();
|
||||||
void handleJumpToSearchResult(const SearchResultItem &item);
|
void handleJumpToSearchResult(const SearchResultItem &item);
|
||||||
void handleReplaceButton();
|
void handleReplaceButton();
|
||||||
void cancel();
|
void cancel();
|
||||||
@@ -117,6 +123,8 @@ private:
|
|||||||
|
|
||||||
SearchResultTreeView *m_searchResultTreeView;
|
SearchResultTreeView *m_searchResultTreeView;
|
||||||
int m_count;
|
int m_count;
|
||||||
|
bool m_sizeWarningActive;
|
||||||
|
bool m_sizeWarningOverridden;
|
||||||
QString m_dontAskAgainGroup;
|
QString m_dontAskAgainGroup;
|
||||||
QFrame *m_messageWidget;
|
QFrame *m_messageWidget;
|
||||||
Core::InfoBar m_infoBar;
|
Core::InfoBar m_infoBar;
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ namespace Internal {
|
|||||||
SearchResultWindowPrivate(SearchResultWindow *window);
|
SearchResultWindowPrivate(SearchResultWindow *window);
|
||||||
bool isSearchVisible() const;
|
bool isSearchVisible() const;
|
||||||
int visibleSearchIndex() const;
|
int visibleSearchIndex() const;
|
||||||
|
void setCurrentIndex(int index, bool focus);
|
||||||
|
|
||||||
SearchResultWindow *q;
|
SearchResultWindow *q;
|
||||||
QList<Internal::SearchResultWidget *> m_searchResultWidgets;
|
QList<Internal::SearchResultWidget *> m_searchResultWidgets;
|
||||||
@@ -102,6 +103,7 @@ namespace Internal {
|
|||||||
public slots:
|
public slots:
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
void moveWidgetToTop();
|
void moveWidgetToTop();
|
||||||
|
void popupRequested(bool focus);
|
||||||
};
|
};
|
||||||
|
|
||||||
SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window)
|
SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window)
|
||||||
@@ -119,7 +121,7 @@ namespace Internal {
|
|||||||
return m_currentIndex - 1;
|
return m_currentIndex - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultWindowPrivate::setCurrentIndex(int index)
|
void SearchResultWindowPrivate::setCurrentIndex(int index, bool focus)
|
||||||
{
|
{
|
||||||
if (isSearchVisible())
|
if (isSearchVisible())
|
||||||
m_searchResultWidgets.at(visibleSearchIndex())->notifyVisibilityChanged(false);
|
m_searchResultWidgets.at(visibleSearchIndex())->notifyVisibilityChanged(false);
|
||||||
@@ -127,9 +129,11 @@ namespace Internal {
|
|||||||
m_widget->setCurrentIndex(index);
|
m_widget->setCurrentIndex(index);
|
||||||
m_recentSearchesBox->setCurrentIndex(index);
|
m_recentSearchesBox->setCurrentIndex(index);
|
||||||
if (!isSearchVisible()) {
|
if (!isSearchVisible()) {
|
||||||
|
if (focus)
|
||||||
m_widget->currentWidget()->setFocus();
|
m_widget->currentWidget()->setFocus();
|
||||||
m_expandCollapseButton->setEnabled(false);
|
m_expandCollapseButton->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
|
if (focus)
|
||||||
m_searchResultWidgets.at(visibleSearchIndex())->setFocusInternally();
|
m_searchResultWidgets.at(visibleSearchIndex())->setFocusInternally();
|
||||||
m_searchResultWidgets.at(visibleSearchIndex())->notifyVisibilityChanged(true);
|
m_searchResultWidgets.at(visibleSearchIndex())->notifyVisibilityChanged(true);
|
||||||
m_expandCollapseButton->setEnabled(true);
|
m_expandCollapseButton->setEnabled(true);
|
||||||
@@ -137,6 +141,11 @@ namespace Internal {
|
|||||||
q->navigateStateChanged();
|
q->navigateStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchResultWindowPrivate::setCurrentIndex(int index)
|
||||||
|
{
|
||||||
|
setCurrentIndex(index, true/*focus*/);
|
||||||
|
}
|
||||||
|
|
||||||
void SearchResultWindowPrivate::moveWidgetToTop()
|
void SearchResultWindowPrivate::moveWidgetToTop()
|
||||||
{
|
{
|
||||||
SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender());
|
SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender());
|
||||||
@@ -170,6 +179,15 @@ namespace Internal {
|
|||||||
++m_currentIndex;
|
++m_currentIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchResultWindowPrivate::popupRequested(bool focus)
|
||||||
|
{
|
||||||
|
SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender());
|
||||||
|
QTC_ASSERT(widget, return);
|
||||||
|
int internalIndex = m_searchResultWidgets.indexOf(widget) + 1/*account for "new search" entry*/;
|
||||||
|
setCurrentIndex(internalIndex, focus);
|
||||||
|
q->popup(focus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace Find::Internal;
|
using namespace Find::Internal;
|
||||||
@@ -367,8 +385,9 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label,
|
|||||||
{
|
{
|
||||||
if (d->m_searchResults.size() >= MAX_SEARCH_HISTORY) {
|
if (d->m_searchResults.size() >= MAX_SEARCH_HISTORY) {
|
||||||
d->m_searchResultWidgets.last()->notifyVisibilityChanged(false);
|
d->m_searchResultWidgets.last()->notifyVisibilityChanged(false);
|
||||||
delete d->m_searchResults.takeLast();
|
// widget first, because that might send interesting signals to SearchResult
|
||||||
delete d->m_searchResultWidgets.takeLast();
|
delete d->m_searchResultWidgets.takeLast();
|
||||||
|
delete d->m_searchResults.takeLast();
|
||||||
d->m_recentSearchesBox->removeItem(d->m_recentSearchesBox->count()-1);
|
d->m_recentSearchesBox->removeItem(d->m_recentSearchesBox->count()-1);
|
||||||
if (d->m_currentIndex >= d->m_recentSearchesBox->count()) {
|
if (d->m_currentIndex >= d->m_recentSearchesBox->count()) {
|
||||||
// temporarily set the index to the last existing
|
// temporarily set the index to the last existing
|
||||||
@@ -380,6 +399,7 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label,
|
|||||||
d->m_widget->insertWidget(1, widget);
|
d->m_widget->insertWidget(1, widget);
|
||||||
connect(widget, SIGNAL(navigateStateChanged()), this, SLOT(navigateStateChanged()));
|
connect(widget, SIGNAL(navigateStateChanged()), this, SLOT(navigateStateChanged()));
|
||||||
connect(widget, SIGNAL(restarted()), d, SLOT(moveWidgetToTop()));
|
connect(widget, SIGNAL(restarted()), d, SLOT(moveWidgetToTop()));
|
||||||
|
connect(widget, SIGNAL(requestPopup(bool)), d, SLOT(popupRequested(bool)));
|
||||||
widget->setTextEditorFont(d->m_font);
|
widget->setTextEditorFont(d->m_font);
|
||||||
widget->setShowReplaceUI(searchOrSearchAndReplace != SearchOnly);
|
widget->setShowReplaceUI(searchOrSearchAndReplace != SearchOnly);
|
||||||
widget->setAutoExpandResults(d->m_expandCollapseAction->isChecked());
|
widget->setAutoExpandResults(d->m_expandCollapseAction->isChecked());
|
||||||
@@ -584,6 +604,8 @@ SearchResult::SearchResult(SearchResultWidget *widget)
|
|||||||
this, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
this, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
||||||
connect(widget, SIGNAL(cancelled()),
|
connect(widget, SIGNAL(cancelled()),
|
||||||
this, SIGNAL(cancelled()));
|
this, SIGNAL(cancelled()));
|
||||||
|
connect(widget, SIGNAL(paused(bool)),
|
||||||
|
this, SIGNAL(paused(bool)));
|
||||||
connect(widget, SIGNAL(visibilityChanged(bool)),
|
connect(widget, SIGNAL(visibilityChanged(bool)),
|
||||||
this, SIGNAL(visibilityChanged(bool)));
|
this, SIGNAL(visibilityChanged(bool)));
|
||||||
connect(widget, SIGNAL(searchAgainRequested()),
|
connect(widget, SIGNAL(searchAgainRequested()),
|
||||||
@@ -697,6 +719,14 @@ void SearchResult::setSearchAgainEnabled(bool enabled)
|
|||||||
m_widget->setSearchAgainEnabled(enabled);
|
m_widget->setSearchAgainEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Pops up the search result panel with this search.
|
||||||
|
*/
|
||||||
|
void SearchResult::popup()
|
||||||
|
{
|
||||||
|
m_widget->sendRequestPopup();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Find
|
} // namespace Find
|
||||||
|
|
||||||
#include "searchresultwindow.moc"
|
#include "searchresultwindow.moc"
|
||||||
|
|||||||
@@ -109,11 +109,13 @@ public slots:
|
|||||||
void setTextToReplace(const QString &textToReplace);
|
void setTextToReplace(const QString &textToReplace);
|
||||||
void restart();
|
void restart();
|
||||||
void setSearchAgainEnabled(bool enabled);
|
void setSearchAgainEnabled(bool enabled);
|
||||||
|
void popup();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activated(const Find::SearchResultItem &item);
|
void activated(const Find::SearchResultItem &item);
|
||||||
void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems);
|
void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems);
|
||||||
void cancelled();
|
void cancelled();
|
||||||
|
void paused(bool paused);
|
||||||
void visibilityChanged(bool visible);
|
void visibilityChanged(bool visible);
|
||||||
void countChanged(int count);
|
void countChanged(int count);
|
||||||
void searchAgainRequested();
|
void searchAgainRequested();
|
||||||
|
|||||||
@@ -698,18 +698,23 @@ class ProcessFile: public std::unary_function<QString, QList<FindReferences::Usa
|
|||||||
typedef FindReferences::Usage Usage;
|
typedef FindReferences::Usage Usage;
|
||||||
QString name;
|
QString name;
|
||||||
const ObjectValue *scope;
|
const ObjectValue *scope;
|
||||||
|
QFutureInterface<Usage> *future;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProcessFile(const ContextPtr &context,
|
ProcessFile(const ContextPtr &context,
|
||||||
QString name,
|
QString name,
|
||||||
const ObjectValue *scope)
|
const ObjectValue *scope,
|
||||||
: context(context), name(name), scope(scope)
|
QFutureInterface<Usage> *future)
|
||||||
|
: context(context), name(name), scope(scope), future(future)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
QList<Usage> operator()(const QString &fileName)
|
QList<Usage> operator()(const QString &fileName)
|
||||||
{
|
{
|
||||||
QList<Usage> usages;
|
QList<Usage> usages;
|
||||||
|
if (future->isPaused())
|
||||||
|
future->waitForResume();
|
||||||
|
if (future->isCanceled())
|
||||||
|
return usages;
|
||||||
Document::Ptr doc = context->snapshot().document(fileName);
|
Document::Ptr doc = context->snapshot().document(fileName);
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return usages;
|
return usages;
|
||||||
@@ -719,7 +724,8 @@ public:
|
|||||||
FindUsages::Result results = findUsages(name, scope);
|
FindUsages::Result results = findUsages(name, scope);
|
||||||
foreach (const AST::SourceLocation &loc, results)
|
foreach (const AST::SourceLocation &loc, results)
|
||||||
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
||||||
|
if (future->isPaused())
|
||||||
|
future->waitForResume();
|
||||||
return usages;
|
return usages;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -730,18 +736,23 @@ class SearchFileForType: public std::unary_function<QString, QList<FindReference
|
|||||||
typedef FindReferences::Usage Usage;
|
typedef FindReferences::Usage Usage;
|
||||||
QString name;
|
QString name;
|
||||||
const ObjectValue *scope;
|
const ObjectValue *scope;
|
||||||
|
QFutureInterface<Usage> *future;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SearchFileForType(const ContextPtr &context,
|
SearchFileForType(const ContextPtr &context,
|
||||||
QString name,
|
QString name,
|
||||||
const ObjectValue *scope)
|
const ObjectValue *scope,
|
||||||
: context(context), name(name), scope(scope)
|
QFutureInterface<Usage> *future)
|
||||||
|
: context(context), name(name), scope(scope), future(future)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
QList<Usage> operator()(const QString &fileName)
|
QList<Usage> operator()(const QString &fileName)
|
||||||
{
|
{
|
||||||
QList<Usage> usages;
|
QList<Usage> usages;
|
||||||
|
if (future->isPaused())
|
||||||
|
future->waitForResume();
|
||||||
|
if (future->isCanceled())
|
||||||
|
return usages;
|
||||||
Document::Ptr doc = context->snapshot().document(fileName);
|
Document::Ptr doc = context->snapshot().document(fileName);
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return usages;
|
return usages;
|
||||||
@@ -751,7 +762,8 @@ public:
|
|||||||
FindTypeUsages::Result results = findUsages(name, scope);
|
FindTypeUsages::Result results = findUsages(name, scope);
|
||||||
foreach (const AST::SourceLocation &loc, results)
|
foreach (const AST::SourceLocation &loc, results)
|
||||||
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
||||||
|
if (future->isPaused())
|
||||||
|
future->waitForResume();
|
||||||
return usages;
|
return usages;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -857,7 +869,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
|||||||
return;
|
return;
|
||||||
future.reportResult(searchStarting);
|
future.reportResult(searchStarting);
|
||||||
|
|
||||||
SearchFileForType process(context, name, typeValue);
|
SearchFileForType process(context, name, typeValue, &future);
|
||||||
UpdateUI reduce(&future);
|
UpdateUI reduce(&future);
|
||||||
|
|
||||||
QtConcurrent::blockingMappedReduced<QList<FindReferences::Usage> > (files, process, reduce);
|
QtConcurrent::blockingMappedReduced<QList<FindReferences::Usage> > (files, process, reduce);
|
||||||
@@ -872,7 +884,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
|||||||
searchStarting.lineText.prepend(scope->className() + QLatin1Char('.'));
|
searchStarting.lineText.prepend(scope->className() + QLatin1Char('.'));
|
||||||
future.reportResult(searchStarting);
|
future.reportResult(searchStarting);
|
||||||
|
|
||||||
ProcessFile process(context, name, scope);
|
ProcessFile process(context, name, scope, &future);
|
||||||
UpdateUI reduce(&future);
|
UpdateUI reduce(&future);
|
||||||
|
|
||||||
QtConcurrent::blockingMappedReduced<QList<FindReferences::Usage> > (files, process, reduce);
|
QtConcurrent::blockingMappedReduced<QList<FindReferences::Usage> > (files, process, reduce);
|
||||||
@@ -930,13 +942,14 @@ void FindReferences::displayResults(int first, int last)
|
|||||||
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
|
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
|
||||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
connect(m_currentSearch, SIGNAL(cancelled()), this, SLOT(cancel()));
|
connect(m_currentSearch, SIGNAL(cancelled()), this, SLOT(cancel()));
|
||||||
|
connect(m_currentSearch, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||||
Find::SearchResultWindow::instance()->popup(true);
|
Find::SearchResultWindow::instance()->popup(true);
|
||||||
|
|
||||||
Core::ProgressManager *progressManager = Core::ICore::progressManager();
|
Core::ProgressManager *progressManager = Core::ICore::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()), Find::SearchResultWindow::instance(), SLOT(popup()));
|
connect(progress, SIGNAL(clicked()), m_currentSearch, SLOT(popup()));
|
||||||
|
|
||||||
++first;
|
++first;
|
||||||
}
|
}
|
||||||
@@ -968,6 +981,12 @@ void FindReferences::cancel()
|
|||||||
m_watcher.cancel();
|
m_watcher.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FindReferences::setPaused(bool paused)
|
||||||
|
{
|
||||||
|
if (!paused || m_watcher.isRunning()) // guard against pausing when the search is finished
|
||||||
|
m_watcher.setPaused(paused);
|
||||||
|
}
|
||||||
|
|
||||||
void FindReferences::openEditor(const Find::SearchResultItem &item)
|
void FindReferences::openEditor(const Find::SearchResultItem &item)
|
||||||
{
|
{
|
||||||
if (item.path.size() > 0) {
|
if (item.path.size() > 0) {
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ private Q_SLOTS:
|
|||||||
void displayResults(int first, int last);
|
void displayResults(int first, int last);
|
||||||
void searchFinished();
|
void searchFinished();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
void setPaused(bool paused);
|
||||||
void openEditor(const Find::SearchResultItem &item);
|
void openEditor(const Find::SearchResultItem &item);
|
||||||
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,16 @@ void BaseFileFind::cancel()
|
|||||||
watcher->cancel();
|
watcher->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseFileFind::setPaused(bool paused)
|
||||||
|
{
|
||||||
|
SearchResult *search = qobject_cast<SearchResult *>(sender());
|
||||||
|
QTC_ASSERT(search, return);
|
||||||
|
QFutureWatcher<FileSearchResultList> *watcher = m_watchers.key(search);
|
||||||
|
QTC_ASSERT(watcher, return);
|
||||||
|
if (!paused || watcher->isRunning()) // guard against pausing when the search is finished
|
||||||
|
watcher->setPaused(paused);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList BaseFileFind::fileNameFilters() const
|
QStringList BaseFileFind::fileNameFilters() const
|
||||||
{
|
{
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
@@ -130,6 +140,7 @@ void BaseFileFind::runNewSearch(const QString &txt, Find::FindFlags findFlags,
|
|||||||
}
|
}
|
||||||
connect(search, SIGNAL(visibilityChanged(bool)), this, SLOT(hideHighlightAll(bool)));
|
connect(search, SIGNAL(visibilityChanged(bool)), this, SLOT(hideHighlightAll(bool)));
|
||||||
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
||||||
|
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||||
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
||||||
connect(this, SIGNAL(enabledChanged(bool)), search, SLOT(setSearchAgainEnabled(bool)));
|
connect(this, SIGNAL(enabledChanged(bool)), search, SLOT(setSearchAgainEnabled(bool)));
|
||||||
runSearch(search);
|
runSearch(search);
|
||||||
@@ -162,7 +173,7 @@ void BaseFileFind::runSearch(Find::SearchResult *search)
|
|||||||
tr("Search"),
|
tr("Search"),
|
||||||
QLatin1String(Constants::TASK_SEARCH));
|
QLatin1String(Constants::TASK_SEARCH));
|
||||||
progress->setWidget(label);
|
progress->setWidget(label);
|
||||||
connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup()));
|
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseFileFind::findAll(const QString &txt, Find::FindFlags findFlags)
|
void BaseFileFind::findAll(const QString &txt, Find::FindFlags findFlags)
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ private slots:
|
|||||||
void displayResult(int index);
|
void displayResult(int index);
|
||||||
void searchFinished();
|
void searchFinished();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
void setPaused(bool paused);
|
||||||
void openEditor(const Find::SearchResultItem &item);
|
void openEditor(const Find::SearchResultItem &item);
|
||||||
void doReplace(const QString &txt,
|
void doReplace(const QString &txt,
|
||||||
const QList<Find::SearchResultItem> &items);
|
const QList<Find::SearchResultItem> &items);
|
||||||
|
|||||||
Reference in New Issue
Block a user