本文整理汇总了C++中QDomNamedNodeMap::namedItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNamedNodeMap::namedItem方法的具体用法?C++ QDomNamedNodeMap::namedItem怎么用?C++ QDomNamedNodeMap::namedItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNamedNodeMap
的用法示例。
在下文中一共展示了QDomNamedNodeMap::namedItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSingleFrameAsset
bool DefinitionParser::createSingleFrameAsset (QDomNode& node, const Content::Class clazz, const QString& tag)
{
QDomNamedNodeMap attr = node.attributes();
const QString name = attr.namedItem(ATTR_CLASS).nodeValue();
const QString pathattr = attr.namedItem(ATTR_PATH).nodeValue();
if (pathattr.isEmpty()) {
warnMissingAttr(ATTR_PATH, tag);
return false;
}
const QString path = _targetDir.absoluteFilePath(pathattr);
if (!checkPathExists(path)) {
return false;
}
if (name.isEmpty()) {
warnMissingAttr(ATTR_CLASS, tag);
return false;
}
if (clazz == Content::SPRITE || clazz == Content::MOVIECLIP) {
struct AssetBit asset;
asset.path = _tempDir.relativeFilePath(path);
copyAttributes(&asset, attr);
struct SpriteAsset* sprite = new SpriteAsset();
sprite->assets.push_back(asset);
sprite->clazz = clazz;
sprite->name = name;
_assets[name] = sprite;
} else {
struct Asset* common = new Asset();
common->path = path;
common->name = name;
_assets[name] = common;
}
return true;
}
示例2: searchFinished
void WSettings::searchFinished(QNetworkReply *reply)
{
reply->deleteLater();
ui.addButton->setEnabled(true);
ui.searchEdit->clear();
QDomDocument doc;
if (!doc.setContent(reply->readAll()))
return;
QDomElement rootElement = doc.documentElement();
QDomNodeList locations = rootElement.elementsByTagName(QLatin1String("location"));
if (locations.isEmpty())
ui.searchEdit->addItem(tr("Not found"));
for (int i = 0; i < locations.count(); i++) {
QDomNamedNodeMap attributes = locations.at(i).attributes();
QString cityId = attributes.namedItem(QLatin1String("location")).nodeValue();
QString cityName = attributes.namedItem(QLatin1String("city")).nodeValue();
QString stateName = attributes.namedItem(QLatin1String("state")).nodeValue();
QString cityFullName = cityName + ", " + stateName;
int index = ui.searchEdit->count();
ui.searchEdit->addItem(cityFullName);
ui.searchEdit->setItemData(index, cityId, CodeRole);
ui.searchEdit->setItemData(index, cityName, CityRole);
ui.searchEdit->setItemData(index, stateName, StateRole);
}
}
示例3: copyAttributes
void DefinitionParser::copyAttributes (AssetBit* asset, const QDomNamedNodeMap& attributes) const
{
asset->x = attributes.namedItem(ATTR_X).nodeValue();
asset->y = attributes.namedItem(ATTR_Y).nodeValue();
asset->alpha = attributes.namedItem(ATTR_ALPHA).nodeValue();
asset->visible = attributes.namedItem(ATTR_VISIBLE).nodeValue();
}
示例4: data
QVariant MetricDomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
DomItem *item = static_cast<DomItem*>(index.internalPointer());
QDomNode node = item->node();
QStringList attributes;
QDomNamedNodeMap attributeMap = node.attributes();
switch (index.column()) {
case 0:
return node.nodeName();
case 1:
if( !attributeMap.contains("Type") ) {
return QVariant();
}
return attributeMap.namedItem("Type").nodeValue();
case 2:
if( !attributeMap.contains("Format") ) {
return QVariant();
}
return attributeMap.namedItem("Format").nodeValue();
default:
return QVariant();
}
}
示例5:
bool CAnm2DXml::loadLayers(QDomNode node, AnmLayer *pParent)
{
while ( !node.isNull() ) {
if ( node.nodeName() == kAnmXML_ID_Layer ) {
QDomNamedNodeMap nodeMap = node.attributes() ;
if ( nodeMap.namedItem(kAnmXML_Attr_Name).isNull()
|| nodeMap.namedItem(kAnmXML_Attr_FrameNum).isNull()
|| nodeMap.namedItem(kAnmXML_Attr_ChildNum).isNull() ) {
return false ;
}
QString name ;
int frameDataNum = 0 ;
int childNum = 0 ;
name = nodeMap.namedItem(kAnmXML_Attr_Name).toAttr().value() ;
frameDataNum = nodeMap.namedItem(kAnmXML_Attr_FrameNum).toAttr().value().toInt() ;
childNum = nodeMap.namedItem(kAnmXML_Attr_ChildNum).toAttr().value().toInt() ;
AnmLayer *pLayer = new AnmLayer ;
pLayer->pParentLayer = pParent ;
pParent->childPtrs.append(pLayer) ;
QDomNode child = node.firstChild() ;
if ( !loadFrameData(child, pLayer, frameDataNum) ) {
return false ;
}
QDomNode layers = node.firstChild() ;
if ( !loadLayers(layers, pLayer) ) {
return false ;
}
}
node = node.nextSibling() ;
}
return true ;
}
示例6: createMultiFrameSprite
bool DefinitionParser::createMultiFrameSprite (QDomNode& frame, const Content::Class clazz)
{
QDomNode parent = frame.parentNode();
QDomNamedNodeMap attributes = parent.attributes();
const QString childName = clazz == Content::MOVIECLIP ? ::NODE_FRAME : ::NODE_OBJECT;
const QString className = attributes.namedItem(ATTR_CLASS).nodeValue();
const QString basePath = attributes.namedItem(ATTR_PATH).nodeValue();
const QString absBasePath = _targetDir.absoluteFilePath(basePath);
struct SpriteAsset* sprite = NULL;
if (!QFile::exists(absBasePath)) {
info("base path \'" + absBasePath + "\' does not exist");
return false;
}
while (!frame.isNull()) {
QDomElement e = frame.toElement();
QDomNamedNodeMap attr = frame.attributes();
checkAttributes(frame);
frame = frame.nextSibling();
if (e.isNull()) {
continue;
}
const QString tn = e.tagName();
if (tn != childName) {
warnInvalidTag(tn, frame.parentNode().nodeName());
continue;
}
const QString relpath = attr.namedItem(ATTR_PATH).nodeValue();
if (attr.isEmpty() || relpath.isEmpty()) {
warnMissingAttr(ATTR_PATH, tn);
continue;
}
const QString path = _targetDir.absoluteFilePath(basePath + relpath);
if (!checkPathExists(path)) {
continue;
}
struct AssetBit asset;
asset.name = attr.namedItem(ATTR_NAME).nodeValue();
asset.path = _tempDir.relativeFilePath(path);
copyAttributes(&asset, attr);
if (!sprite) {
sprite = new SpriteAsset();
}
sprite->assets.push_back(asset);
}
if (sprite) {
sprite->clazz = clazz;
sprite->name = className;
copyAttributes(sprite, attributes);
_assets[className] = sprite;
}
return true;
}
示例7: QPointF
SBGNPort::SBGNPort(QDomNode node)
{
QDomNamedNodeMap attrs = node.attributes();
float x = attrs.namedItem("x").toAttr().value().toFloat();
float y = attrs.namedItem("y").toAttr().value().toFloat();
m_pos = QPointF(x,y);
m_id = attrs.namedItem("id").toAttr().value();
}
示例8: LOG
/******************************************************************************
PopulateComponent
******************************************************************************/
void
CUpdateInfoGetter::PopulateComponent(
const QDomNode &appNode,
CComponentInfo& info)
{
//TODO: sanity check xml
//if (vecStrings.size() != 5)
//{
// Q_ASSERT(false);
// throw ConnectionException(QT_TR_NOOP("Downloaded update info for "
// "component didn't contain the correct number of entries."));
//}
info.Clear();
QDomNamedNodeMap appAttributes = appNode.attributes();
info.SetName(appAttributes.namedItem( "name" ).nodeValue());
#ifdef WIN32
string sPF = UnicornUtils::programFilesPath();
if (sPF == "")
{
// Do our best at faking it. Will at least work some of the time.
LOG(1, "Couldn't get PF path so trying to fake it.");
sPF = "C:\\Program Files\\";
}
info.SetPath(QString::fromStdString(sPF) +
appNode.firstChildElement("Path").text());
#else // not WIN32
info.SetPath(appNode.firstChildElement("Path").text());
#endif // WIN32
if ( !appNode.firstChildElement("Size").isNull() )
info.SetSize( appNode.firstChildElement("Size").text().toInt() );
else
info.SetSize( 0 );
info.SetDownloadURL ( appNode.firstChildElement("Url").text() );
info.SetVersion ( appAttributes.namedItem( "version" ).nodeValue() );
info.SetInstallArgs ( appNode.firstChildElement("Args").text() );
if( appAttributes.contains( "majorUpgrade" )) {
info.SetMajorUpgrade( appAttributes.namedItem( "majorUpgrade" ).nodeValue()
== "true" );
}
if( !appNode.firstChildElement("Description").isNull())
info.SetDescription( appNode.firstChildElement("Description").text());
if( !appNode.firstChildElement("Image").isNull())
info.SetImage( QUrl( appNode.firstChildElement("Image").text()));
}
示例9: if
void
operator <<= (Miro::SensorGroupIDL& group, const QDomNode& node)
{
if (!node.isNull()) {
// set sensor defaults
Miro::SensorPositionIDL sensor;
sensor.masked = false;
QDomNamedNodeMap map = node.attributes();
QDomNode n;
n = map.namedItem("height");
if (!n.isNull()) {
QDomAttr attr = n.toAttr();
if (!attr.isNull())
sensor.height = attr.value().toInt();
}
n = map.namedItem("distance");
if (!n.isNull()) {
QDomAttr attr = n.toAttr();
if (!attr.isNull())
sensor.distance =attr.value().toInt();
}
n = map.namedItem("alpha");
if (!n.isNull()) {
QDomAttr attr = n.toAttr();
if (!attr.isNull())
sensor.alpha = deg2Rad(attr.value().toDouble());
}
n = map.namedItem("beta");
if (!n.isNull()) {
QDomAttr attr = n.toAttr();
if (!attr.isNull())
sensor.beta = deg2Rad(attr.value().toDouble());
}
n = map.namedItem("gamma");
if (!n.isNull()) {
QDomAttr attr = n.toAttr();
if (!attr.isNull())
sensor.gamma = deg2Rad(attr.value().toDouble());
}
QDomNode n1 = node.firstChild();
while(!n1.isNull() ) {
if (n1.nodeName() == "description") {
group.description <<= n1;
}
else if (n1.nodeName() == "sensor") {
group.sensor.length(group.sensor.length() + 1);
group.sensor[group.sensor.length() - 1] = sensor;
group.sensor[group.sensor.length() - 1] <<= n1;
}
n1 = n1.nextSibling();
}
}
}
示例10: createToolbar
void mafGUIManager::createToolbar(QDomElement node) {
QDomNamedNodeMap attributes = node.attributes();
QString title = attributes.namedItem("title").nodeValue();
QString actions = attributes.namedItem("actionList").nodeValue();
QToolBar *toolBar = m_MainWindow->addToolBar(tr(title.toAscii().constData()));
QStringList actionList = actions.split(",");
foreach (QString action, actionList) {
toolBar->addAction((QAction*)menuItemByName(action));
}
示例11: loadFlowKnots
void loadFlowKnots(const QDomNamedNodeMap& _nodeMap, Flow* _flow)
{
int count = _nodeMap.namedItem("KnotsCount").toAttr().value().toInt();
QList<QPointF> list;
for (int i = 0; i < count; ++i) {
QPointF pt = QPointF(
_nodeMap.namedItem("KnotX_" + QString::number(i)).toAttr().value().toDouble(),
_nodeMap.namedItem("KnotY_" + QString::number(i)).toAttr().value().toDouble()
);
list << pt;
}
_flow->setFlowKnots(list);
}
示例12: parseFile
void ColourParser::parseFile() {
QDomNodeList colourList = doc.elementsByTagName("MabiSysPalette");
for (int i = 0; i < colourList.count(); i++) {
QDomNode colour = colourList.at(i);
QDomNamedNodeMap attributes = colour.attributes();
ColourParser::Object *c = new ColourParser::Object;
c->name = localeMap->getValue(attributes.namedItem("nameLocal").nodeValue());
c->colourID = attributes.namedItem("number").nodeValue().toInt();
c->argb = QColor("#" + attributes.namedItem("RGB").nodeValue());
colours.append(c);
}
}
示例13: parseDescriptionAttributes
// -------------------------------------------------------------------------------
void XMLPersister::parseDescriptionAttributes( QDomElement& elem,
CTreeInformationElement& informationElem )
// -------------------------------------------------------------------------------
{
QDomNamedNodeMap attributes = elem.attributes();
if ( !attributes.namedItem("color").isNull() )
{
QColor c( attributes.namedItem("color").toAttr().value() );
Q_ASSERT( c.isValid() );
informationElem.setDescriptionColor( c );
}
}
示例14: setSectionAttributes
/** Sets the layout attributes for the given report section */
void MReportEngine::setSectionAttributes(MReportSection *section, QDomNode *report)
{
// Get the attributes for the section
QDomNamedNodeMap attributes = report->attributes();
// Get the section attributes
section->setHeight(attributes.namedItem("Height").nodeValue().toInt());
section->setPrintFrequency(attributes.namedItem("PrintFrequency").nodeValue().toInt());
if (attributes.contains("SectionId"))
section->setIdSec(attributes.namedItem("SectionId").nodeValue().toUInt());
// Process the sections labels
QDomNodeList children = report->childNodes();
int childCount = children.length();
// For each label, extract the attr list and add the new label
// to the sections's label collection
for (int j = 0; j < childCount; j++) {
QDomNode child = children.item(j);
if (child.nodeType() == QDomNode::ElementNode) {
if (child.nodeName() == "Line") {
QDomNamedNodeMap attributes = child.attributes();
MLineObject *line = new MLineObject();
setLineAttributes(line, &attributes);
section->addLine(line);
} else if (child.nodeName() == "Label") {
QDomNamedNodeMap attributes = child.attributes();
MLabelObject *label = new MLabelObject();
setLabelAttributes(label, &attributes);
section->addLabel(label);
} else if (child.nodeName() == "Special") {
QDomNamedNodeMap attributes = child.attributes();
MSpecialObject *field = new MSpecialObject();
setSpecialAttributes(field, &attributes);
section->addSpecialField(field);
} else if (child.nodeName() == "CalculatedField") {
QDomNamedNodeMap attributes = child.attributes();
MCalcObject *field = new MCalcObject();
setCalculatedFieldAttributes(field, &attributes);
section->addCalculatedField(field);
}
}
}
}
示例15: QRectF
void
StationsPluginFactorySimple::loadCity(const QDomNode & city)
{
QDomNode node;
QPointF min, max;
QDomNamedNodeMap attrs;
StationsPluginSimplePrivate data;
attrs = city.attributes();
data.id = attrs.namedItem("id").nodeValue();
node = city.firstChildElement("latitude");
attrs = node.attributes();
data.center.setX(node.toElement().text().toDouble());
min.setX(attrs.namedItem("min").nodeValue().toDouble());
max.setX(attrs.namedItem("max").nodeValue().toDouble());
node = city.firstChildElement("longitude");
attrs = node.attributes();
data.center.setY(node.toElement().text().toDouble());
min.setY(attrs.namedItem("min").nodeValue().toDouble());
max.setY(attrs.namedItem("max").nodeValue().toDouble());
data.rect = QRectF(min, max);
data.statusUrl = city.firstChildElement("status").text();
data.infosUrl = city.firstChildElement("infos").text();
data.name = city.firstChildElement("name").text();
data.bikeName = city.firstChildElement("bikeName").text();
data.type = city.firstChildElement("type").text();
QString icon = city.firstChildElement("bikeIcon").text();
if (icon.isEmpty())
icon = ":/res/bike.png";
data.bikeIcon = QIcon(icon);
if (data.id.isEmpty() || !data.rect.isValid() || data.center.isNull() ||
data.name.isEmpty() || data.bikeName.isEmpty() || data.type.isEmpty()) {
qWarning() << "Error processing city " << data.id
<< data.name << data.bikeName << data.type;
return ;
}
cities[data.id] = data;
}