예제 #1
0
bool RGBImage::loadXML(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCRGBAlgorithm)
    {
        qWarning() << Q_FUNC_INFO << "RGB Algorithm node not found";
        return false;
    }

    if (root.attribute(KXMLQLCRGBAlgorithmType) != KXMLQLCRGBImage)
    {
        qWarning() << Q_FUNC_INFO << "RGB Algorithm is not Image";
        return false;
    }

    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();
        if (tag.tagName() == KXMLQLCRGBImageFilename)
        {
            setFilename(doc()->denormalizeComponentPath(tag.text()));
        }
        else if (tag.tagName() == KXMLQLCRGBImageAnimationStyle)
        {
            setAnimationStyle(stringToAnimationStyle(tag.text()));
        }
        else if (tag.tagName() == KXMLQLCRGBImageOffset)
        {
            QString str;
            int value;
            bool ok;

            str = tag.attribute(KXMLQLCRGBImageOffsetX);
            ok = false;
            value = str.toInt(&ok);
            if (ok == true)
                setXOffset(value);
            else
                qWarning() << Q_FUNC_INFO << "Invalid X offset:" << str;

            str = tag.attribute(KXMLQLCRGBImageOffsetY);
            ok = false;
            value = str.toInt(&ok);
            if (ok == true)
                setYOffset(value);
            else
                qWarning() << Q_FUNC_INFO << "Invalid Y offset:" << str;
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown RGBImage tag:" << tag.tagName();
        }

        node = node.nextSibling();
    }

    return true;
}
예제 #2
0
bool RGBImage::loadXML(QXmlStreamReader &root)
{
    if (root.name() != KXMLQLCRGBAlgorithm)
    {
        qWarning() << Q_FUNC_INFO << "RGB Algorithm node not found";
        return false;
    }

    if (root.attributes().value(KXMLQLCRGBAlgorithmType).toString() != KXMLQLCRGBImage)
    {
        qWarning() << Q_FUNC_INFO << "RGB Algorithm is not Image";
        return false;
    }

    while (root.readNextStartElement())
    {
        if (root.name() == KXMLQLCRGBImageFilename)
        {
            setFilename(doc()->denormalizeComponentPath(root.readElementText()));
        }
        else if (root.name() == KXMLQLCRGBImageAnimationStyle)
        {
            setAnimationStyle(stringToAnimationStyle(root.readElementText()));
        }
        else if (root.name() == KXMLQLCRGBImageOffset)
        {
            QString str;
            int value;
            bool ok;
            QXmlStreamAttributes attrs = root.attributes();

            str = attrs.value(KXMLQLCRGBImageOffsetX).toString();
            ok = false;
            value = str.toInt(&ok);
            if (ok == true)
                setXOffset(value);
            else
                qWarning() << Q_FUNC_INFO << "Invalid X offset:" << str;

            str = attrs.value(KXMLQLCRGBImageOffsetY).toString();
            ok = false;
            value = str.toInt(&ok);
            if (ok == true)
                setYOffset(value);
            else
                qWarning() << Q_FUNC_INFO << "Invalid Y offset:" << str;
            root.skipCurrentElement();
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown RGBImage tag:" << root.name();
            root.skipCurrentElement();
        }
    }

    return true;
}
예제 #3
0
파일: rgbtext.cpp 프로젝트: OnceBe/qlcplus
bool RGBText::loadXML(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCRGBAlgorithm)
    {
        qWarning() << Q_FUNC_INFO << "RGB Algorithm node not found";
        return false;
    }

    if (root.attribute(KXMLQLCRGBAlgorithmType) != KXMLQLCRGBText)
    {
        qWarning() << Q_FUNC_INFO << "RGB Algorithm is not Text";
        return false;
    }

    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();
        if (tag.tagName() == KXMLQLCRGBTextContent)
        {
            setText(tag.text());
        }
        else if (tag.tagName() == KXMLQLCRGBTextFont)
        {
            QFont font;
            if (font.fromString(tag.text()) == true)
                setFont(font);
            else
                qWarning() << Q_FUNC_INFO << "Invalid font:" << tag.text();
        }
        else if (tag.tagName() == KXMLQLCRGBTextAnimationStyle)
        {
            setAnimationStyle(stringToAnimationStyle(tag.text()));
        }
        else if (tag.tagName() == KXMLQLCRGBTextOffset)
        {
            QString str;
            int value;
            bool ok;

            str = tag.attribute(KXMLQLCRGBTextOffsetX);
            ok = false;
            value = str.toInt(&ok);
            if (ok == true)
                setXOffset(value);
            else
                qWarning() << Q_FUNC_INFO << "Invalid X offset:" << str;

            str = tag.attribute(KXMLQLCRGBTextOffsetY);
            ok = false;
            value = str.toInt(&ok);
            if (ok == true)
                setYOffset(value);
            else
                qWarning() << Q_FUNC_INFO << "Invalid Y offset:" << str;
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown RGBText tag:" << tag.tagName();
        }

        node = node.nextSibling();
    }

    return true;
}