本文整理汇总了C++中QDomElement::nextSiblingElement方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::nextSiblingElement方法的具体用法?C++ QDomElement::nextSiblingElement怎么用?C++ QDomElement::nextSiblingElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::nextSiblingElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
void LineSegment::read(const QDomElement& e)
{
for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement())
readProperties(ee);
}
示例2: loadSld
QgsFeatureRenderer* QgsFeatureRenderer::loadSld( const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage )
{
QDomElement element = node.toElement();
if ( element.isNull() )
return nullptr;
// get the UserStyle element
QDomElement userStyleElem = element.firstChildElement( "UserStyle" );
if ( userStyleElem.isNull() )
{
// UserStyle element not found, nothing will be rendered
errorMessage = "Info: UserStyle element not found.";
return nullptr;
}
// get the FeatureTypeStyle element
QDomElement featTypeStyleElem = userStyleElem.firstChildElement( "FeatureTypeStyle" );
if ( featTypeStyleElem.isNull() )
{
errorMessage = "Info: FeatureTypeStyle element not found.";
return nullptr;
}
// use the RuleRenderer when more rules are present or the rule
// has filters or min/max scale denominators set,
// otherwise use the SingleSymbol renderer
bool needRuleRenderer = false;
int ruleCount = 0;
QDomElement ruleElem = featTypeStyleElem.firstChildElement( "Rule" );
while ( !ruleElem.isNull() )
{
ruleCount++;
// more rules present, use the RuleRenderer
if ( ruleCount > 1 )
{
QgsDebugMsg( "more Rule elements found: need a RuleRenderer" );
needRuleRenderer = true;
break;
}
QDomElement ruleChildElem = ruleElem.firstChildElement();
while ( !ruleChildElem.isNull() )
{
// rule has filter or min/max scale denominator, use the RuleRenderer
if ( ruleChildElem.localName() == "Filter" ||
ruleChildElem.localName() == "MinScaleDenominator" ||
ruleChildElem.localName() == "MaxScaleDenominator" )
{
QgsDebugMsg( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
needRuleRenderer = true;
break;
}
ruleChildElem = ruleChildElem.nextSiblingElement();
}
if ( needRuleRenderer )
{
break;
}
ruleElem = ruleElem.nextSiblingElement( "Rule" );
}
QString rendererType;
if ( needRuleRenderer )
{
rendererType = "RuleRenderer";
}
else
{
rendererType = "singleSymbol";
}
QgsDebugMsg( QString( "Instantiating a '%1' renderer..." ).arg( rendererType ) );
// create the renderer and return it
QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( rendererType );
if ( !m )
{
errorMessage = QString( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
return nullptr;
}
QgsFeatureRenderer* r = m->createRendererFromSld( featTypeStyleElem, geomType );
return r;
}
示例3: charger
void Dossier::charger(const FormationManager& forman, const PeriodeManager& periodeman, const UVManager& uvman, const NoteManager& notman)
{
QDomDocument doc = this->chargerXml(chemin_fichier + "/" + fichier);
QDomElement racine = doc.documentElement();
std::vector<const Formation*> tempformations;
std::vector<Inscription> tempinscriptions;
Factory<UV> tempuvs;
std::map<QString,Note> tempnotes;
QString tempForma = "NULL", tempInscri = "NULL";
if(racine.tagName() == "dossier")
{
QString tempNom, tempPrenom, tempFormation, tempUv, tempNote, code;
QDomElement unElement = racine.firstChildElement();
while(!unElement.isNull())
{
if(unElement.tagName() == "nom")
{
tempNom = unElement.text();
}
else if(unElement.tagName() == "prenom")
{
tempPrenom = unElement.text();
}
else if(unElement.tagName() == "formations")
{
tempForma = unElement.text();
tempformations.push_back(&forman.getFormation(tempForma));
}
else if(unElement.tagName() == "inscription")
{
QDomElement filsElement = unElement.firstChildElement();
while(!filsElement.isNull())
{
if(filsElement.tagName()=="code"){
code = filsElement.text();
}
else if(filsElement.tagName()=="semestre"){
tempInscri = filsElement.text();
}
else if(filsElement.tagName() =="formation"){
tempFormation = filsElement.text();
}
else if(filsElement.tagName() == "uv")
{
QDomElement filsUV = filsElement.firstChildElement();
while(!filsUV.isNull())
{
if(filsUV.tagName() == "codeUV"){
tempUv = filsUV.text();
tempuvs.ajouter(tempUv,uvman.getUV(tempUv));
}
if(filsUV.tagName() == "note"){
tempNote = filsUV.text();
tempnotes[tempUv] = notman.getNote(tempNote);
}
filsUV = filsUV.nextSiblingElement();
}
}
filsElement = filsElement.nextSiblingElement();
}
Inscription temp(code,periodeman.getPeriode(tempInscri),forman.getFormation(tempFormation));
for (map<QString,UV>::iterator it = tempuvs.begin(); it != tempuvs.end(); it++)
{
temp.ajouterUV(it->second);
temp.modifierNote(it->second.getCode(),tempnotes.find(it->second.getCode())->second.getNote());
}
tempuvs.vider();
tempinscriptions.push_back(temp);
}
unElement = unElement.nextSiblingElement();
}
this->setLogin();
this->setNom(tempNom);
this->setPrenom(tempPrenom);
this->setLogin();
if (tempForma != "NULL")
{
for (unsigned int i = 0; i < tempformations.size(); i++)
{
ajouterFormation(*tempformations[i]);
}
tempformations.clear();
tempForma = "NULL";
}
if (tempInscri!="NULL")
{
for(unsigned int i=0; i < tempinscriptions.size(); i++)
{
ajouterInscription(tempinscriptions[i].getCode(),tempinscriptions[i].getPeriode(),tempinscriptions[i].getFormation());
tempuvs=tempinscriptions[i].getUVs();
for (map<QString,UV>::iterator it = tempuvs.begin(); it != tempuvs.end(); it++)
{
getInscription(tempinscriptions[i].getCode()).ajouterUV(uvman.getUV(it->second.getCode()));
getInscription(tempinscriptions[i].getCode()).
modifierNote(it->second.getCode(),tempnotes.find(it->second.getCode())->second.getNote());
}
//.........这里部分代码省略.........
示例4: load
Script* Script::load(std::string name)
{
std::string filename = "scripts/";
filename.append(name);
filename.append(".xml");
QFile file(filename.c_str());
if(!file.open(QIODevice::ReadOnly))
{
pi_warn("Could not open file");
return NULL;
}
QDomDocument document;
document.setContent(&file);
QDomElement docElem = document.documentElement();
// check if this is a valid script file
if(docElem.tagName().toLower().compare("script") != 0)
{
pi_warn("Invalid configuration file: tag \"script\" is missing");
return NULL;
}
Script* script = new Script();
script->m_name = name;
QDomElement elem = docElem.firstChildElement();
while(!elem.isNull())
{
if(elem.tagName().toLower().compare("rule") == 0)
{
Rule* rule = Rule::load(&elem);
if(rule != NULL)
{
script->addRule(rule);
}
}
else if(elem.tagName().toLower().compare("variable") == 0)
{
Variable* variable = Variable::load(&elem);
if(variable != NULL)
{
script->addVariable(variable);
}
}
else if(elem.tagName().toLower().compare("description") == 0)
{
script->m_desc = elem.text().toStdString();
}
elem = elem.nextSiblingElement();
}
file.close();
return script;
}
示例5: read
void Box::read(const QDomElement& de)
{
_leftMargin = _rightMargin = _topMargin = _bottomMargin = 0.0;
bool keepMargins = false; // whether original margins have to be kept when reading old file
for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
const QString& tag(e.tagName());
const QString& text(e.text());
if (tag == "height")
_boxHeight = Spatium(text.toDouble());
else if (tag == "width")
_boxWidth = Spatium(text.toDouble());
else if (tag == "topGap")
_topGap = text.toDouble();
else if (tag == "bottomGap")
_bottomGap = text.toDouble();
else if (tag == "leftMargin")
_leftMargin = text.toDouble();
else if (tag == "rightMargin")
_rightMargin = text.toDouble();
else if (tag == "topMargin")
_topMargin = text.toDouble();
else if (tag == "bottomMargin")
_bottomMargin = text.toDouble();
else if (tag == "Text") {
Text* t;
if (type() == TBOX) {
t = static_cast<TBox*>(this)->getText();
t->read(e);
}
else {
t = new Text(score());
t->read(e);
add(t);
if (score()->mscVersion() <= 114)
t->setLayoutToParentWidth(true);
}
}
else if (tag == "Symbol") {
Symbol* s = new Symbol(score());
s->read(e);
add(s);
}
else if (tag == "Image") {
// look ahead for image type
QString path;
QDomElement ee = e.firstChildElement("path");
if (!ee.isNull())
path = ee.text();
Image* image = 0;
QString s(path.toLower());
if (s.endsWith(".svg"))
image = new SvgImage(score());
else
if (s.endsWith(".jpg")
|| s.endsWith(".png")
|| s.endsWith(".gif")
|| s.endsWith(".xpm")
) {
image = new RasterImage(score());
}
else {
qDebug("unknown image format <%s>\n", path.toLatin1().data());
}
if (image) {
image->setTrack(score()->curTrack);
image->read(e);
add(image);
}
}
else if (tag == "FretDiagram") {
FretDiagram* f = new FretDiagram(score());
f->read(e);
add(f);
}
else if (tag == "LayoutBreak") {
LayoutBreak* lb = new LayoutBreak(score());
lb->read(e);
add(lb);
}
else if (tag == "HBox") {
HBox* hb = new HBox(score());
hb->read(e);
add(hb);
keepMargins = true; // in old file, box nesting used outer box margins
}
else if (tag == "VBox") {
VBox* vb = new VBox(score());
vb->read(e);
add(vb);
keepMargins = true; // in old file, box nesting used outer box margins
}
else
domError(e);
}
// with .msc versions prior to 1.17, box margins were only used when nesting another box inside this box:
// for backward compatibility set them to 0 in all other cases
if (score()->mscVersion() < 117 && (type() == HBOX || type() == VBOX) && !keepMargins) {
//.........这里部分代码省略.........
示例6: if
QSharedPointer<FormatDefinition>
FormatReader::_parseFormat(const QDomElement &formatNode)
{
QString id; // Unique; required
QDateTime releaseDate; // As attribute of id; required
QString name; // Localised; required
QString description; // Localised; optional
QString completeness; // From enum; required
bool isText; // True or false; required
// Prioritised when outputting; required to specify at least one:
QStringList mimeTypes;
// <id releaseDate="xsd:dateTime">xsd:NMTOKEN</id>
QDomElement e = formatNode.firstChildElement();
if (ElementParser::expect(e, "id", ElementParser::Required))
{
releaseDate = ElementParser::dateTime(e.attribute("releaseDate"));
id = ElementParser::nmtoken(e.text());
e = e.nextSiblingElement();
}
else
return QSharedPointer<FormatDefinition>();
// <name xml:lang="xsd:language">xsd:token</name>
// (one or more, with unique xml:lang attributes)
if (ElementParser::expect(e, "name", ElementParser::Required))
{
name = ElementParser::localisedString(e);
e = e.nextSiblingElement();
}
else
return QSharedPointer<FormatDefinition>();
// <description xml:lang="xsd:language">xsd:token</description>
// (zero or more, with unique xml:lang attributes)
if (ElementParser::expect(e, "description", ElementParser::Optional))
{
description = ElementParser::localisedString(e);
e = e.nextSiblingElement();
}
else if (e.isNull())
return QSharedPointer<FormatDefinition>();
// <completeness>(notEmpty|metaOnly|dataOnly|complete)</completeness>
if (ElementParser::expect(e, "completeness", ElementParser::Required))
{
completeness = e.text();
e = e.nextSiblingElement();
}
else
return QSharedPointer<FormatDefinition>();
// <isText> ( true | false ) </isText>
if (ElementParser::expect(e, "isText", ElementParser::Required))
{
isText = ElementParser::boolean(e.text());
e = e.nextSiblingElement();
}
else
return QSharedPointer<FormatDefinition>();
// <mimeTypes>
// <mimeType>xxx/yyy</mimeType>
// ...
// <mimeTypes>
if (ElementParser::expect(e, "mimeTypes", ElementParser::Required))
mimeTypes = ElementParser::tokenList(e, "mimeType");
e = e.nextSiblingElement();
// alloc: QSharedPointer
QSharedPointer<FormatDefinition> format(
new FormatDefinition(id,
name,
description,
releaseDate,
completeness,
isText,
mimeTypes,
0));
if (format->isValid())
return format;
qDebug() << "FormatReader::parseFormat() discarded invalid format"
<< " definition.";
return QSharedPointer<FormatDefinition>();
}
示例7: load
bool Scene::load(const QString& fn) {
QFile file(fn);
if (!file.open(QIODevice::ReadOnly)) {
return false;
}
QByteArray data = file.readAll();
QDomDocument doc;
if (!doc.setContent(data)) {
return false;
}
clearSelection();
beginResetModel();
m_history->clear();
if (m_static_body)
delete m_static_body;
m_static_body = 0;
foreach( Body* b, m_bodys ) {
delete b;
}
m_bodys.clear();
QDomElement root = doc.documentElement();
m_worldSize.setWidth(root.attribute("width").toInt());
m_worldSize.setHeight(root.attribute("height").toInt());
QDomElement node = root.firstChildElement("body");
while (node.isElement()) {
QString type = node.attribute("type");
Body* b = 0;
if (type=="StaticBody") {
b = new StaticBody(this,"body",this);
ReadAttributes(b,node);
if (!m_static_body)
m_static_body = b;
else {
m_bodys.push_back( b );
}
} else if (type=="DynamicBody") {
b = new DynamicBody(this,"body",this);
ReadAttributes(b,node);
m_bodys.push_back( b );
}
if (b) {
QDomElement primNode = node.firstChildElement("primitive");
while (primNode.isElement()) {
Primitive* p = 0;
QString type = primNode.attribute("type");
p = Primitive::create(type,b,this);
if (p) {
ReadAttributes(p,primNode);
b->addPrimitive(p);
}
primNode = primNode.nextSiblingElement("primitive");
}
connect( b,SIGNAL(changed()),this,SLOT(bodyChanged()));
}
node = node.nextSiblingElement("body");
}
endResetModel();
m_filename = fn;
emit changed();
return true;
}
示例8: convert
//.........这里部分代码省略.........
*/
QXmlSimpleReader reader;
QXmlInputSource source;
source.setData(oooDocument.content());
QString errorMsg;
QDomDocument document;
if (!document.setContent(&source, &reader, &errorMsg))
{
setError(QString("Invalid XML document: %1").arg(errorMsg), -1);
delete m_Cursor;
return m_TextDocument;
}
/**
* Read the style properties, so the are available when
* parsing the content.
*/
m_StyleInformation = new StyleInformation();
if (oooDocument.content().size() == 0)
{
setError("Empty document", -1);
}
StyleParser styleParser(&oooDocument, document, m_StyleInformation);
if (!styleParser.parse())
{
setError("Unable to read style information", -1);
delete m_Cursor;
return 0;
}
/**
* Add all images of the document to resource framework
*/
QMap<QString, QByteArray> imageLIST = oooDocument.images();
QMapIterator<QString, QByteArray> it(imageLIST);
while (it.hasNext())
{
it.next();
m_TextDocument->addResource(QTextDocument::ImageResource, QUrl(it.key()), QImage::fromData(it.value()));
}
/**
* Set the correct page size
*/
const QString masterLayout = m_StyleInformation->masterPageName();
if (m_StyleInformation->pagePropertyExists(masterLayout))
{
const int DPX = 231; /// im.logicalDpiX(); // 231
const int DPY = 231; // im.logicalDpiY(); // 231
const int A4Width = MM_TO_POINT(210); /// A4 210 x297 mm
const int A4Height = MM_TO_POINT(297);
const PageFormatProperty property = m_StyleInformation->pageProperty(masterLayout);
int pageWidth = qRound(property.width() / 72.0 * DPX);
if (pageWidth < 1) {
pageWidth = A4Width;
}
int pageHeight = qRound(property.height() / 72.0 * DPY);
if (pageHeight < 1) {
pageHeight = A4Height;
}
m_TextDocument->setPageSize(QSize(pageWidth, pageHeight));
QTextFrameFormat frameFormat;
frameFormat.setMargin(qRound(property.margin()));
QTextFrame *rootFrame = m_TextDocument->rootFrame();
rootFrame->setFrameFormat(frameFormat);
}
/**
* Parse the content of the document
*/
const QDomElement documentElement = document.documentElement();
QDomElement element = documentElement.firstChildElement();
while (!element.isNull())
{
if (element.tagName() == QLatin1String("body"))
{
if (!convertBody(element))
{
setError("Unable to convert document content", -1);
delete m_Cursor;
return 0;
}
}
element = element.nextSiblingElement();
}
return m_TextDocument;
}
示例9: channel
channels_container_t RSS10Parser::Parse (const QDomDocument& doc,
const IDType_t& feedId) const
{
channels_container_t result;
QMap<QString, Channel_ptr> item2Channel;
QDomElement root = doc.documentElement ();
QDomElement channelDescr = root.firstChildElement ("channel");
while (!channelDescr.isNull ())
{
Channel_ptr channel (new Channel (feedId));
channel->Title_ = channelDescr.firstChildElement ("title").text ().trimmed ();
channel->Link_ = channelDescr.firstChildElement ("link").text ();
channel->Description_ =
channelDescr.firstChildElement ("description").text ();
channel->PixmapURL_ =
channelDescr.firstChildElement ("image")
.firstChildElement ("url").text ();
channel->LastBuild_ = GetDCDateTime (channelDescr);
QDomElement itemsRoot = channelDescr.firstChildElement ("items");
QDomNodeList seqs = itemsRoot.elementsByTagNameNS (RDF_, "Seq");
channelDescr = channelDescr.nextSiblingElement ("channel");
if (!seqs.size ())
continue;
QDomElement seqElem = seqs.at (0).toElement ();
QDomNodeList lis = seqElem.elementsByTagNameNS (RDF_, "li");
for (int i = 0; i < lis.size (); ++i)
item2Channel [lis.at (i).toElement ().attribute ("resource")] = channel;
result.push_back (channel);
}
QDomElement itemDescr = root.firstChildElement ("item");
while (!itemDescr.isNull ())
{
QString about = itemDescr.attributeNS (RDF_, "about");
if (item2Channel.contains (about))
{
Item_ptr item (new Item (item2Channel [about]->ChannelID_));
item->Title_ = itemDescr.firstChildElement ("title").text ();
item->Link_ = itemDescr.firstChildElement ("link").text ();
item->Description_ = itemDescr.firstChildElement ("description").text ();
GetDescription (itemDescr, item->Description_);
item->Categories_ = GetAllCategories (itemDescr);
item->Author_ = GetAuthor (itemDescr);
item->PubDate_ = GetDCDateTime (itemDescr);
item->Unread_ = true;
item->NumComments_ = GetNumComments (itemDescr);
item->CommentsLink_ = GetCommentsRSS (itemDescr);
item->CommentsPageLink_ = GetCommentsLink (itemDescr);
item->Enclosures_ = GetEncEnclosures (itemDescr, item->ItemID_);
QPair<double, double> point = GetGeoPoint (itemDescr);
item->Latitude_ = point.first;
item->Longitude_ = point.second;
if (item->Guid_.isEmpty ())
item->Guid_ = "empty";
item2Channel [about]->Items_.push_back (item);
}
itemDescr = itemDescr.nextSiblingElement ("item");
}
return result;
}
示例10: handleProperty
void Variable::handleProperty(const QDomElement &xml)
{
Q_ASSERT(!xml.isNull());
Q_ASSERT(xml.nodeName() == "property");
setInScope(true);
m_fullName = xml.attribute("fullname");
//kDebug() << m_fullName;
if (xml.firstChild().isText()) {
QString v = xml.firstChild().toText().data();
if (xml.attribute("encoding") == "base64") {
//TODO: use Connection::m_codec->toUnicode
v = QString::fromUtf8(QByteArray::fromBase64(xml.text().toAscii()));
}
//kDebug() << "value" << v;
setValue(v);
}
QMap<QString, Variable*> existing;
for (int i = 0; i < childCount() - (hasMore() ? 1 : 0) ; i++) {
Q_ASSERT(dynamic_cast<Variable*>(child(i)));
Variable* v = static_cast<Variable*>(child(i));
existing[v->expression()] = v;
}
QSet<QString> current;
QDomElement el = xml.firstChildElement("property");
while (!el.isNull()) {
QString name = el.attribute("name");
//kDebug() << name;
current << name;
Variable* v = 0;
if( !existing.contains(name) ) {
v = new Variable(model(), this, name);
appendChild( v, false );
} else {
v = existing[name];
}
v->handleProperty(el);
el = el.nextSiblingElement("property");
}
for (int i = 0; i < childCount() - (hasMore() ? 1 : 0); ++i) {
Q_ASSERT(dynamic_cast<KDevelop::Variable*>(child(i)));
KDevelop::Variable* v = static_cast<KDevelop::Variable*>(child(i));
if (!current.contains(v->expression())) {
removeChild(i);
--i;
delete v;
}
}
if (!childCount() && xml.attribute("children") == "1") {
kDebug() << "has more" << this;
setHasMore(true);
if (isExpanded()) {
fetchMoreChildren();
}
}
}
示例11: deSerialize
bool ActionCollection::deSerialize(const QDomElement& actionCollectionElem)
{
if (actionCollectionElem.isNull())
return false;
qDeleteAll(listInterfaceCommands);
listInterfaceCommands.clear();
QDomElement listsElement = actionCollectionElem.firstChildElement("lists");
if (listsElement.isNull()) {
QHash<CommandListElements::Element, VoiceInterfaceCommand*> baseConfig = ScenarioManager::getInstance()->
getListBaseConfiguration();
QHashIterator<CommandListElements::Element, VoiceInterfaceCommand*> i(baseConfig);
while (i.hasNext()) {
i.next();
// i.value() is not a valid command
listInterfaceCommands.insertMulti(i.key(), new VoiceInterfaceCommand(*(i.value())));
}
}
else {
QDomElement commandElem = listsElement.firstChildElement();
while (!commandElem.isNull()) {
VoiceInterfaceCommand *com = VoiceInterfaceCommand::createInstance(commandElem);
int elementId = commandElem.attribute("element").toInt();
commandElem = commandElem.nextSiblingElement("voiceInterfaceCommand");
if (!com) continue;
listInterfaceCommands.insert((CommandListElements::Element) elementId, com);
}
}
QDomElement autorunElem = actionCollectionElem.firstChildElement("autorun");
m_autorunActive = autorunElem.attribute("active") == "1";
m_autorunCommand = autorunElem.firstChildElement("trigger").text();
m_autorunType = autorunElem.firstChildElement("category").text();
//clean member
qDeleteAll(m_actions);
m_actions.clear();
QDomElement pluginElem = actionCollectionElem.firstChildElement("plugin");
while (!pluginElem.isNull()) {
Action *a = Action::createAction(parentScenario, pluginElem, this);
if (!a) {
kDebug() << "Could not load action";
}
else {
//m_actions << a;
appendAction(a, true /*silent*/);
}
pluginElem = pluginElem.nextSiblingElement("plugin");
}
proxy->update();
reset();
if (m_autorunActive)
{
bool succ = triggerCommand(m_autorunType, m_autorunCommand, true /* silent */);
kDebug() << "Executed autorun command; Success: " << succ;
}
return true;
}
示例12: _onOperatorPaste
void ePageView::_onOperatorPaste()
{
eGuiOpPage *guiPage = (eGuiOpPage *)scene();
eASSERT(guiPage != eNULL);
// Check if clipboard format is correct.
const QMimeData *md = QApplication::clipboard()->mimeData();
eASSERT(md != eNULL);
if (!md->hasFormat("operator/xml"))
{
return;
}
// Get operator with smallest (x, y) position,
// needed to calculate new positions for
// pasted operators.
QDomDocument xml;
xml.setContent(md->data("operator/xml"));
QDomElement xmlOp = xml.firstChild().firstChildElement("operator");
ePoint minPos(eS32_MAX, eS32_MAX);
while (!xmlOp.isNull())
{
const eInt x = xmlOp.attribute("xpos").toInt();
const eInt y = xmlOp.attribute("ypos").toInt();
if (x < minPos.x)
{
minPos.x = x;
}
if (y < minPos.y)
{
minPos.y = y;
}
xmlOp = xmlOp.nextSiblingElement("operator");
}
// Iterate the second time through operators. This
// time the operators are added to the page using
// the previously calculated minimum relative
// position.
xmlOp = xml.firstChild().firstChildElement("operator");
while (!xmlOp.isNull())
{
const QString opType = xmlOp.attribute("type");
const eU32 xpos = xmlOp.attribute("xpos").toInt();
const eU32 ypos = xmlOp.attribute("ypos").toInt();
const eU32 width = xmlOp.attribute("width").toInt();
const eID opId = xmlOp.attribute("id").toInt();
const ePoint newPos = guiPage->getInsertAt()+(ePoint(xpos, ypos)-minPos);
eASSERT(newPos.x >= 0 && newPos.y >= 0);
// Only add operator, if its position
// lies on operator page.
if (newPos.y < eOperatorPage::HEIGHT &&
newPos.x+width <= eOperatorPage::WIDTH)
{
eGuiOperator *guiOp = new eGuiOperator(opType.toAscii().constData(), newPos, guiPage, width, eFALSE, opId);
eASSERT(guiOp != eNULL);
// Was adding of operator successful?
if (guiOp->getOperator())
{
guiOp->loadFromXml(xmlOp);
scene()->addItem(guiOp);
}
else
{
eSAFE_DELETE(guiOp);
}
}
xmlOp = xmlOp.nextSiblingElement("operator");
}
// Finally, after adding all operators,
// update links on page.
guiPage->getPage()->updateLinks();
scene()->invalidate();
}
示例13: if
QgsFeatureRendererV2* QgsGraduatedSymbolRendererV2::create( QDomElement& element )
{
QDomElement symbolsElem = element.firstChildElement( "symbols" );
if ( symbolsElem.isNull() )
return NULL;
QDomElement rangesElem = element.firstChildElement( "ranges" );
if ( rangesElem.isNull() )
return NULL;
QgsSymbolV2Map symbolMap = QgsSymbolLayerV2Utils::loadSymbols( symbolsElem );
QgsRangeList ranges;
QDomElement rangeElem = rangesElem.firstChildElement();
while ( !rangeElem.isNull() )
{
if ( rangeElem.tagName() == "range" )
{
double lowerValue = rangeElem.attribute( "lower" ).toDouble();
double upperValue = rangeElem.attribute( "upper" ).toDouble();
QString symbolName = rangeElem.attribute( "symbol" );
QString label = rangeElem.attribute( "label" );
bool render = rangeElem.attribute( "render", "true" ) != "false";
if ( symbolMap.contains( symbolName ) )
{
QgsSymbolV2* symbol = symbolMap.take( symbolName );
ranges.append( QgsRendererRangeV2( lowerValue, upperValue, symbol, label, render ) );
}
}
rangeElem = rangeElem.nextSiblingElement();
}
QString attrName = element.attribute( "attr" );
QgsGraduatedSymbolRendererV2* r = new QgsGraduatedSymbolRendererV2( attrName, ranges );
QString attrMethod = element.attribute( "graduatedMethod" );
if ( attrMethod.length() )
{
if ( attrMethod == graduatedMethodStr( GraduatedColor ) )
r->setGraduatedMethod( GraduatedColor );
else if ( attrMethod == graduatedMethodStr( GraduatedSize ) )
r->setGraduatedMethod( GraduatedSize );
}
// delete symbols if there are any more
QgsSymbolLayerV2Utils::clearSymbolMap( symbolMap );
// try to load source symbol (optional)
QDomElement sourceSymbolElem = element.firstChildElement( "source-symbol" );
if ( !sourceSymbolElem.isNull() )
{
QgsSymbolV2Map sourceSymbolMap = QgsSymbolLayerV2Utils::loadSymbols( sourceSymbolElem );
if ( sourceSymbolMap.contains( "0" ) )
{
r->setSourceSymbol( sourceSymbolMap.take( "0" ) );
}
QgsSymbolLayerV2Utils::clearSymbolMap( sourceSymbolMap );
}
// try to load color ramp (optional)
QDomElement sourceColorRampElem = element.firstChildElement( "colorramp" );
if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( "name" ) == "[source]" )
{
r->setSourceColorRamp( QgsSymbolLayerV2Utils::loadColorRamp( sourceColorRampElem ) );
QDomElement invertedColorRampElem = element.firstChildElement( "invertedcolorramp" );
if ( !invertedColorRampElem.isNull() )
r->setInvertedColorRamp( invertedColorRampElem.attribute( "value" ) == "1" );
}
// try to load mode
QDomElement modeElem = element.firstChildElement( "mode" );
if ( !modeElem.isNull() )
{
QString modeString = modeElem.attribute( "name" );
if ( modeString == "equal" )
r->setMode( EqualInterval );
else if ( modeString == "quantile" )
r->setMode( Quantile );
else if ( modeString == "jenks" )
r->setMode( Jenks );
else if ( modeString == "stddev" )
r->setMode( StdDev );
else if ( modeString == "pretty" )
r->setMode( Pretty );
}
QDomElement rotationElem = element.firstChildElement( "rotation" );
if ( !rotationElem.isNull() && !rotationElem.attribute( "field" ).isEmpty() )
{
for ( QgsRangeList::iterator it = r->mRanges.begin(); it != r->mRanges.end(); ++it )
{
convertSymbolRotation( it->symbol(), rotationElem.attribute( "field" ) );
}
if ( r->mSourceSymbol.data() )
{
convertSymbolRotation( r->mSourceSymbol.data(), rotationElem.attribute( "field" ) );
}
}
//.........这里部分代码省略.........
示例14: load
bool ResourceFile::load()
{
m_error_message.clear();
if (m_file_name.isEmpty()) {
m_error_message = tr("The file name is empty.");
return false;
}
QFile file(m_file_name);
if (!file.open(QIODevice::ReadOnly)) {
m_error_message = file.errorString();
return false;
}
clearPrefixList();
QDomDocument doc;
QString error_msg;
int error_line, error_col;
if (!doc.setContent(&file, &error_msg, &error_line, &error_col)) {
m_error_message = tr("XML error on line %1, col %2: %3")
.arg(error_line).arg(error_col).arg(error_msg);
return false;
}
QDomElement root = doc.firstChildElement(QLatin1String("RCC"));
if (root.isNull()) {
m_error_message = tr("The <RCC> root element is missing.");
return false;
}
QDomElement relt = root.firstChildElement(QLatin1String("qresource"));
for (; !relt.isNull(); relt = relt.nextSiblingElement(QLatin1String("qresource"))) {
QString prefix = fixPrefix(relt.attribute(QLatin1String("prefix")));
if (prefix.isEmpty())
prefix = QString(QLatin1Char('/'));
const QString language = relt.attribute(QLatin1String("lang"));
const int idx = indexOfPrefix(prefix, language);
Prefix * p = 0;
if (idx == -1) {
p = new Prefix(prefix, language);
m_prefix_list.append(p);
} else {
p = m_prefix_list[idx];
}
Q_ASSERT(p);
QDomElement felt = relt.firstChildElement(QLatin1String("file"));
for (; !felt.isNull(); felt = felt.nextSiblingElement(QLatin1String("file"))) {
const QString fileName = absolutePath(felt.text());
const QString alias = felt.attribute(QLatin1String("alias"));
File * const file = new File(p, fileName, alias);
file->compress = felt.attribute(QLatin1String("compress"));
file->threshold = felt.attribute(QLatin1String("threshold"));
p->file_list.append(file);
}
}
return true;
}
示例15: while
QgsFeatureRendererV2* QgsCategorizedSymbolRendererV2::create( QDomElement& element )
{
QDomElement symbolsElem = element.firstChildElement( "symbols" );
if ( symbolsElem.isNull() )
return NULL;
QDomElement catsElem = element.firstChildElement( "categories" );
if ( catsElem.isNull() )
return NULL;
QgsSymbolV2Map symbolMap = QgsSymbolLayerV2Utils::loadSymbols( symbolsElem );
QgsCategoryList cats;
QDomElement catElem = catsElem.firstChildElement();
while ( !catElem.isNull() )
{
if ( catElem.tagName() == "category" )
{
QVariant value = QVariant( catElem.attribute( "value" ) );
QString symbolName = catElem.attribute( "symbol" );
QString label = catElem.attribute( "label" );
if ( symbolMap.contains( symbolName ) )
{
QgsSymbolV2* symbol = symbolMap.take( symbolName );
cats.append( QgsRendererCategoryV2( value, symbol, label ) );
}
}
catElem = catElem.nextSiblingElement();
}
QString attrName = element.attribute( "attr" );
QgsCategorizedSymbolRendererV2* r = new QgsCategorizedSymbolRendererV2( attrName, cats );
// delete symbols if there are any more
QgsSymbolLayerV2Utils::clearSymbolMap( symbolMap );
// try to load source symbol (optional)
QDomElement sourceSymbolElem = element.firstChildElement( "source-symbol" );
if ( !sourceSymbolElem.isNull() )
{
QgsSymbolV2Map sourceSymbolMap = QgsSymbolLayerV2Utils::loadSymbols( sourceSymbolElem );
if ( sourceSymbolMap.contains( "0" ) )
{
r->setSourceSymbol( sourceSymbolMap.take( "0" ) );
}
QgsSymbolLayerV2Utils::clearSymbolMap( sourceSymbolMap );
}
// try to load color ramp (optional)
QDomElement sourceColorRampElem = element.firstChildElement( "colorramp" );
if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( "name" ) == "[source]" )
{
r->setSourceColorRamp( QgsSymbolLayerV2Utils::loadColorRamp( sourceColorRampElem ) );
}
QDomElement rotationElem = element.firstChildElement( "rotation" );
if ( !rotationElem.isNull() )
r->setRotationField( rotationElem.attribute( "field" ) );
QDomElement sizeScaleElem = element.firstChildElement( "sizescale" );
if ( !sizeScaleElem.isNull() )
r->setSizeScaleField( sizeScaleElem.attribute( "field" ) );
// TODO: symbol levels
return r;
}