Esempio n. 1
0
void SATDialog::addCategories(const QString& dir)
{
	// Read categories from the dir itself
	QString tmplFile = findTemplateXml(dir);
	if (QFile::exists(tmplFile))
		readCategories(tmplFile);

	// And from all the subdirectories. template.xml file is only searched one dir level deeper than the dir
	QDir tmpldir(dir);
	if (tmpldir.exists())
	{
		tmpldir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
		QStringList dirs = tmpldir.entryList();
		for (int i = 0; i < dirs.size(); ++i)
		{
			tmplFile = findTemplateXml(dir + "/" + dirs[i]);
			if (QFile::exists(tmplFile))
				readCategories(tmplFile);
		}
	}
}
void nftsettings::addTemplates(QString dir) // dir will be searched for a sub folder called templates
{
	// Add templates from the dir itself
	QString tmplFile = findTemplateXml(dir);
	QFile* tmplxml = new QFile(QDir::toNativeSeparators(tmplFile));
	handler->setSourceDir(dir);
	handler->setSourceFile(tmplFile);
	if (tmplxml->exists())
	{
		QXmlInputSource* source = new QXmlInputSource(tmplxml);
		reader->parse(source);
		delete source;
	}
	delete tmplxml;
	
	
	// And from all the subdirectories. template.xml file is only searched one dir level deeper than the dir
	QDir tmpldir(dir);
	if (tmpldir.exists())
	{
		tmpldir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
		QStringList dirs = tmpldir.entryList();
		for (int i = 0; i < dirs.size(); ++i)
		{
			tmplFile = findTemplateXml(dir + "/" + dirs[i]);
			QFile* tmplxml = new QFile(QDir::toNativeSeparators(tmplFile));
			handler->setSourceDir(dir+"/"+dirs[i]);
			handler->setSourceFile(tmplFile);
			if (tmplxml->exists())
			{
				QXmlInputSource* source = new QXmlInputSource(tmplxml);
				reader->parse(source);
				delete source;
			}
			delete tmplxml;
		}
	}
}