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

Method suppressSelectedIds

gui/resultstree.cpp:970–1002  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

968}
969
970void ResultsTree::suppressSelectedIds()
971{
972 if (!mSelectionModel)
973 return;
974
975 QSet<QString> selectedIds;
976 for (const QModelIndex& index : mSelectionModel->selectedRows()) {
977 const auto *item = dynamic_cast<ResultItem*>(mModel->itemFromIndex(index));
978 if (!item || item->getType() == ResultItem::Type::file || !item->errorItem)
979 continue;
980 selectedIds << item->errorItem->errorId;
981 }
982
983 // delete all errors with selected message Ids
984 for (int i = 0; i < mModel->rowCount(); i++) {
985 QStandardItem * const file = mModel->item(i, 0);
986 for (int j = 0; j < file->rowCount();) {
987 const auto *errorItem = dynamic_cast<ResultItem*>(file->child(j, 0));
988 if (errorItem && errorItem->errorItem && selectedIds.contains(errorItem->errorItem->errorId)) {
989 file->removeRow(j);
990 } else {
991 j++;
992 }
993 }
994 if (file->rowCount() == 0)
995 mModel->removeRow(file->row());
996 }
997
998 if (!selectedIds.isEmpty()) {
999 refreshTree(); // If all visible warnings was suppressed then the file item should be hidden
1000 emit suppressIds(selectedIds.values());
1001 }
1002}
1003
1004void ResultsTree::suppressHash()
1005{

Callers

nothing calls this directly

Calls 4

rowCountMethod · 0.80
isEmptyMethod · 0.80
getTypeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected