Isis 3 Programmer Reference
Template.cpp
1#include "Template.h"
2
3#include <QFile>
4
5#include "FileName.h"
6#include "IException.h"
7#include "Project.h"
8
9namespace Isis{
18 Template::Template(QString fileName, QString templateType, QString importName, QObject *parent) : QObject(parent) {
19 m_fileName = fileName;
20 m_templateType = templateType;
21 m_importName = importName;
22
23 }
24
32 Template::Template(FileName templateFolder, QXmlStreamReader *xmlReader, QObject *parent) :
33 QObject(parent) {
34 // readTemplate(xmlReader);
35 }
36
37
43
44
49 QString Template::fileName() const {
50 return m_fileName;
51 }
52
53
58 QString Template::templateType() const {
59 return m_templateType;
60 }
61
62
67 QString Template::importName() const {
68 return m_importName;
69 }
70
71
78 m_fileName = project->templateRoot() + "/" + m_templateType + "/" + m_importName +"/" + FileName(m_fileName).name();
79 }
80
81
88 if (!QFile::remove(m_fileName)) {
90 tr("Could not remove file [%1]").arg(m_fileName),
91 _FILEINFO_);
92 }
93 }
94
95
104 void Template::save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot)
105 const {
106 stream.writeStartElement("template");
107 stream.writeAttribute("fileName", FileName(m_fileName).name());
108 stream.writeAttribute("templateType", m_templateType);
109 stream.writeAttribute("importName", m_importName);
110 stream.writeEndElement();
111
112 }
113}
File name manipulation and expansion.
Definition FileName.h:100
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
Definition FileName.cpp:162
Isis exception class.
Definition IException.h:91
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition IException.h:155
The main project for ipce.
Definition Project.h:287
static QString templateRoot(QString projectRoot)
Appends the root directory name 'templates' to the project .
Definition Project.cpp:2186
Template(QString fileName, QString templateType, QString importName, QObject *parent=0)
Create a Template from template file's name.
Definition Template.cpp:18
QString fileName() const
Get the file name that this Template represents.
Definition Template.cpp:49
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Method to write this Template object's member data to an XML stream.
Definition Template.cpp:104
QString templateType() const
Get the type of template.
Definition Template.cpp:58
void deleteFromDisk()
Delete the template from disk.
Definition Template.cpp:87
~Template()
Destroys Template object.
Definition Template.cpp:41
void updateFileName(Project *project)
Change the file name for this template to be where it now is with the given project.
Definition Template.cpp:77
QString importName() const
Get the name of the TemplateList this file was imported under.
Definition Template.cpp:67
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16