mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Added method TitleBlockTemplate::saveToXmlFile().
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1456 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
358aef7cf5
commit
a9e4d972b8
@ -117,9 +117,39 @@ bool TitleBlockTemplate::loadFromXmlElement(const QDomElement &xml_element) {
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Save the title block template into an XML file.
|
||||||
|
@param filepath The file path this title block template should be saved to.
|
||||||
|
@return true if the operation succeeds, false otherwise
|
||||||
|
*/
|
||||||
|
bool TitleBlockTemplate::saveToXmlFile(const QString &filepath) {
|
||||||
|
if (filepath.isEmpty()) return(false);
|
||||||
|
|
||||||
|
// open the file
|
||||||
|
QFile xml_file(filepath);
|
||||||
|
if (!xml_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate the XML document
|
||||||
|
QDomDocument doc;
|
||||||
|
QDomElement e = doc.createElement("root");
|
||||||
|
bool saving = saveToXmlElement(e);
|
||||||
|
if (!saving) return(false);
|
||||||
|
doc.appendChild(e);
|
||||||
|
|
||||||
|
// write the file
|
||||||
|
QTextStream out(&xml_file);
|
||||||
|
out.setCodec("UTF-8");
|
||||||
|
out << doc.toString(4);
|
||||||
|
xml_file.close();
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Save the title block template as XML.
|
Save the title block template as XML.
|
||||||
@param xml_element The XMl element this title block template should be saved to.
|
@param xml_element The XML element this title block template should be saved to.
|
||||||
@return true if the export succeeds, false otherwise
|
@return true if the export succeeds, false otherwise
|
||||||
*/
|
*/
|
||||||
bool TitleBlockTemplate::saveToXmlElement(QDomElement &xml_element) const {
|
bool TitleBlockTemplate::saveToXmlElement(QDomElement &xml_element) const {
|
||||||
|
@ -47,6 +47,7 @@ class TitleBlockTemplate : public QObject {
|
|||||||
static QFont fontForCell(const TitleBlockCell &);
|
static QFont fontForCell(const TitleBlockCell &);
|
||||||
bool loadFromXmlFile(const QString &);
|
bool loadFromXmlFile(const QString &);
|
||||||
bool loadFromXmlElement(const QDomElement &);
|
bool loadFromXmlElement(const QDomElement &);
|
||||||
|
bool saveToXmlFile(const QString &);
|
||||||
bool saveToXmlElement(QDomElement &) const;
|
bool saveToXmlElement(QDomElement &) const;
|
||||||
TitleBlockTemplate *clone() const;
|
TitleBlockTemplate *clone() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user