for (int i = 0; i < attributes.count(); i++) {
QString name = attributes.item(i).nodeName();
if (name.startsWith("meta.attr.")) {
- m_metadata.insert(name.section('.', 2, 3), attributes.item(i).nodeValue());
+ m_metadata.insert(name.section('.', 2), attributes.item(i).nodeValue());
} else m_properties.insert(name, attributes.item(i).nodeValue());
}
+ QDomNodeList metas = xml.elementsByTagName("metaproperty");
+ for (int i = 0; i < metas.count(); i++) {
+ QDomElement e = metas.item(i).toElement();
+ if (!e.isNull()) {
+ m_metadata.insert(e.attribute("name").section('.', 2), e.firstChild().nodeValue());
+ }
+ }
if (xml.hasAttribute("cutzones")) {
QStringList cuts = xml.attribute("cutzones").split(';', QString::SkipEmptyParts);
if (hideTemporaryProperties && i.key().startsWith('_')) continue;
if (!i.value().isEmpty()) clip.setAttribute(i.key(), i.value());
}
+
QMapIterator<QString, QString> j(m_metadata);
+ // Metadata name can have special chars so we cannot pass it as simple attribute
while (j.hasNext()) {
j.next();
- if (!j.value().isEmpty()) clip.setAttribute("meta.attr." + j.key(), j.value());
+ if (!j.value().isEmpty()) {
+ QDomElement property = doc.createElement("metaproperty");
+ property.setAttribute("name", "meta.attr." + j.key());
+ QDomText value = doc.createTextNode(j.value());
+ property.appendChild(value);
+ clip.appendChild(property);
+ }
}
doc.appendChild(clip);
if (!m_cutZones.isEmpty()) {
else {
QFile file(tmpFile);
QString errorMsg;
+ int line;
+ int col;
QDomImplementation::setInvalidDataPolicy(QDomImplementation::DropInvalidChars);
- success = m_document.setContent(&file, false, &errorMsg);
+ success = m_document.setContent(&file, false, &errorMsg, &line, &col);
file.close();
KIO::NetAccess::removeTempFile(tmpFile);
if (!success) {
// It is corrupted
- if (KMessageBox::warningContinueCancel(parent, i18n("Cannot open the project file, error is:\n%1\nDo you want to open a backup file?", errorMsg), i18n("Error opening file"), KGuiItem(i18n("Open Backup"))) == KMessageBox::Continue) {
+ if (KMessageBox::warningContinueCancel(parent, i18n("Cannot open the project file, error is:\n%1 (line %2, col %3)\nDo you want to open a backup file?", errorMsg, line, col), i18n("Error opening file"), KGuiItem(i18n("Open Backup"))) == KMessageBox::Continue) {
*openBackup = true;
}
//KMessageBox::error(parent, errorMsg);
QMap<QString, QString> meta;
for (QDomNode m = orig.firstChild(); !m.isNull(); m = m.nextSibling()) {
QString name = m.toElement().attribute("name");
- if (name.startsWith("meta.attr"))
+ if (name.startsWith("meta.attr")) {
+ if (name.endsWith(".markup")) name = name.section('.', 0, -2);
meta.insert(name.section('.', 2, -1), m.firstChild().nodeValue());
+ }
}
if (!meta.isEmpty()) {
if (clip == NULL)
for (int i = 0; i < count; i ++) {
QString name = metadata.get_name(i);
QString value = QString::fromUtf8(metadata.get(i));
- if (name.endsWith("markup") && !value.isEmpty())
+ if (name.endsWith(".markup") && !value.isEmpty())
metadataPropertyMap[ name.section('.', 0, -2)] = value;
}
producer->seek(0);