本文整理汇总了C++中QDomNodeList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNodeList::size方法的具体用法?C++ QDomNodeList::size怎么用?C++ QDomNodeList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNodeList
的用法示例。
在下文中一共展示了QDomNodeList::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: traverse
void UiConverter::traverse(QDomNode node, QDomDocument *doc)
{
if (node.isNull())
return;
QDomElement element = node.toElement();
if (!element.isNull()) {
if (element.nodeName() == QLatin1String("ui"))
fixUiNode(element, doc);
else if (element.nodeName() == QLatin1String("set"))
fixSetNode(element, doc);
else if (element.nodeName() == QLatin1String("enum"))
fixEnumNode(element, doc);
else if (element.nodeName() == QLatin1String("connection"))
fixConnectionNode(element, doc);
else if (element.nodeName() == QLatin1String("widget"))
fixWidgetNode(element, doc);
}
QDomNodeList list = node.childNodes();
for (int i=0; i<list.size(); ++i)
traverse(list.at(i), doc);
}
示例2: readMapLayer
void QgsEditorWidgetRegistry::readMapLayer( QgsMapLayer* mapLayer, const QDomElement& layerElem )
{
if ( mapLayer->type() != QgsMapLayer::VectorLayer )
{
return;
}
QgsVectorLayer* vectorLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
Q_ASSERT( vectorLayer );
QDomNodeList editTypeNodes = layerElem.namedItem( "edittypes" ).childNodes();
for ( int i = 0; i < editTypeNodes.size(); i++ )
{
QDomNode editTypeNode = editTypeNodes.at( i );
QDomElement editTypeElement = editTypeNode.toElement();
QString name = editTypeElement.attribute( "name" );
int idx = vectorLayer->fieldNameIndex( name );
if ( idx == -1 )
continue;
bool hasLegacyType;
QgsVectorLayer::EditType editType =
( QgsVectorLayer::EditType ) editTypeElement.attribute( "type" ).toInt( &hasLegacyType );
QString ewv2Type;
QgsEditorWidgetConfig cfg;
if ( hasLegacyType && editType != QgsVectorLayer::EditorWidgetV2 )
{
Q_NOWARN_DEPRECATED_PUSH
ewv2Type = readLegacyConfig( vectorLayer, editTypeElement, cfg );
Q_NOWARN_DEPRECATED_POP
}
else
示例3: LoadPersionInfo
bool MainWindow::LoadPersionInfo()
{
QDomDocument doc;
QFile file("Config/PersionInfo.xml");
bool bl = file.open(QIODevice::ReadOnly);
if(!bl)
{
return false;
}
if(!doc.setContent(&file))
{
return false;
}
m_perInfo.clear();
m_names.clear();
QDomElement root = doc.documentElement();
if(root.hasChildNodes())
{
QDomNodeList keyList = root.childNodes();
for(int i=0; i<keyList.size(); ++i)
{
// 键值
QDomElement keyElem = keyList.at(i).toElement();
QString key = keyElem.attribute("Key");
// value值
QDomElement valueElem = keyElem.childNodes().at(0).toElement();
PersionInfo info;
info.blackCount = valueElem.text().toInt();
// 插入新节点
m_perInfo.insert(key, info);
m_names.push_back(key);
}
}
file.close();
return true;
}
示例4: readXML
bool QgsComposerPicture::readXML( const QDomElement& itemElem, const QDomDocument& doc )
{
if ( itemElem.isNull() )
{
return false;
}
QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
if ( composerItemList.size() > 0 )
{
_readXML( composerItemList.at( 0 ).toElement(), doc );
}
mSvgCacheUpToDate = false;
mDefaultSvgSize = QSize( 0, 0 );
mCachedDpi = 0;
QString fileName = itemElem.attribute( "file" );
setPictureFile( fileName );
mRotation = itemElem.attribute( "rotation" ).toDouble();
return true;
}
示例5: addLegendGroupToTreeWidget
void QgsEmbedLayerDialog::addLegendGroupToTreeWidget( const QDomElement& groupElem, QTreeWidgetItem* parent )
{
QDomNodeList groupChildren = groupElem.childNodes();
QDomElement currentChildElem;
if ( groupElem.attribute( "embedded" ) == "1" )
{
return;
}
QTreeWidgetItem* groupItem = 0;
if ( !parent )
{
groupItem = new QTreeWidgetItem( mTreeWidget );
}
else
{
groupItem = new QTreeWidgetItem( parent );
}
groupItem->setIcon( 0, QgsApplication::getThemeIcon( "mActionFolder.png" ) );
groupItem->setText( 0, groupElem.attribute( "name" ) );
groupItem->setData( 0, Qt::UserRole, "group" );
for ( int i = 0; i < groupChildren.size(); ++i )
{
currentChildElem = groupChildren.at( i ).toElement();
if ( currentChildElem.tagName() == "legendlayer" )
{
addLegendLayerToTreeWidget( currentChildElem, groupItem );
}
else if ( currentChildElem.tagName() == "legendgroup" )
{
addLegendGroupToTreeWidget( currentChildElem, groupItem );
}
}
}
示例6:
/**
* \brief load the definition of the patterns in this syntax
* \param nodes the node list from which the definition of the patterns should be loaded
* \return true on sucess, false on any error
*
* This function loads the definition of the patterns on this syntax from the node list passed as a parameter.
*
* TODO
* define what are patterns
*/
bool QsvLangDef::loadPatternItems( QDomNodeList nodes )
{
QDomNode node;
int i, size = nodes.size();
i = patternItems.size();
for( i=0; i<size; i++ )
{
node = nodes.at( i );
QsvEntityPatternItem e;
if (!loadEntity( node, e )) return false;
e.regex = node.toElement().elementsByTagName("regex").item(0).toElement().text();
// WTF???
// e.regex.replace( "\\\\", "\\" );
e.regex.replace( "\\n", "$" );
patternItems << e;
}
return true;
}
示例7: parseOrderUrls
void RestWidget::parseOrderUrls(QNetworkReply *reply){
if(reply->error()>0){
xmloutput->addItem(QTime::currentTime().toString() +" : " + reply->errorString());
emit connectionError();
} else{
QByteArray data = reply->readAll();
QDomDocument doc;
dataOutput->setText(data);
doc.setContent(data);
QDomNodeList orderNodes = doc.elementsByTagName("order");
for(int i = 0; i < orderNodes.size(); i++){
xmloutput->addItem(orderNodes.at(i).toElement().text());
orderIDs->append(orderNodes.at(i).toElement().text());
}
order_ptr = 0; //reset the order pointer.
}
QObject::disconnect(netManager2, SIGNAL(finished(QNetworkReply*)),this, SLOT(parseOrderUrls(QNetworkReply*)));
}
示例8: GetCategoryDataFromXml
void CGrammarManagerFromProgram::GetCategoryDataFromXml(QDomElement& parentElement, CTreeItem* parentItem)
{
QDomNodeList childrenNode = parentElement.childNodes();
for (int i = 0; i < childrenNode.size(); i++)
{
if (childrenNode.at(i).isElement())
{
QDomElement childElement = childrenNode.at(i).toElement();
if (childElement.tagName() == XML_TAG_CATEGORY)
{
/*创建分类模型子节点*/
QList<QVariant> childData;
childData << childElement.attribute(XML_ATTRIBUTE_NAME);
CTreeItem* childItem = new CTreeItem(childData, parentItem);
/*将子节点添加到模型中*/
parentItem->appendChild(childItem);
GetCategoryDataFromXml(childElement, childItem);
}
}
}
}
示例9: on_mImportColorsButton_clicked
void QgsRasterTerrainAnalysisDialog::on_mImportColorsButton_clicked()
{
QString file = QFileDialog::getOpenFileName( 0, tr( "Import Colors and elevations from xml" ), QDir::homePath() );
if ( file.isEmpty() )
{
return;
}
QFile inputFile( file );
if ( !inputFile.open( QIODevice::ReadOnly ) )
{
QMessageBox::critical( 0, tr( "Error opening file" ), tr( "The relief color file could not be opened" ) );
return;
}
QDomDocument doc;
if ( !doc.setContent( &inputFile, false ) )
{
QMessageBox::critical( 0, tr( "Error parsing xml" ), tr( "The xml file could not be loaded" ) );
return;
}
mReliefClassTreeWidget->clear();
QDomNodeList reliefColorList = doc.elementsByTagName( "ReliefColor" );
for ( int i = 0; i < reliefColorList.size(); ++i )
{
QDomElement reliefColorElem = reliefColorList.at( i ).toElement();
QTreeWidgetItem* newItem = new QTreeWidgetItem();
newItem->setText( 0, reliefColorElem.attribute( "MinElevation" ) );
newItem->setText( 1, reliefColorElem.attribute( "MaxElevation" ) );
newItem->setBackground( 2, QBrush( QColor( reliefColorElem.attribute( "red" ).toInt(), reliefColorElem.attribute( "green" ).toInt(),
reliefColorElem.attribute( "blue" ).toInt() ) ) );
mReliefClassTreeWidget->addTopLevelItem( newItem );
}
}
示例10: addInterfacesData
/*!
* \brief TLMEditor::addInterfacesData
* Adds the InterfacePoint tag to SubModel.
* \param interfaces
*/
void TLMEditor::addInterfacesData(QDomElement interfaces)
{
QDomNodeList subModelList = mXmlDocument.elementsByTagName("SubModel");
for (int i = 0 ; i < subModelList.size() ; i++) {
QDomElement subModel = subModelList.at(i).toElement();
QDomElement interfaceDataElement = interfaces.firstChildElement();
while (!interfaceDataElement.isNull()) {
if (subModel.attribute("Name").compare(interfaceDataElement.attribute("model")) == 0
&& !existInterfaceData(subModel.attribute("Name"), interfaceDataElement.attribute("name"))) {
QDomElement interfacePoint = mXmlDocument.createElement("InterfacePoint");
interfacePoint.setAttribute("Name",interfaceDataElement.attribute("name"));
interfacePoint.setAttribute("Position",interfaceDataElement.attribute("Position"));
interfacePoint.setAttribute("Angle321",interfaceDataElement.attribute("Angle321"));
subModel.appendChild(interfacePoint);
mpPlainTextEdit->setPlainText(mXmlDocument.toString());
TLMInterfacePointInfo *pTLMInterfacePointInfo;
pTLMInterfacePointInfo = new TLMInterfacePointInfo(subModel.attribute("Name"),"shaft3" , interfaceDataElement.attribute("name"));
getModelWidget()->getDiagramGraphicsView()->getComponentObject(subModel.attribute("Name"))->addInterfacePoint(pTLMInterfacePointInfo);
}
interfaceDataElement = interfaceDataElement.nextSiblingElement();
}
}
}
示例11: parseCmd
/**
* @brief parseCmd
* @param cmd
* @param ns
* @return
*
* 解析客户端发送的数据流
* 解析用户发送的命令,如果是报文,直接转发,返回值为0,否则返回1, ns 中存储命名空间列表
*开始报文的格式为
<start>
<namespace/>
<namespace/>
<namespace/>
<appname/>
..
</start>
*/
static int parseCmd(const QString cmd, QList<QString> &ns)
{
int pos = 0;
pos = cmd.indexOf(QString("<CZXP"));
if ( pos < 0)
return CMD_ERROR;
pos = cmd.indexOf(QString("iq"));
if ( pos >= 0) return CMD_NORMAL;
pos = cmd.indexOf(QString("message"));
if (pos >= 0) return CMD_NORMAL;
QDomDocument dom;
QDomElement root;
//QDomNode root;
QDomNodeList nslist;
if( !dom.setContent(cmd.toUtf8()))
return CMD_ERROR;
//如果没有start节点则认为是正常的报文
root = dom.firstChild().toElement();
if ( root.isNull())
return CMD_NORMAL;
nslist = root.elementsByTagName(QString("namespace"));
int sz = nslist.size();
if ( sz == 0 )
return CMD_NORMAL;
ns.clear();
for ( pos = 0; pos < sz; ++pos)
{
QDomNode node = nslist.item(pos);
QString value = node.lastChild().nodeValue();
ns.push_back(value);
}
return CMD_START;
}
示例12: setLegendGroupElementsWithLayerTree
QList<QDomElement> QgsServerProjectParser::setLegendGroupElementsWithLayerTree( QgsLayerTreeGroup* layerTreeGroup, const QDomElement& legendElement ) const
{
QList<QDomElement> LegendGroupElemList;
QList< QgsLayerTreeNode * > layerTreeGroupChildren = layerTreeGroup->children();
QDomNodeList legendElementChildNodes = legendElement.childNodes();
int g = 0; // index of the last child layer tree group
for ( int i = 0; i < legendElementChildNodes.size(); ++i )
{
QDomNode legendElementNode = legendElementChildNodes.at( i );
if ( !legendElementNode.isElement() )
continue;
QDomElement legendElement = legendElementNode.toElement();
if ( legendElement.tagName() != "legendgroup" )
continue;
for ( int j = g; j < i + 1; ++j )
{
QgsLayerTreeNode* layerTreeNode = layerTreeGroupChildren.at( j );
if ( layerTreeNode->nodeType() != QgsLayerTreeNode::NodeGroup )
continue;
QgsLayerTreeGroup* layerTreeGroup = static_cast<QgsLayerTreeGroup *>( layerTreeNode );
if ( layerTreeGroup->name() == legendElement.attribute( "name" ) )
{
g = j;
QString shortName = layerTreeGroup->customProperty( "wmsShortName" ).toString();
if ( !shortName.isEmpty() )
legendElement.setAttribute( "shortName", shortName );
QString title = layerTreeGroup->customProperty( "wmsTitle" ).toString();
if ( !title.isEmpty() )
legendElement.setAttribute( "title", title );
LegendGroupElemList.append( setLegendGroupElementsWithLayerTree( layerTreeGroup, legendElement ) );
}
}
LegendGroupElemList.push_back( legendElement );
}
return LegendGroupElemList;
}
示例13: setInputVariablesXml
void ModPlusExeCtrl::setInputVariablesXml(QDomDocument & doc, QString modelName, MOVector<Variable> *variables)
{
QDomElement xfmi = doc.firstChildElement("fmiModelDescription");
QDomElement oldxfmi = xfmi;
QDomElement xModelVars = xfmi.firstChildElement("ModelVariables");
QDomElement oldxModelVars = xModelVars;
QDomNodeList listScalarVars = xModelVars.elementsByTagName("ScalarVariable");
// filling map
QMap<QString,int> mapScalarVars; //<name,index in listScalarVars>
QMap<QDomElement,QDomElement> mapNewScalarVars; // <old node,new node>
QDomElement curVar;
QDomElement oldVar;
QDomElement newVar;
int index;
QDomElement oldType;
QDomElement newType;
QString localVarName;
// create map for index looking
for(int i=0;i<listScalarVars.size();i++)
{
curVar = listScalarVars.at(i).toElement();
mapScalarVars.insert(curVar.attribute("name"),i);
}
// change variables values
for(int i=0;i<variables->size();i++)
{
// getting local var name (name in init file does not contain model name)
localVarName = variables->at(i)->name(Variable::SHORT);
if(localVarName.contains(modelName))
localVarName = localVarName.remove(modelName+".");
index = mapScalarVars.value(localVarName,-1);
if(index>-1)
{
oldVar = listScalarVars.at(index).toElement();
newVar = oldVar;
oldType = newVar.firstChildElement("Real");
if(oldType.isNull())
oldType = newVar.firstChildElement("Integer");
if(oldType.isNull())
oldType = newVar.firstChildElement("Boolean");
if(!oldType.isNull())
{
newType = oldType;
newType.setAttribute("start",variables->at(i)->value().toString());
newVar.replaceChild(newType,oldType);
xModelVars.replaceChild(newVar,oldVar);
}
xModelVars.replaceChild(newVar,oldVar);
}
}
// update xfmi with new vars
xfmi.replaceChild(xModelVars,oldxModelVars);
doc.replaceChild(xfmi,oldxfmi);
}
示例14: readXML
bool QgsComposerShape::readXML( const QDomElement& itemElem, const QDomDocument& doc )
{
mShape = QgsComposerShape::Shape( itemElem.attribute( "shapeType", "0" ).toInt() );
mCornerRadius = itemElem.attribute( "cornerRadius", "0" ).toDouble();
//restore general composer item properties
QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
if ( composerItemList.size() > 0 )
{
QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
//rotation
if ( composerItemElem.attribute( "rotation", "0" ).toDouble() != 0 )
{
//check for old (pre 2.1) rotation attribute
setItemRotation( composerItemElem.attribute( "rotation", "0" ).toDouble() );
}
_readXML( composerItemElem, doc );
}
QDomElement shapeStyleSymbolElem = itemElem.firstChildElement( "symbol" );
if ( !shapeStyleSymbolElem.isNull() )
{
delete mShapeStyleSymbol;
mShapeStyleSymbol = dynamic_cast<QgsFillSymbolV2*>( QgsSymbolLayerV2Utils::loadSymbol( shapeStyleSymbolElem ) );
}
else
{
//upgrade project file from 2.0 to use symbolV2 styling
delete mShapeStyleSymbol;
QgsStringMap properties;
properties.insert( "color", QgsSymbolLayerV2Utils::encodeColor( brush().color() ) );
if ( hasBackground() )
{
properties.insert( "style", "solid" );
}
else
{
properties.insert( "style", "no" );
}
if ( hasFrame() )
{
properties.insert( "style_border", "solid" );
}
else
{
properties.insert( "style_border", "no" );
}
properties.insert( "color_border", QgsSymbolLayerV2Utils::encodeColor( pen().color() ) );
properties.insert( "width_border", QString::number( pen().widthF() ) );
//for pre 2.0 projects, shape colour and outline were specified in a different element...
QDomNodeList outlineColorList = itemElem.elementsByTagName( "OutlineColor" );
if ( outlineColorList.size() > 0 )
{
QDomElement frameColorElem = outlineColorList.at( 0 ).toElement();
bool redOk, greenOk, blueOk, alphaOk, widthOk;
int penRed, penGreen, penBlue, penAlpha;
double penWidth;
penWidth = itemElem.attribute( "outlineWidth" ).toDouble( &widthOk );
penRed = frameColorElem.attribute( "red" ).toDouble( &redOk );
penGreen = frameColorElem.attribute( "green" ).toDouble( &greenOk );
penBlue = frameColorElem.attribute( "blue" ).toDouble( &blueOk );
penAlpha = frameColorElem.attribute( "alpha" ).toDouble( &alphaOk );
if ( redOk && greenOk && blueOk && alphaOk && widthOk )
{
properties.insert( "color_border", QgsSymbolLayerV2Utils::encodeColor( QColor( penRed, penGreen, penBlue, penAlpha ) ) );
properties.insert( "width_border", QString::number( penWidth ) );
}
}
QDomNodeList fillColorList = itemElem.elementsByTagName( "FillColor" );
if ( fillColorList.size() > 0 )
{
QDomElement fillColorElem = fillColorList.at( 0 ).toElement();
bool redOk, greenOk, blueOk, alphaOk;
int fillRed, fillGreen, fillBlue, fillAlpha;
fillRed = fillColorElem.attribute( "red" ).toDouble( &redOk );
fillGreen = fillColorElem.attribute( "green" ).toDouble( &greenOk );
fillBlue = fillColorElem.attribute( "blue" ).toDouble( &blueOk );
fillAlpha = fillColorElem.attribute( "alpha" ).toDouble( &alphaOk );
if ( redOk && greenOk && blueOk && alphaOk )
{
properties.insert( "color", QgsSymbolLayerV2Utils::encodeColor( QColor( fillRed, fillGreen, fillBlue, fillAlpha ) ) );
properties.insert( "style", "solid" );
}
}
if ( itemElem.hasAttribute( "transparentFill" ) )
{
//old style (pre 2.0) of specifying that shapes had no fill
bool hasOldTransparentFill = itemElem.attribute( "transparentFill", "0" ).toInt();
if ( hasOldTransparentFill )
{
properties.insert( "style", "no" );
}
}
//.........这里部分代码省略.........
示例15: importTextSpoiler
int OracleImporter::importTextSpoiler(CardSet *set, const QByteArray &data)
{
int cards = 0;
QString bufferContents(data);
// Workaround for ampersand bug in text spoilers
int index = -1;
while ((index = bufferContents.indexOf('&', index + 1)) != -1) {
int semicolonIndex = bufferContents.indexOf(';', index);
if (semicolonIndex > 5) {
bufferContents.insert(index + 1, "amp;");
index += 4;
}
}
QDomDocument doc;
QString errorMsg;
int errorLine, errorColumn;
if (!doc.setContent(bufferContents, &errorMsg, &errorLine, &errorColumn))
qDebug() << "error:" << errorMsg << "line:" << errorLine << "column:" << errorColumn;
QDomNodeList divs = doc.elementsByTagName("div");
for (int i = 0; i < divs.size(); ++i) {
QDomElement div = divs.at(i).toElement();
QDomNode divClass = div.attributes().namedItem("class");
if (divClass.nodeValue() == "textspoiler") {
QString cardName, cardCost, cardType, cardPT, cardText;
int cardId = 0;
int cardLoyalty = 0;
QDomNodeList trs = div.elementsByTagName("tr");
for (int j = 0; j < trs.size(); ++j) {
QDomElement tr = trs.at(j).toElement();
QDomNodeList tds = tr.elementsByTagName("td");
if (tds.size() != 2) {
QStringList cardTextSplit = cardText.split("\n");
for (int i = 0; i < cardTextSplit.size(); ++i)
cardTextSplit[i] = cardTextSplit[i].trimmed();
CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, cardCost, cardType, cardPT, cardLoyalty, cardTextSplit);
if (!set->contains(card)) {
card->addToSet(set);
cards++;
}
cardName = cardCost = cardType = cardPT = cardText = QString();
} else {
QString v1 = tds.at(0).toElement().text().simplified();
QString v2 = tds.at(1).toElement().text().replace(trUtf8("—"), "-");
if (v1 == "Name") {
QDomElement a = tds.at(1).toElement().elementsByTagName("a").at(0).toElement();
QString href = a.attributes().namedItem("href").nodeValue();
cardId = href.mid(href.indexOf("multiverseid=") + 13).toInt();
cardName = v2.simplified();
} else if (v1 == "Cost:")
cardCost = v2.simplified();
else if (v1 == "Type:")
cardType = v2.simplified();
else if (v1 == "Pow/Tgh:")
cardPT = v2.simplified().remove('(').remove(')');
else if (v1 == "Rules Text:")
cardText = v2.trimmed();
else if (v1 == "Loyalty:")
cardLoyalty = v2.trimmed().remove('(').remove(')').toInt();
}
}
break;
}
}
return cards;
}