Exemple #1
0
bool ProItemInfoManager::load(const QString &filename)
{
    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly))
        return false;

    QDomDocument doc;
    if (!doc.setContent(&file))
        return false;

    QDomElement root = doc.documentElement();
    if (root.nodeName() != QLatin1String("proiteminfo"))
        return false;

    QDomElement child = root.firstChildElement();
    for (; !child.isNull(); child = child.nextSiblingElement()) {
        if (child.nodeName() == QLatin1String("scope"))
            readScope(child);
        else if (child.nodeName() == QLatin1String("variable"))
            readVariable(child);
    }

    file.close();
    return true;
}
Exemple #2
0
/*!
    ...
*/
QMap<QString, QKeySequence> CommandsFile::importCommands() const
{
    QMap<QString, QKeySequence> result;

    QFile file(m_filename);
    if (!file.open(QIODevice::ReadOnly))
        return result;

    QDomDocument doc("KeyboardMappingScheme");
    if (!doc.setContent(&file))
        return result;

    QDomElement root = doc.documentElement();
    if (root.nodeName() != QLatin1String("mapping"))
        return result;

    QDomElement ks = root.firstChildElement();
    for (; !ks.isNull(); ks = ks.nextSiblingElement()) {
        if (ks.nodeName() == QLatin1String("shortcut")) {
            QString id = ks.attribute(QLatin1String("id"));
            QKeySequence shortcutkey;
            QDomElement keyelem = ks.firstChildElement("key");
            if (!keyelem.isNull())
                shortcutkey = QKeySequence(keyelem.attribute("value"));
            result.insert(id, shortcutkey);
        }
    }

    file.close();
    return result;
}
Exemple #3
0
void RuleSet::fromXml(const QDomElement& ele) throw(XmlParseException)
{
    QDomNodeList list = ele.childNodes();
    int len = list.length();
    QDomElement current;
    
    for(int i = 0; i < len; i++)
    {
        current = list.item(i).toElement();
        if(!current.isNull())
        {
            if(current.nodeName() == "book")
                m_book = current.text().simplified();
            else if(current.nodeName() == "version")
                m_version = current.text().simplified();
            else if(current.nodeName() == "edition")
                m_edition = current.text().simplified();
            else if(current.nodeName() == "rules")
                RuleList::fromXml(current);
            else
                throw XmlParseException("invalid node" , current);
        }
    }
    
    if(m_book.isEmpty())
        throw XmlParseException("missing ruleset book node", ele);
    
    if(m_edition.isEmpty())
        throw XmlParseException("missing ruleset edition node", ele);
    
    if(m_version.isEmpty())
        throw XmlParseException("missing ruleset version node", ele);
}
void cHorizontalScrollbar::processDefinitionElement(QDomElement element) {
	if (element.nodeName() == "leftbutton") {
		ushort unpressed = Utilities::stringToUInt(element.attribute("unpressed"));
		ushort pressed = Utilities::stringToUInt(element.attribute("pressed", QString::number(unpressed)));
		ushort hover = Utilities::stringToUInt(element.attribute("hover", QString::number(pressed)));
		setLeftButtonIds(unpressed, pressed, hover);
	} else if (element.nodeName() == "rightbutton" && element.hasAttribute("unpressed")) {
		ushort unpressed = Utilities::stringToUInt(element.attribute("unpressed"));
		ushort pressed = Utilities::stringToUInt(element.attribute("pressed", QString::number(unpressed)));
		ushort hover = Utilities::stringToUInt(element.attribute("hover", QString::number(pressed)));
		setRightButtonIds(unpressed, pressed, hover);
	} else if (element.nodeName() == "range" && element.hasAttribute("min") && element.hasAttribute("max")) {
		int min = Utilities::stringToInt(element.attribute("min"));
		int max = Utilities::stringToInt(element.attribute("max"));
		setRange(min, max);
	} else if (element.nodeName() == "background" && element.hasAttribute("id1")) {
		ushort id1 = Utilities::stringToUInt(element.attribute("id1"));
		ushort id2 = Utilities::stringToUInt(element.attribute("id2", QString::number(id1)));
		ushort id3 = Utilities::stringToUInt(element.attribute("id3", QString::number(id1)));
		ushort id4 = Utilities::stringToUInt(element.attribute("id4", QString::number(id1)));
		ushort id5 = Utilities::stringToUInt(element.attribute("id5", QString::number(id1)));
		ushort id6 = Utilities::stringToUInt(element.attribute("id6", QString::number(id1)));
		ushort id7 = Utilities::stringToUInt(element.attribute("id7", QString::number(id1)));
		ushort id8 = Utilities::stringToUInt(element.attribute("id8", QString::number(id1)));
		ushort id9 = Utilities::stringToUInt(element.attribute("id9", QString::number(id1)));
		background->setIds(id1, id2, id3, id4, id5, id6, id7, id8, id9);
	} else {
		cContainer::processDefinitionElement(element);
	}
}
Exemple #5
0
QString XmlUtil::stripAnswers(const QString &input) {
	QDomDocument doc;
	doc.setContent(input);
	QDomElement docElem = doc.documentElement();

	QDomNode n = docElem.firstChild();
	while ( !n.isNull() ) {
		QDomElement e = n.toElement();
		if ( !e.isNull() && (e.namespaceURI().isEmpty() || e.namespaceURI() == XML_NS) ) {
			if ( e.nodeName() == "choose" ) {
				QDomElement c = e.firstChildElement("choice");
				while ( !c.isNull() ) {
					c.removeAttribute("answer");
					c = c.nextSiblingElement("choice");
				}
			} else if ( e.nodeName() == "identification" ) {
				QDomElement a = e.firstChildElement("a");
				while ( !a.isNull() ) {
					e.removeChild(a);
					a = e.firstChildElement("a");
				}
			}
		}
		n = n.nextSibling();
	}
	return doc.toString(2);
}
Exemple #6
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("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);
  }

}
Album ParserAlbum::getAlbumFromFile(const QString &_name)
{
    m_pFile->close();
    if(!m_pFile->open(QIODevice::ReadOnly))
    {
        qDebug() << "Can`t open file : " << m_pFile->fileName();
    }
    Album newAlbum;
    newAlbum.setName(_name);
    QDomElement element = m_pDoc->documentElement();
    QDomNode node = element.firstChild();
    while(!node.isNull())
    {
        if(node.isElement())
        {
            QDomElement domElement = node.toElement();
            if(domElement.nodeName() == "images")
            {
                if(domElement.hasChildNodes())
                {
                    getImages(newAlbum,domElement.childNodes());
                }
            }
            if(domElement.nodeName() == "current")
            {
                newAlbum.setCurrentIndex(domElement.text().toInt());
            }
            node = node.nextSibling().toElement();
        }
    } 
    m_pFile->close();
    return newAlbum;
}
Exemple #8
0
bool FilterScript::open(QString filename)
{
    QDomDocument doc;
    filtparlist.clear();
    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly))
    {
        qDebug("Failure in opening Script %s", qUtf8Printable(filename));
        qDebug("Current dir is %s", qUtf8Printable(QDir::currentPath()));
        return false;
    }
    QString errorMsg; int errorLine,errorColumn;
    if(!doc.setContent(&file,false,&errorMsg,&errorLine,&errorColumn))
    {
        qDebug("Failure in setting Content line %i column %i \nError'%s'",errorLine,errorColumn, qUtf8Printable(errorMsg));
        return false;
    }
    file.close();
    QDomElement root = doc.documentElement();
    if(root.nodeName() != "FilterScript")
    {
        qDebug("Failure in parsing script %s\nNo root node with name FilterScript\n", qUtf8Printable(filename));
        qDebug("Current rootname is %s", qUtf8Printable(root.nodeName()));
        return false;
    }

    qDebug("FilterScript");
    for(QDomElement nf = root.firstChildElement(); !nf.isNull(); nf = nf.nextSiblingElement())
    {
        if (nf.tagName() == QString("filter"))
        {
            RichParameterSet par;
            QString name=nf.attribute("name");
            qDebug("Reading filter with name %s", qUtf8Printable(name));
            for(QDomElement np = nf.firstChildElement("Param"); !np.isNull(); np = np.nextSiblingElement("Param"))
            {
                RichParameter* rp = NULL;
                RichParameterAdapter::create(np,&rp);
                //FilterParameter::addQDomElement(par,np);
                par.paramList.push_back(rp);
            }
            OldFilterNameParameterValuesPair* tmp = new OldFilterNameParameterValuesPair();
            tmp->pair = qMakePair(name,par);
            filtparlist.append(tmp);
        }        
        else
        {
            QString name=nf.attribute("name");
            qDebug("Reading filter with name %s", qUtf8Printable(name));
            QMap<QString,QString> map;
            for(QDomElement np = nf.firstChildElement("xmlparam"); !np.isNull(); np = np.nextSiblingElement("xmlparam"))
                map[np.attribute("name")] = np.attribute("value");
            XMLFilterNameParameterValuesPair* tmp = new XMLFilterNameParameterValuesPair();
            tmp->pair = qMakePair(name,map);
            filtparlist.append(tmp);
        }
    }

    return true;
}
void ReportUser::On_DiffTick()
{
    if (this->qDiff == NULL)
    {
        return;
    }
    if (!this->qDiff->IsProcessed())
    {
        return;
    }
    if (this->qDiff->Result->Failed)
    {
        ui->webView->setHtml(_l("browser-fail", this->qDiff->Result->ErrorMessage));
        this->tPageDiff->stop();
        return;
    }
    QString Summary;
    QString Diff;
    QDomDocument d;
    d.setContent(this->qDiff->Result->Data);
    QDomNodeList l = d.elementsByTagName("rev");
    QDomNodeList diff = d.elementsByTagName("diff");
    if (diff.count() > 0)
    {
        QDomElement e = diff.at(0).toElement();
        if (e.nodeName() == "diff")
        {
            Diff = e.text();
        }
    } else
    {
        Huggle::Syslog::HuggleLogs->DebugLog(this->qDiff->Result->Data);
        this->ui->webView->setHtml("Unable to retrieve diff because api returned no data for it, debug information:<br><hr>" +
                                HuggleWeb::Encode(this->qDiff->Result->Data));
        this->tPageDiff->stop();
        return;
    }
    // get last id
    if (l.count() > 0)
    {
        QDomElement e = l.at(0).toElement();
        if (e.nodeName() == "rev")
        {
            if (e.attributes().contains("comment"))
            {
                Summary = e.attribute("comment");
            }
        }
    }

    if (!Summary.size())
        Summary = "<font color=red>" + _l("browser-miss-summ") + "</font>";
    else
        Summary = HuggleWeb::Encode(Summary);

    this->ui->webView->setHtml(Resources::GetHtmlHeader() + Resources::DiffHeader + "<tr></td colspan=2><b>" + _l("summary")
                               + ":</b> " + Summary + "</td></tr>" + Diff + Resources::DiffFooter + Resources::HtmlFooter);
    this->tPageDiff->stop();
}
void IDefReader::processScriptItemNode( P_ITEM madeItem, QDomElement &Node )
{
	for( UI16 k = 0; k < Node.childNodes().count(); k++ )
	{
		QDomElement currChild = Node.childNodes().item( k ).toElement();
		if( currChild.nodeName() == "amount" )
		{
			QString Value = QString();
			UI16 i = 0;
			if( currChild.hasChildNodes() ) // <random> i.e.
				for( i = 0; i < currChild.childNodes().count(); i++ )
				{
					if( currChild.childNodes().item( i ).isText() )
						Value += currChild.childNodes().item( i ).toText().data();
					else if( currChild.childNodes().item( i ).isElement() )
						Value += processNode( currChild.childNodes().item( i ).toElement() );
				}
			else
				Value = currChild.nodeValue();

			if( Value.toInt() < 1 )
				Value = QString("1");

			if( madeItem->isPileable() )
				madeItem->setAmount( Value.toInt() );
			else
				for( i = 1; i < Value.toInt(); i++ ) //dupe it n-1 times
					Commands->DupeItem(-1, madeItem, 1);
		}
		else if( currChild.nodeName() == "color" ) //process <color> tags
		{
			QString Value = QString();
			if( currChild.hasChildNodes() ) // colorlist or random i.e.
				for( UI16 i = 0; i < currChild.childNodes().count(); i++ )
				{
					if( currChild.childNodes().item( i ).isText() )
						Value += currChild.childNodes().item( i ).toText().data();
					else if( currChild.childNodes().item( i ).isElement() )
						Value += processNode( currChild.childNodes().item( i ).toElement() );
				}
			else
				Value = currChild.nodeValue();
			
			if( Value.toInt() < 0 )
				Value = QString("0");

			madeItem->setColor( Value.toInt() );
		}
		else if( currChild.nodeName() == "inherit" && currChild.attributes().contains("id") )
		{
			QDomElement* derivalSection = DefManager->getSection( WPDT_ITEM, currChild.attribute("id") );
			if( !derivalSection->isNull() )
				this->applyNodes( madeItem, derivalSection );
		}
	}
}
Exemple #11
0
LoadAppScript::LoadAppScript(const QDomElement &elem, const bool system,
                             QStringList &msg, QList<bool> &fatal)
  : Loadable(elem, system, msg, fatal)
{
  _pkgitemtype = "C";

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

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

  if (elem.hasAttribute("grade"))
  {
    msg.append(TR("Node %1 '%2' has a 'grade' attribute but should use "
                      "'order' instead.")
                   .arg(elem.nodeName()).arg(elem.attribute("name")));
    fatal.append(false);
  }

  if (elem.hasAttribute("order"))
  {
    if (elem.attribute("order").contains("highest", Qt::CaseInsensitive))
      _grade = INT_MAX;
    else if (elem.attribute("order").contains("lowest", Qt::CaseInsensitive))
      _grade = INT_MIN;
    else
      _grade = elem.attribute("order").toInt();
  }

  _enabled = true;
  if (elem.hasAttribute("enabled"))
  {
    if (elem.attribute("enabled").contains(trueRegExp))
      _enabled = true;
    else if (elem.attribute("enabled").contains(falseRegExp))
      _enabled = false;
    else
    {
      msg.append(TR("Node %1 '%2' has an 'enabled' attribute that is "
                        "neither 'true' nor 'false'. Using '%3'.")
                         .arg(elem.nodeName()).arg(elem.attribute("name"))
                         .arg(_enabled ? "true" : "false"));
      fatal.append(false);
    }
  }
}
Exemple #12
0
void ProItemInfoManager::readItem(ProItemInfo *item, const QDomElement &data)
{
    QDomElement child = data.firstChildElement();
    for (; !child.isNull(); child = child.nextSiblingElement()) {
        if (child.nodeName() == QLatin1String("id"))
            item->setId(child.text());
        else if (child.nodeName() == QLatin1String("name"))
            item->setName(child.text());
        else if (child.nodeName() == QLatin1String("description"))
            item->setDescription(child.text());
    }
}
Exemple #13
0
CreateTrigger::CreateTrigger(const QDomElement &elem, QStringList &msg, QList<bool> &fatal)
  : CreateDBObj(elem, msg, fatal)
{
  _pkgitemtype = "G";

  if (elem.nodeName() != "createtrigger")
  {
    msg.append(QObject::tr("Creating a CreateTrigger element from a %1 node.")
              .arg(elem.nodeName()));
    fatal.append(false);
  }
}
Exemple #14
0
CreateFunction::CreateFunction(const QDomElement &elem, QStringList &msg, QList<bool> &fatal)
  : CreateDBObj(elem, msg, fatal)
{
  _pkgitemtype = "F";

  if (elem.nodeName() != "createfunction")
  {
    msg.append(TR("Creating a CreateFunction element from a %1 node.")
              .arg(elem.nodeName()));
    fatal.append(false);
  }
}
Exemple #15
0
CreateView::CreateView(const QDomElement &elem, QStringList &msg, QList<bool> &fatal)
  : CreateDBObj(elem, msg, fatal)
{
  _pkgitemtype = "V";
  _relkind     = "v";

  if (elem.nodeName() != "createview")
  {
    msg.append(TR("Creating a CreateView element from a %1 node.")
              .arg(elem.nodeName()));
    fatal.append(false);
  }
}
Exemple #16
0
LoadReport::LoadReport(const QDomElement & elem, const bool system,
                       QStringList &msg, QList<bool> &fatal)
  : Loadable(elem, system, msg, fatal)
{
  _pkgitemtype = "R";

  if (elem.nodeName() != "loadreport")
  {
    msg.append(TR("Creating a LoadAppReport element from a %1 node.")
                       .arg(elem.nodeName()));
    fatal.append(false);
  }
}
CreateTable::CreateTable(const QDomElement &elem, QStringList &msg, QList<bool> &fatal)
  : CreateDBObj(elem, msg, fatal)
{
  _pkgitemtype = "T";
  _relkind     = "r";   // pg_class.relkind 'r' => relation (ordinary table)

  if (elem.nodeName() != "createtable")
  {
    msg.append(TR("Creating a CreateTable element from a %1 node.")
              .arg(elem.nodeName()));
    fatal.append(false);
  }
}
Exemple #18
0
bool K3b::MixedDoc::loadDocumentData( QDomElement* rootElem )
{
    QDomNodeList nodes = rootElem->childNodes();

    if( nodes.length() < 4 )
        return false;

    if( nodes.item(0).nodeName() != "general" )
        return false;
    if( !readGeneralDocumentData( nodes.item(0).toElement() ) )
        return false;

    if( nodes.item(1).nodeName() != "audio" )
        return false;
    QDomElement audioElem = nodes.item(1).toElement();
    if( !m_audioDoc->loadDocumentData( &audioElem ) )
        return false;

    if( nodes.item(2).nodeName() != "data" )
        return false;
    QDomElement dataElem = nodes.item(2).toElement();
    if( !m_dataDoc->loadDocumentData( &dataElem ) )
        return false;

    if( nodes.item(3).nodeName() != "mixed" )
        return false;

    QDomNodeList optionList = nodes.item(3).childNodes();
    for( int i = 0; i < optionList.count(); i++ ) {

        QDomElement e = optionList.item(i).toElement();
        if( e.isNull() )
            return false;

        if( e.nodeName() == "remove_buffer_files" )
            setRemoveImages( e.toElement().text() == "yes" );
        else if( e.nodeName() == "image_path" )
            setTempDir( e.toElement().text() );
        else if( e.nodeName() == "mixed_type" ) {
            QString mt = e.toElement().text();
            if( mt == "last_track" )
                setMixedType( DATA_LAST_TRACK );
            else if( mt == "second_session" )
                setMixedType( DATA_SECOND_SESSION );
            else
                setMixedType( DATA_FIRST_TRACK );
        }
    }

    return true;
}
Exemple #19
0
void Configurer::initValues()
{
	QDomElement const root = config.documentElement();

	QDomElement const stages = root.elementsByTagName("values").at(0).toElement();
	for (QDomNode child = stages.firstChild()
			; !child.isNull()
			; child = child.nextSibling())
	{
		if (!child.isElement()) {
			continue;
		}

		QDomElement const childElement = child.toElement();
		if (childElement.nodeName() != "value") {
			qDebug() << "Malformed <values> tag";
			throw "pwmTest.xml parsing failed";
		}

		Value value;
		value.frequency = childElement.attribute("frequency").toInt();
		value.duty = childElement.attribute("duty").toInt();
		mValues.append(value);
	}
}
Exemple #20
0
void Configurer::initDevices()
{
	QDomElement const root = config.documentElement();

	QDomElement const devices = root.elementsByTagName("devices").at(0).toElement();

	for (QDomNode child = devices.firstChild()
			; !child.isNull()
			; child = child.nextSibling())
	{
		if (!child.isElement()) {
			continue;
		}

		QDomElement const childElement = child.toElement();
		if (childElement.nodeName() != "device") {
			qDebug() << "Malformed <devices> tag";
			throw "i2cTest.xml parsing failed";
		}

		QString name = childElement.attribute("name");
		Location location;
		location.bus = childElement.attribute("bus").toInt();
		location.address = childElement.attribute("address").toInt(NULL, 16);
		mDevices.append(name);
		mLocations[name] = location;
	}
}
Exemple #21
0
bool parseError(QS3Error &dest, const QByteArray &data, QString &errorMessage)
{
    QDomDocument doc;
    if (!doc.setContent(data, &errorMessage))
        return false;

    // <Error>
    QDomElement root = doc.documentElement();
    if (root.isNull() || root.nodeName() != NODE_NAME_ERROR)
    {
        errorMessage = "Failed to get document root <Error> element. XML response was invalid.";
        return false;
    }

    QDomElement e = root.firstChildElement(NODE_NAME_CODE);
    if (!e.isNull())
        dest.code = e.text();
    e = root.firstChildElement(NODE_NAME_MESSAGE);
    if (!e.isNull())
        dest.message = e.text();
    e = root.firstChildElement(NODE_NAME_RESOURCE);
    if (!e.isNull())
        dest.resource = e.text();
    e = root.firstChildElement(NODE_NAME_REQUEST_ID);
    if (!e.isNull())
        dest.requestId = e.text();
    return true;
}
Exemple #22
0
Node::NodeSP SceneLoader::_LoadElement(const QDomElement& og_element, Node::NodeSP dt_node)
{    
    QString name = og_element.nodeName();
    Node::NodeSP node = nullptr;

    if(name == SL_LIGHT)
    {
        node = _LoadLight(og_element, dt_node);                   //Light
    }
    else if(name == SL_CAMERA)
    {
        node = _LoadCamera(og_element, dt_node);                  //Camera
    }
    else if(name == SL_SOUND)
    {
        node = _LoadSound(og_element, dt_node);                   //Sound
    }
    else if(name == SL_NODE)
    {
        if(og_element.firstChildElement(SL_ENTITY).isNull() && og_element.firstChildElement(SL_PLANE).isNull())
        {
            node = _LoadNode(og_element, dt_node);                //Node
        }
        else
        {
            node = _LoadMesh(og_element, dt_node);                //Mesh
        }
    }
    return node;
}
Exemple #23
0
void Configurer::initBusFiles()
{
	QDomElement const root = config.documentElement();

	QDomElement const busses = root.elementsByTagName("busses").at(0).toElement();

	for (QDomNode child = busses.firstChild()
			; !child.isNull()
			; child = child.nextSibling())
	{
		if (!child.isElement()) {
			continue;
		}

		QDomElement const childElement = child.toElement();
		if (childElement.nodeName() != "bus") {
			qDebug() << "Malformed <busses> tag";
			throw "i2cTest.xml parsing failed";
		}

		int id = childElement.attribute("id").toInt();
		QString file = childElement.attribute("file");
		mBusFiles[id] = file;
	}
}
Exemple #24
0
CreateDBObj::CreateDBObj(const QDomElement & elem, QStringList &msg, QList<bool> &fatal)
{
  _nodename = elem.nodeName();

  if (elem.hasAttribute("name"))
    _name = elem.attribute("name");
  else
  {
    msg.append(TR("The contents.xml must name the object for %1.")
               .arg(_nodename));
    fatal.append("false");
  }

  if (elem.hasAttribute("file"))
    _filename = elem.attribute("file");
  else
  {
    msg.append(TR("The contents.xml must name the file for %1.")
               .arg(_nodename));
    fatal.append(true);
  }

  if (elem.hasAttribute("onerror"))
    _onError = nameToOnError(elem.attribute("onerror"));

  _comment = elem.text().trimmed();
}
Exemple #25
0
void SvgFlattener::unRotateChild(QDomElement & element, QMatrix transform) {

	// TODO: missing ellipse element

    if(!element.hasChildNodes()) {

		double scale = qMin(qAbs(transform.m11()), qAbs(transform.m22()));
		if (scale != 1 && transform.m21() == 0 && transform.m12() == 0) {
			QString sw = element.attribute("stroke-width");
			if (!sw.isEmpty()) {
				bool ok;
				double strokeWidth = sw.toDouble(&ok);
				if (ok) {
					element.setAttribute("stroke-width", QString::number(strokeWidth * scale));
				}
			}
		}

		// I'm a leaf node.
		QString tag = element.nodeName().toLower();
		if(tag == "path"){
            QString data = element.attribute("d").trimmed();
            if (!data.isEmpty()) {
                const char * slot = SLOT(rotateCommandSlot(QChar, bool, QList<double> &, void *));
                PathUserData pathUserData;
                pathUserData.transform = transform;
                if (parsePath(data, slot, pathUserData, this, true)) {
                    element.setAttribute("d", pathUserData.string);
                }
            }
        }
Exemple #26
0
bool QgsMeshLayer::writeXml( QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context ) const
{
  // first get the layer element so that we can append the type attribute
  QDomElement mapLayerNode = layer_node.toElement();

  if ( mapLayerNode.isNull() || ( QLatin1String( "maplayer" ) != mapLayerNode.nodeName() ) )
  {
    QgsDebugMsgLevel( QStringLiteral( "can't find <maplayer>" ), 2 );
    return false;
  }

  mapLayerNode.setAttribute( QStringLiteral( "type" ), QStringLiteral( "mesh" ) );

  // add provider node
  if ( mDataProvider )
  {
    QDomElement provider  = document.createElement( QStringLiteral( "provider" ) );
    QDomText providerText = document.createTextNode( providerType() );
    provider.appendChild( providerText );
    layer_node.appendChild( provider );
  }

  // renderer specific settings
  QString errorMsg;
  return writeSymbology( layer_node, document, errorMsg, context );
}
Exemple #27
0
// Author & Date: Ehsan Azar       23 Aug 2011
// Purpose: Get all child elements
// Inputs:
//   count - maximum number of children to retrieve (-1 means all)
// Outputs:
//   Returns a list of element childern of the current element node
QStringList XmlFile::childKeys(int count) const
{
    QStringList res;

    QDomNode parent;
    if (!m_nodes.isEmpty())
    {
        // Get the current node
        parent = m_nodes.last();
    } else {
        parent = m_doc;
    }
    if (!parent.isNull())
    {
        for(QDomElement elem = parent.firstChildElement(); !elem.isNull(); elem = elem.nextSiblingElement())
        {
            res += elem.nodeName();
            if (count > 0)
            {
                count--;
                if (count == 0)
                    break;
            }
        }
    }
    return res;
}
Exemple #28
0
void Configurer::initStages()
{
	QDomElement const root = config.documentElement();

	QDomElement const stages = root.elementsByTagName("stages").at(0).toElement();
	for (QDomNode child = stages.firstChild()
			; !child.isNull()
			; child = child.nextSibling())
	{
		if (!child.isElement()) {
			continue;
		}

		QDomElement const childElement = child.toElement();
		if (childElement.nodeName() != "stage") {
			qDebug() << "Malformed <stages> tag";
			throw "pwmTest.xml parsing failed";
		}

		Stage stage;
		stage.generatorPort = childElement.attribute("generatorPort");
		stage.capturePort = childElement.attribute("capturePort");
		mStages.append(stage);
	}
}
Exemple #29
0
int XmlNumInterface::readFile(QString const& fileName)
{
	if(XMLQtInterface::readFile(fileName) == 0)
		return 0;

	QDomDocument doc("OGS-NUM-DOM");
	doc.setContent(_fileData);
	QDomElement const docElement = doc.documentElement(); //OGSNonlinearSolverSetup
	if (docElement.nodeName().compare("OGSNonlinearSolverSetup"))
	{
		ERR("XmlNumInterface::readFile() - Unexpected XML root.");
		return 0;
	}

	QDomElement num_node = docElement.firstChildElement();

	while (!num_node.isNull())
	{
		if (num_node.nodeName().compare("Type") == 0)
		{
			std::string const solver_type = num_node.toElement().text().toStdString();
			INFO("Non-linear solver type: %s.", solver_type.c_str());
		}
		else if (num_node.nodeName().compare("LinearSolver") == 0)
			readLinearSolverConfiguration(num_node);
		else if (num_node.nodeName().compare("IterationScheme") == 0)
			readIterationScheme(num_node);
		else if (num_node.nodeName().compare("Convergence") == 0)
			readConvergenceCriteria(num_node);

		num_node = num_node.nextSiblingElement();
	}

	return 1;
}
Exemple #30
0
int XmlGspInterface::readFile(const QString &fileName)
{
	if(XMLQtInterface::readFile(fileName) == 0)
		return 0;

	QFileInfo fi(fileName);
	QString path = (fi.path().length() > 3) ? QString(fi.path() + "/") : fi.path();

	QDomDocument doc("OGS-PROJECT-DOM");
	doc.setContent(_fileData);
	QDomElement docElement = doc.documentElement(); //OpenGeoSysProject
	if (docElement.nodeName().compare("OpenGeoSysProject"))
	{
		ERR("XmlGspInterface::readFile(): Unexpected XML root.");
		return 0;
	}

	QDomNodeList fileList = docElement.childNodes();

	for(int i = 0; i < fileList.count(); i++)
	{
		const QString file_node(fileList.at(i).nodeName());
		if (file_node.compare("geo") == 0)
		{
			XmlGmlInterface gml(*(_project.getGEOObjects()));
			const QDomNodeList childList = fileList.at(i).childNodes();
			for(int j = 0; j < childList.count(); j++)
			{
				const QDomNode child_node (childList.at(j));
				if (child_node.nodeName().compare("file") == 0)
				{
					DBUG("XmlGspInterface::readFile(): path: \"%s\".",
					     path.data());
					DBUG("XmlGspInterface::readFile(): file name: \"%s\".",
					     (child_node.toElement().text()).data());
					gml.readFile(QString(path + child_node.toElement().text()));
				}
			}
		}
		else if (file_node.compare("stn") == 0)
		{
			XmlStnInterface stn(*(_project.getGEOObjects()));
			const QDomNodeList childList = fileList.at(i).childNodes();
			for(int j = 0; j < childList.count(); j++)
				if (childList.at(j).nodeName().compare("file") == 0)
					stn.readFile(QString(path +
					                     childList.at(j).toElement().text()));
		}
		else if (file_node.compare("msh") == 0)
		{
			const std::string msh_name = path.toStdString() +
			                             fileList.at(i).toElement().text().toStdString();
			MeshLib::Mesh* msh = FileIO::readMeshFromFile(msh_name);
			if (msh)
				_project.addMesh(msh);
		}
	}

	return 1;
}