r23294 by jghali - Fix signed/unsigned comparison warnign in gtgettext.cpp + some refactoring

scribus-commit scribus-commit at lists.scribus.net
Tue Oct 29 05:37:10 UTC 2019


Author: jghali
Date: Tue Oct 29 05:37:10 2019
New Revision: 23294

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23294
Log:
Fix signed/unsigned comparison warnign in gtgettext.cpp + some refactoring

Modified:
    trunk/Scribus/scribus/gtgettext.cpp

Modified: trunk/Scribus/scribus/gtgettext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23294&path=/trunk/Scribus/scribus/gtgettext.cpp
==============================================================================
--- trunk/Scribus/scribus/gtgettext.cpp	(original)
+++ trunk/Scribus/scribus/gtgettext.cpp	Tue Oct 29 05:37:10 2019
@@ -153,15 +153,13 @@
 QStringList gtGetText::getSupportedTypes()
 {
 	QStringList result;
-	for (int i = 0; i < m_importers.size(); ++i)
-	{
-		if (m_importers[i].fileEndings.count() != 0)
-		{
-			for (int j = 0; j < m_importers[i].fileEndings.count(); ++j)
-			{
-				result.append(m_importers[i].fileEndings[j].toLower());
-			}
-		}
+	for (size_t i = 0; i < m_importers.size(); ++i)
+	{
+		const ImporterData& importerData = m_importers[i];
+		if (importerData.fileEndings.count() <= 0)
+			continue;
+		for (int j = 0; j < importerData.fileEndings.count(); ++j)
+			result.append(importerData.fileEndings[j].toLower());
 	}
 	return result;
 }
@@ -171,40 +169,44 @@
 {
 	// Initialize a filters list.
 	QString filters;
+
 	// Create a string for the "All supported files filter". Start with the label then loop through
 	// the importers vector and add all of the file extensions supported.
 	QString allSupported = QObject::tr("All Supported Formats") + " (";
 	// Loop through the importers vector.
-	for (uint i = 0; i < m_importers.size(); ++i)
-	{
+	for (size_t i = 0; i < m_importers.size(); ++i)
+	{
+		const ImporterData& importerData = m_importers[i];
 		// If there are any file extnsions declared by the importer
-		if (m_importers[i].fileEndings.count() != 0)
-		{
-			// Add the importer name to the filters list
-			filters += m_importers[i].fileFormatName + " (";
-			// Loop though the extensions supported by the importer
-			for (int j = 0; j < m_importers[i].fileEndings.count(); ++j)
-			{
-				// Add the extension to both the filter and allSupported strings
-				filters += "*." + m_importers[i].fileEndings[j] + " ";
-				allSupported += "*." + m_importers[i].fileEndings[j] + " ";
-			}  // for (int j = 0; j < importers[i].fileEndings.count(); ++j)
-			// Trim the Qstring
-			filters = filters.trimmed();
-			// Append "entry of entry" information to the end of the filter.
-			filters += ");;";
-		}  // if (importers[i].fileEndings.count() != 0)
-	}  // for (uint i = 0; i < importers.size(); ++i)
+		if (importerData.fileEndings.count() <= 0)
+			continue;
+		// Add the importer name to the filters list
+		filters += importerData.fileFormatName + " (";
+		// Loop though the extensions supported by the importer
+		for (int j = 0; j < importerData.fileEndings.count(); ++j)
+		{
+			// Add the extension to both the filter and allSupported strings
+			filters += "*." + importerData.fileEndings[j] + " ";
+			allSupported += "*." + importerData.fileEndings[j] + " ";
+		}
+		// Trim the Qstring
+		filters = filters.trimmed();
+		// Append "entry of entry" information to the end of the filter.
+		filters += ");;";
+	}
+
 	// Trim the allSupported QString and append "end of entry" data to the end of it.
 	allSupported = allSupported.trimmed();
 	allSupported += ");;";
+
 	// Prepend allSupported to the filters Qstring.
 	filters = allSupported + filters;
 	// Add an "all files" entry to the end of the filters QString
 	filters += QObject::tr("All Files (*)");
 	// Populate ilist with the file importer names.
-	for (uint i = 0;  i < m_importers.size(); ++i)
+	for (size_t i = 0;  i < m_importers.size(); ++i)
 		m_ilist.append(m_importers[i].fileFormatName);
+
 	// Create a new dialog.
 	m_dias = new gtDialogs();
 	// Create a new ImportSetup struct




More information about the scribus-commit mailing list