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; } } } }
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; } } } }
bool Manager::add(const QUrl &templateSourceURL, const QString &name, const QUrl &icon) { KileDocument::Extensions *extensions = m_kileInfo->extensions(); KileDocument::Type type = extensions->determineDocumentType(templateSourceURL); return add(templateSourceURL, type, name, icon); }