r18305 by jghali - more cleanup of "new from template" code

scribus-commit scribus-commit at lists.scribus.net
Sun Jun 9 15:37:43 UTC 2013


Author: jghali
Date: Sun Jun  9 15:37:42 2013
New Revision: 18305

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18305
Log:
more cleanup of "new from template" code

Modified:
    branches/Version14x/Scribus/scribus/nfttemplate.cpp

Modified: branches/Version14x/Scribus/scribus/nfttemplate.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18305&path=/branches/Version14x/Scribus/scribus/nfttemplate.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/nfttemplate.cpp (original)
+++ branches/Version14x/Scribus/scribus/nfttemplate.cpp Sun Jun  9 15:37:42 2013
@@ -21,61 +21,61 @@
 
 void nfttemplate::remove()
 {
-	if (tmplXml->exists())
+	if (!tmplXml->exists())
+		return;
+
+	QString newTmplXml = "";
+	QString tmp;
+	bool collect = false;
+	tmplXml->open(QIODevice::ReadOnly);
+	QTextStream stream(tmplXml);
+	stream.setCodec("UTF-8");
+	QString line = stream.readLine();
+	while (!line.isNull())
 	{
-		QString newTmplXml = "";
-		QString tmp;
-		bool collect = false;
-		tmplXml->open(QIODevice::ReadOnly);
-		QTextStream stream(tmplXml);
-		stream.setCodec("UTF-8");
-		QString line = stream.readLine();
-		while (!line.isNull())
+		if ((line.indexOf(enCategory) != -1) || collect)
 		{
-			if ((line.indexOf(enCategory) != -1) || collect)
+			collect = true;
+			line += "\n";
+			tmp += line;
+			if (line.indexOf("name") != -1)
 			{
-				collect = true;
-				line += "\n";
-				tmp += line;
-				if (line.indexOf("name") != -1)
-				{
-					if (line.indexOf(name) == -1)
-					{
-						collect = false;
-						newTmplXml += tmp;
-						tmp = "";
-					}
-				} 
-				else if (line.indexOf("file") != -1)
-				{
-					QString shortFile = file.right(file.length() - file.lastIndexOf("/") -1);
-					if (line.indexOf(shortFile) == -1)
-					{
-						collect = false;
-						newTmplXml += tmp;
-						tmp = "";
-					}
-				} 
-				else if (line.indexOf("</template>") != -1)
+				if (line.indexOf(name) == -1)
 				{
 					collect = false;
+					newTmplXml += tmp;
 					tmp = "";
 				}
+			} 
+			else if (line.indexOf("file") != -1)
+			{
+				QString shortFile = file.right(file.length() - file.lastIndexOf("/") -1);
+				if (line.indexOf(shortFile) == -1)
+				{
+					collect = false;
+					newTmplXml += tmp;
+					tmp = "";
+				}
+			} 
+			else if (line.indexOf("</template>") != -1)
+			{
+				collect = false;
+				tmp = "";
 			}
-			else
-			{
-				line += "\n";
-				newTmplXml += line;
-			}
-			line = stream.readLine();
 		}
-		tmplXml->close();
-		tmplXml->open(QIODevice::WriteOnly);
-		QTextStream instream(tmplXml);
-		instream.setCodec("UTF-8");
-		instream << newTmplXml;
-		tmplXml->close();
+		else
+		{
+			line += "\n";
+			newTmplXml += line;
+		}
+		line = stream.readLine();
 	}
+	tmplXml->close();
+	tmplXml->open(QIODevice::WriteOnly);
+	QTextStream instream(tmplXml);
+	instream.setCodec("UTF-8");
+	instream << newTmplXml;
+	tmplXml->close();
 }
 
 bool nfttemplate::canWrite()




More information about the scribus-commit mailing list