本文整理汇总了C++中QDomNamedNodeMap::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNamedNodeMap::count方法的具体用法?C++ QDomNamedNodeMap::count怎么用?C++ QDomNamedNodeMap::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNamedNodeMap
的用法示例。
在下文中一共展示了QDomNamedNodeMap::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
}
示例2: count
int QDomNamedNodeMapProto:: count() const
{
QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject());
if (item)
return item->count();
return 0;
}
示例3: XMLToVariables
void XML::XMLToVariables(MOVector<Variable> & variables,QDomElement &element)
{
variables.clear();
QDomElement e;
QDomNode n = element.firstChild();
QString fieldName;
int iField;
while( !n.isNull() )
{
e = n.toElement();
if( !e.isNull() && (e.tagName()=="Variable"))
{
Variable* newVar = new Variable();
QDomNamedNodeMap attributes = e.attributes();
for(int i=0;i<attributes.count();i++)
{
iField = newVar->getFieldIndex(attributes.item(i).toAttr().name());
if(iField>-1)
newVar->setFieldValue(iField,QVariant(attributes.item(i).toAttr().value()));
}
variables.addItem(newVar);
}
n = n.nextSibling();
}
}
示例4: cleanMathml
void cleanMathml(QDomElement pElement)
{
// Clean up the current element
// Note: the idea is to remove all the attributes that are not in the
// MathML namespace. Indeed, if we were to leave them in then the XSL
// transformation would either do nothing or, worst, crash OpenCOR...
static const QString MathmlNamespace = "http://www.w3.org/1998/Math/MathML";
QDomNamedNodeMap attributes = pElement.attributes();
QList<QDomNode> nonMathmlAttributes = QList<QDomNode>();
for (int i = 0, iMax = attributes.count(); i < iMax; ++i) {
QDomNode attribute = attributes.item(i);
if (attribute.namespaceURI().compare(MathmlNamespace))
nonMathmlAttributes << attribute;
}
foreach (QDomNode nonMathmlAttribute, nonMathmlAttributes)
pElement.removeAttributeNode(nonMathmlAttribute.toAttr());
// Go through the element's child elements, if any, and clean them up
for (QDomElement childElement = pElement.firstChildElement();
!childElement.isNull(); childElement = childElement.nextSiblingElement()) {
cleanMathml(childElement);
}
}
示例5: 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();
}
}
示例6: getDrawerByName
BorderDrawerInterface * BorderDrawersLoader::getDrawerFromSvg(QDomElement & drawerElement)
{
QMap<QString,QString> properties;
QDomNamedNodeMap attributes = drawerElement.attributes();
for (int j = attributes.count()-1; j >= 0; --j)
{
QDomAttr attr = attributes.item(j).toAttr();
if (attr.isNull())
continue;
properties.insert(attr.name(), attr.value());
}
QString drawerName = properties.take("name");
if (!instance()->registeredDrawers().contains(drawerName))
return 0;
BorderDrawerInterface * drawer = getDrawerByName(drawerName);
const QMetaObject * meta = drawer->metaObject();
int count = meta->propertyCount();
for (int i = 0; i < count; ++i)
{
QMetaProperty p = meta->property(i);
QString value = properties.take(p.name());
if (value.isEmpty())
continue;
p.write(drawer, QVariant(QByteArray::fromBase64(value.toAscii())));
}
return drawer;
}
示例7: elementToString
QString XmlProtocol::elementToString(const QDomElement &e, bool clip)
{
if(elem.isNull())
elem = elemDoc.importNode(docElement(), true).toElement();
// Determine the appropriate 'fakeNS' to use
QString ns;
// first, check root namespace
QString pre = e.prefix();
if(pre.isNull())
pre = "";
if(pre == elem.prefix()) {
ns = elem.namespaceURI();
}
else {
// scan the root attributes for 'xmlns' (oh joyous hacks)
QDomNamedNodeMap al = elem.attributes();
int n;
for(n = 0; n < al.count(); ++n) {
QDomAttr a = al.item(n).toAttr();
QString s = a.name();
int x = s.indexOf(':');
if(x != -1)
s = s.mid(x+1);
else
s = "";
if(pre == s) {
ns = a.value();
break;
}
}
if(n >= al.count()) {
// if we get here, then no appropriate ns was found. use root then..
ns = elem.namespaceURI();
}
}
// build qName
QString qn;
if(!elem.prefix().isEmpty())
qn = elem.prefix() + ':';
qn += elem.localName();
// make the string
return sanitizeForStream(xmlToString(e, ns, qn, clip));
}
示例8: data
QVariant XUPProjectModel::data( const QModelIndex& index, int role ) const
{
if ( !index.isValid() ) {
return QVariant();
}
XUPItem* item = static_cast<XUPItem*>( index.internalPointer() );
switch ( role ) {
case Qt::DecorationRole:
return item->displayIcon();
case Qt::DisplayRole:
return item->displayText();
case XUPProjectModel::TypeRole:
return item->type();
case Qt::ToolTipRole:
{
const QDomNode node = item->node();
const QDomNamedNodeMap attributeMap = node.attributes();
QStringList attributes;
if ( item->type() == XUPItem::Project ) {
attributes << QString( "Project: %1" ).arg( item->project()->fileName() );
}
for ( int i = 0; i < attributeMap.count(); i++ ) {
const QDomNode attribute = attributeMap.item( i );
const QString name = attribute.nodeName();
const QString value = attribute.nodeValue();
attributes << QString( "%1=\"%2\"" ).arg( name ).arg( value );
}
switch ( item->type() ) {
case XUPItem::Value:
attributes << QString( "Value=\"%1\"" ).arg( item->content() );
break;
case XUPItem::File:
attributes << QString( "File=\"%1\"" ).arg( item->content() );
break;
case XUPItem::Path:
attributes << QString( "Path=\"%1\"" ).arg( item->content() );
break;
default:
break;
}
return attributes.join( "\n" );
}
case Qt::SizeHintRole:
return QSize( -1, 18 );
default:
break;
}
return QVariant();
}
示例9: QString
QDebug operator<<(QDebug dbg, const QDomElement &el)
{
QDomNamedNodeMap map = el.attributes();
QString args;
for (int i=0; i<map.count(); ++i)
args += " " + map.item(i).nodeName() + "='" + map.item(i).nodeValue() + "'";
dbg.nospace() << QString("<%1%2>%3</%1>").arg(el.tagName()).arg(args).arg(el.text());
return dbg.space();
}
示例10: readXmlAttributesByTagName
MStriantMap MusicAbstractXml::readXmlAttributesByTagName(const QString &tagName) const
{
QDomNodeList nodelist = m_ddom->elementsByTagName(tagName);
QDomNamedNodeMap nodes = nodelist.at(0).toElement().attributes();
MStriantMap maps;
for(int i=0; i<nodes.count(); ++i)
{
QDomAttr attr = nodes.item(i).toAttr();
maps[attr.name()] = attr.value();
}
return maps;
}
示例11: 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();
}
示例12: elementString
QString ConfiguratorHelper::elementString(QDomElement &el) {
QString str;
str += "<"%el.tagName()%" ";
QDomNamedNodeMap attrs = el.attributes();
int count = attrs.count();
for (int i = 0; i < count; ++i) {
str += attrs.item(i).toAttr().name()%"=\""%attrs.item(i).toAttr().value()%"\" ";
}
str += "/>";
return str;
}
示例13:
/*!
Set of search parameters.
*/
QHash<QString,QString> TasTargetObject::searchParameters() const
{
QHash<QString,QString> params;
QDomNamedNodeMap attributes = mElement.attributes();
for(int i = 0 ; i < attributes.count(); i++){
QDomNode node = attributes.item(i);
//strip special attrs
if(node.nodeName() != "objectName" && node.nodeName() != "className" && node.nodeName() != "tasId"){
params.insert(node.nodeName(), node.nodeValue());
}
}
return params;
}
示例14: cssGroup
/* debug all item incomming in tree 2 level */
QString cssGroup( const QDomElement e )
{
QStringList cssitem;
QDomNamedNodeMap alist = e.attributes();
for (int i=0; i<alist.count(); i++) {
QDomNode nod = alist.item(i);
cssitem.append(QString("%1:%2").arg(nod.nodeName().toLower()).arg(nod.nodeValue()));
}
QDomNode child = e.firstChild();
while ( !child.isNull() ) {
if ( child.isElement() ) {
QDomNamedNodeMap list = child.attributes();
for (int x=0; x<list.count(); x++) {
QDomNode nod = list.item(x);
cssitem.append(QString("%1:%2").arg(nod.nodeName().toLower()).arg(nod.nodeValue()));
}
}
child = child.nextSibling();
}
return cssitem.join(";");
}
示例15: FilterAttribute
/* loop to find attribute name xx */
QString UnionXml::FilterAttribute(QDomElement element, QString attribute) {
QString base = "-1";
QDomNamedNodeMap attlist = element.attributes();
int bigint = attlist.count();
if (bigint > 0) {
for (int i = 0; i < bigint; i++) {
QDomNode nod = attlist.item(i);
if (nod.nodeName() == attribute) {
base = QString(nod.nodeValue());
return base;
}
}
}
return base;
}