示例#1
0
bool MapParser::startElement(const QString&, const QString&, const QString& p_qName, const QXmlAttributes& p_atts)
{
    if (p_qName == "Arena")
    {
        int nbRows = 0;
        int nbColumns = 0;
        // Initialize the number of rows and columns
        for (int i = 0; i < p_atts.count(); ++i)
        {
            if (p_atts.qName(i) == "rowCount")
            {
                nbRows = p_atts.value(i).toInt();
            }
            if (p_atts.qName(i) == "colCount")
            {
                nbColumns = p_atts.value(i).toInt();
            }
            //TODO:check for the right arenaFileVersion
            //if (p_atts.qName(i) == "arenaFileVersion")
            //{
            //    m_arenaFileVersion = p_atts.value(i).toInt();
            //}
        }
        // Create the Arena matrix
        m_arena->init(nbRows, nbColumns);
        // initialize random generator
        qsrand(QDateTime::currentDateTime().toTime_t());
    }
    
    return true;
}
示例#2
0
bool KWord13Parser::startElementFrame(const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem)
{
    if (stackItem->elementType == KWord13TypeFrameset || stackItem->elementType == KWord13TypePictureFrameset) {
        stackItem->elementType = KWord13TypeEmpty;
        if (stackItem->m_currentFrameset) {
            const int num = ++stackItem->m_currentFrameset->m_numFrames;
            for (int i = 0; i < attributes.count(); ++i) {
                QString attrName(name);
                attrName += ':';
                attrName += QString::number(num);
                attrName += ':';
                attrName += attributes.qName(i);
                stackItem->m_currentFrameset->m_frameData[ attrName ] = attributes.value(i);
                kDebug(30520) << "FrameData:" << attrName << " =" << attributes.value(i);
            }

        } else {
            kError(30520) << "Data of <FRAMESET> not found";
            return false;
        }
    } else if (stackItem->elementType != KWord13TypeUnknownFrameset) {
        kError(30520) << "<FRAME> not child of <FRAMESET>";
        return false;
    }
    return true;
}
示例#3
0
    bool startElement(
        const QString&, const QString &,
        const QString &name, const QXmlAttributes &a
    )
    {
        if (fresh)
        {
            if (name=="playlist")
            {
                fresh=false;
                return true;
            }
            else
            {
                return false;
            }
        }

        if (name != "item")
            return true;

        QMap<QString,QString> propMap;

        for (int i=0; i<a.count(); i++)
        {
            propMap[a.qName(i)] = a.value(i);
        }
        saver->readItem(propMap);

        return true;
    }
示例#4
0
void StyleReader::tabStop(const QXmlAttributes& attrs)
{
	if (currentStyle->target() == "paragraph")
	{
		gtParagraphStyle* pstyle = dynamic_cast<gtParagraphStyle*>(currentStyle);
		assert(pstyle != NULL);
		QString pos = NULL;
		QString type = NULL;
		for (int i = 0; i < attrs.count(); ++i)
		{
			if (attrs.localName(i) == "style:position")
				pos = attrs.value(i);
			else if (attrs.localName(i) == "style:type")
				type = attrs.value(i);
				
		}
		if (!pos.isNull())
		{
			if (type.isNull())
				type = "left";
			double posd = getSize(pos);
			if (type == "left")
				pstyle->setTabValue(posd, LEFT_T);
			else if (type == "right")
				pstyle->setTabValue(posd, RIGHT_T);
			else if (type == "center")
				pstyle->setTabValue(posd, CENTER_T);
			else
				pstyle->setTabValue(posd, CENTER_T);
		}
	}
}
示例#5
0
bool KWord13Parser::startElementFormatOneProperty(const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem)
{
    // ### TODO: check status
    if (stackItem->elementType == KWord13TypeLayoutFormatOne) {
        if (! m_currentLayout) {
            kError(30520) << "No current LAYOUT for storing FORMAT property: " << name;
            return false;
        }
        for (int i = 0; i < attributes.count(); ++i) {
            QString attrName(name);
            attrName += ':';
            attrName += attributes.qName(i);
            m_currentLayout->m_format.m_properties[ attrName ] = attributes.value(i);
            kDebug(30520) << "Format Property (for LAYOUT):" << attrName << " =" << attributes.value(i);
        }
        stackItem->elementType = KWord13TypeEmpty;
        return true;
    } else if (stackItem->elementType == KWord13TypeFormat) {
        if (! m_currentFormat) {
            kError(30520) << "No current FORMAT for storing FORMAT property: " << name;
            return false;
        }
        KWord13FormatOneData* data = m_currentFormat->getFormatOneData();

        if (! data) {
            kError(30520) << "Current FORMAT cannot store FORMAT text property: " << name;
            return false;
        }

        for (int i = 0; i < attributes.count(); ++i) {
            QString attrName(name);
            attrName += ':';
            attrName += attributes.qName(i);
            data->m_properties[ attrName ] = attributes.value(i);
            kDebug(30520) << "Format Property (for FORMATS):" << attrName << " =" << attributes.value(i);
        }
        stackItem->elementType = KWord13TypeEmpty;
        return true;
    } else if (stackItem->elementType == KWord13TypeIgnore) {
        return true;
    } else {
        kError(30520) << "Wrong parents for FORMAT property: " << name;
        return false;
    }
}
	bool startElement( const QString& nsURI, const QString& locName, const QString& qName,
	                   const QXmlAttributes& qattr)
	{
		Xml_attr attr;
		for (int i=0; i < qattr.count(); ++i)
			attr[qattr.qName(i)] = fromSTLString(qattr.value(i).toUtf8().data());
		dig->begin(qName, attr);
		return true;
	}
示例#7
0
bool KEYBMAPParser::startElement( const QString&, const QString&, const QString &name, const QXmlAttributes &attrs )
{
    QString desc = "";
    QString modifier="";
    int scancode,masterscancode,delay,x,y,w,h;
    View view=FRONTview;
    bool ok = false;

    scancode=masterscancode=delay=x=y=w=h=0;

    if( inKeyboard && name == "KEY" )
    {

        for( int i=0; i<attrs.count(); i++ )
        {
            if( attrs.localName( i ) == "description" )
                desc = attrs.value( i );
            else if( attrs.localName( i ) == "scancode" )
                scancode = attrs.value( i ).toInt(&ok,16);
            else if( attrs.localName( i ) == "left" )
                x = attrs.value( i ).toInt(&ok,10);
            else if( attrs.localName( i ) == "top" )
                y = attrs.value( i ).toInt(&ok,10);
            else if( attrs.localName( i ) == "width" )
                w = attrs.value( i ).toInt(&ok,10);
            else if( attrs.localName( i ) == "height" )
                h = attrs.value( i ).toInt(&ok,10);
            else if( attrs.localName( i ) == "masterscancode" )
                masterscancode = attrs.value( i ).toInt(&ok,16);
            else if( attrs.localName( i ) == "delay" ) {
                delay = attrs.value( i ).toInt(&ok,10);
                qWarning()<<"delay="<<delay;
            }
            else if( attrs.localName( i ) == "modifier" )
                modifier = attrs.value( i );
            else if( attrs.localName( i ) == "view" ) {
                if (attrs.value( i ) == "FRONT") view = FRONTview;
                if (attrs.value( i ) == "TOP") view = TOPview;
                if (attrs.value( i ) == "LEFT") view = LEFTview;
                if (attrs.value( i ) == "RIGHT") view = RIGHTview;
                if (attrs.value( i ) == "BACK") view = BACKview;
                if (attrs.value( i ) == "BOTTOM") view = BOTTOMview;
            }
        }
        Parent->Keys.append(CKey(scancode,desc,QRect(x,y,w,h),masterscancode,modifier,view,delay));
        AddLog(LOG_KEYBOARD,mainwindow->tr("XML Read key : %1, scan=0x%2 , Rect=(%3,%4,%5,%6), mscan=0x%7, mod=%8").
               arg(desc).
               arg(scancode,2,16,QChar('0')).
               arg(x).arg(y).arg(w).arg(h).
               arg(masterscancode,2,16,QChar('0')).
               arg(modifier));
    }
    else if( name == "Keyboard" )
        inKeyboard = true;

    return true;
}
示例#8
0
QString FbXmlHandler::NodeHandler::Value(const QXmlAttributes &attributes, const QString &name)
{
    int count = attributes.count();
    for (int i = 0; i < count; ++i ) {
        if (attributes.localName(i).compare(name, Qt::CaseInsensitive) == 0) {
            return attributes.value(i);
        }
    }
    return QString();
}
示例#9
0
bool PokedexParser::startElement(const QString		&//namespaceURI
				 ,
				 const QString		&//localName
				 ,
				 const QString		&qName,
				 const QXmlAttributes	&attrs)
{
  if (qName == "pokedex")
    this->inPokedex_ = true;
  else if (qName == "pokemon")
    {
      if ((attrs.count() >= 1) && (attrs.qName(0) == "id"))
	tmpPok_ = new Pokemon(attrs.value(0).toInt());
      else
	tmpPok_ = NULL;
    }
  else if (qName == "evolution")
    {
      if ((attrs.count() >= 1) && (attrs.qName(0) == "id"))
	tmpEvo_ = new Evolution(attrs.value(0).toInt());
      inEvo_ = true;
    }
  else if (qName == "move")
    {
      if ((attrs.count() >= 1) && (attrs.qName(0) == "type"))
	{
	  if (attrs.value(0) == "level-up")
	    {
	      tmpLevel_ = new Level();
	      inLevel_ = true;
	    }
	  else if (attrs.value(0) == "TM/HM")
	    {
	      tmpTm_hm_ = new Tm_hm();
	      inTmHm_ = true;
	    }
	  else if (attrs.value(0) == "egg")
	    inEggs_ = true;
	}
    }
  return true;
}
示例#10
0
 virtual bool startElement(const QString &namespaceURI,
                           const QString &localName,
                           const QString &qName,
                           const QXmlAttributes &atts)
 {
     Q_UNUSED(namespaceURI);
     Q_UNUSED(localName);
     Q_UNUSED(qName);
     attrName = atts.qName(0);
     attrCount = atts.count();
     return true;
 }
示例#11
0
bool XMLSettingParser::startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes)
{
  if (qName.toLower() == "settings")
  {
    for (int i = 0; i < attributes.count(); i++)
    {
      m_map[attributes.qName(i)] = attributes.value(i);
    }
  }

  return true;
}
示例#12
0
bool XmlHandler::startElement(const QString &/*namespaceURI*/, const QString &/*localName*/,
                      const QString &qName, const QXmlAttributes &attributes)
{
	if( qName == this->qName ) {
		IsoCodeEntry entry;
		for(int i=0; i<attributes.count(); i++) {
			entry.insert(attributes.qName(i), attributes.value(i));
		}
		isoEntryList.append(entry);
	}
	return true;
}
示例#13
0
bool LibraryParser::startElement( const QString&, const QString&, const QString &name, const QXmlAttributes &attrs)
{
    // start of a new library definition
    buffer.clear();
    if(name == "library") {
        library = new Library();
        for(int i=0; i<attrs.count(); i++) {
            if (attrs.qName(i) == "name") library->name = attrs.value(i);
        }
    }

    return true;
}
示例#14
0
QString ContentHandler::formatAttributes(const QXmlAttributes &atts)
{
    QString result;
    for (int i = 0, cnt = atts.count(); i < cnt; ++i) {
	if (i != 0) result += ", ";
	result += "{localName=\"" + escapeStr(atts.localName(i))
		    + "\", qName=\"" + escapeStr(atts.qName(i))
		    + "\", uri=\"" + escapeStr(atts.uri(i))
		    + "\", type=\"" + escapeStr(atts.type(i))
		    + "\", value=\"" + escapeStr(atts.value(i)) + "\"}";
    }
    return result;
}
示例#15
0
bool TestResultHandler::startElement(const QString &namespaceURI,
                                     const QString &localName,
                                     const QString &,
                                     const QXmlAttributes &atts)
{
    /* We only care about 'test-case', ignore everything else. */
    if(localName != QLatin1String("test-case") ||
       namespaceURI != Global::xqtsResultNS)
        return true;

    /* The 'comments' attribute is optional. */
    Q_ASSERT_X(atts.count() == 2 || atts.count() == 3, Q_FUNC_INFO,
               "The input appears to not conform to XQTSResult.xsd");

    Q_ASSERT_X(!m_result.contains(atts.value(QLatin1String("name"))),
               Q_FUNC_INFO,
               qPrintable(QString::fromLatin1("A test result for test case %1 has "
                                              "already been read(duplicate entry it seems).").arg(atts.value(QLatin1String("name")))));

    m_result.insert(atts.value(0), TestResult::statusFromString(atts.value(QLatin1String("result"))));

    return true;
}
示例#16
0
bool nftrcreader::startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs) 
{
	if (name == "name")
		inName = true;
	else if (name == "file")
		inFile = true;
	else if (name == "tnail")
		inTNail = true;
	else if (name == "img")
		inImg = true;
	else if (name == "psize")
		inPSize = true;
	else if (name == "color") 
		inColor = true;
	else if (name == "descr")
		inDescr = true;
	else if (name == "usage")
		inUsage = true;
	else if (name == "scribus_version")
		inScribusVersion = true;
	else if (name == "date")
		inDate = true;
	else if (name == "author")
		inAuthor = true;
	else if (name == "email")
		inEmail = true;


	if (name == "template") { // new template starts here
		inTemplate = true;
		QString category;
		QString enCat;
		for (int i = 0; i < attrs.count(); i++)
		{
			if (attrs.localName(i) == "category")
			{
				category = getCategory(attrs.value(i));
				enCat = attrs.value(i);
			}
		}
		tmpTemplate = new nfttemplate(new QFile(currentFile), category); // create a new template
		tmpTemplate->enCategory = enCat;
	}

	if (name == "settings") 
		inSettings = true;

	return true;
}
示例#17
0
void StyleReader::defaultStyle(const QXmlAttributes& attrs)
{
	currentStyle = NULL;
	for (int i = 0; i < attrs.count(); ++i)
		if (attrs.localName(i) == "style:family")
			if (attrs.value(i) == "paragraph")
			{
				gtParagraphStyle* pstyle = new gtParagraphStyle(*(writer->getDefaultStyle()));
				pstyle->setDefaultStyle(true);
				currentStyle = dynamic_cast<gtStyle*>(pstyle);
				currentStyle->setName("default-style");
				readProperties = true;
				defaultStyleCreated = true;
			}
}
示例#18
0
bool ImportHandler::startElement (const QString &, const QString &, const QString &qName, const QXmlAttributes &atts ) {
	m_data = "";

	if (qName == "template")
		inTemplate = true;

	if (! inTemplate)
		return true;

	//save sttributes to a map
	m_attributes.clear();
	for (int i = 0; i < atts.count(); ++i)
		m_attributes[atts.qName(i)] = atts.value(i);
	return true;
}
示例#19
0
bool MetaBundle::XmlLoader::startElement( const QString &, const QString &localName, const QString &, const QXmlAttributes &atts )
{
    if( localName == "item" )
    {
        m_bundle.clear();
        m_attributes.clear();
        for( int i = 0, n = atts.count(); i < n; ++i )
            newAttribute( atts.localName( i ), atts.value( i ) );

        m_currentElement = QString::null;
    }
    else
        m_currentElement = localName;

    return true;
}
示例#20
0
	bool startElement(const QString & szNamespaceUri, const QString & szLocalName, const QString & szQualifiedName, const QXmlAttributes & attrs) override
	{
		KviKvsVariant ret;
		KviKvsVariantList par;
		par.setAutoDelete(true);
		par.append(new KviKvsVariant(szQualifiedName));
		KviKvsHash * pHash = new KviKvsHash();
		par.append(new KviKvsVariant(pHash));
		par.append(new KviKvsVariant(szNamespaceUri));
		par.append(new KviKvsVariant(szLocalName));
		int c = attrs.count();
		for(int i = 0; i < c; i++)
			pHash->set(attrs.qName(i), new KviKvsVariant(attrs.value(i)));
		if(!m_pReader->callFunction(m_pReader, "onElementStart", &ret, &par))
			return kvsCodeFailure();
		return handleKvsCallReturnValue(&ret);
	}
void cElement::copyAttributes( const QXmlAttributes& attributes )
{
	freeAttributes();
	attrCount_ = attributes.count();

	if ( attrCount_ > 0 )
	{
		this->attributes = new stAttribute * [attrCount_];

		for ( unsigned int i = 0; i < attrCount_; ++i )
		{
			this->attributes[i] = new stAttribute;
			this->attributes[i]->name = attributes.localName( i );
			this->attributes[i]->value = attributes.value( i );
		}
	}
}
示例#22
0
文件: config.cpp 项目: viking/krails
bool ConfigHandler::startElement( const QString &, const QString &, const QString &name, const QXmlAttributes &attrs )
{
  if (inConf && name == "tab") {
    for(int i = 0; i < attrs.count(); i++) {
      if (attrs.localName(i) == "name")
        tName = attrs.value(i);
      else if (attrs.localName(i) == "dir")
        tDir = attrs.value(i);
      else if (attrs.localName(i) == "command")
        tCommand = attrs.value(i);
    }
  }
  else if ( name == "krails" ) {
    inConf = true;
  }

  return true;
}
示例#23
0
bool KWord13Parser::startElementDocumentAttributes(const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem,
        const KWord13StackItemType& allowedParentType, const KWord13StackItemType& newType)
{
    if (parserStack.current()->elementType == allowedParentType) {
        stackItem->elementType = newType;
        for (int i = 0; i < attributes.count(); ++i) {
            QString attrName(name);
            attrName += ':';
            attrName += attributes.qName(i);
            m_kwordDocument->m_documentProperties[ attrName ] = attributes.value(i);
            kDebug(30520) << "DocAttr:" <<  attrName << " =" << attributes.value(i);
        }
        return true;
    } else {
        kError(30520) << "Wrong parent!";
        return false;
    }
}
示例#24
0
bool TweakIndexHandler::startElement (const QString &, const QString &, const QString &qName, const QXmlAttributes &atts ) {

	// Start processing tweak
	if (qName == "tweak") {
		tweak = new Tweak();
		inTweak = true;
	}

	// Not processing a tweak. nothing to do
	if (!inTweak)
		return true;

	m_data = "";
	//save sttributes to a map
	m_attributes.clear();
	for (int i = 0; i < atts.count(); ++i)
		m_attributes[atts.qName(i)] = atts.value(i);
	return true;
}
示例#25
0
void FbReadHandler::TextHandler::Init(const QString &name, const QXmlAttributes &atts)
{
    Keyword key = toKeyword(name);
    writer().writeStartElement(m_tag);
    int count = atts.count();
    for (int i = 0; i < count; i++) {
        QString name = atts.qName(i);
        switch (key) {
            case Anchor: { if (atts.localName(i) == "href") name = "href"; break; }
            case Image:  { if (atts.localName(i) == "href") name = "src"; break; }
            default: ;
        }
        writer().writeAttribute(name, atts.value(i));
    }
    if (name == "empty-line") {
        writer().writeEmptyElement("br");
        m_empty = false;
    }
}
示例#26
0
bool TrackReader::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts)
{
    Q_UNUSED(qName)

    const QString eName  = myQName(namespaceURI, localName);
    d->currentElements << eName;
    rebuildElementPath();
    const QString& ePath = d->currentElementPath;

    if (ePath == QString::fromLatin1("gpx:gpx/gpx:trk/gpx:trkseg/gpx:trkpt"))
    {
        qreal lat    = 0.0;
        qreal lon    = 0.0;
        bool haveLat = false;
        bool haveLon = false;

        for (int i = 0; i < atts.count(); ++i)
        {
            const QString attName  = myQName(atts.uri(i), atts.localName(i));
            const QString attValue = atts.value(i);

            if (attName == QString::fromLatin1("lat"))
            {
                lat = attValue.toDouble(&haveLat);
            }
            else if (attName == QString::fromLatin1("lon"))
            {
                lon = attValue.toDouble(&haveLon);
            }
        }

        if (haveLat&&haveLon)
        {
            d->currentDataPoint.coordinates.setLatLon(lat, lon);
        }
    }
    else if (ePath == QString::fromLatin1("gpx:gpx"))
    {
        d->verifyFoundGPXElement = true;
    }

    return true;
}
示例#27
0
bool KWord13Parser::startElementLayoutProperty(const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem)
{
    // ### TODO: check status
    if (stackItem->elementType == KWord13TypeIgnore) {
        return true;
    } else if (m_currentLayout) {
        for (int i = 0; i < attributes.count(); ++i) {
            QString attrName(name);
            attrName += ':';
            attrName += attributes.qName(i);
            m_currentLayout->m_layoutProperties[ attrName ] = attributes.value(i);
            kDebug(30520) << "Layout Property:" << attrName << " =" << attributes.value(i);
        }
        stackItem->elementType = KWord13TypeEmpty;
        return true;
    } else {
        kError(30520) << "No current layout for storing property: " << name;
        return false;
    }
}
示例#28
0
bool SaxHandler::startElement(const QString &namespaceURI ,
                              const QString &localName,
                              const QString &qName,
                              const QXmlAttributes &attributes)
{
    ++depth;
    if (currentItem) {
        currentItem = new QTreeWidgetItem(currentItem);
    } else {
        currentItem = new QTreeWidgetItem(treeWidget);
    }
    currentItem->setText(0, qName);
    QString attrs;
    attrs += QString("namespace=")+namespaceURI+QString(";");
    attrs += QString("localName=")+localName+QString(";");
    for(int i=0; i<attributes.count(); i++)
    {
        attrs += attributes.qName(i) + QString("=");
        attrs += attributes.value(i) + QString(";");
    }
    currentItem->setData(0, Qt::UserRole, attrs);
    return true;
}
示例#29
0
bool W2parser::startElement(const QString &,
                            const QString &,
                            const QString &qName,
                            const QXmlAttributes &atts)
{
    if (qName.compare("item") == 0)
        line.clear();
    else if (qName.compare("ingredients_list") == 0)
        ingredients.clear();

    QString key;
    QString value;
    for (int i = 0; i < atts.count(); ++i) {
        key = atts.localName(i);
        value = atts.value(i);
        if (key.compare("name") == 0)
            line.append(value + ",");
        else if (key.compare("crafted_item") == 0)
            line.append(value + ",");
    }

    return true;
}
bool UserMetricParser::startElement( const QString&, const QString&, const QString &, const QXmlAttributes &attrs)
{
    // reset
    add = UserMetricSettings();
    buffer.clear();

    // basic settings for the metric are in the element attributes
    for(int i=0; i<attrs.count(); i++) {
        if (attrs.qName(i) == "symbol") add.symbol=attrs.value(i);
        if (attrs.qName(i) == "name") add.name=attrs.value(i);
        if (attrs.qName(i) == "description") add.description=attrs.value(i);
        if (attrs.qName(i) == "precision") add.precision=attrs.value(i).toInt();
        if (attrs.qName(i) == "aggzero") add.aggzero=attrs.value(i).toInt();
        if (attrs.qName(i) == "istime") add.istime=attrs.value(i).toInt();
        if (attrs.qName(i) == "type") add.type=attrs.value(i).toInt();
        if (attrs.qName(i) == "unitsMetric") add.unitsMetric=attrs.value(i);
        if (attrs.qName(i) == "unitsImperial") add.unitsImperial=attrs.value(i);
        if (attrs.qName(i) == "conversion") add.conversion=attrs.value(i).toDouble();
        if (attrs.qName(i) == "conversionSum") add.conversionSum=attrs.value(i).toDouble();
        if (attrs.qName(i) == "fingerprint") add.fingerprint=attrs.value(i);
    }

    return true;
}