Пример #1
0
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;
}
Пример #2
0
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;
}
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;
}
Пример #4
0
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;
}
Пример #5
0
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);
}
Пример #6
0
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;
}
Пример #7
0
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");
	}
}
// 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" ) );
  }
}
Пример #9
0
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);
    }
}
Пример #10
0
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;
}
Пример #11
0
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() );
}
Пример #12
0
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);
  }
}
Пример #13
0
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;
}
Пример #14
0
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);
  }

}
Пример #15
0
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;
}
void QgsRasterTransparency::readXML( const QDomElement& elem )
{
  if ( elem.isNull() )
  {
    return;
  }

  mTransparentSingleValuePixelList.clear();
  mTransparentThreeValuePixelList.clear();
  QDomElement currentEntryElem;

  QDomElement singlePixelListElem = elem.firstChildElement( "singleValuePixelList" );
  if ( !singlePixelListElem.isNull() )
  {
    QDomNodeList entryList = singlePixelListElem.elementsByTagName( "pixelListEntry" );
    TransparentSingleValuePixel sp;
    for ( int i = 0; i < entryList.size(); ++i )
    {
      currentEntryElem = entryList.at( i ).toElement();
      sp.percentTransparent = currentEntryElem.attribute( "percentTransparent" ).toDouble();
      // Backward compoatibility < 1.9 : pixelValue (before ranges)
      if ( currentEntryElem.hasAttribute( "pixelValue" ) )
      {
        sp.min = sp.max = currentEntryElem.attribute( "pixelValue" ).toDouble();
      }
      else
      {
        sp.min = currentEntryElem.attribute( "min" ).toDouble();
        sp.max = currentEntryElem.attribute( "max" ).toDouble();
      }
      mTransparentSingleValuePixelList.append( sp );
    }
  }
  QDomElement threeValuePixelListElem = elem.firstChildElement( "threeValuePixelList" );
  if ( !threeValuePixelListElem.isNull() )
  {
    QDomNodeList entryList = threeValuePixelListElem.elementsByTagName( "pixelListEntry" );
    TransparentThreeValuePixel tp;
    for ( int i = 0; i < entryList.size(); ++i )
    {
      currentEntryElem = entryList.at( i ).toElement();
      tp.red = currentEntryElem.attribute( "red" ).toDouble();
      tp.green = currentEntryElem.attribute( "green" ).toDouble();
      tp.blue = currentEntryElem.attribute( "blue" ).toDouble();
      tp.percentTransparent = currentEntryElem.attribute( "percentTransparent" ).toDouble();
      mTransparentThreeValuePixelList.append( tp );
    }
  }
}
Пример #17
0
ComplexType Parser::parseComplexType( ParserContext *context, const QDomElement &element )
{
  ComplexType newType( d->mNameSpace );

  newType.setName( element.attribute( QLatin1String("name") ) );

  if (debugParsing())
      qDebug() << "complexType:" << d->mNameSpace << newType.name();

  if ( element.hasAttribute( QLatin1String("mixed") ) )
    newType.setContentModel( XSDType::MIXED );

  QDomElement childElement = element.firstChildElement();

  AttributeGroup::List attributeGroups;

  while ( !childElement.isNull() ) {
    NSManager namespaceManager( context, childElement );
    const QName name( childElement.tagName() );
    if ( name.localName() == QLatin1String("all") ) {
      all( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("sequence") ) {
      parseCompositor( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("choice") ) {
      parseCompositor( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("attribute") ) {
      newType.addAttribute( parseAttribute( context, childElement ) );
    } else if ( name.localName() == QLatin1String("attributeGroup") ) {
      AttributeGroup g = parseAttributeGroup( context, childElement );
      attributeGroups.append( g );
    } else if ( name.localName() == QLatin1String("anyAttribute") ) {
      addAnyAttribute( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("complexContent") ) {
      parseComplexContent( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("simpleContent") ) {
      parseSimpleContent( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("annotation") ) {
      Annotation::List annotations = parseAnnotation( context, childElement );
      newType.setDocumentation( annotations.documentation() );
      newType.setAnnotations( annotations );
    }

    childElement = childElement.nextSiblingElement();
  }

  newType.setAttributeGroups( attributeGroups );

  return newType;
}
Пример #18
0
		bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
		{
			if(depth == 0) {
				Parser::Event *e = new Parser::Event;
				QXmlAttributes a;
				for(int n = 0; n < atts.length(); ++n) {
					QString uri = atts.uri(n);
					QString ln = atts.localName(n);
					if(a.index(uri, ln) == -1)
						a.append(atts.qName(n), uri, ln, atts.value(n));
				}
				e->setDocumentOpen(namespaceURI, localName, qName, a, nsnames, nsvalues);
				nsnames.clear();
				nsvalues.clear();
				e->setActualString(in->lastString());

				in->resetLastData();
				eventList.append(e);
				in->pause(true);
			}
			else {
				QDomElement e = doc->createElementNS(namespaceURI, qName);
				for(int n = 0; n < atts.length(); ++n) {
					QString uri = atts.uri(n);
					QString ln = atts.localName(n);
					bool have;
					if(!uri.isEmpty()) {
						have = e.hasAttributeNS(uri, ln);
						if(qt_bug_have)
							have = !have;
					}
					else
						have = e.hasAttribute(ln);
					if(!have)
						e.setAttributeNS(uri, atts.qName(n), atts.value(n));
				}

				if(depth == 1) {
					elem = e;
					current = e;
				}
				else {
					current.appendChild(e);
					current = e;
				}
			}
			++depth;
			return true;
		}
Пример #19
0
void MidiPort::loadSettings( const QDomElement& thisElement )
{
	m_inputChannelModel.loadSettings( thisElement, "inputchannel" );
	m_outputChannelModel.loadSettings( thisElement, "outputchannel" );
	m_inputControllerModel.loadSettings( thisElement, "inputcontroller" );
	m_outputControllerModel.loadSettings( thisElement, "outputcontroller" );
	m_fixedInputVelocityModel.loadSettings( thisElement, "fixedinputvelocity" );
	m_fixedOutputVelocityModel.loadSettings( thisElement, "fixedoutputvelocity" );
	m_outputProgramModel.loadSettings( thisElement, "outputprogram" );
	m_baseVelocityModel.loadSettings( thisElement, "basevelocity" );
	m_readableModel.loadSettings( thisElement, "readable" );
	m_writableModel.loadSettings( thisElement, "writable" );

	// restore connections

	if( isInputEnabled() )
	{
		QStringList rp = thisElement.attribute( "inports" ).split( ',' );
		for( Map::ConstIterator it = m_readablePorts.begin(); it != m_readablePorts.end(); ++it )
		{
			if( it.value() != ( rp.indexOf( it.key() ) != -1 ) )
			{
				subscribeReadablePort( it.key() );
			}
		}
		emit readablePortsChanged();
	}

	if( isOutputEnabled() )
	{
		QStringList wp = thisElement.attribute( "outports" ).split( ',' );
		for( Map::ConstIterator it = m_writablePorts.begin(); it != m_writablePorts.end(); ++it )
		{
			if( it.value() != ( wp.indexOf( it.key() ) != -1 ) )
			{
				subscribeWritablePort( it.key() );
			}
		}
		emit writablePortsChanged();
	}

	if( thisElement.hasAttribute( "basevelocity" ) == false )
	{
		// for projects created by LMMS < 0.9.92 there's no value for the base
		// velocity and for compat reasons we have to stick with maximum velocity
		// which did not allow note volumes > 100%
		m_baseVelocityModel.setValue( MidiMaxVelocity );
	}
}
Пример #20
0
void SoapBinding::Body::loadXML(ParserContext *context, const QDomElement &element)
{
#if 0
    // ## Seems to be set to a namespace, always http://schemas.xmlsoap.org/soap/encoding/ ... unused here.
    if (element.hasAttribute("encodingStyle")) {
        mEncodingStyle = element.attribute("encodingStyle");
    } else {
        mEncodingStyle = QString();
    }
#endif

    mPart = element.attribute(QLatin1String("parts"));
    mNameSpace = element.attribute(QLatin1String("namespace"));

    if (element.hasAttribute(QLatin1String("use"))) {
        if (element.attribute(QLatin1String("use")) == QLatin1String("literal")) {
            mUse = LiteralUse;
        } else if (element.attribute(QLatin1String("use")) == QLatin1String("encoded")) {
            mUse = EncodedUse;
        } else {
            context->messageHandler()->warning(QLatin1String("SoapBinding::Body: unknown 'use' value"));
        }
    }
}
Пример #21
0
KConfigPropagator::Rule KConfigPropagator::parsePropagation( const QDomElement &e )
{
  Rule r;

  QString source = e.attribute( "source" );
  parseConfigEntryPath( source, r.sourceFile, r.sourceGroup, r.sourceEntry );

  QString target = e.attribute( "target" );
  parseConfigEntryPath( target, r.targetFile, r.targetGroup, r.targetEntry );

  r.hideValue = e.hasAttribute( "hidevalue" ) &&
                e.attribute( "hidevalue" ) == "true";

  return r;
}
Пример #22
0
LoadMetasql::LoadMetasql(const QDomElement &elem, const bool system,
                         QStringList &msg, QList<bool> &fatal)
  : Loadable(elem, system, msg, fatal)
{
  if (DEBUG)
    qDebug("LoadMetasql::LoadMetasql(QDomElement) entered");

  _pkgitemtype = "M";

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

  if (elem.hasAttribute("group"))
    _group = elem.attribute("group");

  if (elem.hasAttribute("grade") || elem.hasAttribute("order"))
  {
    msg.append(TR("Node %1 '%2' has a 'grade' or 'order' attribute "
                           "but these are ignored for MetaSQL statements.")
                           .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 MetaSQL statements.")
                       .arg(elem.nodeName()).arg(elem.attribute("name")));
    fatal.append(false);
  }

}
Пример #23
0
bool SceneLoader::readAttributeAsFloat(const QDomElement &element, const QString &attributeName, float &value) const {
  if (!element.hasAttribute(attributeName)) {
    std::cerr << "Scene parsing error: element '" << element.tagName().toUtf8().constData() << "' has no attribute with name '" << attributeName.toUtf8().constData() << "'" << std::endl;
    return false;
  }

  bool isConversionOk;
  value = element.attribute(attributeName).toFloat(&isConversionOk);    
  if (!isConversionOk) {
    std::cerr << "Scene parsing error: unable to convert '" << attributeName.toUtf8().constData() << "' attribute of element '" << element.tagName().toUtf8().constData() << "' to float" << std::endl;
    return false;
  }

  return true;
}
bool TestXmlElementHandlerV1::imageElement( KDReports::ImageElement& imageElement, QDomElement& xmlElement )
{
    Q_UNUSED( imageElement );
    Q_UNUSED( xmlElement ); // unused in release mode
    Q_ASSERT( xmlElement.tagName() == "image" );

    if ( xmlElement.hasAttribute("broken") ) {
        KDReports::ErrorDetails details;
        details.setDriverMessage( QString("PC LOAD LETTER") );
        setErrorDetails( details );
        return false;
    }
    cb << "imageElement";
    return true;
}
Пример #25
0
void SoapBinding::Operation::loadXML( ParserContext *context, const QDomElement &element )
{
  mSoapAction = element.attribute( "soapAction" );

  if ( element.hasAttribute( "style" ) ) {
    if ( element.attribute( "style" ) == "rpc" )
      mStyle = RPCStyle;
    else if ( element.attribute( "style" ) == "document" )
      mStyle = DocumentStyle;
    else
      context->messageHandler()->warning( "SoapBinding::Operation: unknown 'style' value" );
  }

  // TODO: fallback is style value of soap:binding
}
Пример #26
0
void UV::fromXml (const QDomNode& noeud) {
  if (noeud.nodeName() != UV::XML_NODE_NAME) {
    throw "Fichier XML invalide";
  }
  
  QDomElement e = noeud.toElement();
  this->tag(e.attribute("tag"));
  this->titre(e.attribute("titre"));
  this->automne(e.hasAttribute("automne"));
  this->printemps(e.hasAttribute("printemps"));
  this->cursus(e.attribute("cursus").split(' '));

  QDomNodeList child = noeud.childNodes();

  for (int i = 0; i < child.count(); i++) {
    QDomNode c = child.at(i);
    if (c.nodeName() != UV::CREDIT_XML_NODE_NAME) {
      throw "Les uv ne peuvent contenir que des balises credits";
    }
    QDomElement e = c.toElement();
    QString type = e.attribute("type");
    this->_credits[type] = e.text().toInt();
  }
}
Пример #27
0
int QtXmlWrapper::getparbool(const std::string &name, int defaultpar) const
{
    QDomElement tmp = findElement( d->m_node, "par_bool", "name", name.c_str() );
    if( tmp.isNull() || !tmp.hasAttribute( "value" ) )
    {
        return defaultpar;
    }

    const QString val = tmp.attribute( "value" ).toLower();
    if( val[0] == 'y' )
    {
        return 1;
    }
    return 0;
}
Пример #28
0
void SoapBinding::Header::loadXML(ParserContext *context, const QDomElement &element)
{
    mMessage = element.attribute(QLatin1String("message"));
    if (mMessage.isEmpty()) {
        context->messageHandler()->warning(QLatin1String("SoapBinding::Header: 'message' required"));
    } else {
        if (!mMessage.prefix().isEmpty()) {
            mMessage.setNameSpace(context->namespaceManager()->uri(mMessage.prefix()));
        }
    }

    mPart = element.attribute(QLatin1String("part"));
    if (mPart.isEmpty()) {
        context->messageHandler()->warning(QLatin1String("SoapBinding::Header: 'part' required"));
    }

    if (element.attribute(QLatin1String("use")) == QLatin1String("literal")) {
        mUse = LiteralUse;
    } else if (element.attribute(QLatin1String("use")) == QLatin1String("encoded")) {
        mUse = EncodedUse;
    } else if (element.attribute(QLatin1String("use")).isEmpty()) {
        context->messageHandler()->warning(QLatin1String("SoapBinding::Header: 'use' required"));
    } else {
        context->messageHandler()->warning(QLatin1String("SoapBinding::Header: unknown 'use' value"));
    }

#if 0
    if (element.hasAttribute("encodingStyle")) {
        mEncodingStyle = element.attribute("encodingStyle");
    } else {
        mEncodingStyle = QString();
    }
#endif

    mNameSpace = element.attribute(QLatin1String("namespace"));

    QDomElement child = element.firstChildElement();
    while (!child.isNull()) {
        NSManager namespaceManager(context, child);
        if (child.tagName() == soapPrefix(context) + QLatin1String("headerfault")) {
            mHeaderFault.loadXML(context, child);
        } else {
            context->messageHandler()->warning(QString::fromLatin1("SoapBinding::Header: unknown tag %1").arg(child.tagName()));
        }

        child = child.nextSiblingElement();
    }
}
Пример #29
0
void
SmugMug::WebService::_parseLogin (QDomElement &root) {

    qDebug () << "_parseLogin";

    QSettings settings;
    settings.beginGroup (QLatin1String ("WebService"));
    settings.setValue (QLatin1String ("userName"), _userName);

    QDomElement loginElem = root.firstChildElement (QLatin1String ("Login"));
    if (!loginElem.isNull ()) {

        if (loginElem.hasAttribute (QLatin1String ("PasswordHash"))) {

            _passwordHash = loginElem.attribute (QLatin1String ("PasswordHash"));
            settings.setValue (QLatin1String ("passwordHash"), _passwordHash);

            qDebug () << "PasswordHash:" << _passwordHash;
        }
    }

    QDomNode node = loginElem.firstChild ();
    while (!node.isNull ()) {

        if (node.isElement ()) {

            QDomElement elem = node.toElement ();

            if (elem.tagName () == QLatin1String ("Session")) {

                _sessionId = elem.attribute (QLatin1String ("id"));
                qDebug () << "Session id:" << _sessionId;

                _loggedIn = !_sessionId.isEmpty ();
            }
            else if (elem.tagName () == QLatin1String ("User")) {

                _userId = elem.attribute (QLatin1String ("id"));
                settings.setValue (QLatin1String ("userId"), _userId);
                qDebug () << "User id:" << _userId;
            }
        }

        node = node.nextSibling ();
    }

    settings.endGroup ();
}
QgsEditorWidgetConfig QgsExternalResourceWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
{
  Q_UNUSED( layer )
  Q_UNUSED( fieldIdx )

  QgsEditorWidgetConfig cfg;

  if ( configElement.hasAttribute( "FileWidgetButton" ) )
    cfg.insert( "FileWidgetButton", configElement.attribute( "FileWidgetButton" ) == "1" );

  if ( configElement.hasAttribute( "FileWidget" ) )
    cfg.insert( "FileWidget", configElement.attribute( "FileWidget" ) == "1" );

  if ( configElement.hasAttribute( "UseLink" ) )
    cfg.insert( "UseLink", configElement.attribute( "UseLink" ) == "1" );

  if ( configElement.hasAttribute( "FullUrl" ) )
    cfg.insert( "FullUrl", configElement.attribute( "FullUrl" ) == "1" );

  if ( configElement.hasAttribute( "DefaultRoot" ) )
    cfg.insert( "DefaultRoot", configElement.attribute( "DefaultRoot" ) );

  if ( configElement.hasAttribute( "RelativeStorage" ) )
  {
    if (( configElement.attribute( "RelativeStorage" ) == "Default" && configElement.hasAttribute( "DefaultRoot" ) ) ||
        configElement.attribute( "RelativeStorage" ) == "Project" )
      cfg.insert( "RelativeStorage" , configElement.attribute( "RelativeStorage" ) );
  }

  if ( configElement.hasAttribute( "DocumentViewer" ) )
    cfg.insert( "DocumentViewer", configElement.attribute( "DocumentViewer" ) );

  if ( configElement.hasAttribute( "FileWidgetFilter" ) )
    cfg.insert( "FileWidgetFilter", configElement.attribute( "FileWidgetFilter" ) );


  cfg.insert( "StorageMode", configElement.attribute( "StorageMode", "Files" ) );

  return cfg;
}