summaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols/controls/tableview/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-07-10 21:21:17 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-15 14:21:25 +0200
commit874f8ef3b9fb9d80a2b05c264ca48464e31257e2 (patch)
tree2a1213104b290a196e71f57e928befc38a20c992 /examples/quickcontrols/controls/tableview/src
parent0a8d24180e11a093656a8efe31370a591115a96f (diff)
Eradicate Java-style iterators and Q_FOREACH and mark the module free of them
... and QLinkedList. Java-style iterators are scheduled to be deprecated, or at the very least banned from use in Qt's own implementation. Ditto Q_FOREACH. Ditto QLinkedList. Change-Id: I92eb5c22762b63cba45f8eaf717c1b7d458fcda4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/quickcontrols/controls/tableview/src')
-rw-r--r--examples/quickcontrols/controls/tableview/src/sortfilterproxymodel.cpp18
1 files changed, 3 insertions, 15 deletions
diff --git a/examples/quickcontrols/controls/tableview/src/sortfilterproxymodel.cpp b/examples/quickcontrols/controls/tableview/src/sortfilterproxymodel.cpp
index b93641a90..1e47f23e5 100644
--- a/examples/quickcontrols/controls/tableview/src/sortfilterproxymodel.cpp
+++ b/examples/quickcontrols/controls/tableview/src/sortfilterproxymodel.cpp
@@ -132,11 +132,8 @@ QJSValue SortFilterProxyModel::get(int idx) const
QJSValue value = engine->newObject();
if (idx >= 0 && idx < count()) {
QHash<int, QByteArray> roles = roleNames();
- QHashIterator<int, QByteArray> it(roles);
- while (it.hasNext()) {
- it.next();
+ for (auto it = roles.cbegin(), end = roles.cend(); it != end; ++it)
value.setProperty(QString::fromUtf8(it.value()), data(index(idx, 0), it.key()).toString());
- }
}
return value;
}
@@ -156,14 +153,7 @@ void SortFilterProxyModel::componentComplete()
int SortFilterProxyModel::roleKey(const QByteArray &role) const
{
- QHash<int, QByteArray> roles = roleNames();
- QHashIterator<int, QByteArray> it(roles);
- while (it.hasNext()) {
- it.next();
- if (it.value() == role)
- return it.key();
- }
- return -1;
+ return roleNames().key(role, -1);
}
QHash<int, QByteArray> SortFilterProxyModel::roleNames() const
@@ -181,9 +171,7 @@ bool SortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &so
QAbstractItemModel *model = sourceModel();
if (filterRole().isEmpty()) {
QHash<int, QByteArray> roles = roleNames();
- QHashIterator<int, QByteArray> it(roles);
- while (it.hasNext()) {
- it.next();
+ for (auto it = roles.cbegin(), end = roles.cend(); it != end; ++it) {
QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent);
QString key = model->data(sourceIndex, it.key()).toString();
if (key.contains(rx))