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

Method refreshTree

gui/resultstree.cpp:514–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512
513
514void ResultsTree::refreshTree()
515{
516 mVisibleErrors = false;
517 //Get the amount of files in the tree
518 const int filecount = mModel->rowCount();
519
520 for (int i = 0; i < filecount; i++) {
521 //Get file i
522 auto *fileItem = dynamic_cast<ResultItem*>(mModel->item(i, 0));
523 if (!fileItem) {
524 continue;
525 }
526
527 //Get the amount of errors this file contains
528 const int errorcount = fileItem->rowCount();
529
530 //By default it shouldn't be visible
531 bool showFile = false;
532
533 for (int j = 0; j < errorcount; j++) {
534 //Get the error itself
535 const auto *child = dynamic_cast<ResultItem*>(fileItem->child(j, 0));
536 if (!child) {
537 continue;
538 }
539
540 //Check if this error should be hidden
541 const bool hide = child->hidden || isErrorItemHidden(child->errorItem);
542
543 if (!hide) {
544 showFile = true;
545 mVisibleErrors = true;
546 }
547
548 //Hide/show accordingly
549 setRowHidden(j, fileItem->index(), hide);
550 }
551
552 // Show the file if any of it's errors are visible
553 setRowHidden(i, QModelIndex(), !showFile);
554 }
555 sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
556}
557
558bool ResultsTree::isErrorItemHidden(const QSharedPointer<ErrorItem>& errorItem) const {
559 //Check if this error should be hidden

Callers 1

checkingFinishedMethod · 0.80

Calls 2

rowCountMethod · 0.80
QModelIndexClass · 0.70

Tested by

no test coverage detected