本文整理汇总了C++中QDomElement::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::setAttribute方法的具体用法?C++ QDomElement::setAttribute怎么用?C++ QDomElement::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeXML
bool QgsSymbol::writeXML( QDomNode & item, QDomDocument & document, const QgsVectorLayer *vl ) const
{
bool returnval = false;
returnval = true; // no error checking yet
QDomElement symbol = document.createElement( "symbol" );
item.appendChild( symbol );
appendText( symbol, document, "lowervalue", mLowerValue );
appendText( symbol, document, "uppervalue", mUpperValue );
appendText( symbol, document, "label", mLabel );
QString name = pointSymbolName();
if ( name.startsWith( "svg:" ) )
{
name = name.mid( 4 );
QFileInfo fi( name );
if ( fi.exists() )
{
name = fi.canonicalFilePath();
QStringList svgPaths = QgsApplication::svgPaths();
for ( int i = 0; i < svgPaths.size(); i++ )
{
QString dir = QFileInfo( svgPaths[i] ).canonicalFilePath();
if ( !dir.isEmpty() && name.startsWith( dir ) )
{
name = name.mid( dir.size() );
break;
}
}
}
name = "svg:" + name;
}
appendText( symbol, document, "pointsymbol", name );
appendText( symbol, document, "pointsize", QString::number( pointSize() ) );
appendText( symbol, document, "pointsizeunits", pointSizeUnits() ? "mapunits" : "pixels" );
if ( vl )
{
appendField( symbol, document, *vl, "rotationclassificationfieldname", mRotationClassificationField );
appendField( symbol, document, *vl, "scaleclassificationfieldname", mScaleClassificationField );
appendField( symbol, document, *vl, "symbolfieldname", mSymbolField );
}
QDomElement outlinecolor = document.createElement( "outlinecolor" );
outlinecolor.setAttribute( "red", QString::number( mPen.color().red() ) );
outlinecolor.setAttribute( "green", QString::number( mPen.color().green() ) );
outlinecolor.setAttribute( "blue", QString::number( mPen.color().blue() ) );
symbol.appendChild( outlinecolor );
appendText( symbol, document, "outlinestyle", QgsSymbologyUtils::penStyle2QString( mPen.style() ) );
appendText( symbol, document, "outlinewidth", QString::number( mPen.widthF() ) );
QDomElement fillcolor = document.createElement( "fillcolor" );
fillcolor.setAttribute( "red", QString::number( mBrush.color().red() ) );
fillcolor.setAttribute( "green", QString::number( mBrush.color().green() ) );
fillcolor.setAttribute( "blue", QString::number( mBrush.color().blue() ) );
symbol.appendChild( fillcolor );
appendText( symbol, document, "fillpattern", QgsSymbologyUtils::brushStyle2QString( mBrush.style() ) );
appendText( symbol, document, "texturepath", QgsProject::instance()->writePath( mTextureFilePath ) );
return returnval;
}
示例2: buildXML
void ORGraphicsSectionDetail::buildXML(QDomDocument & doc, QDomElement & section)
{
// name/title
QDomElement name = doc.createElement("name");
name.appendChild(doc.createTextNode(getTitle()));
section.appendChild(name);
if(pageBreak() != ORGraphicsSectionDetail::BreakNone)
{
QDomElement spagebreak = doc.createElement("pagebreak");
if(pageBreak() == ORGraphicsSectionDetail::BreakAtEnd)
spagebreak.setAttribute("when", "at end");
section.appendChild(spagebreak);
}
for(int i = 0; i < groupList.count(); i++)
{
ORGraphicsSectionDetailGroup * rsdg = groupList.at(i);
QDomNode grp = doc.createElement("group");
QDomNode gname = doc.createElement("name");
gname.appendChild(doc.createTextNode(rsdg->getTitle()));
grp.appendChild(gname);
QDomNode gcol = doc.createElement("column");
gcol.appendChild(doc.createTextNode(rsdg->column()));
grp.appendChild(gcol);
if(rsdg->pageBreak() != ORGraphicsSectionDetailGroup::BreakNone)
{
QDomElement pagebreak = doc.createElement("pagebreak");
if(rsdg->pageBreak() == ORGraphicsSectionDetailGroup::BreakAfterGroupFooter)
pagebreak.setAttribute("when", "after foot");
grp.appendChild(pagebreak);
}
//group head
if(rsdg->isGroupHeadShowing())
{
QDomElement ghead = doc.createElement("head");
rsdg->getGroupHead()->buildXML(doc,ghead);
grp.appendChild(ghead);
}
// group foot
if(rsdg->isGroupFootShowing())
{
QDomElement gfoot = doc.createElement("foot");
rsdg->getGroupFoot()->buildXML(doc,gfoot);
grp.appendChild(gfoot);
}
section.appendChild(grp);
}
// detail section
QDomElement gdetail = doc.createElement("detail");
QDomElement key = doc.createElement("key");
QDomElement kquery = doc.createElement("query");
kquery.appendChild(doc.createTextNode(query()));
key.appendChild(kquery);
gdetail.appendChild(key);
_detail->buildXML(doc,gdetail);
section.appendChild(gdetail);
}
示例3: saveToXml
QByteArray WeeklyTimesheetXmlWriter::saveToXml() const
{
// now create the report:
QDomDocument document = XmlSerialization::createXmlTemplate( "weekly-timesheet" );
// find metadata and report element:
QDomElement root = document.documentElement();
QDomElement metadata = XmlSerialization::metadataElement( document );
QDomElement charmVersion = document.createElement( "charmversion" );
QDomText charmVersionString = document.createTextNode( CHARM_VERSION );
charmVersion.appendChild( charmVersionString );
metadata.appendChild( charmVersion );
QDomElement report = XmlSerialization::reportElement( document );
Q_ASSERT( !root.isNull() && !metadata.isNull() && !report.isNull() );
// extend metadata tag: add year, and serial (week) number:
{
QDomElement yearElement = document.createElement( "year" );
metadata.appendChild( yearElement );
QDomText text = document.createTextNode( QString::number( m_year ) );
yearElement.appendChild( text );
QDomElement weekElement = document.createElement( "serial-number" );
weekElement.setAttribute( "semantics", "week-number" );
metadata.appendChild( weekElement );
QDomText weektext = document.createTextNode( QString::number( m_weekNumber ) );
weekElement.appendChild( weektext );
}
typedef QMap< TaskId, QVector<int> > SecondsMap;
SecondsMap secondsMap;
TimeSheetInfoList timeSheetInfo = TimeSheetInfo::filteredTaskWithSubTasks(
TimeSheetInfo::taskWithSubTasks( m_dataModel, DaysInWeek, m_rootTask, secondsMap ),
false ); // here, we don't care about active or not, because we only report on the tasks
// extend report tag: add tasks and effort structure
{ // tasks
QDomElement tasks = document.createElement( "tasks" );
report.appendChild( tasks );
Q_FOREACH ( const TimeSheetInfo& info, timeSheetInfo ) {
if ( info.taskId == 0 ) // the root task
continue;
const Task& modelTask = m_dataModel->getTask( info.taskId );
tasks.appendChild( modelTask.toXml( document ) );
// TaskId parentTask = DATAMODEL->parentItem( modelTask ).task().id();
// QDomElement task = document.createElement( "task" );
// task.setAttribute( "taskid", QString::number( info.taskId ) );
// if ( parentTask != 0 )
// task.setAttribute( "parent", QString::number( parentTask ) );
// QDomText name = document.createTextNode( modelTask.name() );
// task.appendChild( name );
// tasks.appendChild( task );
}
}
{ // effort
// make effort element:
QDomElement effort = document.createElement( "effort" );
report.appendChild( effort );
// aggregate (group by task and day):
typedef QPair<TaskId, QDate> Key;
QMap< Key, Event> events;
Q_FOREACH ( const Event& event, m_events ) {
TimeSheetInfoList::iterator it;
for ( it = timeSheetInfo.begin(); it != timeSheetInfo.end(); ++it )
if ( ( *it ).taskId == event.taskId() ) break;
if ( it == timeSheetInfo.end() )
continue;
Key key( event.taskId(), event.startDateTime().date() );
if ( events.contains( key ) ) {
// add to previous events:
const Event& oldEvent = events[key];
const int seconds = oldEvent.duration() + event.duration();
const QDateTime start = oldEvent.startDateTime();
const QDateTime end( start.addSecs( seconds ) );
Q_ASSERT( start.secsTo( end ) == seconds );
Event newEvent( oldEvent );
newEvent.setStartDateTime( start );
newEvent.setEndDateTime( end );
Q_ASSERT( newEvent.duration() == seconds );
QString comment = oldEvent.comment();
if ( ! event.comment().isEmpty() ) {
if ( !comment.isEmpty() ) { // make separator
comment += " / ";
}
comment += event.comment();
newEvent.setComment( comment );
}
events[key] = newEvent;
} else {
// add this event:
events[key] = event;
events[key].setId( -events[key].id() ); // "synthetic" :-)
// move to start at midnight in UTC (for privacy reasons)
// never, never, never use setTime() here, it breaks on DST changes! (twice a year)
QDateTime start( event.startDateTime().date(), QTime(0, 0, 0, 0), Qt::UTC );
QDateTime end( start.addSecs( event.duration() ) );
events[key].setStartDateTime( start );
events[key].setEndDateTime( end );
//.........这里部分代码省略.........
示例4: replaceElemParams
void QgsSvgCache::replaceElemParams( QDomElement& elem, const QColor& fill, const QColor& outline, double outlineWidth )
{
if ( elem.isNull() )
{
return;
}
//go through attributes
QDomNamedNodeMap attributes = elem.attributes();
int nAttributes = attributes.count();
for ( int i = 0; i < nAttributes; ++i )
{
QDomAttr attribute = attributes.item( i ).toAttr();
//e.g. style="fill:param(fill);param(stroke)"
if ( attribute.name().compare( QLatin1String( "style" ), Qt::CaseInsensitive ) == 0 )
{
//entries separated by ';'
QString newAttributeString;
QStringList entryList = attribute.value().split( ';' );
QStringList::const_iterator entryIt = entryList.constBegin();
for ( ; entryIt != entryList.constEnd(); ++entryIt )
{
QStringList keyValueSplit = entryIt->split( ':' );
if ( keyValueSplit.size() < 2 )
{
continue;
}
QString key = keyValueSplit.at( 0 );
QString value = keyValueSplit.at( 1 );
if ( value.startsWith( QLatin1String( "param(fill)" ) ) )
{
value = fill.name();
}
else if ( value.startsWith( QLatin1String( "param(fill-opacity)" ) ) )
{
value = fill.alphaF();
}
else if ( value.startsWith( QLatin1String( "param(outline)" ) ) )
{
value = outline.name();
}
else if ( value.startsWith( QLatin1String( "param(outline-opacity)" ) ) )
{
value = outline.alphaF();
}
else if ( value.startsWith( QLatin1String( "param(outline-width)" ) ) )
{
value = QString::number( outlineWidth );
}
if ( entryIt != entryList.constBegin() )
{
newAttributeString.append( ';' );
}
newAttributeString.append( key + ':' + value );
}
elem.setAttribute( attribute.name(), newAttributeString );
}
else
{
QString value = attribute.value();
if ( value.startsWith( QLatin1String( "param(fill)" ) ) )
{
elem.setAttribute( attribute.name(), fill.name() );
}
else if ( value.startsWith( QLatin1String( "param(fill-opacity)" ) ) )
{
elem.setAttribute( attribute.name(), fill.alphaF() );
}
else if ( value.startsWith( QLatin1String( "param(outline)" ) ) )
{
elem.setAttribute( attribute.name(), outline.name() );
}
else if ( value.startsWith( QLatin1String( "param(outline-opacity)" ) ) )
{
elem.setAttribute( attribute.name(), outline.alphaF() );
}
else if ( value.startsWith( QLatin1String( "param(outline-width)" ) ) )
{
elem.setAttribute( attribute.name(), QString::number( outlineWidth ) );
}
}
}
QDomNodeList childList = elem.childNodes();
int nChildren = childList.count();
for ( int i = 0; i < nChildren; ++i )
{
QDomElement childElem = childList.at( i ).toElement();
replaceElemParams( childElem, fill, outline, outlineWidth );
}
}
示例5: run
void XdgMenuLayoutProcessor::run()
{
QDomDocument doc = mLayout.ownerDocument();
mResult = doc.createElement(QLatin1String("Result"));
mElement.appendChild(mResult);
// Process childs menus ...............................
{
DomElementIterator it(mElement, QLatin1String("Menu"));
while (it.hasNext())
{
QDomElement e = it.next();
XdgMenuLayoutProcessor p(e, this);
p.run();
}
}
// Step 1 ...................................
DomElementIterator it(mLayout);
it.toFront();
while (it.hasNext())
{
QDomElement e = it.next();
if (e.tagName() == QLatin1String("Filename"))
processFilenameTag(e);
else if (e.tagName() == QLatin1String("Menuname"))
processMenunameTag(e);
else if (e.tagName() == QLatin1String("Separator"))
processSeparatorTag(e);
else if (e.tagName() == QLatin1String("Merge"))
{
QDomElement merge = mResult.ownerDocument().createElement(QLatin1String("Merge"));
merge.setAttribute(QLatin1String("type"), e.attribute(QLatin1String("type")));
mResult.appendChild(merge);
}
}
// Step 2 ...................................
{
MutableDomElementIterator ri(mResult, QLatin1String("Merge"));
while (ri.hasNext())
{
processMergeTag(ri.next());
}
}
// Move result cilds to element .............
MutableDomElementIterator ri(mResult);
while (ri.hasNext())
{
mElement.appendChild(ri.next());
}
// Final ....................................
mElement.removeChild(mResult);
if (mLayout.parentNode() == mElement)
mElement.removeChild(mLayout);
if (mDefaultLayout.parentNode() == mElement)
mElement.removeChild(mDefaultLayout);
}
示例6: f
cmenu::cmenu(QString filename,bool *success)
{
menusDoc=new QDomDocument("swim_menu");
QFile f( filename );
if ( !f.open( IO_ReadOnly ) )
{
*success=false;
cout<<filename<<" not found"<<endl;
return;
}
QString errorMsg;
int errorLine, errorColumn;
if ( !menusDoc->setContent( &f, false, &errorMsg,&errorLine,&errorColumn ) )
{
f.close();
cout<<"Error while parsing menu :"<<endl<<errorMsg<<", Line: "<<errorLine<<" ,Column: "<<errorColumn<<endl;
*success=false;
return;
}
f.close();
*success=true;
//root element
QDomElement docElem = menusDoc->documentElement();
// assigning global configuration
QDomNode globalNode = docElem.firstChild();
if((!globalNode.isNull())&&(globalNode.nodeName().compare("global_config")==0))
{
QDomElement globalElement=globalNode.toElement();
defaultImage=globalElement.attribute("defaultimage");
defaultDir=globalElement.attribute("defaultdir","ltr");
docsPath=globalElement.attribute("docspath","");
imagePath=globalElement.attribute("imagepath","");
firstPage=globalElement.attribute("firstpage");
if (docsPath[docsPath.length()-1]!='/') docsPath.append('/');
if (imagePath[imagePath.length()-1]!='/') imagePath.append('/');
}
// expanding the tree (add the plays to the menus level, because of the images problem)
QDomNode menuNode = docElem.firstChild();
while( !menuNode.isNull() )
{
if((menuNode.nodeName().compare("menu")==0)&&(menuNode.isElement()))
{
// if no firstpage defined, take the first menu you see.
if (firstPage.isNull()) firstPage=menuNode.toElement().attribute("name");
QDomNode linkNode=menuNode.firstChild();
QDomElement linkElem;
while(!linkNode.isNull())
{
linkElem=linkNode.toElement();
if ((!linkElem.isNull()) && (linkElem.tagName().compare("link")==0) && (linkElem.attribute("type","menu").compare("play")==0))
{
QDomElement append = menusDoc->createElement("play");
append.setAttribute("name",linkElem.attribute("name"));
if (!linkElem.attribute("image").isNull()) append.setAttribute("image", linkElem.attribute("image"));
// add this to the menus level.
docElem.appendChild( append );
}
linkNode = linkNode.nextSibling();
}
}
menuNode = menuNode.nextSibling();
}
}
示例7: QDomDocument
KWDWriter::KWDWriter(KOdfStore *store)
{
_store = store;
_doc = new QDomDocument("DOC");
_docinfo = new QDomDocument("document-info");
_doc->appendChild(_doc->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
_docinfo->appendChild(_docinfo->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
QDomElement infodoc = _docinfo->createElement("document-info");
_docinfoMain = infodoc;
_docinfo->appendChild(infodoc);
tableNo = 1;
insidetable = false;
QDomElement kwdoc = _doc->createElement("DOC");
kwdoc.setAttribute("editor", "HTML Import Filter");
kwdoc.setAttribute("mime", "application/x-kword");
_doc->appendChild(kwdoc);
QDomElement paper = _doc->createElement("PAPER");
kwdoc.appendChild(paper);
paper.setAttribute("format", 1);
paper.setAttribute("width", 595);
paper.setAttribute("height", 841);
paper.setAttribute("orientation", 0);
paper.setAttribute("columns", 1);
paper.setAttribute("columnspacing", 3);
paper.setAttribute("hType", 0);
paper.setAttribute("fType", 0);
QDomElement borders = _doc->createElement("PAPERBORDERS");
paper.appendChild(borders);
borders.setAttribute("left", 20);
borders.setAttribute("top", 10);
borders.setAttribute("right", 10);
borders.setAttribute("bottom", 10);
QDomElement docattrs = _doc->createElement("ATTRIBUTES");
kwdoc.appendChild(docattrs);
docattrs.setAttribute("processing", 0);
docattrs.setAttribute("standardpage", 1);
docattrs.setAttribute("hasHeader", 0);
docattrs.setAttribute("hasFooter", 0);
//docattrs.setAttribute( "unit", "mm" ); // use KWord default instead
QDomElement framesets = _doc->createElement("FRAMESETS");
kwdoc.appendChild(framesets);
QDomElement rootframeset = addFrameSet(framesets);
_mainFrameset = rootframeset;
QDomElement mainframe = addFrame(rootframeset, QRect(28, 28, 539, 757));
QDomElement styles = _doc->createElement("STYLES");
kwdoc.appendChild(styles);
QDomElement standard = _doc->createElement("STYLE");
styles.appendChild(standard);
QDomElement tmp;
tmp = _doc->createElement("NAME");
tmp.setAttribute("value", "Standard");
standard.appendChild(tmp);
tmp = _doc->createElement("FOLLOWING");
tmp.setAttribute("name", "Standard");
standard.appendChild(tmp);
QDomElement fmt;
fmt = _doc->createElement("FORMAT");
fmt.setAttribute("id", "1");
standard.appendChild(fmt);
tmp = _doc->createElement("SIZE");
tmp.setAttribute("value", "12"); // HACK !
fmt.appendChild(tmp);
#define HEADINGSTYLE(a,b) standard=_doc->createElement("STYLE");\
styles.appendChild(standard);\
tmp=_doc->createElement("NAME");\
tmp.setAttribute("value",#a);\
standard.appendChild(tmp);\
tmp=_doc->createElement("FOLLOWING");\
tmp.setAttribute("name","Standard");\
standard.appendChild(tmp);\
fmt=_doc->createElement("FORMAT");\
fmt.setAttribute("id","1");\
standard.appendChild(fmt);\
tmp=_doc->createElement("SIZE");\
tmp.setAttribute("value",#b);\
fmt.appendChild(tmp);
HEADINGSTYLE(h1, 20);
HEADINGSTYLE(h2, 18);
HEADINGSTYLE(h3, 16);
HEADINGSTYLE(h4, 14);
HEADINGSTYLE(h5, 10);
HEADINGSTYLE(h6, 8);
//.........这里部分代码省略.........
示例8: createElement
//-----------------------
//读取文件创建元素
QDomElement FilterParameter::createElement(QDomDocument &doc)
{
QDomElement parElem = doc.createElement("Param");
parElem.setAttribute("name",this->fieldName);
switch (this->fieldType)
{
case FilterParameter::PARBOOL:
parElem.setAttribute("type","Bool");
parElem.setAttribute("value",this->fieldVal.toString());
break;
case FilterParameter::PARSTRING:
parElem.setAttribute("type","String");
parElem.setAttribute("value",this->fieldVal.toString());
break;
case FilterParameter::PARINT:
parElem.setAttribute("type","Int");
parElem.setAttribute("value",this->fieldVal.toInt());
break;
case FilterParameter::PARFLOAT:
parElem.setAttribute("type","Float");
parElem.setAttribute("value",this->fieldVal.toString());
break;
case FilterParameter::PARABSPERC:
parElem.setAttribute("type","AbsPerc");
parElem.setAttribute("value",this->fieldVal.toString());
parElem.setAttribute("min",QString::number(this->min));
parElem.setAttribute("max",QString::number(this->max));
break;
case FilterParameter::PARCOLOR:
parElem.setAttribute("type","Color");
parElem.setAttribute("rgb",this->fieldVal.toString());
break;
case FilterParameter::PARENUM:
{
parElem.setAttribute("type","Enum");
parElem.setAttribute("value",this->fieldVal.toString());
QStringList::iterator kk;
for(kk = this->enumValues.begin();kk!=this->enumValues.end();++kk){
QDomElement sElem = doc.createElement("EnumString");
sElem.setAttribute("value",(*kk));
parElem.appendChild(sElem);
}
}
break;
case FilterParameter::PARMATRIX:
{
parElem.setAttribute("type","Matrix44");
QList<QVariant> matrixVals = this->fieldVal.toList();
for(int i=0;i<16;++i)
parElem.setAttribute(QString("val")+QString::number(i),matrixVals[i].toString());
}
break;
case FilterParameter::PARMESH:
parElem.setAttribute(TypeName(), MeshPointerName());
//this is the mesh's position in the mesh document that was used
parElem.setAttribute(ValueName(),(this->fieldVal.toString()));
break;
case FilterParameter::PARFLOATLIST:
{
parElem.setAttribute(TypeName(), FloatListName());
QList<QVariant> values = this->fieldVal.toList();
for(int i=0; i < values.size(); ++i)
{
QDomElement listElement = doc.createElement(ItemName());
listElement.setAttribute(ValueName(), values[i].toString());
parElem.appendChild(listElement);
}
}
break;
case FilterParameter::PARDYNFLOAT:
parElem.setAttribute(TypeName(), DynamicFloatName());
parElem.setAttribute(ValueName(), this->fieldVal.toString());
parElem.setAttribute(MinName(), QString::number(this->min));
parElem.setAttribute(MaxName(), QString::number(this->max));
parElem.setAttribute(MaskName(),QString::number(this->mask));
break;
case FilterParameter::PAROPENFILENAME:
parElem.setAttribute(TypeName(), OpenFileNameName());
parElem.setAttribute(ValueName(), this->fieldVal.toString());
break;
case FilterParameter::PARSAVEFILENAME:
parElem.setAttribute(TypeName(), SaveFileNameName());
parElem.setAttribute(ValueName(), this->fieldVal.toString());
break;
case FilterParameter::PARPOINT3F:
{
QList<QVariant> pointVals = this->fieldVal.toList();
parElem.setAttribute("type","Point3f");
parElem.setAttribute("x",QString::number(pointVals[0].toDouble()));
parElem.setAttribute("y",QString::number(pointVals[1].toDouble()));
parElem.setAttribute("z",QString::number(pointVals[2].toDouble()));
}
break;
default: assert(0);
}
return parElem;
}
示例9: createTransactionDocument
QDomDocument createTransactionDocument( QgsServerInterface* serverIface, const QString& version,
const QgsServerRequest& request )
{
Q_UNUSED( version );
QDomDocument doc;
QgsWfsProjectParser* configParser = getConfigParser( serverIface );
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl* accessControl = serverIface->accessControls();
#endif
const QString requestBody = request.getParameter( QStringLiteral( "REQUEST_BODY" ) );
QString errorMsg;
if ( !doc.setContent( requestBody, true, &errorMsg ) )
{
throw QgsRequestNotWellFormedException( errorMsg );
}
QDomElement docElem = doc.documentElement();
QDomNodeList docChildNodes = docElem.childNodes();
// Re-organize the transaction document
QDomDocument mDoc;
QDomElement mDocElem = mDoc.createElement( QStringLiteral( "myTransactionDocument" ) );
mDocElem.setAttribute( QStringLiteral( "xmlns" ), QGS_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:wfs" ), WFS_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:gml" ), GML_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:ogc" ), OGC_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:qgs" ), QGS_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:xsi" ), QStringLiteral( "http://www.w3.org/2001/XMLSchema-instance" ) );
mDoc.appendChild( mDocElem );
QDomElement actionElem;
QString actionName;
QDomElement typeNameElem;
QString typeName;
for ( int i = docChildNodes.count(); 0 < i; --i )
{
actionElem = docChildNodes.at( i - 1 ).toElement();
actionName = actionElem.localName();
if ( actionName == QLatin1String( "Insert" ) )
{
QDomElement featureElem = actionElem.firstChild().toElement();
typeName = featureElem.localName();
}
else if ( actionName == QLatin1String( "Update" ) )
{
typeName = actionElem.attribute( QStringLiteral( "typeName" ) );
}
else if ( actionName == QLatin1String( "Delete" ) )
{
typeName = actionElem.attribute( QStringLiteral( "typeName" ) );
}
if ( typeName.contains( QLatin1String( ":" ) ) )
typeName = typeName.section( QStringLiteral( ":" ), 1, 1 );
QDomNodeList typeNameList = mDocElem.elementsByTagName( typeName );
if ( typeNameList.count() == 0 )
{
typeNameElem = mDoc.createElement( typeName );
mDocElem.appendChild( typeNameElem );
}
else
typeNameElem = typeNameList.at( 0 ).toElement();
typeNameElem.appendChild( actionElem );
}
// It's time to make the transaction
// Create the response document
QDomDocument resp;
//wfs:WFS_TransactionRespone element
QDomElement respElem = resp.createElement( QStringLiteral( "WFS_TransactionResponse" )/*wfs:WFS_TransactionResponse*/ );
respElem.setAttribute( QStringLiteral( "xmlns" ), WFS_NAMESPACE );
respElem.setAttribute( QStringLiteral( "xmlns:xsi" ), QStringLiteral( "http://www.w3.org/2001/XMLSchema-instance" ) );
respElem.setAttribute( QStringLiteral( "xsi:schemaLocation" ), WFS_NAMESPACE + " http://schemas.opengis.net/wfs/1.0.0/wfs.xsd" );
respElem.setAttribute( QStringLiteral( "xmlns:ogc" ), OGC_NAMESPACE );
respElem.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0.0" ) );
resp.appendChild( respElem );
// Store the created feature id for WFS
QStringList insertResults;
// Get the WFS layers id
QStringList wfsLayersId = configParser->wfsLayers();;
QList<QgsMapLayer*> layerList;
QgsMapLayer* currentLayer = nullptr;
// Loop through the layer transaction elements
docChildNodes = mDocElem.childNodes();
for ( int i = 0; i < docChildNodes.count(); ++i )
{
// Get the vector layer
typeNameElem = docChildNodes.at( i ).toElement();
typeName = typeNameElem.tagName();
//.........这里部分代码省略.........
示例10: writePropertiesToElement
bool QgsLayoutTable::writePropertiesToElement( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext & ) const
{
elem.setAttribute( QStringLiteral( "cellMargin" ), QString::number( mCellMargin ) );
elem.setAttribute( QStringLiteral( "emptyTableMode" ), QString::number( static_cast< int >( mEmptyTableMode ) ) );
elem.setAttribute( QStringLiteral( "emptyTableMessage" ), mEmptyTableMessage );
elem.setAttribute( QStringLiteral( "showEmptyRows" ), mShowEmptyRows );
elem.appendChild( QgsFontUtils::toXmlElement( mHeaderFont, doc, QStringLiteral( "headerFontProperties" ) ) );
elem.setAttribute( QStringLiteral( "headerFontColor" ), QgsSymbolLayerUtils::encodeColor( mHeaderFontColor ) );
elem.setAttribute( QStringLiteral( "headerHAlignment" ), QString::number( static_cast< int >( mHeaderHAlignment ) ) );
elem.setAttribute( QStringLiteral( "headerMode" ), QString::number( static_cast< int >( mHeaderMode ) ) );
elem.appendChild( QgsFontUtils::toXmlElement( mContentFont, doc, QStringLiteral( "contentFontProperties" ) ) );
elem.setAttribute( QStringLiteral( "contentFontColor" ), QgsSymbolLayerUtils::encodeColor( mContentFontColor ) );
elem.setAttribute( QStringLiteral( "gridStrokeWidth" ), QString::number( mGridStrokeWidth ) );
elem.setAttribute( QStringLiteral( "gridColor" ), QgsSymbolLayerUtils::encodeColor( mGridColor ) );
elem.setAttribute( QStringLiteral( "horizontalGrid" ), mHorizontalGrid );
elem.setAttribute( QStringLiteral( "verticalGrid" ), mVerticalGrid );
elem.setAttribute( QStringLiteral( "showGrid" ), mShowGrid );
elem.setAttribute( QStringLiteral( "backgroundColor" ), QgsSymbolLayerUtils::encodeColor( mBackgroundColor ) );
elem.setAttribute( QStringLiteral( "wrapBehavior" ), QString::number( static_cast< int >( mWrapBehavior ) ) );
//columns
QDomElement displayColumnsElem = doc.createElement( QStringLiteral( "displayColumns" ) );
for ( QgsLayoutTableColumn *column : qgis::as_const( mColumns ) )
{
QDomElement columnElem = doc.createElement( QStringLiteral( "column" ) );
column->writeXml( columnElem, doc );
displayColumnsElem.appendChild( columnElem );
}
elem.appendChild( displayColumnsElem );
//cell styles
QDomElement stylesElem = doc.createElement( QStringLiteral( "cellStyles" ) );
QMap< CellStyleGroup, QString >::const_iterator it = mCellStyleNames.constBegin();
for ( ; it != mCellStyleNames.constEnd(); ++it )
{
QString styleName = it.value();
QDomElement styleElem = doc.createElement( styleName );
QgsLayoutTableStyle *style = mCellStyles.value( it.key() );
if ( style )
{
style->writeXml( styleElem, doc );
stylesElem.appendChild( styleElem );
}
}
elem.appendChild( stylesElem );
return true;
}
示例11: writeLayerXML
bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& document, QString relativeBasePath )
{
// use scale dependent visibility flag
layerElement.setAttribute( "hasScaleBasedVisibilityFlag", hasScaleBasedVisibility() ? 1 : 0 );
layerElement.setAttribute( "minimumScale", QString::number( minimumScale() ) );
layerElement.setAttribute( "maximumScale", QString::number( maximumScale() ) );
// ID
QDomElement layerId = document.createElement( "id" );
QDomText layerIdText = document.createTextNode( id() );
layerId.appendChild( layerIdText );
layerElement.appendChild( layerId );
// data source
QDomElement dataSource = document.createElement( "datasource" );
QString src = source();
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( this );
// TODO: what about postgres, mysql and others, they should not go through writePath()
if ( vlayer && vlayer->providerType() == "spatialite" )
{
QgsDataSourceURI uri( src );
QString database = QgsProject::instance()->writePath( uri.database(), relativeBasePath );
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], relativeBasePath );
src = theURIParts.join( "|" );
}
else if ( vlayer && vlayer->providerType() == "gpx" )
{
QStringList theURIParts = src.split( "?" );
theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0], relativeBasePath );
src = theURIParts.join( "?" );
}
else if ( vlayer && vlayer->providerType() == "delimitedtext" )
{
QUrl urlSource = QUrl::fromEncoded( src.toAscii() );
QUrl urlDest = QUrl::fromLocalFile( QgsProject::instance()->writePath( urlSource.toLocalFile(), relativeBasePath ) );
urlDest.setQueryItems( urlSource.queryItems() );
src = QString::fromAscii( urlDest.toEncoded() );
}
else
{
bool handled = false;
if ( !vlayer )
{
QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( this );
// Update path for subdataset
if ( rlayer && rlayer->providerType() == "gdal" )
{
if ( src.startsWith( "NETCDF:" ) )
{
// NETCDF:filename:variable
// filename can be quoted with " as it can contain colons
QRegExp r( "NETCDF:(.+):([^:]+)" );
if ( r.exactMatch( src ) )
{
QString filename = r.cap( 1 );
if ( filename.startsWith( '"' ) && filename.endsWith( '"' ) )
filename = filename.mid( 1, filename.length() - 2 );
src = "NETCDF:\"" + QgsProject::instance()->writePath( filename, relativeBasePath ) + "\":" + r.cap( 2 );
handled = true;
}
}
else if ( src.startsWith( "HDF4_SDS:" ) )
{
// HDF4_SDS:subdataset_type:file_name:subdataset_index
// filename can be quoted with " as it can contain colons
QRegExp r( "HDF4_SDS:([^:]+):(.+):([^:]+)" );
if ( r.exactMatch( src ) )
{
QString filename = r.cap( 2 );
if ( filename.startsWith( '"' ) && filename.endsWith( '"' ) )
filename = filename.mid( 1, filename.length() - 2 );
src = "HDF4_SDS:" + r.cap( 1 ) + ":\"" + QgsProject::instance()->writePath( filename, relativeBasePath ) + "\":" + r.cap( 3 );
handled = true;
}
}
else if ( src.startsWith( "HDF5:" ) )
{
// HDF5:file_name:subdataset
// filename can be quoted with " as it can contain colons
QRegExp r( "HDF5:(.+):([^:]+)" );
if ( r.exactMatch( src ) )
{
QString filename = r.cap( 1 );
if ( filename.startsWith( '"' ) && filename.endsWith( '"' ) )
filename = filename.mid( 1, filename.length() - 2 );
src = "HDF5:\"" + QgsProject::instance()->writePath( filename, relativeBasePath ) + "\":" + r.cap( 2 );
handled = true;
}
}
else if ( src.contains( QRegExp( "^(NITF_IM|RADARSAT_2_CALIB):" ) ) )
//.........这里部分代码省略.........
示例12: saveSettings
bool ProcessController::saveSettings(QDomDocument& doc, QDomElement& element)
{
if(!mProcessList)
return false;
element.setAttribute("hostName", sensors().at(0)->hostName());
element.setAttribute("sensorName", sensors().at(0)->name());
element.setAttribute("sensorType", sensors().at(0)->type());
element.setAttribute("version", QString::number(PROCESSHEADERVERSION));
element.setAttribute("treeViewHeader", QString::fromLatin1(mProcessList->treeView()->header()->saveState().toBase64()));
element.setAttribute("showTotals", mProcessList->showTotals()?1:0);
element.setAttribute("units", (int)(mProcessList->units()));
element.setAttribute("ioUnits", (int)(mProcessList->processModel()->ioUnits()));
element.setAttribute("ioInformation", (int)(mProcessList->processModel()->ioInformation()));
element.setAttribute("showCommandLineOptions", mProcessList->processModel()->isShowCommandLineOptions());
element.setAttribute("showTooltips", mProcessList->processModel()->isShowingTooltips());
element.setAttribute("normalizeCPUUsage", mProcessList->processModel()->isNormalizedCPUUsage());
element.setAttribute("filterState", (int)(mProcessList->state()));
SensorDisplay::saveSettings(doc, element);
return true;
}
示例13: docToNavdoc
QString HtmlUtil::docToNavdoc(const QString &data, QString &header, QString &nav)
{
QDomDocument doc;
QStringList srcLines = data.split("\n");
QStringList navLines;
QStringList dstLines;
navLines.append("<table class=\"unruled\"><tbody><tr><td class=\"first\"><dl>");
int index = 0;
if (srcLines.length() >= 1) {
header = findTitle(data);
if (header.isEmpty()) {
//<!-- How to Write Go Code -->
QString line = srcLines.at(0);
QRegExp reg("<!--([\\w\\s]*)-->");
if (reg.indexIn(line) >= 0) {
header = reg.cap(1);
header.trimmed();
}
}
}
foreach(QString source, srcLines) {
QString line = source.trimmed();
index++;
if (line.length() >= 10) {
if (line.left(3) == "<h2") {
if (doc.setContent(line)) {
QDomElement e = doc.firstChildElement("h2");
if (!e.isNull()) {
QString text = e.text();
QString id = e.attribute("id");
if (id.isEmpty()) {
id = QString("tmp_%1").arg(index);
e.setAttribute("id",id);
}
//<span class="navtop"><a href="#top">[Top]</a></span>
QDomElement span = doc.createElement("span");
span.setAttribute("class","navtop");
QDomElement a = doc.createElement("a");
a.setAttribute("href","#top");
QDomText top = doc.createTextNode("[Top]");
a.appendChild(top);
span.appendChild(a);
e.appendChild(span);
source = doc.toString();
navLines << QString("<dt><a href=\"#%1\">%2</a></dt>").arg(id).arg(text);
}
}
}
else if (line.left(3) == "<h3") {
if (doc.setContent(line)) {
QDomElement e = doc.firstChildElement("h3");
if (!e.isNull()) {
QString text = e.text();
QString id = e.attribute("id");
if (id.isEmpty()) {
id = QString("tmp_%1").arg(index);
e.setAttribute("id",id);
}
source = doc.toString();
navLines << QString("<dd><a href=\"#%1\">%2</a></dd>").arg(id).arg(text);
}
}
}
}
dstLines.append(source);
}
示例14: saveSettings
void Controller::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setAttribute( "type", type() );
_this.setAttribute( "name", name() );
}
示例15: saveConfiguration
void QgsAttributeEditorRelation::saveConfiguration( QDomElement& elem ) const
{
elem.setAttribute( QStringLiteral( "relation" ), mRelation.id() );
elem.setAttribute( QStringLiteral( "showLinkButton" ), mShowLinkButton );
elem.setAttribute( QStringLiteral( "showUnlinkButton" ), mShowUnlinkButton );
}