8#include "XmlStackedHandlerReader.h"
35 xmlReader->pushContentHandler(
new XmlHandler(
this, templateFolder));
60 return m_templateType;
89 if (!QFile::remove(m_fileName)) {
91 tr(
"Could not remove file [%1]").arg(m_fileName),
107 stream.writeStartElement(
"template");
108 stream.writeAttribute(
"fileName",
FileName(m_fileName).name());
109 stream.writeAttribute(
"templateType", m_templateType);
110 stream.writeAttribute(
"importName", m_importName);
111 stream.writeEndElement();
142 const QString &qName,
const QXmlAttributes &atts) {
143 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
144 if (localName ==
"template") {
145 QString
fileName = atts.value(
"fileName");
147 QString
importName = atts.value(
"importName");
150 m_xmlHandlerTemplate->m_fileName = m_xmlHandlerTemplateFolderName.expanded()
161 m_xmlHandlerTemplate->m_importName =
importName;
File name manipulation and expansion.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
@ Io
A type of error that occurred when performing an actual I/O operation.
The main project for ipce.
static QString templateRoot(QString projectRoot)
Appends the root directory name 'templates' to the project .
FileName m_xmlHandlerTemplateFolderName
The name of the folder for the template xml.
Template * m_xmlHandlerTemplate
A pointer to the Template object to be read or written.
XmlHandler(Template *currentTemplate, FileName templateFolder)
Constructor for the Template object's XmlHandler.
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Method to read the given XML formatted attribute for a Template object into the XmlHandler.
Template(QString fileName, QString templateType, QString importName, QObject *parent=0)
Create a Template from template file's name.
QString fileName() const
Get the file name that this Template represents.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Method to write this Template object's member data to an XML stream.
QString templateType() const
Get the type of template.
void deleteFromDisk()
Delete the template from disk.
~Template()
Destroys Template object.
void updateFileName(Project *project)
Change the file name for this template to be where it now is with the given project.
QString importName() const
Get the name of the TemplateList this file was imported under.
Manage a stack of content handlers for reading XML files.
This is free and unencumbered software released into the public domain.