Esempio n. 1
0
void Manager::scanForTemplates() {
	KILE_DEBUG() << "===scanForTemplates()===================" << endl;
	QStringList dirs = KGlobal::dirs()->findDirs("appdata", "templates");
	QDir templates;
	KileTemplate::Info ti;
	KileDocument::Extensions *extensions = m_kileInfo->extensions();

	m_TemplateList.clear();
	for ( QValueListIterator<QString> i = dirs.begin(); i != dirs.end(); ++i)
	{
		templates = QDir(*i, "template_*");
		for ( uint j = 0; j< templates.count(); ++j)
		{
			ti.path = templates.path() + '/' + templates[j];
			QFileInfo fileInfo(ti.path);
			ti.name = fileInfo.baseName(true).mid(9); //remove "template_", do it this way to avoid problems with user input!
			ti.type = extensions->determineDocumentType(KURL::fromPathOrURL(ti.path));
			ti.icon = KGlobal::dirs()->findResource("appdata","pics/type_" + ti.name + extensions->defaultExtensionForDocumentType(ti.type) + ".kileicon");
			if (m_TemplateList.contains(ti))
			{
				KILE_DEBUG() << "\tignoring: " << ti.path << endl;
			}
			else
			{
				m_TemplateList.append(ti);
				KILE_DEBUG() << "\tadding: " << ti.name << " " << ti.path << endl;
			}
		}
	}
}
Esempio n. 2
0
void Manager::scanForTemplates() {
	KILE_DEBUG_MAIN << "===scanForTemplates()===================";
	QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation, "templates", QStandardPaths::LocateDirectory);
	QDir templates;
	KileTemplate::Info ti;
	KileDocument::Extensions *extensions = m_kileInfo->extensions();

	m_TemplateList.clear();
	for(QStringList::iterator i = dirs.begin(); i != dirs.end(); ++i) {
		templates = QDir(*i, "template_*");
		for (uint j = 0; j < templates.count(); ++j) {
			ti.path = templates.path() + '/' + templates[j];
			QFileInfo fileInfo(ti.path);
			ti.name = fileInfo.completeBaseName().mid(9); //remove "template_", do it this way to avoid problems with user input!
			ti.type = extensions->determineDocumentType(QUrl::fromUserInput(ti.path));
			ti.icon = QStandardPaths::locate(QStandardPaths::DataLocation, "pics/type_" + ti.name + extensions->defaultExtensionForDocumentType(ti.type) + ".kileicon");
			if (m_TemplateList.contains(ti)) {
				KILE_DEBUG_MAIN << "\tignoring: " << ti.path;
			}
			else {
				m_TemplateList.append(ti);
				KILE_DEBUG_MAIN << "\tadding: " << ti.name << " " << ti.path;
			}
		}
	}
}
Esempio n. 3
0
bool Manager::add(const QUrl &templateSourceURL, KileDocument::Type type, const QString &name, const QUrl &icon) {
	KileDocument::Extensions *extensions = m_kileInfo->extensions();
	QString extension = extensions->defaultExtensionForDocumentType(type);

	return copyAppData(templateSourceURL, "templates", "template_" + name + extension) && copyAppData(icon, "pics", "type_" + name + extension + ".kileicon");
}