r21797 by jghali - remove unnecessary level of indentation in ColorSetManager::searchDir() by exiting early

scribus-commit scribus-commit at lists.scribus.net
Tue Feb 28 14:00:35 UTC 2017


Author: jghali
Date: Tue Feb 28 14:00:35 2017
New Revision: 21797

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21797
Log:
remove unnecessary level of indentation in ColorSetManager::searchDir() by exiting early

Modified:
    trunk/Scribus/scribus/colorsetmanager.cpp

Modified: trunk/Scribus/scribus/colorsetmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21797&path=/trunk/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.cpp	(original)
+++ trunk/Scribus/scribus/colorsetmanager.cpp	Tue Feb 28 14:00:35 2017
@@ -156,52 +156,52 @@
 	exts << "acb" << "aco" << "ai" << "ase" << "eps" << "gpl" << "skp" << "sla" << "soc" << "xar" << "xml" << "sbz";
 	QDir dirs(path, "*", QDir::Name,  QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks);
 	dirs.setSorting(QDir::Name | QDir::DirsFirst);
-	if ((dirs.exists()) && (dirs.count() != 0))
-	{
-		for (uint dc = 0; dc < dirs.count(); ++dc)
-		{
-			QFileInfo fi(path + dirs[dc]);
-			if (fi.isDir())
+	if ((!dirs.exists()) || (dirs.count() == 0))
+		return;
+
+	for (uint dc = 0; dc < dirs.count(); ++dc)
+	{
+		QFileInfo fi(path + dirs[dc]);
+		if (fi.isDir())
+		{
+			QDir sd(path + dirs[dc], "*", QDir::Name, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks);
+			if (sd.count() > 0)
 			{
-				QDir sd(path + dirs[dc], "*", QDir::Name, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks);
-				if (sd.count() > 0)
+				QString setName = fi.baseName();
+				setName.replace("_", " ");
+				if (parent != NULL)
 				{
-					QString setName = fi.baseName();
-					setName.replace("_", " ");
-					if (parent != NULL)
+					QTreeWidgetItem* item;
+					if (path + dirs[dc] == ScPaths::applicationDataDir()+"swatches/locked")
+						item = parent;
+					else
 					{
-						QTreeWidgetItem* item;
-						if (path + dirs[dc] == ScPaths::applicationDataDir()+"swatches/locked")
-							item = parent;
-						else
-						{
-							item = new QTreeWidgetItem(parent);
-							item->setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
-							item->setIcon(0, QIcon(IconManager::instance()->loadIcon("16/folder.png")));
-							item->setText(0, setName);
-						}
-						searchDir(path + dirs[dc] + "/", pList, item);
+						item = new QTreeWidgetItem(parent);
+						item->setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+						item->setIcon(0, QIcon(IconManager::instance()->loadIcon("16/folder.png")));
+						item->setText(0, setName);
 					}
-					else
-						searchDir(path + dirs[dc] + "/", pList, parent);
+					searchDir(path + dirs[dc] + "/", pList, item);
 				}
+				else
+					searchDir(path + dirs[dc] + "/", pList, parent);
 			}
-			else
+		}
+		else
+		{
+			if (exts.contains(fi.suffix().toLower()))
 			{
-				if (exts.contains(fi.suffix().toLower()))
+				QString setName = fi.baseName();
+				setName.replace("_", " ");
+				pList.insert(fi.absolutePath() + "/" + setName, fi.absoluteFilePath());
+				if (parent != 0)
 				{
-					QString setName = fi.baseName();
-					setName.replace("_", " ");
-					pList.insert(fi.absolutePath() + "/" + setName, fi.absoluteFilePath());
-					if (parent != 0)
-					{
-						QTreeWidgetItem* item = new QTreeWidgetItem(parent);
-						item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
-						item->setText(0, setName);
-						item->setData(0, Qt::UserRole, fi.absolutePath());
-						if ((!fi.isWritable()) || (fi.absolutePath().contains(ScPaths::applicationDataDir()+"swatches/locked")))
-							item->setIcon(0, QIcon(IconManager::instance()->loadIcon("16/lock.png")));
-					}
+					QTreeWidgetItem* item = new QTreeWidgetItem(parent);
+					item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+					item->setText(0, setName);
+					item->setData(0, Qt::UserRole, fi.absolutePath());
+					if ((!fi.isWritable()) || (fi.absolutePath().contains(ScPaths::applicationDataDir()+"swatches/locked")))
+						item->setIcon(0, QIcon(IconManager::instance()->loadIcon("16/lock.png")));
 				}
 			}
 		}




More information about the scribus-commit mailing list