MCPcopy Create free account
hub / github.com/KDE/kdevelop / diffReady

Method diffReady

plugins/git/diffviewsctrl.cpp:289–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287
288
289void DiffViewsCtrl::diffReady(KDevelop::VcsJob* diffJob)
290{
291 if (diffJob->status() == VcsJob::JobSucceeded) {
292 // Fetch the job results
293 auto diff = diffJob->fetchResults().value<VcsDiff>();
294 auto key = diffJob->property("key").toString();
295 auto p = (UpdateDiffParams)diffJob->property("activate").toInt();
296
297 ViewData vData;
298 auto vDataIt = m_views.find(key);
299
300 // If the diff is empty, close the view if present
301 // and return
302 if (diff.isEmpty()) {
303 if (vDataIt != m_views.end() && vDataIt->second.doc)
304 vDataIt->second.doc->close();
305 return;
306 }
307
308 if (vDataIt != m_views.end()) {
309 vData = vDataIt->second;
310 } else {
311 vData = createView(diffJob->property("url").toUrl(),
312 (RepoStatusModel::Areas)diffJob->property("area").toInt());
313 if (! vData.isValid())
314 return;
315 }
316
317 auto position = vData.ktDoc->views().constFirst()->cursorPosition(); // assume there is only one view
318 vData.ktDoc->setReadWrite(true);
319 vData.ktDoc->setText(diff.diff());
320 vData.ktDoc->setReadWrite(false);
321 vData.ktDoc->setModified(false);
322 vData.ktDoc->views().constFirst()->setCursorPosition(position); // assume there is only one view
323 vData.ktDoc->setMode(QStringLiteral("diff"));
324 vData.ktDoc->setHighlightingMode(QStringLiteral("diff"));
325
326 // Activate the diff document, if required
327 if (p == Activate) {
328 auto* docCtrl = ICore::self()->documentController();
329 docCtrl->activateDocument(vData.doc);
330 }
331 }
332}
333
334void DiffViewsCtrl::revertSelected()
335{

Callers

nothing calls this directly

Calls 15

propertyMethod · 0.80
toIntMethod · 0.80
documentControllerMethod · 0.80
activateDocumentMethod · 0.80
statusMethod · 0.45
fetchResultsMethod · 0.45
toStringMethod · 0.45
findMethod · 0.45
isEmptyMethod · 0.45
endMethod · 0.45
closeMethod · 0.45
toUrlMethod · 0.45

Tested by

no test coverage detected