r22838 by jghali - Some refactoring for LanguageManager

scribus-commit scribus-commit at lists.scribus.net
Tue Feb 19 22:55:04 UTC 2019


Author: jghali
Date: Tue Feb 19 22:55:04 2019
New Revision: 22838

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22838
Log:
Some refactoring for LanguageManager

Modified:
    trunk/Scribus/scribus/langmgr.cpp

Modified: trunk/Scribus/scribus/langmgr.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22838&path=/trunk/Scribus/scribus/langmgr.cpp
==============================================================================
--- trunk/Scribus/scribus/langmgr.cpp	(original)
+++ trunk/Scribus/scribus/langmgr.cpp	Tue Feb 19 22:55:04 2019
@@ -1035,30 +1035,30 @@
 		dictList.replaceInStrings(".dic","");
 
 		//Ensure we have aff+dic file pairs, remove any hyphenation dictionaries from the list
-
-		foreach(const QString& dictName, dictList)
-		{
-			if (!QFile::exists(dictionaryPaths.at(i)+dictName+".aff"))
+		for (const QString& dictName : qAsConst(dictList))
+		{
+			if (!QFile::exists(dictionaryPaths.at(i) + dictName + ".aff"))
+			{
 				dictList.removeAll(dictName);
-			else
+				continue;
+			}
+				
+			if (dictionaryMap.contains(dictName))
+				continue;
+
+			if (dictName.length()<=5)
 			{
-				if (!dictionaryMap.contains(dictName))
-				{
-					if (dictName.length()<=5)
-					{
-						//QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(dictName));
-						//qDebug()<<"findSpellingDictionarySets"<<dictName<<shortAbbrev;
-						dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
-						//dictionaryMap.insert(shortAbbrev, dictionaryPaths.at(i)+dictName);
-					}
-					//qDebug()<<"Spell Finder:"<<dictName<<dictionaryPaths.at(i)+dictName;
-					if (dictName.length()>5)
-					{
-						QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(dictName));
-						//qDebug()<<shortAbbrev;
-						dictionaryMap.insert(shortAbbrev, dictionaryPaths.at(i)+dictName);
-					}
-				}
+				//QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(dictName));
+				//qDebug()<<"findSpellingDictionarySets"<<dictName<<shortAbbrev;
+				dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
+				//dictionaryMap.insert(shortAbbrev, dictionaryPaths.at(i)+dictName);
+			}
+			//qDebug()<<"Spell Finder:"<<dictName<<dictionaryPaths.at(i)+dictName;
+			if (dictName.length()>5)
+			{
+				QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(dictName));
+				//qDebug()<<shortAbbrev;
+				dictionaryMap.insert(shortAbbrev, dictionaryPaths.at(i)+dictName);
 			}
 		}
 //		qDebug()<<"Number of dictionaries/AFFs found in"<<dictionaryPaths.at(i)<<":"<<dictList.count();
@@ -1108,28 +1108,28 @@
 		QDir dictLocation(dictionaryPaths.at(i));
 		QStringList dictFilters("hyph*.dic");
 		if (dictionaryPaths.at(i)==ScPaths::userDictDir(ScPaths::Hyph, false))
-				dictFilters.append("*.dic");
+			dictFilters.append("*.dic");
 		QStringList dictList(dictLocation.entryList(dictFilters, QDir::Files, QDir::Name));
 		dictList.replaceInStrings(".dic","");
-		foreach(const QString& dn, dictList)
+
+		for (const QString& dn : qAsConst(dictList))
 		{
 //			qDebug()<<dn;
 			QString dictName;
 			if (dn.startsWith("hyph_"))
-				dictName=dn.section('_',1);
+				dictName = dn.section('_',1);
 			else
-				dictName=dn;
-			if (!dictionaryMap.contains(dictName))
+				dictName = dn;
+			if (dictionaryMap.contains(dictName))
+				continue;
+			if (dictName.length()<=2)
 			{
-				if (dictName.length()<=2)
-				{
-					dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dn+".dic");
-				}
-				if (dictName.length()>2)
-				{
-					QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(dictName));
-					dictionaryMap.insert(shortAbbrev, dictionaryPaths.at(i)+dn+".dic");
-				}
+				dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dn+".dic");
+			}
+			if (dictName.length()>2)
+			{
+				QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(dictName));
+				dictionaryMap.insert(shortAbbrev, dictionaryPaths.at(i)+dn+".dic");
 			}
 		}
 	}




More information about the scribus-commit mailing list