当前位置: 首页>>代码示例>>C++>>正文


C++ QDomAttr类代码示例

本文整理汇总了C++中QDomAttr的典型用法代码示例。如果您正苦于以下问题:C++ QDomAttr类的具体用法?C++ QDomAttr怎么用?C++ QDomAttr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QDomAttr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ProcessAttributes

bool OsisData::ProcessAttributes(QDomElement& xmlElement)
{
   // Parse and save attributes
   QDomNamedNodeMap attr = xmlElement.attributes();
   int size = attr.size();
   if (!size)
   {
      return false; // Error
   }

   for (int i = 0; i < size; i++)
   {
      QDomAttr at = attr.item(i).toAttr();
      QString value(at.value());
      int key = getEnumKey("OsisElementAttributes", at.name().toLocal8Bit().constData());

      if (key != -1)
      {
         if (Attribute.contains(key))
         {
            Attribute.remove(key);
         }
         Attribute[key] = value;
      }
      else
      {
         qCritical() << "<" << ElementName << ">:  Unknown attribute: " << at.name() << "=" << value << endl;
      }
   }

   return true;
}
开发者ID:omishukov,项目名称:dsu_osis,代码行数:32,代码来源:osisdata.cpp

示例2: LoadContent

void DialogEditNodeTable::LoadContent()
{
    //Load the element value
    m_pValueLine->setText(m_node.toElement().text());

    //Get all the attributes
    QDomNamedNodeMap attributes = m_node.attributes();

    m_pTable->setRowCount(attributes.size());

    QTableWidgetItem* item = 0;

    //Add each attribute in to the table
    for(int indexRow=0; indexRow < attributes.size(); ++indexRow)
    {
        int columnIndex = 0;

        QDomAttr attributeNode = attributes.item(indexRow).toAttr();

        item = new QTableWidgetItem(attributeNode.nodeName());// << attribute name
        item->setToolTip(attributeNode.nodeName());
        m_pTable->setItem(indexRow, columnIndex, item);
        columnIndex++;

        item = new QTableWidgetItem(attributeNode.nodeValue());// << value
        item->setToolTip(attributeNode.nodeValue());
        m_pTable->setItem(indexRow, columnIndex, item);
        columnIndex++;
    }

}
开发者ID:Mauxx91,项目名称:XML-Editor,代码行数:31,代码来源:DialogEditNodeTable.cpp

示例3: pathMapperNode

void PathMapper::addHistory(const QString &localpath, const QString &serverpath, bool saveinproject)
{
  bool exists = false;
  for (unsigned int cnt = 0; cnt < m_serverlist.count() && !exists; cnt++ )
    if(m_serverlist[cnt] == serverpath &&  m_locallist[cnt] == localpath)
      exists = true;

  if(!exists)
  {
    if(saveinproject)
    {
      QDomNode node = pathMapperNode();
      QDomNode newnode = Project::ref()->dom()->createElement("mapping");
  
      QDomAttr serverattr = Project::ref()->dom()->createAttribute("serverpath");
      serverattr.setValue(serverpath);
      QDomAttr localattr = Project::ref()->dom()->createAttribute("localpath");
      localattr.setValue(localpath);
  
      newnode.attributes().setNamedItem(serverattr);
      newnode.attributes().setNamedItem(localattr);
  
      node = node.namedItem("mappings");
      node.insertAfter(newnode, node.lastChild());
    }
    
    m_serverlist.append(serverpath);
    m_locallist.append(localpath);
  }

}
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:31,代码来源:pathmapper.cpp

示例4: getDateTime

// 将销售记录写入文档
void Widget::writeXml()
{
    // 先从文件读取
    if (docRead()) {
            QString currentDate = getDateTime(Date);
            QDomElement root = doc.documentElement();
            // 根据是否有日期节点进行处理
            if (!root.hasChildNodes()) {
                    QDomElement date = doc.createElement(QString("日期"));
                    QDomAttr curDate = doc.createAttribute("date");
                    curDate.setValue(currentDate);
                    date.setAttributeNode(curDate);
                    root.appendChild(date);
                    createNodes(date);
            } else {
                    QDomElement date = root.lastChild().toElement();
                    // 根据是否已经有今天的日期节点进行处理
                    if (date.attribute("date") == currentDate) {
                            createNodes(date);
                    } else {
                            QDomElement date = doc.createElement(QString("日期"));
                            QDomAttr curDate = doc.createAttribute("date");
                            curDate.setValue(currentDate);
                            date.setAttributeNode(curDate);
                            root.appendChild(date);
                            createNodes(date);
                    }
            }
            // 写入到文件
            docWrite();
    }
}
开发者ID:github-jxm,项目名称:QtCrearor_fast_learn,代码行数:33,代码来源:widget.cpp

示例5: while

/** 
 * \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);	
		}
	}
}
开发者ID:app,项目名称:ananas-labs,代码行数:42,代码来源:amsotemplate.cpp

示例6: helperToXmlAddDomElement

static void helperToXmlAddDomElement(QXmlStreamWriter* stream, const QDomElement& element, const QStringList &omitNamespaces)
{
    stream->writeStartElement(element.tagName());

    /* attributes */
    QString xmlns = element.namespaceURI();
    if (!xmlns.isEmpty() && !omitNamespaces.contains(xmlns))
        stream->writeAttribute("xmlns", xmlns);
    QDomNamedNodeMap attrs = element.attributes();
    for (int i = 0; i < attrs.size(); i++)
    {
        QDomAttr attr = attrs.item(i).toAttr();
        stream->writeAttribute(attr.name(), attr.value());
    }

    /* children */
    QDomNode childNode = element.firstChild();
    while (!childNode.isNull())
    {
        if (childNode.isElement())
        {
            helperToXmlAddDomElement(stream, childNode.toElement(), QStringList() << xmlns);
        } else if (childNode.isText()) {
            stream->writeCharacters(childNode.toText().data());
        }
        childNode = childNode.nextSibling();
    }
    stream->writeEndElement();
}
开发者ID:unisontech,项目名称:qxmpp,代码行数:29,代码来源:QXmppServer.cpp

示例7: scanNode

bool ItDocument::scanNode(QDomNode node)
{
    ItElement* itElement;
    QDomElement e = node.toElement();
    //qDebug() << "New element";
    if (!e.isNull()) {
        //QDomElement* element = static_cast<QDomElement*>(&node);
        //QDomElement element = QDomElement (node);
        QDomAttr a = e.attributeNode("id");
        QString id = "";
        if (!a.isNull() && a.namespaceURI()==idNamespaceURI) {
            id =  e.attribute("id","");
        }
        //if (!a.isNull() && a.namespaceURI()!=idNamespaceURI) {qDebug()<<"URI: "<<a.namespaceURI(); }
        //qDebug() << "Adding id:" << id;
        if (id != "") {
            if (index.contains(id)) {
                errorMessage = QObject::tr("Duplicate id '%1' for element '%2'.").arg(id, e.tagName());
                return false;
            }
            itElement = new ItElement(e);
            index[id] = itElement;
        }
        QDomNodeList children = e.childNodes();
        for (unsigned int i=0; i<children.length(); ++i) {
            if (!scanNode(children.at(i)))
                return false;
        }
    }
    return true;
}
开发者ID:czcorpus,项目名称:InterText_editor,代码行数:31,代码来源:ItDocument.cpp

示例8: save

void Properties::save(QDomDocument &doc, QDomElement &parent)
{               
  QDomElement propertiesElem = doc.createElement(XML_TAGNAME.c_str());
  parent.appendChild(propertiesElem);

  QDomAttr propertieAttr;
  for (std::map<std::string, Property*>::iterator it = _properties.begin(); it != _properties.end(); ++it)
  {    
    // to save string lists, we save each value the format property_name[index]
    const std::vector<std::string> &lst = it->second->valueStrList();
    if(lst.size()>1)
    {
      
      for(unsigned int i=0;i<lst.size(); i++)
      {
        QString index;
        index.sprintf("%i",i);
        propertieAttr = doc.createAttribute(QString(it->second->name().c_str()).replace(' ', WHITESPACE_REPLACEMENT)+index);
        propertieAttr.setValue(lst[i].c_str());
        propertiesElem.setAttributeNode(propertieAttr);
      }
    }
    else
    {
      propertieAttr = doc.createAttribute(QString(it->second->name().c_str()).replace(' ', WHITESPACE_REPLACEMENT));
      propertieAttr.setValue(it->second->valueStr().c_str());
      propertiesElem.setAttributeNode(propertieAttr);
    }
  }    
}
开发者ID:foogywoo,项目名称:drone,代码行数:30,代码来源:Properties.cpp

示例9: 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;
}
开发者ID:coder89,项目名称:PhotoLayoutsEditor,代码行数:27,代码来源:BorderDrawersLoader.cpp

示例10: nodeType

int QDomAttrProto:: nodeType()     const
{
  QDomAttr *item = qscriptvalue_cast<QDomAttr*>(thisObject());
  if (item)
    return item->nodeType();
  return 0;
}
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:7,代码来源:qdomattrproto.cpp

示例11: specified

bool QDomAttrProto:: specified()    const
{
  QDomAttr *item = qscriptvalue_cast<QDomAttr*>(thisObject());
  if (item)
    return item->specified();
  return false;
}
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:7,代码来源:qdomattrproto.cpp

示例12: ReplaceHtmlChar

void NewsSite::parseAtom(QDomDocument domDoc)
{
    QDomNodeList entries = domDoc.elementsByTagName("entry");

    for (unsigned int i = 0; i < (unsigned) entries.count(); i++)
    {
        QDomNode itemNode = entries.item(i);
        QString title =  ReplaceHtmlChar(itemNode.namedItem("title").toElement()
                                         .text().simplified());

        QDomNode summNode = itemNode.namedItem("summary");
        QString description = QString::null;
        if (!summNode.isNull())
        {
            description = ReplaceHtmlChar(
                summNode.toElement().text().simplified());
        }

        QDomNode linkNode = itemNode.namedItem("link");
        QString url = QString::null;
        if (!linkNode.isNull())
        {
            QDomAttr linkHref = linkNode.toElement().attributeNode("href");
            if (!linkHref.isNull())
                url = linkHref.value();
        }

        insertNewsArticle(NewsArticle(title, description, url));
    }
}
开发者ID:DragonStalker,项目名称:mythtv,代码行数:30,代码来源:newssite.cpp

示例13: ownerElement

QDomElement QDomAttrProto:: ownerElement() const
{
  QDomAttr *item = qscriptvalue_cast<QDomAttr*>(thisObject());
  if (item)
    return item->ownerElement();
  return QDomElement();
}
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:7,代码来源:qdomattrproto.cpp

示例14: value

QString QDomAttrProto:: value()        const
{
  QDomAttr *item = qscriptvalue_cast<QDomAttr*>(thisObject());
  if (item)
    return item->value();
  return QString();
}
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:7,代码来源:qdomattrproto.cpp

示例15: toString

QString QDomAttrProto:: toString()     const
{
  QDomAttr *item = qscriptvalue_cast<QDomAttr*>(thisObject());
  if (item)
    return QString("[QDomAttr %1='%2']").arg(item->name()).arg(item->value());
  return QString();
}
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:7,代码来源:qdomattrproto.cpp


注:本文中的QDomAttr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。