本文整理汇总了C++中QDomNode::replaceChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::replaceChild方法的具体用法?C++ QDomNode::replaceChild怎么用?C++ QDomNode::replaceChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::replaceChild方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setNodeText
//================================================================================
void customLineEdit::setNodeText(std::string key,
QString & textValue)
{
if(isAttribute_)
{
// ss_.str(""); ss_<< key
// << " was |"
// << elementNode_.toElement().attribute(QString(key.c_str())).toStdString()
// << "| now is |"
// << textValue.toStdString()
// << "|";
// STDLINE(ss_.str(),ACWhite) ;
elementNode_.toElement().setAttribute(QString(key.c_str()),textValue) ;
}
else
{
QDomNode thisNode = elementNode_.toElement()
.elementsByTagName(QString(key.c_str()))
.at(0)
.parentNode()
.toElement()
.elementsByTagName(QString(key.c_str()))
.at(0);
QDomNode child = thisNode.firstChild() ;
QDomText text = elementNode_.ownerDocument().createTextNode(textValue) ;
thisNode.replaceChild(text,child) ;
}
ui->lineEdit->setToolTip(textValue);
}
示例2: accept
void configInfo::accept()
{
QDomNode element = node->root()->node().namedItem(md_root);
QDomNode oldInfoElement =node->root()->node().namedItem(md_root ).namedItem(md_info);//.setNodeValue(editInfo//->text());
QDomDocument domDocument = QDomDocument();
domDocument.setContent(QString("<?xml version = '1.0' encoding = 'UTF-8'?>\n"));
QDomElement newInfoElement = domDocument.createElement(md_info);
QDomElement name = domDocument.createElement(md_info_name);
name.appendChild(domDocument.createTextNode(editInfo->text()));
newInfoElement.appendChild(name);
QDomElement autor = domDocument.createElement(md_info_author);
autor.appendChild(domDocument.createTextNode(autorEdit->text()));
newInfoElement.appendChild(autor);
QDomElement date = domDocument.createElement(md_info_date);
date.appendChild(domDocument.createTextNode(dateEdit->date().toString()));
newInfoElement.appendChild(date);
QDomElement comment = domDocument.createElement(md_info_remark);
comment.appendChild(domDocument.createTextNode(commentEdit->toPlainText()));
newInfoElement.appendChild(comment);
element.replaceChild(newInfoElement, oldInfoElement);
QDialog::accept();
}
示例3: QDomNode
QDomNode QDomNodeProto:: replaceChild(const QDomNode& newChild, const QDomNode& oldChild)
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->replaceChild(newChild, oldChild);
return QDomNode();
}
示例4: QgsDebugMsg
void QgsProjectFileTransform::transform091to0100()
{
QgsDebugMsg( "entering" );
if ( ! mDom.isNull() )
{
// Insert transforms here!
QDomNodeList rasterPropertyList = mDom.elementsByTagName( "rasterproperties" );
QgsDebugMsg( QString( "Raster properties file entries: " ) + QString::number( rasterPropertyList.count() ) );
for ( int i = 0; i < rasterPropertyList.count(); i++ )
{
// Get one rasterproperty element from list, and rename the sub-properties.
QDomNode rasterProperty = rasterPropertyList.item( i );
// rasterProperty.namedItem("").toElement().setTagName("");
rasterProperty.namedItem( "stdDevsToPlotDouble" ).toElement().setTagName( "mStandardDeviations" );
rasterProperty.namedItem( "invertHistogramFlag" ).toElement().setTagName( "mInvertPixelsFlag" );
rasterProperty.namedItem( "showDebugOverLayFlag" ).toElement().setTagName( "mDebugOverLayFlag" );
rasterProperty.namedItem( "redBandNameQString" ).toElement().setTagName( "mRedBandName" );
rasterProperty.namedItem( "blueBandNameQString" ).toElement().setTagName( "mBlueBandName" );
rasterProperty.namedItem( "greenBandNameQString" ).toElement().setTagName( "mGreenBandName" );
rasterProperty.namedItem( "grayBandNameQString" ).toElement().setTagName( "mGrayBandName" );
}
// Changing symbol size for hard: symbols
QDomNodeList symbolPropertyList = mDom.elementsByTagName( "symbol" );
for ( int i = 0; i < symbolPropertyList.count(); i++ )
{
// Get the <poinmtsymbol> to check for 'hard:' for each <symbol>
QDomNode symbolProperty = symbolPropertyList.item( i );
QDomElement pointSymbol = symbolProperty.firstChildElement( "pointsymbol" );
if ( pointSymbol.text().startsWith( "hard:" ) )
{
// Get pointsize and line width
int lineWidth = symbolProperty.firstChildElement( "outlinewidth" ).text().toInt();
int pointSize = symbolProperty.firstChildElement( "pointsize" ).text().toInt();
// Just a precaution, checking for 0
if ( pointSize != 0 )
{
// int r = (s-2*lw)/2-1 --> 2r = (s-2*lw)-2 --> 2r+2 = s-2*lw
// --> 2r+2+2*lw = s
// where '2r' is the old size.
pointSize = pointSize + 2 + 2 * lineWidth;
QgsDebugMsg( QString( "Setting point size to %1" ).arg( pointSize ) );
QDomElement newPointSizeProperty = mDom.createElement( "pointsize" );
QDomText newPointSizeTxt = mDom.createTextNode( QString::number( pointSize ) );
newPointSizeProperty.appendChild( newPointSizeTxt );
symbolProperty.replaceChild( newPointSizeProperty, pointSymbol );
}
}
}
}
return;
}
示例5: setNodeText
//================================================================================
void customTextEdit::setNodeText(std::string key,
QString & textValue)
{
if(isAttribute_)
{
// ss_.str(""); ss_<< key
// << " was |"
// << elementNode_.toElement().attribute(QString(key.c_str())).toStdString()
// << "| now is |"
// << textValue.toStdString()
// << "|";
// STDLINE(ss_.str(),ACRed) ;
elementNode_.toElement().setAttribute(QString(key.c_str()),textValue) ;
// QString text ;
// QTextStream stream( &text );
// elementNode_.save( stream, 2 ) ;
// STDLINE(std::string("Node content sofar: ")+text.toStdString(),ACYellow) ;
usleep(100000) ; // This is important: if users type charecters in the TestEdit box too
// fast, for some reason the elementNode_ is scrambled up. Slow down.
}
else
{
// ss_.str(""); ss_<< key
// << " = "
// << elementNode_.toElement().attribute(QString(key.c_str())).toStdString();
// STDLINE(ss_.str(),ACWhite) ;
QDomNode thisNode = elementNode_.toElement()
.elementsByTagName(QString(key.c_str()))
.at(0)
.parentNode()
.toElement()
.elementsByTagName(QString(key.c_str()))
.at(0);
QDomNode child = thisNode.firstChild() ;
QDomText text = elementNode_.ownerDocument().createTextNode(textValue) ;
thisNode.replaceChild(text,child) ;
}
}
示例6: convertRasterProperties
//.........这里部分代码省略.........
if ( colorShadingAlgorithm == "FreakOutShader" )
{
colorList << "#ff00ff" << "#00ffff" << "#ff0000" << "#00ff00";
}
else //pseudocolor
{
colorList << "#0000ff" << "#00ffff" << "#ffff00" << "#ff0000";
}
QStringList::const_iterator colorIt = colorList.constBegin();
double boundValue = minValue;
for ( ; colorIt != colorList.constEnd(); ++colorIt )
{
QDomElement newItemElem = doc.createElement( "item" );
newItemElem.setAttribute( "value", QString::number( boundValue ) );
newItemElem.setAttribute( "label", QString::number( boundValue ) );
newItemElem.setAttribute( "color", *colorIt );
newColorRampShaderElem.appendChild( newItemElem );
boundValue += breakSize;
}
}
else if ( colorShadingAlgorithm == "ColorRampShader" )
{
QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( "customColorRamp" );
QString type = customColorRampElem.firstChildElement( "colorRampType" ).text();
newColorRampShaderElem.setAttribute( "colorRampType", type );
QDomNodeList colorNodeList = customColorRampElem.elementsByTagName( "colorRampEntry" );
QString value, label;
QColor newColor;
int red, green, blue;
QDomElement currentItemElem;
for ( int i = 0; i < colorNodeList.size(); ++i )
{
currentItemElem = colorNodeList.at( i ).toElement();
value = currentItemElem.attribute( "value" );
label = currentItemElem.attribute( "label" );
red = currentItemElem.attribute( "red" ).toInt();
green = currentItemElem.attribute( "green" ).toInt();
blue = currentItemElem.attribute( "blue" ).toInt();
newColor = QColor( red, green, blue );
QDomElement newItemElem = doc.createElement( "item" );
newItemElem.setAttribute( "value", value );
newItemElem.setAttribute( "label", label );
newItemElem.setAttribute( "color", newColor.name() );
newColorRampShaderElem.appendChild( newItemElem );
}
}
}
else if ( drawingStyle == "PalettedColor" )
{
rasterRendererElem.setAttribute( "type", "paletted" );
rasterRendererElem.setAttribute( "band", grayBand );
QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( "customColorRamp" );
QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( "colorRampEntry" );
QDomElement newColorPaletteElem = doc.createElement( "colorPalette" );
int red = 0;
int green = 0;
int blue = 0;
int value = 0;
QDomElement colorRampEntryElem;
for ( int i = 0; i < colorRampEntryList.size(); ++i )
{
colorRampEntryElem = colorRampEntryList.at( i ).toElement();
QDomElement newPaletteElem = doc.createElement( "paletteEntry" );
value = ( int )( colorRampEntryElem.attribute( "value" ).toDouble() );
newPaletteElem.setAttribute( "value", value );
red = colorRampEntryElem.attribute( "red" ).toInt();
green = colorRampEntryElem.attribute( "green" ).toInt();
blue = colorRampEntryElem.attribute( "blue" ).toInt();
newPaletteElem.setAttribute( "color", QColor( red, green, blue ).name() );
newColorPaletteElem.appendChild( newPaletteElem );
}
rasterRendererElem.appendChild( newColorPaletteElem );
}
else if ( drawingStyle == "MultiBandColor" )
{
rasterRendererElem.setAttribute( "type", "multibandcolor" );
//red band, green band, blue band
int redBand = rasterBandNumber( rasterPropertiesElem, "mRedBandName", rlayer );
int greenBand = rasterBandNumber( rasterPropertiesElem, "mGreenBandName", rlayer );
int blueBand = rasterBandNumber( rasterPropertiesElem, "mBlueBandName", rlayer );
rasterRendererElem.setAttribute( "redBand", redBand );
rasterRendererElem.setAttribute( "greenBand", greenBand );
rasterRendererElem.setAttribute( "blueBand", blueBand );
transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
}
else
{
return;
}
//replace rasterproperties element with rasterrenderer element
if ( !parentNode.isNull() )
{
parentNode.replaceChild( rasterRendererElem, rasterPropertiesElem );
}
}
示例7: visit
//start
QDomElement Slacker::visit(QDomElement element) {
QString name = element.tagName();
QString cvalue = element.attribute("c", QString()) ;
if (cvalue != QString()) { /* Modifying attributes - any c= becomes condition= */
element.setAttribute("condition", cvalue);
element.setAttribute("c", QString());
}
//end
/* For any condition= attribute, add a role= */
cvalue = element.attribute("condition", QString());
if (cvalue != QString()) {
element.setAttribute("role", cvalue);
}
// Mapping elements:
if (name == "p") {
element.setTagName("para");
return element;
}
if (name == "ul") {
element.setTagName("unorderedlist");
return element;
}
//start
if (name == "b") {
element.setAttribute("role", "strong");
element.setTagName("emphasis");
return element;
}
if (name == "li") { /* This transformation is more interesting because
we replace <li> text </li> with
<listitem><para> text </para></listitem>. */
QDomNode parent = element.parentNode();
QDomElement listitem = createElement("listitem");
parent.replaceChild(listitem, element); /* Remove the li tag, put a listitem in its place. */
element.setTagName("para"); /* Modify tag name in-place. */
listitem.appendChild(element);
return listitem;
}
//end
if (name == "include") { /* replaces the entire <include>
node with the contents of a referenced file */
QDomNode parent = element.parentNode();
QString filename = element.attribute("src");
FILE* f = fopen(filename.toAscii(), "r");
if (f==0) {
return element;
}
QTextStream stream(f, QIODevice::ReadOnly);
QString text = stream.readAll();
QDomText tn = this->m_Doc.createTextNode(text);
QDomElement pl = createElement("programlisting");
parent.replaceChild(pl, element);
pl.appendChild(tn);
return pl;
}
return element;
}
示例8: convertRasterProperties
//.........这里部分代码省略.........
if ( colorShadingAlgorithm == "FreakOutShader" )
{
colorList << "#ff00ff" << "#00ffff" << "#ff0000" << "#00ff00";
}
else //pseudocolor
{
colorList << "#0000ff" << "#00ffff" << "#ffff00" << "#ff0000";
}
QStringList::const_iterator colorIt = colorList.constBegin();
double boundValue = minValue;
for ( ; colorIt != colorList.constEnd(); ++colorIt )
{
QDomElement newItemElem = doc.createElement( "item" );
newItemElem.setAttribute( "value", QString::number( boundValue ) );
newItemElem.setAttribute( "label", QString::number( boundValue ) );
newItemElem.setAttribute( "color", *colorIt );
newColorRampShaderElem.appendChild( newItemElem );
boundValue += breakSize;
}
}
else if ( colorShadingAlgorithm == "ColorRampShader" )
{
QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( "customColorRamp" );
QString type = customColorRampElem.firstChildElement( "colorRampType" ).text();
newColorRampShaderElem.setAttribute( "colorRampType", type );
QDomNodeList colorNodeList = customColorRampElem.elementsByTagName( "colorRampEntry" );
QString value, label;
QColor newColor;
int red, green, blue;
QDomElement currentItemElem;
for ( int i = 0; i < colorNodeList.size(); ++i )
{
currentItemElem = colorNodeList.at( i ).toElement();
value = currentItemElem.attribute( "value" );
label = currentItemElem.attribute( "label" );
red = currentItemElem.attribute( "red" ).toInt();
green = currentItemElem.attribute( "green" ).toInt();
blue = currentItemElem.attribute( "blue" ).toInt();
newColor = QColor( red, green, blue );
QDomElement newItemElem = doc.createElement( "item" );
newItemElem.setAttribute( "value", value );
newItemElem.setAttribute( "label", label );
newItemElem.setAttribute( "color", newColor.name() );
newColorRampShaderElem.appendChild( newItemElem );
}
}
}
else if ( drawingStyle == "PalettedColor" )
{
rasterRendererElem.setAttribute( "type", "paletted" );
rasterRendererElem.setAttribute( "band", grayBand );
QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( "customColorRamp" );
QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( "colorRampEntry" );
QDomElement newColorPaletteElem = doc.createElement( "colorPalette" );
int red = 0;
int green = 0;
int blue = 0;
int value = 0;
QDomElement colorRampEntryElem;
for ( int i = 0; i < colorRampEntryList.size(); ++i )
{
colorRampEntryElem = colorRampEntryList.at( i ).toElement();
QDomElement newPaletteElem = doc.createElement( "paletteEntry" );
value = ( int )( colorRampEntryElem.attribute( "value" ).toDouble() );
newPaletteElem.setAttribute( "value", value );
red = colorRampEntryElem.attribute( "red" ).toInt();
green = colorRampEntryElem.attribute( "green" ).toInt();
blue = colorRampEntryElem.attribute( "blue" ).toInt();
newPaletteElem.setAttribute( "color", QColor( red, green, blue ).name() );
newColorPaletteElem.appendChild( newPaletteElem );
}
rasterRendererElem.appendChild( newColorPaletteElem );
}
else if ( drawingStyle == "MultiBandColor" )
{
rasterRendererElem.setAttribute( "type", "multibandcolor" );
//red band, green band, blue band
int redBand = rasterBandNumber( rasterPropertiesElem, "mRedBandName", rlayer );
int greenBand = rasterBandNumber( rasterPropertiesElem, "mGreenBandName", rlayer );
int blueBand = rasterBandNumber( rasterPropertiesElem, "mBlueBandName", rlayer );
rasterRendererElem.setAttribute( "redBand", redBand );
rasterRendererElem.setAttribute( "greenBand", greenBand );
rasterRendererElem.setAttribute( "blueBand", blueBand );
transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
}
else
{
return;
}
//replace rasterproperties element with rasterrenderer element
if ( !parentNode.isNull() )
{
parentNode.replaceChild( rasterRendererElem, rasterPropertiesElem );
}
}