本文整理汇总了C++中QDomNode::toAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::toAttr方法的具体用法?C++ QDomNode::toAttr怎么用?C++ QDomNode::toAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::toAttr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
}
示例2: parseNode
void XMLParser::parseNode(IEntity *entity,QDomNode *node)
{
while(!node->isNull())
{
QString namesp;
QString name;
IEntity *auxent = NULL;
QDomElement child = node->toElement();
if(!child.isNull())
{
#ifdef PARSER_DEBUG
qDebug() << child.tagName();
#endif
splitNode(child.tagName(),namesp,name);
if(name.isEmpty())
throw new XMLParserException("Unable to parse node\n");
auxent = new IEntity(namesp,name);
}
if(node->hasAttributes())
{
QDomNamedNodeMap attributes = node->attributes();
for(unsigned int i=0; i<=attributes.length(); i++)
{
QDomNode n = attributes.item(i);
if(n.isAttr())
{
#ifdef PARSER_DEBUG
qDebug() << n.toAttr().name()<< "=" << n.toAttr().value();
#endif
QString attnamesp;
QString attname;
splitNode(n.toAttr().name(),attnamesp,attname);
//TODO: add attribute with namespace
auxent->addAttribute(attname,n.toAttr().value());
}
}
}
if(node->isText())
{
#ifdef PARSER_DEBUG
qDebug() << node->toText().data();
#endif
entity->addValue(node->toText().data());
} else
entity->addEntity(auxent);
if (node->hasChildNodes())
parseNode(auxent,&node->firstChild());
node = &(node->nextSibling());
}
}
示例3: modify
void SvgImage::modify(const QString &tag, const QString &id, const QString &attribute,
const QString &value)
{
bool modified = false;
QDomNodeList nodeList = m_svgDocument.elementsByTagName( tag );
for ( int i = 0; i < nodeList.count(); ++i )
{
QDomNode node = nodeList.at( i );
QDomNamedNodeMap attributes = node.attributes();
if ( checkIDAttribute( attributes, id ) )
{
QDomNode attrElement = attributes.namedItem( attribute );
if ( attrElement.isAttr() )
{
QDomAttr attr = attrElement.toAttr();
attr.setValue( value );
modified = true;
}
}
}
if ( modified )
{
m_updateNeeded = true;
update();
}
}
示例4: QDomAttr
QDomAttr QDomNodeProto:: toAttr() const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->toAttr();
return QDomAttr();
}
示例5: mustBeDrawed
/** Returns wether the Report Section must be drawed or not depending on the DrawIf attribute and the current record values */
bool MReportSection::mustBeDrawed( QDomNode * record ) {
QString value;
QDomNamedNodeMap fields = record->attributes();
QString drawIfField = getDrawIf();
if ( !drawIfField.isEmpty() ) {
QDomNode n = fields.namedItem( drawIfField );
if ( n.isNull() )
return false;
value = n.toAttr().value();
if ( value.isEmpty() )
return false;
bool b = true;
float f = value.toFloat( &b );
if ( f == 0 && b )
return false;
}
return true;
}
示例6: checkIDAttribute
bool checkIDAttribute( const QDomNamedNodeMap& map, const QString& value )
{
QDomNode attrElement = map.namedItem( "id" );
if ( attrElement.isAttr() )
{
QDomAttr attr = attrElement.toAttr();
return attr.value() == value;
}
return false;
}
示例7: findDomNodeScan
/**
* @brief XmlEditWidgetPrivate::findDomNodeScan find the nearest match to a position
* @param node
* @param nodeTarget
* @param lineSearched
* @param columnSearched
* @param lastKnownNode: last known "good" position
* @return
*/
bool XmlEditWidgetPrivate::findDomNodeScan(QDomNode node, QDomNode nodeTarget, const int lineSearched, const int columnSearched, FindNodeWithLocationInfo &info)
{
int row = node.lineNumber();
int col = node.columnNumber();
if(!node.isDocument()) {
if((lineSearched == row) && (columnSearched == col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched == row) && (columnSearched == col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched == row) && (columnSearched < col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched < row)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched <= row)) {
info.lastKnownNode = nodeTarget ;
}
if(node.nodeType() == QDomNode::ElementNode) {
QDomElement element = node.toElement();
QDomNamedNodeMap attributes = element.attributes();
int numAttrs = attributes.length();
for(int i = 0 ; i < numAttrs ; i++) {
QDomNode node = attributes.item(i);
QDomAttr attr = node.toAttr();
if(findDomNodeScan(attr, nodeTarget, lineSearched, columnSearched, info)) {
return true;
}
} // for
}
}
int nodes = node.childNodes().count();
for(int i = 0 ; i < nodes ; i ++) {
QDomNode childNode = node.childNodes().item(i) ;
if(childNode.isText() || childNode.isCDATASection()) {
if(findDomNodeScan(childNode, nodeTarget, lineSearched, columnSearched, info)) {
return true;
}
} else {
if(findDomNodeScan(childNode, childNode, lineSearched, columnSearched, info)) {
return true ;
}
}
}
return false ;
}
示例8: processNodeAttributes
void ItemDefinitionGroup::processNodeAttributes(const QDomElement &nodeElement)
{
// process attributes
QDomNamedNodeMap namedNodeMap = nodeElement.attributes();
QDomNode domNode = namedNodeMap.item(0);
if (domNode.nodeType() == QDomNode::AttributeNode) {
QDomAttr domElement = domNode.toAttr();
if (domElement.name() == QLatin1String("Condition"))
m_condition = domElement.value();
}
}
示例9: processNodeAttributes
void DebuggerTool::processNodeAttributes(const QDomElement &element)
{
QDomNamedNodeMap namedNodeMap = element.attributes();
for (int i = 0; i < namedNodeMap.size(); ++i) {
QDomNode domNode = namedNodeMap.item(i);
if (domNode.nodeType() == QDomNode::AttributeNode) {
QDomAttr domElement = domNode.toAttr();
m_anyAttribute.insert(domElement.name(), domElement.value());
// vc_dbg << "Any AttributeNode: name: " << domElement.name() << " value: " << domElement.value();
}
}
}
示例10: processNodeAttributes
void OnError::processNodeAttributes(const QDomElement &nodeElement)
{
// process attributes
QDomNamedNodeMap namedNodeMap = nodeElement.attributes();
QDomNode domNode = namedNodeMap.item(0);
if (domNode.nodeType() == QDomNode::AttributeNode) {
QDomAttr domElement = domNode.toAttr();
if (domElement.name() == QLatin1String("Condition"))
m_condition = domElement.value();
else if (domElement.name() == QLatin1String("ExecuteTargets"))
m_executeTargets = domElement.value().split(QLatin1Char(';'));
}
}
示例11: processNodeAttributes
void Platform::processNodeAttributes(const QDomElement &element)
{
QDomNamedNodeMap namedNodeMap = element.attributes();
if (namedNodeMap.size() == 1) {
QDomNode domNode = namedNodeMap.item(0);
if (domNode.nodeType() == QDomNode::AttributeNode) {
QDomAttr domElement = domNode.toAttr();
if (domElement.name() == QString("Name")) {
m_name = domElement.value();
// vc_dbg << "AttributeNode: name: " << domElement.name() << " value: " << domElement.value();
}
}
}
}
示例12: setXMLData
void ComplexBaseInputField::setXMLData( const QDomElement &element )
{
if ( mName != element.tagName() ) {
qDebug( "ComplexBaseInputField: Wrong dom element passed: expected %s, got %s", qPrintable( mName ), qPrintable( element.tagName() ) );
return;
}
// elements
if ( mType->isArray() ) {
InputField *field = childField( "item" );
field->setXMLData( element );
} else {
QDomNode node = element.firstChild();
while ( !node.isNull() ) {
QDomElement child = node.toElement();
if ( !child.isNull() ) {
InputField *field = childField( child.tagName() );
if ( !field ) {
qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( child.tagName() ) );
} else {
field->setXMLData( child );
}
}
node = node.nextSibling();
}
}
// attributes
QDomNamedNodeMap nodes = element.attributes();
for ( int i = 0; i < nodes.count(); ++i ) {
QDomNode node = nodes.item( i );
QDomAttr attr = node.toAttr();
InputField *field = childField( attr.name() );
if ( !field ) {
qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( attr.name() ) );
} else {
field->setData( attr.value() );
}
}
}
示例13: processNodeAttributes
void Project::processNodeAttributes(const QDomElement &nodeElement)
{
// process attributes
QDomNamedNodeMap namedNodeMap = nodeElement.attributes();
for (int i = 0; i < namedNodeMap.size(); ++i) {
QDomNode domNode = namedNodeMap.item(i);
if (domNode.nodeType() == QDomNode::AttributeNode) {
QDomAttr domElement = domNode.toAttr();
if (domElement.name() == QLatin1String("DefaultTargets"))
m_defaultTargets = domElement.value().split(QLatin1Char(';'));
else if (domElement.name() == QLatin1String("InitialTargets"))
m_initialTargets = domElement.value().split(QLatin1Char(';'));
else if (domElement.name() == QLatin1String("ToolsVersion"))
m_toolsVersion = domElement.value();
else if (domElement.name() == QLatin1String("xmlns"))
m_xmlns = domElement.value();
}
}
}
示例14: processAttributes
void Item::processAttributes(const QDomElement &nodeElement)
{
// process attributes
QDomNamedNodeMap namedNodeMap = nodeElement.attributes();
for (int i = 0; i < namedNodeMap.size(); ++i) {
QDomNode domNode = namedNodeMap.item(i);
if (domNode.nodeType() == QDomNode::AttributeNode) {
QDomAttr domElement = domNode.toAttr();
if (domElement.name() == QLatin1String("Condition"))
m_condition = domElement.value();
else if (domElement.name() == QLatin1String("Include"))
m_include = domElement.value();
else if (domElement.name() == QLatin1String("Exclude"))
m_exclude = domElement.value();
else if (domElement.name() == QLatin1String("Remove"))
m_remove = domElement.value();
}
}
m_name = nodeElement.nodeName();
}
示例15: loadConfigFile
void configManager::loadConfigFile()
{
// read the XML file and create DOM tree
QFile cfg_file( m_lmmsRcFile );
QDomDocument dom_tree;
if( cfg_file.open( QIODevice::ReadOnly ) )
{
QString errorString;
int errorLine, errorCol;
if( dom_tree.setContent( &cfg_file, false, &errorString, &errorLine, &errorCol ) )
{
// get the head information from the DOM
QDomElement root = dom_tree.documentElement();
QDomNode node = root.firstChild();
// create the settings-map out of the DOM
while( !node.isNull() )
{
if( node.isElement() &&
node.toElement().hasAttributes () )
{
stringPairVector attr;
QDomNamedNodeMap node_attr =
node.toElement().attributes();
for( int i = 0; i < node_attr.count();
++i )
{
QDomNode n = node_attr.item( i );
if( n.isAttr() )
{
attr.push_back( qMakePair( n.toAttr().name(),
n.toAttr().value() ) );
}
}
m_settings[node.nodeName()] = attr;
}
else if( node.nodeName() == "recentfiles" )
{
m_recentlyOpenedProjects.clear();
QDomNode n = node.firstChild();
while( !n.isNull() )
{
if( n.isElement() && n.toElement().hasAttributes() )
{
m_recentlyOpenedProjects <<
n.toElement().attribute( "path" );
}
n = n.nextSibling();
}
}
node = node.nextSibling();
}
if( value( "paths", "artwork" ) != "" )
{
m_artworkDir = value( "paths", "artwork" );
if( !QDir( m_artworkDir ).exists() )
{
m_artworkDir = defaultArtworkDir();
}
if( m_artworkDir.right( 1 ) !=
QDir::separator() )
{
m_artworkDir += QDir::separator();
}
}
setWorkingDir( value( "paths", "workingdir" ) );
setVSTDir( value( "paths", "vstdir" ) );
setFLDir( value( "paths", "fldir" ) );
setLADSPADir( value( "paths", "laddir" ) );
#ifdef LMMS_HAVE_STK
setSTKDir( value( "paths", "stkdir" ) );
#endif
#ifdef LMMS_HAVE_FLUIDSYNTH
setDefaultSoundfont( value( "paths", "defaultsf2" ) );
#endif
setBackgroundArtwork( value( "paths", "backgroundartwork" ) );
}
else
{
QMessageBox::warning( NULL, MainWindow::tr( "Configuration file" ),
MainWindow::tr( "Error while parsing configuration file at line %1:%2: %3" ).
arg( errorLine ).
arg( errorCol ).
arg( errorString ) );
}
cfg_file.close();
}
if( m_vstDir.isEmpty() || m_vstDir == QDir::separator() ||
!QDir( m_vstDir ).exists() )
{
#ifdef LMMS_BUILD_WIN32
m_vstDir = windowsConfigPath( CSIDL_PROGRAM_FILES ) +
QDir::separator() + "VstPlugins";
#else
m_vstDir = ensureTrailingSlash( QDir::home().absolutePath() );
//.........这里部分代码省略.........