summaryrefslogtreecommitdiff
path: root/examples
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
parent0a8d24180e11a093656a8efe31370a591115a96f (diff)
downloadqtquickcontrols-874f8ef3b9fb9d80a2b05c264ca48464e31257e2.tar.gz
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')
-rw-r--r--examples/quickcontrols/controls/tableview/src/sortfilterproxymodel.cpp18
-rw-r--r--examples/quickcontrols/controls/texteditor/src/documenthandler.cpp3
2 files changed, 5 insertions, 16 deletions
diff --git a/examples/quickcontrols/controls/tableview/src/sortfilterproxymodel.cpp b/examples/quickcontrols/controls/tableview/src/sortfilterproxymodel.cpp
index b93641a9..1e47f23e 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))
diff --git a/examples/quickcontrols/controls/texteditor/src/documenthandler.cpp b/examples/quickcontrols/controls/texteditor/src/documenthandler.cpp
index 69da88f0..ac9f5bd4 100644
--- a/examples/quickcontrols/controls/texteditor/src/documenthandler.cpp
+++ b/examples/quickcontrols/controls/texteditor/src/documenthandler.cpp
@@ -345,7 +345,8 @@ QStringList DocumentHandler::defaultFontSizes() const
// uhm... this is quite ugly
QStringList sizes;
QFontDatabase db;
- foreach (int size, db.standardSizes())
+ const auto standardSizes = db.standardSizes();
+ for (int size : standardSizes)
sizes.append(QString::number(size));
return sizes;
}