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


C++ QDomNode::toText方法代码示例

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


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

示例1: parseInstrName

static QString parseInstrName(const QString& name)
      {
      QString sName;
      QDomDocument dom;
      int line, column;
      QString err;
      if (!dom.setContent(name, false, &err, &line, &column)) {
            QString col, ln;
            col.setNum(column);
            ln.setNum(line);
            QString error = err + "\n at line " + ln + " column " + col;
            qDebug("error: %s\n", qPrintable(error));
            qDebug("   data:<%s>\n", qPrintable(name));
            return QString();
            }

      for (QDomNode e = dom.documentElement(); !e.isNull(); e = e.nextSiblingElement()) {
            for (QDomNode ee = e.firstChild(); !ee.isNull(); ee = ee.nextSibling()) {
                  QDomElement el = ee.toElement();
                  const QString& tag(el.tagName());
                  if (tag == "symbol") {
                        QString name = el.attribute(QString("name"));
                        if (name == "flat")
                              sName += "b";
                        else if (name == "sharp")
                              sName += "#";
                        }
                  QDomText t = ee.toText();
                  if (!t.isNull())
                        sName += t.data();
                  }
            }
      return sName;
      }
开发者ID:Mistobaan,项目名称:MuseScore,代码行数:34,代码来源:instrtemplate.cpp

示例2: _getTitle

/**
   Get the project title

   XML in file has this form:
\verbatim
   <qgis projectname="default project">
   <title>a project title</title>
\endverbatim

   @todo XXX we should go with the attribute xor title, not both.
*/
static void _getTitle( QDomDocument const &doc, QString & title )
{
  QDomNodeList nl = doc.elementsByTagName( "title" );

  title = "";                 // by default the title will be empty

  if ( !nl.count() )
  {
    QgsDebugMsg( "unable to find title element" );
    return;
  }

  QDomNode titleNode = nl.item( 0 );  // there should only be one, so zeroth element ok

  if ( !titleNode.hasChildNodes() ) // if not, then there's no actual text
  {
    QgsDebugMsg( "unable to find title element" );
    return;
  }

  QDomNode titleTextNode = titleNode.firstChild();  // should only have one child

  if ( !titleTextNode.isText() )
  {
    QgsDebugMsg( "unable to find title element" );
    return;
  }

  QDomText titleText = titleTextNode.toText();

  title = titleText.data();

} // _getTitle
开发者ID:PhilippeDorelon,项目名称:Quantum-GIS,代码行数:44,代码来源:qgsproject.cpp

示例3: convertLink

bool Converter::convertLink( QTextCursor *cursor, const QDomElement &element, const QTextCharFormat &format )
{
  int startPosition = cursor->position();

  QDomNode child = element.firstChild();
  while ( !child.isNull() ) {
    if ( child.isElement() ) {
      const QDomElement childElement = child.toElement();
      if ( childElement.tagName() == QLatin1String( "span" ) ) {
        if ( !convertSpan( cursor, childElement, format ) )
          return false;
      }
    } else if ( child.isText() ) {
      const QDomText childText = child.toText();
      if ( !convertTextNode( cursor, childText, format ) )
        return false;
    }

    child = child.nextSibling();
  }

  int endPosition = cursor->position();

  Okular::Action *action = new Okular::BrowseAction( QUrl(element.attribute( QStringLiteral("href") )) );
  emit addAction( action, startPosition, endPosition );

  return true;
}
开发者ID:KDE,项目名称:okular,代码行数:28,代码来源:converter.cpp

示例4: convertHeader

bool Converter::convertHeader( QTextCursor *cursor, const QDomElement &element )
{
  const QString styleName = element.attribute( QStringLiteral("style-name") );
  const StyleFormatProperty property = mStyleInformation->styleProperty( styleName );

  QTextBlockFormat blockFormat;
  QTextCharFormat textFormat;
  property.applyBlock( &blockFormat );
  property.applyText( &textFormat );

  cursor->setBlockFormat( blockFormat );

  QDomNode child = element.firstChild();
  while ( !child.isNull() ) {
    if ( child.isElement() ) {
      const QDomElement childElement = child.toElement();
      if ( childElement.tagName() == QLatin1String( "span" ) ) {
        if ( !convertSpan( cursor, childElement, textFormat ) )
          return false;
      }
    } else if ( child.isText() ) {
      const QDomText childText = child.toText();
      if ( !convertTextNode( cursor, childText, textFormat ) )
        return false;
    }

    child = child.nextSibling();
  }

  emit addTitle( element.attribute( QStringLiteral("outline-level"), QStringLiteral("0") ).toInt(), element.text(), cursor->block() );

  return true;
}
开发者ID:KDE,项目名称:okular,代码行数:33,代码来源:converter.cpp

示例5: convertLink

bool Converter::convertLink(QTextCursor *cursor, const QDomElement &element, const QTextCharFormat &format)
{
    int startPosition = cursor->position();

    QDomNode child = element.firstChild();
    while (!child.isNull())
    {
        if (child.isElement())
        {
            const QDomElement childElement = child.toElement();
            if (childElement.tagName() == QLatin1String("span"))
            {
                if (!convertSpan(cursor, childElement, format))
                    return false;
            }
        }
        else if (child.isText())
        {
            const QDomText childText = child.toText();
            if (!convertTextNode(cursor, childText, format))
                return false;
        }

        child = child.nextSibling();
    }

    int endPosition = cursor->position();
    USETODONEXT(endPosition);
    USETODONEXT(startPosition);
    return true;
}
开发者ID:madnight,项目名称:chessx,代码行数:31,代码来源:converter.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: nodeToVariant

//! 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;
    }
开发者ID:gbrault,项目名称:firtool,代码行数:32,代码来源:qxmlsettings.cpp

示例8: QDomText

QDomText QDomNodeProto:: toText() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->toText();
  return QDomText();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例9: valid

		word_t(const QDomNode& node) : valid(false)
									   , ticked(false)
													  , deflines(0)
	{
		QDomElement e = node.toElement();
		if (e.isNull() || e.tagName() != "Word")
			return;
		name = e.attribute("name", "");
		if (name.isEmpty())
			return;
		time = e.attribute("time", "");
		marks = e.attribute("marks", "").toInt();
		QDomNode n = node.firstChild();
		def = n.toText().data();
		def.remove("&nbsp;");
		int pos = def.indexOf('$', 0);
		while (pos >= 0)
		{
			def[pos] = '\n';
			deflines ++;
			pos = def.indexOf('$', pos+1);
		}

		if (def.isEmpty())
			return;
		valid = true;
	}
开发者ID:Ryzh,项目名称:voc,代码行数:27,代码来源:main.cpp

示例10: getText

QString KWDWriter::getText(const QDomElement &paragraph)
{
    QDomNode temp = paragraph.elementsByTagName("TEXT").item(0).firstChild();
    QDomText currentText = temp.toText();
    if (temp.isNull()) {
        kWarning(30503) << "no text";
    }
    return currentText.data();
}
开发者ID:KDE,项目名称:calligra-history,代码行数:9,代码来源:kwdwriter.cpp

示例11: getTextFromNode

QString getTextFromNode(QDomNode* nodePtr) {
	QDomNode childNode = nodePtr->firstChild();
	while (!childNode.isNull()) {
		if (childNode.nodeType() == QDomNode::TextNode) {
			return childNode.toText().data().trimmed();
		}
		childNode = childNode.nextSibling();
	}
	return "";
}
开发者ID:sofgame-plugin,项目名称:psiplus-plugin,代码行数:10,代码来源:utils.cpp

示例12: _parseEntry

void DomParser::_parseEntry(const QDomElement &element, int &l)
{
  if(ready2Parse==FALSE)
    return;

  QDomNode node = element.firstChild();
   
  // Block: only save *complete* o-t pairs
  // Drawback: o must be the first element of e. Is that a problem? We'll see.
  if (node.toElement().tagName() == "o") {
    QDomNode c = node.firstChild();
    if (c.nodeType() == QDomNode::TextNode)
    {
      l++;
    }
  }

  while (!node.isNull()) {
    if (node.toElement().tagName() == "e") {
      _parseEntry(node.toElement(), l);
    } else if (node.toElement().tagName() == "o") {
        QDomNode childNode = node.firstChild();
        while (!childNode.isNull()) {
          if (childNode.nodeType() == QDomNode::TextNode) {
            iTitles[l] = QString(childNode.toText().data());
            break;
          }
          childNode = childNode.nextSibling();
        }
    } else if (node.toElement().tagName() == "t") {
      QDomNode childNode = node.firstChild();
      while (!childNode.isNull()) 
      {
        if (childNode.nodeType() == QDomNode::TextNode && !iTitles[l].isEmpty()) {
          iTexts[l] = QString(childNode.toText().data());
          break;
        }
        childNode = childNode.nextSibling();
      }
    }
    node = node.nextSibling();
  }
}
开发者ID:rene-s,项目名称:KdeLearningAid,代码行数:43,代码来源:klaid.cpp

示例13: getFirstText

static QString getFirstText(QDomElement element)
{
    for (QDomNode dname = element.firstChild(); !dname.isNull();
         dname = dname.nextSibling())
    {
        QDomText t = dname.toText();
        if (!t.isNull())
            return t.data();
    }
    return QString();
}
开发者ID:DocOnDev,项目名称:mythtv,代码行数:11,代码来源:xmltvparser.cpp

示例14: importJreepadFile

void SoftwareImporters::importJreepadFile(){
    typedef QPair<BasketScene *, QDomElement> basketAndElementPair;

    QString fileName = KFileDialog::getOpenFileName(KUrl("kfiledialog:///:ImportJreepadFile"),
                                                    "*.xml|XML files");
    if (fileName.isEmpty()) {
        return;
    }

    basketAndElementPair newElement;
    basketAndElementPair currentElement;
    QList<basketAndElementPair> elements;
    QList<BasketScene*> basketList;

    QDomDocument *doc = XMLWork::openFile("node", fileName);
    newElement.second = doc->documentElement();

    BasketScene *basket = 0;
    BasketFactory::newBasket(/*icon=*/"xml", /*name=*/doc->documentElement().attribute("title"), 
                             /*backgroundImage=*/"", /*backgroundColor=*/QColor(), 
                             /*textColor=*/QColor(), /*templateName=*/"1column", /*createIn=*/0);
    basket = Global::bnpView->currentBasket();
    basket->load();
    basketList << basket;
    newElement.first = basket;

    elements << newElement;

    while ( !elements.isEmpty() ) {
        currentElement = elements.takeFirst();
        for (QDomNode n = currentElement.second.firstChild(); !n.isNull(); n = n.nextSibling()) {
            if ( n.isText() ) {
                basket = currentElement.first;
                Note *note = NoteFactory::createNoteFromText(n.toText().data(), basket);
                basket->insertNote(note, basket->firstNote(), 
                                   Note::BottomColumn, QPoint(), /*animate=*/false);
            } else if ( n.isElement() ) {
                BasketFactory::newBasket(/*icon=*/"xml", /*name=*/n.toElement().attribute("title"), 
                                         /*backgroundImage=*/"", /*backgroundColor=*/QColor(), 
                                         /*textColor=*/QColor(), /*templateName=*/"1column", 
                                         /*createIn=*/currentElement.first);
                basket = Global::bnpView->currentBasket();
                basket->load();
                basketList << basket;
                newElement.first = basket;
                newElement.second = n.toElement();
                elements << newElement;
            }
        }
    }
    
    foreach (basket, basketList) {
        finishImport(basket);
    }
开发者ID:bewitchingme,项目名称:basket,代码行数:54,代码来源:softwareimporters.cpp

示例15: getparstr

std::string QtXmlWrapper::getparstr(const std::string &name,
                                    const std::string &defaultpar) const
{
    QDomNode tmp = findElement( d->m_node, "string", "name", name.c_str() );
    if( tmp.isNull() || !tmp.hasChildNodes() )
    {
        return defaultpar;
    }

    tmp = tmp.firstChild();
    if( tmp.nodeType() == QDomNode::ElementNode && !tmp.toElement().tagName().isEmpty() )
    {
        return tmp.toElement().tagName().toUtf8().constData();
    }
    if( tmp.nodeType() == QDomNode::TextNode && !tmp.toText().data().isEmpty() )
    {
        return tmp.toText().data().toUtf8().constData();
    }

    return defaultpar;
}
开发者ID:Supat609,项目名称:zynaddsubfx,代码行数:21,代码来源:QtXmlWrapper.cpp


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