void LayerVector::loadDomElement(QDomElement element, QString dataDirPath) { if (!element.attribute("id").isNull()) id = element.attribute("id").toInt(); name = element.attribute("name"); visible = (element.attribute("visibility") == "1"); m_eType = static_cast<LAYER_TYPE>( element.attribute( "type" ).toInt( ) ); QDomNode imageTag = element.firstChild(); while (!imageTag.isNull()) { QDomElement imageElement = imageTag.toElement(); if (!imageElement.isNull()) { if (imageElement.tagName() == "image") { if (!imageElement.attribute("src").isNull()) { QString path = dataDirPath +"/" + imageElement.attribute("src"); // the file is supposed to be in the data irectory //qDebug() << "LAY_VECTOR dataDirPath=" << dataDirPath << " ;path=" << path; //added for debugging puproses QFileInfo fi(path); if (!fi.exists()) path = imageElement.attribute("src"); int position = imageElement.attribute("frame").toInt(); loadImageAtFrame( path, position ); } else { int frame = imageElement.attribute("frame").toInt(); addImageAtFrame( frame ); getVectorImageAtFrame( frame )->loadDomElement(imageElement); } } } imageTag = imageTag.nextSibling(); } }
void LayerVector::loadDomElement(QDomElement element, QString filePath) { if(!element.attribute("id").isNull()) id = element.attribute("id").toInt(); name = element.attribute("name"); visible = (element.attribute("visibility") == "1"); type = element.attribute("type").toInt(); QDomNode imageTag = element.firstChild(); while(!imageTag.isNull()) { QDomElement imageElement = imageTag.toElement(); if(!imageElement.isNull()) { if(imageElement.tagName() == "image") { if(!imageElement.attribute("src").isNull()) { QString path = filePath +".data/" + imageElement.attribute("src"); // the file is supposed to be in the data irectory QFileInfo fi(path); if(!fi.exists()) path = imageElement.attribute("src"); int position = imageElement.attribute("frame").toInt(); loadImageAtFrame( path, position ); } else { int frame = imageElement.attribute("frame").toInt(); addImageAtFrame( frame ); getVectorImageAtFrame( frame )->loadDomElement(imageElement); } } } imageTag = imageTag.nextSibling(); } }