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


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

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


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

示例1: fromXml

Event Event::fromXml( const QDomElement& element, int databaseSchemaVersion )
{   // in case any event object creates trouble with
    // serialization/deserialization, add an object of it to
    // void XmlSerializationTests::testEventSerialization()
    Event event;
    bool ok;
    event.setComment( element.text() );
    event.setId( element.attribute( EventIdAttribute ).toInt( &ok ) );
    if ( !ok ) throw XmlSerializationException( QObject::tr( "Event::fromXml: invalid event id" ) );
    event.setInstallationId( element.attribute( EventInstallationIdAttribute ).toInt( &ok ) );
    if ( !ok ) throw XmlSerializationException( QObject::tr( "Event::fromXml: invalid installation id" ) );
    event.setTaskId( element.attribute( EventTaskIdAttribute ).toInt( &ok ) );
    if ( !ok ) throw XmlSerializationException( QObject::tr( "Event::fromXml: invalid task id" ) );
    event.setUserId( element.attribute( EventUserIdAttribute ).toInt( &ok ) );
    if ( !ok && databaseSchemaVersion > 1 ) {
        throw XmlSerializationException( QObject::tr( "Event::fromXml: invalid user id" ) );
        event.setUserId( 0 );
    }
    event.setReportId( element.attribute( EventReportIdAttribute ).toInt( &ok ) );
    if ( !ok && databaseSchemaVersion > 1 ) {
        throw XmlSerializationException( QObject::tr( "Event::fromXml: invalid report id" ) );
        event.setReportId( 0 );
    }
    if ( element.hasAttribute( EventStartAttribute ) ) {
        QDateTime start = QDateTime::fromString( element.attribute( EventStartAttribute ), Qt::ISODate );
        if ( !start.isValid() ) throw XmlSerializationException( QObject::tr( "Event::fromXml: invalid start date" ) );
        start.setTimeSpec( Qt::UTC );
        event.setStartDateTime( start );
    }
    if ( element.hasAttribute( EventEndAttribute ) ) {
        QDateTime end = QDateTime::fromString( element.attribute( EventEndAttribute ), Qt::ISODate );
        if ( !end.isValid() ) throw XmlSerializationException( QObject::tr( "Event::fromXml: invalid end date" ) );
        end.setTimeSpec( Qt::UTC );
        event.setEndDateTime( end.toLocalTime() );
    }
    event.setComment( element.text() );
    return event;
}
开发者ID:hefee,项目名称:Charm,代码行数:38,代码来源:Event.cpp

示例2: txtNeu

QMap<QString, QString> TransitionHandler::getTransitionParamsFromXml(const QDomElement &xml)
{
    QDomNodeList attribs = xml.elementsByTagName(QStringLiteral("parameter"));
    QMap<QString, QString> map;
    QLocale locale;
    for (int i = 0; i < attribs.count(); ++i) {
        QDomElement e = attribs.item(i).toElement();
        QString name = e.attribute(QStringLiteral("name"));
        map[name] = e.attribute(QStringLiteral("default"));
        if (e.hasAttribute(QStringLiteral("value"))) {
            map[name] = e.attribute(QStringLiteral("value"));
        }
        double factor = e.attribute(QStringLiteral("factor"), QStringLiteral("1")).toDouble();
        double offset = e.attribute(QStringLiteral("offset"), QStringLiteral("0")).toDouble();
        if (factor!= 1 || offset != 0) {
            if (e.attribute(QStringLiteral("type")) == QLatin1String("simplekeyframe")) {
                QStringList values = e.attribute(QStringLiteral("value")).split(';', QString::SkipEmptyParts);
                for (int j = 0; j < values.count(); ++j) {
                    QString pos = values.at(j).section(QLatin1Char('='), 0, 0);
                    double val = (values.at(j).section(QLatin1Char('='), 1, 1).toDouble() - offset) / factor;
                    values[j] = pos + '=' + locale.toString(val);
                }
                map[name] = values.join(QLatin1Char(';'));
            } else if (e.attribute(QStringLiteral("type")) != QLatin1String("addedgeometry")) {
                map[name] = locale.toString((locale.toDouble(map.value(name)) - offset) / factor);
                //map[name]=map[name].replace(".",","); //FIXME how to solve locale conversion of . ,
            }
        }
        if (e.attribute(QStringLiteral("namedesc")).contains(';')) {
            //TODO: Deprecated, does not seem used anywhere...
            QString format = e.attribute(QStringLiteral("format"));
            QStringList separators = format.split(QStringLiteral("%d"), QString::SkipEmptyParts);
            QStringList values = e.attribute(QStringLiteral("value")).split(QRegExp("[,:;x]"));
            QString neu;
            QTextStream txtNeu(&neu);
            if (values.size() > 0)
                txtNeu << (int)values[0].toDouble();
            int i = 0;
            for (i = 0; i < separators.size() && i + 1 < values.size(); ++i) {
                txtNeu << separators[i];
                txtNeu << (int)(values[i+1].toDouble());
            }
            if (i < separators.size())
                txtNeu << separators[i];
            map[e.attribute(QStringLiteral("name"))] = neu;
        }

    }
    return map;
}
开发者ID:jessezwd,项目名称:kdenlive,代码行数:50,代码来源:transitionhandler.cpp

示例3: changeUiClassName

QString FormTemplateWizardPage::changeUiClassName(const QString &uiXml, const QString &newUiClassName)
{
    if (Designer::Constants::Internal::debug)
        qDebug() << '>' << Q_FUNC_INFO << newUiClassName;
    QDomDocument domUi;
    if (!domUi.setContent(uiXml)) {
        qWarning("Failed to parse:\n%s", uiXml.toUtf8().constData());
        return uiXml;
    }

    bool firstWidgetElementFound = false;
    QString oldClassName;

    // Loop first level children. First child is <ui>
    const QDomNodeList children = domUi.firstChildElement().childNodes();
    const QString classTag = QLatin1String("class");
    const QString widgetTag = QLatin1String("widget");
    const QString connectionsTag = QLatin1String("connections");
    const int count = children.size();
    for (int i = 0; i < count; i++) {
        const QDomNode node = children.at(i);
        if (node.isElement()) {
            // Replace <class> element text
            QDomElement element = node.toElement();
            const QString name = element.tagName();
            if (name == classTag) {
                if (!changeDomElementContents(element, truePredicate, newUiClassName, &oldClassName)) {
                    qWarning("Unable to change the <class> element:\n%s", uiXml.toUtf8().constData());
                    return uiXml;
                }
            } else {
                // Replace first <widget> element name attribute
                if (!firstWidgetElementFound && name == widgetTag) {
                    firstWidgetElementFound = true;
                    const QString nameAttribute = QLatin1String("name");
                    if (element.hasAttribute(nameAttribute))
                        element.setAttribute(nameAttribute, newUiClassName);
                } else {
                    // Replace <sender>, <receiver> tags of dialogs.
                    if (name == connectionsTag)
                        changeDomConnectionList(element, oldClassName, newUiClassName);
                }
            }
        }
    }
    const QString rc = domUi.toString();
    if (Designer::Constants::Internal::debug > 1)
        qDebug() << '<' << Q_FUNC_INFO << newUiClassName << rc;
    return rc;
}
开发者ID:Herysutrisno,项目名称:qt-creator,代码行数:50,代码来源:formtemplatewizardpage.cpp

示例4: attribute

QString StyleStack::attribute( const QString& name ) const
{
    // TODO: has to be fixed for complex styles like list-styles
    QList<QDomElement>::ConstIterator it = m_stack.end();
    while ( it != m_stack.begin() )
    {
        --it;
        QDomElement properties = searchAttribute( *it, m_nodeNames, name );
        if ( properties.hasAttribute( name ) )
            return properties.attribute( name );
    }

    return QString::null;
}
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:14,代码来源:stylestack.cpp

示例5: vertices

Sphere::Sphere(const QDomElement& e)
    :mCenter(Eigen::Vector3f(0.0,0.0,0.0))
{
    if(e.hasAttribute("radius"))
        mRadius = e.attribute("radius").toFloat();
    else{
        QMessageBox::warning(NULL, "Object XML error", "Error while parsing Object XML document: radius attribute missing");
        return;
    }
    mpMesh = new Mesh;
    Eigen::Matrix<float,3,12> vertices((float*)vdata);
    vertices = (vertices*radius()).colwise() + center();
    mpMesh->loadRawData(vertices.data(), 12, (int*)tindices, 20);
}
开发者ID:Vic-King,项目名称:SIRE,代码行数:14,代码来源:Sphere.cpp

示例6: areTherePinnedTabs

bool areTherePinnedTabs(QDomElement & window)
{
    bool b = false;

    for (unsigned int tabNo = 0; tabNo < window.elementsByTagName("tab").length(); tabNo++)
    {
        QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement();
        b = tab.hasAttribute("pinned");
        if (b)
            return true;
    }

    return b;
}
开发者ID:ksarend,项目名称:rekonq,代码行数:14,代码来源:sessionmanager.cpp

示例7: distribute

void Client::distribute(const QDomElement &x)
{
	if(x.hasAttribute("from")) {
		Jid j(x.attribute("from"));
		if(!j.isValid()) {
			debug("Client: bad 'from' JID\n");
			return;
		}
	}

	if(!rootTask()->take(x)) {
		debug("Client: packet was ignored.\n");
	}
}
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:14,代码来源:client.cpp

示例8: _renderer2labelingRules

// manipulate DOM before dropping it so that rules are more useful
void _renderer2labelingRules( QDomElement &ruleElem )
{
  // labeling rules recognize only "description"
  if ( ruleElem.hasAttribute( QStringLiteral( "label" ) ) )
    ruleElem.setAttribute( QStringLiteral( "description" ), ruleElem.attribute( QStringLiteral( "label" ) ) );

  // run recursively
  QDomElement childRuleElem = ruleElem.firstChildElement( QStringLiteral( "rule" ) );
  while ( !childRuleElem.isNull() )
  {
    _renderer2labelingRules( childRuleElem );
    childRuleElem = childRuleElem.nextSiblingElement( QStringLiteral( "rule" ) );
  }
}
开发者ID:boundlessgeo,项目名称:QGIS,代码行数:15,代码来源:qgsrulebasedlabelingwidget.cpp

示例9: stringToVal

static State::Value read_valueDefault(
        const QDomElement& dom_element,
        const QString& type)
{
    if(dom_element.hasAttribute("valueDefault"))
    {
        const auto value = dom_element.attribute("valueDefault");
        return stringToVal(value, type);
    }
    else
    {
        return stringToVal((type == "string") ? "" : "0", type);
    }
}
开发者ID:rperrot,项目名称:i-score,代码行数:14,代码来源:XMLDeviceLoader.cpp

示例10: getRootElement

QDomElement* Signaltypes::getRootElement()
{
	char cfg_path[MAX_PATH_LENGTH];
	QString errorStr;
	int	errorLine,
		errorColumn;
	QDomDocument document;
	bool	success;

	configpath(cfg_path, "Signaltypes.xml");
	QFile file(cfg_path);
	success = file.open(QFile::ReadOnly | QFile::Text);
	if(not success)
	{
		QMessageBox::warning(parent->mainwindow, tr("Signaltypes"), tr("Cannot read file %1:\n%2.").arg(cfg_path).arg(file.errorString()));
		default_types();
		return NULL;
	}

	success = document.setContent(&file, true, &errorStr, &errorLine, &errorColumn);

	if(not success)
	{
		QMessageBox::information(parent->mainwindow,
					tr("Signaltypes"),
					tr("Parse error at line %1, column %2:\n%3").arg(errorLine).arg(errorColumn).arg(errorStr));
		default_types();
		file.close();
		return NULL;
	}
	file.close();

	QDomElement *root = new QDomElement(document.documentElement());
	if( root->tagName() != "Signaltypes" )
	{
		QMessageBox::information(parent->mainwindow, tr("Signaltypes"), tr("%1 is not a Signaltypes.xml file.").arg(cfg_path) );
		default_types();
		delete root;
		return NULL;
	}

	else if( root->hasAttribute("version") && root->attribute("version") != "0.0.1" )
	{
		QMessageBox::information(parent->mainwindow, tr("Signaltypes"), tr("%1 is not Signaltypes.xml version 0.0.1 file.").arg(cfg_path) );
		default_types();
		delete root;
		return NULL;
	}
	return root;
}
开发者ID:jusjusjus,项目名称:edfView,代码行数:50,代码来源:Signaltypes.cpp

示例11: loadSettings

void SampleTCO::loadSettings( const QDomElement & _this )
{
	if( _this.attribute( "pos" ).toInt() >= 0 )
	{
		movePosition( _this.attribute( "pos" ).toInt() );
	}
	setSampleFile( _this.attribute( "src" ) );
	if( sampleFile().isEmpty() && _this.hasAttribute( "data" ) )
	{
		m_sampleBuffer->loadFromBase64( _this.attribute( "data" ) );
	}
	changeLength( _this.attribute( "len" ).toInt() );
	setMuted( _this.attribute( "muted" ).toInt() );
}
开发者ID:Frankenwolfe,项目名称:lmms,代码行数:14,代码来源:SampleTrack.cpp

示例12: nameToOnError

Script::Script(const QDomElement & elem, QStringList &msg, QList<bool> &fatal)
{
  _name = elem.attribute("name");
  if (elem.hasAttribute("file"))
    _name = elem.attribute("file");
  _onError = nameToOnError(elem.attribute("onerror"));
  _comment = elem.text();

  if (_name.isEmpty())
  {
    msg.append(TR("This script does not have a name."));
    fatal.append(true);
  }
}
开发者ID:bunhin,项目名称:updater,代码行数:14,代码来源:script.cpp

示例13: getAttributeInt

bool GwfObjectInfoReader::getAttributeInt(const QDomElement &element, QString attribute, int &result)
{
    if (element.hasAttribute(attribute))
    {
        bool res;
        result = element.attribute(attribute).toInt(&res);

        if (!res) return false;

        return true;
    }
    errorHaventAttribute(element.tagName(), attribute);
    return false;
}
开发者ID:dark-al,项目名称:kbe,代码行数:14,代码来源:gwfobjectinforeader.cpp

示例14: Loadable

LoadImage::LoadImage(const QDomElement &elem, const bool system,
                     QStringList &msg, QList<bool> &fatal)
  : Loadable(elem, system, msg, fatal)
{
  _pkgitemtype = "I";

  if (_name.isEmpty())
  {
    msg.append(TR("The image in %1 does not have a name.")
                       .arg(_filename));
    fatal.append(true);
  }

  if (elem.nodeName() != "loadimage")
  {
    msg.append(TR("Creating a LoadImage element from a %1 node.")
              .arg(elem.nodeName()));
    fatal.append(false);
  }

  if (elem.hasAttribute("grade") || elem.hasAttribute("order"))
  {
    msg.append(TR("Node %1 '%2' has a 'grade' or 'order' attribute "
                           "but these are ignored for images.")
                           .arg(elem.nodeName()).arg(elem.attribute("name")));
    fatal.append(false);
  }

  if (elem.hasAttribute("enabled"))
  {
    msg.append(TR("Node %1 '%2' has an 'enabled' "
                           "attribute which is ignored for images.")
                       .arg(elem.nodeName()).arg(elem.attribute("name")));
    fatal.append(false);
  }

}
开发者ID:gpazo,项目名称:xtuple-svn,代码行数:37,代码来源:loadimage.cpp

示例15: addTransition

bool TransitionHandler::addTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool do_refresh)
{
    if (in >= out) return false;
    QMap<QString, QString> args = getTransitionParamsFromXml(xml);
    QScopedPointer<Mlt::Field> field(m_tractor->field());

    Mlt::Transition transition(*m_tractor->profile(), tag.toUtf8().constData());
    if (!transition.is_valid()) return false;
    if (out != GenTime())
        transition.set_in_and_out((int) in.frames(m_fps), (int) out.frames(m_fps) - 1);

    int position = mlt_producer_position(m_tractor->get_producer());

    if (do_refresh && ((position < in.frames(m_fps)) || (position > out.frames(m_fps)))) do_refresh = false;
    QMap<QString, QString>::Iterator it;
    QString key;
    if (xml.attribute(QStringLiteral("automatic")) == QLatin1String("1")) transition.set("automatic", 1);
    ////qDebug() << " ------  ADDING TRANSITION PARAMs: " << args.count();
    if (xml.hasAttribute(QStringLiteral("id")))
        transition.set("kdenlive_id", xml.attribute(QStringLiteral("id")).toUtf8().constData());
    if (xml.hasAttribute(QStringLiteral("force_track")))
        transition.set("force_track", xml.attribute(QStringLiteral("force_track")).toInt());

    for (it = args.begin(); it != args.end(); ++it) {
        key = it.key();
        if (!it.value().isEmpty())
            transition.set(key.toUtf8().constData(), it.value().toUtf8().constData());
        ////qDebug() << " ------  ADDING TRANS PARAM: " << key << ": " << it.value();
    }
    // attach transition
    m_tractor->lock();
    plantTransition(field.data(), transition, a_track, b_track);
    // field->plant_transition(*transition, a_track, b_track);
    m_tractor->unlock();
    if (do_refresh) emit refresh();
    return true;
}
开发者ID:dreamsxin,项目名称:kdenlive,代码行数:37,代码来源:transitionhandler.cpp


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