r19187 by craig - #5638: Sort translation info in the About window, even when translated

scribus-commit scribus-commit at lists.scribus.net
Fri Jun 6 22:23:24 UTC 2014


Author: craig
Date: Fri Jun  6 22:23:24 2014
New Revision: 19187

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19187
Log:
#5638: Sort translation info in the About window, even when translated

Modified:
    trunk/Scribus/scribus/ui/about.cpp

Modified: trunk/Scribus/scribus/ui/about.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19187&path=/trunk/Scribus/scribus/ui/about.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/about.cpp (original)
+++ trunk/Scribus/scribus/ui/about.cpp Fri Jun  6 22:23:24 2014
@@ -20,6 +20,7 @@
 #include <QPushButton>
 #include <QShowEvent>
 #include <QString>
+#include <QStringList>
 #include <QTabWidget>
 #include <QTextStream>
 #include <QToolTip>
@@ -481,6 +482,13 @@
 		bool startText = false;
 		bool startTitle = false;
 		result = "<table>";
+
+		QMap<QString, QString> sections;
+		QMap<QString, QString> languages;
+		QMultiMap<QString, QString> names;
+		QString currLang;
+		int section=0;
+		QString snum;
 		while (!inTS.atEnd())
 		{
 			lineTS = inTS.readLine();
@@ -492,7 +500,11 @@
 			{
 				if  (isSectionTitle)
 				{
-					result += "<tr><td><b><i>"+About::trTranslationTitle(lineTS)+"</i></b></td><td></td></tr>";
+					++section;
+					snum.setNum(section);
+					//result += "<tr><td><b><i>"+About::trTranslationTitle(lineTS)+"</i></b></td><td></td></tr>";
+
+					sections.insert(snum, "<tr><td><b><i>"+About::trTranslationTitle(lineTS)+"</i></b></td><td></td></tr>");
 					isSectionTitle = false;
 					isTitle = false;
 					startTitle = false;
@@ -508,8 +520,10 @@
 						code.replace(")", "");
 						code = LanguageManager::instance()->getLangFromAbbrev(code);
 					}
-					result += "<tr><td><b>"+code+"</b></td><td></td></tr>";
+					//result += "<tr><td><b>"+code+"</b></td><td></td></tr>";
+					languages.insert(snum+":"+code, "<tr><td><b>"+code+"</b></td><td></td></tr>");
 					isTitle = false;
+					currLang=code;
 
 				} // if is title
 				else
@@ -520,7 +534,8 @@
 					contact.replace("(", "");
 					contact.replace(")", "");
 					name = (fieldTS.isEmpty() ? "" : fieldTS.join(" "));
-					result += "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>";
+					//result += "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>";
+					names.insert(snum+":"+code, "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>");
 				} // else is title
 			} // if is empty line
 			else
@@ -531,7 +546,7 @@
 					isTitle = !isTitle;
 					if (isTitle)
 					{
-						result += "<tr><td></td><td></td></tr>";
+						//result += "<tr><td></td><td></td></tr>";
 						startTitle = true;
 					}
 					else
@@ -548,6 +563,33 @@
 				}
 			} // else is empty line
 		} // while ! atEnd
+
+		QMapIterator<QString, QString> s(sections);
+		while (s.hasNext())
+		{
+			s.next();
+			result += s.value();
+			QMapIterator<QString, QString> l(languages);
+			while (l.hasNext())
+			{
+				l.next();
+				QStringList sl=l.key().split(":");
+				if (s.key()==sl.first())
+				{
+					result += l.value();
+
+					QMapIterator<QString, QString> n(names);
+					while (n.hasNext())
+					{
+						n.next();
+						if (n.key()==l.key())
+							result += n.value();
+					}
+					result += "<tr><td></td><td></td></tr>";
+				}
+			}
+			result += "<tr><td></td><td></td></tr><tr><td></td><td></td></tr>";
+		}
 		result += "<table>";
 	} // if file found
 	else




More information about the scribus-commit mailing list