forked from qt-creator/qt-creator
Move repeated searches to top.
Task-number: QTCREATORBUG-6907 Change-Id: I25c04185beb3729e2d11cc88d17fcd1a3b51037c Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -311,7 +311,7 @@ void CppFindReferences::searchAgain()
|
||||
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
|
||||
Snapshot snapshot = CppModelManagerInterface::instance()->snapshot();
|
||||
search->reset();
|
||||
search->restart();
|
||||
if (!findSymbol(¶meters, snapshot)) {
|
||||
search->finishSearch();
|
||||
return;
|
||||
|
||||
@@ -276,7 +276,7 @@ void SymbolsFindFilter::searchAgain()
|
||||
{
|
||||
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||
QTC_ASSERT(search, return);
|
||||
search->reset();
|
||||
search->restart();
|
||||
startSearch(search);
|
||||
}
|
||||
|
||||
|
||||
@@ -457,7 +457,7 @@ void SearchResultWidget::goToPrevious()
|
||||
}
|
||||
}
|
||||
|
||||
void SearchResultWidget::reset()
|
||||
void SearchResultWidget::restart()
|
||||
{
|
||||
m_replaceTextEdit->setEnabled(false);
|
||||
m_replaceButton->setEnabled(false);
|
||||
@@ -466,6 +466,7 @@ void SearchResultWidget::reset()
|
||||
m_cancelButton->setVisible(true);
|
||||
m_searchAgainButton->setVisible(false);
|
||||
updateMatchesFoundLabel();
|
||||
emit restarted();
|
||||
}
|
||||
|
||||
void SearchResultWidget::setSearchAgainSupported(bool supported)
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void goToNext();
|
||||
void goToPrevious();
|
||||
|
||||
void reset();
|
||||
void restart();
|
||||
|
||||
void setSearchAgainSupported(bool supported);
|
||||
void setSearchAgainEnabled(bool enabled);
|
||||
@@ -96,6 +96,7 @@ signals:
|
||||
void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems);
|
||||
void searchAgainRequested();
|
||||
void cancelled();
|
||||
void restarted();
|
||||
void visibilityChanged(bool visible);
|
||||
|
||||
void navigateStateChanged();
|
||||
|
||||
@@ -101,6 +101,7 @@ namespace Internal {
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(int index);
|
||||
void moveWidgetToTop();
|
||||
};
|
||||
|
||||
SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window)
|
||||
@@ -135,6 +136,40 @@ namespace Internal {
|
||||
}
|
||||
q->navigateStateChanged();
|
||||
}
|
||||
|
||||
void SearchResultWindowPrivate::moveWidgetToTop()
|
||||
{
|
||||
SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender());
|
||||
QTC_ASSERT(widget, return);
|
||||
int index = m_searchResultWidgets.indexOf(widget);
|
||||
if (index == 0)
|
||||
return; // nothing to do
|
||||
int internalIndex = index + 1/*account for "new search" entry*/;
|
||||
QString searchEntry = m_recentSearchesBox->itemText(internalIndex);
|
||||
|
||||
m_searchResultWidgets.removeAt(index);
|
||||
m_widget->removeWidget(widget);
|
||||
m_recentSearchesBox->removeItem(internalIndex);
|
||||
SearchResult *result = m_searchResults.takeAt(index);
|
||||
|
||||
m_searchResultWidgets.prepend(widget);
|
||||
m_widget->insertWidget(1, widget);
|
||||
m_recentSearchesBox->insertItem(1, searchEntry);
|
||||
m_searchResults.prepend(result);
|
||||
|
||||
// adapt the current index
|
||||
if (index == visibleSearchIndex()) {
|
||||
// was visible, so we switch
|
||||
// this is the default case
|
||||
m_currentIndex = 1;
|
||||
m_widget->setCurrentIndex(1);
|
||||
m_recentSearchesBox->setCurrentIndex(1);
|
||||
} else if (visibleSearchIndex() < index) {
|
||||
// academical case where the widget moved before the current widget
|
||||
// only our internal book keeping needed
|
||||
++m_currentIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using namespace Find::Internal;
|
||||
@@ -344,6 +379,7 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label,
|
||||
d->m_searchResultWidgets.prepend(widget);
|
||||
d->m_widget->insertWidget(1, widget);
|
||||
connect(widget, SIGNAL(navigateStateChanged()), this, SLOT(navigateStateChanged()));
|
||||
connect(widget, SIGNAL(restarted()), d, SLOT(moveWidgetToTop()));
|
||||
widget->setTextEditorFont(d->m_font);
|
||||
widget->setShowReplaceUI(searchOrSearchAndReplace != SearchOnly);
|
||||
widget->setAutoExpandResults(d->m_expandCollapseAction->isChecked());
|
||||
@@ -651,9 +687,9 @@ void SearchResult::setTextToReplace(const QString &textToReplace)
|
||||
/*!
|
||||
* \brief Removes all search results.
|
||||
*/
|
||||
void SearchResult::reset()
|
||||
void SearchResult::restart()
|
||||
{
|
||||
m_widget->reset();
|
||||
m_widget->restart();
|
||||
}
|
||||
|
||||
void SearchResult::setSearchAgainEnabled(bool enabled)
|
||||
|
||||
@@ -107,7 +107,7 @@ public slots:
|
||||
void addResults(const QList<SearchResultItem> &items, AddMode mode);
|
||||
void finishSearch();
|
||||
void setTextToReplace(const QString &textToReplace);
|
||||
void reset();
|
||||
void restart();
|
||||
void setSearchAgainEnabled(bool enabled);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -319,7 +319,7 @@ void BaseFileFind::hideHighlightAll(bool visible)
|
||||
void BaseFileFind::searchAgain()
|
||||
{
|
||||
SearchResult *search = qobject_cast<SearchResult *>(sender());
|
||||
search->reset();
|
||||
search->restart();
|
||||
runSearch(search);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user