| 297 | } |
| 298 | |
| 299 | void 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 | |
| 346 | void TestView::addTestSuite(ITestSuite* suite) |
| 347 | { |
nothing calls this directly
no test coverage detected