r22308 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Fri Dec 29 23:27:34 UTC 2017
Author: jghali
Date: Fri Dec 29 23:27:34 2017
New Revision: 22308
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22308
Log:
improvement to r22303: reduce level of indentation by exiting early when possible
Modified:
trunk/Scribus/scribus/nfttemplate.cpp
Modified: trunk/Scribus/scribus/nfttemplate.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22308&path=/trunk/Scribus/scribus/nfttemplate.cpp
==============================================================================
--- trunk/Scribus/scribus/nfttemplate.cpp (original)
+++ trunk/Scribus/scribus/nfttemplate.cpp Fri Dec 29 23:27:34 2017
@@ -24,61 +24,61 @@
if (!tmplXml.exists())
return;
- if (tmplXml.open(QIODevice::ReadOnly))
+ if (!tmplXml.open(QIODevice::ReadOnly))
+ return;
+
+ QString newTmplXml;
+ QString tmp;
+ bool collect = false;
+ QTextStream stream(&tmplXml);
+ stream.setCodec("UTF-8");
+ QString line = stream.readLine();
+ while (!line.isNull())
{
- QString newTmplXml;
- QString tmp;
- bool collect = false;
- 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
+ else if (line.indexOf("file") != -1)
{
- line += "\n";
- newTmplXml += line;
+ QString shortFile = file.right(file.length() - file.lastIndexOf("/") -1);
+ if (line.indexOf(shortFile) == -1)
+ {
+ collect = false;
+ newTmplXml += tmp;
+ tmp = "";
+ }
}
- line = stream.readLine();
+ else if (line.indexOf("</template>") != -1)
+ {
+ collect = false;
+ tmp = "";
+ }
}
+ else
+ {
+ line += "\n";
+ newTmplXml += line;
+ }
+ line = stream.readLine();
+ }
+ tmplXml.close();
+ if (tmplXml.open(QIODevice::WriteOnly))
+ {
+ QTextStream instream(&tmplXml);
+ instream.setCodec("UTF-8");
+ instream << newTmplXml;
tmplXml.close();
- if (tmplXml.open(QIODevice::WriteOnly))
- {
- QTextStream instream(&tmplXml);
- instream.setCodec("UTF-8");
- instream << newTmplXml;
- tmplXml.close();
- }
}
}
More information about the scribus-commit
mailing list