Commit ae739002 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

translations: reverse function-covering conditionals

if the condition is covering the entire function then we can simply
return early, get less nesting depth and quicker exit condition reading
as you don't have to scroll down to see if anything happens after that
huge if
parent f0c18316
......@@ -265,31 +265,33 @@ QStringList SelectedTranslationsModel::selectedLanguages() const
void SelectedTranslationsModel::setSelectedLanguages(const QStringList &languages)
{
if (m_selectedLanguages != languages) {
QStringList missingLanguages;
if (m_selectedLanguages == languages) {
return;
}
for (const QString &lang : languages) {
reloadCompleteness(lang);
if (!m_installedLanguages.contains(lang)) {
missingLanguages << lang;
}
QStringList missingLanguages;
for (const QString &lang : languages) {
reloadCompleteness(lang);
if (!m_installedLanguages.contains(lang)) {
missingLanguages << lang;
}
}
missingLanguages.sort();
missingLanguages.sort();
if (missingLanguages != m_missingLanguages) {
m_missingLanguages = missingLanguages;
emit missingLanguagesChanged();
}
if (missingLanguages != m_missingLanguages) {
m_missingLanguages = missingLanguages;
emit missingLanguagesChanged();
}
beginResetModel();
beginResetModel();
m_selectedLanguages = languages;
m_selectedLanguages = languages;
endResetModel();
endResetModel();
emit selectedLanguagesChanged(m_selectedLanguages);
}
emit selectedLanguagesChanged(m_selectedLanguages);
}
QStringList SelectedTranslationsModel::missingLanguages() const
......
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