示例#1
0
bool TsHandler::startElement( const QString& /* namespaceURI */,
                              const QString& /* localName */,
                              const QString& qName,
                              const QXmlAttributes& atts )
{
    if ( qName == QString("byte") ) {
        for ( int i = 0; i < atts.length(); i++ ) {
            if ( atts.qName(i) == QString("value") ) {
                QString value = atts.value( i );
                int base = 10;
                if ( value.startsWith("x") ) {
                    base = 16;
                    value = value.mid( 1 );
                }
                int n = value.toUInt( 0, base );
                if ( n != 0 )
                    accum += QChar( n );
            }
        }
    } else {
        if ( qName == QString("TS") ) {
            m_language = atts.value(QLatin1String("language"));
        } else if ( qName == QString("context") ) {
            context.truncate( 0 );
            source.truncate( 0 );
            comment.truncate( 0 );
            m_translatorComment.truncate( 0 );
            translations.clear();
            contextIsUtf8 = encodingIsUtf8( atts );
        } else if ( qName == QString("message") ) {
            inMessage = true;
            type = MetaTranslatorMessage::Finished;
            source.truncate( 0 );
            comment.truncate( 0 );
            m_translatorComment.truncate( 0 );
            translations.clear();
            messageIsUtf8 = encodingIsUtf8( atts );
            m_isPlural = atts.value(QLatin1String("numerus")).compare(QLatin1String("yes")) == 0;
        } else if (qName == QString("location") && inMessage) {
            bool bOK;
            int lineNo = atts.value(QString("line")).toInt(&bOK);
            if (!bOK) lineNo = -1;
            m_fileName = atts.value(QString("filename"));
            m_lineNumber = lineNo;
        } else if ( qName == QString("translation") ) {
            for ( int i = 0; i < atts.length(); i++ ) {
                if ( atts.qName(i) == QString("type") ) {
                    if ( atts.value(i) == QString("unfinished") )
                        type = MetaTranslatorMessage::Unfinished;
                    else if ( atts.value(i) == QString("obsolete") )
                        type = MetaTranslatorMessage::Obsolete;
                    else
                        type = MetaTranslatorMessage::Finished;
                }
            }
        }
        accum.truncate( 0 );
    }
    return true;
}
示例#2
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;
}
bool TsHandler::startElement( const QString& /* namespaceURI */, const QString& /* localName */, const QString& qName, const QXmlAttributes& atts )
{
	if ( qName == QString( "byte" ) )
	{
		for ( int i = 0; i < atts.length(); i++ )
		{
			if ( atts.qName( i ) == QString( "value" ) )
			{
				QString value = atts.value( i );
				int base = 10;
				if ( value.startsWith( "x" ) )
				{
					base = 16;
					value = value.mid( 1 );
				}
				int n = value.toUInt( 0, base );
				if ( n != 0 )
					accum += QChar( n );
			}
		}
	}
	else
	{
		if ( qName == QString( "context" ) )
		{
			context.truncate( 0 );
			source.truncate( 0 );
			comment.truncate( 0 );
			translation.truncate( 0 );
			contextIsUtf8 = encodingIsUtf8( atts );
		}
		else if ( qName == QString( "message" ) )
		{
			inMessage = TRUE;
			type = MetaTranslatorMessage::Finished;
			source.truncate( 0 );
			comment.truncate( 0 );
			translation.truncate( 0 );
			messageIsUtf8 = encodingIsUtf8( atts );
		}
		else if ( qName == QString( "translation" ) )
		{
			for ( int i = 0; i < atts.length(); i++ )
			{
				if ( atts.qName( i ) == QString( "type" ) )
				{
					if ( atts.value( i ) == QString( "unfinished" ) )
						type = MetaTranslatorMessage::Unfinished;
					else if ( atts.value( i ) == QString( "obsolete" ) )
						type = MetaTranslatorMessage::Obsolete;
					else
						type = MetaTranslatorMessage::Finished;
				}
			}
		}
		accum.truncate( 0 );
	}
	return TRUE;
}
static bool encodingIsUtf8( const QXmlAttributes& atts )
{
    for ( int i = 0; i < atts.length(); i++ ) {
	// utf8="true" is a pre-3.0 syntax
	if ( atts.qName(i) == QString("utf8") ) {
	    return ( atts.value(i) == QString("true") );
	} else if ( atts.qName(i) == QString("encoding") ) {
	    return ( atts.value(i) == QString("UTF-8") );
	}
    }
    return FALSE;
}
		bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
		{
			if(depth == 0) {
				Parser::Event *e = new Parser::Event;
				QXmlAttributes a;
				for(int n = 0; n < atts.length(); ++n) {
					QString uri = atts.uri(n);
					QString ln = atts.localName(n);
					if(a.index(uri, ln) == -1)
						a.append(atts.qName(n), uri, ln, atts.value(n));
				}
				e->setDocumentOpen(namespaceURI, localName, qName, a, nsnames, nsvalues);
				nsnames.clear();
				nsvalues.clear();
				e->setActualString(in->lastString());

				in->resetLastData();
				eventList.append(e);
				in->pause(true);
			}
			else {
				QDomElement e = doc->createElementNS(namespaceURI, qName);
				for(int n = 0; n < atts.length(); ++n) {
					QString uri = atts.uri(n);
					QString ln = atts.localName(n);
					bool have;
					if(!uri.isEmpty()) {
						have = e.hasAttributeNS(uri, ln);
						if(qt_bug_have)
							have = !have;
					}
					else
						have = e.hasAttribute(ln);
					if(!have)
						e.setAttributeNS(uri, atts.qName(n), atts.value(n));
				}

				if(depth == 1) {
					elem = e;
					current = e;
				}
				else {
					current.appendChild(e);
					current = e;
				}
			}
			++depth;
			return true;
		}
示例#6
0
bool XMLHandler::startElement(const QString &namespaceURI, const QString & /*localName*/, const QString &qName, const QXmlAttributes &atts)
{
    if(currentNode()->nodeType() == Node::TEXT_NODE)
        exitText();

    DOMString nsURI;
    if(!namespaceURI.isNull())
        nsURI = DOMString(namespaceURI);
    else
        // No namespace declared, default to the no namespace
        nsURI = DOMString("");
    ElementImpl *newElement = m_doc->createElementNS(nsURI, qName);
    if(!newElement)
        return false;
    int i;
    for(i = 0; i < atts.length(); i++)
    {
        int exceptioncode = 0;
        QString uriString = atts.uri(i);
        QString qnString = atts.qName(i);
        fixUpNSURI(uriString, qnString);
        DOMString uri(uriString);
        DOMString qn(qnString);
        DOMString val(atts.value(i));
        newElement->setAttributeNS(uri, qn, val, exceptioncode);
        if(exceptioncode) // exception setting attributes
            return false;
    }

    if(newElement->id() == ID_SCRIPT || newElement->id() == makeId(xhtmlNamespace, ID_SCRIPT))
        static_cast< HTMLScriptElementImpl * >(newElement)->setCreatedByParser(true);

    // this is tricky. in general the node doesn't have to attach to the one it's in. as far
    // as standards go this is wrong, but there's literally thousands of documents where
    // we see <p><ul>...</ul></p>. the following code is there for those cases.
    // when we can't attach to the currently holding us node we try to attach to its parent
    bool attached = false;
    for(NodeImpl *current = currentNode(); current; current = current->parent())
    {
        attached = current->addChild(newElement);
        if(attached)
            break;
    }
    if(attached)
    {
        if(m_view && !newElement->attached() && !m_doc->hasPendingSheets())
            newElement->attach();
        pushNode(newElement);
        return true;
    }
    else
    {
        delete newElement;
        return false;
    }

    // ### DOM spec states: "if there is no markup inside an element's content, the text is contained in a
    // single object implementing the Text interface that is the only child of the element."... do we
    // need to ensure that empty elements always have an empty text child?
}
示例#7
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;
}
示例#8
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;
    }
bool TemplateQueryHandler::startElement ( const QString & /*namespaceURI*/, const QString & /*localName*/, const QString & qName, const QXmlAttributes & atts )
{
  //qDebug() << "startElement: " << qName;
  if(!m_inTripleList && (qName.compare("triple_list")==0 ))
    {
      m_inTripleList = true;
      return true;
    }
  if(m_currentTriple)
    {
      if(qName.compare("subject") == 0 )
	{
	  // no need to check for element type, since subject are always URIs (when received)
	  m_component = ESubject;
	}
      else if(qName.compare("predicate") == 0 )
	{
	  // no need to check for element type, since predicates are always URIs 
	  m_component = EPredicate;
	}
      else if(qName.compare("object") == 0 && 
	      (atts.length() == 1) && 
	      (atts.qName(0).compare("type") == 0))
	{
	  //check elementtype for object, bNode is illegal when received.
	  QString attrvalue = atts.value(0);
	  m_component = EObject;
	  if( attrvalue.compare("literal", Qt::CaseInsensitive) == 0) 
	    m_elementType = TripleElement::ElementTypeLiteral;
	  else if (attrvalue.compare("URI", Qt::CaseInsensitive) == 0)
	    m_elementType = TripleElement::ElementTypeURI;
	  else
	    {
	      m_errorString = "Invalid object type: ";
	      m_errorString.append(attrvalue);
	      return false;
	    }
	  m_component = EObject;
	}
      else
	{
	  m_errorString = "Invalid element name for a triple: ";
	  m_errorString.append(qName);
	  return false;
	}
    }
  else
    {
      if(qName.compare("triple") == 0 )
	{
	  m_currentTriple = new Triple();
	}
      else
	{
	  m_errorString = "starting something other than triple element";
	  return false;
	}
    }
  return true;
}
bool StructureParser::startElement( const QString& namespaceURI,
                                    const QString& ,
                                    const QString& qName,
                                    const QXmlAttributes& attributes)
{
    QTreeWidgetItem * element;


    if (!stack.isEmpty())
    {
        QTreeWidgetItem *lastChild = stack.top().firstChild();

        if ( lastChild )
        {
            while ( lastChild->nextSibling() )
                lastChild = lastChild->nextSibling();
        }
        element = new QTreeWidgetItem( stack.top(), lastChild, qName, namespaceURI );
    }
    else
    {
        element = new QTreeWidgetItem( table, qName, namespaceURI );
    }

    stack.push( element );
    element->setOpen( TRUE );
    if ( attributes.length() > 0 ) {
        for ( int i = 0 ; i < attributes.length(); i++ ) {
            new QTreeWidgetItem( element, attributes.qName(i), attributes.uri(i) );
        }
    }
    return TRUE;
}
示例#11
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;
	}
示例#13
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;
}
示例#14
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;
}
示例#15
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;
 }
示例#16
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;
}
示例#17
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;
}
示例#18
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;
}
示例#19
0
文件: myhandler.cpp 项目: jabouzi/qt
bool MyHandler::startElement( const QString&, /* We have omitted the names of the parameters that we don't use. This prevents the compiler from issuing "unused parameter" warnings. */
                              const QString&, const QString& qName,
                              const QXmlAttributes& atts) {
    QString str = QString("\n%1\\%2").arg(indent).arg(qName);
    cout << str;
    if (atts.length()>0) {
        QString fieldName = atts.qName(0);
        QString fieldValue = atts.value(0);
        cout << QString("(%2=%3)").arg(fieldName).arg(fieldValue);
    }
    cout << "{";
    indent += "    ";
    return TRUE;
}
示例#20
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;
}
示例#21
0
/*!
    Start parsing an element called \a qName, which can be be broken up
    into \a namespaceURI and \a localName.  The attribute list is \a atts.
*/
bool QWbXmlToXmlContentHandler::startElement( const QString& , const QString& , const QString& qName, const QXmlAttributes& atts )
{
    if ( d->lastWasTag ) {
        d->result += "\n";
        addIndent();
    }
    ++(d->indent);
    d->result += "<" + qName;
    for( int index = 0; index < atts.length(); ++index ) {
        d->result += " " + atts.qName( index ) + "=\"";
        addQuoted( atts.value( index ) );
        d->result += "\"";
    }
    d->result += ">";
    d->lastWasTag = true;
    return true;
}
示例#22
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);
	}
示例#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
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;
    }
}
示例#25
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;
}
示例#26
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;
    }
}
示例#27
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;
}
bool PlannerParser::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& att )
{
    kDebug() << "entering function";
    QString taskName;
    int     taskComplete=0;
    
    // only <task>s within <tasks> are processed
    if (qName == QString::fromLatin1("tasks")) withInTasks=true;
    if ((qName == QString::fromLatin1("task")) && (withInTasks))
    {
        // find out name and percent-complete
        for (int i=0; i<att.length(); i++)
        {
            if (att.qName(i) == QString::fromLatin1("name")) taskName=att.value(i);
            if (att.qName(i)==QString::fromLatin1("percent-complete")) taskComplete=att.value(i).toInt();
        }
    
        // at the moment, task is still the old task or the old father task (if an endElement occurred) or not existing (if the
        // new task is a top-level-task). Make task the parenttask, if existing.
        DesktopList dl;
        if (level++>0)
        {
            parentTask=task;
            task = new Task(taskName, 0, 0, dl, parentTask);
            task->setUid(_taskView->storage()->addTask(task, parentTask));
        }
        else
        {
            task = new Task(taskName, 0, 0, dl, _taskView);
            kDebug() <<"added" << taskName;
            task->setUid(_taskView->storage()->addTask(task, 0));
        }
        task->setPercentComplete(taskComplete, _taskView->storage());
    }
    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;
}
示例#30
0
    bool startElement(const QString&, const QString &,
                      const QString &name, const QXmlAttributes &a)
    {
        if (fresh)
        {
            if (name.lower()=="asx")
            {
                //kdDebug(66666) << "found ASX format" << endl;
                fresh=false;
                return true;
            }
            else
            {
                kdDebug(66666) << "This is NOT an ASX style playlist!" << endl;
                return false;
            }
        }

        if (name.lower()=="entry")
        {
            if(inEntry) // WHOOPS, we are already in an entry, this should NEVER happen
            {
                kdDebug(66666) << "STOP, ENTRY INSIDE ENTRY!" << endl;
                return false;
            }
//			kdDebug(66666) << "<ENTRY> =====================" << endl;
            inEntry=true;
        }
        else
        {
            if (inEntry) // inside entry block
            {
                // known stuff inside an <entry> ... </entry> block:
                // <title>blah</title>
                // <param album="blub" />
                // <param artist="blah" />
                // <ref HREF="file:/something" />
                if(name.lower()=="ref")
                {
                    for (int i=0; i<a.count(); i++)
                    {
                        if(a.qName(i).lower()=="href")
                        {
                            QString filename=a.value(i);
                            if (filename.find(QRegExp("^[a-zA-Z0-9]+:/"))==0)
                            {
                                KURL url(filename);
                                KMimeType::Ptr mimetype = KMimeType::findByURL(url);
                                QString type=mimetype->name();
                                if (type != "application/octet-stream")
                                {
                                    propMap["url"]=filename;
                                }
                                else
                                {
                                    propMap["playObject"]="SplayPlayObject";
                                    propMap["title"] = i18n("Stream from %1").arg(url.host());
                                    if (!url.hasPath())
                                        url.setPath("/");
                                    propMap["url"] = url.url();
                                    propMap["stream_"]=propMap["url"];
//									readItem(propMap);
//									continue;
                                }
                            }
                            else
                            {
                                KURL u1;
                                // we have to deal with a relative path
                                if (filename.find('/'))
                                {
                                    u1.setPath(mAbsPath); //FIXME: how to get the path in this place?
                                    u1.setFileName(filename);
                                }
                                else
                                {
                                    u1.setPath(filename);
                                }
                                propMap["url"]=u1.url();
                            }
//							kdDebug(66666) << "adding property url, value='" << propMap["url"] << "'" << endl;
                        }
                    }
                }
                else if(name.lower()=="param")
                {
                    QString keyName="", keyValue="";

                    for (int i=0; i<a.count(); i++)
                    {
                        if(a.value(i).lower()=="album")
                            keyName="album";
                        else if(a.value(i).lower()=="artist")
                            keyName="author";
                        else if(!keyName.isEmpty()) // successfully found a key, the next key=value pair has to be the value
                        {
//							kdDebug(66666) << "keyName=" << keyName << ", next value is '" << a.value(i) << "'" << endl;
                            keyValue=a.value(i);
                        }
                    }

                    if (!keyName.isEmpty() && !keyValue.isEmpty())
                    {
//						kdDebug(66666) << "adding property; key='" << keyName << "', value='" << keyValue << "'" << endl;
                        propMap[keyName]=keyValue;
                    }
                }
                else if(name.lower()=="title")
                {
                    if(inTitle) // WHOOPS, we are already in an entry, this should NEVER happen
                    {
                        kdDebug(66666) << "STOP, TITLE INSIDE TITLE!" << endl;
                        return false;
                    }
//					kdDebug(66666) << "<TITLE> ======" << endl;
                    inTitle=true;
                }
                /*				else
                				{
                					kdDebug(66666) << "Unknown/unused element inside ENTRY block, NAME='" << name << "'" << endl;
                					for (int i=0; i<a.count(); i++)
                						kdDebug(66666) << " | " << a.qName(i) << " = '" << a.value(i) << "'" << endl;
                				}*/
            }
            /*			else
            			{
            				kdDebug(66666) << "Uninteresting element, NAME='" << name << "'" << endl;
            				for (int i=0; i<a.count(); i++)
            					kdDebug(66666) << "  | " << a.qName(i) << " = '" << a.value(i) << "'" << endl;
            			}*/
        }

        return true;
    }