本文整理汇总了C++中QDomDocument::createElement方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::createElement方法的具体用法?C++ QDomDocument::createElement怎么用?C++ QDomDocument::createElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomDocument
的用法示例。
在下文中一共展示了QDomDocument::createElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeTasksElement
QDomElement Task::makeTasksElement( QDomDocument document, const TaskList& tasks )
{
QDomElement element = document.createElement( taskListTagName() );
Q_FOREACH( const Task& task, tasks ) {
element.appendChild( task.toXml( document ) );
}
示例2: setGetCapabilitiesResponse
void QgsSOAPRequestHandler::setGetCapabilitiesResponse( const QDomDocument& doc )
{
//Parse the QDomDocument Document and create a SOAP response
QDomElement DocCapabilitiesElement = doc.firstChildElement();
if ( !DocCapabilitiesElement.isNull() )
{
QDomNodeList capabilitiesNodes = DocCapabilitiesElement.elementsByTagName( "Capability" );
if ( capabilitiesNodes.size() > 0 )
{
//create response document
QDomDocument soapResponseDoc;
//Envelope element
QDomElement soapEnvelopeElement = soapResponseDoc.createElement( "soap:Envelope" );
soapEnvelopeElement.setAttribute( "xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/" );
soapEnvelopeElement.setAttribute( "soap:encoding", "http://schemas.xmlsoap.org/soap/encoding/" );
soapResponseDoc.appendChild( soapEnvelopeElement );
//Body element
QDomElement soapBodyElement = soapResponseDoc.createElementNS( "http://schemas.xmlsoap.org/soap/envelope/", "soap:Body" );
soapEnvelopeElement.appendChild( soapBodyElement );
// check if WMS or MS SOAP request
if ( mService == "MS" || mService == "MDS" || mService == "MAS" )
{
//OA_MI_MS_Capabilities element
QDomElement msCapabilitiesElement = soapResponseDoc.createElement( "ms:OA_MI_Service_Capabilities" );
msCapabilitiesElement.setAttribute( "service", "MS" );
msCapabilitiesElement.setAttribute( "version", "1.1" );
msCapabilitiesElement.setAttribute( "xmlns:ms", "http://www.eu-orchestra.org/services/ms" );
msCapabilitiesElement.setAttribute( "xmlns", "http://www.eu-orchestra.org/services/oas/oa_basic" );
msCapabilitiesElement.setAttribute( "xmlns:gml", "http://www.opengis.net/gml" );
msCapabilitiesElement.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
msCapabilitiesElement.setAttribute( "xmlns:xsd", "http://www.w3.org/2001/XMLSchema" );
soapBodyElement.appendChild( msCapabilitiesElement );
// import the orchestra common capabilities
QFile common( "common.xml" );
if ( !common.open( QIODevice::ReadOnly ) )
{
//throw an exception...
QgsDebugMsg( "external orchestra common capabilities not found" );
}
else
{
QDomDocument externCapDoc;
QString parseError;
int errorLineNo;
if ( !externCapDoc.setContent( &common, false, &parseError, &errorLineNo ) )
{
QgsDebugMsg( "parse error at setting content of external orchestra common capabilities: "
+ parseError + " at line " + QString::number( errorLineNo ) );
common.close();
}
common.close();
// write common capabilities
QDomElement orchestraCommon = externCapDoc.firstChildElement();
msCapabilitiesElement.appendChild( orchestraCommon );
// write specific capabilities
QDomElement msSpecificCapabilitiesElement = soapResponseDoc.createElement( "serviceSpecificCapabilities" );
soapBodyElement.appendChild( msSpecificCapabilitiesElement );
QDomElement capabilitiesElement = capabilitiesNodes.item( 0 ).toElement();
msSpecificCapabilitiesElement.appendChild( capabilitiesElement );
// to do supportedOperations
QDomNodeList requestNodes = capabilitiesElement.elementsByTagName( "Request" );
if ( requestNodes.size() > 0 )
{
QDomElement requestElement = requestNodes.item( 0 ).toElement();
QDomNodeList requestChildNodes = requestElement.childNodes();
//append an array element for 'supportedOperations' to the soap document
QDomElement supportedOperationsElement = soapResponseDoc.createElement( "supportedOperations" );
supportedOperationsElement.setAttribute( "xsi:type", "soapenc:Array" );
supportedOperationsElement.setAttribute( "soap:arrayType", "xsd:string[" + QString::number( requestChildNodes.size() ) + "]" );
for ( int i = 0; i < requestChildNodes.size(); ++i )
{
QDomElement itemElement = soapResponseDoc.createElement( "item" );
QDomText itemText = soapResponseDoc.createTextNode( requestChildNodes.item( i ).toElement().tagName() );
itemElement.appendChild( itemText );
supportedOperationsElement.appendChild( itemElement );
}
}
//operationTypeInfo
//predefinedLayers
//predefinedDimensions
//layerTypeInfo
//predefinedStyles
//supportedLayerDataInputFormat
//supportedExceptionFormats
//supportedDCP
}
}
//.........这里部分代码省略.........
示例3: writeXML
bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )
{
// general layer metadata
QDomElement maplayer = document.createElement( "maplayer" );
// use scale dependent visibility flag
maplayer.setAttribute( "hasScaleBasedVisibilityFlag", hasScaleBasedVisibility() ? 1 : 0 );
maplayer.setAttribute( "minimumScale", minimumScale() );
maplayer.setAttribute( "maximumScale", maximumScale() );
// ID
QDomElement layerId = document.createElement( "id" );
QDomText layerIdText = document.createTextNode( id() );
layerId.appendChild( layerIdText );
maplayer.appendChild( layerId );
// data source
QDomElement dataSource = document.createElement( "datasource" );
QString src = source();
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( this );
if ( vlayer && vlayer->providerType() == "spatialite" )
{
QgsDataSourceURI uri( src );
QString database = QgsProject::instance()->writePath( uri.database() );
uri.setConnection( uri.host(), uri.port(), database, uri.username(), uri.password() );
src = uri.uri();
}
else if ( vlayer && vlayer->providerType() == "ogr" )
{
QStringList theURIParts = src.split( "|" );
theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0] );
src = theURIParts.join( "|" );
}
else if ( vlayer && vlayer->providerType() == "delimitedtext" )
{
QUrl urlSource = QUrl::fromEncoded( src.toAscii() );
QUrl urlDest = QUrl::fromLocalFile( QgsProject::instance()->writePath( urlSource.toLocalFile() ) );
urlDest.setQueryItems( urlSource.queryItems() );
src = QString::fromAscii( urlDest.toEncoded() );
}
else
{
src = QgsProject::instance()->writePath( src );
}
QDomText dataSourceText = document.createTextNode( src );
dataSource.appendChild( dataSourceText );
maplayer.appendChild( dataSource );
// layer name
QDomElement layerName = document.createElement( "layername" );
QDomText layerNameText = document.createTextNode( name() );
layerName.appendChild( layerNameText );
maplayer.appendChild( layerName );
// timestamp if supported
if ( timestamp() > QDateTime() )
{
QDomElement stamp = document.createElement( "timestamp" );
QDomText stampText = document.createTextNode( timestamp().toString( Qt::ISODate ) );
stamp.appendChild( stampText );
maplayer.appendChild( stamp );
}
maplayer.appendChild( layerName );
// zorder
// This is no longer stored in the project file. It is superfluous since the layers
// are written and read in the proper order.
// spatial reference system id
QDomElement mySrsElement = document.createElement( "srs" );
mCRS->writeXML( mySrsElement, document );
maplayer.appendChild( mySrsElement );
// <transparencyLevelInt>
QDomElement transparencyLevelIntElement = document.createElement( "transparencyLevelInt" );
QDomText transparencyLevelIntText = document.createTextNode( QString::number( getTransparency() ) );
transparencyLevelIntElement.appendChild( transparencyLevelIntText );
maplayer.appendChild( transparencyLevelIntElement );
// now append layer node to map layer node
layer_node.appendChild( maplayer );
writeCustomProperties( maplayer, document );
return writeXml( maplayer, document );
} // bool QgsMapLayer::writeXML
示例4: writeCondition
void XmlCndInterface::writeCondition( QDomDocument doc, QDomElement &listTag, const FEMCondition* cond, const QString &condText, const QString &geometryName) const
{
QString geoName (QString::fromStdString(cond->getAssociatedGeometryName()));
if ((geometryName.length()>0) && (geoName.compare(geometryName) != 0))
{
std::cout << "Geometry name not matching, skipping condition \"" << cond->getGeoName() << "\"..." << std::endl;
return;
}
QDomElement condTag ( doc.createElement(condText) );
condTag.setAttribute("geometry", geoName);
listTag.appendChild(condTag);
QDomElement processTag ( doc.createElement("Process") );
condTag.appendChild(processTag);
QDomElement processTypeTag ( doc.createElement("Type") );
processTag.appendChild(processTypeTag);
QDomText processTypeText ( doc.createTextNode(
QString::fromStdString(FiniteElement::convertProcessTypeToString(cond->getProcessType()))) );
processTypeTag.appendChild(processTypeText);
QDomElement processPVTag ( doc.createElement("Variable") );
processTag.appendChild(processPVTag);
QDomText processPVText ( doc.createTextNode(
QString::fromStdString(FiniteElement::convertPrimaryVariableToString(cond->getProcessPrimaryVariable()))) );
processPVTag.appendChild(processPVText);
QDomElement geoTag ( doc.createElement("Geometry") );
condTag.appendChild(geoTag);
QDomElement geoTypeTag ( doc.createElement("Type") );
geoTag.appendChild(geoTypeTag);
QDomText geoTypeText ( doc.createTextNode(
QString::fromStdString(GeoLib::convertGeoTypeToString(cond->getGeoType()))) );
geoTypeTag.appendChild(geoTypeText);
QDomElement geoNameTag ( doc.createElement("Name") );
geoTag.appendChild(geoNameTag);
QString geo_obj_name ( QString::fromStdString(cond->getGeoName()) );
QDomText geoNameText ( doc.createTextNode(geo_obj_name) );
geoNameTag.appendChild(geoNameText);
QDomElement disTag ( doc.createElement("Distribution") );
condTag.appendChild(disTag);
QDomElement disTypeTag ( doc.createElement("Type") );
disTag.appendChild(disTypeTag);
QDomText disTypeText ( doc.createTextNode(
QString::fromStdString(FiniteElement::convertDisTypeToString(cond->getProcessDistributionType()))) );
disTypeTag.appendChild(disTypeText);
QDomElement disValueTag ( doc.createElement("Value") );
disTag.appendChild(disValueTag);
/*
if (cond->getProcessDistributionType() != FiniteElement::DIRECT)
{
double dis_value (cond->getDisValue()[0]); //TODO: do this correctly!
disValueText = doc.createTextNode(QString::number(dis_value));
}
else
disValueText = doc.createTextNode(QString::fromStdString(cond->getDirectFileName()));
*/
const std::vector<size_t> dis_nodes = cond->getDisNodes();
const std::vector<double> dis_values = cond->getDisValues();
const size_t nNodes = dis_nodes.size();
const size_t nValues = dis_values.size();
std::stringstream ss;
if (nNodes==0 && nValues==1) // CONSTANT
ss << dis_values[0];
else if ((nValues>0) && (nValues==nNodes)) // LINEAR && DIRECT
{
ss << "\n\t";
for (size_t i=0; i<nValues; i++)
ss << dis_nodes[i] << "\t" << dis_values[i] << "\n\t";
}
else
{
std::cout << "Error in XmlCndInterface::writeCondition() - Inconsistent length of distribution value array." << std::endl;
ss << "-9999";
}
std::string dv = ss.str();
QDomText disValueText = doc.createTextNode(QString::fromStdString(ss.str()));
disValueTag.appendChild(disValueText);
}
示例5: save
/*!
\overload
*/
void QFormatScheme::save(QDomElement& elem) const
{
QDomDocument doc = elem.ownerDocument();
elem.setAttribute("version", QFORMAT_VERSION);
for ( int i = 0; i < m_formatKeys.count(); ++i )
{
QDomText t;
QDomElement f, c = doc.createElement("format");
c.setAttribute("id", m_formatKeys.at(i));
const QFormat& fmt = m_formatValues.at(i);
f = doc.createElement("bold");
t = doc.createTextNode((fmt.weight == QFont::Bold) ? "true" : "false");
f.appendChild(t);
c.appendChild(f);
f = doc.createElement("italic");
t = doc.createTextNode(fmt.italic ? "true" : "false");
f.appendChild(t);
c.appendChild(f);
f = doc.createElement("overline");
t = doc.createTextNode(fmt.overline ? "true" : "false");
f.appendChild(t);
c.appendChild(f);
f = doc.createElement("underline");
t = doc.createTextNode(fmt.underline ? "true" : "false");
f.appendChild(t);
c.appendChild(f);
f = doc.createElement("strikeout");
t = doc.createTextNode(fmt.strikeout ? "true" : "false");
f.appendChild(t);
c.appendChild(f);
f = doc.createElement("waveUnderline");
t = doc.createTextNode(fmt.waveUnderline ? "true" : "false");
f.appendChild(t);
c.appendChild(f);
if ( fmt.foreground.isValid() )
{
f = doc.createElement("foreground");
t = doc.createTextNode(fmt.foreground.name());
f.appendChild(t);
c.appendChild(f);
}
if ( fmt.background.isValid() )
{
f = doc.createElement("background");
t = doc.createTextNode(fmt.background.name());
f.appendChild(t);
c.appendChild(f);
}
if ( fmt.linescolor.isValid() )
{
f = doc.createElement("linescolor");
t = doc.createTextNode(fmt.linescolor.name());
f.appendChild(t);
c.appendChild(f);
}
elem.appendChild(c);
}
}
示例6: addToXML
void addToXML(QString data)
{
/*
This fuction will parse the data from the CSPro
into XML nodes. There are several controling bool
variables to knows where in the CSPro data data is
and how is its parent
*/
bool section;
section = false;
QString currData;
currData = data;
if (data == "[Dictionary]")
{
section = true;
inDict = true;
inLevel = false;
inIdItems = false;
inItem = false;
inRecord = false;
inValueSet = false;
createRecords = true;
dict = doc.createElement("Dictionary");
root.appendChild(dict);
}
if (data == "[Level]")
{
section = true;
inDict = false;
inLevel = true;
inIdItems = false;
inRecord = false;
inItem = false;
inValueSet = false;
level = doc.createElement("Level");
dict.appendChild(level);
}
if (data == "[IdItems]")
{
section = true;
inDict = false;
inLevel = false;
inIdItems = true;
inRecord = false;
inItem = false;
inValueSet = false;
createItems = true;
iditems = doc.createElement("IdItems");
dict.appendChild(iditems);
}
if (data == "[Item]")
{
section = true;
inDict = false;
inLevel = false;
inItem = true;
inValueSet = false;
if (createItems)
{
if (inIdItems)
{
items = doc.createElement("Items");
iditems.appendChild(items);
}
if (inRecord)
{
items = doc.createElement("Items");
record.appendChild(items);
}
createItems = false;
}
item = doc.createElement("Item");
items.appendChild(item);
}
if (data == "[Record]")
{
section = true;
inDict = false;
inLevel = false;
inIdItems = false;
inItem = false;
inRecord = true;
inValueSet = false;
createItems = true;
if (createRecords)
{
records = doc.createElement("Records");
dict.appendChild(records);
createRecords = false;
}
record = doc.createElement("Record");
records.appendChild(record);
}
if (data == "[ValueSet]")
{
section = true;
inDict = false;
//.........这里部分代码省略.........
示例7: serialize
QDomElement PMObject::serialize( QDomDocument& doc ) const
{
QDomElement e = doc.createElement( className( ).lower( ) );
serialize( e, doc );
return e;
}
示例8: saveSldStyle
QString QgsMapLayer::saveSldStyle( const QString theURI, bool & theResultFlag )
{
QDomDocument myDocument = QDomDocument();
QDomNode header = myDocument.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" );
myDocument.appendChild( header );
// Create the root element
QDomElement root = myDocument.createElementNS( "http://www.opengis.net/sld", "StyledLayerDescriptor" );
root.setAttribute( "version", "1.1.0" );
root.setAttribute( "xsi:schemaLocation", "http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
root.setAttribute( "xmlns:ogc", "http://www.opengis.net/ogc" );
root.setAttribute( "xmlns:se", "http://www.opengis.net/se" );
root.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
root.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
myDocument.appendChild( root );
// Create the NamedLayer element
QDomElement namedLayerNode = myDocument.createElement( "NamedLayer" );
root.appendChild( namedLayerNode );
QString errorMsg;
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( this );
if ( !vlayer )
{
theResultFlag = false;
return tr( "Could not save symbology because:\n%1" ).arg( "Non-vector layers not supported yet" );
}
if ( !vlayer->writeSld( namedLayerNode, myDocument, errorMsg ) )
{
theResultFlag = false;
return tr( "Could not save symbology because:\n%1" ).arg( errorMsg );
}
// check if the uri is a file or ends with .sld,
// which indicates that it should become one
QString filename;
if ( vlayer->providerType() == "ogr" )
{
QStringList theURIParts = theURI.split( "|" );
filename = theURIParts[0];
}
else if ( vlayer->providerType() == "delimitedtext" )
{
filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile();
}
else
{
filename = theURI;
}
QFileInfo myFileInfo( filename );
if ( myFileInfo.exists() || filename.endsWith( ".sld", Qt::CaseInsensitive ) )
{
QFileInfo myDirInfo( myFileInfo.path() ); //excludes file name
if ( !myDirInfo.isWritable() )
{
return tr( "The directory containing your dataset needs to be writable!" );
}
// now construct the file name for our .sld style file
QString myFileName = myFileInfo.path() + QDir::separator() + myFileInfo.completeBaseName() + ".sld";
QFile myFile( myFileName );
if ( myFile.open( QFile::WriteOnly | QFile::Truncate ) )
{
QTextStream myFileStream( &myFile );
// save as utf-8 with 2 spaces for indents
myDocument.save( myFileStream, 2 );
myFile.close();
theResultFlag = true;
return tr( "Created default style file as %1" ).arg( myFileName );
}
}
theResultFlag = false;
return tr( "ERROR: Failed to created SLD style file as %1. Check file permissions and retry." ).arg( filename );
}
示例9: getXmlItem
QDomElement PixmapItem::getXmlItem(QDomDocument xml )
{
QDomElement pictureItem = xml.createElement( "CardPixmapItem");
QDomElement newElement = xml.createElement( "name");
QDomText text = xml.createTextNode(name);
newElement.appendChild(text);
pictureItem.appendChild(newElement);
newElement = xml.createElement( "source");
text = xml.createTextNode(QString::number(source));
newElement.appendChild(text);
pictureItem.appendChild(newElement);
newElement = xml.createElement( "file");
if(file != "" && source == 0)
text = xml.createTextNode(file);
else
{
if(source == 0)
text = xml.createTextNode(":/images/gadu.png");
else
text = xml.createTextNode("");
}
newElement.appendChild(text);
pictureItem.appendChild(newElement);
newElement = xml.createElement( "posX");
text = xml.createTextNode(QString::number(pos().x()));
newElement.appendChild(text);
pictureItem.appendChild(newElement);
newElement = xml.createElement( "posY");
text = xml.createTextNode(QString::number(pos().y()));
newElement.appendChild(text);
pictureItem.appendChild(newElement);
newElement = xml.createElement( "zValue");
text = xml.createTextNode(QString::number( zValue() ));
newElement.appendChild(text);
pictureItem.appendChild(newElement);
newElement = xml.createElement( "width");
text = xml.createTextNode(QString::number(boundingRect().width()));
newElement.appendChild(text);
pictureItem.appendChild(newElement);
newElement = xml.createElement( "height");
text = xml.createTextNode(QString::number(boundingRect().height()));
newElement.appendChild(text);
pictureItem.appendChild(newElement);
newElement = xml.createElement( "isLocked");
text = xml.createTextNode(QString::number(isLocked));
newElement.appendChild(text);
pictureItem.appendChild(newElement);
return pictureItem;
}
示例10: serviceCapabilities
void QgsServerProjectParser::serviceCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& service, bool sia2045 ) const
{
QDomElement propertiesElement = propertiesElem();
if ( propertiesElement.isNull() )
{
QgsConfigParserUtils::fallbackServiceCapabilities( parentElement, doc );
return;
}
QDomElement serviceElem = doc.createElement( "Service" );
QDomElement serviceCapabilityElem = propertiesElement.firstChildElement( "WMSServiceCapabilities" );
if ( serviceCapabilityElem.isNull() || serviceCapabilityElem.text().compare( "true", Qt::CaseInsensitive ) != 0 )
{
QgsConfigParserUtils::fallbackServiceCapabilities( parentElement, doc );
return;
}
//Service name
QDomElement wmsNameElem = doc.createElement( "Name" );
QDomText wmsNameText = doc.createTextNode( service );
wmsNameElem.appendChild( wmsNameText );
serviceElem.appendChild( wmsNameElem );
//WMS title
//why not use project title ?
QDomElement titleElem = propertiesElement.firstChildElement( "WMSServiceTitle" );
if ( !titleElem.isNull() )
{
QDomElement wmsTitleElem = doc.createElement( "Title" );
QDomText wmsTitleText = doc.createTextNode( titleElem.text() );
wmsTitleElem.appendChild( wmsTitleText );
serviceElem.appendChild( wmsTitleElem );
}
//WMS abstract
QDomElement abstractElem = propertiesElement.firstChildElement( "WMSServiceAbstract" );
if ( !abstractElem.isNull() )
{
QDomElement wmsAbstractElem = doc.createElement( "Abstract" );
QDomText wmsAbstractText = doc.createTextNode( abstractElem.text() );
wmsAbstractElem.appendChild( wmsAbstractText );
serviceElem.appendChild( wmsAbstractElem );
}
//keyword list
QDomElement keywordListElem = propertiesElement.firstChildElement( "WMSKeywordList" );
if ( service.compare( "WMS", Qt::CaseInsensitive ) == 0 )
{
QDomElement wmsKeywordElem = doc.createElement( "KeywordList" );
//add default keyword
QDomElement keywordElem = doc.createElement( "Keyword" );
keywordElem.setAttribute( "vocabulary", "ISO" );
QDomText keywordText = doc.createTextNode( "infoMapAccessService" );
/* If WFS and WCS 2.0 is implemented
if ( service.compare( "WFS", Qt::CaseInsensitive ) == 0 )
keywordText = doc.createTextNode( "infoFeatureAccessService" );
else if ( service.compare( "WCS", Qt::CaseInsensitive ) == 0 )
keywordText = doc.createTextNode( "infoCoverageAccessService" );*/
keywordElem.appendChild( keywordText );
wmsKeywordElem.appendChild( keywordElem );
serviceElem.appendChild( wmsKeywordElem );
//add config keywords
if ( !keywordListElem.isNull() && !keywordListElem.text().isEmpty() )
{
QDomNodeList keywordList = keywordListElem.elementsByTagName( "value" );
for ( int i = 0; i < keywordList.size(); ++i )
{
keywordElem = doc.createElement( "Keyword" );
keywordText = doc.createTextNode( keywordList.at( i ).toElement().text() );
keywordElem.appendChild( keywordText );
if ( sia2045 )
{
keywordElem.setAttribute( "vocabulary", "SIA_Geo405" );
}
wmsKeywordElem.appendChild( keywordElem );
}
}
}
else if ( !keywordListElem.isNull() && !keywordListElem.text().isEmpty() )
{
QDomNodeList keywordNodeList = keywordListElem.elementsByTagName( "value" );
QStringList keywordList;
for ( int i = 0; i < keywordNodeList.size(); ++i )
{
keywordList.push_back( keywordNodeList.at( i ).toElement().text() );
}
QDomElement wmsKeywordElem = doc.createElement( "Keywords" );
if ( service.compare( "WCS", Qt::CaseInsensitive ) == 0 )
wmsKeywordElem = doc.createElement( "keywords" );
QDomText keywordText = doc.createTextNode( keywordList.join( ", " ) );
wmsKeywordElem.appendChild( keywordText );
serviceElem.appendChild( wmsKeywordElem );
}
//OnlineResource element is mandatory according to the WMS specification
QDomElement wmsOnlineResourceElem = propertiesElement.firstChildElement( "WMSOnlineResource" );
if ( !wmsOnlineResourceElem.isNull() )
{
QDomElement onlineResourceElem = doc.createElement( "OnlineResource" );
if ( service.compare( "WFS", Qt::CaseInsensitive ) == 0 )
//.........这里部分代码省略.........
示例11: addXMLStationNode
/**
* Adds a QDomElement for the station to the element stationsElements (it will have the tags station)
* @param doc XML Document
* @param stationsElement
*/
void NMGStation::addXMLStationNode( QDomDocument& doc, QDomElement& stationsElement )
{
QDomElement element = doc.createElement( TAG_STATION );
stationsElement.appendChild( element );
/* test host info */
QDomElement test = doc.createElement( TAG_STATION_TEST );
element.appendChild( test );
QDomElement testAddr = doc.createElement( TAG_STATION_ADDRESS );
test.appendChild( testAddr );
QDomText testAddrText = doc.createTextNode( getTestHost().getAddress() );
testAddr.appendChild( testAddrText );
if ( !getTestHost().getAlias().isEmpty() )
{
QDomElement testAlias = doc.createElement( TAG_STATION_ALIAS );
test.appendChild( testAlias );
QDomText testAliasText = doc.createTextNode( getTestHost().getAlias() );
testAlias.appendChild( testAliasText );
}
QDomElement testProtocol = doc.createElement( TAG_STATION_PROTOCOL );
test.appendChild( testProtocol );
QDomText testProtocolText = doc.createTextNode( getTestHost().isHostIPv4() ? STATION_PROTOCOL_IPV4 : STATION_PROTOCOL_IPV6 );
testProtocol.appendChild( testProtocolText );
/* management host info */
QDomElement management = doc.createElement( TAG_STATION_MANAGEMENT );
element.appendChild( management );
QDomElement managementAddr = doc.createElement( TAG_STATION_ADDRESS );
management.appendChild( managementAddr );
QDomText managementAddrText = doc.createTextNode( getManagementHost().getAddress() );
managementAddr.appendChild( managementAddrText );
QDomElement managementPort = doc.createElement( TAG_STATION_PORT );
management.appendChild( managementPort );
QDomText managementPortText = doc.createTextNode( QString::number(getManagementAddressPort()) );
managementPort.appendChild( managementPortText );
if ( !getManagementHost().getAlias().isEmpty() )
{
QDomElement managementAlias = doc.createElement( TAG_STATION_ALIAS );
management.appendChild( managementAlias );
QDomText managementAliasText = doc.createTextNode( getManagementHost().getAlias() );
managementAlias.appendChild( managementAliasText );
}
QDomElement managementProtocol = doc.createElement( TAG_STATION_PROTOCOL );
management.appendChild( managementProtocol );
QDomText managementProtocolText = doc.createTextNode( getManagementHost().isHostIPv4() ? STATION_PROTOCOL_IPV4 : STATION_PROTOCOL_IPV6 );
managementProtocol.appendChild( managementProtocolText );
QDomElement username = doc.createElement( TAG_STATION_USERNAME );
management.appendChild( username );
QDomText usernameText = doc.createTextNode( getManagementUsername() );
username.appendChild( usernameText );
////B64 encrypted password!!!
QDomElement password = doc.createElement( TAG_STATION_PASSWORD );
management.appendChild( password );
//QDomText passwordText = doc.createTextNode ( getManagementPassword() );
QByteArray b64pass (managementPassword.toUtf8());
QDomText passwordText = doc.createTextNode ( QString(b64pass.toBase64()) );
password.appendChild( passwordText );
/* Save fields to XML */
stationFieldsManager.addFieldNodetoXML( doc, element );
}
示例12: processPluginParams
void FlpImport::processPluginParams( FL_Channel * _ch )
{
qDebug( "plugin params for plugin %d (%d bytes): ", _ch->pluginType,
_ch->pluginSettingsLength );
dump_mem( _ch->pluginSettings, _ch->pluginSettingsLength );
switch( _ch->pluginType )
{
case FL_Plugin::Sampler: // AudioFileProcessor loaded
{
QDomDocument dd;
QDomElement de = dd.createElement(
_ch->instrumentPlugin->nodeName() );
de.setAttribute( "reversed", _ch->sampleReversed );
de.setAttribute( "amp", _ch->sampleAmp );
de.setAttribute( "looped", _ch->sampleUseLoopPoints );
de.setAttribute( "sframe", 0 );
de.setAttribute( "eframe", 1 );
de.setAttribute( "src", _ch->sampleFileName );
_ch->instrumentPlugin->restoreState( de );
break;
}
case FL_Plugin::TS404: // LB302 loaded
break;
case FL_Plugin::Fruity_3x_Osc: // TripleOscillator loaded
{
const Oscillator::WaveShapes mapped_3xOsc_Shapes[] =
{
Oscillator::SineWave,
Oscillator::TriangleWave,
Oscillator::SquareWave,
Oscillator::SawWave,
Oscillator::SquareWave, // square-sin
Oscillator::WhiteNoise,
Oscillator::UserDefinedWave
} ;
QDomDocument dd;
QDomElement de = dd.createElement(
_ch->instrumentPlugin->nodeName() );
de.setAttribute( "modalgo1", Oscillator::SignalMix );
de.setAttribute( "modalgo2", Oscillator::SignalMix );
int ws = Oscillator::UserDefinedWave;
for( int i = 0; i < 3; ++i )
{
const int32_t * d = (const int32_t *)
( _ch->pluginSettings + i * 28 );
QString is = QString::number( i );
de.setAttribute( "vol" + is,
QString::number( d[0] * 100 /
( 3 * 128 ) ) );
de.setAttribute( "pan" + is,
QString::number( d[1] ) );
de.setAttribute( "coarse" + is,
QString::number( d[3] ) );
de.setAttribute( "finel" + is,
QString::number( d[4] - d[6] / 2 ) );
de.setAttribute( "finer" + is,
QString::number( d[4] + d[6] / 2 ) );
de.setAttribute( "stphdetun" + is,
QString::number( d[5] ) );
const int s = mapped_3xOsc_Shapes[d[2]];
de.setAttribute( "wavetype" + is,
QString::number( s ) );
if( s != Oscillator::UserDefinedWave )
{
ws = s;
}
}
if( ws == Oscillator::UserDefinedWave )
{
de.setAttribute( "wavetype0",
Oscillator::SawWave );
}
de.setAttribute( "vol0", QString::number( 100/2 ) );
// now apply the prepared plugin-state
_ch->instrumentPlugin->restoreState( de );
break;
}
case FL_Plugin::Layer:
// nothing to do
break;
case FL_Plugin::Plucked: // Vibed loaded
// TODO: setup vibed-instrument
break;
case FL_Plugin::UnknownPlugin:
default:
qDebug( "handling of plugin params not implemented "
"for current plugin\n" );
break;
}
}
示例13: save
void Doc_Test::save()
{
Scene* s = new Scene(m_doc);
m_doc->addFunction(s);
Fixture* f1 = new Fixture(m_doc);
f1->setName("One");
f1->setChannels(5);
f1->setAddress(0);
f1->setUniverse(0);
m_doc->addFixture(f1);
Chaser* c = new Chaser(m_doc);
m_doc->addFunction(c);
Fixture* f2 = new Fixture(m_doc);
f2->setName("Two");
f2->setChannels(10);
f2->setAddress(20);
f2->setUniverse(1);
m_doc->addFixture(f2);
Collection* o = new Collection(m_doc);
m_doc->addFunction(o);
Fixture* f3 = new Fixture(m_doc);
f3->setName("Three");
f3->setChannels(15);
f3->setAddress(40);
f3->setUniverse(2);
m_doc->addFixture(f3);
EFX* e = new EFX(m_doc);
m_doc->addFunction(e);
FixtureGroup* grp = new FixtureGroup(m_doc);
grp->setName("Group 1");
m_doc->addFixtureGroup(grp);
grp = new FixtureGroup(m_doc);
grp->setName("Group 2");
m_doc->addFixtureGroup(grp);
QVERIFY(m_doc->isModified() == true);
QDomDocument document;
QDomElement root = document.createElement("TestRoot");
QVERIFY(m_doc->saveXML(&document, &root) == true);
uint fixtures = 0, groups = 0, functions = 0;
QDomNode node = root.firstChild();
QVERIFY(node.toElement().tagName() == "Engine");
// Merely tests that the start of each hierarchy is found from the XML document.
// Their contents are tested individually in their own separate tests.
node = node.firstChild();
while (node.isNull() == false)
{
QDomElement tag = node.toElement();
if (tag.tagName() == "Fixture")
fixtures++;
else if (tag.tagName() == "Function")
functions++;
else if (tag.tagName() == "FixtureGroup")
groups++;
else if (tag.tagName() == "Bus")
QFAIL("Bus tags should not be saved anymore!");
else
QFAIL(QString("Unexpected tag: %1")
.arg(tag.tagName()).toLatin1());
node = node.nextSibling();
}
QVERIFY(fixtures == 3);
QVERIFY(groups == 2);
QVERIFY(functions == 4);
/* Saving doesn't implicitly reset modified status */
QVERIFY(m_doc->isModified() == true);
}
示例14: toXml
QDomElement MaiaObject::toXml(QVariant arg) {
//dummy document
QDomDocument doc;
//value element, we need this in each case
QDomElement tagValue = doc.createElement("value");
switch(arg.type()) {
case QVariant::String: {
QDomElement tagString = doc.createElement("string");
QDomText textString = doc.createTextNode(arg.toString());
tagValue.appendChild(tagString);
tagString.appendChild(textString);
return tagString;
} case QVariant::Int: {
QDomElement tagInt = doc.createElement("int");
QDomText textInt = doc.createTextNode(QString::number(arg.toInt()));
tagValue.appendChild(tagInt);
tagInt.appendChild(textInt);
return tagValue;
} case QVariant::Double: {
QDomElement tagDouble = doc.createElement("double");
QDomText textDouble = doc.createTextNode(QString::number(arg.toDouble()));
tagValue.appendChild(tagDouble);
tagDouble.appendChild(textDouble);
return tagValue;
} case QVariant::Bool: {
QString textValue = arg.toBool() ? "1" : "0";
QDomElement tag = doc.createElement("boolean");
QDomText text = doc.createTextNode(textValue);
tagValue.appendChild(tag);
tag.appendChild(text);
return tagValue;
} case QVariant::ByteArray: {
QString textValue = arg.toByteArray().toBase64();
QDomElement tag = doc.createElement("base64");
QDomText text = doc.createTextNode(textValue);
tagValue.appendChild(tag);
tag.appendChild(text);
return tagValue;
} case QVariant::DateTime: {
QString textValue = arg.toDateTime().toString("yyyyMMddThh:mm:ss");
QDomElement tag = doc.createElement("datetime.iso8601");
QDomText text = doc.createTextNode(textValue);
tagValue.appendChild(tag);
tag.appendChild(text);
return tagValue;
} case QVariant::List: {
QDomElement tagArray = doc.createElement("array");
QDomElement tagData = doc.createElement("data");
tagArray.appendChild(tagData);
tagValue.appendChild(tagArray);
const QList<QVariant> args = arg.toList();
for(int i = 0; i < args.size(); ++i) {
tagData.appendChild(toXml(args.at(i)));
}
return tagValue;
} case QVariant::Map: {
QDomElement tagStruct = doc.createElement("struct");
QDomElement member;
QDomElement name;
tagValue.appendChild(tagStruct);
QMap<QString, QVariant> map = arg.toMap();
QMapIterator<QString, QVariant> i(map);
while(i.hasNext()) {
i.next();
//.........这里部分代码省略.........
示例15:
//! [0]
QDomDocument doc;
QDomImplementation impl;
// This will create the element, but the resulting XML document will
// be invalid, because '~' is not a valid character in a tag name.
impl.setInvalidDataPolicy(QDomImplementation::AcceptInvalidData);
QDomElement elt1 = doc.createElement("foo~bar");
// This will create an element with the tag name "foobar".
impl.setInvalidDataPolicy(QDomImplementation::DropInvalidData);
QDomElement elt2 = doc.createElement("foo~bar");
// This will create a null element.
impl.setInvalidDataPolicy(QDomImplementation::ReturnNullNode);
QDomElement elt3 = doc.createElement("foo~bar");
//! [0]
//! [1]
QDomDocument d;
d.setContent(someXML);
QDomNode n = d.firstChild();
while (!n.isNull()) {
if (n.isElement()) {
QDomElement e = n.toElement();
cout << "Element name: " << e.tagName() << endl;
break;
}
n = n.nextSibling();
}