| 66 | } |
| 67 | |
| 68 | void DiffWidgetManager::openDiff(const QByteArray &diff, DiffParams p, class KTextEditor::MainWindow *mw) |
| 69 | { |
| 70 | DiffWidget *existing = existingDiffWidgetForParams(mw, p); |
| 71 | if (!existing) { |
| 72 | existing = new DiffWidget(p); |
| 73 | mw->connect(existing, &DiffWidget::openFileRequested, mw, [mw](QString path, int line, int columnNumber) { |
| 74 | auto view = mw->openUrl(QUrl(path)); |
| 75 | view->setCursorPosition(KTextEditor::Cursor(line - 1, columnNumber)); |
| 76 | }); |
| 77 | if (!p.tabTitle.isEmpty()) { |
| 78 | existing->setWindowTitle(p.tabTitle); |
| 79 | } else { |
| 80 | if (p.destFile.isEmpty()) |
| 81 | existing->setWindowTitle(i18n("Diff %1", Utils::fileNameFromPath(p.srcFile))); |
| 82 | else |
| 83 | existing->setWindowTitle(i18n("Diff %1..%2", Utils::fileNameFromPath(p.srcFile), Utils::fileNameFromPath(p.destFile))); |
| 84 | } |
| 85 | existing->setWindowIcon(QIcon::fromTheme(QStringLiteral("text-x-patch"))); |
| 86 | existing->openDiff(diff); |
| 87 | mw->addWidget(existing); |
| 88 | } else { |
| 89 | existing->clearData(); |
| 90 | existing->m_params = p; |
| 91 | existing->openDiff(diff); |
| 92 | mw->activateWidget(existing); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | void DiffWidgetManager::diffDocs(KTextEditor::Document *l, KTextEditor::Document *r, class KTextEditor::MainWindow *mw) |
| 97 | { |