Changeset View
Changeset View
Standalone View
Standalone View
plugins/grepview/grepdialog.cpp
Show First 20 Lines • Show All 474 Lines • ▼ Show 20 Line(s) | 474 | { | |||
---|---|---|---|---|---|
475 | close(); | 475 | close(); | ||
476 | return; | 476 | return; | ||
477 | } | 477 | } | ||
478 | 478 | | |||
479 | const QString descriptionOrUrl(m_settings.searchPaths); | 479 | const QString descriptionOrUrl(m_settings.searchPaths); | ||
480 | QList<QUrl> choice = getDirectoryChoice(descriptionOrUrl); | 480 | QList<QUrl> choice = getDirectoryChoice(descriptionOrUrl); | ||
481 | QString description = descriptionOrUrl; | 481 | QString description = descriptionOrUrl; | ||
482 | 482 | | |||
483 | GrepJob* job = m_plugin->newGrepJob(); | | |||
484 | // Shorten the description | 483 | // Shorten the description | ||
485 | if(descriptionOrUrl != allOpenFilesString() && descriptionOrUrl != allOpenProjectsString()) { | 484 | if(descriptionOrUrl != allOpenFilesString() && descriptionOrUrl != allOpenProjectsString()) { | ||
486 | auto prettyFileName = [](const QUrl& url) { | 485 | auto prettyFileName = [](const QUrl& url) { | ||
487 | return ICore::self()->projectController()->prettyFileName(url, KDevelop::IProjectController::FormatPlain); | 486 | return ICore::self()->projectController()->prettyFileName(url, KDevelop::IProjectController::FormatPlain); | ||
488 | }; | 487 | }; | ||
489 | 488 | | |||
490 | if (choice.size() > 1) { | 489 | if (choice.size() > 1) { | ||
491 | description = i18np("%2, and %1 more item", "%2, and %1 more items", choice.size() - 1, prettyFileName(choice[0])); | 490 | description = i18np("%2, and %1 more item", "%2, and %1 more items", choice.size() - 1, prettyFileName(choice[0])); | ||
492 | } else if (!choice.isEmpty()) { | 491 | } else if (!choice.isEmpty()) { | ||
493 | description = prettyFileName(choice[0]); | 492 | description = prettyFileName(choice[0]); | ||
494 | } | 493 | } | ||
495 | } | 494 | } | ||
496 | 495 | | |||
497 | GrepOutputView *toolView = (GrepOutputView*)ICore::self()->uiController()-> | 496 | GrepOutputView *toolView = | ||
498 | findToolView(i18n("Find/Replace in Files"), m_plugin->toolViewFactory(), IUiController::CreateAndRaise); | 497 | (GrepOutputView*)ICore::self()->uiController()->findToolView( | ||
499 | GrepOutputModel* outputModel = toolView->renewModel(m_settings, description); | 498 | i18n("Find/Replace in Files"), m_plugin->toolViewFactory(), | ||
499 | m_settings.fromHistory ? IUiController::Create : IUiController::CreateAndRaise); | ||||
500 | | ||||
501 | if (m_settings.fromHistory) { | ||||
502 | // when restored from history, only display the parameters | ||||
503 | toolView->renewModel(m_settings, i18n("Search \"%1\" in %2", m_settings.pattern, description)); | ||||
504 | emit m_plugin->grepJobFinished(true); | ||||
505 | } else { | ||||
506 | GrepOutputModel* outputModel = | ||||
507 | toolView->renewModel(m_settings, | ||||
508 | i18n("Search \"%1\" in %2 (at time %3)", m_settings.pattern, description, | ||||
509 | QTime::currentTime().toString(QStringLiteral("hh:mm")))); | ||||
500 | 510 | | |||
511 | GrepJob* job = m_plugin->newGrepJob(); | ||||
501 | connect(job, &GrepJob::showErrorMessage, | 512 | connect(job, &GrepJob::showErrorMessage, | ||
502 | toolView, &GrepOutputView::showErrorMessage); | 513 | toolView, &GrepOutputView::showErrorMessage); | ||
503 | //the GrepOutputModel gets the 'showMessage' signal to store it and forward | 514 | //the GrepOutputModel gets the 'showMessage' signal to store it and forward | ||
504 | //it to toolView | 515 | //it to toolView | ||
505 | connect(job, &GrepJob::showMessage, | 516 | connect(job, &GrepJob::showMessage, | ||
506 | outputModel, &GrepOutputModel::showMessageSlot); | 517 | outputModel, &GrepOutputModel::showMessageSlot); | ||
507 | connect(outputModel, &GrepOutputModel::showMessage, | 518 | connect(outputModel, &GrepOutputModel::showMessage, | ||
508 | toolView, &GrepOutputView::showMessage); | 519 | toolView, &GrepOutputView::showMessage); | ||
509 | 520 | | |||
510 | connect(toolView, &GrepOutputView::outputViewIsClosed, job, [=]() {job->kill();}); | 521 | connect(toolView, &GrepOutputView::outputViewIsClosed, job, [=]() {job->kill();}); | ||
511 | 522 | | |||
512 | job->setOutputModel(outputModel); | 523 | job->setOutputModel(outputModel); | ||
513 | job->setDirectoryChoice(choice); | 524 | job->setDirectoryChoice(choice); | ||
514 | 525 | | |||
515 | job->setSettings(m_settings); | 526 | job->setSettings(m_settings); | ||
516 | 527 | | |||
517 | ICore::self()->runController()->registerJob(job); | 528 | ICore::self()->runController()->registerJob(job); | ||
529 | } | ||||
518 | 530 | | |||
519 | m_plugin->rememberSearchDirectory(descriptionOrUrl); | 531 | m_plugin->rememberSearchDirectory(descriptionOrUrl); | ||
520 | 532 | | |||
521 | // if m_show is false, the dialog is closed somewhere else | 533 | // if m_show is false, the dialog is closed somewhere else | ||
522 | if (m_show) | 534 | if (m_show) | ||
523 | close(); | 535 | close(); | ||
524 | } | 536 | } | ||
525 | 537 | | |||
Show All 19 Lines |