MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / ensureFileItem

Method ensureFileItem

gui/resultstree.cpp:584–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582}
583
584ResultItem *ResultsTree::ensureFileItem(const QSharedPointer<ErrorItem>& errorItem, bool hide)
585{
586 QString name = QDir::toNativeSeparators(stripPath(errorItem->getFile(), false));
587 // Since item has path with native separators we must use path with
588 // native separators to find it.
589 ResultItem *fileItem = findFileItem(name);
590
591 if (fileItem) {
592 if (!hide)
593 setRowHidden(fileItem->row(), QModelIndex(), hide);
594 return fileItem;
595 }
596
597 // Ensure shown path is with native separators
598 fileItem = createFilenameItem(errorItem, ResultItem::Type::file, errorItem->getMainLocIndex());
599 fileItem->setIcon(QIcon(":images/text-x-generic.png"));
600
601 mModel->appendRow(fileItem);
602
603 setRowHidden(fileItem->row(), QModelIndex(), hide);
604
605 return fileItem;
606}
607
608void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
609{

Callers

nothing calls this directly

Calls 3

getMainLocIndexMethod · 0.80
QModelIndexClass · 0.70
getFileMethod · 0.45

Tested by

no test coverage detected