本文整理汇总了C++中QDomElement::isElement方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::isElement方法的具体用法?C++ QDomElement::isElement怎么用?C++ QDomElement::isElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::isElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: domToTodo
bool LocalXmlBackend::domToTodo(const QDomDocument &doc, OpenTodoList::ITodo *todo)
{
QDomElement root = doc.documentElement();
if ( !root.isElement() ) {
return false;
}
todo->setUuid( QUuid( root.attribute( "id" ) ) );
todo->setTitle( root.attribute( "title" ) );
if ( root.hasAttribute( "done" ) ) {
todo->setDone( root.attribute( "done", "true" ) == "true" );
} else {
// TODO: Remove this in 0.3 release
todo->setDone( root.attribute( "progress", 0 ).toInt() >= 100 );
}
todo->setPriority( qBound( -1, root.attribute( "priority", QString::number(todo->priority()) ).toInt(), 10 ) );
if ( root.hasAttribute( "dueDate" ) ) {
todo->setDueDate( QDateTime::fromString( root.attribute( "dueDate" ) ) );
} else {
todo->setDueDate( QDateTime() );
}
todo->setWeight( root.attribute( "weight", QString::number( todo->weight() ) ).toDouble() );
QDomElement description = root.firstChildElement( "description" );
if ( description.isElement() ) {
todo->setDescription( description.text() );
}
return true;
}
示例2: 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;
}
示例3: onRefreshAll
void CFuncHelper::onRefreshAll()
{
m_listFuncs.clear();
QString qsPath = qApp->applicationDirPath() + "/Funcs.xml";
QFile file(qsPath);
if(!file.open(QFile::ReadOnly))
return;
QDomDocument doc;
doc.setContent(file.readAll());
file.close();
QDomElement eleRoot = doc.firstChildElement("funcs");
if(!eleRoot.isElement())
return;
QDomElement eleFunc = eleRoot.firstChildElement("func");
while(eleFunc.isElement())
{
QDomElement eleName = eleFunc.firstChildElement("name");
QDomElement eleDesc = eleFunc.firstChildElement("desc");
if(eleName.isElement() && eleDesc.isElement())
{
QListWidgetItem* pItem = new QListWidgetItem(eleName.text());
pItem->setData(Qt::UserRole,eleDesc.text());
m_listFuncs.addItem(pItem);
}
eleFunc = eleFunc.nextSiblingElement("func");
}
}
示例4: read
bool FotowallFile::read(const QString & fwFilePath, Canvas * canvas, bool inHistory)
{
// open the file for reading
QFile file(fwFilePath);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(0, QObject::tr("Loading error"), QObject::tr("Unable to load the Fotowall file %1").arg(fwFilePath));
return false;
}
// load the DOM
QString error;
QDomDocument doc;
if (!doc.setContent(&file, false, &error)) {
QMessageBox::critical(0, QObject::tr("Parsing error"), QObject::tr("Unable to parse the Fotowall file %1. The error was: %2").arg(fwFilePath, error));
return false;
}
file.close();
// get the Canvas node
QDomElement root = doc.documentElement();
QDomElement canvasElement = root.firstChildElement("canvas");
if (!canvasElement.isElement()) // 'Format 1'
canvasElement = root;
if (!canvasElement.isElement())
return false;
// restore the canvas
canvas->setFilePath(fwFilePath);
canvas->loadFromXml(canvasElement);
// add to the recent history
if (inHistory)
App::settings->addRecentFotowallUrl(QUrl(fwFilePath));
return true;
}
示例5: documentation
QString DocParser::documentation(const AbstractMetaEnumValue *java_enum_value) const {
if (!m_dom)
return QString();
QDomElement root_node = m_dom->documentElement();
QDomNodeList enums = root_node.elementsByTagName("enum");
for (int i = 0; i < enums.size(); ++i) {
QDomNode node = enums.item(i);
QDomElement *e = (QDomElement *) & node;
Q_ASSERT(e->isElement());
QDomNodeList enumValues = e->elementsByTagName("enum-value");
for (int j = 0; j < enumValues.size(); ++j) {
QDomNode node = enumValues.item(j);
QDomElement *ev = (QDomElement *) & node;
if (ev->attribute("name") == java_enum_value->name()) {
return ev->attribute("doc");
}
}
}
return QString();
}
示例6: ReadAttributes
void ReadAttributes(QObject* obj,QDomElement& el) {
QDomElement prop = el.firstChildElement("property");
while (prop.isElement()) {
QString propName = prop.attribute("name");
int propIndx = obj->metaObject()->indexOfProperty(propName.toLatin1().constData());
if (propIndx>=0 && propIndx<obj->metaObject()->propertyCount()) {
QMetaProperty metaProperty(obj->metaObject()->property(propIndx));
QString valueStr = prop.attribute("value");
if (metaProperty.type()==QVariant::String) {
metaProperty.write(obj,valueStr);
} else if (metaProperty.type()==QVariant::Int) {
metaProperty.write(obj,valueStr.toInt());
} else if (metaProperty.type()==QVariant::UInt) {
metaProperty.write(obj,valueStr.toUInt());
} else if (metaProperty.type()==QVariant::Double) {
metaProperty.write(obj,valueStr.toDouble());
} else if (metaProperty.type()==QVariant::Bool) {
metaProperty.write(obj,bool(valueStr.toInt()));
} else if (metaProperty.type()==QVariant::Point) {
QStringList sl = valueStr.split(";");
metaProperty.write(obj,QPoint(sl.first().toInt(),sl.last().toInt()));
} else if (metaProperty.type()==QVariant::PointF) {
QStringList sl = valueStr.split(";");
metaProperty.write(obj,QPoint(sl.first().toDouble(),sl.last().toDouble()));
} else if (metaProperty.type()==QVariant::Size) {
QStringList sl = valueStr.split(";");
metaProperty.write(obj,QSize(sl.first().toInt(),sl.last().toInt()));
} else if (metaProperty.type()==QVariant::SizeF) {
QStringList sl = valueStr.split(";");
metaProperty.write(obj,QSizeF(sl.first().toDouble(),sl.last().toDouble()));
}
}
prop = prop.nextSiblingElement("property");
}
}
示例7: setContext
void LinguistExportPlugin::setContext( QDomDocument& doc, QString newContext )
{
// Nothing to do here.
if ( newContext == context )
return;
// Find out whether there is already such a context in the QDomDocument.
QDomNode node = doc.documentElement( ).firstChild( );
while ( !node.isNull( ) ) {
if ( node.isElement( ) ) {
QDomElement elem = node.firstChild( ).toElement( );
if ( elem.isElement( ) && elem.tagName( ) == "name" && elem.text( ) == newContext ) {
// We found the context.
context = newContext;
contextElement = node.toElement( );
// Nothing more to do.
return;
}
}
node = node.nextSibling( );
}
// Create new context element.
contextElement = doc.createElement( "context" );
doc.documentElement( ).appendChild( contextElement );
// Appropriate name element.
QDomElement nameElement = doc.createElement( "name" );
QDomText text = doc.createTextNode( newContext );
nameElement.appendChild( text );
contextElement.appendChild( nameElement );
// Store new context.
context = newContext;
}
示例8: parseMatrix
/**
* Helper function to parse a matrix. Example matrix:
*
* <matrix>
* <row a="1" b="0" c="0" d="0"/>
* <row a="0" b="1" c="0" d="0"/>
* <row a="0" b="0" c="1" d="0"/>
* <row a="0" b="0" c="0" d="1"/>
* </matrix>
*/
bool parseMatrix(const QDomElement &matrix, double m[16])
{
QDomNode childNode = matrix.firstChild();
int row = 0;
while (!childNode.isNull())
{
QDomElement e = childNode.toElement();
if (e.isElement())
{
float a, b, c, d;
if (!parseQuadruple(e, a, b, c, d, "a", "b", "c", "d") && !parseQuadruple(e, a, b, c, d, "v1", "v2", "v3", "v4"))
{
PARSE_ERROR(e);
return false;
}
m[row*4 + 0] = a;
m[row*4 + 1] = b;
m[row*4 + 2] = c;
m[row*4 + 3] = d;
if (++row == 4) break;
}
childNode = childNode.nextSibling();
}
return (row == 4);
}
示例9: fromXml
bool PictureContent::fromXml(QDomElement & pe)
{
AbstractContent::fromXml(pe);
// load picture properties
QString path = pe.firstChildElement("path").text();
// build the afterload effects list
m_afterLoadEffects.clear();
QDomElement effectsE = pe.firstChildElement("effects");
for (QDomElement effectE = effectsE.firstChildElement("effect"); effectE.isElement(); effectE = effectE.nextSiblingElement("effect")) {
PictureEffect fx;
fx.effect = (PictureEffect::Effect)effectE.attribute("type").toInt();
fx.param = effectE.attribute("param").toDouble();
if (fx.effect == PictureEffect::Opacity)
setOpacity(fx.param);
else if (fx.effect == PictureEffect::Crop) {
QString rect = effectE.attribute("cropingRect");
QStringList coordinates = rect.split(" ");
if(coordinates.size() >= 3) {
QRect cropingRect (coordinates.at(0).toInt(), coordinates.at(1).toInt(), coordinates.at(2).toInt(), coordinates.at(3).toInt());
fx.cropingRect = cropingRect;
}
}
m_afterLoadEffects.append(fx);
}
// load Network image
if (path.startsWith("http", Qt::CaseInsensitive) || path.startsWith("ftp", Qt::CaseInsensitive))
return loadFromNetwork(path, 0);
// load Local image
return loadPhoto(path);
}
示例10: doTests
void tst_ICheck::doTests()
{
QString msg;
QString xmltestfile = getTestFileFolder();
xmltestfile += "/Test.xml";
QFile xmlfile(xmltestfile);
bool failed = false;
if (xmlfile.exists()){
QDomDocument document;
if (document.setContent(&xmlfile)) {
QDomElement rootnd = document.documentElement();
if(rootnd.isElement()){
QDomNodeList nodeList = rootnd.childNodes();
for(int i = 0; i < nodeList.count(); i++){
QDomNode nd = nodeList.at(i);
TestCase test(nd);
if(!test.run()){
QWARN(test.getErrorMsg().toLatin1());
failed = true;
}
}
}
}
}
else {
QFAIL ( QString(xmltestfile + " file not found").toLatin1() );
}
if(failed)
QFAIL ( "Test failed, please read warnings!" );
}
示例11: readOrCreateIdentifier
bool XmlState::readOrCreateIdentifier(const QDomElement& el) {
if (!el.isElement()) {
return false;
}
QDomElement eId = el.firstChildElement(QLatin1String("Sky:Id"));
if (eId.isElement()) {
mId = eId.text();
}
if (!mId.isValid()) {
mId = QUuid::createUuid().toString();
}
return true;
}
示例12: UpdateNamePosition
/**
* @brief UpdateNamePosition save new position label to the pattern file.
* @param mx label bias x axis.
* @param my label bias y axis.
*/
void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(mx));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(my));
emit toolhaveChange();
}
}
示例13: domToTodoList
bool LocalXmlBackend::domToTodoList(const QDomDocument &doc, OpenTodoList::ITodoList *list)
{
QDomElement root = doc.documentElement();
if ( !root.isElement() ) {
return false;
}
list->setUuid( QUuid( root.attribute( "id", list->uuid().toString() ) ) );
list->setName( root.attribute( "name", list->name() ) );
return true;
}
示例14: todoListToDom
bool LocalXmlBackend::todoListToDom(const OpenTodoList::ITodoList *list, QDomDocument &doc)
{
QDomElement root = doc.documentElement();
if ( !root.isElement() ) {
root = doc.createElement( "todoList" );
doc.appendChild( root );
}
root.setAttribute( "id", list->uuid().toString() );
root.setAttribute( "name", list->name() );
return true;
}
示例15: FullUpdateFromFile
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolAlongLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
}
RefreshGeometry();
}