QCalendar: eradicate Java-style iterator

We had QT_NO_JAVA_STYLE_ITERATORS in .qmake.conf, but it was lost in
the transition from QMake to CMake, and - plop - they start trickling
in again.

Pick-to: 6.3 6.2
Change-Id: Ib92937e5fe510aba2aad92809f7a6d5fbae6f3a0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Marc Mutz 2022-01-28 01:26:40 +01:00
parent 096e8b5f65
commit 55a88206f3

View File

@ -449,10 +449,15 @@ const QCalendarBackend *QCalendarRegistry::fromEnum(QCalendar::System system)
QStringList QCalendarRegistry::backendNames(const QCalendarBackend *backend)
{
QStringList l;
l.reserve(byName.size()); // too large, but never really large, so ok
QHashIterator<CalendarName, QCalendarBackend *> i(byName);
while (i.findNext(const_cast<QCalendarBackend *>(backend)))
l.push_back(i.key());
// same as byName.keys(backend), except for
// - the missing const on mapped_type and
// - CalendarName != QString as the key_type
for (auto it = byName.cbegin(), end = byName.cend(); it != end; ++it) {
if (it.value() == backend)
l.push_back(it.key());
}
return l;
}