[qet] [1456] Added method TitleBlockTemplate::saveToXmlFile().

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 1456
Author:   xavier
Date:     2012-01-12 07:47:02 +0100 (Thu, 12 Jan 2012)
Log Message:
-----------
Added method TitleBlockTemplate::saveToXmlFile().

Modified Paths:
--------------
    branches/0.3/sources/titleblocktemplate.cpp
    branches/0.3/sources/titleblocktemplate.h

Modified: branches/0.3/sources/titleblocktemplate.cpp
===================================================================
--- branches/0.3/sources/titleblocktemplate.cpp	2012-01-10 22:21:03 UTC (rev 1455)
+++ branches/0.3/sources/titleblocktemplate.cpp	2012-01-12 06:47:02 UTC (rev 1456)
@@ -118,8 +118,38 @@
 }
 
 /**
+	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.
-	@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
 */
 bool TitleBlockTemplate::saveToXmlElement(QDomElement &xml_element) const {

Modified: branches/0.3/sources/titleblocktemplate.h
===================================================================
--- branches/0.3/sources/titleblocktemplate.h	2012-01-10 22:21:03 UTC (rev 1455)
+++ branches/0.3/sources/titleblocktemplate.h	2012-01-12 06:47:02 UTC (rev 1456)
@@ -47,6 +47,7 @@
 	static QFont fontForCell(const TitleBlockCell &);
 	bool loadFromXmlFile(const QString &);
 	bool loadFromXmlElement(const QDomElement &);
+	bool saveToXmlFile(const QString &);
 	bool saveToXmlElement(QDomElement &) const;
 	TitleBlockTemplate *clone() const;
 	QString name() const;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/