本文整理汇总了C++中QDomNode::nodeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::nodeValue方法的具体用法?C++ QDomNode::nodeValue怎么用?C++ QDomNode::nodeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::nodeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setDetMiscAttributes
/** Sets the layout attributes for the detail headers and footers */
void MReportEngine::setDetMiscAttributes( MReportSection * section, QDomNode * report ) {
// Get the attributes for the section
QDomNamedNodeMap attributes = report->attributes();
// Get the section attributes
section->setDrawIf( attributes.namedItem( "DrawIf" ).nodeValue() );
QDomNode levelNode = attributes.namedItem( "Level" );
if ( !levelNode.isNull() )
section->setLevel( attributes.namedItem( "Level" ).nodeValue().toInt() );
else
section->setLevel( -1 );
QDomNode n = attributes.namedItem( "NewPage" );
if ( !n.isNull() )
section->setNewPage( n.nodeValue().upper() == "TRUE" );
else
section->setNewPage( false );
n = attributes.namedItem( "PlaceAtBottom" );
if ( !n.isNull() )
section->setPlaceAtBottom( n.nodeValue().upper() == "TRUE" );
else
section->setPlaceAtBottom( false );
n = attributes.namedItem( "DrawAllPages" );
if ( !n.isNull() )
section->setDrawAllPages( n.nodeValue().upper() == "TRUE" );
else
section->setDrawAllPages( false );
}
示例2: fillStrings
void WAccount::fillStrings(QString &text, QString &html, const QDomElement &element, const QString &prefix)
{
QString key = prefix + QLatin1Char('%');
if (key != QLatin1String("%%")) {
text.replace(key, element.text());
html.replace(key, element.text().toHtmlEscaped());
qDebug() << key;
}
key.chop(1);
QDomNamedNodeMap attributes = element.attributes();
for (int i = 0; i < attributes.count(); ++i) {
QDomNode attribute = attributes.item(i);
QString attributeKey = key
% QLatin1Char('/')
% attribute.nodeName()
% QLatin1Char('%');
qDebug() << attributeKey;
text.replace(attributeKey, attribute.nodeValue());
html.replace(attributeKey, attribute.nodeValue().toHtmlEscaped());
}
if (!key.endsWith(QLatin1Char('%')))
key += QLatin1Char('/');
QDomNodeList elementChildren = element.childNodes();
for (int i = 0; i < elementChildren.count(); ++i) {
QDomNode node = elementChildren.at(i);
if (node.isElement())
fillStrings(text, html, node.toElement(), key + node.nodeName());
}
}
示例3: applyString
QString Reference::applyString( const QDomElement &context ) const
{
if( isEmpty() )
return QString();
Reference::Segment s = lastSegment();
QString txt;
if ( s.isAttribute() ) {
QDomElement targetElement = applyAttributeContext( context );
txt = targetElement.attribute( s.name() );
} else {
QDomElement e = applyElement( context );
if( e.isText() )
txt = e.text();
else {
QDomNode child = e.firstChild();
if( !child.nodeValue().isEmpty() )
txt = child.nodeValue();
else
txt = child.nodeName();
}
}
return txt;
}
示例4: data
//! [3]
QVariant DomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
DomItem *item = static_cast<DomItem*>(index.internalPointer());
QDomNode node = item->node();
//! [3] //! [4]
QStringList attributes;
QDomNamedNodeMap attributeMap = node.attributes();
switch (index.column()) {
case 0:
return node.nodeName();
case 1:
for (int i = 0; i < attributeMap.count(); ++i) {
QDomNode attribute = attributeMap.item(i);
attributes << attribute.nodeName() + "=\""
+attribute.nodeValue() + "\"";
}
return attributes.join(" ");
case 2:
return node.nodeValue().split("\n").join(" ");
default:
return QVariant();
}
}
示例5: setAsXMLNode
bool ReturnInstruction::setAsXMLNode(QDomNode& node)
{
if (node.hasChildNodes()) {
QDomNodeList nodeList = node.childNodes();
for (unsigned i = 0; i < nodeList.length(); i++) {
QDomElement e = nodeList.item(i).toElement();
if (!e.isNull()) {
if (e.tagName() == "text") {
QDomNode t = e.firstChild();
setContents(t.nodeValue());
} else if (e.tagName() == "comment") {
QDomNode t = e.firstChild();
setComment(t.nodeValue());
}
}
}
} else {
// tekst, komentarz i pixmapa puste
}
validateContents();
return true;
}
示例6: setArgs
void GTest_RunCMDLine::setArgs(const QDomElement & el) {
QString commandLine;
QDomNamedNodeMap map = el.attributes();
int mapSz = map.length();
for( int i = 0; i < mapSz; ++i ) {
QDomNode node = map.item(i);
if(node.nodeName() == "message"){
expectedMessage = node.nodeValue();
continue;
}
if(node.nodeName() == "nomessage"){
unexpectedMessage = node.nodeValue();
continue;
}
if(node.nodeName() == WORKINK_DIR_ATTR){
continue;
}
QString argument = "--" + node.nodeName() + "=" + getVal(node.nodeValue());
if( argument.startsWith("--task") ) {
args.prepend(argument);
commandLine.prepend(argument + " ");
} else {
args.append(argument);
commandLine.append(argument + " ");
}
}
args.append("--log-level-details");
args.append("--lang=en");
args.append("--log-no-task-progress");
commandLine.append(QString(" --log-level-details --lang=en --log-no-task-progress"));
cmdLog.info(commandLine);
}
示例7: isDeepEqual
bool TestBaseLine::isDeepEqual(const QDomNode &n1, const QDomNode &n2)
{
if(n1.nodeType() != n2.nodeType())
return false;
switch(n1.nodeType())
{
case QDomNode::CommentNode:
/* Fallthrough. */
case QDomNode::TextNode:
{
return static_cast<const QDomCharacterData &>(n1).data() ==
static_cast<const QDomCharacterData &>(n2).data();
}
case QDomNode::ProcessingInstructionNode:
{
return n1.nodeName() == n2.nodeName() &&
n1.nodeValue() == n2.nodeValue();
}
case QDomNode::DocumentNode:
return isChildrenDeepEqual(n1.childNodes(), n2.childNodes());
case QDomNode::ElementNode:
{
return n1.localName() == n2.localName() &&
n1.namespaceURI() == n2.namespaceURI() &&
n1.nodeName() == n2.nodeName() && /* Yes, this one is needed in addition to localName(). */
isAttributesEqual(n1.attributes(), n2.attributes()) &&
isChildrenDeepEqual(n1.childNodes(), n2.childNodes());
}
/* Fallthrough all these. */
case QDomNode::EntityReferenceNode:
case QDomNode::CDATASectionNode:
case QDomNode::EntityNode:
case QDomNode::DocumentTypeNode:
case QDomNode::DocumentFragmentNode:
case QDomNode::NotationNode:
case QDomNode::BaseNode:
case QDomNode::CharacterDataNode:
{
Q_ASSERT_X(false, Q_FUNC_INFO,
"An unsupported node type was encountered.");
return false;
}
case QDomNode::AttributeNode:
{
Q_ASSERT_X(false, Q_FUNC_INFO,
"This should never happen. QDom doesn't allow us to compare DOM attributes "
"properly.");
return false;
}
default:
{
Q_ASSERT_X(false, Q_FUNC_INFO, "Unhandled QDom::NodeType value.");
return false;
}
}
}
示例8: deserialize
void TrackerSettingsWidget::deserialize(const QDomNode *node)
{
mProjectList->clear();
QDomNode itemNode = node->namedItem("login");
if (!itemNode.isNull())
{
QDomNode attr = itemNode.attributes().namedItem("value");
if (!attr.isNull())
{
mLoginEdit->setText(attr.nodeValue());
}
}
itemNode = node->namedItem("password");
if (!itemNode.isNull())
{
QDomNode attr = itemNode.attributes().namedItem("value");
if (!attr.isNull())
{
mPasswordEdit->setText(attr.nodeValue());
}
}
itemNode = node->namedItem("endpoint");
if (!itemNode.isNull())
{
QDomNode attr = itemNode.attributes().namedItem("value");
if (!attr.isNull())
{
mUrlEdit->setText(attr.nodeValue());
}
}
QDomNode projectsRootNode = node->namedItem("projects");
if (!projectsRootNode.isNull())
{
QDomNodeList projects = projectsRootNode.childNodes();
for (int i = 0; i < projects.size(); ++i)
{
QDomNode proj = projects.item(i);
QDomNode nameAttr = proj.attributes().namedItem("name");
QString name, shortName;
if (!nameAttr.isNull())
{
name = nameAttr.nodeValue();
}
nameAttr = proj.attributes().namedItem("shortName");
if (!nameAttr.isNull())
shortName = nameAttr.nodeValue();
if (!name.isEmpty() && !shortName.isEmpty())
mProjectList->addItem(name, shortName);
}
}
testConnection();
}
示例9: data
QVariant DomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
//role to get full xml path of index
if(role == XPathRole)
{
QString wholeXmlPath;
DomItem *item = static_cast<DomItem*>(index.internalPointer());
if (item==NULL)
qFatal("can't convert domitem from datamodel");
for(;item->parent()!=NULL;item=item->parent())
{
wholeXmlPath=item->node().nodeName()+"/"+wholeXmlPath;
}
wholeXmlPath="/"+wholeXmlPath;
return wholeXmlPath;
}
else if (role == Qt::DisplayRole)
{
DomItem *item = static_cast<DomItem*>(index.internalPointer());
QDomNode node = item->node();
QStringList attributes;
QDomNamedNodeMap attributeMap = node.attributes();
switch (index.column())
{
//name
case 0:
return node.nodeName();
//attributes
case 1:
for (int i = 0; i < attributeMap.count(); ++i)
{
QDomNode attribute = attributeMap.item(i);
attributes << attribute.nodeName() + "=\"" +attribute.nodeValue() + "\"";
}
return attributes.join(" ");
//value
case 2:
return node.nodeValue().split("\n").join(" ");
default:
return QVariant();
}
}
else
return QVariant();
}
示例10: fromDom
void ViElement::fromDom(QDomNode &dom)
{
setName(dom.toElement().tagName());
QDomNamedNodeMap attributes = dom.attributes();
for(int i = 0; i < attributes.size(); ++i)
{
addAttribute(ViAttribute(attributes.item(i).nodeName(), attributes.item(i).nodeValue()));
}
QDomNodeList children = dom.childNodes();
if(children.size() > 0)
{
for(int i = 0; i < children.size(); ++i)
{
if(children.item(i).isText())
{
setValue(children.item(i).nodeValue());
}
else
{
ViElement child;
QDomNode node = children.item(i);
child.fromDom(node);
addChild(child);
}
}
}
else
{
setValue(dom.nodeValue());
}
}
示例11: writeElementChilds
void FileWriter::writeElementChilds(const QDomElement &AParent)
{
QDomNode node = AParent.firstChild();
while (!node.isNull())
{
if (node.isElement())
{
QDomElement elem = node.toElement();
if (elem.tagName() != "thread")
{
FXmlWriter->writeStartElement(elem.tagName());
QString elemNs = elem.namespaceURI();
if (!elemNs.isEmpty() && elem.parentNode().namespaceURI()!=elemNs)
FXmlWriter->writeAttribute("xmlns",elem.namespaceURI());
QDomNamedNodeMap attrMap = elem.attributes();
for (uint i=0; i<attrMap.length(); i++)
{
QDomNode attrNode = attrMap.item(i);
FXmlWriter->writeAttribute(attrNode.nodeName(), attrNode.nodeValue());
}
writeElementChilds(elem);
FXmlWriter->writeEndElement();
}
}
else if (node.isCharacterData())
{
FXmlWriter->writeCharacters(node.toCharacterData().data());
}
node = node.nextSibling();
}
}
示例12: QString
QString QDomNodeProto:: nodeValue() const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->nodeValue();
return QString();
}
示例13: extractTextFromParagraph
QString ExampleContent::extractTextFromParagraph(const QDomNode &parentNode)
{
QString description;
QDomNode node = parentNode.firstChild();
while (!node.isNull()) {
QString beginTag;
QString endTag;
if (node.isText())
description += Colors::contentColor + node.nodeValue();
else if (node.hasChildNodes()) {
if (node.nodeName() == "b") {
beginTag = "<b>";
endTag = "</b>";
} else if (node.nodeName() == "a") {
beginTag = Colors::contentColor;
endTag = "</font>";
} else if (node.nodeName() == "i") {
beginTag = "<i>";
endTag = "</i>";
} else if (node.nodeName() == "tt") {
beginTag = "<tt>";
endTag = "</tt>";
}
description += beginTag + this->extractTextFromParagraph(node) + endTag;
}
node = node.nextSibling();
}
return description;
}
示例14: goc_addXMLObject
// Add an object to this space from a dom element
void GOCXMLSpace::goc_addXMLObject(QDomElement xmlObjectElem){
//Create an XMLObject from the dom element - in this XMLSpace
GOCXMLObject *xmlObj = new GOCXMLObject(xmlObjectElem,this);
QDomNode nObjNode = xmlObjectElem.firstChild();
if(!nObjNode.isNull() && !nObjNode.isText()){//TODO: manage the text case and comments
//Create a sub space of the object - if it has child(ren)
xmlObj->goc_setXMLObjectSubbed(true);
}
GOCXMLSpace *xmlObjSubSpace = xmlObj->goc_getXMLObjectSpace();
while(!nObjNode.isNull()) {
QDomElement e = nObjNode.toElement(); // try to convert the node to an element.
if(!nObjNode.isText()){
//Add a new object
xmlObjSubSpace->goc_addXMLObject(e);
}else{
//Update the node value
QString sNodeValue = nObjNode.nodeValue();
QVariant vNodeValue = QVariant(sNodeValue);
GOCAttribute *gocAtt = new GOCAttribute(xmlObj);
QSharedPointer<GOCAttribute> spAtt(gocAtt);
spAtt->attName = GOCOBJECT_OBJECTNODEVALUE;
spAtt->attValue = vNodeValue;
spAtt->attVisible = true;
spAtt->attRemovable = false;
xmlObj->goc_setObjectNodeValue(sNodeValue);
spAtt->attNameModifiable = false;
}
nObjNode = nObjNode.nextSibling();
}
}
示例15:
/**
* \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();
}
}