Commit 8a7bc472 authored by Eike Ziller's avatar Eike Ziller

Mark canceled searches as such.

Task-number: QTCREATORBUG-6820

Change-Id: Ic14c0ea6f26e4a05c642012b87578f30c817fef7
Reviewed-by: default avatarRobert Löhning <robert.loehning@nokia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent cfa703c6
......@@ -275,7 +275,7 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search)
{
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
if (!(parameters.symbol && parameters.symbol->identifier())) {
search->finishSearch();
search->finishSearch(false);
return;
}
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
......@@ -313,7 +313,7 @@ void CppFindReferences::searchAgain()
Snapshot snapshot = CppModelManagerInterface::instance()->snapshot();
search->restart();
if (!findSymbol(&parameters, snapshot)) {
search->finishSearch();
search->finishSearch(false);
return;
}
search->setUserData(qVariantFromValue(parameters));
......@@ -498,7 +498,7 @@ void CppFindReferences::searchFinished()
QFutureWatcher<Usage> *watcher = static_cast<QFutureWatcher<Usage> *>(sender());
Find::SearchResult *search = m_watchers.value(watcher);
if (search)
search->finishSearch();
search->finishSearch(watcher->isCanceled());
m_watchers.remove(watcher);
}
......
......@@ -217,7 +217,7 @@ void SymbolsFindFilter::finish()
static_cast<QFutureWatcher<Find::SearchResultItem> *>(sender());
Find::SearchResult *search = m_watchers.value(watcher);
if (search)
search->finishSearch();
search->finishSearch(watcher->isCanceled());
m_watchers.remove(watcher);
watcher->deleteLater();
}
......
......@@ -96,6 +96,23 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
QHBoxLayout *topLayout = new QHBoxLayout(topWidget);
topLayout->setMargin(2);
topWidget->setLayout(topLayout);
layout->addWidget(topWidget);
m_messageWidget = new QFrame;
pal.setColor(QPalette::Window, QColor(255, 255, 225));
pal.setColor(QPalette::WindowText, Qt::red);
m_messageWidget->setPalette(pal);
m_messageWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
m_messageWidget->setLineWidth(1);
m_messageWidget->setAutoFillBackground(true);
QHBoxLayout *messageLayout = new QHBoxLayout(m_messageWidget);
messageLayout->setMargin(2);
m_messageWidget->setLayout(messageLayout);
QLabel *messageLabel = new QLabel(tr("Search was canceled."));
messageLabel->setPalette(pal);
messageLayout->addWidget(messageLabel);
layout->addWidget(m_messageWidget);
m_messageWidget->setVisible(false);
m_searchResultTreeView = new Internal::SearchResultTreeView(this);
m_searchResultTreeView->setFrameStyle(QFrame::NoFrame);
......@@ -104,11 +121,9 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
agg->add(m_searchResultTreeView);
agg->add(new TreeViewFind(m_searchResultTreeView,
ItemDataRoles::ResultLineRole));
layout->addWidget(topWidget);
layout->addWidget(m_searchResultTreeView);
m_infoBarDisplay.setTarget(layout, 1);
m_infoBarDisplay.setTarget(layout, 2);
m_infoBarDisplay.setInfoBar(&m_infoBar);
m_descriptionContainer = new QWidget(topWidget);
......@@ -332,6 +347,7 @@ void SearchResultWidget::restart()
m_count = 0;
m_cancelButton->setVisible(true);
m_searchAgainButton->setVisible(false);
m_messageWidget->setVisible(false);
updateMatchesFoundLabel();
emit restarted();
}
......@@ -347,11 +363,12 @@ void SearchResultWidget::setSearchAgainEnabled(bool enabled)
m_searchAgainButton->setEnabled(enabled);
}
void SearchResultWidget::finishSearch()
void SearchResultWidget::finishSearch(bool canceled)
{
m_replaceTextEdit->setEnabled(m_count > 0);
m_replaceButton->setEnabled(m_count > 0);
m_cancelButton->setVisible(false);
m_messageWidget->setVisible(canceled);
m_searchAgainButton->setVisible(m_searchAgainSupported);
}
......
......@@ -37,6 +37,7 @@
#include <coreplugin/infobar.h>
#include <QFrame>
#include <QLabel>
#include <QLineEdit>
#include <QToolButton>
......@@ -89,7 +90,7 @@ public:
void setSearchAgainEnabled(bool enabled);
public slots:
void finishSearch();
void finishSearch(bool canceled);
signals:
void activated(const Find::SearchResultItem &item);
......@@ -117,6 +118,7 @@ private:
SearchResultTreeView *m_searchResultTreeView;
int m_count;
QString m_dontAskAgainGroup;
QFrame *m_messageWidget;
Core::InfoBar m_infoBar;
Core::InfoBarDisplay m_infoBarDisplay;
bool m_isShowingReplaceUI;
......
......@@ -669,9 +669,9 @@ void SearchResult::addResults(const QList<SearchResultItem> &items, AddMode mode
\brief Notifies the search result window that the current search
has finished, and the UI should reflect that.
*/
void SearchResult::finishSearch()
void SearchResult::finishSearch(bool canceled)
{
m_widget->finishSearch();
m_widget->finishSearch(canceled);
}
/*!
......
......@@ -105,7 +105,7 @@ 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 finishSearch(bool canceled);
void setTextToReplace(const QString &textToReplace);
void restart();
void setSearchAgainEnabled(bool enabled);
......
......@@ -958,7 +958,7 @@ void FindReferences::displayResults(int first, int last)
void FindReferences::searchFinished()
{
if (m_currentSearch)
m_currentSearch->finishSearch();
m_currentSearch->finishSearch(m_watcher.isCanceled());
m_currentSearch = 0;
emit changed();
}
......
......@@ -216,7 +216,7 @@ void BaseFileFind::searchFinished()
static_cast<QFutureWatcher<FileSearchResultList> *>(sender());
SearchResult *search = m_watchers.value(watcher);
if (search)
search->finishSearch();
search->finishSearch(watcher->isCanceled());
m_watchers.remove(watcher);
watcher->deleteLater();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment