Example #1
0
void Platform::processNodeAttributes(const QDomElement &element)
{
    QDomNamedNodeMap namedNodeMap = element.attributes();

    if (namedNodeMap.size() == 1) {
        QDomNode domNode = namedNodeMap.item(0);

        if (domNode.nodeType() == QDomNode::AttributeNode) {
            QDomAttr domElement = domNode.toAttr();

            if (domElement.name() == QString("Name")) {
                m_name = domElement.value();
//                vc_dbg << "AttributeNode: name: " << domElement.name() << " value: " << domElement.value();
            }
        }
    }
}
Example #2
0
/**
 * Check that the node map doesn't contain any unknown elements
 * @param attrs node map to check
 * @param names list of known names
 * @return false if node map contains unknown elements
 */
bool isKnown(const QDomNamedNodeMap& attrs, const char **names) {
	bool ok=true;
	for(int i=0;i<attrs.length();++i) {
		QDomNode n = attrs.item(i);
		const char **name = names;
		bool found=false;
		while(!found && *name!=0) {
			found = n.nodeName() == *name;
			++name;
		}
		if(!found) {
			qWarning() << "Unknown attribute" << n.nodeName();
			ok=false;
		}
	}
	return ok;
}
Example #3
0
void Definitions::loadXML( ParserContext *context, const QDomElement &element )
{
  setTargetNamespace( element.attribute( "targetNamespace" ) );
  mName = element.attribute( "name" );

  QDomNamedNodeMap attributes = element.attributes();
  for ( int i = 0; i < attributes.count(); ++i ) {
    QDomAttr attribute = attributes.item( i ).toAttr();
    if ( attribute.name().startsWith( "xmlns:" ) ) {
      QString prefix = attribute.name().mid( 6 );
      context->namespaceManager()->setPrefix( prefix, attribute.value() );
    }
  }

  QDomElement child = element.firstChildElement();
  while ( !child.isNull() ) {
    QName tagName = child.tagName();
    if ( tagName.localName() == "import" ) {
      Import import( mTargetNamespace );
      import.loadXML( context, child );
      mImports.append( import );
    } else if ( tagName.localName() == "types" ) {
      mType.loadXML( context, child );
    } else if ( tagName.localName() == "message" ) {
      Message message( mTargetNamespace );
      message.loadXML( context, child );
      mMessages.append( message );
    } else if ( tagName.localName() == "portType" ) {
      PortType portType( mTargetNamespace );
      portType.loadXML( context, child );
      mPortTypes.append( portType );
    } else if ( tagName.localName() == "binding" ) {
      Binding binding( mTargetNamespace );
      binding.loadXML( context, child );
      mBindings.append( binding );
    } else if ( tagName.localName() == "service" ) {
      mService.loadXML( context, &mBindings, child );
    } else if ( tagName.localName() == "documentation" ) {
      // ignore documentation for now
    } else {
      context->messageHandler()->warning( QString( "Definitions: unknown tag %1" ).arg( child.tagName() ) );
    }

    child = child.nextSiblingElement();
  }
}
Example #4
0
void NodeBrowser::itemClicked( QTreeWidgetItem *itm )
{
	d->browser.properties->clear();
	
	if( itm == 0) return;
	
	d->domPath = d->node->path("",itm);
	d->browser.path->setText(d->domPath);
	
	QDomNode node = SxDomUtils::getElement( d->doc.toElement(), d->domPath ); 
	if( !node.isNull() )
	{
		QDomNamedNodeMap map = node.attributes();
		int count = map.count();
		for( int idx = 0; idx < count; ++idx)
		d->browser.properties->addItem( map.item(idx).nodeName() );
	}
}
Example #5
0
static QDomElement addCorrectNS(const QDomElement &e)
{
	uint x;

	// grab child nodes
	/*QDomDocumentFragment frag = e.ownerDocument().createDocumentFragment();
	QDomNodeList nl = e.childNodes();
	for(x = 0; x < nl.count(); ++x)
		frag.appendChild(nl.item(x).cloneNode());*/

	// find closest xmlns
	QDomNode n = e;
	while(!n.isNull() && !n.toElement().hasAttribute("xmlns"))
		n = n.parentNode();
	QString ns;
	if(n.isNull() || !n.toElement().hasAttribute("xmlns"))
		ns = "jabber:client";
	else
		ns = n.toElement().attribute("xmlns");

	// make a new node
	QDomElement i = e.ownerDocument().createElementNS(ns, e.tagName());

	// copy attributes
	QDomNamedNodeMap al = e.attributes();
	for(x = 0; x < al.count(); ++x) {
		QDomAttr a = al.item(x).toAttr();
		if(a.name() != "xmlns")
			i.setAttributeNodeNS(a.cloneNode().toAttr());
	}

	// copy children
	QDomNodeList nl = e.childNodes();
	for(x = 0; x < nl.count(); ++x) {
		QDomNode n = nl.item(x);
		if(n.isElement())
			i.appendChild(addCorrectNS(n.toElement()));
		else
			i.appendChild(n.cloneNode());
	}

	//i.appendChild(frag);
	return i;
}
void FopLeader::RestoreOn( QDomElement appender )
{
	QDomDocument doc;
	
	if (ELoriginal.size() > 8 && doc.setContent(ELoriginal,false) ) {
		    QDomElement root_extern = doc.documentElement(); 
				QDomNamedNodeMap alist = root_extern.attributes();
		
			          QDomElement leader = appender.ownerDocument().createElement("fo:leader");
								for (int i=0; i<alist.count(); i++){
									QDomNode nod = alist.item(i);
									leader.setAttribute(nod.nodeName().toLower(),nod.nodeValue());
								}
								
								QDomNode child = root_extern.firstChild();
										while ( !child.isNull() ) {
											
											if ( child.isElement() ) {
											leader.appendChild(appender.ownerDocument().importNode(child,true).toElement());
											}
											
										child = child.nextSibling();            
										}
				appender.appendChild(leader);
										
	} else {
		
		/* rebuild it but not editable! now  */
		/*
		<fo:leader leader-pattern="rule"
                   rule-thickness="10cm"
                   leader-length="6cm"
                   space-before.optimum="12pt"
                   space-after.optimum="12pt"
                   start-indent="1.5cm"
                   end-indent="2cm"
                   background-color="blue"
                   color="yellow"/>
		*/
	}
	
	
}
Example #7
0
void QtSimpleXml::parse(QDomNode node)
{
 //   puts("parse");
    if (node.isNull())
        return;

    valid = true;
    n = node.nodeName();
    QDomElement element = node.toElement();

    QDomNamedNodeMap attrs = element.attributes();
    for (int i = 0; i < (int) attrs.count(); ++i) {
        QDomAttr attribute = attrs.item(i).toAttr();
        attr.insert(attribute.name(), attribute.value());
    }

    if (element.firstChild().isText()) {
  //      printf("Got text %s\n", element.text().stripWhiteSpace().latin1());
        s = element.text().trimmed();
        return;
    }

    if (node.hasChildNodes()) {

        // Skip to first element child
        QDomNode child = node.firstChild();
        while (!child.isNull() && !child.isElement())
            child = child.nextSibling();

        while (!child.isNull()) {
            QtSimpleXml *xmlNode = new QtSimpleXml;
            xmlNode->parse(child);
            children.insert(xmlNode->name(), xmlNode);

            node = node.nextSibling();

            do {
                child = child.nextSibling();
            } while (!child.isNull() && !child.isElement());
        }
    }
}
Example #8
0
void ComplexBaseInputField::setXMLData( const QDomElement &element )
{
  if ( mName != element.tagName() ) {
    qDebug( "ComplexBaseInputField: Wrong dom element passed: expected %s, got %s", qPrintable( mName ), qPrintable( element.tagName() ) );
    return;
  }

  // elements
  if ( mType->isArray() ) {
    InputField *field = childField( "item" );
    field->setXMLData( element );
  } else {
    QDomNode node = element.firstChild();
    while ( !node.isNull() ) {
      QDomElement child = node.toElement();
      if ( !child.isNull() ) {
        InputField *field = childField( child.tagName() );
        if ( !field ) {
          qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( child.tagName() ) );
        } else {
          field->setXMLData( child );
        }
      }

      node = node.nextSibling();
    }
  }

  // attributes
  QDomNamedNodeMap nodes = element.attributes();
  for ( int i = 0; i < nodes.count(); ++i ) {
    QDomNode node = nodes.item( i );
    QDomAttr attr = node.toAttr();

    InputField *field = childField( attr.name() );
    if ( !field ) {
      qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( attr.name() ) );
    } else {
      field->setData( attr.value() );
    }
  }
}
QByteArray FopLeader::SaveElement( const QDomElement e )
{
    QDomDocument em;
    QDomElement import = em.createElement(e.tagName().toLower());
    em.appendChild( import );
    QDomNamedNodeMap attlist = e.attributes();
    for (int i=0; i<attlist.count(); i++){
    QDomNode nod = attlist.item(i);
    import.setAttribute (nod.nodeName().toLower(),nod.nodeValue()); 
    }
                            QDomNode child = e.firstChild();
                               while ( !child.isNull() ) {
                                   if ( child.isElement() ) {
                                    import.appendChild(em.importNode(child,true).toElement());
                                   }
                                 child = child.nextSibling();            
                               }
															 
    return em.toByteArray(0);
}
Example #10
0
void Xml::htmlToString(QDomElement e, int level, QString* s)
      {
      *s += QString("<%1").arg(e.tagName());
      QDomNamedNodeMap map = e.attributes();
      int n = map.size();
      for (int i = 0; i < n; ++i) {
            QDomAttr a = map.item(i).toAttr();
            *s += QString(" %1=\"%2\"").arg(a.name()).arg(a.value());
            }
      *s += ">";
      ++level;
      for (QDomNode ee = e.firstChild(); !ee.isNull(); ee = ee.nextSibling()) {
            if (ee.nodeType() == QDomNode::ElementNode)
                  htmlToString(ee.toElement(), level, s);
            else if (ee.nodeType() == QDomNode::TextNode)
                  *s += Qt::escape(ee.toText().data());
            }
      *s += QString("</%1>").arg(e.tagName());
      --level;
      }
QVector<Value> AVRStudioXMLParser::GetValues(QDomNodeList nodelist)
{
    QVector<Value> values;

    for(int i = 0; i < nodelist.size(); i++)
    {
        QDomNamedNodeMap attributes =  nodelist.at(i).attributes();
        Value value;

        for(int i = 0; i < attributes.size(); i++)
        {
            QDomNode attribute = attributes.item(i);
            if(value.GetMappingMap()[attribute.nodeName()])
                *value.GetMappingMap()[attribute.nodeName()] = attribute.nodeValue();
        }

        values.append(value);
    }

    return values;
}
Example #12
0
void PdfElement::setAttributes(const QDomNamedNodeMap attr, const QString cdata) {
	_attributes.clear();
	if (cdata != NULL && !cdata.isEmpty()) {
		extractExpressions(const_cast<QString*>(&cdata));
		_attributes.insert("cdata", cdata);
	}
	QString val;
	for (uint i = 0; i < attr.length(); i++) {
		QDomAttr a = attr.item(i).toAttr();
		if (!a.isNull()) {
			if (a.name().toLower() == "nth") {
				_onlyOnLast = a.value().toLower() == "last";
				_onlyOnFirst = a.value().toLower() == "first";
				_onlyOnNth = _onlyOnLast || _onlyOnFirst ? 1 : a.value().toInt();
			}
			val = a.value();
			extractExpressions(const_cast<QString*>(&val));
			_attributes.insert(a.name().toLower(), val);
		}
	}
}
Example #13
0
/**
 * This method is used to load element properties that are stored in plugins
 * @param element The Element being loaded
 * @param elProperties the xml properties of the element
 */
void CMapFileFilterXML::loadPluginPropertiesForElement(CMapElement *element,QDomElement *elProperties)
{
	QDomElement pluginsNode = readChildElement(elProperties,"plugins");
	if (!pluginsNode.isNull())
	{
		QDomNode n = pluginsNode.firstChild();
		while (!n.isNull() )
		{

			QDomElement e = n.toElement();

			if (!e.isNull() )
			{
				for (CMapPluginBase *plugin = m_mapManager->getPluginList()->first(); plugin!=0; plugin = m_mapManager->getPluginList()->next())
				{
					if (plugin->name()==e.tagName())
					{
						KMemConfig pluginProperties;

						QDomNamedNodeMap attribs = e.attributes();

						for (int i=0; i<attribs.length();i++)
						{
							QDomNode n2 = attribs.item(i);

							kDebug() << "Attrib " << n2.nodeName() << " = " << n2.nodeValue();
							pluginProperties.group("Properties").writeEntry(n2.nodeName(),n2.nodeValue());
							
						}
						
						plugin->loadElementProperties(element,&pluginProperties);
						break;	
					}
                }
			}

			n = n.nextSibling();
		}
	}
}
QVector<ProgrammingInterface> AVRStudioXMLParser::GetInterfaces(QDomNode node)
{
    QVector<ProgrammingInterface> interfaces(0);

    while(!node.isNull())
    {
        QDomNamedNodeMap attributes = node.attributes();
        ProgrammingInterface interface;

        for(int i = 0; i < attributes.size(); i++)
        {
            QDomNode attribute = attributes.item(i);
            if(interface.GetMappingMap()[attribute.nodeName()])
                *interface.GetMappingMap()[attribute.nodeName()] = attribute.nodeValue();
        }

        interfaces.append(interface);
        node = node.nextSibling();
    }

    return interfaces;
}
Example #15
0
void Project::processNodeAttributes(const QDomElement &nodeElement)
{
    // process attributes
    QDomNamedNodeMap namedNodeMap = nodeElement.attributes();

    for (int i = 0; i < namedNodeMap.size(); ++i) {
        QDomNode domNode = namedNodeMap.item(i);

        if (domNode.nodeType() == QDomNode::AttributeNode) {
            QDomAttr domElement = domNode.toAttr();

            if (domElement.name() == QLatin1String("DefaultTargets"))
                m_defaultTargets = domElement.value().split(QLatin1Char(';'));
            else if (domElement.name() == QLatin1String("InitialTargets"))
                m_initialTargets = domElement.value().split(QLatin1Char(';'));
            else if (domElement.name() == QLatin1String("ToolsVersion"))
                m_toolsVersion = domElement.value();
            else if (domElement.name() == QLatin1String("xmlns"))
                m_xmlns = domElement.value();
        }
    }
}
QVector<Bit> AVRStudioXMLParser::GetBits(QDomNode node)
{
    QVector<Bit> bits(0);

    while(!node.isNull())
    {
        QDomNamedNodeMap attributes = node.attributes();
        Bit bit;

        for(int i = 0; i < attributes.size(); i++)
        {
            QDomNode attribute = attributes.item(i);
            if(bit.GetMappingMap()[attribute.nodeName()])
                *bit.GetMappingMap()[attribute.nodeName()] = attribute.nodeValue();
        }

        bit.SetValues(GetValues(node.childNodes()));
        bits.append(bit);

        node = node.nextSibling();
    }

    return bits;
}
Example #17
0
void Item::processAttributes(const QDomElement &nodeElement)
{
    // process attributes
    QDomNamedNodeMap namedNodeMap = nodeElement.attributes();

    for (int i = 0; i < namedNodeMap.size(); ++i) {
        QDomNode domNode = namedNodeMap.item(i);

        if (domNode.nodeType() == QDomNode::AttributeNode) {
            QDomAttr domElement = domNode.toAttr();

            if (domElement.name() == QLatin1String("Condition"))
                m_condition = domElement.value();
            else if (domElement.name() == QLatin1String("Include"))
                m_include = domElement.value();
            else if (domElement.name() == QLatin1String("Exclude"))
                m_exclude = domElement.value();
            else if (domElement.name() == QLatin1String("Remove"))
                m_remove = domElement.value();
        }
    }

    m_name = nodeElement.nodeName();
}
Example #18
0
static QDomElement oldStyleNS(const QDomElement &e)
{
	// find closest parent with a namespace
	QDomNode par = e.parentNode();
	while(!par.isNull() && par.namespaceURI().isNull())
		par = par.parentNode();
	bool noShowNS = false;
	if(!par.isNull() && par.namespaceURI() == e.namespaceURI())
		noShowNS = true;

	QDomElement i;
	uint x;
	//if(noShowNS)
		i = e.ownerDocument().createElement(e.tagName());
	//else
	//	i = e.ownerDocument().createElementNS(e.namespaceURI(), e.tagName());

	// copy attributes
	QDomNamedNodeMap al = e.attributes();
	for(x = 0; x < al.count(); ++x)
		i.setAttributeNode(al.item(x).cloneNode().toAttr());

	if(!noShowNS)
		i.setAttribute("xmlns", e.namespaceURI());

	// copy children
	QDomNodeList nl = e.childNodes();
	for(x = 0; x < nl.count(); ++x) {
		QDomNode n = nl.item(x);
		if(n.isElement())
			i.appendChild(oldStyleNS(n.toElement()));
		else
			i.appendChild(n.cloneNode());
	}
	return i;
}
QByteArray CatDomElement( const QDomElement e )
{
    if (e.isNull()) {
        return QByteArray();
    }
    QDomDocument doc;
    QDomElement Pbb = doc.createElement(e.tagName());
    QDomNamedNodeMap alist = e.attributes();
    for (int i=0; i<alist.count(); i++) {
        QDomNode nod = alist.item(i);
        Pbb.setAttribute(nod.nodeName().toLower(),nod.nodeValue());
    }
    doc.appendChild(Pbb);

    QDomNode child = e.firstChild();
    while ( !child.isNull() ) {
        if ( child.isElement() ) {
            Pbb.appendChild(doc.importNode(child,true).toElement());
        }
        child = child.nextSibling();
    }

    return doc.toByteArray(1);
}
Example #20
0
void DocumentReader::_readElement(QDomElement element, Node* node)
{
    for (int i = 0; i < element.childNodes().count(); i++)
    {
        // The QDomDocument class creates a node named "#text" which contains
        // the node value (content).
        if (element.childNodes().at(i).nodeName().toLower() == "#text")
            node->setContent(element.childNodes().at(i).nodeValue());
        else
        {
            Node* new_node = new Node(node,
                                      element.childNodes().at(i).nodeName().toLower(),
                                      node->getLayer() + 1);
            node->addChild(new_node);
            QDomNamedNodeMap attributes = element.childNodes().at(i).attributes();
            DocumentReaderData documentreference = _translationMapper->getDocumentReference();
            if (element.childNodes().at(i).nodeName().toLower() == documentreference.getTagName())
            {
                if (Settings::DEBUG)
                {
                    std::cerr << tr("#\tReadElement - '").toStdString()
                            << documentreference.getTagName().toStdString()
                            << tr("': \n#\t\tindexFileInfo.absPath: ").toStdString()
                            << _indexFileInfo.absolutePath().toStdString()
                            << std::endl << tr("#\t\thref: ").toStdString()
                            << new_node->getAttributes()["href"].toStdString() << std::endl;
                }
                QString urlattribute = documentreference.getUrlContainingAttributeName();
                new_node->addAttribute(urlattribute, attributes.namedItem(urlattribute).nodeValue());
                // compose absolute file path
                QFileInfo myfileinfo;
                if (QFileInfo(_indexFileInfo.absolutePath() + new_node->getAttributes()["href"]).exists())
                    // unix
                    myfileinfo = QFileInfo(_indexFileInfo.absolutePath()
                                           + new_node->getAttributes()["href"]);
                else
                    // windows
                    myfileinfo = QFileInfo(_indexFileInfo.absolutePath()
                                           + QDir::separator() + new_node->getAttributes()["href"]);
                if (_includeSubDocuments)
                    _documentStack.push(new DocumentData(myfileinfo, new_node, _fileType));
                if(Settings::DEBUG)
                {
                    std::cerr << tr("# CDocumentReader::readElement()").toStdString()
                           << std::endl << tr("#\tat \"if (element.childNodes()").toStdString()
                           << tr(".at(i).nodeName().toLower() == \"a\")\" returned true").toStdString()
                           << std::endl << tr("#\tfound subdocument href=").toStdString()
                           << new_node->getAttributes()["href"].toStdString() << std::endl;
                }
            }
            else
            {
                QDomNode attribute;
                for (int i = 0; i < attributes.count(); i++)
                {
                    attribute = attributes.item(i);
                    new_node->addAttribute(attribute.nodeName(), attribute.nodeValue());
                }
            }
            QDomElement new_element = element.childNodes().at(i).toElement();
            _readElement(new_element, new_node);
        }
    }
};
Example #21
0
bool KXMLGUIClient::mergeXML( QDomElement &base, const QDomElement &additive, KActionCollection *actionCollection )
{
  static const QString &tagAction = KGlobal::staticQString( "Action" );
  static const QString &tagMerge = KGlobal::staticQString( "Merge" );
  static const QString &tagSeparator = KGlobal::staticQString( "Separator" );
  static const QString &attrName = KGlobal::staticQString( "name" );
  static const QString &attrAppend = KGlobal::staticQString( "append" );
  static const QString &attrWeakSeparator = KGlobal::staticQString( "weakSeparator" );
  static const QString &tagMergeLocal = KGlobal::staticQString( "MergeLocal" );
  static const QString &tagText = KGlobal::staticQString( "text" );
  static const QString &attrAlreadyVisited = KGlobal::staticQString( "alreadyVisited" );
  static const QString &attrNoMerge = KGlobal::staticQString( "noMerge" );
  static const QString &attrOne = KGlobal::staticQString( "1" );

  // there is a possibility that we don't want to merge in the
  // additive.. rather, we might want to *replace* the base with the
  // additive.  this can be for any container.. either at a file wide
  // level or a simple container level.  we look for the 'noMerge'
  // tag, in any event and just replace the old with the new
  if ( additive.attribute(attrNoMerge) == attrOne ) // ### use toInt() instead? (Simon)
  {
    base.parentNode().replaceChild(additive, base);
    return true;
  }

  QString tag;

  // iterate over all elements in the container (of the global DOM tree)
  QDomNode n = base.firstChild();
  while ( !n.isNull() )
  {
    QDomElement e = n.toElement();
    n = n.nextSibling(); // Advance now so that we can safely delete e
    if (e.isNull())
       continue;

    tag = e.tagName();

    // if there's an action tag in the global tree and the action is
    // not implemented, then we remove the element
    if ( tag == tagAction )
    {
      QCString name =  e.attribute( attrName ).utf8(); // WABA
      if ( !actionCollection->action( name ) ||
           (kapp && !kapp->authorizeKAction(name)))
      {
        // remove this child as we aren't using it
        base.removeChild( e );
        continue;
      }
    }

    // if there's a separator defined in the global tree, then add an
    // attribute, specifying that this is a "weak" separator
    else if ( tag == tagSeparator )
    {
      e.setAttribute( attrWeakSeparator, (uint)1 );

      // okay, hack time. if the last item was a weak separator OR
      // this is the first item in a container, then we nuke the
      // current one
      QDomElement prev = e.previousSibling().toElement();
      if ( prev.isNull() ||
	 ( prev.tagName() == tagSeparator && !prev.attribute( attrWeakSeparator ).isNull() ) ||
	 ( prev.tagName() == tagText ) )
      {
        // the previous element was a weak separator or didn't exist
        base.removeChild( e );
        continue;
      }
    }

    // the MergeLocal tag lets us specify where non-standard elements
    // of the local tree shall be merged in.  After inserting the
    // elements we delete this element
    else if ( tag == tagMergeLocal )
    {
      QDomNode it = additive.firstChild();
      while ( !it.isNull() )
      {
        QDomElement newChild = it.toElement();
        it = it.nextSibling();
        if (newChild.isNull() )
          continue;

        if ( newChild.tagName() == tagText )
          continue;

        if ( newChild.attribute( attrAlreadyVisited ) == attrOne )
          continue;

        QString itAppend( newChild.attribute( attrAppend ) );
        QString elemName( e.attribute( attrName ) );

        if ( ( itAppend.isNull() && elemName.isEmpty() ) ||
             ( itAppend == elemName ) )
        {
          // first, see if this new element matches a standard one in
          // the global file.  if it does, then we skip it as it will
          // be merged in, later
          QDomElement matchingElement = findMatchingElement( newChild, base );
          if ( matchingElement.isNull() || newChild.tagName() == tagSeparator )
            base.insertBefore( newChild, e );
        }
      }

      base.removeChild( e );
      continue;
    }

    // in this last case we check for a separator tag and, if not, we
    // can be sure that its a container --> proceed with child nodes
    // recursively and delete the just proceeded container item in
    // case its empty (if the recursive call returns true)
    else if ( tag != tagMerge )
    {
      // handle the text tag
      if ( tag == tagText )
        continue;

      QDomElement matchingElement = findMatchingElement( e, additive );

      if ( !matchingElement.isNull() )
      {
        matchingElement.setAttribute( attrAlreadyVisited, (uint)1 );

        if ( mergeXML( e, matchingElement, actionCollection ) )
        {
          base.removeChild( e );
          continue;
        }

        // Merge attributes
        const QDomNamedNodeMap attribs = matchingElement.attributes();
        const uint attribcount = attribs.count();

        for(uint i = 0; i < attribcount; ++i)
        {
          const QDomNode node = attribs.item(i);
          e.setAttribute(node.nodeName(), node.nodeValue());
        }

        continue;
      }
      else
      {
        // this is an important case here! We reach this point if the
        // "local" tree does not contain a container definition for
        // this container. However we have to call mergeXML recursively
        // and make it check if there are actions implemented for this
        // container. *If* none, then we can remove this container now
        if ( mergeXML( e, QDomElement(), actionCollection ) )
          base.removeChild( e );
        continue;
      }
    }
  }

  //here we append all child elements which were not inserted
  //previously via the LocalMerge tag
  n = additive.firstChild();
  while ( !n.isNull() )
  {
    QDomElement e = n.toElement();
    n = n.nextSibling(); // Advance now so that we can safely delete e
    if (e.isNull())
       continue;

    QDomElement matchingElement = findMatchingElement( e, base );

    if ( matchingElement.isNull() )
    {
      base.appendChild( e );
    }
  }

  // do one quick check to make sure that the last element was not
  // a weak separator
  QDomElement last = base.lastChild().toElement();
  if ( (last.tagName() == tagSeparator) && (!last.attribute( attrWeakSeparator ).isNull()) )
  {
    base.removeChild( last );
  }

  // now we check if we are empty (in which case we return "true", to
  // indicate the caller that it can delete "us" (the base element
  // argument of "this" call)
  bool deleteMe = true;

  n = base.firstChild();
  while ( !n.isNull() )
  {
    QDomElement e = n.toElement();
    n = n.nextSibling(); // Advance now so that we can safely delete e
    if (e.isNull())
       continue;

    tag = e.tagName();

    if ( tag == tagAction )
    {
      // if base contains an implemented action, then we must not get
      // deleted (note that the actionCollection contains both,
      // "global" and "local" actions
      if ( actionCollection->action( e.attribute( attrName ).utf8() ) )
      {
        deleteMe = false;
        break;
      }
    }
    else if ( tag == tagSeparator )
    {
      // if we have a separator which has *not* the weak attribute
      // set, then it must be owned by the "local" tree in which case
      // we must not get deleted either
      QString weakAttr = e.attribute( attrWeakSeparator );
      if ( weakAttr.isEmpty() || weakAttr.toInt() != 1 )
      {
        deleteMe = false;
        break;
      }
    }

    // in case of a merge tag we have unlimited lives, too ;-)
    else if ( tag == tagMerge )
    {
//      deleteMe = false;
//      break;
        continue;
    }

    // a text tag is NOT enough to spare this container
    else if ( tag == tagText )
    {
      continue;
    }

    // what's left are non-empty containers! *don't* delete us in this
    // case (at this position we can be *sure* that the container is
    // *not* empty, as the recursive call for it was in the first loop
    // which deleted the element in case the call returned "true"
    else
    {
      deleteMe = false;
      break;
    }
  }

  return deleteMe;
}
Example #22
0
void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillParam, QColor& defaultFill, bool& hasOutlineParam, QColor& defaultOutline,
                                      bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
{
  if ( elem.isNull() )
  {
    return;
  }

  //we already have all the information, no need to go deeper
  if ( hasFillParam && hasOutlineParam && hasOutlineWidthParam )
  {
    return;
  }

  //check this elements attribute
  QDomNamedNodeMap attributes = elem.attributes();
  int nAttributes = attributes.count();

  QStringList valueSplit;
  for ( int i = 0; i < nAttributes; ++i )
  {
    QDomAttr attribute = attributes.item( i ).toAttr();
    if ( attribute.name().compare( "style", Qt::CaseInsensitive ) == 0 )
    {
      //entries separated by ';'
      QStringList entryList = attribute.value().split( ';' );
      QStringList::const_iterator entryIt = entryList.constBegin();
      for ( ; entryIt != entryList.constEnd(); ++entryIt )
      {
        QStringList keyValueSplit = entryIt->split( ':' );
        if ( keyValueSplit.size() < 2 )
        {
          continue;
        }
        QString key = keyValueSplit.at( 0 );
        QString value = keyValueSplit.at( 1 );
        valueSplit = value.split( " " );
        if ( !hasFillParam && value.startsWith( "param(fill)" ) )
        {
          hasFillParam = true;
          if ( valueSplit.size() > 1 )
          {
            defaultFill = QColor( valueSplit.at( 1 ) );
          }
        }
        else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) )
        {
          hasOutlineParam = true;
          if ( valueSplit.size() > 1 )
          {
            defaultOutline = QColor( valueSplit.at( 1 ) );
          }
        }
        else if ( !hasOutlineWidthParam && value.startsWith( "param(outline-width)" ) )
        {
          hasOutlineWidthParam = true;
          if ( valueSplit.size() > 1 )
          {
            defaultOutlineWidth = valueSplit.at( 1 ).toDouble();
          }
        }
      }
    }
    else
    {
      QString value = attribute.value();
      valueSplit = value.split( " " );
      if ( !hasFillParam && value.startsWith( "param(fill)" ) )
      {
        hasFillParam = true;
        if ( valueSplit.size() > 1 )
        {
          defaultFill = QColor( valueSplit.at( 1 ) );
        }
      }
      else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) )
      {
        hasOutlineParam = true;
        if ( valueSplit.size() > 1 )
        {
          defaultOutline = QColor( valueSplit.at( 1 ) );
        }
      }
      else if ( !hasOutlineWidthParam && value.startsWith( "param(outline-width)" ) )
      {
        hasOutlineWidthParam = true;
        if ( valueSplit.size() > 1 )
        {
          defaultOutlineWidth = valueSplit.at( 1 ).toDouble();
        }
      }
    }
  }

  //pass it further to child items
  QDomNodeList childList = elem.childNodes();
  int nChildren = childList.count();
  for ( int i = 0; i < nChildren; ++i )
  {
    QDomElement childElem = childList.at( i ).toElement();
    containsElemParams( childElem, hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
  }
}
Example #23
0
void QgsSvgCache::replaceElemParams( QDomElement& elem, const QColor& fill, const QColor& outline, double outlineWidth )
{
  if ( elem.isNull() )
  {
    return;
  }

  //go through attributes
  QDomNamedNodeMap attributes = elem.attributes();
  int nAttributes = attributes.count();
  for ( int i = 0; i < nAttributes; ++i )
  {
    QDomAttr attribute = attributes.item( i ).toAttr();
    //e.g. style="fill:param(fill);param(stroke)"
    if ( attribute.name().compare( "style", Qt::CaseInsensitive ) == 0 )
    {
      //entries separated by ';'
      QString newAttributeString;

      QStringList entryList = attribute.value().split( ';' );
      QStringList::const_iterator entryIt = entryList.constBegin();
      for ( ; entryIt != entryList.constEnd(); ++entryIt )
      {
        QStringList keyValueSplit = entryIt->split( ':' );
        if ( keyValueSplit.size() < 2 )
        {
          continue;
        }
        QString key = keyValueSplit.at( 0 );
        QString value = keyValueSplit.at( 1 );
        if ( value.startsWith( "param(fill" ) )
        {
          value = fill.name();
        }
        else if ( value.startsWith( "param(outline)" ) )
        {
          value = outline.name();
        }
        else if ( value.startsWith( "param(outline-width)" ) )
        {
          value = QString::number( outlineWidth );
        }

        if ( entryIt != entryList.constBegin() )
        {
          newAttributeString.append( ";" );
        }
        newAttributeString.append( key + ":" + value );
      }
      elem.setAttribute( attribute.name(), newAttributeString );
    }
    else
    {
      QString value = attribute.value();
      if ( value.startsWith( "param(fill)" ) )
      {
        elem.setAttribute( attribute.name(), fill.name() );
      }
      else if ( value.startsWith( "param(outline)" ) )
      {
        elem.setAttribute( attribute.name(), outline.name() );
      }
      else if ( value.startsWith( "param(outline-width)" ) )
      {
        elem.setAttribute( attribute.name(), QString::number( outlineWidth ) );
      }
    }
  }

  QDomNodeList childList = elem.childNodes();
  int nChildren = childList.count();
  for ( int i = 0; i < nChildren; ++i )
  {
    QDomElement childElem = childList.at( i ).toElement();
    replaceElemParams( childElem, fill, outline, outlineWidth );
  }
}
Example #24
0
/**** BEE ****/
FileList BEE::readSigset(const File &sigset, bool ignoreMetadata)
{
    FileList fileList;

#ifndef BR_EMBEDDED
    QDomDocument doc(sigset.fileName());
    QFile file(sigset.resolved());
    bool success;
    success = file.open(QIODevice::ReadOnly); if (!success) qFatal("Unable to open %s for reading.", qPrintable(sigset));
    success = doc.setContent(&file);

    file.close();

    if (!success) {
        qWarning("Unable to parse %s.", qPrintable(sigset));
        return fileList;
    }

    QDomElement docElem = doc.documentElement();
    if (docElem.nodeName() != "biometric-signature-set")
        return fileList;

    QDomNode subject = docElem.firstChild();
    while (!subject.isNull()) {
        // Looping through subjects
        QDomNode fileNode = subject.firstChild();
        QDomElement d = subject.toElement();
        QString name = d.attribute("name");
        while (!fileNode.isNull()) {
            // Looping through files
            File file("", name);

            QDomElement e = fileNode.toElement();
            QDomNamedNodeMap attributes = e.attributes();
            for (int i=0; i<attributes.length(); i++) {
                const QString key = attributes.item(i).nodeName();
                const QString value = attributes.item(i).nodeValue();
                if      (key == "file-name") file.name = value;
                else if (!ignoreMetadata)    file.set(key, value);
            }

            // add bounding boxes, if they exist (will be child elements of <presentation>)
            if (fileNode.hasChildNodes()) {
                QList<QRectF> rects;
                QDomNodeList bboxes = fileNode.childNodes();
                for (int i=0; i<bboxes.length(); i++) {
                    QDomElement bbox = bboxes.at(i).toElement();
                    qreal x = bbox.attribute("x").toDouble();
                    qreal y = bbox.attribute("y").toDouble();
                    qreal width = bbox.attribute("width").toDouble();
                    qreal height = bbox.attribute("height").toDouble();
                    rects += QRectF(x, y, width, height);
                }
                file.setRects(rects);
            }

            if (file.name.isEmpty()) qFatal("Missing file-name in %s.", qPrintable(sigset));
            fileList.append(file);

            fileNode = fileNode.nextSibling();
        }
        subject = subject.nextSibling();
    }
#else // BR_EMBEDDED
    (void) sigset;
    (void) ignoreMetadata;
#endif // BR_EMBEDDED

    return fileList;
}
Example #25
0
bool Parser::parseSchemaTag( ParserContext *context, const QDomElement &root )
{
  QName name = root.tagName();
  if ( name.localName() != QLatin1String("schema") )
    return false;

  NSManager *parentManager = context->namespaceManager();
  NSManager namespaceManager;

  // copy namespaces from wsdl
  if ( parentManager )
    namespaceManager = *parentManager;

  context->setNamespaceManager( &namespaceManager );

  QDomNamedNodeMap attributes = root.attributes();
  for ( int i = 0; i < attributes.count(); ++i ) {
    QDomAttr attribute = attributes.item( i ).toAttr();
    if ( attribute.name().startsWith( QLatin1String("xmlns:") ) ) {
      QString prefix = attribute.name().mid( 6 );
      context->namespaceManager()->setPrefix( prefix, attribute.value() );
    }
  }

  if ( root.hasAttribute( QLatin1String("targetNamespace") ) )
    d->mNameSpace = root.attribute( QLatin1String("targetNamespace") );

 // mTypesTable.setTargetNamespace( mNameSpace );

  QDomElement element = root.firstChildElement();
  while ( !element.isNull() ) {
    QName name = element.tagName();
    if ( name.localName() == QLatin1String("import") ) {
      parseImport( context, element );
    } else if ( name.localName() == QLatin1String("element") ) {
      addGlobalElement( parseElement( context, element, d->mNameSpace, element ) );
    } else if ( name.localName() == QLatin1String("complexType") ) {
      ComplexType ct = parseComplexType( context, element );
      d->mComplexTypes.append( ct );
    } else if ( name.localName() == QLatin1String("simpleType") ) {
      SimpleType st = parseSimpleType( context, element );
      d->mSimpleTypes.append( st );
    } else if ( name.localName() == QLatin1String("attribute") ) {
      addGlobalAttribute( parseAttribute( context, element ) );
    } else if ( name.localName() == QLatin1String("attributeGroup") ) {
      d->mAttributeGroups.append( parseAttributeGroup( context, element ) );
    } else if ( name.localName() == QLatin1String("annotation") ) {
      d->mAnnotations = parseAnnotation( context, element );
    } else if ( name.localName() == QLatin1String("include") ) {
      parseInclude( context, element );
    }

    element = element.nextSiblingElement();
  }

  context->setNamespaceManager( parentManager );
  d->mNamespaces = joinNamespaces( d->mNamespaces, namespaceManager.uris() );
  d->mNamespaces = joinNamespaces( d->mNamespaces, QStringList( d->mNameSpace ) );

  resolveForwardDeclarations();

  return true;
}
void FopLeader::read( const QDomElement e  , qreal pagewidth)  /* to be % width space */
{
    QDomNamedNodeMap attlist = e.attributes();
    qreal border = 0;
    QStringList WI_rec;
    QStringList HI_rec;
    WI_rec << "content-width" << "width" << "leader-length";
    HI_rec << "content-height" << "height" << "rule-thickness";
    
    for (int i=0; i<attlist.count(); i++)  {
             QDomNode nod = attlist.item(i);
             const QString valore = nod.nodeValue().toLower();
      
          if (nod.nodeName().toLower() == "background-color") {
               bg = ColorFromFoString(valore);
               format.setBackground(QBrush(bg));
          }
					
					if (nod.nodeName().toLower() == "color") {
               co = ColorFromFoString(valore);
               //////format.setBackground(QBrush(bg));
          }
					
					
          if (nod.nodeName().toLower().startsWith("border-") && nod.nodeName().toLower().endsWith("-width") ) {
                if (valore.endsWith("%")) {
                border = 0.5;
                } else {
                border = qMax(border,FopInt(valore));
                }
          }
          /* width */
          if (  WI_rec.contains( nod.nodeName().toLower() ) ) {
                 if (valore.endsWith("%")) {
									 int percentual = valore.left( valore.length() - 1 ).toInt();
									 area.setWidth(pagewidth / 100. * percentual);
									 format.setWidth ( area.width() );
								 } else {
                    if (FopInt(valore) > 0) {
                     area.setWidth(FopInt(valore));
										 format.setWidth ( area.width() );
                    }
                 }
          }
					
					 /* height */
          if (  HI_rec.contains( nod.nodeName().toLower() ) ) {
                 if (valore.endsWith("%")) {
									 int percentual = valore.left( valore.length() - 1 ).toInt();
									 area.setHeight(pagewidth / 100. * percentual);
									 format.setHeight ( area.height() );
								 } else {
                    if (FopInt(valore) > 0) {
                     area.setHeight (FopInt(valore));
										 format.setHeight ( area.height() );
                    }
                 }
          }
					
					
					
					
          if ( nod.nodeName().toLower() == "space-before" || 
                      nod.nodeName().toLower() == "space-before.optimum" ||
                      nod.nodeName().toLower() == "margin-top"  ) {   /* top */
                     if (FopInt(nod.nodeValue()) > 0) {
                     format.setTopMargin(FopInt(nod.nodeValue()));
                     }
           }
           
          if ( nod.nodeName().toLower() == "space-after" || 
                      nod.nodeName().toLower() == "space-after.optimum" ||
                      nod.nodeName().toLower() == "margin-bottom"  ) {   /* top */
                     if (FopInt(nod.nodeValue()) > 0) {
                     format.setBottomMargin(FopInt(nod.nodeValue()));
                     }
           }
           
             
           
          if ( nod.nodeName().toLower() == "space-start" || 
               nod.nodeName().toLower() == "end-indent" ||
               nod.nodeName().toLower() == "margin-right" ) {  /* right */
                    format.setRightMargin(FopInt(nod.nodeValue()));
          }     
          if ( nod.nodeName().toLower() == "space-end" || 
              nod.nodeName().toLower() == "start-indent" || 
              nod.nodeName().toLower() == "margin-left" ) {   /* left */
              format.setLeftMargin(FopInt(nod.nodeValue()));
          }
          if (display.contains(nod.nodeValue())) {
            visibility = display.indexOf(nod.nodeValue());
          }
          
          if (pattern.contains(nod.nodeValue())) {
            leaderpattern = pattern.indexOf(nod.nodeValue());
          }
    }  /* loop attributes */
		
		if ( leaderpattern == 3 ) {
			area = QRectF(0,0,1,1);
		}
		
		///////////qDebug() << "### leaderpattern -------  " << leaderpattern;
		
		
		ELoriginal = SaveElement(e);
		///////format.setProperty(LeaderNummer,this);
}
bool DrugDrugInteraction::updateDomElement(QDomElement *element, QDomDocument *doc) const
{
    if (element->tagName()!="DDI")
        return false;
    element->setAttribute("i1", m_Data.value(FirstInteractorName).toString());
    element->setAttribute("i2", m_Data.value(SecondInteractorName).toString());
    element->setAttribute("i1ra", m_Data.value(FirstInteractorRouteOfAdministrationIds).toStringList().join(";"));
    element->setAttribute("i2ra", m_Data.value(SecondInteractorRouteOfAdministrationIds).toStringList().join(";"));
    element->setAttribute("l", m_Data.value(LevelCode).toString());
    element->setAttribute("a", m_Data.value(DateCreation).toString());
    element->setAttribute("lu", m_Data.value(DateLastUpdate).toString());
    element->setAttribute("v", m_Data.value(IsValid).toInt());
    element->setAttribute("rv", m_Data.value(IsReviewed).toInt());
    element->setAttribute("p", m_Data.value(PMIDsStringList).toStringList().join(";"));

    // Update risk
    QDomElement riskNode = element->firstChildElement("R");
    if (riskNode.isNull()) {
        // create risk
        QDomElement rFr = doc->createElement("R");
        rFr.setAttribute("l", "fr");
        rFr.setAttribute("t", risk("fr"));
        element->appendChild(rFr);
        QDomElement rEn = doc->createElement("R");
        rEn.setAttribute("l", "en");
        rEn.setAttribute("t", risk("en"));
        element->appendChild(rEn);
    } else {
        if (riskNode.attribute("l").compare("fr",Qt::CaseInsensitive)==0) {
            riskNode.setAttribute("t", risk("fr"));
            QDomElement rEn = riskNode.nextSiblingElement("R");
            if (rEn.isNull()) {
                rEn = doc->createElement("R");
                rEn.setAttribute("l", "en");
                element->appendChild(rEn);
            }
            rEn.setAttribute("t", risk("en"));
        } else if (riskNode.attribute("l").compare("en",Qt::CaseInsensitive)==0) {
            riskNode.setAttribute("t", risk("en"));
            QDomElement rFr = riskNode.nextSiblingElement("R");
            if (rFr.isNull()) {
                rFr = doc->createElement("R");
                rFr.setAttribute("l", "fr");
                element->appendChild(rFr);
            }
            rFr.setAttribute("t", risk("fr"));
        }
    }

    // Update management
    QDomElement manNode = element->firstChildElement("M");
    if (manNode.isNull()) {
        // create management
        QDomElement rFr = doc->createElement("M");
        rFr.setAttribute("l", "fr");
        rFr.setAttribute("t", management("fr"));
        element->appendChild(rFr);
        QDomElement rEn = doc->createElement("M");
        rEn.setAttribute("l", "en");
        rEn.setAttribute("t", management("en"));
        element->appendChild(rEn);
    } else {
        if (manNode.attribute("l").compare("fr",Qt::CaseInsensitive)==0) {
            manNode.setAttribute("t", management("fr"));
            QDomElement rEn = manNode.nextSiblingElement("M");
            if (rEn.isNull()) {
                rEn = doc->createElement("R");
                rEn.setAttribute("l", "en");
                element->appendChild(rEn);
            }
            rEn.setAttribute("t", management("en"));
        } else if (manNode.attribute("l").compare("en",Qt::CaseInsensitive)==0) {
            manNode.setAttribute("t", risk("en"));
            QDomElement rFr = manNode.nextSiblingElement("M");
            if (rFr.isNull()) {
                rFr = doc->createElement("R");
                rFr.setAttribute("l", "fr");
                element->appendChild(rFr);
            }
            rFr.setAttribute("t", management("fr"));
        }
    }

    // Update doses
//    QDomElement dose = element.firstChildElement("D");
//    while (!dose.isNull()) {
//        DrugDrugInteractionDose *ddidose = 0;
//        if (dose.attribute("i") == "1") {
//            ddidose = &m_FirstDose;
//        } else {
//            ddidose = &m_SecondDose;
//        }
//        if (dose.attribute("uf").toInt()==1) {
//            ddidose->setData(DrugDrugInteractionDose::UsesFrom, true);
//            ddidose->setData(DrugDrugInteractionDose::FromValue , dose.attribute("fv"));
//            ddidose->setData(DrugDrugInteractionDose::FromUnits, dose.attribute("fu"));
//            ddidose->setData(DrugDrugInteractionDose::FromRepartition , dose.attribute("fr"));
//        } else if (dose.attribute("ut").toInt()==1) {
//            ddidose->setData(DrugDrugInteractionDose::UsesTo, true);
//            ddidose->setData(DrugDrugInteractionDose::ToValue , dose.attribute("tv"));
//            ddidose->setData(DrugDrugInteractionDose::ToUnits, dose.attribute("tu"));
//            ddidose->setData(DrugDrugInteractionDose::ToRepartition , dose.attribute("tr"));
//        }
//        dose = dose.nextSiblingElement("D");
//    }

    // Update formalized risk
    QDomElement formNode = element->firstChildElement("F");
    if (!formNode.isNull()) {
        QDomNamedNodeMap attributeMap = formNode.attributes();
        for(int i=0; i < attributeMap.size(); ++i) {
            formNode.removeAttribute(attributeMap.item(i).nodeName());
        }
    }
    if (m_Formalized.count() > 0) {
        QHashIterator<QString,QString> i(m_Formalized);
        while (i.hasNext()) {
            i.next();
            formNode.setAttribute(i.key(), i.value());
        }
    }
    return true;
}
Example #28
0
/**
  * Parser method for the layout module configurations.
  * Modules are used to define event handling between objects.
  * A module can consist of several seqeuences.
  * In order to ensure that behavior module attributes has to
  * be append to an existing module with the same adr information.
  * If there is no module existing with the current adr a new one will
  * be created and append to the module list.
  *
  */
bool ConfigParser::buildModuleConfig(const QString mod_cfgv)
	{
    this->module_list_ref->clear();
	this->getNodeList(mod_cfgv,MODULE_CFG_TAG);
	if(!this->temp_node_list->count() > 0)
		{
        this->core->configLogError(QString(MISSING_OBJ_TAG));
		return false;
		}

	/*each module*/
	for(int i = 0;i <this->temp_node_list->count();i++)
		{
		Module *temp_module;
		QDomNode node = this->temp_node_list->item(i);
		QDomNamedNodeMap map = node.attributes();
		int index = 0;
		bool new_mod = false;
		/*get the adr of the module*/
		int adr = this->getModAdrFromTag(map);
		/*search for a module with this adr in the module reference list*/
		index = this->getModIndexByAdr(adr, this->module_list_ref);
		/*if no module was found*/
		if( index < 0 )
			{
			new_mod = true;
			temp_module = new Module();
			}
		/*iterate through the attributes*/
		for(uint j = 1; j <= map.length();j++)
			{
			if(map.item(j-1).isAttr())
				{
				QDomAttr attr = map.item(j-1).toAttr();
				if(attr.name() == MODULE_ATTR_MOD_ADR)
					{
					if(new_mod)
						temp_module->setModAdr(attr.value().toInt());
					}
				else if(attr.name() == MODULE_ATTR_SEQ)
					{
					if(new_mod)
						temp_module->addModSeq(attr.value().toInt());
					else
						this->module_list_ref->at(index)->addModSeq(attr.value().toInt());
					}
				else if(attr.name() == MODULE_ATTR_SOURCE)
					{
					if(new_mod)
						temp_module->addModSource(attr.value().toInt());
					else
						this->module_list_ref->at(index)->addModSource(attr.value().toInt());
					}
				else if(attr.name() == MODULE_ATTR_EVENT_IN)
					{
					if(new_mod)
						temp_module->addModEventIn(attr.value());
					else
						this->module_list_ref->at(index)->addModEventIn(attr.value());
					}
				else if(attr.name() == MODULE_ATTR_EVENT_OUT)
					{
					if(new_mod)
						temp_module->addModEventOut(attr.value());
					else
						this->module_list_ref->at(index)->addModEventOut(attr.value());
					}
				else if(attr.name() == MODULE_ATTR_TARGET)
					{
					if(new_mod)
						temp_module->addModTarget(attr.value().toInt());
					else
						this->module_list_ref->at(index)->addModTarget(attr.value().toInt());
					}
				else
					this->core->configLogWarning(QString(UNHA_ATT_MSG).replace("#_1",attr.name()).replace("#_2",MODULE_CFG_TAG));
				}
			}
		if(new_mod)
			this->module_list_ref->append(temp_module);
		}
	for(int i = 0; i < this->module_list_ref->count(); i++)
		{
		this->core->configLogInfo(this->module_list_ref->at(i)->getModLogEntry());
		}
    return true;
	}
Example #29
0
void UPnpDeviceDesc::_InternalLoad( QDomNode oNode, UPnpDevice *pCurDevice )
{
    QString pin = GetMythDB()->GetSetting( "SecurityPin", "");
    pCurDevice->m_securityPin = !(pin.isEmpty() || pin == "0000");

    for ( oNode = oNode.firstChild();
          !oNode.isNull();
          oNode = oNode.nextSibling() )
    {
        QDomElement e = oNode.toElement();

        if (e.isNull())
            continue;

        // TODO: make this table driven (using offset within structure)
        if ( e.tagName() == "deviceType" )
            SetStrValue( e, pCurDevice->m_sDeviceType);
        else if ( e.tagName() == "friendlyName" )
            SetStrValue( e, pCurDevice->m_sFriendlyName );
        else if ( e.tagName() == "manufacturer" )
            SetStrValue( e, pCurDevice->m_sManufacturer );
        else if ( e.tagName() == "manufacturerURL" )
            SetStrValue( e, pCurDevice->m_sManufacturerURL );
        else if ( e.tagName() == "modelDescription" )
            SetStrValue( e, pCurDevice->m_sModelDescription);
        else if ( e.tagName() == "modelName" )
            SetStrValue( e, pCurDevice->m_sModelName );
        else if ( e.tagName() == "modelNumber" )
            SetStrValue( e, pCurDevice->m_sModelNumber );
        else if ( e.tagName() == "modelURL" )
            SetStrValue( e, pCurDevice->m_sModelURL );
        else if ( e.tagName() == "serialNumber" )
            SetStrValue( e, pCurDevice->m_sSerialNumber );
        else if ( e.tagName() == "UPC" )
            SetStrValue( e, pCurDevice->m_sUPC );
        else if ( e.tagName() == "presentationURL" )
            SetStrValue( e, pCurDevice->m_sPresentationURL );
        else if ( e.tagName() == "UDN" )
            SetStrValue( e, pCurDevice->m_sUDN );
        else if ( e.tagName() == "iconList" )
            ProcessIconList( oNode, pCurDevice );
        else if ( e.tagName() == "serviceList" )
            ProcessServiceList( oNode, pCurDevice );
        else if ( e.tagName() == "deviceList" )
            ProcessDeviceList ( oNode, pCurDevice );
        else if ( e.tagName() == "mythtv:X_secure" )
            SetBoolValue( e, pCurDevice->m_securityPin );
        else if ( e.tagName() == "mythtv:X_protocol" )
            SetStrValue( e, pCurDevice->m_protocolVersion );
        else
        {
            // Not one of the expected element names... add to extra list.
            QString sValue = "";
            SetStrValue( e, sValue );
            NameValue node = NameValue(e.tagName(), sValue);
            QDomNamedNodeMap attributes =  e.attributes();
            for (int i = 0; i < attributes.size(); i++)
            {
                node.AddAttribute(attributes.item(i).nodeName(),
                                  attributes.item(i).nodeValue(),
                                  true); // TODO Check whether all attributes are in fact requires for the device xml
            }
            pCurDevice->m_lstExtra.push_back(node);
        }
    }
}
Example #30
0
void QgsProjectFileTransform::transform2990()
{
  QDomNodeList mapLayers = mDom.elementsByTagName( QStringLiteral( "maplayer" ) );

  for ( int mapLayerIndex = 0; mapLayerIndex < mapLayers.count(); ++mapLayerIndex )
  {
    QDomElement layerElem = mapLayers.at( mapLayerIndex ).toElement();

    // The newly added fieldConfiguration element
    QDomElement fieldConfigurationElement = mDom.createElement( QStringLiteral( "fieldConfiguration" ) );
    layerElem.appendChild( fieldConfigurationElement );

    QDomNodeList editTypeNodes = layerElem.namedItem( QStringLiteral( "edittypes" ) ).childNodes();
    QDomElement constraintExpressionsElem = mDom.createElement( QStringLiteral( "constraintExpressions" ) );
    layerElem.appendChild( constraintExpressionsElem );

    for ( int i = 0; i < editTypeNodes.size(); ++i )
    {
      QDomNode editTypeNode = editTypeNodes.at( i );
      QDomElement editTypeElement = editTypeNode.toElement();

      QDomElement fieldElement = mDom.createElement( QStringLiteral( "field" ) );
      fieldConfigurationElement.appendChild( fieldElement );

      QString name = editTypeElement.attribute( QStringLiteral( "name" ) );
      fieldElement.setAttribute( QStringLiteral( "name" ), name );
      QDomElement constraintExpressionElem = mDom.createElement( QStringLiteral( "constraint" ) );
      constraintExpressionElem.setAttribute( "field", name );
      constraintExpressionsElem.appendChild( constraintExpressionElem );

      QDomElement editWidgetElement = mDom.createElement( QStringLiteral( "editWidget" ) );
      fieldElement.appendChild( editWidgetElement );

      QString ewv2Type = editTypeElement.attribute( QStringLiteral( "widgetv2type" ) );
      editWidgetElement.setAttribute( "type", ewv2Type );

      QDomElement ewv2CfgElem = editTypeElement.namedItem( QStringLiteral( "widgetv2config" ) ).toElement();

      if ( !ewv2CfgElem.isNull() )
      {
        QDomElement editWidgetConfigElement = mDom.createElement( QStringLiteral( "config" ) );
        editWidgetElement.appendChild( editWidgetConfigElement );

        QVariantMap editWidgetConfiguration;

        QDomNamedNodeMap configAttrs = ewv2CfgElem.attributes();
        for ( int configIndex = 0; configIndex < configAttrs.count(); ++configIndex )
        {
          QDomAttr configAttr = configAttrs.item( configIndex ).toAttr();
          if ( configAttr.name() == QStringLiteral( "fieldEditable" ) )
          {
            editWidgetConfigElement.setAttribute( QStringLiteral( "fieldEditable" ), configAttr.value() );
          }
          else if ( configAttr.name() == QStringLiteral( "labelOnTop" ) )
          {
            editWidgetConfigElement.setAttribute( QStringLiteral( "labelOnTop" ), configAttr.value() );
          }
          else if ( configAttr.name() == QStringLiteral( "notNull" ) )
          {
            editWidgetConfigElement.setAttribute( QStringLiteral( "notNull" ), configAttr.value() );
          }
          else if ( configAttr.name() == QStringLiteral( "constraint" ) )
          {
            constraintExpressionElem.setAttribute( "exp", configAttr.value() );
          }
          else if ( configAttr.name() == QStringLiteral( "constraintDescription" ) )
          {
            constraintExpressionElem.setAttribute( "desc", configAttr.value() );
          }
          else
          {
            editWidgetConfiguration.insert( configAttr.name(), configAttr.value() );
          }
        }

        if ( ewv2Type == QStringLiteral( "ValueMap" ) )
        {
          QDomNodeList configElements = ewv2CfgElem.childNodes();
          QVariantMap map;
          for ( int configIndex = 0; configIndex < configElements.count(); ++configIndex )
          {
            QDomElement configElem = configElements.at( configIndex ).toElement();
            map.insert( configElem.attribute( QStringLiteral( "key" ) ), configElem.attribute( QStringLiteral( "value" ) ) );
          }
          editWidgetConfiguration.insert( QStringLiteral( "map" ), map );
        }

        editWidgetConfigElement.appendChild( QgsXmlUtils::writeVariant( editWidgetConfiguration, mDom ) );
      }
    }
  }
}