コード例 #1
0
ファイル: amsotemplate.cpp プロジェクト: app/ananas-labs
/** 
 * \en
 * insert new row in table and replace tag to value
 * \_en
 * \ru
 * Вставляет новую строку в таблицу, заменяет теги на значения, удаляет тег секции из строки таблицы.
 * Выполняет рекурсивный поиск узла, содержащего строку таблицы. У этого узла есть
 * специальное имя(w:r), которое распознается функцией. После того, как узел найден, строка строка дублируется, 
 * а из текущей строки удаляются все теги секции, чтобы избежать мнократного размножения строк таблицы.
 * \_ru
 * \param node - \en context for inserting \_en \ru узел, в который происходит вставка \_ru 
 * \see searchTags()
 */
void 
aMSOTemplate::insertRowValues(QDomNode node)
{
	QDomNode n = node;
	while(!n.parentNode().isNull())
	{
		n = n.parentNode();
		QDomElement e = n.toElement();
		if( n.nodeName()=="Row" ) 
		{	
			QDomAttr a = n.toElement().attributeNode( "ss:Index" );
			n.parentNode().insertAfter(n.cloneNode(true),n);
			clearTags(n,true);
			
			QMap<QString,QString>::Iterator it;
			for ( it = values.begin(); it != values.end(); ++it )
			{
				searchTags(n,it.key());
			}
			int rowIndex = a.value().toInt();
			if (rowIndex == 0) 
			{
				rowIndex = getRowIndex(n);
				n.toElement().setAttribute("ss:Index",rowIndex);	
			}
			n.nextSibling().toElement().setAttribute("ss:Index",rowIndex+1);	
		}
	}
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: lomsansnom/IHM_OFELI
void MainWindow::heightXML(QDomNode doc, int *height)
{
    if(!doc.isNull())
    {
        int heightCurrentNode = 0;
        QDomNode docParent = doc;
        while(!docParent.parentNode().isNull())
        {
            docParent = docParent.parentNode();
            heightCurrentNode++;
        }
        if(heightCurrentNode > *height)
        {
            *height = heightCurrentNode;
        }
        if(!doc.childNodes().isEmpty() && (doc.firstChild().toElement().tagName() != "" || doc.firstChild().isComment()))
        {
            QDomNodeList nodeList = doc.childNodes();

            for(int i = 0; i < nodeList.length(); i++)
            {
                heightXML(nodeList.at(i), height);
            }
        }
    }
}
コード例 #3
0
ファイル: amsotemplate.cpp プロジェクト: app/ananas-labs
/**
 * \en
 * Deletes row, having section tag
 * \_en
 * \ru
 * Рекурсивная функция. Удаляет строки, содержащие тег секции
 * \_ru
* \param node - \en context \_en \ru узел из которого нужно удалить строки \_ru
 */
void
aMSOTemplate::clearRow(QDomNode node)
{
QDomNode n = node.lastChild();
	while( !n.isNull() )
	{	
		if(n.isText())
		{
			QString str = n.nodeValue();
			QRegExp re;
			re.setPattern(QString("%1.*%2").arg(open_token_section).arg(close_token_section));
			re.setMinimal(true);
			int pos = re.search(str,0);
			if(pos!=-1)
			{
				QDomNode tmp = n;
				while(!tmp.parentNode().isNull())
				{
					tmp = tmp.parentNode();
					if( tmp.nodeName()=="Row" ) 
					{
						tmp.parentNode().removeChild(tmp);
						break;
					}
				}
			}
		}
		else
		{
			clearRow(n);
		}
		n = n.previousSibling();
	}	
}
コード例 #4
0
ファイル: DefinitionParser.cpp プロジェクト: hkunz/createswf
bool DefinitionParser::createMultiFrameSprite (QDomNode& frame, const Content::Class clazz)
{
	QDomNode parent = frame.parentNode();
	QDomNamedNodeMap attributes = parent.attributes();
	const QString childName = clazz == Content::MOVIECLIP ? ::NODE_FRAME : ::NODE_OBJECT;
	const QString className = attributes.namedItem(ATTR_CLASS).nodeValue();
	const QString basePath = attributes.namedItem(ATTR_PATH).nodeValue();
	const QString absBasePath = _targetDir.absoluteFilePath(basePath);
	struct SpriteAsset* sprite = NULL;

	if (!QFile::exists(absBasePath)) {
		info("base path \'" + absBasePath + "\' does not exist");
		return false;
	}

	while (!frame.isNull()) {
		QDomElement e = frame.toElement();
		QDomNamedNodeMap attr = frame.attributes();
		checkAttributes(frame);
		frame = frame.nextSibling();

		if (e.isNull()) {
			continue;
		}

		const QString tn = e.tagName();
		if (tn != childName) {
			warnInvalidTag(tn, frame.parentNode().nodeName());
			continue;
		}

		const QString relpath = attr.namedItem(ATTR_PATH).nodeValue();
		if (attr.isEmpty() || relpath.isEmpty()) {
			warnMissingAttr(ATTR_PATH, tn);
			continue;
		}

		const QString path = _targetDir.absoluteFilePath(basePath + relpath);
		if (!checkPathExists(path)) {
			continue;
		}
		struct AssetBit asset;
		asset.name = attr.namedItem(ATTR_NAME).nodeValue();
		asset.path = _tempDir.relativeFilePath(path);
		copyAttributes(&asset, attr);
		if (!sprite) {
			sprite = new SpriteAsset();
		}
		sprite->assets.push_back(asset);
	}
	if (sprite) {
		sprite->clazz = clazz;
		sprite->name = className;
		copyAttributes(sprite, attributes);
		_assets[className] = sprite;
	}
	return true;
}
コード例 #5
0
ファイル: configuration.cpp プロジェクト: jhludwig/mythtv
void XmlConfiguration::ClearValue( const QString &sSetting )
{
    QDomNode node = FindNode(sSetting);
    if (!node.isNull())
    {
        QDomNode parent = node.parentNode();
        parent.removeChild(node);
        while (parent.childNodes().count() == 0)
        {
            QDomNode next_parent = parent.parentNode();
            next_parent.removeChild(parent);
            parent = next_parent;
        }
    }
}
コード例 #6
0
QDomNode QDomNodeProto:: parentNode() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->parentNode();
  return QDomNode();
}
コード例 #7
0
ファイル: XMLConfigLoader.cpp プロジェクト: nerd-toolkit/nerd
/**
 * Returns the path to the given XML Element in the document,
 * Example:
 *  <elem1>
 *    <elem2 />
 *  </elem1>
 *  
 *  Input: elem2
 *  Output: "elem1/elem2"
 * 
 * @return QString with the path to to the QDomElement.
 */
QString XMLConfigLoader::getFullPath(const QDomElement &element)
{
  QString path = element.tagName();
  
  QDomNode parent = element.parentNode();
  while(!parent.isNull())
  {
    if(parent.isElement() && !parent.parentNode().isDocument())
    {
      path = path.prepend(parent.toElement().tagName() + "/");
    }
    parent = parent.parentNode();
  }
  
  return path;
}
コード例 #8
0
bool hasParentNode(const QDomNode& n, const QString& name)
{
    QDomNode p = n.parentNode();
    if (p.isNull()) return false;
    if (p.nodeName() == name) return true;
    return hasParentNode(p, name);
}
コード例 #9
0
bool KFormula13ContentHandler::endElement(const QString&,
        const QString& localName,
        const QString&)
{
    if (localName == "CONTENT" || localName == "FORMULASETTINGS" ||
            localName == "FORMULA" || localName == "DENOMINATOR" ||
            localName == "NUMERATOR" || localName == "TEXT")
        return true;

    if (localName == "MATRIX")     // a matrix has been completely parsed
        m_matrixStack.pop();

    if (localName == "SEQUENCE" && m_currentElement.tagName() == "mtext" &&
            m_currentElement.parentNode().childNodes().count() == 1) {
        QDomNode parent = m_currentElement.parentNode();
        parent.parentNode().appendChild(m_currentElement);
        m_currentElement.parentNode().removeChild(parent);
    }

    m_currentElement = m_currentElement.parentNode().toElement();

    if (m_currentElement.tagName() == "mtd")  // move up to trigger mtr in parseMatrix()
        m_currentElement = m_currentElement.parentNode().toElement();

    return true;
}
コード例 #10
0
ファイル: databackend.cpp プロジェクト: purnimab/fizzix
void DataBackend::createConstant(QDomNode d_)
{
	if(d_.parentNode().nodeName()=="fizzix_object") return;
	QDomElement d=d_.toElement();
	QString name = d.attribute("name");
	constants->setElement(name, Parser::parseFizdatum(d.text(),((Type)(d.attribute("type").toInt()))));
}
コード例 #11
0
void projectviewer::setprojContent(QFile* input)
{
	QString err_msg; int err_line; int err_column;
	doc.clear();
	clear();
	bool set_cont = doc.setContent(input, &err_msg, &err_line, &err_column);
	if (!set_cont)
	{
		emit(errorOpeningFile(qPrintable(err_msg), err_line, err_column));
		return;
	}

	QStandardItem *parentItem = invisibleRootItem();
	addNode(&doc.firstChild().firstChild().firstChild(), parentItem);
	
// -------- add cwd entry if necessary
	char dummy[300];
	if (setXMLEntry(&doc, "workingDirectory", dummy))
	{
		QDomNode currentItem = doc.elementsByTagName("workingDirectory").item(0);
		QDomNode parrent = currentItem.parentNode();
		parrent.removeChild(currentItem);
	}
		QDomElement newelement = doc.createElement("workingDirectory");
		QDomText newnodetext = doc.createTextNode(QDir::current().absolutePath());
		newelement.appendChild(newnodetext);
		doc.firstChild().firstChild().appendChild(newelement);

// ----------

}
コード例 #12
0
ファイル: qxmlsettings.cpp プロジェクト: gbrault/firtool
//! function
static bool nodeToVariant(const QDomNode &aNode,QVariant &aValue) {
    bool vRetval = false;
    QString vType, vValue;

    aValue = QVariant();
    if(!vRetval && aNode.isCDATASection()) {
        vValue = aNode.toCDATASection().data();
        vRetval = true;
    }

    if(!vRetval && aNode.isText()) {
        vValue = aNode.toText().data();
        vRetval = true;
    }

    if(!vRetval) return vRetval;
    if(vValue.isEmpty()) return false; // ????

    const QDomNode vParent = aNode.parentNode();
    if(vParent.isElement()) {
        vType = vParent.toElement().attribute(QString::fromLatin1("type"));
    }

    if(vType == QString::fromLatin1("bytearray")) {
        aValue = QVariant(vValue.toLatin1());
    }
    else if(vType == QString::fromLatin1("variant")) {
        QByteArray vArray(vValue.toLatin1());
        QDataStream vStream(&vArray, QIODevice::ReadOnly);
        vStream >> aValue;
    }
コード例 #13
0
/*
    \internal
*/
void DomTool::fixAttribute(QDomNode &node, double version)
{
    QString tagName =  node.toElement().tagName();
    if (tagName == QLatin1String("widget")) {
        QString clss = node.toElement().attribute(QLatin1String("class"));
        for (int i = 0; i < widgs; ++i)
            if ((version < widgetTable[i].version)
                 && (clss == widgetTable[i].before)) {
                node.toElement().setAttribute(QLatin1String("class"), propertyTable[i].after);
                return;
            }
        return;
    }
    if (tagName == QLatin1String("property")) {
        QDomElement e = node.parentNode().toElement();
        QString clss = e.attribute(QLatin1String("class"));
        QString name = node.toElement().attribute(QLatin1String("name"), QLatin1String(""));
        for (int i = 0; i < props; ++i)
            if ((version < propertyTable[i].version)
                 && (clss == propertyTable[i].clss)
                 && (propertyTable[i].before.isNull()
                      || name == propertyTable[i].before)) {
                node.toElement().setAttribute(QLatin1String("name"), propertyTable[i].after);
                return;
            }
    }
}
コード例 #14
0
/**
\param operador
\return
**/
bool BcCuentasAnualesImprimirView::procesaOperador ( const QDomNode &operador )
{
    BL_FUNC_DEBUG
    QDomElement valor = operador.firstChildElement ( "VALORACT" );
    if ( !valor.isNull() )
        return true;
    /// Miramos la f&oacute;rmula.
    QDomElement lineaid = operador.firstChildElement ( "LINEAID" );

    if ( !lineaid.isNull() ) {
        QDomNodeList litems = m_doc.elementsByTagName ( "ID" );
        for ( int i = 0; i < litems.count(); i++ ) {
            QDomNode item = litems.item ( i );
            QDomElement e1 = item.toElement(); /// Try to convert the node to an element.
            if ( !e1.isNull() ) { /// The node was really an element.
                if ( e1.text() == lineaid.text() ) {
                    /// Este item es la f&oacute;rmula referenciada.
                    QDomNode formula = item.parentNode().firstChildElement ( "FORMULA" );
                    QString valoract, valorant;
                    if ( valorItem ( formula, valoract, valorant ) ) {
                        agregaValores ( operador, valoract, valorant );
                        return true;
                    } else {
                        return false;
                    } // end if
                } // end if
            } // end if
        } // end for
    } // end if

    
    return false;
}
コード例 #15
0
/**
\param formula
\param return
\return
**/
bool BcCuentasAnualesImprimirView::procesaFormula ( const QDomNode &formula )
{
    BL_FUNC_DEBUG
    QDomElement valor = formula.firstChildElement ( "VALORACT" );
    //
    QString valors = valor.toElement().text();
    QString codigo = formula.parentNode().firstChildElement ( "CONCEPTO" ).toElement().text();
    //
    if ( !valor.isNull() ) {
        return true;
    } // end if
    BlFixed tvaloract = BlFixed ( "0.0" );
    BlFixed tvalorant = BlFixed ( "0.0" );
    QDomElement formula3 = formula.toElement();
    QDomNodeList litems = formula3.elementsByTagName ( "OPERADOR" );
    for ( int i = 0; i < litems.count(); i++ ) {
        QDomNode item = litems.item ( i );
        QDomElement e1 = item.toElement(); /// Try to convert the node to an element.
        if ( !e1.isNull() ) { /// The node was really an element.
            if ( !procesaOperador ( item ) )
                return false;
            QString valoract, valorant;
            if ( valorItem ( item, valoract, valorant ) ) {
                tvaloract = tvaloract + BlFixed ( valoract );
                tvalorant = tvalorant + BlFixed ( valorant );
            } else
                return false;
        } // end if
    } // end for
    QString tvaloracts = tvaloract.toQString();
    QString tvalorants = tvalorant.toQString();
    agregaValores ( formula, tvaloracts, tvalorants );
    
    return true;
}
コード例 #16
0
ファイル: database.cpp プロジェクト: ixotum/ksilit_qt
QDomNode DataBase::getNextNode(QDomNode &currentNode, QDomNode &lastNode) {
  DBGS(PRINT_START("currentNode: 0x%08x, lastNode: 0x%08x", &currentNode, &lastNode));

  QDomNode nextNode;

  if (currentNode.hasChildNodes()) {
    nextNode = currentNode.firstChild();
  }
  else {
    QDomNode previousNode = currentNode;
    nextNode = currentNode.nextSibling();

    while (nextNode.isNull()) {
      QDomNode parentNode = previousNode.parentNode();

      if (parentNode == lastNode) {
        break;
      }
      else {
        previousNode = parentNode;
        nextNode = parentNode.nextSibling();
      }
    }
  }

  DBGR(PRINT_RETURN("nextNode: 0x%08x", &nextNode));
  return nextNode;
}
コード例 #17
0
ファイル: databackend.cpp プロジェクト: purnimab/fizzix
void DataBackend::createMacro(QDomNode d_)
{
	if(d_.parentNode().nodeName()=="fizzix_force") return;
	QDomElement d=d_.toElement();
	QString name = d.attribute("name");
	int i=0;
	macros->setElement(name, new FizFormula(Parser::parse(d.text(),i)));
}
コード例 #18
0
void QQMlDom::removeNodeById(QDomElement nDocument, QString element)
{
    QDomNodeList removeList = nDocument.elementsByTagName(element);
    QDomNode rUrl = removeList.at(0);
    QDomNode rrUrl = rUrl.parentNode();
    qDebug() << "is there a child node ?"  << rrUrl.hasChildNodes() <<"  " << rrUrl.childNodes().at(0).nodeName() ;
    rrUrl.removeChild(rrUrl.childNodes().at(0));
}
コード例 #19
0
ファイル: xmlflochatransfer.cpp プロジェクト: xjoof/flowchart
void XmlFloTransBase::removeNode(FlowchartsTemplate *flocha)
{
    auto it = flochaNodeHash.find(flocha);
    QDomNode node = it.value();
    node.parentNode().removeChild(node);

    flochaNodeHash.erase(it);
}
コード例 #20
0
ファイル: wbwidget.cpp プロジェクト: lyn1337/PsiStorm
void WbWidget::checkForViewBoxChange(const QDomNode &node) {
	if(node.isAttr() && node.nodeName().toLower() == "viewbox" && node.parentNode() == session_->document().documentElement()) {
		QRectF box = parseSvgViewBox(node.nodeValue());
		if(box.width() > 0 && box.height() > 0) {
			scene_->setSceneRect(box);
		}
	}
}
コード例 #21
0
ファイル: mainwindow.cpp プロジェクト: Ulle84/UllesSourceCode
void MainWindow::on_pushButtonDeleteEvaluationData_clicked()
{
  for (int i = 0; i < ui->listWidget->count(); i++)
  {
    QString fileName = ui->listWidget->item(i)->text();
    QFile* file = new QFile(fileName);

    if (!file->open(QIODevice::ReadOnly))
    {
      QMessageBox messageBox;
      messageBox.setText(tr("could not open file: %1 for reading").arg(fileName));
      messageBox.exec();
      continue;
    }

    ui->statusBar->showMessage(fileName);

    QString errorStr;
    int errorLine;
    int errorColumn;

    QDomDocument domDocument;

    if (!domDocument.setContent(file, true, &errorStr, &errorLine, &errorColumn))
    {
      QString errorString = tr("Parse error at line %1, column %2:\n%3").arg(errorLine).arg(errorColumn).arg(errorStr);
      QMessageBox::information(window(), tr("XML parse error"), errorString);
      return;
    }

    file->close();

    // remove EvalutationData
    QDomNodeList domNodeList = domDocument.elementsByTagName("EvaluationData");

    for (int j = 0; j < domNodeList.length(); j++)
    {
      QApplication::processEvents(); // keeping the GUI responsive
      QDomNode domNode = domNodeList.at(j);
      domNode.parentNode().removeChild(domNode);
    }

    if (!file->open(QIODevice::WriteOnly))
    {
      QMessageBox messageBox;
      messageBox.setText(tr("could not open file: %1 for writing").arg(fileName));
      messageBox.exec();
      continue;
    }

    QTextStream out(file);
    domDocument.save(out, 2);

    file->close();
  }

  ui->statusBar->showMessage(tr("ready"));
}
コード例 #22
0
ファイル: amsotemplate.cpp プロジェクト: app/ananas-labs
/**
 * \en
 * Deletes from node attribute
 * \_en
 * \ru
 * Рекурсивная функция. Удаляет из узла атрибут
 * \_ru
* \param node - \en context \_en \ru узел из которого нужно удалить атрибут \_ru
* \param nodename - \en node name \_en \ru имя узла \_ru
* \param attr - \en attribut name \_en \ru имя атрибута,который нужно удалить \_ru
 */
void
aMSOTemplate::clearAttributes(QDomNode node, const QString nodename, const QString attr)
{
	QDomNode n = node.lastChild();
	while( !n.isNull() )
	{
		if( n.parentNode().nodeName()==nodename ) 
		{	
			n.parentNode().toElement().removeAttribute(attr);		
			break;
		}	
		else
		{
			clearAttributes(n, nodename, attr);
		}
		n = n.previousSibling();
	}
}
コード例 #23
0
    bool operator()(QDomNode node) {
	QDomElement elem = node.toElement();
	if(elem.tagName() == "stop" &&
                (node.parentNode().nodeName() == "linearGradient" ||
                 node.parentNode().nodeName() == "radialGradient")) {
	    return true;
	}
	return false;
    }
コード例 #24
0
QString XmlRelationCheckerCoreImpl::CheckIsSubNodeFrom(const QDomNode& nodeToCheck, XmlRelation* xmlRelation) const
{
    //Precondition: the passed node is an element

    //For debug
    //const QString& nodeName = nodeToCheck.nodeName();

    //List of the key of the referenced value
    QString key = "";

    //If the relation is a SUB_TAG relation, otherwise is not supported and always return false
    if(xmlRelation->GetRelationType() == SUB_TAG)
    {
        //For debug
        //QString subTagName = xmlRelation->GetSubTagNameOfTagFrom();

        //Check the tag name corresponds with the subtag from name
        if(nodeToCheck.nodeName() == xmlRelation->GetSubTagNameOfTagFrom())
        {
            //Now it has to search all the child node with the given tag name with the right attribute

            //Obtain the parent node
            const QDomNode& parentNode = nodeToCheck.parentNode();

            //If the node is the correct child of the right node from
            if(parentNode.isElement() && parentNode.nodeName() == xmlRelation->GetTagFromName())
            {
                //Check the presence of the right attribute

                const QDomNamedNodeMap& attributeNodesList = nodeToCheck.attributes();

                //For exit when the fist match is found
                bool attributeFound = false;

                //Flow the list searching the
                for(int i=0; i<attributeNodesList.size() && !attributeFound; ++i)
                {
                    const QDomAttr& attritubeNode = attributeNodesList.item(i).toAttr();
                    const QString& attributeName = attritubeNode.name();

                    //If the attribute match set to display the value
                    if( attributeName == xmlRelation->GetAttributeNameofTagFrom() )
                    {
                        //Attribute found exit the cycle
                        attributeFound = true;

                        //Add the key in the list
                        key = attritubeNode.value();
                    }
                }
            }
        }
    }

    return key;
}
コード例 #25
0
ファイル: DefinitionParser.cpp プロジェクト: hkunz/createswf
void DefinitionParser::parseAssetNodes (QDomNode& node, const Content::Class clazz)
{
	bool sprite = false;
	QString nodeName;
	switch (clazz) {
	case Content::MOVIECLIP:
		nodeName = NODE_MOVIECLIP;
		sprite = true;
		break;
	case Content::SPRITE:
		sprite = true;
		nodeName = NODE_SPRITE;
		break;
	case Content::BITMAPDATA:
		nodeName = NODE_BITMAP;
		break;
	case Content::SOUND:
		nodeName = NODE_SOUND;
		break;
	case Content::BYTEARRAY:
		nodeName = NODE_BINARY;
		break;
	default:
		error("invalid class type " + QString::number(clazz));
		return;
	}
	while (!node.isNull()) {
		QDomElement elem = node.toElement();
		QDomNode parseNode = node;
		QDomNamedNodeMap attributes = node.attributes();
		QDomNode frame = node.firstChild();
		checkAttributes(node);
		node = node.nextSibling();

		if (elem.isNull()) {
			continue;
		}

		const QString tag = elem.tagName();
		if (nodeName != tag) {
			warnInvalidTag(tag, parseNode.parentNode().nodeName());
			continue;
		}

		if (attributes.isEmpty() || attributes.namedItem(ATTR_CLASS).nodeValue().isEmpty()) {
			warnMissingAttr(ATTR_CLASS, tag);
			continue;
		}

		if (frame.isNull() || !sprite) {
			createSingleFrameAsset(parseNode, clazz, nodeName);
		} else {
			createMultiFrameSprite(frame, clazz);
		}
	}
}
コード例 #26
0
ファイル: aimlparser.cpp プロジェクト: KDE/simon
QList<QDomNode> elementsByTagName(QDomNode *node, const QString& tagName)
{
  QList<QDomNode> list;
  QDomNodeList childNodes = node->toElement().elementsByTagName(tagName);
  for (int i = 0; i < childNodes.count(); i++) {
    QDomNode n = childNodes.item(i);
    if (n.parentNode() == *node)
      list.append(n);
  }
  return list;
}
コード例 #27
0
ファイル: DefinitionParser.cpp プロジェクト: hkunz/createswf
void DefinitionParser::parse ()
{
	info("parse definition.xml");
	init();

	_attributesMap[ATTR_CLASS] = 1;
	_attributesMap[ATTR_PATH] = 1;
	_attributesMap[ATTR_NAME] = 1;
	_attributesMap[ATTR_X] = 1;
	_attributesMap[ATTR_Y] = 1;
	_attributesMap[ATTR_ALPHA] = 1;
	_attributesMap[ATTR_VISIBLE] = 1;

	QDomElement doc = _definition.documentElement();
	QDomNode node = doc.firstChildElement(DefinitionNode::LIBRARY).firstChild();

	while (!node.isNull()) {
		QDomElement elem = node.toElement();
		node = node.nextSibling();

		if (elem.isNull()) {
			continue;
		}

		const QString text = elem.text();
		const QString tag = elem.tagName();

		QDomNode n(elem.firstChild());
		if (tag == ::NODE_SPRITES) {
			parseAssetNodes(n, Content::SPRITE);
		} else if (tag == ::NODE_MOVIECLIPS) {
			parseAssetNodes(n, Content::MOVIECLIP);
		} else if (tag == ::NODE_BITMAPS) {
			parseAssetNodes(n, Content::BITMAPDATA);
		} else if (tag == ::NODE_SOUNDS) {
			parseAssetNodes(n, Content::SOUND);
		} else if (tag == ::NODE_BINARIES) {
			parseAssetNodes(n, Content::BYTEARRAY);
		} else {
			warnInvalidTag(tag, node.parentNode().nodeName());
		}
	}

	for (std::map<QString, Asset*>::const_iterator i = _assets.begin(); i != _assets.end(); ++i) {
		const Asset* asset = i->second;
		if (asset->clazz == Content::MOVIECLIP || asset->clazz == Content::SPRITE) {
			AbstractAssetsParser::createFileSprite(static_cast<const SpriteAsset*>(asset));
		} else {
			AbstractAssetsParser::createFileCommon(asset->name, asset->path);
		}
		delete asset;
	}
	createMainClass();
}
コード例 #28
0
void AnnotationOutput::writeAnnotations(const QString &fileName, const QMap<uint, QPair<QString, QString> > &a_annotations)
{
  m_annotatedFileItems.clear();
  m_fileNames.clear();
  m_lines.clear();
  m_yourFileItems.clear();
  m_yourFileNames.clear();
  m_yourLines.clear();

  bool modified = false;
  QMap<uint, QPair<QString, QString> > annotations = a_annotations;
  QDomDocument *dom = Project::ref()->dom();
  QDomElement annotationElement = dom->firstChild().firstChild().namedItem("annotations").toElement();
  if (annotationElement.isNull())
  {
    annotationElement = dom->createElement("annotations");
    dom->firstChild().firstChild().appendChild(annotationElement);
  }
  QDomNode n = annotationElement.firstChild();
  while ( !n.isNull() ) 
  {
    QDomElement el = n.toElement();
    QString fName = el.attribute("url");
    QDomNode n2 = n.nextSibling();
    if (fileName == fName)    
    {
      QString text = el.attribute("text");
      bool ok;
      int line = el.attribute("line").toInt(&ok, 10);
      if (!annotations.contains(line) || (annotations[line].first != text))
      {
        n.parentNode().removeChild(n);
        modified = true;
      } else
        annotations.remove(line);
    }
    n = n2;
  }
  for (QMap<uint, QPair<QString, QString> >::ConstIterator it = annotations.constBegin(); it != annotations.constEnd(); ++it)
  {
    QDomElement el = dom->createElement("annotation");
    el.setAttribute("url", fileName);
    el.setAttribute("line", it.key());
    el.setAttribute("text", it.data().first);
    el.setAttribute("receiver", it.data().second.lower());
    annotationElement.appendChild(el);
    modified = true;
  }
  if (modified)
    Project::ref()->setModified(true);
  if (m_allAnnotations->isVisible() || m_yourAnnotations->isVisible())
    readAnnotations();
}
コード例 #29
0
QDomElement addCorrectNS(const QDomElement &e)
{
	int 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.toElement().namespaceURI() == "" )
		n = n.parentNode();
	QString ns;
	if(n.isNull() || !n.toElement().hasAttribute("xmlns")){
		if (n.toElement().namespaceURI () == ""){
			ns = "jabber:client";
		} else {
			ns = n.toElement().namespaceURI();
		}
	} 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;
}
コード例 #30
0
// stripExtraNS
//
// This function removes namespace information from various nodes for
// display purposes only (the element is pretty much useless for processing
// after this).  We do this because QXml is a bit overzealous about outputting
// redundant namespaces.
static QDomElement stripExtraNS(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;

	// build qName (prefix:localName)
	QString qName;
	if(!e.prefix().isEmpty())
		qName = e.prefix() + ':' + e.localName();
	else
		qName = e.tagName();

	QDomElement i;
	int x;
	if(noShowNS)
		i = e.ownerDocument().createElement(qName);
	else
		i = e.ownerDocument().createElementNS(e.namespaceURI(), qName);

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

		// don't show xml namespace
		if(a.namespaceURI() == NS_XML)
			i.setAttribute(QString("xml:") + a.name(), a.value());
		else
			i.setAttributeNodeNS(a);
	}

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