forked from qt-creator/qt-creator
Use new progress subtitle API for search result count
Change-Id: Ie40f44a3bdb7621c48560cb560ccc2622d59ba4a Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -293,10 +293,6 @@ void BaseFileFind::runNewSearch(const QString &txt, FindFlags findFlags,
|
|||||||
void BaseFileFind::runSearch(SearchResult *search)
|
void BaseFileFind::runSearch(SearchResult *search)
|
||||||
{
|
{
|
||||||
const FileFindParameters parameters = search->userData().value<FileFindParameters>();
|
const FileFindParameters parameters = search->userData().value<FileFindParameters>();
|
||||||
auto label = new CountingLabel;
|
|
||||||
connect(search, &SearchResult::countChanged, label, &CountingLabel::updateCount);
|
|
||||||
auto statusLabel = new CountingLabel;
|
|
||||||
connect(search, &SearchResult::countChanged, statusLabel, &CountingLabel::updateCount);
|
|
||||||
SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch|IOutputPane::WithFocus));
|
SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch|IOutputPane::WithFocus));
|
||||||
auto watcher = new QFutureWatcher<FileSearchResultList>();
|
auto watcher = new QFutureWatcher<FileSearchResultList>();
|
||||||
watcher->setPendingResultsLimit(1);
|
watcher->setPendingResultsLimit(1);
|
||||||
@@ -316,10 +312,13 @@ void BaseFileFind::runSearch(SearchResult *search)
|
|||||||
search->finishSearch(watcher->isCanceled());
|
search->finishSearch(watcher->isCanceled());
|
||||||
});
|
});
|
||||||
watcher->setFuture(executeSearch(parameters));
|
watcher->setFuture(executeSearch(parameters));
|
||||||
FutureProgress *progress =
|
FutureProgress *progress = ProgressManager::addTask(watcher->future(),
|
||||||
ProgressManager::addTask(watcher->future(), tr("Searching"), Constants::TASK_SEARCH);
|
tr("Searching"),
|
||||||
progress->setWidget(label);
|
Constants::TASK_SEARCH);
|
||||||
progress->setStatusBarWidget(statusLabel);
|
connect(search, &SearchResult::countChanged, progress, [progress](int c) {
|
||||||
|
progress->setSubtitle(BaseFileFind::tr("%n found.", nullptr, c));
|
||||||
|
});
|
||||||
|
progress->setSubtitleVisibleInStatusBar(true);
|
||||||
connect(progress, &FutureProgress::clicked, search, &SearchResult::popup);
|
connect(progress, &FutureProgress::clicked, search, &SearchResult::popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,23 +565,5 @@ QFuture<FileSearchResultList> BaseFileFind::executeSearch(const FileFindParamete
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
CountingLabel::CountingLabel()
|
|
||||||
{
|
|
||||||
setAlignment(Qt::AlignCenter);
|
|
||||||
// ### TODO this setup should be done by style
|
|
||||||
QFont f = font();
|
|
||||||
f.setBold(true);
|
|
||||||
f.setPointSizeF(StyleHelper::sidebarFontSize());
|
|
||||||
setFont(f);
|
|
||||||
setPalette(StyleHelper::sidebarFontPalette(palette()));
|
|
||||||
setProperty("_q_custom_style_disabled", QVariant(true));
|
|
||||||
updateCount(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CountingLabel::updateCount(int count)
|
|
||||||
{
|
|
||||||
setText(BaseFileFind::tr("%n found.", nullptr, count));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
Reference in New Issue
Block a user