当前位置: 首页>>代码示例>>C++>>正文


C++ QDomElement::removeAttribute方法代码示例

本文整理汇总了C++中QDomElement::removeAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::removeAttribute方法的具体用法?C++ QDomElement::removeAttribute怎么用?C++ QDomElement::removeAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDomElement的用法示例。


在下文中一共展示了QDomElement::removeAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: stripAnswers

QString XmlUtil::stripAnswers(const QString &input) {
	QDomDocument doc;
	doc.setContent(input);
	QDomElement docElem = doc.documentElement();

	QDomNode n = docElem.firstChild();
	while ( !n.isNull() ) {
		QDomElement e = n.toElement();
		if ( !e.isNull() && (e.namespaceURI().isEmpty() || e.namespaceURI() == XML_NS) ) {
			if ( e.nodeName() == "choose" ) {
				QDomElement c = e.firstChildElement("choice");
				while ( !c.isNull() ) {
					c.removeAttribute("answer");
					c = c.nextSiblingElement("choice");
				}
			} else if ( e.nodeName() == "identification" ) {
				QDomElement a = e.firstChildElement("a");
				while ( !a.isNull() ) {
					e.removeChild(a);
					a = e.firstChildElement("a");
				}
			}
		}
		n = n.nextSibling();
	}
	return doc.toString(2);
}
开发者ID:trigger-happy,项目名称:Cerberus,代码行数:27,代码来源:xml_util.cpp

示例2: sipReleaseType

static PyObject *meth_QDomElement_removeAttribute(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QString * a0;
        int a0State = 0;
        QDomElement *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QDomElement, &sipCpp, sipType_QString,&a0, &a0State))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->removeAttribute(*a0);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QDomElement, sipName_removeAttribute, NULL);

    return NULL;
}
开发者ID:ClydeMojura,项目名称:android-python27,代码行数:26,代码来源:sipQtXmlQDomElement.cpp

示例3: elem

/**
 * Update DOM tree element
 */
void
GEdge::updateElement()
{
#if 0    
    QDomElement e = elem();
    int i = 0;
    QDomElement new_e = graph()->createElement( "edge");
    QDomNode e2 = graph()->documentElement().removeChild( e);
    assert( !e2.isNull());
    graph()->documentElement().appendChild( new_e);
    setElement( new_e);
    e = new_e;
#endif
    /* Base class method call to print generic edge properties */
    AuxEdge::updateElement();
    QDomElement e = elem();
    /** Save style that describes this edge only along with edge */
    if ( isNotNullP( style())) 
    {     
        if ( 1 == style()->numItems())
        {
            e.removeAttribute("style");
            style()->writeElement( e, false);
        } else
        {
            e.setAttribute("style", style()->name());
        }
    }

}
开发者ID:ChunHungLiu,项目名称:codequery,代码行数:33,代码来源:edge_item.cpp

示例4: todoToDom

bool LocalXmlBackend::todoToDom(const OpenTodoList::ITodo *todo, QDomDocument &doc)
{
  QDomElement root = doc.documentElement();
  if ( !root.isElement() ) {
    root = doc.createElement( "todo" );
    doc.appendChild( root );
  }
  root.setAttribute( "id", todo->uuid().toString() );
  root.setAttribute( "title", todo->title() );
  root.setAttribute( "done", todo->done() ? "true" : "false" );
  root.setAttribute( "priority", todo->priority() );
  root.setAttribute( "weight", todo->weight() );
  if ( todo->dueDate().isValid() ) {
    root.setAttribute( "dueDate", todo->dueDate().toString() );
  } else {
    root.removeAttribute( "dueDate" );
  }
  QDomElement descriptionElement = root.firstChildElement( "description" );
  if ( !descriptionElement.isElement() ) {
    descriptionElement = doc.createElement( "description" );
    root.appendChild( descriptionElement );
  }
  while ( !descriptionElement.firstChild().isNull() ) {
    descriptionElement.removeChild( descriptionElement.firstChild() );
  }
  QDomText descriptionText = doc.createTextNode( todo->description() );
  descriptionElement.appendChild( descriptionText );
  return true;
}
开发者ID:uglide,项目名称:opentodolist,代码行数:29,代码来源:localxmlbackend.cpp

示例5: setNodeAttr

/*
 * We don't want to have empty node attributes, so we remove them
 * if we are supplied an empty value.
 */
void Util::setNodeAttr(QDomElement &node, const QString &attr_name,
                       const QString &attr_val) {
    if (attr_val != "") {
        node.setAttribute(attr_name, attr_val);
    } else {
        node.removeAttribute(attr_name);
    }
}
开发者ID:burillo-se,项目名称:bfd3me,代码行数:12,代码来源:util.cpp

示例6: startFormat

QDomElement KWDWriter::startFormat(const QDomElement &paragraph,
                                   const QDomElement &formatToClone)
{
    QDomElement format = formatToClone.cloneNode().toElement();
    if (format.isNull()) {
        kWarning(30503) << "startFormat: null format cloned";
    }
    if (paragraph.isNull()) {
        kWarning(30503) << "startFormat on empty paragraph";
    }

    format.removeAttribute("len");
    format.removeAttribute("pos");
    format.removeAttribute("id");
    for (QDomElement a = format.firstChild().toElement();!a.isNull();a = a.nextSibling().toElement()) {
        if (a.tagName() == "ANCHOR") {
            format.removeChild(a);
        }
    }
    paragraph.elementsByTagName("FORMATS").item(0).appendChild(format);
    return format;
}
开发者ID:KDE,项目名称:calligra-history,代码行数:22,代码来源:kwdwriter.cpp

示例7: saveSettings

void SetupPluginsDialog::saveSettings()
{
	QMap<QTableWidgetItem *, QDomElement>::iterator it = FItemElement.begin();
	while (it != FItemElement.end())
	{
		QDomElement pluginElem = it.value();
		if (it.key()->checkState() == Qt::Checked)
			pluginElem.removeAttribute("enabled");
		else
			pluginElem.setAttribute("enabled","false");
		it++;
	}
	FPluginManager->setLocale((QLocale::Language)ui.cmbLanguage->itemData(ui.cmbLanguage->currentIndex()).toInt(), (QLocale::Country)ui.cmbCountry->itemData(ui.cmbCountry->currentIndex()).toInt());
}
开发者ID:RandomWalkEagle,项目名称:Contacts,代码行数:14,代码来源:setuppluginsdialog.cpp

示例8: eraseAttribute

void parserxml::eraseAttribute(std::string pNodeDirection, std::string pNameAttribute)
{
    if(isRoot(pNodeDirection))
    {
        _document.firstChild().toElement().removeAttribute(QString::fromStdString(pNameAttribute));
    }
    else
    {
        QDomElement childaux = tourXML(pNodeDirection);
        childaux.removeAttribute(QString::fromStdString(pNameAttribute));
    }
    qDebug() << "Atributo borrado con exito.";
    updateDocument();
}
开发者ID:jloaiza,项目名称:NewDiglet,代码行数:14,代码来源:parserxml.cpp

示例9: undoRemoveBookmark

void BookmarkWidget::undoRemoveBookmark(QTreeWidgetItem* item)
{
    QString caption = item->text(TITLE_COLUMN);
    QString uuid = item->text(UUID_COLUMN);
    QString path = item->text(2);
    path.append(QDir::separator() + QString("BookMark") + QDir::separator() + QString("bookmarks.xml"));

    caption = caption.split("</font>")[0].split("<font color=\"gray\">")[1];
    item->setText(TITLE_COLUMN, caption);
    item->setText(3, QString::number(1));

    QDomDocument doc;
    qDebug()<<"in undo"<<path;
    QDomElement elt = findElementbyUUID(doc, uuid, BOOKMARK, path);
    if(elt.isNull() || elt.attribute("isHidden") != QString("True")) return;
    elt.removeAttribute("isHidden");
    saveDOMToFile(doc, path);
    refreshBookmarkList();
}
开发者ID:WeiqiJust,项目名称:CHER-Ob,代码行数:19,代码来源:bookmarkWidget.cpp

示例10: slotSaveGroup

void CollapsibleGroup::slotSaveGroup()
{
    QString name = QInputDialog::getText(this, i18n("Save Group"), i18n("Name for saved group: "), QLineEdit::Normal, m_title->text());
    if (name.isEmpty()) return;
    QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/effects/");
    if (!dir.exists()) {
        dir.mkpath(QStringLiteral("."));
    }

    if (dir.exists(name + ".xml")) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", name + ".xml")) == KMessageBox::No) return;

    QDomDocument doc = effectsData();
    QDomElement base = doc.documentElement();
    QDomNodeList effects = base.elementsByTagName(QStringLiteral("effect"));
    for (int i = 0; i < effects.count(); ++i) {
	QDomElement eff = effects.at(i).toElement();
        eff.removeAttribute(QStringLiteral("kdenlive_ix"));
	EffectInfo info;
	info.fromString(eff.attribute(QStringLiteral("kdenlive_info")));
	// Make sure all effects have the correct new group name
	info.groupName = name;
	// Saved effect group should have a group index of -1
	info.groupIndex = -1;
	eff.setAttribute(QStringLiteral("kdenlive_info"), info.toString());

    }
    
    base.setAttribute(QStringLiteral("name"), name);
    base.setAttribute(QStringLiteral("id"), name);
    base.setAttribute(QStringLiteral("type"), QStringLiteral("custom"));  

    QFile file(dir.absoluteFilePath(name + ".xml"));
    if (file.open(QFile::WriteOnly | QFile::Truncate)) {
        QTextStream out(&file);
        out << doc.toString();
    }
    file.close();
    emit reloadEffects();
}
开发者ID:JongHong,项目名称:kdenlive,代码行数:39,代码来源:collapsiblegroup.cpp

示例11: flattenChildren

void SvgFlattener::flattenChildren(QDomElement &element){

    // recurse the children
    QDomNodeList childList = element.childNodes();

    for(uint i = 0; i < childList.length(); i++){
        QDomElement child = childList.item(i).toElement();
        flattenChildren(child);
    }

    //do translate
    if(hasTranslate(element)){
		QList<double> params = TextUtils::getTransformFloats(element);
		if (params.size() == 2) {
            shiftChild(element, params.at(0), params.at(1), false);
			//DebugDialog::debug(QString("translating %1 %2").arg(params.at(0)).arg(params.at(1)));
		}
		else if (params.size() == 6) {
            shiftChild(element, params.at(4), params.at(5), false);
		}
		else if (params.size() == 1) {
            shiftChild(element, params.at(0), 0, false);
			//DebugDialog::debug(QString("translating %1").arg(params.at(0)));
		}
		else {
			DebugDialog::debug("weird transform found");
		}
    }
    else if(hasOtherTransform(element)) {
        QMatrix transform = TextUtils::transformStringToMatrix(element.attribute("transform"));

        //DebugDialog::debug(QString("rotating %1 %2 %3 %4 %5 %6").arg(params.at(0)).arg(params.at(1)).arg(params.at(2)).arg(params.at(3)).arg(params.at(4)).arg(params.at(5)));
        unRotateChild(element, transform);
    }

    // remove transform
    element.removeAttribute("transform");
}
开发者ID:Ipallis,项目名称:Fritzing,代码行数:38,代码来源:svgflattener.cpp

示例12: splitString

bool SvgFileSplitter::splitString(QString & contents, const QString & elementID)
{
	m_byteArray.clear();

	// gets rid of some crap inserted by illustrator which can screw up polygons and paths
	contents.replace('\t', ' ');
	contents.replace('\n', ' ');
	contents.replace('\r', ' ');

	// get rid of inkscape stuff too
	TextUtils::cleanSodipodi(contents);

	QString errorStr;
	int errorLine;
	int errorColumn;

	if (!m_domDocument.setContent(contents, true, &errorStr, &errorLine, &errorColumn)) {
        //DebugDialog::debug(QString("parse error: %1 l:%2 c:%3\n\n%4").arg(errorStr).arg(errorLine).arg(errorColumn).arg(contents));
		return false;
	}

	QDomElement root = m_domDocument.documentElement();
	if (root.isNull()) {
		return false;
	}

	if (root.tagName() != "svg") {
		return false;
	}

	root.removeAttribute("space");

	QDomElement element = TextUtils::findElementWithAttribute(root, "id", elementID);
	if (element.isNull()) {
		return false;
	}

	QStringList superTransforms;
	QDomNode parent = element.parentNode();
	while (!parent.isNull()) {
		QDomElement e = parent.toElement();
		if (!e.isNull()) {
			QString transform = e.attribute("transform");
			if (!transform.isEmpty()) {
				superTransforms.append(transform);
			}
		}
		parent = parent.parentNode();
	}

	if (!superTransforms.isEmpty()) {
		element.removeAttribute("id");
	}

	QDomDocument document;
	QDomNode node = document.importNode(element, true);
	document.appendChild(node);
	QString elementText = document.toString();

	if (!superTransforms.isEmpty()) {
		for (int i = 0; i < superTransforms.count() - 1; i++) {
			elementText = QString("<g transform='%1'>%2</g>").arg(superTransforms[i]).arg(elementText);
		}
		elementText = QString("<g id='%1' transform='%2'>%3</g>")
			.arg(elementID)
			.arg(superTransforms[superTransforms.count() - 1])
			.arg(elementText);
	}

	while (!root.firstChild().isNull()) {
		root.removeChild(root.firstChild());
	}

	// at this point the document should contain only the <svg> element and possibly svg info strings
	QString svgOnly = m_domDocument.toString();
	int ix = svgOnly.lastIndexOf("/>");
	if (ix < 0) return false;

	svgOnly[ix] = ' ';
	svgOnly += elementText;
	svgOnly += "</svg>";

	if (!m_domDocument.setContent(svgOnly, true, &errorStr, &errorLine, &errorColumn)) {
		return false;
	}

	m_byteArray = m_domDocument.toByteArray();

	//QString s = m_domDocument.toString();
	//DebugDialog::debug(s);

	return true;
}
开发者ID:DHaylock,项目名称:fritzing-app,代码行数:93,代码来源:svgfilesplitter.cpp

示例13: main

int main(int argc, char *argv[])
{
#if QT_VERSION < 0x050000
	qInstallMsgHandler(myMessageHandler);
#else
	qInstallMessageHandler(myMessageHandler);
#endif
	QCoreApplication app(argc, argv);

	if (argc != 2)
	{
		qCritical("Usage: autotranslate <target-dir>");
		return -1;
	}

	QDir srcDir(app.arguments().value(1),"*.ts",QDir::Name,QDir::Files);
	if (!srcDir.exists())
	{
		qCritical("Source directory '%s' not found.",srcDir.dirName().toLocal8Bit().constData());
		return -1;
	}

	QDirIterator srcIt(srcDir);
	while (srcIt.hasNext())
	{
		QFile srcFile(srcIt.next());
		if (srcFile.open(QFile::ReadOnly))
		{
			QDomDocument doc;
			if (doc.setContent(&srcFile,true))
			{
				qDebug("Generation auto translation from '%s'.",srcFile.fileName().toLocal8Bit().constData());

				QDomElement rootElem = doc.firstChildElement("TS");
				rootElem.setAttribute("language",rootElem.attribute("sourcelanguage","en"));
				
				QDomElement contextElem = rootElem.firstChildElement("context");
				while(!contextElem.isNull())
				{
					QDomElement messageElem = contextElem.firstChildElement("message");
					while(!messageElem.isNull())
					{
						QDomElement sourceElem = messageElem.firstChildElement("source");
						QDomElement translationElem = messageElem.firstChildElement("translation");
						if (!sourceElem.isNull() && !translationElem.isNull())
							if (translationElem.attribute("type")=="unfinished" && translationElem.text().isEmpty())
							{
								QString sourceText = sourceElem.text();
								if (messageElem.attribute("numerus") == "yes")
									qWarning("Untranslated numerus message: \"%s\"", sourceText.toLocal8Bit().constData());
								else
								{
									translationElem.removeChild(translationElem.firstChild());
									translationElem.appendChild(doc.createTextNode(sourceText));
									translationElem.removeAttribute("type");
								}
							}
						messageElem = messageElem.nextSiblingElement("message");
					}
					contextElem = contextElem.nextSiblingElement("context");
				}
				srcFile.close();
				if (srcFile.open(QFile::WriteOnly|QFile::Truncate))
				{
					srcFile.write(doc.toByteArray());
					srcFile.close();
				}
				else
					qWarning("Failed to open destination file '%s' for write.",srcFile.fileName().toLocal8Bit().constData());
			}
			else
				qWarning("Invalid translation source file '%s'.",srcFile.fileName().toLocal8Bit().constData());
			srcFile.close();
		}
		else
			qWarning("Could not open translation source file '%s'.",srcFile.fileName().toLocal8Bit().constData());
	}
	return 0;
}
开发者ID:RoadWorksSoftware,项目名称:eyecu-qt,代码行数:79,代码来源:autotranslate.cpp

示例14: eraseAttribute

void parserxml::eraseAttribute(std::string pChildDirection, std::string pAttribute)
{
    QDomElement childaux = tourXML(pChildDirection);
    childaux.removeAttribute(QString::fromStdString(pAttribute));
}
开发者ID:jloaiza,项目名称:dugtrio,代码行数:5,代码来源:parserxml.cpp

示例15: if

void QgsProjectFileTransform::transform1800to1900()
{
  if ( mDom.isNull() )
  {
    return;
  }

  QDomNodeList layerItemList = mDom.elementsByTagName( "rasterproperties" );
  for ( int i = 0; i < layerItemList.size(); ++i )
  {
    QDomElement rasterPropertiesElem = layerItemList.at( i ).toElement();
    QDomNode layerNode = rasterPropertiesElem.parentNode();
    QDomElement dataSourceElem = layerNode.firstChildElement( "datasource" );
    QDomElement layerNameElem = layerNode.firstChildElement( "layername" );
    QgsRasterLayer rasterLayer;
    // TODO: We have to use more data from project file to read the layer it correctly,
    // OTOH, we should not read it until it was converted
    rasterLayer.readXML( layerNode );
    convertRasterProperties( mDom, layerNode, rasterPropertiesElem, &rasterLayer );
  }

  //composer: replace mGridAnnotationPosition with mLeftGridAnnotationPosition & co.
  // and mGridAnnotationDirection with mLeftGridAnnotationDirection & co.
  QDomNodeList composerMapList = mDom.elementsByTagName( "ComposerMap" );
  for ( int i = 0; i < composerMapList.size(); ++i )
  {
    QDomNodeList gridList = composerMapList.at( i ).toElement().elementsByTagName( "Grid" );
    for ( int j = 0; j < gridList.size(); ++j )
    {
      QDomNodeList annotationList = gridList.at( j ).toElement().elementsByTagName( "Annotation" );
      for ( int k = 0; k < annotationList.size(); ++k )
      {
        QDomElement annotationElem = annotationList.at( k ).toElement();

        //position
        if ( annotationElem.hasAttribute( "position" ) )
        {
          int pos = annotationElem.attribute( "position" ).toInt();
          annotationElem.setAttribute( "leftPosition", pos );
          annotationElem.setAttribute( "rightPosition", pos );
          annotationElem.setAttribute( "topPosition", pos );
          annotationElem.setAttribute( "bottomPosition", pos );
          annotationElem.removeAttribute( "position" );
        }

        //direction
        if ( annotationElem.hasAttribute( "direction" ) )
        {
          int dir = annotationElem.attribute( "direction" ).toInt();
          if ( dir == 2 )
          {
            annotationElem.setAttribute( "leftDirection", 0 );
            annotationElem.setAttribute( "rightDirection", 0 );
            annotationElem.setAttribute( "topDirection", 1 );
            annotationElem.setAttribute( "bottomDirection", 1 );
          }
          else if ( dir == 3 )
          {
            annotationElem.setAttribute( "leftDirection", 1 );
            annotationElem.setAttribute( "rightDirection", 1 );
            annotationElem.setAttribute( "topDirection", 0 );
            annotationElem.setAttribute( "bottomDirection", 0 );
          }
          else
          {
            annotationElem.setAttribute( "leftDirection", dir );
            annotationElem.setAttribute( "rightDirection", dir );
            annotationElem.setAttribute( "topDirection", dir );
            annotationElem.setAttribute( "bottomDirection", dir );
          }
          annotationElem.removeAttribute( "direction" );
        }
      }
    }
  }

  //Composer: move all items under Composition element
  QDomNodeList composerList = mDom.elementsByTagName( "Composer" );
  for ( int i = 0; i < composerList.size(); ++i )
  {
    QDomElement composerElem = composerList.at( i ).toElement();

    //find <QgsComposition element
    QDomElement compositionElem = composerElem.firstChildElement( "Composition" );
    if ( compositionElem.isNull() )
    {
      continue;
    }

    QDomNodeList composerChildren = composerElem.childNodes();

    if ( composerChildren.size() < 1 )
    {
      continue;
    }

    for ( int j = composerChildren.size() - 1; j >= 0; --j )
    {
      QDomElement childElem = composerChildren.at( j ).toElement();
      if ( childElem.tagName() == "Composition" )
//.........这里部分代码省略.........
开发者ID:L-Infantini,项目名称:Quantum-GIS,代码行数:101,代码来源:qgsprojectfiletransform.cpp


注:本文中的QDomElement::removeAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。