Пример #1
0
CmdDelete::CmdDelete (MainWindow &mainWindow,
                      Document &document,
                      const QString &cmdDescription,
                      QXmlStreamReader &reader) :
  CmdAbstract (mainWindow,
               document,
               cmdDescription)
{
  LOG4CPP_INFO_S ((*mainCat)) << "CmdDelete::CmdDelete";

  QXmlStreamAttributes attributes = reader.attributes();

  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
      ENGAUGE_ASSERT (false);
  }

  QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();

  m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
  m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
  m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
  m_curvesGraphs.loadXml(reader);
}
CmdAddPointGraph::CmdAddPointGraph (MainWindow &mainWindow,
                                    Document &document,
                                    const QString &cmdDescription,
                                    QXmlStreamReader &reader) :
  CmdPointChangeBase (mainWindow,
                      document,
                      cmdDescription)
{
  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph";

  QXmlStreamAttributes attributes = reader.attributes();

  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_X) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_Y) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_CURVE_NAME) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_ORDINAL) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER)) {
    xmlExitWithError (reader,
                      QString ("Missing attribute(s) %1, %2, %3, %4 and/or %5")
                      .arg (DOCUMENT_SERIALIZE_SCREEN_X)
                      .arg (DOCUMENT_SERIALIZE_SCREEN_Y)
                      .arg (DOCUMENT_SERIALIZE_CURVE_NAME)
                      .arg (DOCUMENT_SERIALIZE_ORDINAL)
                      .arg (DOCUMENT_SERIALIZE_IDENTIFIER));
  }

  m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
  m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
  m_curveName = attributes.value(DOCUMENT_SERIALIZE_CURVE_NAME).toString();
  m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
  m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
}
Пример #3
0
DriApplication::DriApplication(QXmlStreamReader *xml)
{
    QXmlStreamAttributes attributes = xml->attributes();

    options.clear();
    if (attributes.hasAttribute("name"))
        name = attributes.value("name").toString();
    else
        name.clear();

    if (attributes.hasAttribute("executable"))
        executable = attributes.value("executable").toString();
    else
        executable.clear();

    if (name.isNull() && !executable.isNull()) {
        std::cout << "application found with no name. One has been given.";
        name = QString(executable);
    }

    if (!name.isNull() && executable.isNull()) {
        std::cout << "application found with no executable. Options ignored";
        name.clear();
        while (xml->readNextStartElement())
            xml->skipCurrentElement();
        return;
    }

    while (xml->readNextStartElement()) {
        if (xml->name() == "option")
            DriOptionValue::insertList(&options, new DriOptionValue(xml));
        else
            xml->skipCurrentElement();
    }
}
Пример #4
0
bool ShowFunction::loadXML(QXmlStreamReader &root)
{
    if (root.name() != KXMLShowFunction)
    {
        qWarning() << Q_FUNC_INFO << "ShowFunction node not found";
        return false;
    }

    QXmlStreamAttributes attrs = root.attributes();

    if (attrs.hasAttribute(KXMLShowFunctionID))
        setFunctionID(attrs.value(KXMLShowFunctionID).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionStartTime))
        setStartTime(attrs.value(KXMLShowFunctionStartTime).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionDuration))
        setDuration(attrs.value(KXMLShowFunctionDuration).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionColor))
        setColor(QColor(attrs.value(KXMLShowFunctionColor).toString()));
    if (attrs.hasAttribute(KXMLShowFunctionLocked))
        setLocked(true);

    root.skipCurrentElement();

    return true;
}
void DocumentModelPointMatch::loadXml(QXmlStreamReader &reader)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelPointMatch::loadXml";

  bool success = true;

  QXmlStreamAttributes attributes = reader.attributes();

  if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED)) {

    setMaxPointSize (attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE).toDouble());
    setPaletteColorAccepted ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED).toInt());
    setPaletteColorCandidate ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE).toInt());
    setPaletteColorRejected ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED).toInt());

    // Read until end of this subtree
    while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
    (reader.name() != DOCUMENT_SERIALIZE_POINT_MATCH)){
      loadNextFromReader(reader);
      if (reader.atEnd()) {
        success = false;
        break;
      }
    }
  }

  if (!success) {
    reader.raiseError (QObject::tr ("Cannot read point match data"));
  }
}
Пример #6
0
DescriptionLangInfo::DescriptionLangInfo(QXmlStreamReader *xml)
{
    QXmlStreamAttributes attributes = xml->attributes();

    if (attributes.hasAttribute("lang"))
        language = attributes.value("lang").toString();
    else
        throw "Missing lang element to description";

    if (attributes.hasAttribute("text"))
        text = attributes.value("text").toString();
    else
        throw "Missing text element to description";

    enum_info.clear();
    if (!xml->readNextStartElement()) {
        return;
    }
    do {
        if (xml->name() == "enum")
            enum_info.append(new EnumLangInfo(xml));
        else
            xml->skipCurrentElement();
    } while (xml->readNextStartElement());
}
void ctkXnatResourceCatalogXmlParser::parseXml(QList<QVariantMap>& result)
{
    Q_D(ctkXnatResourceCatalogXmlParser);

    while (!d->xmlReader.atEnd())
    {
        if (d->xmlReader.name().compare("entry") == 0)
        {
            QVariantMap map;
            QXmlStreamAttributes attributes = d->xmlReader.attributes();

            if( attributes.hasAttribute("name") && attributes.hasAttribute("digest"))
            {
                QString name("");
                name += attributes.value("name");
                QString md5("");
                md5 += attributes.value("digest");
                map[name] = md5;
                result.append(map);
            }
        }
        d->xmlReader.readNext();
    }
    if (d->xmlReader.hasError())
    {
        qWarning()<<"Error parsing XNAT resource catalog xml!";
    }
}
Пример #8
0
CmdCut::CmdCut (MainWindow &mainWindow,
                Document &document,
                const QString &cmdDescription,
                QXmlStreamReader &reader) :
  CmdPointChangeBase (mainWindow,
                      document,
                      cmdDescription)
{
  LOG4CPP_INFO_S ((*mainCat)) << "CmdCut::CmdCut";

  QXmlStreamAttributes attributes = reader.attributes();

  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
    xmlExitWithError (reader,
                      QString ("%1 %2, %3 %4 %5")
                      .arg (QObject::tr ("Missing argument(s)"))
                      .arg (DOCUMENT_SERIALIZE_TRANSFORM_DEFINED)
                      .arg (DOCUMENT_SERIALIZE_CSV)
                      .arg (QObject::tr ("and/or"))
                      .arg (DOCUMENT_SERIALIZE_HTML));
  }

  QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();

  m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
  m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
  m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
  m_curvesGraphsRemoved.loadXml(reader);
}
Пример #9
0
void PointStyle::loadXml(QXmlStreamReader &reader)
{
  LOG4CPP_INFO_S ((*mainCat)) << "PointStyle::loadXml";

  QXmlStreamAttributes attributes = reader.attributes();

  if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_COLOR) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE)) {

    setRadius (attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS).toInt());
    setLineWidth (attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH).toInt());
    setPaletteColor ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_COLOR).toInt());
    setShape ((PointShape) attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE).toInt());

    // Read until end of this subtree
    while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
    (reader.name() != DOCUMENT_SERIALIZE_POINT_STYLE)){
      loadNextFromReader(reader);
    }
  } else {
    reader.raiseError ("Cannot read point style data");
  }
}
Пример #10
0
DriOptionInfo::DriOptionInfo(QXmlStreamReader *xml)
{
    QXmlStreamAttributes attributes = xml->attributes();

    if (attributes.hasAttribute("name"))
        name = attributes.value("name").toString();
    else
        throw "Missing name element to option info";

    if (attributes.hasAttribute("type")) {
        QString type_string = attributes.value("type").toString();
        if (type_string == "bool")
            type = OptionBool;
        else if (type_string == "int")
            type = OptionInt;
        else if (type_string == "enum")
            type = OptionEnum;
        else if (type_string == "string")
            type = OptionString;
        else
            throw "Unknown type element to option info";
    } else
        throw "Missing type element to option info";

    if (attributes.hasAttribute("default"))
        default_value = attributes.value("default").toString();
    else
        default_value.clear();

    if (type == OptionEnum) {
        if (!attributes.hasAttribute("valid"))
            throw "Missing valid element to option info with enum";

        QString valid_string = attributes.value("valid").toString();
        QStringList valid_string_list = valid_string.split(':');
        bool ok = 0;

        if (!valid_string_list.count() == 2)
            throw "Invalid valid element to option info with enum";

        min_valid = valid_string_list[0].toInt(&ok);
        if (!ok)
            throw "Invalid valid element to option info with enum";
        max_valid = valid_string_list[1].toInt(&ok);
        if (!ok || min_valid > max_valid)
            throw "Invalid valid element to option info with enum";
    }

    descriptions.clear();
    if (!xml->readNextStartElement()) {
        return;
    }
    do {
        if (xml->name() == "description")
            descriptions.append(new DescriptionLangInfo(xml));
        else
            xml->skipCurrentElement();
    } while (xml->readNextStartElement());
}
Пример #11
0
void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
{
    while (!xml.atEnd()) {
        if (xml.readNext() == QXmlStreamReader::EndElement)
            break;
        if (xml.name() == "card") {
            QString name, manacost, type, pt, text;
            QStringList colors;
            QStringMap customPicURLs, customPicURLsHq;
            MuidMap muids;
            SetList sets;
            int tableRow = 0;
            int loyalty = 0;
            bool cipt = false;
            bool isToken = false;
            while (!xml.atEnd()) {
                if (xml.readNext() == QXmlStreamReader::EndElement)
                    break;
                if (xml.name() == "name")
                    name = xml.readElementText();
                else if (xml.name() == "manacost")
                    manacost = xml.readElementText();
                else if (xml.name() == "type")
                    type = xml.readElementText();
                else if (xml.name() == "pt")
                    pt = xml.readElementText();
                else if (xml.name() == "text")
                    text = xml.readElementText();
                else if (xml.name() == "set") {
                    QXmlStreamAttributes attrs = xml.attributes();
                    QString setName = xml.readElementText();
                    sets.append(getSet(setName));
                    if (attrs.hasAttribute("muId")) {
                        muids[setName] = attrs.value("muId").toString().toInt();
                    }
                    if (attrs.hasAttribute("picURL")) {
                        customPicURLs[setName] = attrs.value("picURL").toString();
                    }
                    if (attrs.hasAttribute("picURLHq")) {
                        customPicURLsHq[setName] = attrs.value("picURLHq").toString();
                    }
                } else if (xml.name() == "color")
                    colors << xml.readElementText();
                else if (xml.name() == "tablerow")
                    tableRow = xml.readElementText().toInt();
                else if (xml.name() == "cipt")
                    cipt = (xml.readElementText() == "1");
                else if (xml.name() == "loyalty")
                    loyalty = xml.readElementText().toInt();
                else if (xml.name() == "token")
                    isToken = xml.readElementText().toInt();
            }

            if (isToken == tokens) {
                addCard(new CardInfo(this, name, isToken, manacost, type, pt, text, colors, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
            }
        }
    }
}
Пример #12
0
bool QmlProfilerFileReader::loadQtd(QIODevice *device)
{
    QXmlStreamReader stream(device);

    bool validVersion = true;

    while (validVersion && !stream.atEnd() && !stream.hasError()) {
        if (isCanceled())
            return false;
        QXmlStreamReader::TokenType token = stream.readNext();
        const QStringRef elementName = stream.name();
        switch (token) {
        case QXmlStreamReader::StartDocument :  continue;
        case QXmlStreamReader::StartElement : {
            if (elementName == _("trace")) {
                QXmlStreamAttributes attributes = stream.attributes();
                if (attributes.hasAttribute(_("version")))
                    validVersion = attributes.value(_("version")) == _(PROFILER_FILE_VERSION);
                else
                    validVersion = false;
                if (attributes.hasAttribute(_("traceStart")))
                    m_traceStart = attributes.value(_("traceStart")).toLongLong();
                if (attributes.hasAttribute(_("traceEnd")))
                    m_traceEnd = attributes.value(_("traceEnd")).toLongLong();
            }

            if (elementName == _("eventData")) {
                loadEventTypes(stream);
                emit typesLoaded(m_eventTypes);
                break;
            }

            if (elementName == _("profilerDataModel")) {
                loadEvents(stream);
                break;
            }

            if (elementName == _("noteData")) {
                loadNotes(stream);
                emit notesLoaded(m_notes);
                break;
            }

            break;
        }
        default: break;
        }
    }

    if (stream.hasError()) {
        emit error(tr("Error while parsing trace data file: %1").arg(stream.errorString()));
        return false;
    } else {
        emit success();
        return true;
    }
}
bool Board::load(std::string cells_param)
{
    ROS_DEBUG("Ready to read xml data of cells");

    std::string xml_cells;

    if (ros::param::get(cells_param, xml_cells)) //reading the xml data from the parameter server
    {
        cells.clear(); //cleaning all previous cells

        QXmlStreamReader xml;
        xml.addData(QString::fromStdString(xml_cells)); //adding the xml content to the input stream
        while(!xml.atEnd() && !xml.hasError()) {
            /* Read next element.*/
            QXmlStreamReader::TokenType token = xml.readNext();
            ROS_DEBUG_STREAM("name=" << xml.name().toString().toStdString());
            /* If token is just StartDocument, we'll go to next.*/
            if(token == QXmlStreamReader::StartDocument) {
                continue;
            }
            /* If token is StartElement, we'll see if we can read it.*/
            if(token == QXmlStreamReader::StartElement) {
                /* If it's named cell, we'll add a new cell to the board.*/
                if(xml.name() == "cell") {
                    cells.push_back(Cell());
                    continue;
                }
                /* If it's named vertex, we'll dig the information from there.*/
                if(xml.name() == "vertex") {
                    /* Let's get the attributes for vertex */
                    QXmlStreamAttributes attributes = xml.attributes();
                    /* Let's check that vertex has x and y attribute. */
                    if(attributes.hasAttribute("x") && attributes.hasAttribute("y")) {
                        /* We'll add it to the cell */
                        cells.back().contours.push_back(cv::Point(attributes.value("x").toString().toInt(), attributes.value("y").toString().toInt()));
                    }
                    else xml.raiseError("Vertex corrupted: x and/or y value is missing");
                }
            }
        }
        ROS_WARN_COND(xml.hasError(),"Error parsing xml data (l.%d, c.%d):%s", (int)xml.lineNumber(), (int)xml.columnNumber(), xml.errorString().toStdString().c_str());

        ROS_INFO("Xml data successfully loaded. %i cells loaded.", (int)cells.size());

        for (int i = 0; i < cells.size(); ++i)
        {
            ROS_INFO("Cell %i:  %s",i,cells[i].toString().c_str());
        }
        return true;
    }
    else
    {
        ROS_FATAL_STREAM("xml cell data not loaded!");
        return false;
    }
}
Пример #14
0
bool optional_assign(const QXmlStreamAttributes &attr, const char *key, T &v, const QXmlStreamReader &reader) {
	if ( attr.hasAttribute(XmlUtil::XML_NS, key) ) {
		v = checked_convert<T>(attr.value(XmlUtil::XML_NS, key).toString(), key, reader);
		return true;
	} else if ( attr.hasAttribute("", key) ) {
		v = checked_convert<T>(attr.value("", key).toString(), key, reader);
		return true;
	}
	return false;
}
Пример #15
0
// Constructor for parser function
Message::Message(XmlStreamReader& xml)
 :  QObject(),
    m_timeStamp(),
    m_timeStampPresent( false ),
    m_code( 0 ),
    m_codePresent( false ),
    m_version( "1.0.0" ), // initialize fixed value
    m_versionPresent( true ),
    m_changed(true)
{
    QXmlStreamAttributes attr = xml.attributes();
    if ( attr.hasAttribute( "TimeStamp" ) )
    {
        if ( !setTimeStamp( QDateTime::fromString(attr.value( "TimeStamp" ).toString(), Qt::ISODate)) )
            xml.validationError( "error set TimeStamp = " + attr.value( "TimeStamp" ).toString() );
    }
    if ( attr.hasAttribute( "Code" ) )
    {
        if ( !setCode( attr.value( "Code" ).toString().toInt() ) )
            xml.validationError( "error set Code = " + attr.value( "Code" ).toString() );
    }
    if ( attr.hasAttribute( "Version" ) )
    {
        if ( !setVersion( attr.value( "Version" ).toString() ) )
            xml.validationError( "error set Version = " + attr.value( "Version" ).toString() );
    }
    bool stop(false);
    while(!xml.atEnd() && !stop)
    {
        QXmlStreamReader::TokenType token = xml.readNext();
        switch ( token )
        {
        case QXmlStreamReader::EndElement:
            if (  xml.name() == "Message" )
                stop = true;
            break;
        case QXmlStreamReader::StartElement:
            if ( xml.name() == "Argument" )
            {
                QString val = xml.readElementText();
                if ( xml.name() != "Argument" )
                    xml.raiseError( "tag mismatch Argument" );
                else if ( !addArgument( val ) )
                    xml.validationError( "error add Argument"  );
            }
            else
            {
                xml.validationError( "unexpected element " + xml.name().toString() );
            }
            break;
        default:
            break;
        }
    }
}
Пример #16
0
/**
 * Called when the webview finished loading a new page
 */
void PhoneGap::loadFinished( bool ok ) {
    Q_UNUSED(ok)

    // Change into the xml-directory
    QDir xmlDir( m_workingDir );
    xmlDir.cd( "xml" );

    // Try to open the plugins configuration
    QFile pluginsXml( xmlDir.filePath("plugins.xml") );
    if( !pluginsXml.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
        qDebug() << "Error loading plugins config!";
        return;
    }

    // Start reading the file as a stream
    QXmlStreamReader plugins;
    plugins.setDevice( &pluginsXml );

    // Get a reference to the current main-frame
    QWebFrame *webFrame = m_webView->page()->mainFrame();

    // Iterate over plugins-configuration and load all according plugins
    while(!plugins.atEnd()) {
        if( plugins.readNext() == QXmlStreamReader::StartElement ) {
            // Check if we have a plugin element
            if( plugins.name() == "plugin" ) {
                QXmlStreamAttributes attribs = plugins.attributes();
                // Check for name & value attributes
                if( attribs.hasAttribute("name") && attribs.hasAttribute("value") ) {
                    // Construct object & attribute names
                    QString attribName = attribs.value( "name" ).toString();
                    QString attribValue = attribs.value( "value" ).toString();
                    QString objectName = attribName + "_native";

                    qDebug() << "Adding Plugin " << attribName << " with " << attribValue;
                    // Check for such a plugin
                    PGPlugin *currPlugin = PluginRegistry::getRegistry()->getPlugin( attribValue );
                    if( currPlugin != NULL ) {
                        currPlugin->setWebFrame( webFrame );
                        webFrame->addToJavaScriptWindowObject( objectName, currPlugin );

                        webFrame->evaluateJavaScript( "PhoneGap.Qt.registerObject( '" + attribValue + "', " + objectName + " )" );
                        webFrame->evaluateJavaScript( "PhoneGap.enablePlugin( '" + attribValue + "' )" );
                    }
                    else {
                        qDebug() << "Unknown Plugin " << attribName;
                    }
                }
            }
        }
    }

    // Device is now ready to rumble
    webFrame->evaluateJavaScript( "PhoneGap.deviceready();" );
}
Пример #17
0
    bool handleStanza(const QXmlStreamAttributes &attributes)
    {
        if (!attributes.hasAttribute("branch"))
            return false;
        if (!attributes.hasAttribute("tip"))
            return false;

        data->branch = attributes.value("branch").toString();
        data->tip = attributes.value("tip").toString();
        return true;
    }
Пример #18
0
void Groups::finishedFetchingGroups()
{
    QNetworkReply *reply = static_cast<QNetworkReply *>(sender());

    if (reply->hasRawHeader("Backoff"))
        d->api->startBackoff(QString::fromLatin1(reply->rawHeader("Backoff").constData()).toInt());
    else if (reply->hasRawHeader("Retry-After"))
        d->api->startBackoff(QString::fromLatin1(reply->rawHeader("Retry-After").constData()).toInt());

    if (reply->error() == QNetworkReply::NoError) {
        QString nextPage;
        QXmlStreamReader xmlReader(reply);
        while (!xmlReader.atEnd() && !xmlReader.hasError()) {
            const QXmlStreamReader::TokenType tt = xmlReader.readNext();
            if (tt == QXmlStreamReader::StartElement && xmlReader.name() == QStringLiteral("entry")) {
                QString label;
                int groupId = -1;
                while (!xmlReader.atEnd() && !xmlReader.hasError()) {
                    const QXmlStreamReader::TokenType tt = xmlReader.readNext();
                    if (tt == QXmlStreamReader::StartElement && xmlReader.name() == QStringLiteral("title"))
                        label = xmlReader.readElementText(QXmlStreamReader::IncludeChildElements);
                    else if (tt == QXmlStreamReader::StartElement && xmlReader.name() == QStringLiteral("groupID")) {
                        bool ok = false;
                        groupId = xmlReader.readElementText(QXmlStreamReader::IncludeChildElements).toInt(&ok);
                        if (groupId < 1) groupId = -1;
                    } else if (tt == QXmlStreamReader::EndElement && xmlReader.name() == QStringLiteral("entry"))
                        break;
                }

                if (!label.isEmpty() && groupId > 0)
                    d->groups.insert(groupId, label);
            } else if (tt == QXmlStreamReader::StartElement && xmlReader.name() == QStringLiteral("link")) {
                const QXmlStreamAttributes attrs = xmlReader.attributes();
                if (attrs.hasAttribute(QStringLiteral("rel")) && attrs.hasAttribute(QStringLiteral("href")) && attrs.value(QStringLiteral("rel")) == QStringLiteral("next"))
                    nextPage = attrs.value(QStringLiteral("href")).toString();
            } else if (tt == QXmlStreamReader::EndElement && xmlReader.name() == QStringLiteral("feed"))
                break;
        }

        if (!nextPage.isEmpty())
            d->requestZoteroUrl(nextPage);
        else {
            d->busy = false;
            d->initialized = true;
            emit finishedLoading();
        }
    } else {
        qCWarning(LOG_KBIBTEX_NETWORKING) << reply->errorString(); ///< something went wrong
        d->busy = false;
        d->initialized = false;
        emit finishedLoading();
    }
}
Пример #19
0
void BillItemMeasure::loadFromXml10(const QXmlStreamAttributes &attrs) {
    if( attrs.hasAttribute( "comment" ) ){
        setComment(  attrs.value( "comment").toString() );
    }
    if( attrs.hasAttribute( "formula" ) ){
        QString f = attrs.value( "formula").toString();
        if( m_d->parser->decimalSeparator() != "." ){
            f.replace( ".", m_d->parser->decimalSeparator());
        }
        setFormula( f );
    }
}
void GModelComponent::readComponentConnections(QXmlStreamReader & xmlReader, QList<QString>& errorMessages)
{
  if(!xmlReader.name().compare("ModelComponentConnection",Qt::CaseInsensitive) && !xmlReader.hasError() && xmlReader.tokenType() == QXmlStreamReader::StartElement )
  {
    while(!(xmlReader.isEndElement() && !xmlReader.name().compare("ModelComponentConnection", Qt::CaseInsensitive)) && !xmlReader.hasError())
    {
      if(!xmlReader.name().compare("OutputExchangeItem",Qt::CaseInsensitive) && !xmlReader.hasError() && xmlReader.tokenType() == QXmlStreamReader::StartElement)
      {
        QXmlStreamAttributes attributes = xmlReader.attributes();

        if(attributes.hasAttribute("OutputExchangeItemId"))
        {
          QStringRef id = attributes.value("OutputExchangeItemId");

          GOutput* outputExchangeItem = nullptr;

          for(GOutput* output : m_outputGraphicObjects.values())
          {
            if(!output->output()->id().compare(id.toString()))
            {
              if(attributes.hasAttribute("XPos") && attributes.hasAttribute("YPos"))
              {
                QString xposS = attributes.value("XPos").toString();
                QString yposS = attributes.value("YPos").toString();

                bool ok;

                double xloc = xposS.toDouble(&ok);
                double yloc = yposS.toDouble(&ok);

                if(ok)
                {
                  output->setPos(xloc,yloc);
                }
              }

              outputExchangeItem = output;
              break;
            }
          }

          if(outputExchangeItem)
          {
            outputExchangeItem->readOutputExchangeItemConnections(xmlReader, errorMessages);
          }
        }
      }
      xmlReader.readNext();
    }
  }
}
Пример #21
0
DriOptionValue::DriOptionValue(QXmlStreamReader *xml)
{
    QXmlStreamAttributes attributes = xml->attributes();

    if (attributes.hasAttribute("name"))
        name = attributes.value("name").toString();
    else
        throw "Missing name element to option";
    if (attributes.hasAttribute("value"))
        value = attributes.value("value").toString(); // We'll have to check after the type
    else
        throw "Missing value element to option";
    xml->skipCurrentElement();
}
Пример #22
0
static bool DecodeCamera(QXmlStreamReader& stream, CameraDesc& camera)
{
	assert(stream.name() == "camera");

	QXmlStreamAttributes cameraAttributes = stream.attributes();
	if (	!cameraAttributes.hasAttribute("id")
		||	!cameraAttributes.hasAttribute("sensor_id")
		||	!cameraAttributes.hasAttribute("label"))
	{
		//invalid camera?!
		assert(false);
		return false;
	}
	
	camera.id = cameraAttributes.value("id").toInt();
	camera.sensorId = cameraAttributes.value("sensor_id").toInt();
	camera.imageFilename = cameraAttributes.value("label").toString();

	while (stream.readNextStartElement())
	{
#ifdef _DEBUG
		//DisplayCurrentNodeInfo(stream);
#endif

		if (stream.name() == "transform")
		{
			QString transformationValues = stream.readElementText();
			DecodeTransformation<float>(transformationValues, camera.trans);
		}
		else if (stream.name() == "reference")
		{
			QXmlStreamAttributes attributes = stream.attributes();
			if (attributes.value("enabled").toString() == "true")
			{
				CCVector3d T = {	attributes.value("x").toDouble(),
									attributes.value("y").toDouble(),
									attributes.value("z").toDouble() };
				//What is exactly the "reference" point?!
				//camera.trans.setTranslation(CCVector3::fromArray(T.u));
			}
			stream.skipCurrentElement();
		}
		else //orientation? Not sure what it corresponds to!
		{
			stream.skipCurrentElement();
		}
	}

	return true;
}
Пример #23
0
/**
 * Called when the webview finished loading a new page
 */
void Cordova::loadFinished( bool ok ) {
    Q_UNUSED(ok)

    // Change into the xml-directory
    QDir xmlDir( m_workingDir );
    xmlDir.cd( "xml" );

    // Try to open the plugins configuration
    QFile pluginsXml( xmlDir.filePath("plugins.xml") );
    if( !pluginsXml.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
        qDebug() << "Error loading plugins config!";
        return;
    }

    // Start reading the file as a stream
    QXmlStreamReader plugins;
    plugins.setDevice( &pluginsXml );

    // Iterate over plugins-configuration and load all according plugins
    while(!plugins.atEnd()) {
        if( plugins.readNext() == QXmlStreamReader::StartElement ) {
            // Check if we have a plugin element
            if( plugins.name() == "plugin" ) {
                QXmlStreamAttributes attribs = plugins.attributes();
                // Check for name & value attributes
                if( attribs.hasAttribute("name") && attribs.hasAttribute("value") ) {
                    // Construct object & attribute names
                    QString attribName = attribs.value( "name" ).toString();
                    QString attribValue = attribs.value( "value" ).toString();

                    qDebug() << "Adding Plugin " << attribName << " with " << attribValue;
                    // Check for such a plugin
                    CPlugin *currPlugin = PluginRegistry::getRegistry()->getPlugin( attribValue );
                    if(currPlugin) {
                        currPlugin->init();
                        emit pluginWantsToBeAdded(attribValue, currPlugin, attribName);
                        execJS( "Cordova.enablePlugin( '" + attribValue + "' )" );
                    }
                    else {
                        qDebug() << "Unknown Plugin " << attribName;
                    }
                }
            }
        }
    }

    // Device is now ready to rumble
    execJS( "Cordova.deviceready();" );
}
Пример #24
0
void Document::generateEmptyPixmap(const QXmlStreamAttributes &attributes)
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::generateEmptyPixmap";

  int width = 800, height = 500; // Defaults

  if (attributes.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_WIDTH) &&
      attributes.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_HEIGHT)) {

    width = attributes.value (DOCUMENT_SERIALIZE_IMAGE_WIDTH).toInt();
    height = attributes.value (DOCUMENT_SERIALIZE_IMAGE_HEIGHT).toInt();

  }

  m_pixmap = QPixmap (width, height);
}
Пример #25
0
void InitTabStateObj::run()
{
    if (flags & GuiConst::STATE_SAVE_REQUEST) {
        qCritical() << tr("InitTabStateObj should not be used for saving T_T");
    } else {
        if (readNextStart(GuiConst::STATE_TAB)) {
            QXmlStreamAttributes attrList = reader->attributes();
            bool ok = false;
            int pretype = readInt(attrList.value(GuiConst::STATE_PRETAB_TYPE), &ok);
            if (ok && pretype >= 0 && pretype < GuiConst::AVAILABLE_TAB_STRINGS.size()) {
                TabAbstract *tab = mtabs->newPreTab((GuiConst::AVAILABLE_PRETABS)pretype);
                if (tab != nullptr) {
                    emit newTab(tab);
                    BaseStateAbstract *tabstate = tab->getStateMngtObj();
                    emit addNewState(tabstate);
                    if (attrList.hasAttribute(GuiConst::STATE_WINDOWED)) {
                        QString value = attrList.value(GuiConst::STATE_WINDOWED).toString();
                        bool ok = false;
                        int ivalue = value.toInt(&ok);
                        if (ok) {
                            if (ivalue == TabAbstract::WINDOWED_TAB) {
                                QByteArray geometry = readByteArray(attrList.value(GuiConst::STATE_WIDGET_GEOM));
                                emit detachTab(tab, geometry);
                            }
                        }
                    }
                } else {
                    qCritical() << tr("Returned tab is nullptr T_T");
                }
            } else {
                qCritical() << tr("Pretab value is invalid T_T");
            }
        }
    }
}
QMap<QString, QString> TabDialog::parseSectionGroup(QXmlStreamReader& xml) {
    QMap<QString, QString> sectionGroup;
    /* Let's check that we're really getting a sectionGroup. */
    if(xml.tokenType() != QXmlStreamReader::StartElement &&
            xml.name() == "sectionGroup") {
        return sectionGroup;
    }
    /* Let's get the attributes for sectionGroup */
    QXmlStreamAttributes attributes = xml.attributes();
    /* Let's check that sectionGroup has name attribute. */
    if(attributes.hasAttribute("name")) {
        /* We'll add it to the map. */
        sectionGroup["name"] = attributes.value("name").toString();
    }
    /* Next element... */
    xml.readNext();
    /*
     * We're going to loop over the things because the order might change.
     * We'll continue the loop until we hit an EndElement named sectionGroup.
     */
    while(!(xml.tokenType() == QXmlStreamReader::EndElement &&
            xml.name() == "sectionGroup")) {
        if(xml.tokenType() == QXmlStreamReader::StartElement) {
            /* We've add all section filters to Map. */
            if(xml.name() == "section") {
                this->addElementDataToMap(xml, sectionGroup);
            }
        }
        /* ...and next... */
        xml.readNext();
    }
    return sectionGroup;
}
Пример #27
0
glm::vec3 Scene::parseVectorNode(QXmlStreamReader &xml)
{
    glm::vec3 v;
    QXmlStreamAttributes attributes = xml.attributes();
    if(attributes.hasAttribute("x")) {
        v.x = attributes.value("x").toFloat();
    }
    if(attributes.hasAttribute("y")) {
        v.y = attributes.value("y").toFloat();
    }
    if(attributes.hasAttribute("z")) {
        v.z = attributes.value("z").toFloat();
    }
    cout << "(" << v.x << ", " << v.y << ", " << v.z << ")" << endl;
    return v;
}
Пример #28
0
void InstanceParser::readProblem()
{
    Q_ASSERT(isStartElement()
             && name() == "problem");

    QXmlStreamAttributes elementAttributes = attributes();
    if(elementAttributes.hasAttribute("name")) {
        if(elementAttributes.value("name").toString() == "mkp") {
            m_type = InstanceParser::MultipleKnapsack;
        }
        else if(elementAttributes.value("name").toString() == "BinPacking") {
            m_type = InstanceParser::BinPacking;
        }
    }

    while(!atEnd()) {
        readNext();

        if(isEndElement())
            break;

        if(isStartElement()) {
            if(name() == "probleminstance")
                readProblemInstance();
            else
                readUnknownElement();
        }
    }
}
Пример #29
0
void ContentHandler::parseAttributes(ContentElement *content,
                                     QXmlStreamAttributes attributes) const
{
    if(attributes.hasAttribute("type")) {
        content->setContentType(attributes.value("type").toString());
    }
}
Пример #30
0
void Deposit::load(QXmlStreamReader *xml)
{
	QXmlStreamAttributes attributes = xml->attributes();
	if (attributes.hasAttribute("year"))
#if QT_VERSION >= 0x050000
		year = attributes.value("year").toInt();
#else
	{
		QString temp;
		temp.append(attributes.value("year"));
		year = temp.toInt();
	}
#endif

	xml->readNext();
	if (xml->tokenType() == QXmlStreamReader::Characters)
#if QT_VERSION >= 0x050000
		amount = xml->text().toFloat();
#else
	{
		QString temp;
		temp.append(xml->text());
		amount = temp.toFloat();
	}
#endif

}