Пример #1
0
void tst_QXmlItem::copyConstructorFromQXmlNodeModelIndex() const
{
    // TODO copy a valid model index.

    /* Construct from a null QXmlNodeModelIndex. */
    {
        const QXmlItem item((QXmlNodeModelIndex()));
        QVERIFY(item.isNull());
    }
}
Пример #2
0
void tst_QXmlItem::toNodeModelIndex() const
{
    /* Check default value. */
    {
        const QXmlItem item;
        QVERIFY(item.toNodeModelIndex().isNull());
    }

    /* On valid atomic value. */
    {
        const QXmlItem item(QVariant(3));
        QVERIFY(item.toNodeModelIndex().isNull());
    }

    /* On a QXmlItem constructed from a null QVariant. */
    {
        const QXmlItem item((QVariant()));
        QVERIFY(item.isNull());
    }

    /* On a QXmlItem constructed from a null QXmlNodeModelIndex. */
    {
        const QXmlItem item((QXmlNodeModelIndex()));
        QVERIFY(item.isNull());
    }
}
Пример #3
0
void tst_QXmlItem::isAtomicValue() const
{
    /* Check default value. */
    {
        const QXmlItem item;
        QVERIFY(!item.isAtomicValue());
    }

    /* On valid atomic value. */
    {
        const QXmlItem item(QVariant(3));
        QVERIFY(item.isAtomicValue());
    }

    // TODO on valid node index

    /* On a QXmlItem constructed from a null QVariant. */
    {
        const QXmlItem item((QVariant()));
        QVERIFY(!item.isAtomicValue());
    }

    /* On a QXmlItem constructed from a null QXmlNodeModelIndex. */
    {
        const QXmlItem item((QXmlNodeModelIndex()));
        QVERIFY(!item.isAtomicValue());
    }
}
Пример #4
0
void tst_QXmlItem::copyConstructorFromQVariant() const
{
    /* Construct & destruct a single value. */
    {
        const QXmlItem item(QVariant(QString::fromLatin1("dummy")));
    }

    /* Copy a null QVariant. */
    {
        const QXmlItem item((QVariant()));
        QVERIFY(item.isNull());
    }

}
Пример #5
0
ItemType::Ptr AtomicValue::qtToXDMType(const QXmlItem &item)
{
    Q_ASSERT(!item.isNull());

    if(item.isNull())
        return ItemType::Ptr();

    if(item.isNode())
        return BuiltinTypes::node;

    Q_ASSERT(item.isAtomicValue());
    const QVariant v(item.toAtomicValue());

    switch(int(v.type()))
    {
        case QVariant::Char:
        /* Fallthrough. */
        case QVariant::String:
        /* Fallthrough. */
        case QVariant::Url:
            return BuiltinTypes::xsString;
        case QVariant::Bool:
            return BuiltinTypes::xsBoolean;
        case QVariant::ByteArray:
            return BuiltinTypes::xsBase64Binary;
        case QVariant::Int:
        /* Fallthrough. */
        case QVariant::LongLong:
            return BuiltinTypes::xsInteger;
        case QVariant::ULongLong:
            return BuiltinTypes::xsUnsignedLong;
        case QVariant::Date:
            return BuiltinTypes::xsDate;
        case QVariant::DateTime:
        /* Fallthrough. */
        case QVariant::Time:
            return BuiltinTypes::xsDateTime;
        case QMetaType::Float:
	    return BuiltinTypes::xsFloat;
        case QVariant::Double:
            return BuiltinTypes::xsDouble;
        default:
            return ItemType::Ptr();
    }
}
static PyObject *meth_QXmlItem_isNull(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QXmlItem *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QXmlItem, &sipCpp))
        {
            bool sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->isNull();
            Py_END_ALLOW_THREADS

            return PyBool_FromLong(sipRes);
        }
    }
Presets *PtzManagement::getPresets()
{
    Presets *presets = NULL;
    Message *msg = newMessage();
    QDomElement getPresets = newElement("wsdl:GetPresets");
    QDomElement profileToken = newElement("wsdl:ProfileToken","profile_CIF");
    getPresets.appendChild(profileToken);
    msg->appendToBody(getPresets);
    MessageParser *result = sendMessage(msg);
    if(result != NULL){
        presets = new Presets();
        QXmlQuery *query = result->query();
        QXmlResultItems items;
        QXmlItem item;
        QString value,xml;
        QDomDocument doc;
        QDomNodeList itemNodeList;
        QDomNode node;
        query->setQuery(result->nameSpace()+"doc($inputDocument)//tptz:Preset");
        query->evaluateTo(&items);
        item = items.next();
        while(!item.isNull()){
            query->setFocus(item);
            query->setQuery(result->nameSpace()+".");
            query->evaluateTo(&xml);
            doc.setContent(xml);
            itemNodeList = doc.elementsByTagName("tptz:Preset");
            for(int i=0; i<itemNodeList.size(); i++)
            {
                node = itemNodeList.at(i);
                value = node.toElement().attribute("token");
                presets->setToken(value.trimmed());
            }
            query->setQuery(result->nameSpace()+"./tt:Name/string()");
            query->evaluateTo(&value);
            presets->setName(value.trimmed());
            item = items.next();
        }
    }
    delete msg;
    delete result;
    return presets;
}
Пример #8
0
bool setFocusHelper(QXmlQuery *const queryInstance,
                    const TInputType &focusValue)
{
    /* We call resourceLoader(), so we have ensured that we have a resourceLoader
     * that we will share in our copy. */
    queryInstance->d->resourceLoader();

    QXmlQuery focusQuery(*queryInstance);

    /* Now we use the same, so we own the loaded document. */
    focusQuery.d->m_resourceLoader = queryInstance->d->m_resourceLoader;

    /* The copy constructor doesn't allow us to copy an existing QXmlQuery and
     * changing the language at the same time so we need to use private API. */
    focusQuery.d->queryLanguage = QXmlQuery::XQuery10;

    Q_ASSERT(focusQuery.queryLanguage() == QXmlQuery::XQuery10);
    focusQuery.bindVariable(QChar::fromLatin1('u'), focusValue);
    focusQuery.setQuery(QLatin1String("doc($u)"));
    Q_ASSERT(focusQuery.isValid());

    QXmlResultItems focusResult;

    queryInstance->d->m_resourceLoader = focusQuery.d->m_resourceLoader;

    focusQuery.evaluateTo(&focusResult);
    const QXmlItem focusItem(focusResult.next());

    if(focusItem.isNull() || focusResult.hasError())
    {
        /* The previous focus must be cleared in error situations.
         * Otherwise the query may be left in an inconsistent state. */
        queryInstance->setFocus(QXmlItem());
        return false;
    }
    else
    {
        queryInstance->setFocus(focusItem);
        return true;
    }
}
Пример #9
0
/*!
  Check that the functions that should be const, are.
 */
void tst_QXmlItem::constCorrectness() const
{
    const QXmlItem item;
    item.isNull();
    item.isNode();
    item.isAtomicValue();

    item.toAtomicValue();
    item.toNodeModelIndex();
}
Пример #10
0
/*!
  Binds the variable \a name to the \a value so that $\a name can be
  used from within the query to refer to the \a value.

  \a name must not be \e null. \a {name}.isNull() must return false.
  If \a name has already been bound by a previous bindVariable() call,
  its previous binding will be overridden.

  If \a {value} is null so that \a {value}.isNull() returns true, and
  \a {name} already has a binding, the effect is to remove the
  existing binding for \a {name}.

  To bind a value of type QString or QUrl, wrap the value in a
  QVariant such that QXmlItem's QVariant constructor is called.

  All strings processed by the query must be valid XQuery strings,
  which means they must contain only XML 1.0 characters. However,
  this requirement is not checked. If the query processes an invalid
  string, the behavior is undefined.

  \sa QVariant::isValid(), {QtXDM}{How QVariant maps to XQuery's Data Model},
   QXmlItem::isNull()
 */
void QXmlQuery::bindVariable(const QXmlName &name, const QXmlItem &value)
{
    if(name.isNull())
    {
        qWarning("The variable name cannot be null.");
        return;
    }

    const QPatternist::VariableLoader::Ptr vl(d->variableLoader());
    const QVariant variant(QVariant::fromValue(value));

    /* If the type of the variable changed(as opposed to only the value),
     * we will have to recompile. */
    if(vl->invalidationRequired(name, variant) || value.isNull())
        d->recompileRequired();

    vl->addBinding(name, variant);
}
Пример #11
0
TestResult::List TestCase::execute(const ExecutionStage stage)
{
    ErrorHandler errHandler;
    ErrorHandler::installQtMessageHandler(&errHandler);

    pDebug() << "TestCase::execute()";
    delete m_result;

    QXmlQuery query(language(), Global::namePoolAsPublic());

    query.d->setExpressionFactory(s_exprFact);
    query.setInitialTemplateName(initialTemplateName());

    QXmlQuery openDoc(query.namePool());

    if(contextItemSource().isValid())
    {
        openDoc.setQuery(QString::fromLatin1("doc('") + contextItemSource().toString() + QLatin1String("')"));
        Q_ASSERT(openDoc.isValid());
        QXmlResultItems result;

        openDoc.evaluateTo(&result);
        const QXmlItem item(result.next());
        Q_ASSERT(!item.isNull());
        query.setFocus(item);
    }

    TestResult::List retval;

    const Scenario scen(scenario());
    TestResult::Status resultStatus = TestResult::Unknown;

    bool ok = false;
    const QString queryString(sourceCode(ok));

    if(!ok)
    {
        /* Loading the query file failed, or similar. */
        resultStatus = TestResult::Fail;

        m_result = new TestResult(name(), resultStatus, s_exprFact->astTree(),
                                  errHandler.messages(), QPatternist::Item::List(), QString());
        retval.append(m_result);
        ErrorHandler::installQtMessageHandler(0);
        changed(this);
        return retval;
    }

    query.setMessageHandler(&errHandler);
    QXmlNamePool namePool(query.namePool());

    /* Bind variables. */
    QPatternist::ExternalVariableLoader::Ptr loader(externalVariableLoader());
    if(loader)
    {
        Q_ASSERT(loader);
        const ExternalSourceLoader::VariableMap vMap(static_cast<const ExternalSourceLoader *>(loader.data())->variableMap());
        const QStringList variables(vMap.keys());

        for(int i = 0; i < variables.count(); ++i)
        {
            const QXmlName name(namePool, variables.at(i));
            const QXmlItem val(QPatternist::Item::toPublic(loader->evaluateSingleton(name, QPatternist::DynamicContext::Ptr())));
            query.bindVariable(name, val);
        }
    }

    /* We pass in the testCasePath(), such that the base URI is correct fort
     * XSL-T stylesheets. */
    query.setQuery(queryString, testCasePath());

    if(!query.isValid())
    {
        pDebug() << "Got compilation exception.";
        resultStatus = TestBaseLine::scanErrors(errHandler.messages(), baseLines());

        Q_ASSERT(resultStatus != TestResult::Unknown);
        m_result = new TestResult(name(), resultStatus, s_exprFact->astTree(),
                                  errHandler.messages(), QPatternist::Item::List(), QString());
        retval.append(m_result);
        ErrorHandler::installQtMessageHandler(0);
        changed(this);
        return retval;
    }

    if(stage == CompileOnly)
    {
        m_result = new TestResult(name(), TestResult::Fail, s_exprFact->astTree(),
                                  errHandler.messages(), QPatternist::Item::List(), QString());
        retval.append(m_result);
        return retval;
    }

    Q_ASSERT(stage == CompileAndRun);

    if(scen == ParseError) /* We're supposed to have received an error
                              at this point. */
    {
        m_result = new TestResult(name(), TestResult::Fail, s_exprFact->astTree(),
                                  errHandler.messages(), QPatternist::Item::List(), QString());
        ErrorHandler::installQtMessageHandler(0);
        retval.append(m_result);
        changed(this);
        return retval;
    }

    QPatternist::Item::List itemList;

    QByteArray output;
    QBuffer buffer(&output);
    buffer.open(QIODevice::WriteOnly);

    QXmlSerializer serializer(query, &buffer);

    pDebug() << "-------------------------- evaluateToPushCallback() ---------------------------- ";
    const bool success = query.evaluateTo(&serializer);
    pDebug() << "------------------------------------------------------------------------------------ ";

    buffer.close();

    const QString serialized(QString::fromUtf8(output.constData(), output.size()));

    if(!success)
    {
        resultStatus = TestBaseLine::scanErrors(errHandler.messages(), baseLines());

        Q_ASSERT(resultStatus != TestResult::Unknown);
        m_result = new TestResult(name(), resultStatus, s_exprFact->astTree(),
                                  errHandler.messages(), QPatternist::Item::List(), serialized);
        retval.append(m_result);
        ErrorHandler::installQtMessageHandler(0);
        changed(this);
        return retval;
    }

    /* It's a regular test. */
    Q_ASSERT(scen == Standard || scen == RuntimeError);

    resultStatus = TestBaseLine::scan(serialized, baseLines());
    Q_ASSERT(resultStatus != TestResult::Unknown);

    /* Check that errHandler()->messages() at most only contains
     * warnings, since it shouldn't have errors at this point. */
    const ErrorHandler::Message::List errors (errHandler.messages());
    const ErrorHandler::Message::List::const_iterator end(errors.constEnd());
    ErrorHandler::Message::List::const_iterator it(errors.constBegin());

    for(; it != end; ++it)
    {
        const QtMsgType type = (*it).type();
        if(type == QtFatalMsg)
        {
            m_result = new TestResult(name(), TestResult::Fail, s_exprFact->astTree(),
                                      errHandler.messages(), itemList, serialized);
            retval.append(m_result);
            ErrorHandler::installQtMessageHandler(0);
            changed(this);
            return retval;
        }
    }

    m_result = new TestResult(name(), resultStatus, s_exprFact->astTree(),
                              errHandler.messages(), itemList, serialized);
    retval.append(m_result);
    ErrorHandler::installQtMessageHandler(0);
    changed(this);
    return retval;
}
Пример #12
0
//Load the asset from the specified file
bool GMAsset_Sprite::Load(const QFileInfo &file)
{
    this->GMAsset::Load(file);
    QFile spriteFile(file.absoluteFilePath());
    if (!spriteFile.exists()) return false; //File does not exist
    if (!spriteFile.open(QIODevice::ReadOnly | QIODevice::Text))
            return false; //Failed to open the file
    QXmlQuery query;
    QXmlResultItems  result;
    QXmlItem item;
    query.setFocus(&spriteFile);

    //Type of sprite
    query.setQuery("sprite/type/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
        SetType(item.toAtomicValue().toInt());
    }

    QPoint origin;
    //X Origin
    query.setQuery("sprite/xorig/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
        origin.setX(item.toAtomicValue().toInt());
    }

    //Y Origin
    query.setQuery("sprite/yorigin/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
        origin.setY(item.toAtomicValue().toInt());
    }
    SetOrigin(origin);

    //Collision Kind
    query.setQuery("sprite/colkind/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
        SetCollisionKind((CollisionKind)item.toAtomicValue().toInt());
    }

    //Color Tolerance
    query.setQuery("sprite/coltolerance/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
        SetColTolerance(item.toAtomicValue().toInt());
    }

    //Seprate Masks?
    query.setQuery("sprite/sepmasks/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
        SetSepMasks(item.toAtomicValue().toBool());
    }

    //Bounding Box Mode
    query.setQuery("sprite/bboxmode/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
        SetBboxMode((BoundingBoxMode)item.toAtomicValue().toInt());
    }

    QRect bbox; //Bounding box
    //Bounding Box Left
    query.setQuery("sprite/bbox_left/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       bbox.setLeft(item.toAtomicValue().toInt());
    }

    //Bounding Box Right
    query.setQuery("sprite/bbox_right/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       bbox.setRight(item.toAtomicValue().toInt());
    }

    //Bounding Box Top
    query.setQuery("sprite/bbox_top/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       bbox.setTop(item.toAtomicValue().toInt());
    }

    //Bounding Box Bottom
    query.setQuery("sprite/bbox_bottom/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       bbox.setBottom(item.toAtomicValue().toInt());
    }

    SetBbox(bbox); //Set the bounding box

    //Horizontal Tile?
    query.setQuery("sprite/HTile/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       SetHTile(item.toAtomicValue().toBool());
    }

    //Vertical Tile?
    query.setQuery("sprite/VTile/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       SetVTile(item.toAtomicValue().toBool());
    }

    //For 3D?
    query.setQuery("sprite/For3D/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       SetFor3D(item.toAtomicValue().toBool());
    }


    QSize size;
    //Width of sprite
    query.setQuery("sprite/width/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       size.setWidth(item.toAtomicValue().toInt());
    }

    //Height of Sprite
    query.setQuery("sprite/height/string()");
    query.evaluateTo(&result);
    item = result.next();
    if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
       size.setHeight(item.toAtomicValue().toInt());
    }

    SetSize(size); //Set the size of the sprite


    //We will now get all of the frames for the sprite (NOTE: This ignores the index attribute and just adds them in order)
    query.setQuery("sprite/frames/frame/string()");
    query.evaluateTo(&result);
    item = result.next();
    while (!item.isNull()) {
        if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
            QString frameFilePath = GetFileInfo().absolutePath().append("/").append(item.toAtomicValue().toString());
            frames.push_back(QFileInfo(frameFilePath));
        }
        item = result.next();
    }

    spriteFile.close(); //Close the XML File
    return true;
}
Пример #13
0
Configurations *PtzManagement::getConfigurations()
{
    Configurations *configurations = NULL;
    Message *msg = newMessage();
    msg->appendToBody(newElement("wsdl:GetConfigurations"));
    MessageParser *result = sendMessage(msg);
    if(result != NULL){
        configurations = new Configurations();
        QXmlQuery *query = result->query();
        QString value,xml;
        QDomDocument doc;
        QDomNodeList itemNodeList;
        QDomNode node;
        QXmlResultItems items;
        QXmlItem item;
        query->setQuery(result->nameSpace()+"doc($inputDocument)//tptz:PTZConfiguration");
        query->evaluateTo(&items);
        item = items.next();
        while(!item.isNull()){
            query->setFocus(item);
            query->setQuery(result->nameSpace()+".");
            query->evaluateTo(&xml);
            doc.setContent(xml);
            itemNodeList = doc.elementsByTagName("tptz:PTZConfiguration");
            for(int i=0; i<itemNodeList.size(); i++)
            {
                node = itemNodeList.at(i);
                value = node.toElement().attribute("token");
                configurations->setToken(value.trimmed());
            }

            query->setQuery(result->nameSpace()+"./tt:Name/string()");
            query->evaluateTo(&value);
            configurations->setName(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:UseCount/string()");
            query->evaluateTo(&value);
            configurations->setUseCount(value.trimmed().toInt());

            query->setQuery(result->nameSpace()+"./tt:NodeToken/string()");
            query->evaluateTo(&value);
            configurations->setNodeToken(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:DefaultAbsolutePantTiltPositionSpace/string()");
            query->evaluateTo(&value);
            configurations->setDefaultAbsolutePantTiltPositionSpace(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:DefaultAbsoluteZoomPositionSpace/string()");
            query->evaluateTo(&value);
            configurations->setDefaultAbsoluteZoomPositionSpace(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:DefaultRelativePanTiltTranslationSpace/string()");
            query->evaluateTo(&value);
            configurations->setDefaultRelativePanTiltTranslationSpace(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:DefaultRelativeZoomTranslationSpace/string()");
            query->evaluateTo(&value);
            configurations->setDefaultRelativeZoomTranslationSpace(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:DefaultContinuousPanTiltVelocitySpace/string()");
            query->evaluateTo(&value);
            configurations->setDefaultContinuousPanTiltVelocitySpace(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:DefaultContinuousZoomVelocitySpace/string()");
            query->evaluateTo(&value);
            configurations->setDefaultContinuousZoomVelocitySpace(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:DefaultPTZSpeed/tt:PanTilt");
            query->evaluateTo(&xml);
            doc.setContent(xml);
            itemNodeList = doc.elementsByTagName("tt:PanTilt");
            for(int i=0; i<itemNodeList.size();i++)
            {
                node = itemNodeList.at(i);
                value = node.toElement().attribute("space");
                configurations->setPanTiltSpace(value.trimmed());

                value = node.toElement().attribute("y");
                configurations->setPanTiltY(value.trimmed().toFloat());

                value = node.toElement().attribute("x");
                configurations->setPanTiltX(value.trimmed().toFloat());
            }

            query->setQuery(result->nameSpace()+"./tt:DefaultPTZSpeed/tt:Zoom");
            query->evaluateTo(&xml);
            doc.setContent(xml);
            itemNodeList = doc.elementsByTagName("tt:Zoom");
            for(int i=0; i<itemNodeList.size(); i++)
            {
                node = itemNodeList.at(i);
                value = node.toElement().attribute("space");
                configurations->setZoomSpace(value.trimmed());

                value = node.toElement().attribute("x");
                configurations->setZoomX(value.trimmed().toFloat());
            }

            query->setQuery(result->nameSpace()+"./tt:DefaultPTZTimeout/string()");
            query->evaluateTo(&value);
            configurations->setDefaultPTZTimeout(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:PanTiltLimits/tt:Range/tt:URI/string()");
            query->evaluateTo(&value);
            configurations->setPanTiltRangeUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:PanTiltLimits/tt:Range/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            configurations->setPanTiltXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:PanTiltLimits/tt:Range/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            configurations->setPanTiltXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:PanTiltLimits/tt:Range/tt:YRange/tt:Min/string()");
            query->evaluateTo(&value);
            configurations->setPanTiltYRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:PanTiltLimits/tt:Range/tt:YRange/tt:Max/string()");
            query->evaluateTo(&value);
            configurations->setPanTiltYRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:ZoomLimits/tt:Range/tt:URI/string()");
            query->evaluateTo(&value);
            configurations->setZoomRangeUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:ZoomLimits/tt:Range/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            configurations->setZoomXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:ZoomLimits/tt:Range/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            configurations->setZoomXRangeMax(value.trimmed().toFloat());

            item = items.next();
        }
    }
    delete msg;
    delete result;
    return configurations;
}
Пример #14
0
Nodes *PtzManagement::getNodes()
{
    Nodes *nodes = NULL;
    Message *msg = newMessage();
    QDomElement getNodes = newElement("wsdl:GetNodes");
    msg->appendToBody(getNodes);
    MessageParser *result = sendMessage(msg);
    if(result != NULL){
        nodes = new Nodes();
        QXmlQuery *query = result->query();
        QXmlResultItems items;
        QXmlItem item;
        QDomDocument doc;
        QDomNodeList itemNodeList;
        QDomNode node;
        QString value,xml;
        query->setQuery(result->nameSpace()+"doc($inputDocument)//tptz:PTZNode");
        query->evaluateTo(&items);
        item = items.next();
        while(!item.isNull()){
            query->setFocus(item);
            query->setQuery(result->nameSpace()+".");
            query->evaluateTo(&xml);
            doc.setContent(xml);
            itemNodeList = doc.elementsByTagName("tptz:PTZNode");
            for(int i=0; i<itemNodeList.size();i++)
            {
                node = itemNodeList.at(i);
                value = node.toElement().attribute("token");
                nodes->setPtzNodeToken(value.trimmed());
            }
            query->setQuery(result->nameSpace()+"./tt:Name/string()");
            query->evaluateTo(&value);
            nodes->setName(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:URI/string()");
            query->evaluateTo(&value);
            nodes->setAppsUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setAppsXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setAppsXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:YRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setAppsYRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:YRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setAppsYRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:AbsoluteZoomPositionSpace/tt:URI/string()");
            query->evaluateTo(&value);
            nodes->setAzpsUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:AbsoluteZoomPositionSpace/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setAzpsXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:AbsoluteZoomPositionSpace/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setAzpsXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:RelativePanTiltTranslationSpace/tt:URI/string()");
            query->evaluateTo(&value);
            nodes->setRptsUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:RelativePanTiltTranslationSpace/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setRptsXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:RelativePanTiltTranslationSpace/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setRptsXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:RelativePanTiltTranslationSpace/tt:YRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setRptsYRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:RelativePanTiltTranslationSpace/tt:YRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setRptsYRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:RelativeZoomTranslationSpace/tt:URI/string()");
            query->evaluateTo(&value);
            nodes->setRztsUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:RelativeZoomTranslationSpace/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setRztsXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:RelativeZoomTranslationSpace/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setRztsXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ContinuousPanTiltVelocitySpace/tt:URI/string()");
            query->evaluateTo(&value);
            nodes->setCpvsUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ContinuousPanTiltVelocitySpace/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setCpvsXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ContinuousPanTiltVelocitySpace/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setCpvsXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ContinuousPanTiltVelocitySpace/tt:YRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setCpvsYRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ContinuousPanTiltVelocitySpace/tt:YRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setCpvsYRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ContinuousZoomVelocitySpace/tt:URI/string()");
            query->evaluateTo(&value);
            nodes->setCzvsUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ContinuousZoomVelocitySpace/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setCzvsXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ContinuousZoomVelocitySpace/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setCzvsXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:PanTiltSpeedSpace/tt:URI/string()");
            query->evaluateTo(&value);
            nodes->setPssUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:PanTiltSpeedSpace/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setPssXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:PanTiltSpeedSpace/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setPssXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ZoomSpeedSpace/tt:URI/string()");
            query->evaluateTo(&value);
            nodes->setZssUri(value.trimmed());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ZoomSpeedSpace/tt:XRange/tt:Min/string()");
            query->evaluateTo(&value);
            nodes->setZssXRangeMin(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:SupportedPTZSpaces/tt:ZoomSpeedSpace/tt:XRange/tt:Max/string()");
            query->evaluateTo(&value);
            nodes->setZssXRangeMax(value.trimmed().toFloat());

            query->setQuery(result->nameSpace()+"./tt:MaximumNumberOfPresets/string()");
            query->evaluateTo(&value);
            nodes->setMaximumNumberOfPresets(value.trimmed().toInt());

            query->setQuery(result->nameSpace()+"./tt:HomeSupported/string()");
            query->evaluateTo(&value);
            nodes->setHomeSupported(value.trimmed() == "true"?true:false);
            item = items.next();
        }
    }
    delete msg;
    delete result;
    return nodes;
}