Use std::accumulate instead of manually adding
This commit is contained in:
parent
e89f157bac
commit
c065b04cbe
1 changed files with 5 additions and 11 deletions
|
@ -174,7 +174,7 @@ void CheckableTestModel::printTableTo(QTextCursor &cursor) const
|
||||||
charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
|
charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
|
||||||
charFormat.setFontPointSize(8);
|
charFormat.setFontPointSize(8);
|
||||||
textCursor.setCharFormat(charFormat);
|
textCursor.setCharFormat(charFormat);
|
||||||
|
|
||||||
textCursor.insertText(text);
|
textCursor.insertText(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ void CheckableTestModel::printTableTo(QTextCursor &cursor) const
|
||||||
currentRow += 2;
|
currentRow += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckableTestModel::printSummaryTo(QTextCursor &cursor) const
|
void CheckableTestModel::printSummaryTo(QTextCursor &cursor) const
|
||||||
{
|
{
|
||||||
QTextTableFormat tableFormat;
|
QTextTableFormat tableFormat;
|
||||||
|
@ -231,7 +231,7 @@ void CheckableTestModel::printSummaryTo(QTextCursor &cursor) const
|
||||||
charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
|
charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
|
||||||
charFormat.setFontPointSize(8);
|
charFormat.setFontPointSize(8);
|
||||||
textCursor.setCharFormat(charFormat);
|
textCursor.setCharFormat(charFormat);
|
||||||
|
|
||||||
textCursor.insertText(text);
|
textCursor.insertText(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -283,12 +283,6 @@ const CheckableItem &CheckableTestModel::getItem(const QModelIndex &index) const
|
||||||
|
|
||||||
unsigned int CheckableTestModel::getPoints() const
|
unsigned int CheckableTestModel::getPoints() const
|
||||||
{
|
{
|
||||||
unsigned int points = 0;
|
return std::accumulate(std::begin(m_tests), std::end(m_tests), 0,
|
||||||
|
[](int base, const CheckableTest &test) { return base + test.getPoints(); });
|
||||||
for (const auto &test : m_tests)
|
|
||||||
{
|
|
||||||
points += test.getPoints();
|
|
||||||
}
|
|
||||||
|
|
||||||
return points;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue