chore: clazy fixes

- detaching container while iterating
- mixing const and non-const iterators
This commit is contained in:
Lukáš Tinkl 2023-07-13 13:59:35 +02:00
parent 6a471f1bef
commit 0ea2220f62
No known key found for this signature in database
GPG Key ID: 4ABB993B9382F296
1 changed files with 8 additions and 7 deletions

View File

@ -208,11 +208,11 @@ void QQmlSortFilterProxyModel::componentComplete()
{
m_completed = true;
for (const auto& filter : m_filters)
for (const auto& filter : qAsConst(m_filters))
filter->proxyModelCompleted(*this);
for (const auto& sorter : m_sorters)
for (const auto& sorter : qAsConst(m_sorters))
sorter->proxyModelCompleted(*this);
for (const auto& proxyRole : m_proxyRoles)
for (const auto& proxyRole : qAsConst(m_proxyRoles))
proxyRole->proxyModelCompleted(*this);
invalidate();
@ -266,7 +266,7 @@ QVariantMap QQmlSortFilterProxyModel::get(int row) const
QVariantMap map;
QModelIndex modelIndex = index(row, 0);
QHash<int, QByteArray> roles = roleNames();
for (QHash<int, QByteArray>::const_iterator it = roles.begin(); it != roles.end(); ++it)
for (auto it = roles.cbegin(); it != roles.cend(); ++it)
map.insert(it.value(), data(modelIndex, it.key()));
return map;
}
@ -436,8 +436,9 @@ void QQmlSortFilterProxyModel::updateRoleNames()
auto roles = m_roleNames.keys();
auto maxIt = std::max_element(roles.cbegin(), roles.cend());
int maxRole = maxIt != roles.cend() ? *maxIt : -1;
for (auto proxyRole : m_proxyRoles) {
for (auto roleName : proxyRole->names()) {
for (auto proxyRole : qAsConst(m_proxyRoles)) {
const auto proxyRoleNames = proxyRole->names();
for (const auto &roleName : proxyRoleNames) {
++maxRole;
m_roleNames[maxRole] = roleName.toUtf8();
m_proxyRoleMap[maxRole] = {proxyRole, roleName};
@ -509,7 +510,7 @@ QVariantMap QQmlSortFilterProxyModel::modelDataMap(const QModelIndex& modelIndex
{
QVariantMap map;
QHash<int, QByteArray> roles = roleNames();
for (QHash<int, QByteArray>::const_iterator it = roles.begin(); it != roles.end(); ++it)
for (auto it = roles.cbegin(); it != roles.cend(); ++it)
map.insert(it.value(), sourceModel()->data(modelIndex, it.key()));
return map;
}