summaryrefslogtreecommitdiff
path: root/src/plugins/find
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@nokia.com>2011-12-13 10:50:57 +0100
committerEike Ziller <eike.ziller@nokia.com>2011-12-19 12:07:05 +0100
commit2538f8001c9fc2809d4179c1f06082632c24f9e0 (patch)
treed1c200e22d016366a6f8307b13efd578c755f605 /src/plugins/find
parente1c388f1d2adfe09ea65f9bf3966256ef15e5fe8 (diff)
downloadqt-creator-2538f8001c9fc2809d4179c1f06082632c24f9e0.tar.gz
Implement "Search Again" for file/text searches
Task-number: QTCREATORBUG-621 Change-Id: I6fb7df3d943353497b73b9813684ae973b708913 Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
Diffstat (limited to 'src/plugins/find')
-rw-r--r--src/plugins/find/searchresultwidget.cpp37
-rw-r--r--src/plugins/find/searchresultwidget.h8
-rw-r--r--src/plugins/find/searchresultwindow.cpp15
-rw-r--r--src/plugins/find/searchresultwindow.h3
4 files changed, 61 insertions, 2 deletions
diff --git a/src/plugins/find/searchresultwidget.cpp b/src/plugins/find/searchresultwidget.cpp
index 11195b35d5..9bb9707375 100644
--- a/src/plugins/find/searchresultwidget.cpp
+++ b/src/plugins/find/searchresultwidget.cpp
@@ -211,7 +211,8 @@ using namespace Find::Internal;
SearchResultWidget::SearchResultWidget(QWidget *parent) :
QWidget(parent),
m_count(0),
- m_isShowingReplaceUI(false)
+ m_isShowingReplaceUI(false),
+ m_searchAgainSupported(false)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
@@ -259,21 +260,30 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
m_cancelButton->setText(tr("Cancel"));
m_cancelButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
+ m_searchAgainButton = new QToolButton(topWidget);
+ m_searchAgainButton->setToolTip(tr("Repeat the search with same parameters"));
+ m_searchAgainButton->setText(tr("Search again"));
+ m_searchAgainButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
+ m_searchAgainButton->setVisible(false);
+ connect(m_searchAgainButton, SIGNAL(clicked()), this, SLOT(searchAgain()));
m_replaceLabel = new QLabel(tr("Replace with:"), topWidget);
m_replaceTextEdit = new WideEnoughLineEdit(topWidget);
m_replaceTextEdit->setMinimumWidth(120);
+ m_replaceTextEdit->setEnabled(false);
+ m_replaceTextEdit->setTabOrder(m_replaceTextEdit, m_searchResultTreeView);
m_replaceButton = new QToolButton(topWidget);
m_replaceButton->setToolTip(tr("Replace all occurrences"));
m_replaceButton->setText(tr("Replace"));
m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
- m_replaceTextEdit->setTabOrder(m_replaceTextEdit, m_searchResultTreeView);
+ m_replaceButton->setEnabled(false);
m_matchesFoundLabel = new QLabel(topWidget);
updateMatchesFoundLabel();
topLayout->addWidget(m_descriptionContainer);
topLayout->addWidget(m_cancelButton);
+ topLayout->addWidget(m_searchAgainButton);
topLayout->addWidget(m_replaceLabel);
topLayout->addWidget(m_replaceTextEdit);
topLayout->addWidget(m_replaceButton);
@@ -447,11 +457,29 @@ void SearchResultWidget::goToPrevious()
}
}
+void SearchResultWidget::reset()
+{
+ m_replaceTextEdit->setEnabled(false);
+ m_replaceButton->setEnabled(false);
+ m_searchResultTreeView->clear();
+ m_count = 0;
+ m_cancelButton->setVisible(true);
+ m_searchAgainButton->setVisible(false);
+ updateMatchesFoundLabel();
+}
+
+void SearchResultWidget::setSearchAgainSupported(bool supported)
+{
+ m_searchAgainSupported = supported;
+ m_searchAgainButton->setVisible(supported && !m_cancelButton->isVisible());
+}
+
void SearchResultWidget::finishSearch()
{
m_replaceTextEdit->setEnabled(m_count > 0);
m_replaceButton->setEnabled(m_count > 0);
m_cancelButton->setVisible(false);
+ m_searchAgainButton->setVisible(m_searchAgainSupported);
}
void SearchResultWidget::hideNoUndoWarning()
@@ -481,6 +509,11 @@ void SearchResultWidget::cancel()
emit cancelled();
}
+void SearchResultWidget::searchAgain()
+{
+ emit searchAgainRequested();
+}
+
bool SearchResultWidget::showWarningMessage() const
{
if (m_dontAskAgainGroup.isEmpty())
diff --git a/src/plugins/find/searchresultwidget.h b/src/plugins/find/searchresultwidget.h
index 6fde4e6c38..65e0a99812 100644
--- a/src/plugins/find/searchresultwidget.h
+++ b/src/plugins/find/searchresultwidget.h
@@ -83,12 +83,17 @@ public:
void goToNext();
void goToPrevious();
+ void reset();
+
+ void setSearchAgainSupported(bool supported);
+
public slots:
void finishSearch();
signals:
void activated(const Find::SearchResultItem &item);
void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems);
+ void searchAgainRequested();
void cancelled();
void visibilityChanged(bool visible);
@@ -99,6 +104,7 @@ private slots:
void handleJumpToSearchResult(const SearchResultItem &item);
void handleReplaceButton();
void cancel();
+ void searchAgain();
private:
bool showWarningMessage() const;
@@ -115,6 +121,8 @@ private:
QLabel *m_replaceLabel;
QLineEdit *m_replaceTextEdit;
QToolButton *m_replaceButton;
+ QToolButton *m_searchAgainButton;
+ bool m_searchAgainSupported;
QWidget *m_descriptionContainer;
QLabel *m_label;
QLabel *m_searchTerm;
diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/find/searchresultwindow.cpp
index a8beb98601..03ece1322d 100644
--- a/src/plugins/find/searchresultwindow.cpp
+++ b/src/plugins/find/searchresultwindow.cpp
@@ -549,6 +549,8 @@ SearchResult::SearchResult(SearchResultWidget *widget)
this, SIGNAL(cancelled()));
connect(widget, SIGNAL(visibilityChanged(bool)),
this, SIGNAL(visibilityChanged(bool)));
+ connect(widget, SIGNAL(searchAgainRequested()),
+ this, SIGNAL(searchAgainRequested()));
}
/*!
@@ -587,6 +589,11 @@ int SearchResult::count() const
return m_widget->count();
}
+void SearchResult::setSearchAgainSupported(bool supported)
+{
+ m_widget->setSearchAgainSupported(supported);
+}
+
/*!
\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.
@@ -640,6 +647,14 @@ void SearchResult::setTextToReplace(const QString &textToReplace)
m_widget->setTextToReplace(textToReplace);
}
+/*!
+ * \brief Removes all search results.
+ */
+void SearchResult::reset()
+{
+ m_widget->reset();
+}
+
} // namespace Find
#include "searchresultwindow.moc"
diff --git a/src/plugins/find/searchresultwindow.h b/src/plugins/find/searchresultwindow.h
index 5415166c2d..284eca5f75 100644
--- a/src/plugins/find/searchresultwindow.h
+++ b/src/plugins/find/searchresultwindow.h
@@ -99,6 +99,7 @@ public:
QVariant userData() const;
QString textToReplace() const;
int count() const;
+ void setSearchAgainSupported(bool supported);
public slots:
void addResult(const QString &fileName, int lineNumber, const QString &lineText,
@@ -106,6 +107,7 @@ public slots:
void addResults(const QList<SearchResultItem> &items, AddMode mode);
void finishSearch();
void setTextToReplace(const QString &textToReplace);
+ void reset();
signals:
void activated(const Find::SearchResultItem &item);
@@ -113,6 +115,7 @@ signals:
void cancelled();
void visibilityChanged(bool visible);
void countChanged(int count);
+ void searchAgainRequested();
private:
SearchResult(Internal::SearchResultWidget *widget);