diff --git a/plugins/grepview/grepdialog.cpp b/plugins/grepview/grepdialog.cpp --- a/plugins/grepview/grepdialog.cpp +++ b/plugins/grepview/grepdialog.cpp @@ -480,7 +480,6 @@ QList choice = getDirectoryChoice(descriptionOrUrl); QString description = descriptionOrUrl; - GrepJob* job = m_plugin->newGrepJob(); // Shorten the description if(descriptionOrUrl != allOpenFilesString() && descriptionOrUrl != allOpenProjectsString()) { auto prettyFileName = [](const QUrl& url) { @@ -494,27 +493,40 @@ } } - GrepOutputView *toolView = (GrepOutputView*)ICore::self()->uiController()-> - findToolView(i18n("Find/Replace in Files"), m_plugin->toolViewFactory(), IUiController::CreateAndRaise); - GrepOutputModel* outputModel = toolView->renewModel(m_settings, description); + GrepOutputView *toolView = + (GrepOutputView*)ICore::self()->uiController()->findToolView( + i18n("Find/Replace in Files"), m_plugin->toolViewFactory(), + m_settings.fromHistory ? IUiController::Create : IUiController::CreateAndRaise); - connect(job, &GrepJob::showErrorMessage, - toolView, &GrepOutputView::showErrorMessage); - //the GrepOutputModel gets the 'showMessage' signal to store it and forward - //it to toolView - connect(job, &GrepJob::showMessage, - outputModel, &GrepOutputModel::showMessageSlot); - connect(outputModel, &GrepOutputModel::showMessage, - toolView, &GrepOutputView::showMessage); + if (m_settings.fromHistory) { + // when restored from history, only display the parameters + toolView->renewModel(m_settings, i18n("Search \"%1\" in %2", m_settings.pattern, description)); + emit m_plugin->grepJobFinished(true); + } else { + GrepOutputModel* outputModel = + toolView->renewModel(m_settings, + i18n("Search \"%1\" in %2 (at time %3)", m_settings.pattern, description, + QTime::currentTime().toString(QStringLiteral("hh:mm")))); + + GrepJob* job = m_plugin->newGrepJob(); + connect(job, &GrepJob::showErrorMessage, + toolView, &GrepOutputView::showErrorMessage); + //the GrepOutputModel gets the 'showMessage' signal to store it and forward + //it to toolView + connect(job, &GrepJob::showMessage, + outputModel, &GrepOutputModel::showMessageSlot); + connect(outputModel, &GrepOutputModel::showMessage, + toolView, &GrepOutputView::showMessage); - connect(toolView, &GrepOutputView::outputViewIsClosed, job, [=]() {job->kill();}); + connect(toolView, &GrepOutputView::outputViewIsClosed, job, [=]() {job->kill();}); - job->setOutputModel(outputModel); - job->setDirectoryChoice(choice); + job->setOutputModel(outputModel); + job->setDirectoryChoice(choice); - job->setSettings(m_settings); + job->setSettings(m_settings); - ICore::self()->runController()->registerJob(job); + ICore::self()->runController()->registerJob(job); + } m_plugin->rememberSearchDirectory(descriptionOrUrl); diff --git a/plugins/grepview/grepjob.h b/plugins/grepview/grepjob.h --- a/plugins/grepview/grepjob.h +++ b/plugins/grepview/grepjob.h @@ -37,6 +37,8 @@ struct GrepJobSettings { + bool fromHistory = false; + bool projectFilesOnly = false; bool caseSensitive = true; bool regexp = true; diff --git a/plugins/grepview/grepoutputview.cpp b/plugins/grepview/grepoutputview.cpp --- a/plugins/grepview/grepoutputview.cpp +++ b/plugins/grepview/grepoutputview.cpp @@ -149,6 +149,7 @@ settings.exclude = s.takeFirst(); settings.searchPaths = s.takeFirst(); + settings.fromHistory = true; m_settingsHistory << settings; } @@ -220,12 +221,8 @@ connect(m_plugin, &GrepViewPlugin::grepJobFinished, this, &GrepOutputView::updateScrollArea); // appends new model to history - const QString displayName = i18n("Search \"%1\" in %2 (at time %3)", - settings.pattern, description, - QTime::currentTime().toString(QStringLiteral("hh:mm"))); - modelSelector->insertItem(0, displayName, qVariantFromValue(newModel)); - - modelSelector->setCurrentIndex(0);//setCurrentItem(displayName); + modelSelector->insertItem(0, description, qVariantFromValue(newModel)); + modelSelector->setCurrentIndex(0); m_settingsHistory.append(settings); @@ -338,6 +335,7 @@ QList refresh_history({ m_settingsHistory.takeAt(m_settingsHistory.count() - 1 - index) }); + refresh_history.first().fromHistory = false; GrepDialog* dlg = new GrepDialog(m_plugin, this, false); dlg->historySearch(refresh_history);