r21818 by craig - Some more cleanup of nft/sat template plugin code and their lack of use of ScPaths

scribus-commit scribus-commit at lists.scribus.net
Sun Mar 12 17:49:03 UTC 2017


Author: craig
Date: Sun Mar 12 17:49:03 2017
New Revision: 21818

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21818
Log:
Some more cleanup of nft/sat template plugin code and their lack of use of ScPaths

Modified:
    trunk/Scribus/scribus/nftsettings.cpp
    trunk/Scribus/scribus/nftsettings.h
    trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.cpp
    trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.h
    trunk/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp

Modified: trunk/Scribus/scribus/nftsettings.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21818&path=/trunk/Scribus/scribus/nftsettings.cpp
==============================================================================
--- trunk/Scribus/scribus/nftsettings.cpp	(original)
+++ trunk/Scribus/scribus/nftsettings.cpp	Sun Mar 12 17:49:03 2017
@@ -15,27 +15,21 @@
 nftsettings::nftsettings(QString guilang)
 {
 	lang = guilang;
-	scribusShare = ScPaths::instance().templateDir();
-	scribusUserHome = QDir::toNativeSeparators(ScPaths::applicationDataDir());
-
 	read();
 }
 
 void nftsettings::read()
 {
-	nftrcreader reader(&templates ,scribusUserHome);
+	nftrcreader reader(&templates, QDir::toNativeSeparators(ScPaths::applicationDataDir()));
 
-	addTemplates(reader, scribusShare);
-	addTemplates(reader, scribusUserHome+"/templates");
-	QString userTemplateDir(PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates);
-	if (userTemplateDir.right(1) == "/")
-		userTemplateDir.chop(1);
-	if ((!userTemplateDir.isNull()) && (!userTemplateDir.isEmpty()))
-		addTemplates(reader, userTemplateDir);
+	addTemplates(reader, ScPaths::instance().templateDir());
+	addTemplates(reader, ScPaths::instance().userTemplateDir(true));
 }
 
 void nftsettings::addTemplates(nftrcreader& reader, QString dir) // dir will be searched for a sub folder called templates
 {
+	if (dir.isEmpty())
+		return;
 	// Add templates from the dir itself
 	QString tmplFile = findTemplateXml(dir);
 	QString tmplFilePath = QDir::toNativeSeparators(tmplFile);

Modified: trunk/Scribus/scribus/nftsettings.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21818&path=/trunk/Scribus/scribus/nftsettings.h
==============================================================================
--- trunk/Scribus/scribus/nftsettings.h	(original)
+++ trunk/Scribus/scribus/nftsettings.h	Sun Mar 12 17:49:03 2017
@@ -20,11 +20,9 @@
 #include "nfttemplate.h"
 #include "nftrcreader.h"
  
-class nftsettings {
+class nftsettings
+{
 private:
-	QString scribusShare;
-	QString scribusUserHome;
-	QString nftHomeDir;
 	QString lang;
 
 	void read();

Modified: trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21818&path=/trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.cpp	(original)
+++ trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.cpp	Sun Mar 12 17:49:03 2017
@@ -13,28 +13,24 @@
 nftsettings::nftsettings(QString guilang, QString templateDir)
 {
 	lang = guilang;
-	scribusShare = ScPaths::instance().templateDir();
-	scribusUserHome = QDir::toNativeSeparators(ScPaths::getApplicationDataDir());
-	userTemplateDir = templateDir;
-	if (userTemplateDir.right(1) == "/")
-		userTemplateDir = userTemplateDir.left(userTemplateDir.length() - 1);
+
 	read();
 }
 
 void nftsettings::read()
 {
-	handler = new nftrcreader(&templates,scribusUserHome);
+	handler = new nftrcreader(&templates, QDir::toNativeSeparators(ScPaths::getApplicationDataDir()));
 	reader = new QXmlSimpleReader();
 	reader->setContentHandler(handler);
 
-	addTemplates(scribusShare);
-	addTemplates(scribusUserHome+"/templates");
-	if ((!userTemplateDir.isNull()) && (!userTemplateDir.isEmpty()))
-		addTemplates(userTemplateDir);
+	addTemplates(ScPaths::instance().templateDir());
+	addTemplates(ScPaths::instance().userTemplateDir());
 }
 
 void nftsettings::addTemplates(QString dir) // dir will be searched for a sub folder called templates
 {
+	if (dir.isEmpty())
+		return;
 	// Add templates from the dir itself
 	QString tmplFile = findTemplateXml(dir);
 	QFile* tmplxml = new QFile(QDir::toNativeSeparators(tmplFile));

Modified: trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21818&path=/trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.h
==============================================================================
--- trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.h	(original)
+++ trunk/Scribus/scribus/plugins/newfromtemplateplugin/nftsettings.h	Sun Mar 12 17:49:03 2017
@@ -20,10 +20,7 @@
  
 class nftsettings {
 private:
-	QString scribusShare;
-	QString scribusUserHome;
-	QString userTemplateDir;
-	QString nftHomeDir;
+
 	QString lang;
 	nftrcreader* handler;
 	QXmlSimpleReader* reader;

Modified: trunk/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21818&path=/trunk/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp	(original)
+++ trunk/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp	Sun Mar 12 17:49:03 2017
@@ -122,12 +122,12 @@
 	QString currentFile(doc->DocName);
 	bool hasName = doc->hasName;
 	bool isModified = doc->isModified();
-	QString userTemplatesDir = PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates;
+	QString userTemplatesDir = ScPaths::instance().userTemplateDir(true);
 	PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
 	QString oldCollect = dirs->get("collect", ".");
 	QString templatesDir = ".";
 	if (userTemplatesDir.isEmpty())
-		templatesDir = ScPaths::applicationDataDir() + "templates";
+		templatesDir = ScPaths::instance().templateDir();
 	else
 	{
 		if (userTemplatesDir.right(1) == "/")




More information about the scribus-commit mailing list