Reading and writing of project title now restored.

Note that we still need to decide if the project title is stored as an
attribute of <qgis> or as a separate text node in <title>.  Currently
redundantly storing project title in both for backward compatibility, but only
relying on <title> for reading.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2176 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mcoletti 2004-10-26 19:03:00 +00:00
parent 71b0638251
commit 2fb77fe376

View File

@ -272,6 +272,9 @@ _getMapUnits( QDomDocument const & doc )
XML in file has this form:
<qgis projectname="default project">
<title>a project title</title>
@todo XXX we should go with the attribute xor <title>, not both.
*/
static
void
@ -279,10 +282,31 @@ _getTitle( QDomDocument const & doc, QString & title )
{
QDomNodeList nl = doc.elementsByTagName("title");
QDomNode node = nl.item(0); // there should only be one, so zeroth element ok
QDomElement element = node.toElement();
if ( ! nl.count() )
{
qDebug( "%s : %s %s", __FILE__ , __LINE__, " unable to find title element\n" );
return;
}
title = element.attribute("projectname");
QDomNode titleNode = nl.item(0); // there should only be one, so zeroth element ok
if ( ! titleNode.hasChildNodes() ) // if not, then there's no actual text
{
qDebug( "%s : %s %s", __FILE__ , __LINE__, " unable to find title element\n" );
return;
}
QDomNode titleTextNode = titleNode.firstChild(); // should only have on child
if ( ! titleTextNode.isText() )
{
qDebug( "%s : %s %s", __FILE__ , __LINE__, " unable to find title element\n" );
return;
}
QDomText titleText = titleTextNode.toText();
title = titleText.data();
} // _getTitle