r22956 by jghali - Small refactoring for Prefs_KeyboardShortcuts::scanForSets()

scribus-commit scribus-commit at lists.scribus.net
Sat Apr 20 21:08:21 UTC 2019


Author: jghali
Date: Sat Apr 20 21:08:21 2019
New Revision: 22956

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22956
Log:
Small refactoring for Prefs_KeyboardShortcuts::scanForSets()

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

Modified: trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22956&path=/trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp	Sat Apr 20 21:08:21 2019
@@ -245,43 +245,42 @@
 QStringList Prefs_KeyboardShortcuts::scanForSets()
 {
 	keySetList.clear();
-	QString location=ScPaths::instance().shareDir();
-	QString keySetLocation=QDir::toNativeSeparators(location+"keysets/");
+	QString location = ScPaths::instance().shareDir();
+	QString keySetLocation = QDir::toNativeSeparators(location+"keysets/");
 	QDir keySetsDir(keySetLocation, "*.xml", QDir::Name, QDir::Files | QDir::NoSymLinks);
-	if ((keySetsDir.exists()) && (keySetsDir.count() != 0))
-	{
-		QStringList appNames;
-		for (uint fileCounter = 0; fileCounter < keySetsDir.count(); ++fileCounter)
-		{
-			QString filename=QDir::toNativeSeparators(location+"keysets/"+keySetsDir[fileCounter]);
-
-			QDomDocument doc( "keymapentries" );
-			QFile file( filename );
-			if ( !file.open( QIODevice::ReadOnly ) )
-				continue;
-			QString errorMsg;
-			int eline;
-			int ecol;
-
-			if ( !doc.setContent( &file, &errorMsg, &eline, &ecol ))
-			{
-				qDebug("%s", QString("Could not open key set file: %1\nError:%2 at line: %3, row: %4").arg(keySetsDir[fileCounter]).arg(errorMsg).arg(eline).arg(ecol).toLatin1().constData());
-				file.close();
-				continue;
-			}
+	if ((!keySetsDir.exists()) || (keySetsDir.count() <= 0))
+		return QStringList();
+
+	QStringList appNames;
+	for (uint fileCounter = 0; fileCounter < keySetsDir.count(); ++fileCounter)
+	{
+		QString filename = QDir::toNativeSeparators(location+"keysets/"+keySetsDir[fileCounter]);
+
+		QDomDocument doc( "keymapentries" );
+		QFile file( filename );
+		if (!file.open( QIODevice::ReadOnly))
+			continue;
+		QString errorMsg;
+		int eline;
+		int ecol;
+
+		if (!doc.setContent( &file, &errorMsg, &eline, &ecol ))
+		{
+			qDebug("%s", QString("Could not open key set file: %1\nError:%2 at line: %3, row: %4").arg(keySetsDir[fileCounter]).arg(errorMsg).arg(eline).arg(ecol).toLatin1().constData());
 			file.close();
-
-			QDomElement docElem = doc.documentElement();
-			if (docElem.tagName()=="shortcutset" && docElem.hasAttribute("name"))
-			{
-				QDomAttr nameAttr = docElem.attributeNode( "name" );
-				appNames.append(nameAttr.value());
-				keySetList.insert(nameAttr.value(), filename);
-			}
-		}
-		return QStringList(appNames);
-	}
-	return QStringList();
+			continue;
+		}
+		file.close();
+
+		QDomElement docElem = doc.documentElement();
+		if (docElem.tagName() == "shortcutset" && docElem.hasAttribute("name"))
+		{
+			QDomAttr nameAttr = docElem.attributeNode( "name" );
+			appNames.append(nameAttr.value());
+			keySetList.insert(nameAttr.value(), filename);
+		}
+	}
+	return QStringList(appNames);
 }
 
 QString Prefs_KeyboardShortcuts::getKeyText(const QKeySequence& KeyC)




More information about the scribus-commit mailing list