Commit ef4aa7c3 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Port away from foreach and Q_FOREACH

parent 7a79eaa7
......@@ -37,14 +37,14 @@ void Collection::numDueWords(WordCount &wc)
{
// Get the entries from the collection. Cache them for future use.
if (m_allTestEntries.isEmpty()) {
EntryFilter filter(m_doc, this);
m_allTestEntries = filter.entries(false);
EntryFilter filter(m_doc, this);
m_allTestEntries = filter.entries(false);
}
// Count the number of words due for each grade level.
foreach (const TestEntry *entry, m_allTestEntries) {
int languageTo = entry->languageTo();
KEduVocExpression *exp = entry->entry();
for (const TestEntry *entry : qAsConst(m_allTestEntries)) {
int languageTo = entry->languageTo();
KEduVocExpression *exp = entry->entry();
int grade = exp->translation(languageTo)->grade();
int pregrade = exp->translation(languageTo)->preGrade();
......
......@@ -212,14 +212,14 @@ QMimeData * ContainerModel::mimeData(const QModelIndexList &indexes) const
ContainerMimeData *mimeData = new ContainerMimeData();
// QByteArray encodedData;
foreach(const QModelIndex & index, indexes) {
for (const QModelIndex & index : indexes) {
mimeData->addContainer(static_cast<KEduVocContainer*>(index.internalPointer()));
}
mimeData->setText(QStringLiteral("Parley lesson"));
// QDataStream stream(&encodedData, QIODevice::WriteOnly);
// stream << "Parley lesson";
// foreach (const QModelIndex &index, indexes) {
// for (const QModelIndex &index : qAsConst(indexes)) {
// if (index.isValid()) {
// QString text = data(index, Qt::DisplayRole).toString();
// stream << text;
......@@ -244,7 +244,8 @@ bool ContainerModel::dropMimeData(const QMimeData * data, Qt::DropAction action,
qobject_cast<const ContainerMimeData *>(data);
if (containerData) {
foreach(KEduVocContainer * container, containerData->containerList()) {
const QList<KEduVocContainer*> containerList = containerData->containerList();
for (KEduVocContainer * container : containerList) {
// no way to move a word type to a lesson for now
if (container->containerType() != m_type) {
return false;
......@@ -308,19 +309,21 @@ bool ContainerModel::dropMimeData(const QMimeData * data, Qt::DropAction action,
// Create a list of the entries associated with the translations being copied. This prevents duplicates if they highlighted several columns.
QList<KEduVocExpression*> entries;
foreach(KEduVocTranslation * translation, translationData->translationList()) {
const QList<KEduVocTranslation*> translationList = translationData->translationList();
for (const auto & translation : translationList) {
if (!entries.contains(translation->entry())) {
entries << translation->entry();
}
}
foreach(KEduVocExpression * entry, entries) {
for (KEduVocExpression * entry : qAsConst(entries)) {
static_cast<KEduVocLesson*>(parent.internalPointer())->appendEntry(new KEduVocExpression(*entry));
}
}
if (containerType() == KEduVocContainer::WordType) {
foreach(KEduVocTranslation * translation, translationData->translationList()) {
const QList<KEduVocTranslation*> translationList = translationData->translationList();
for (const auto & translation : translationList) {
translation->setWordType(
static_cast<KEduVocWordType*>(parent.internalPointer()));
}
......
......@@ -176,7 +176,7 @@ QList<TestEntry*> EntryFilter::entries(bool showDialog)
to = Prefs::knownLanguage();
}
foreach(KEduVocExpression * entry, m_currentSelection[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_currentSelection[setNo])) {
// Set the from and to translation for the entry itself.
TestEntry *testEntry = new TestEntry(entry);
......@@ -195,7 +195,7 @@ void EntryFilter::expireEntries(int setNo)
{
if (Prefs::expire()) {
int counter = 0;
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
int grade = entry->translation(m_toTranslation)->grade();
const QDateTime &date = entry->translation(m_toTranslation)->practiceDate();
......@@ -249,7 +249,7 @@ void EntryFilter::setupFilteredEntries(int setNo)
void EntryFilter::lessonEntries(int setNo)
{
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
if (entry->lesson()->inPractice()) {
m_entriesLesson[setNo].insert(entry);
}
......@@ -259,7 +259,7 @@ void EntryFilter::lessonEntries(int setNo)
void EntryFilter::wordTypeEntries(int setNo)
{
if (Prefs::wordTypesInPracticeEnabled()) {
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
if (entry->translation(m_toTranslation)->wordType()) {
if (entry->translation(m_toTranslation)->wordType()->inPractice()) {
m_entriesWordType[setNo].insert(entry);
......@@ -280,14 +280,14 @@ void EntryFilter::blockedEntries(int setNo)
switch (Prefs::practiceMode()) {
case Prefs::EnumPracticeMode::ConjugationPractice:
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
if (!isConjugationBlocked(entry->translation(m_toTranslation))) {
m_entriesNotBlocked[setNo].insert(entry);
}
}
break;
case Prefs::EnumPracticeMode::GenderPractice:
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
KEduVocText article = entry->translation(m_toTranslation)->article();
if (!isBlocked(&article)) {
m_entriesNotBlocked[setNo].insert(entry);
......@@ -295,7 +295,7 @@ void EntryFilter::blockedEntries(int setNo)
}
break;
case Prefs::EnumPracticeMode::ComparisonPractice:
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
KEduVocTranslation* translation = entry->translation(m_toTranslation);
KEduVocText comparative = translation->comparativeForm();
KEduVocText superlative = translation->superlativeForm();
......@@ -306,7 +306,7 @@ void EntryFilter::blockedEntries(int setNo)
}
break;
default:
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
if (!isBlocked(entry->translation(m_toTranslation))) {
m_entriesNotBlocked[setNo].insert(entry);
//debugEntry("Not blocked:", entry,
......@@ -325,10 +325,11 @@ void EntryFilter::blockedEntries(int setNo)
bool EntryFilter::isConjugationBlocked(KEduVocTranslation* translation) const
{
foreach(const QString & tense, translation->conjugationTenses()) {
const QStringList conjugationTenses = translation->conjugationTenses();
for (const QString & tense : conjugationTenses) {
if (m_tenses.contains(tense)) {
QList<KEduVocWordFlags> pronouns = translation->getConjugation(tense).keys();
foreach(const KEduVocWordFlags & pronoun, pronouns) {
const QList<KEduVocWordFlags> pronouns = translation->getConjugation(tense).keys();
for (const KEduVocWordFlags & pronoun : pronouns) {
KEduVocText grade = translation->getConjugation(tense).conjugation(pronoun);
if (!isBlocked(&(grade))) {
// just need to find any form that is not blocked for generating test entries
......@@ -392,7 +393,7 @@ bool EntryFilter::isBlocked(const KEduVocText* const text) const
void EntryFilter::timesWrongEntries(int setNo)
{
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
if (entry->translation(m_toTranslation)->badCount() >= Prefs::practiceMinimumWrongCount() && entry->translation(m_toTranslation)->badCount() <= Prefs::practiceMaximumWrongCount()) {
m_entriesTimesWrong[setNo].insert(entry);
}
......@@ -401,7 +402,7 @@ void EntryFilter::timesWrongEntries(int setNo)
void EntryFilter::timesPracticedEntries(int setNo)
{
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
if (entry->translation(m_toTranslation)->practiceCount() >= Prefs::practiceMinimumTimesAsked() && entry->translation(m_toTranslation)->practiceCount() <= Prefs::practiceMaximumTimesAsked()) {
m_entriesTimesPracticed[setNo].insert(entry);
}
......@@ -410,7 +411,7 @@ void EntryFilter::timesPracticedEntries(int setNo)
void EntryFilter::minMaxGradeEntries(int setNo)
{
foreach(KEduVocExpression * entry, m_entries[setNo]) {
for (KEduVocExpression * entry : qAsConst(m_entries[setNo])) {
int grade = entry->translation(m_toTranslation)->grade();
if (grade >= Prefs::practiceMinimumGrade() && grade <= Prefs::practiceMaximumGrade()) {
m_entriesMinMaxGrade[setNo].insert(entry);
......@@ -514,7 +515,8 @@ void EntryFilter::cleanupInvalid(int setNo)
// Remove entries which don't have any of the tenses which are configured for practice
QSet<QString> practice_tenses = QSet<QString>(m_tenses.begin(), m_tenses.end());
QSet<QString> existing_tenses;
foreach(const QString & tense, translation->conjugationTenses()) {
const QStringList conjugationTenses = translation->conjugationTenses();
for (const QString & tense : conjugationTenses) {
if (!translation->getConjugation(tense).isEmpty()) {
existing_tenses << tense;
}
......@@ -548,8 +550,9 @@ QList< TestEntry* > EntryFilter::conjugationTestEntries(bool ignoreBlocked) cons
QList<TestEntry*> testEntries;
for (int i = 0; i < m_numSets; ++i) {
foreach(KEduVocExpression * entry, m_currentSelection[i]) {
foreach(const QString & tense, entry->translation(m_toTranslation)->conjugationTenses()) {
for (KEduVocExpression * entry : qAsConst(m_currentSelection[i])) {
const QStringList conjugationTenses = entry->translation(m_toTranslation)->conjugationTenses();
for (const QString & tense : conjugationTenses) {
// Only include tenses which are both non-empty and which should be practiced
if (!m_tenses.contains(tense)) {
......@@ -561,8 +564,8 @@ QList< TestEntry* > EntryFilter::conjugationTestEntries(bool ignoreBlocked) cons
}
bool blocked = true;
QList<KEduVocWordFlags> pronouns = conjugation.keys();
foreach(const KEduVocWordFlags & pronoun, pronouns) {
const QList<KEduVocWordFlags> pronouns = conjugation.keys();
for (const KEduVocWordFlags & pronoun : pronouns) {
KEduVocText* grade = &conjugation.conjugation(pronoun);
if (ignoreBlocked || !isBlocked(grade)) {
blocked = false;
......
......@@ -200,7 +200,8 @@ grade_t TestEntry::practiceModeDependentGrade(std::function<grade_t(KEduVocText)
KEduVocConjugation conj(translation->getConjugation(conjugationTense()));
// Depending on what minMaxFunc is used result needs an appropriate initialisation
result = (minMaxFunc(0, 1) == 1) ? KV_MIN_GRADE:KV_MAX_GRADE;
foreach(KEduVocWordFlags pronoun, conjugationPronouns()) {
const QList<KEduVocWordFlags> conjugationPronouns = this->conjugationPronouns();
for (KEduVocWordFlags pronoun : conjugationPronouns) {
result = minMaxFunc(result, gradeFunc(conj.conjugation(pronoun)));
}
}
......
......@@ -18,20 +18,20 @@ void VocabularyMimeData::setTranslations(const QList<KEduVocTranslation *> &tran
// sort the translations into entries to make deep copies for real copy and paste
// to only include each expression once
QList<KEduVocExpression *> expressions;
foreach(KEduVocTranslation * translation, m_translations) {
for (KEduVocTranslation * translation : qAsConst(m_translations)) {
if (!expressions.contains(translation->entry())) {
expressions.append(translation->entry());
}
}
foreach(KEduVocExpression * expression, expressions) {
for (KEduVocExpression * expression : qAsConst(expressions)) {
MimeExpression exp;
// deep copy
exp.expression = KEduVocExpression(*expression);
// copy word types
// this sucks but there is not really a better was. copying pointers is not a good idea because copy and paste can be done between different documents.
foreach(int i, expression->translationIndices()) {
for (int i : expression->translationIndices()) {
// generate text string representation
m_text.append(expression->translation(i)->text());
m_text.append(" - ");
......
......@@ -126,14 +126,16 @@ QVariant VocabularyModel::data(const QModelIndex & index, int role) const
return QVariant(QString());
case Synonym: {
QStringList displayElements;
foreach(KEduVocTranslation * synonym, m_container->entry(index.row(), m_recursive)->translation(translationId)->synonyms()) {
QList<KEduVocTranslation *> synonyms = m_container->entry(index.row(), m_recursive)->translation(translationId)->synonyms();
for (KEduVocTranslation * synonym : qAsConst(synonyms)) {
displayElements.append(synonym->text());
}
return QVariant(displayElements.join(QStringLiteral("; ")));
}
case Antonym: {
QStringList displayElements;
foreach(KEduVocTranslation * antonym, m_container->entry(index.row(), m_recursive)->translation(translationId)->antonyms()) {
QList<KEduVocTranslation *> antonyms = m_container->entry(index.row(), m_recursive)->translation(translationId)->antonyms();
for (KEduVocTranslation * antonym : qAsConst(antonyms)) {
displayElements.append(antonym->text());
}
return QVariant(displayElements.join(QStringLiteral("; ")));
......@@ -362,7 +364,7 @@ QMimeData * VocabularyModel::mimeData(const QModelIndexList & indexes) const
qDebug() << "mimeData for " << indexes.count() << "indexes";
QList<KEduVocTranslation*> translations;
foreach(const QModelIndex & index, sortedIndexes) {
for (const QModelIndex & index : qAsConst(sortedIndexes)) {
// only add if it's a translation. other cells like word type are being ignored for now.
if (columnType(index.column()) == Translation) {
translations.append(m_container->entry(index.row(), m_recursive)->translation(translation(index.column())));
......
......@@ -333,7 +333,7 @@ void Dashboard::setTheme()
void Dashboard::updateWidgets()
{
foreach (CollectionWidget *cw, m_collectionWidgets) {
for (CollectionWidget *cw : qAsConst(m_collectionWidgets)) {
cw->updateDue();
}
}
......
......@@ -156,7 +156,7 @@ void FromToEntryPage::setData(const QList<int>& entries)
if (m_entries.count() > 1) {
// fill enabled fields if equal for all edited entries, otherwise empty.
foreach(int entry, m_entries) {
for (int entry : qAsConst(m_entries)) {
// grade
KEduVocExpression *currentEntry = m_doc->entry(entry);
if (firstEntry->translation(m_translationTo)
......@@ -215,7 +215,7 @@ void FromToEntryPage::commitData()
}
// things that are changed for multiple or single entries
foreach(int entry, m_entries) {
for (int entry : qAsConst(m_entries)) {
if (m_gradeChanged) {
m_doc->entry(entry)->translation(m_translationTo).gradeFrom(m_translationFrom).setGrade(gradebox->currentIndex());
}
......
......@@ -88,13 +88,13 @@ void ConjugationWidget::updateEntries()
{
m_lastTenseSelection = tenseComboBox->currentText();
KEduVocConjugation conjugation = m_entry->translation(m_identifier)->getConjugation(m_lastTenseSelection);
foreach(KEduVocWordFlags flags, m_conjugationLineEdits.keys()) {
for(auto iter = m_conjugationLineEdits.cbegin(); iter != m_conjugationLineEdits.cend(); ++iter) {
QString text;
if (conjugation.keys().contains(flags)) {
text = conjugation.conjugation(flags).text();
if (conjugation.keys().contains(iter.key())) {
text = conjugation.conjugation(iter.key()).text();
}
m_conjugationLineEdits[flags]->setText(text);
m_conjugationLineEdits[iter.key()]->setText(text);
}
}
......
......@@ -32,8 +32,8 @@ DeclensionWidget::DeclensionWidget(QWidget *parent) : QWidget(parent)
setupLineEdits();
foreach(int index, m_DeclensionLineEdits.keys()) {
connect(m_DeclensionLineEdits.value(index), &QLineEdit::textChanged, this, &DeclensionWidget::textChanged);
for (auto iter = m_DeclensionLineEdits.begin(); iter != m_DeclensionLineEdits.end(); ++iter) {
connect(iter.value(), &QLineEdit::textChanged, this, &DeclensionWidget::textChanged);
}
}
......@@ -49,8 +49,8 @@ void DeclensionWidget::textChanged(const QString& text)
void DeclensionWidget::updateEntries()
{
foreach(int key, m_DeclensionLineEdits.keys()) {
m_DeclensionLineEdits.value(key)->setText(m_entry->translation(m_identifier)->declension()->declension((KEduVocWordFlag::Flags)(key | currentAdditionalWordFlag())).text());
for (auto iter = m_DeclensionLineEdits.cbegin(); iter != m_DeclensionLineEdits.cend(); ++iter) {
m_DeclensionLineEdits.value(iter.key())->setText(m_entry->translation(m_identifier)->declension()->declension((KEduVocWordFlag::Flags)(iter.key() | currentAdditionalWordFlag())).text());
}
}
......
......@@ -55,7 +55,8 @@ void ImageChooserWidget::slotImageChanged(const QString & urlStr)
if (m_entry) {
m_entry->translation(m_currentTranslation)->setImageUrl(url);
foreach(int j, m_entry->translationIndices()) {
const QList<int> translationIndices = m_entry->translationIndices();
for (int j : translationIndices) {
if (m_entry->translation(j)->imageUrl().isEmpty()) {
m_entry->translation(j)->setImageUrl(imageUrlRequester->url());
}
......
......@@ -122,7 +122,7 @@ bool MultipleChoiceWidget::eventFilter(QObject *obj, QEvent *event)
if (( dropEvent->mimeData() != NULL ) && dropEvent->mimeData()->hasText()) {
QStringList choices = dropEvent->mimeData()->text().split('\n');
foreach(const QString & choice, choices) {
for (const QString & choice : qAsConst(choices)) {
m_choicesModel->insertRow(multipleChoiceListView->model()->rowCount());
m_choicesModel->setData(m_choicesModel->index(multipleChoiceListView->model()->rowCount() - 1), choice);
}
......
......@@ -110,7 +110,7 @@ void SynonymWidget::updateList()
list = m_currentTranslation->falseFriends();
break;
}
foreach(KEduVocTranslation * translation, list) {
for (KEduVocTranslation * translation : qAsConst(list)) {
int row = m_listModel->rowCount();
m_listModel->insertRow(row);
m_listModel->setData(m_listModel->index(row), translation->text());
......
......@@ -250,7 +250,8 @@ void VocabularyView::appendChar(const QChar &c)
void VocabularyView::deleteSelectedEntries(bool askConfirmation)
{
QSet<int> rows;
foreach(const QModelIndex & index, selectionModel()->selectedIndexes()) {
const QModelIndexList selectedIndexes = selectionModel()->selectedIndexes();
for (const QModelIndex & index : selectedIndexes) {
rows.insert(index.row());
}
......@@ -284,15 +285,18 @@ void VocabularyView::slotEditPaste()
const VocabularyMimeData *vocMimeData = qobject_cast<const VocabularyMimeData *>(mimeData);
if (vocMimeData) {
qDebug() << "Clipboard contains vocabulary mime data.";
foreach(const VocabularyMimeData::MimeExpression & mimeEntry, vocMimeData->expressionList()) {
QList< VocabularyMimeData::MimeExpression > expressionList = vocMimeData->expressionList();
for (const VocabularyMimeData::MimeExpression & mimeEntry : qAsConst(expressionList)) {
KEduVocExpression *pasteExpression = new KEduVocExpression(mimeEntry.expression);
m_model->appendEntry(pasteExpression);
// find word type (create if not found)
KEduVocWordType *type = m_doc->wordTypeContainer();
foreach(int translation, mimeEntry.wordTypes.keys()) {
for (auto iter = mimeEntry.wordTypes.cbegin(); iter != mimeEntry.wordTypes.cend(); ++iter) {
const int translation = iter.key();
// append if needed
foreach(const QString & typeName, mimeEntry.wordTypes.value(translation).wordType) {
const QStringList wordType = mimeEntry.wordTypes.value(translation).wordType;
for (const QString & typeName : wordType) {
qDebug() << mimeEntry.wordTypes.value(translation).wordType;
KEduVocContainer *childType = type->childContainer(typeName);
if (!childType) {
......@@ -315,7 +319,7 @@ void VocabularyView::slotEditPaste()
qDebug() << "Clipboard contains text data.";
// split at newline
QStringList lines = clipboard->text().split('\n');
foreach(QString line, lines) {
for (QString line : qAsConst(lines)) {
// split at tabs or semicolon:
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
m_model->appendEntry(new KEduVocExpression(line.split(QRegExp(QStringLiteral("[\t;]")), QString::KeepEmptyParts)));
......
......@@ -396,7 +396,8 @@ void ParleyMainWindow::showDocumentActions(bool open, bool edit)
void ParleyMainWindow::setVisibleToolbar(const QString& name)
{
Q_FOREACH(KToolBar * toolbar, toolBars()) {
const QList<KToolBar*> toolbars = toolBars();
for (KToolBar * toolbar : toolbars) {
if (toolbar && toolbar->objectName() == name) {
toolbar->show();
} else if (toolbar) {
......
......@@ -48,7 +48,7 @@ bool ConjugationBackendMode::setTestEntry(TestEntry* current)
m_frontend->setQuestion(QVariant::fromValue<ConjugationData>(data));
QStringList answers;
foreach(const KEduVocWordFlags & key, m_pronounFlags) {
for (const KEduVocWordFlags & key : qAsConst(m_pronounFlags)) {
answers.append(m_conjugation.conjugation(key).text());
}
m_frontend->setSolution(answers);
......@@ -65,7 +65,7 @@ bool ConjugationBackendMode::setTestEntry(TestEntry* current)
QStringList ConjugationBackendMode::validPersonalPronouns()
{
QStringList pp;
foreach(const KEduVocWordFlags & person, m_pronounFlags) {
for (const KEduVocWordFlags & person : qAsConst(m_pronounFlags)) {
// FIXME: Used to be m_practiceOptions.languageTo()
pp.append(m_doc->identifier(Prefs::learningLanguage()).personalPronouns().personalPronoun(person));
}
......@@ -80,7 +80,7 @@ void ConjugationBackendMode::checkAnswer()
bool allCorrect = true;
int numRight = 0;
int i = 0;
foreach(const KEduVocWordFlags & key, m_pronounFlags) {
for (const KEduVocWordFlags & key : qAsConst(m_pronounFlags)) {
if (answers.at(i) == m_conjugation.conjugation(key).text()) {
++numRight;
} else {
......@@ -110,7 +110,7 @@ void ConjugationBackendMode::checkAnswer()
grade_t ConjugationBackendMode::currentPreGradeForEntry() const
{
grade_t min_preGrade = KV_MAX_GRADE;
foreach(KEduVocWordFlags key, m_pronounFlags) {
for (KEduVocWordFlags key : qAsConst(m_pronounFlags)) {
min_preGrade = qMin(m_conjugation.conjugation(key).preGrade(), min_preGrade);
}
......@@ -120,7 +120,7 @@ grade_t ConjugationBackendMode::currentPreGradeForEntry() const
grade_t ConjugationBackendMode::currentGradeForEntry() const
{
grade_t min_grade = KV_MAX_GRADE;
foreach(KEduVocWordFlags key, m_pronounFlags) {
for (KEduVocWordFlags key : qAsConst(m_pronounFlags)) {
min_grade = qMin(m_conjugation.conjugation(key).grade(), min_grade);
}
......@@ -131,7 +131,7 @@ void ConjugationBackendMode::updateGrades()
{
qDebug() << "Grading conjugations";
foreach(const KEduVocWordFlags & key, m_pronounFlags) {
for (const KEduVocWordFlags & key : qAsConst(m_pronounFlags)) {
KEduVocTranslation *translation = m_current->entry()->translation(m_current->languageTo());
if (translation) {
KEduVocConjugation conjugationToUpdate = translation->getConjugation(m_currentTense);
......
......@@ -86,7 +86,7 @@ void ConjugationModeWidget::setQuestion(const QVariant& question)
setNumberOfConjugationWidgets(data.personalPronouns.size());
int i = 0;
foreach(QString pp, data.personalPronouns) {
for (QString pp : qAsConst(data.personalPronouns)) {
if (data.personalPronouns.size() == 1) {
pp += " (" + data.tense + ')';
}
......
......@@ -18,7 +18,7 @@ const char* identifier = "parleyimagecache2";
void ImageCache::setFilenames(const QStringList& filenames)
{
m_timestamps.clear();
Q_FOREACH(const QString & filename, filenames) {
for (const QString & filename : filenames) {
QFileInfo info(filename);
m_timestamps.append(info.lastModified());
}
......
......@@ -139,7 +139,7 @@ void LatexRenderer::latexRendered()
QStringList extensions;
extensions << QStringLiteral(".log") << QStringLiteral(".aux") << QStringLiteral(".tex") << QStringLiteral(".dvi") << QStringLiteral(".eps") << QStringLiteral(".png");
foreach(const QString & ext, extensions) {
for (const QString & ext : qAsConst(extensions)) {
QString s = m_latexFilename;
s.replace(QLatin1String(".eps"), ext);
QFile f(s);
......
......@@ -54,7 +54,7 @@ void MixedLettersModeWidget::updatePixmap()
defaultPen.setColor(palette().color(QPalette::WindowText));
QString enteredChars = m_ui->answerEdit->text();
int i = 0;
Q_FOREACH(QChar ch, m_mixedSolution) {
for (QChar ch : qAsConst(m_mixedSolution)) {
int pos = enteredChars.indexOf(ch);
if (pos != -1) {
p.setPen(scheme.foreground(KColorScheme::InactiveText).color());
......@@ -74,13 +74,13 @@ void MixedLettersModeWidget::setSolution(const QVariant& solution)
WrittenPracticeWidget::setSolution(solution);
m_solution = solution.toString();
QList<QChar> chars;
Q_FOREACH(QChar ch, solution.toString()) {
for (QChar ch : qAsConst(m_solution)) {
chars.append(ch);
}
KRandom::shuffle(chars);
m_mixedSolution.clear();
m_positions.clear();
Q_FOREACH(QChar ch, chars) {
for (QChar ch : qAsConst(chars)) {
m_mixedSolution.append(ch);
m_positions.append(QRandomGenerator::global()->bounded(8));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment