Title block templates now embed a free field for extra information.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1541 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-03-02 17:55:27 +00:00
parent fac0fea239
commit 6bdd166e57
6 changed files with 160 additions and 4 deletions

View File

@@ -111,6 +111,7 @@ bool TitleBlockTemplate::loadFromXmlElement(const QDomElement &xml_element) {
}
name_ = xml_element.attribute("name");
loadInformation(xml_element);
loadLogos(xml_element, true);
loadGrid(xml_element);
@@ -158,6 +159,7 @@ bool TitleBlockTemplate::saveToXmlElement(QDomElement &xml_element) const {
xml_element.setTagName("titleblocktemplate");
xml_element.setAttribute("name", name_);
saveInformation(xml_element);
saveLogos(xml_element);
saveGrid(xml_element);
return(true);
@@ -170,6 +172,7 @@ bool TitleBlockTemplate::saveToXmlElement(QDomElement &xml_element) const {
TitleBlockTemplate *TitleBlockTemplate::clone() const {
TitleBlockTemplate *copy = new TitleBlockTemplate();
copy -> name_ = name_;
copy -> information_ = information_;
// this does not really duplicates pixmaps, only the objects that hold a key to the implicitly shared pixmaps
foreach (QString logo_key, bitmap_logos_.keys()) {
@@ -214,6 +217,17 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const {
return(copy);
}
/**
Import text informations from a given XML title block template.
*/
void TitleBlockTemplate::loadInformation(const QDomElement &xml_element) {
for (QDomNode n = xml_element.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
if (n.isElement() && n.toElement().tagName() == "information") {
setInformation(n.toElement().text());
}
}
}
/**
Import the logos from a given XML titleblock template.
@param xml_element An XML element representing an titleblock template.
@@ -453,6 +467,18 @@ void TitleBlockTemplate::loadCell(const QDomElement &cell_element) {
}
}
/**
Export this template's extra information.
@param xml_element XML element under which extra informations will be attached
*/
void TitleBlockTemplate::saveInformation(QDomElement &xml_element) const {
QDomNode information_text_node = xml_element.ownerDocument().createTextNode(information());
QDomElement information_element = xml_element.ownerDocument().createElement("information");
information_element.appendChild(information_text_node);
xml_element.appendChild(information_element);
}
/**
Export this template's logos as XML
@param xml_element XML Element under which the \<logos\> element will be attached
@@ -689,6 +715,20 @@ QString TitleBlockTemplate::name() const {
return(name_);
}
/**
@return the information field attached to this template
*/
QString TitleBlockTemplate::information() const {
return(information_);
}
/**
@param info information to be attached to this template
*/
void TitleBlockTemplate::setInformation(const QString &info) {
information_ = info;
}
/**
@param i row index
@return the height of the row at index i