examples: port away from Java-style iterators
There's no reason to use them here, the Mutable is misleading in a few instances, ranged-for is much simpler, and more future-proof. Change-Id: Ifd5eaae95bbaa0b4cf0f435e6cfee6d778817b44 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
923e08132c
commit
b4a88aa758
@ -247,12 +247,8 @@ void GLWidget::createBubbles(int number)
|
|||||||
//! [13]
|
//! [13]
|
||||||
void GLWidget::animate()
|
void GLWidget::animate()
|
||||||
{
|
{
|
||||||
QMutableListIterator<Bubble*> iter(bubbles);
|
for (Bubble *bubble : qAsConst(bubbles))
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Bubble *bubble = iter.next();
|
|
||||||
bubble->move(rect());
|
bubble->move(rect());
|
||||||
}
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
//! [13]
|
//! [13]
|
||||||
|
@ -399,12 +399,9 @@ void GLWidget::paintGL()
|
|||||||
|
|
||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
QMutableListIterator<Bubble*> iter(m_bubbles);
|
for (Bubble *bubble : qAsConst(m_bubbles))
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Bubble *bubble = iter.next();
|
|
||||||
bubble->move(rect());
|
bubble->move(rect());
|
||||||
}
|
|
||||||
if (!(m_frames % 100)) {
|
if (!(m_frames % 100)) {
|
||||||
m_time.start();
|
m_time.start();
|
||||||
m_frames = 0;
|
m_frames = 0;
|
||||||
|
@ -126,11 +126,8 @@ WordCount countWords(const QString &file)
|
|||||||
// at a time.
|
// at a time.
|
||||||
void reduce(WordCount &result, const WordCount &w)
|
void reduce(WordCount &result, const WordCount &w)
|
||||||
{
|
{
|
||||||
QMapIterator<QString, int> i(w);
|
for (auto i = w.begin(), end = w.end(); i != end; ++i)
|
||||||
while (i.hasNext()) {
|
|
||||||
i.next();
|
|
||||||
result[i.key()] += i.value();
|
result[i.key()] += i.value();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
@ -163,11 +163,8 @@ QStringList LanguageChooser::findQmFiles()
|
|||||||
QDir dir(":/translations");
|
QDir dir(":/translations");
|
||||||
QStringList fileNames = dir.entryList(QStringList("*.qm"), QDir::Files,
|
QStringList fileNames = dir.entryList(QStringList("*.qm"), QDir::Files,
|
||||||
QDir::Name);
|
QDir::Name);
|
||||||
QMutableStringListIterator i(fileNames);
|
for (QString &fileName : fileNames)
|
||||||
while (i.hasNext()) {
|
fileName = dir.filePath(fileName);
|
||||||
i.next();
|
|
||||||
i.setValue(dir.filePath(i.value()));
|
|
||||||
}
|
|
||||||
return fileNames;
|
return fileNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user