bool Chaser::loadXML(const QDomElement& root) { if (root.tagName() != KXMLQLCFunction) { qWarning() << Q_FUNC_INFO << "Function node not found"; return false; } if (root.attribute(KXMLQLCFunctionType) != typeToString(Function::Chaser)) { qWarning() << Q_FUNC_INFO << root.attribute(KXMLQLCFunctionType) << "is not a chaser"; return false; } /* Load chaser contents */ QDomNode node = root.firstChild(); while (node.isNull() == false) { QDomElement tag = node.toElement(); if (tag.tagName() == KXMLQLCBus) { m_legacyHoldBus = tag.text().toUInt(); } else if (tag.tagName() == KXMLQLCFunctionSpeed) { loadXMLSpeed(tag); } else if (tag.tagName() == KXMLQLCFunctionDirection) { loadXMLDirection(tag); } else if (tag.tagName() == KXMLQLCFunctionRunOrder) { loadXMLRunOrder(tag); } else if (tag.tagName() == KXMLQLCChaserSpeedModes) { QString str; str = tag.attribute(KXMLQLCFunctionSpeedFadeIn); setFadeInMode(stringToSpeedMode(str)); str = tag.attribute(KXMLQLCFunctionSpeedFadeOut); setFadeOutMode(stringToSpeedMode(str)); str = tag.attribute(KXMLQLCFunctionSpeedDuration); setDurationMode(stringToSpeedMode(str)); } else if (tag.tagName() == KXMLQLCChaserSequenceTag) { QString str = tag.attribute(KXMLQLCChaserSequenceBoundScene); enableSequenceMode(str.toUInt()); if (tag.hasAttribute(KXMLQLCChaserSequenceStartTime)) setStartTime(tag.attribute(KXMLQLCChaserSequenceStartTime).toUInt()); if (tag.hasAttribute(KXMLQLCChaserSequenceColor)) setColor(QColor(tag.attribute(KXMLQLCChaserSequenceColor))); if (tag.hasAttribute(KXMLQLCChaserSequenceLocked)) setLocked(true); } else if (tag.tagName() == KXMLQLCFunctionStep) { //! @todo stepNumber is useless if the steps are in the wrong order ChaserStep step; int stepNumber = -1; if (step.loadXML(tag, stepNumber) == true) { if (isSequence() == true) step.fid = getBoundSceneID(); if (stepNumber >= m_steps.size()) m_steps.append(step); else m_steps.insert(stepNumber, step); } } else { qWarning() << Q_FUNC_INFO << "Unknown chaser tag:" << tag.tagName(); } node = node.nextSibling(); } return true; }
bool Chaser::loadXML(QXmlStreamReader &root) { if (root.name() != KXMLQLCFunction) { qWarning() << Q_FUNC_INFO << "Function node not found"; return false; } if (root.attributes().value(KXMLQLCFunctionType).toString() != typeToString(Function::Chaser)) { qWarning() << Q_FUNC_INFO << root.attributes().value(KXMLQLCFunctionType).toString() << "is not a chaser"; return false; } /* Load chaser contents */ while (root.readNextStartElement()) { if (root.name() == KXMLQLCBus) { m_legacyHoldBus = root.readElementText().toUInt(); } else if (root.name() == KXMLQLCFunctionSpeed) { loadXMLSpeed(root); } else if (root.name() == KXMLQLCFunctionDirection) { loadXMLDirection(root); } else if (root.name() == KXMLQLCFunctionRunOrder) { loadXMLRunOrder(root); } else if (root.name() == KXMLQLCChaserSpeedModes) { QXmlStreamAttributes attrs = root.attributes(); QString str; str = attrs.value(KXMLQLCFunctionSpeedFadeIn).toString(); setFadeInMode(stringToSpeedMode(str)); str = attrs.value(KXMLQLCFunctionSpeedFadeOut).toString(); setFadeOutMode(stringToSpeedMode(str)); str = attrs.value(KXMLQLCFunctionSpeedDuration).toString(); setDurationMode(stringToSpeedMode(str)); root.skipCurrentElement(); } else if (root.name() == KXMLQLCChaserSequenceTag) { QXmlStreamAttributes attrs = root.attributes(); QString str = attrs.value(KXMLQLCChaserSequenceBoundScene).toString(); enableSequenceMode(str.toUInt()); if (attrs.hasAttribute(KXMLQLCChaserSequenceStartTime)) setStartTime(attrs.value(KXMLQLCChaserSequenceStartTime).toString().toUInt()); if (attrs.hasAttribute(KXMLQLCChaserSequenceColor)) setColor(QColor(attrs.value(KXMLQLCChaserSequenceColor).toString())); if (attrs.hasAttribute(KXMLQLCChaserSequenceLocked)) setLocked(true); root.skipCurrentElement(); } else if (root.name() == KXMLQLCFunctionStep) { //! @todo stepNumber is useless if the steps are in the wrong order ChaserStep step; int stepNumber = -1; if (step.loadXML(root, stepNumber) == true) { if (isSequence() == true) step.fid = getBoundSceneID(); if (stepNumber >= m_steps.size()) m_steps.append(step); else m_steps.insert(stepNumber, step); } } else { qWarning() << Q_FUNC_INFO << "Unknown chaser tag:" << root.name(); root.skipCurrentElement(); } } return true; }