Ejemplo n.º 1
0
ConstraintTypes::PlaylistFileSize::PlaylistFileSize( QDomElement& xmlelem, ConstraintNode* p )
        : Constraint( p )
        , m_size( 700 )
        , m_unit( 1 )
        , m_comparison( CompareNumEquals )
        , m_strictness( 1.0 )
{
    QDomAttr a;

    a = xmlelem.attributeNode( "size" );
    if ( !a.isNull() )
        m_size = a.value().toInt();

    a = xmlelem.attributeNode( "unit" );
    if ( !a.isNull() )
        m_unit = a.value().toInt();

    a = xmlelem.attributeNode( "comparison" );
    if ( !a.isNull() )
        m_comparison = a.value().toInt();

    a = xmlelem.attributeNode( "strictness" );
    if ( !a.isNull() )
        m_strictness = a.value().toDouble();
}
void
Pattern::xmlAddTransition(QDomElement _element)
{
    // a transition must have a message tag
    QDomAttr attrMessage = _element.attributeNode("message");
    if (attrMessage.isNull() ||
            attrMessage.value().isEmpty()) {
        throw BehaviourEngine::
        EMalformedPolicy(CORBA::string_dup("Transition without message."));
    }
    std::string message = attrMessage.value().latin1();

    // a transition must have a target tag
    QDomAttr attrPattern = _element.attributeNode("target");
    if (attrPattern.isNull() ||
            attrPattern.value().isEmpty()) {
        throw BehaviourEngine::
        EMalformedPolicy(CORBA::string_dup("Transition without target."));
    }
    std::string target = attrPattern.value().latin1();

    // internal transitions are only possible within some policy
    if (parent_ == NULL)
        throw BehaviourEngine::
        EMalformedPolicy(CORBA::string_dup("Internal transition at top level."));

    parent_->transitions_.insert(std::make_pair(std::make_pair(getName(),
                                 message),
                                 target));
}
Ejemplo n.º 3
0
ConstraintTypes::PlaylistLength::PlaylistLength( QDomElement& xmlelem, ConstraintNode* p )
        : Constraint( p )
        , m_length( 30 )
        , m_comparison( CompareNumEquals )
        , m_strictness( 1.0 )
{
    QDomAttr a;

    a = xmlelem.attributeNode( "length" );
    if ( !a.isNull() ) {
        m_length = a.value().toInt();
        /* after 2.3.2, what was the PlaylistLength constraint became the
         * PlaylistDuration constraint, so this works around the instance when
         * a user loads an XML file generated with the old code -- sth*/
        if ( m_length > 1000 )
            m_length /= 240000;
    }

    a = xmlelem.attributeNode( "comparison" );
    if ( !a.isNull() )
        m_comparison = a.value().toInt();

    a = xmlelem.attributeNode( "strictness" );
    if ( !a.isNull() )
        m_strictness = a.value().toDouble();
}
Ejemplo n.º 4
0
BattleEvent* BattleEvent::translateFromXML(QDomElement element) {
	QString ID = element.attributeNode("ID").value();
	QDomElement typeElement = element.firstChildElement("type");
	QString typeString = typeElement.attributeNode("value").value();

	if (typeString != "BATTLE")
		throw ProjectException("The translation of a battle event should have type BATTLE instead of " + typeString + ".");

	Event::Trigger trigger = Event::NONE;
	QString triggerString = element.firstChildElement("trigger").attributeNode("value").value();
	if (triggerString == "TOUCH")
		trigger = Event::TOUCH;
	else if (triggerString == "INTERACT")
		trigger = Event::INTERACT;
	else if (triggerString == "NONE")
		trigger = Event::NONE;

	BattleEvent *event = create(ID, trigger);
	Event::translateFromXML(element, event);

	QDomElement activationElement = element.firstChildElement("activation");
	event->setActivation(activationElement.attributeNode("value").value().toInt());

	return event;
}
Ejemplo n.º 5
0
ConstraintTypes::PlaylistDuration::PlaylistDuration( QDomElement& xmlelem, ConstraintNode* p )
        : Constraint( p )
        , m_duration( 0 )
        , m_comparison( CompareNumEquals )
        , m_strictness( 1.0 )
{
    QDomAttr a;

    a = xmlelem.attributeNode( "duration" );
    if ( !a.isNull() ) {
        m_duration = a.value().toInt();
    } else {
        // Accommodate schema change when PlaylistLength became PlaylistDuration
        a = xmlelem.attributeNode( "length" );
        if ( !a.isNull() )
            m_duration = a.value().toInt();
    }


    a = xmlelem.attributeNode( "comparison" );
    if ( !a.isNull() )
        m_comparison = a.value().toInt();

    a = xmlelem.attributeNode( "strictness" );
    if ( !a.isNull() )
        m_strictness = a.value().toDouble();
}
Ejemplo n.º 6
0
void LevelLoader::loadLine(QDomElement lineNode)
{
    // Reading the line number
    QDomAttr attribute = lineNode.attributeNode(QStringLiteral("Number"));
    QDomElement attributeNode = lineNode.firstChildElement(QStringLiteral("Number"));
    if (!attribute.isNull()) {
        m_lineNumber = attribute.value().toInt();
    } else if (!attributeNode.isNull()) {
        m_lineNumber = attributeNode.text().toInt();
    } else {
        // Standard line numbering: load next line
        m_lineNumber++;
    }

    // Reading the brick information
    attribute = lineNode.attributeNode(QStringLiteral("Bricks"));
    attributeNode = lineNode.firstChildElement(QStringLiteral("Bricks"));
    QString line;
    if (!attribute.isNull()) {
        line = attribute.value();
    } else if (!attributeNode.isNull()) {
        line = attributeNode.text();
    } else {
        line = lineNode.text();
    }

    if (line.size() > WIDTH) {
        qCritical() << "Invalid levelset " << m_levelname << ": too many bricks in line "
                    << m_lineNumber << endl;
    }

    emit newLine(line, m_lineNumber);
}
Ejemplo n.º 7
0
Variable* XDVariableParser::parseVar(QDomNode& node, Variable* parent, bool fullname)
{
  QDomElement e = node.toElement();
  
  PHPVariable* var = new PHPVariable(parent);

  int children = e.attributeNode("numchildren").value().toInt();
  QString type = e.attributeNode("type").value();
  
  QString fname = fullname?"fullname":"name";
  var->setName(e.attributeNode(fname).value());

  if(type == "object")
  {
    PHPObjectValue* objValue = new PHPObjectValue(var);
    var->setValue(objValue);
    objValue->setScalar(false);
    objValue->setClassType(e.attributeNode("classname").value());
    objValue->setList(parseList(e.childNodes(), var));
  }
  else if(children)
  {
    PHPArrayValue* arrayValue = new PHPArrayValue(var, children);
    var->setValue(arrayValue);
    arrayValue->setScalar(false);
    if (e.childNodes().count() > 0) 
    {
      arrayValue->setList(parseList(e.childNodes(), var, false));
    }
  }
  else
  {
    PHPScalarValue* value = new PHPScalarValue(var);
    var->setValue(value);

    if(type == "null")
    {
      value->setType(PHPScalarValue::Undefined);
      value->set("null");
    }
    else if(type == "int")
    {
      value->setType(PHPScalarValue::Integer);
      value->set(e.text());
    }
    else if(type == "string")
    {
      value->setType(PHPScalarValue::String);
      value->set(QString("\"") + QString(KCodecs::base64Decode (e.text().utf8())) + QString("\""));
    }
    else if(type == "float")
    {
      value->setType(PHPScalarValue::Double);
      value->set(e.text());
    }
  }
  return var;
}
Ejemplo n.º 8
0
void Block::Unmarshall( QDomElement& blockElement, Level* level )
{
  QDomAttr blockRowAttr = blockElement.attributeNode(BLOCK_ROW_ATTR);
  QDomAttr blockColumnAttr = blockElement.attributeNode(BLOCK_COLUMN_ATTR);

  UrAsset::setRow( blockRowAttr.value().toUInt() );
  UrAsset::setColumn( blockColumnAttr.value().toUInt() );
  UrAsset::calculateLevelEditorPosition(level->Row);
}
Ejemplo n.º 9
0
ConstraintTypes::TagMatch::TagMatch( QDomElement& xmlelem, ConstraintNode* p )
        : MatchingConstraint( p )
        , m_comparer( new Comparer() )
        , m_fieldsModel( new TagMatchFieldsModel() )
{
    DEBUG_BLOCK
    QDomAttr a;

    a = xmlelem.attributeNode( "field" );
    if ( !a.isNull() ) {
        if ( m_fieldsModel->contains( a.value() ) )
            m_field = a.value();
        else
            debug() << a.value() << "is not a recognized field name" << endl;
    }

    a = xmlelem.attributeNode( "comparison" );
    if ( !a.isNull() ) {
        m_comparison = a.value().toInt();
    }

    a = xmlelem.attributeNode( "value" );
    if ( !a.isNull() ) {
        if ( m_fieldsModel->type_of( m_field ) == FieldTypeInt ) {
            m_value = a.value().toInt();
        } else if ( m_fieldsModel->type_of( m_field ) == FieldTypeDate ) {
            if ( m_comparison == CompareDateWithin ) {
                QStringList parts = a.value().split(" ");
                if ( parts.size() == 2 ) {
                    int u = parts.at( 0 ).toInt();
                    int v = 0;
                    if ( parts.at( 1 ) == "months" )
                        v = 1;
                    else if ( parts.at( 1 ) == "years" )
                        v = 2;
                    m_value = QVariant::fromValue( DateRange( u, v ) );
                } else
                    m_value = QVariant::fromValue( DateRange( 0, 0 ) );
            } else
                m_value = QDate::fromString( a.value(), Qt::ISODate );
        } else { // String type
            m_value = a.value();
        }
    }

    a = xmlelem.attributeNode( "invert" );
    if ( !a.isNull() && a.value() == "true" )
        m_invert = true;
    else
        m_invert = false;

    a = xmlelem.attributeNode( "strictness" );
    if ( !a.isNull() )
        m_strictness = a.value().toDouble();

    debug() << getName();
}
Ejemplo n.º 10
0
int MainWindow::checkUserProfile(QString profile)
{
    QFile file(profile);
    qDebug()<<"本地profile文件检查";
    if(!file.open(QFile::ReadOnly | QFile::Text))
    {
        qDebug()<<"XML文件打开失败";
        this->statusBarLabel->setText("can't find xml file");
        QMessageBox::critical(NULL,"错误", "找不到启动配置文件,进入登陆认证", QMessageBox::Yes, QMessageBox::Yes);
        //goto ask for new config file,other exit
        return -1;
    }
    qDebug()<<profile<< "file open";
 //   QDomDocument doc;
    QString errStr;
    int errLine, errCol;
    // setContent 是将指定的内容指定给QDomDocument 解析,第一参数可以是QByteArray或者是文件名等。
    if(!userProfile.setContent(&file, false, &errStr, &errLine, &errCol))
    {
        qDebug()<<tr("指定XML内容失败 原因: ") << errStr;
    }
    file.close();
    QDomElement node = userProfile.documentElement();
    qDebug()<<node.tagName();
    node = node.firstChildElement();
    int userInfo = 0;

    while(!node.isNull())
    {
        if(node.tagName() == tr("userInfo")){
            qDebug()<<node.attributeNode("userName").nodeValue();
            qDebug()<<node.attributeNode("password").nodeValue();
            qDebug()<<node.attributeNode("email").nodeValue();
            userInfo++;

        }
        if(node.tagName() == tr("phoneInfo")){
            qDebug()<<node.attributeNode("brand").nodeValue();
            qDebug()<<node.attributeNode("model").nodeValue();
            qDebug()<<node.attributeNode("rom").nodeValue();
            userInfo++;
        }
        node = node.nextSiblingElement();
    }
    if(userInfo > 1){
        QMessageBox info;
        info.addButton(QMessageBox::Ok);
        info.setText(tr("请重新输入密码、邮箱,选择对应的手机型号,如果找不到您的手机型号,请选择其他,并且你的其他中表示出的你的手机型号,功能加紧研发中,如果有特殊需求,请邮件联系[email protected]"));
        info.exec();
        return 1;
    }
    else{
        qDebug()<<"user info error";
        return -1;
    }

}
Ejemplo n.º 11
0
void LevelLoader::loadLevel(QList< Brick* >& bricks)
{   
    // Selecting the correct level
    m_level++;
    
    if( m_levelset == 0 ){
        qDebug() << "Error: No levelset specified" << endl;
        return;
    }
    
    QDomElement levels = m_levelset->documentElement();
    QDomNode node = levels.firstChild();
    for( int i = 1; i < m_level; i++ ){
        node = node.nextSibling();
    }
    // --
    
    // Load level information
    if( node.isNull() || node.toElement().tagName() != "Level" ){
        // Level not found or no more levels
        return;
    }
    
    QDomAttr attribute;
    QDomElement level = node.toElement();
    if( level.isNull() ){
        qDebug() << "Invalid Levelset " << m_levelname << ": Can't read level information";
    }
    attribute = level.attributeNode("Name");
    QString levelName;
    if( !attribute.isNull() ){
        levelName = level.attributeNode("Name").value();
    }
    node = node.firstChild();
    // --
    
    // Load bricks and gifts
    m_lineNumber = 0;
    while( !node.isNull() ){
        QDomElement info = node.toElement();
        if( info.isNull() ){ qDebug() << "Invalid levelset " << m_levelname << ": Can't read level information."; }
            
        if( info.tagName() == "Line" ){
            // Load one line of bricks
            loadLine( info, bricks );
        } else if( info.tagName() == "Gift" ){
            // Load one gift type
            loadGift( info, bricks );
        } else {
            qDebug() << "Invalid tag name " << info.tagName() << " has occured in level "
                     << levelName << " in levelset " << m_levelname << endl;
        }
        
        node = node.nextSibling();
    }
}
Ejemplo n.º 12
0
void Prefs_KeyboardShortcuts::importKeySet(QString filename)
{
	searchTextLineEdit->clear();
	QFileInfo fi = QFileInfo(filename);
	if (fi.exists())
	{
		//import the file into qdomdoc
		QDomDocument doc( "keymapentries" );
		QFile file1( filename );
		if ( !file1.open( QIODevice::ReadOnly ) )
			return;
		QTextStream ts(&file1);
		ts.setCodec("UTF-8");
		QString errorMsg;
		int eline;
		int ecol;
		if ( !doc.setContent( ts.readAll(), &errorMsg, &eline, &ecol ))
		{
			qDebug("%s", QString("Could not open key set file: %1\nError:%2 at line: %3, row: %4").arg(filename).arg(errorMsg).arg(eline).arg(ecol).toLatin1().constData());
			file1.close();
			return;
		}
		file1.close();
		//load the file now
		QDomElement docElem = doc.documentElement();
		if (docElem.tagName()=="shortcutset" && docElem.hasAttribute("name"))
		{
			QDomAttr keysetAttr = docElem.attributeNode( "name" );

			//clear current menu entries
			for (QMap<QString,Keys>::Iterator it=keyMap.begin(); it!=keyMap.end(); ++it)
				it.value().keySequence = QKeySequence();

			//load in new set
			QDomNode n = docElem.firstChild();
			while( !n.isNull() )
			{
				QDomElement e = n.toElement(); // try to convert the node to an element.
				if( !e.isNull() )
				{
					if (e.hasAttribute("name")  && e.hasAttribute( "shortcut" ))
					{
						QDomAttr nameAttr = e.attributeNode( "name" );
						QDomAttr shortcutAttr = e.attributeNode( "shortcut" );
						if (keyMap.contains(nameAttr.value()))
							keyMap[nameAttr.value()].keySequence=QKeySequence(shortcutAttr.value());
					}
				}
				n = n.nextSibling();
			}
		}
	}
	insertActions();
}
Ejemplo n.º 13
0
QString cDefinable::getNodeValue( const QDomElement &Tag )
{
	QString Value = QString();
	
	if( !Tag.hasChildNodes() )
		return "";
	else
	{
		QDomNode childNode = Tag.firstChild();
		while( !childNode.isNull() )
		{
			if( !childNode.isElement() )
			{
				if( childNode.isText() )
					Value += childNode.toText().data();
				childNode = childNode.nextSibling();
				continue;
			}
			QDomElement childTag = childNode.toElement();
			if( childTag.nodeName() == "random" )
			{
				if( childTag.attributes().contains("min") && childTag.attributes().contains("max") )
					Value += QString("%1").arg( RandomNum( childTag.attributeNode("min").nodeValue().toInt(), childTag.attributeNode("max").nodeValue().toInt() ) );
				else if( childTag.attributes().contains("valuelist") )
				{
					QStringList RandValues = QStringList::split(",", childTag.attributeNode("list").nodeValue());
					Value += RandValues[ RandomNum(0,RandValues.size()-1) ];
				}
				else if( childTag.attributes().contains( "list" ) )
				{
					Value += DefManager->getRandomListEntry( childTag.attribute( "list" ) );
				}
				else if( childTag.attributes().contains("dice") )
					Value += QString("%1").arg(rollDice(childTag.attributeNode("dice").nodeValue()));
				else
					Value += QString("0");
			}

			// Process the childnodes
			QDomNodeList childNodes = childTag.childNodes();

			for( int i = 0; i < childNodes.count(); i++ )
			{
				if( !childNodes.item( i ).isElement() )
					continue;

				Value += this->getNodeValue( childNodes.item( i ).toElement() );
			}
			childNode = childNode.nextSibling();
		}
	}
	return hex2dec( Value );
}
Ejemplo n.º 14
0
void LevelLoader::loadGift(QDomElement giftNode)
{
    bool nodeTextRead = false;
    // Reading the brick type
    QDomAttr attribute = giftNode.attributeNode(QStringLiteral("Type"));
    QDomElement attributeNode = giftNode.firstChildElement(QStringLiteral("Type"));
    QString giftType;
    if (!attribute.isNull()) {
        giftType = attribute.value();
    } else if (!attributeNode.isNull()) {
        giftType = attributeNode.text();
        nodeTextRead = true;
    } else {
        giftType = giftNode.text();
        nodeTextRead = true;
    }

    // Reading number of gifts to be distributed. If not specified one gift is placed.
    attribute = giftNode.attributeNode(QStringLiteral("Count"));
    attributeNode = giftNode.firstChildElement(QStringLiteral("Count"));
    int times = 1;
    bool ok = true;
    if (!attribute.isNull()) {
        times = attribute.value().toInt(&ok);
    } else if (!attributeNode.isNull()) {
        times = attributeNode.text().toInt(&ok);
        nodeTextRead = true;
    } else if (!nodeTextRead) {
        times = giftNode.text().toInt(&ok);
        if (!ok) {
            times = 1;
        }
    }

    // If only one brick to be placed: see if position is given
    QString position;
    if (times == 1) {
        attribute = giftNode.attributeNode(QStringLiteral("Position"));
        attributeNode = giftNode.firstChildElement(QStringLiteral("Position"));
        if (!attribute.isNull()) {
            position = attribute.value();
        } else if (!attributeNode.isNull()) {
            position = attributeNode.text();
            nodeTextRead = true;
        } else if (!nodeTextRead && giftNode.text().contains(QLatin1Char(','))) {
            position = giftNode.text();
            nodeTextRead = true;
        }
    }

    emit newGift(giftType, times, position);
}
Ejemplo n.º 15
0
static void mergeBenchmarkResults(const QString &xmlFile, BenchmarkResults *bmResults)
{
    QFile f(xmlFile);
    f.open(QIODevice::ReadOnly);
    QByteArray xml = f.readAll();

    QDomDocument doc;

    int line;
    int col;
    QString errorMsg;
    if (doc.setContent(xml, &errorMsg, &line, &col) == false) {
        qDebug() << "dom setContent failed" << line << col << errorMsg;
    }

    int outputPos = 0;

    QDomNodeList testFunctions = doc.elementsByTagName("TestFunction");
    for (int i = 0; i < testFunctions.count(); ++i) {
        QDomElement function = testFunctions.at(i).toElement();
        QString functionName = function.attributeNode("name").value();

        QDomNodeList results = function.elementsByTagName("BenchmarkResult");
        for (int j = 0; j < results.count(); ++j) {    
            QDomElement result = results.at(j).toElement();
            QString tag = result.attributeNode("tag").value();
            QString metric = result.attributeNode("metric").value();
            
            QString valueString = result.attributeNode("value").value();
            QString iterationsString = result.attributeNode("iterations").value();
            const int value = valueString.toInt();
            const int iterations = iterationsString.toInt();

            const QString funcTag = functionName + tag;
            BenchmarkResult *bmResult = bmResults->value(funcTag);
            if (!bmResult) {
                bmResult = new BenchmarkResult(functionName, tag, outputPos++);
                bmResults->insert(funcTag, bmResult);
            }

            MetricResult *metricResult = bmResult->metricResults.value(metric);
            if (!metricResult) {
                metricResult = new MetricResult(value, iterations);
                bmResult->metricResults.insert(metric, metricResult);
            }
        }
    }
}
Ejemplo n.º 16
0
bool ItDocument::scanNode(QDomNode node)
{
    ItElement* itElement;
    QDomElement e = node.toElement();
    //qDebug() << "New element";
    if (!e.isNull()) {
        //QDomElement* element = static_cast<QDomElement*>(&node);
        //QDomElement element = QDomElement (node);
        QDomAttr a = e.attributeNode("id");
        QString id = "";
        if (!a.isNull() && a.namespaceURI()==idNamespaceURI) {
            id =  e.attribute("id","");
        }
        //if (!a.isNull() && a.namespaceURI()!=idNamespaceURI) {qDebug()<<"URI: "<<a.namespaceURI(); }
        //qDebug() << "Adding id:" << id;
        if (id != "") {
            if (index.contains(id)) {
                errorMessage = QObject::tr("Duplicate id '%1' for element '%2'.").arg(id, e.tagName());
                return false;
            }
            itElement = new ItElement(e);
            index[id] = itElement;
        }
        QDomNodeList children = e.childNodes();
        for (unsigned int i=0; i<children.length(); ++i) {
            if (!scanNode(children.at(i)))
                return false;
        }
    }
    return true;
}
Ejemplo n.º 17
0
void Level::Unmarshall( QDomElement& levelElement )
{
  QDomAttr idAttr = levelElement.attributeNode(LEVEL_ID_ATTR);
  QDomAttr nameAttr = levelElement.attributeNode(LEVEL_NAME_ATTR);

  QDomElement descriptionElement = levelElement.firstChildElement(LEVEL_DESCRIPTION_TAG);
  QDomElement sizeElement = levelElement.firstChildElement(LEVEL_SIZE_TAG);
  QDomAttr sizeColumnAttr = sizeElement.attributeNode(LEVEL_SIZE_COLUMN_ATTR);
  QDomAttr sizeRowAttr = sizeElement.attributeNode(LEVEL_SIZE_ROW_ATTR);

  Id = idAttr.value().toUInt();
  Name = nameAttr.value();
  Description = descriptionElement.text();
  Row = sizeRowAttr.value().toUInt();
  Column = sizeColumnAttr.value().toUInt();
}
Ejemplo n.º 18
0
int ImageshackTalker::parseErrorResponse(QDomElement elem, QString& errMsg)
{
    int errCode = -1;
    QString err_code;

    for (QDomNode node = elem.firstChild();
         !node.isNull();
         node = node.nextSibling())
    {
        if (!node.isElement())
            continue;
        QDomElement e = node.toElement();
        if (e.tagName() == "error") {
            err_code = e.attributeNode("id").value();
            errMsg = e.text();
        }
    }

    if (err_code == "file_too_big")
    {
        errCode = 501;
    }
    else
    {
        errCode = 502;
    }

    return errCode;
}
Ejemplo n.º 19
0
/**
* Translate the text event from XML.
*/
TextEvent* TextEvent::translateFromXML(QDomElement element) {
	QString ID = element.attributeNode("ID").value();
	QDomElement typeElement = element.firstChildElement("type");
	QString typeString = typeElement.attributeNode("value").value();

	if (typeString != "TEXT")
		throw ProjectException("The translation of a text event should have type TEXT instead of " + typeString + ".");

	Event::Trigger trigger = Event::NONE;
	QString triggerString = element.firstChildElement("trigger").attributeNode("value").value();
	if (triggerString == "TOUCH")
		trigger = Event::TOUCH;
	else if (triggerString == "INTERACT")
		trigger = Event::INTERACT;
	else if (triggerString == "NONE")
		trigger = Event::NONE;

	TextEvent *event = create(ID, trigger);
	Event::translateFromXML(element, event);

	QDomNodeList textElements = element.elementsByTagName("text");
	for (int i = 0; i < textElements.size(); i++) {
		QDomElement textElement = textElements.at(i).toElement();
		event->addMessage(textElement.text());
	}

	return event;
}
Ejemplo n.º 20
0
static PyObject *meth_QDomElement_attributeNode(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))
        {
            QDomAttr*sipRes;

            sipRes = new QDomAttr(sipCpp->attributeNode(*a0));
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);

            return sipConvertFromNewType(sipRes,sipType_QDomAttr,NULL);
        }
    }

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

    return NULL;
}
Ejemplo n.º 21
0
void ConfigGuiSunbird::load( const QString &xml )
{
  QString path;
  QString url;
  QString username;
  QString password;
  QString defaultcal;
  QString days;

  QDomDocument doc;
  doc.setContent( xml );
  QDomElement docElement = doc.documentElement();
  QDomNode node;
  for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
    QDomElement element = node.toElement();
    if ( element.tagName() == "file" ) {
      QDomAttr pathAttr = element.attributeNode( "path" );
      path = pathAttr.value();
      QDomAttr defaultAttr = element.attributeNode( "default" );
      defaultcal = defaultAttr.value();
      QDomAttr daysAttr = element.attributeNode( "deletedaysold" );
      days = daysAttr.value();

      LocalCalendar *cal = new LocalCalendar( path, defaultcal, days, mLocalWidget );
      mLocalLayout->removeItem( mLocalSpacer );
      cal->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
      mLocalLayout->addWidget( cal );
      mLocalLayout->addItem( mLocalSpacer );
      mLocalList.append( cal );

      connect( cal, SIGNAL( deleteRequest( LocalCalendar* ) ), SLOT( delLocalCalendar( LocalCalendar* ) ) );
      cal->show();
    } else if ( element.tagName() == "webdav" ) {
      QDomAttr urlAttr = element.attributeNode( "url" );
      url = urlAttr.value();
      QDomAttr unameAttr = element.attributeNode( "username" );
      username = unameAttr.value();
      QDomAttr pwordAttr = element.attributeNode( "password" );
      password = pwordAttr.value();
      QDomAttr defaultAttr = element.attributeNode( "default" );
      defaultcal = defaultAttr.value();
      QDomAttr daysAttr = element.attributeNode( "deletedaysold" );
      days = daysAttr.value();

      WebdavCalendar *cal = new WebdavCalendar( username, password,
                                                url, defaultcal, days, mWebdavWidget );
      mWebdavLayout->removeItem( mWebdavSpacer );
      cal->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
      mWebdavLayout->addWidget( cal );
      mWebdavLayout->addItem( mWebdavSpacer );
      mWebdavList.append( cal );

      connect( cal, SIGNAL( deleteRequest( WebdavCalendar* ) ), SLOT( delWebdavCalendar( WebdavCalendar* ) ) );
      cal->show();
    }
  }
}
Ejemplo n.º 22
0
int MainWindow::execCmdList(QDomElement node)
{
    QMessageBox info;
    info.addButton(QMessageBox::Ok);
    info.setText(("开始进行系统备份,请按照提示执行"));
    info.exec();
    QString cmd,errorString;
    int cmdType = 0,errorCheckType=0,timeOut=0;
//    QStringList par;
//    par<<"";
    int checkValue;
    while(!node.isNull()){
        cmd = node.attributeNode("cmd").nodeValue();
        errorString = node.attributeNode("errorString").nodeValue();
        cmdType = node.attributeNode("type").nodeValue().toInt();
        errorCheckType = node.attributeNode("errorCheckType").nodeValue().toInt();
        timeOut = node.attributeNode("timeOut").nodeValue().toInt();
        node = node.nextSiblingElement();
        qDebug()<<cmd <<errorString<<cmdType<<errorCheckType<<timeOut;
        switch(cmdType){
        case 1:
            qDebug()<<"cmd-->" << cmd;
 //           this->pointer->waitForFinished(timeOut*1000);
            this->pointer->start(cmd);
            this->pointer->waitForFinished(timeOut*1000);
            checkValue = this->checkError(errorCheckType,&errorString);
            if(checkValue < 0){
                return checkValue;
            }
            break;
        case 2:
            qDebug()<<"status :"<<cmd;
            break;
        case 3:
            info.setText((cmd));
            info.exec();
            break;
        case 4:

            break;
        default:
            break;
        }
    }
    return 1;
}
Ejemplo n.º 23
0
    bool operator()(QDomNode node) {
	QDomElement elem = node.toElement();
	QDomAttr attr = elem.attributeNode("id");
	if(!attr.isNull() && attr.value() == m_value) {
	    return true;
	}
	return false;
    }
Ejemplo n.º 24
0
bool QgsAttributeAction::readXML( const QDomNode& layer_node )
{
  mActions.clear();

  QDomNode aaNode = layer_node.namedItem( "attributeactions" );

  if ( !aaNode.isNull() )
  {
    QDomNodeList actionsettings = aaNode.childNodes();
    for ( unsigned int i = 0; i < actionsettings.length(); ++i )
    {
      QDomElement setting = actionsettings.item( i ).toElement();
      addAction(( QgsAction::ActionType ) setting.attributeNode( "type" ).value().toInt(),
                setting.attributeNode( "name" ).value(),
                setting.attributeNode( "action" ).value(),
                setting.attributeNode( "capture" ).value().toInt() != 0 );
    }
  }
  return true;
}
Ejemplo n.º 25
0
/* remove file */
QString UnionXml::GetAtt(QDomElement e, QString name) {
    QString textvalue;
    QString errorvalue = "ERROR";
    QDomAttr a1 = e.attributeNode(name);
    textvalue = a1.value();
    if (textvalue.size() > 0) {
        return textvalue;
    } else {
        return errorvalue;
    }
}
Ejemplo n.º 26
0
QString XmlHelper::ParseXmlNodeAttribute(const QDomElement &elem, const QString& attr_key)
{
    QString str;
    QDomNodeList node_list = doc_.elementsByTagName(elem.tagName());
    if (node_list.count() > 0)
    {
        QDomElement elem = node_list.at(0).toElement();
        str = elem.attributeNode(attr_key).toText().data();
    }

    return str;
}
Ejemplo n.º 27
0
void LevelLoader::loadLine(QDomElement lineNode, QList< Brick* >& bricks)
{
    // Reading the line number
    QDomAttr attribute = lineNode.attributeNode("Number");
    QDomElement attributeNode = lineNode.firstChildElement("Number");
    if( !attribute.isNull() ){
        m_lineNumber = attribute.value().toInt();
    } else if( !attributeNode.isNull() ) {
        m_lineNumber = attributeNode.text().toInt();
    } else {
        // Standard line numbering: load next line
        m_lineNumber++;
    }
    
    // Reading the brick information
    attribute = lineNode.attributeNode("Bricks");
    attributeNode = lineNode.firstChildElement("Bricks");
    QString line;
    if( !attribute.isNull() ){
        line = attribute.value();
    } else if( !attributeNode.isNull() ) {
        line = attributeNode.text();
    } else {
        line = lineNode.text();
    }

    if( line.size() > WIDTH ){
        qDebug() << "Invalid levelset " << m_levelname << ": too many bricks in line "
                 << m_lineNumber << endl;
    }
    
    // Convert line information to bricks
    for( int x = 0; x < line.size(); x++ ){
        char charType = line[x].toLatin1();
        if (charType != '-') {
            bricks.append( new Brick(m_game, getTypeFromChar(charType), x+1, m_lineNumber) );
        }
    }
}
Ejemplo n.º 28
0
void MainWindow::on_pushButton_backup_clicked()
{
    QDomElement node = backupDoc.documentElement();
    qDebug()<<node.tagName();
    node = node.firstChildElement();
    qDebug()<<node.tagName();
    while(!node.isNull()){
        if(node.attributeNode("name").nodeValue() == ui->comboBox_backup_plan->currentText()){
            qDebug()<<node.attributeNode("name").nodeValue() << node.tagName();
            break;
        }
        node=node.nextSiblingElement();
    }
    if(node.isNull()){
        QMessageBox info;
        info.addButton(QMessageBox::Ok);
        info.setText(tr("找不到备份方案,请升级后尝试"));
        info.exec();
        return ;
    }
    execCmdList(node.firstChildElement());

}
Ejemplo n.º 29
0
void myWizard::getPhoneModel(int index)
{
    qDebug()<<"state change";
    QDomElement child = phoneDoc.documentElement().firstChildElement();
    while(!child.isNull()){
        if(ui->comboBox_phone_brife->currentText() == child.attributeNode("brandName").nodeValue())
            break;
        child = child.nextSiblingElement();
    }
    ui->comboBox_phone_detail->clear();
    if(child.isNull()){
        qDebug()<<"can find the index :"<<ui->comboBox_phone_brife->currentText();
        return ;
    }
    child = child.firstChildElement();
    QStringList brand;
    while(!child.isNull()){
        brand << child.attributeNode("modelName").nodeValue();
        qDebug()<<child.attributeNode("modelName").nodeValue() << child.tagName();
        child = child.nextSiblingElement();
    }
    ui->comboBox_phone_detail->addItems(brand);
}
Ejemplo n.º 30
0
void myWizard::initSystem(void){
    QFile file("./phone.xml");
    if(!file.open(QFile::ReadOnly | QFile::Text))
    {
        qDebug()<<"XML文件打开失败";
        QMessageBox::critical(NULL,"致命错误", "找不到启动配置文件", QMessageBox::Yes, QMessageBox::Yes);
        //goto ask for new config file,other exit

    }
    qDebug()<<"file open";
 //   QDomDocument doc;
    QString errStr;
    int errLine, errCol;
    // setContent 是将指定的内容指定给QDomDocument 解析,第一参数可以是QByteArray或者是文件名等。
    if(!phoneDoc.setContent(&file, false, &errStr, &errLine, &errCol))
    {
        qDebug()<<tr("指定XML内容失败 原因: ") << errStr;
    }
    file.close();

    QDomElement root = phoneDoc.documentElement();
    QDomElement child = root;
    qDebug()<<child.tagName();
    child = child.firstChildElement();
    qDebug()<<child.tagName();
    QStringList brand;
    while(!child.isNull()){
        brand << child.attributeNode("brandName").nodeValue();
        qDebug()<<child.attributeNode("brandName").nodeValue() << child.tagName();
        child = child.nextSiblingElement();
    }
    ui->comboBox_phone_brife->addItems(brand);
    connect(ui->comboBox_phone_brife,SIGNAL(currentIndexChanged(int)),this,SLOT(getPhoneModel(int)));


}