| 78 | } |
| 79 | |
| 80 | void ProblemCollector::clearScans() |
| 81 | { |
| 82 | // Remove all elements which originate from a previous scan, before doing a new scan |
| 83 | // and do so, properly informing the model about all changes. |
| 84 | auto firstToDeleteIt = m_problems.begin(); |
| 85 | auto it = firstToDeleteIt; |
| 86 | while (true) { |
| 87 | if (it != m_problems.end() && it->findingCategory == Problem::Scan) { |
| 88 | ++it; |
| 89 | } else if (firstToDeleteIt != it) { // this is supposed to be called also if `it == m_problems.end()` |
| 90 | auto firstRow = std::distance(m_problems.begin(), firstToDeleteIt); |
| 91 | auto count = std::distance(m_problems.begin(), it) - firstRow; |
| 92 | emit aboutToRemoveProblems(firstRow, count); |
| 93 | firstToDeleteIt = it = m_problems.erase(firstToDeleteIt, it); |
| 94 | emit problemsRemoved(); |
| 95 | } else if (it != m_problems.end()) { |
| 96 | ++it; |
| 97 | ++firstToDeleteIt; |
| 98 | } else { |
| 99 | break; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | const QVector<Problem> &ProblemCollector::problems() |
| 105 | { |