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

Method showSource

plugins/testview/testview.cpp:299–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299void TestView::showSource()
300{
301 QModelIndexList indexes = m_tree->selectionModel()->selectedIndexes();
302 if (indexes.isEmpty())
303 {
304 return;
305 }
306
307 IndexedDeclaration declaration;
308 ITestController* tc = ICore::self()->testController();
309
310 QModelIndex index = m_filter->mapToSource(indexes.first());
311 QStandardItem* item = m_model->itemFromIndex(index);
312 if (item->parent() == nullptr)
313 {
314 // No sense in finding source code for projects.
315 return;
316 }
317 else if (item->parent()->parent() == nullptr)
318 {
319 IProject* project = ICore::self()->projectController()->findProjectByName(item->parent()->data(ProjectRole).toString());
320 ITestSuite* suite = tc->findTestSuite(project, item->data(SuiteRole).toString());
321 declaration = suite->declaration();
322 }
323 else
324 {
325 IProject* project = ICore::self()->projectController()->findProjectByName(item->parent()->parent()->data(ProjectRole).toString());
326 ITestSuite* suite = tc->findTestSuite(project, item->parent()->data(SuiteRole).toString());
327 declaration = suite->caseDeclaration(item->data(CaseRole).toString());
328 }
329
330 DUChainReadLocker locker;
331 Declaration* d = declaration.data();
332 if (!d)
333 {
334 return;
335 }
336
337 QUrl url = d->url().toUrl();
338 KTextEditor::Cursor cursor = d->rangeInCurrentRevision().start();
339 locker.unlock();
340
341 IDocumentController* dc = ICore::self()->documentController();
342 qCDebug(PLUGIN_TESTVIEW) << "Activating declaration in" << url;
343 dc->openDocument(url, cursor);
344}
345
346void TestView::addTestSuite(ITestSuite* suite)
347{

Callers

nothing calls this directly

Calls 15

testControllerMethod · 0.80
findProjectByNameMethod · 0.80
projectControllerMethod · 0.80
findTestSuiteMethod · 0.80
documentControllerMethod · 0.80
isEmptyMethod · 0.45
mapToSourceMethod · 0.45
firstMethod · 0.45
itemFromIndexMethod · 0.45
parentMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected