예제 #1
0
QString QDomNodeProto:: nodeName() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->nodeName();
  return QString();
}
예제 #2
0
void
fileVpzView::onUndoRedoVpz(QDomNode oldValVpz,
                           QDomNode newValVpz,
                           QDomNode oldValVpm,
                           QDomNode newValVpm)
{
    if (newValVpz.nodeName() == "vle_project") {
        setVpz(mVpz);
        return;
    }

    QString tab = getCurrentTab();
    if (tab == "Diagram") {
        mScene.onUndoRedoVpz(oldValVpz, newValVpz, oldValVpm, newValVpm);
    } else if (tab == "Conditions") {
        mExpCondTab->onUndoRedoVpz(oldValVpz, newValVpz, oldValVpm, newValVpm);
    } else if (tab == "Dynamics") {
        mDynamicsTab->onUndoRedoVpz(
          oldValVpz, newValVpz, oldValVpm, newValVpm);
    } else if (tab == "Observables") {
        mObservablesTab->onUndoRedoVpz(
          oldValVpz, newValVpz, oldValVpm, newValVpm);
    } else if (tab == "Views") {
        mExpViewTab->onUndoRedoVpz(oldValVpz, newValVpz, oldValVpm, newValVpm);
    } else if (tab == "Classes") {
        mClassesTab->onUndoRedoVpz(oldValVpz, newValVpz, oldValVpm, newValVpm);
    } else if (tab == "Simulation") {
        //        mSimTab->onUndoRedoVpz(oldValVpz, newValVpz,
        //                oldValVpm, newValVpm);
    } else if (tab == "Project") {
        mProjectTab->onUndoRedoVpz(oldValVpz, newValVpz, oldValVpm, newValVpm);
    }
}
void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &metaDataDir,
    const PackageInfoVector &packages, const QString &appName, const QString &appVersion)
{
    const QString targetDir = makePathAbsolute(_targetDir);
    if (!QFile::exists(targetDir))
        QInstaller::mkpath(targetDir);

    QDomDocument doc;
    QDomElement root;
    QFile existingUpdatesXml(QFileInfo(metaDataDir, QLatin1String("Updates.xml")).absoluteFilePath());
    if (existingUpdatesXml.open(QIODevice::ReadOnly) && doc.setContent(&existingUpdatesXml)) {
        root = doc.documentElement();
        // remove entry for this component from existing Updates.xml, if found
        foreach (const PackageInfo &info, packages) {
            const QDomNodeList packageNodes = root.childNodes();
            for (int i = packageNodes.count() - 1; i >= 0; --i) {
                const QDomNode node = packageNodes.at(i);
                if (node.nodeName() != QLatin1String("PackageUpdate"))
                    continue;
                if (node.firstChildElement(QLatin1String("Name")).text() != info.name)
                    continue;
                root.removeChild(node);
            }
        }
        existingUpdatesXml.close();
    } else {
예제 #4
0
void PcbXML::drawNode(QDomNode node){
	DebugDialog::debug("drawing node:");

	QString tag = node.nodeName().toLower();

	if(tag=="pin"){
		DebugDialog::debug("\tPin");
		drawPin(node);
	}
	else if(tag=="pad"){
		DebugDialog::debug("\tPad");
		drawPad(node);
	}
	else if(tag=="elementline"){
		DebugDialog::debug("\tElementLine");
		drawElementLine(node);
	}
	else if(tag=="elementarc"){
		DebugDialog::debug("\tElementArc");
		drawElementArc(node);
	}
	else if(tag=="mark"){
		DebugDialog::debug("\tMark");
		drawMark(node);
	}
	else {
		DebugDialog::debug("cannot draw - unrecognized tag");
	}
}
예제 #5
0
/************************************************************
* 功能		: 从type_property.xml中读取type和property的配置信息
* 输入		: 
* 返回值	: void
*************************************************************/
void CreatModel::readTypeInfo()
{
	openXml(QDir::currentPath() + "/Config/type_property.xml");
	
	QDomNode n = m_root.firstChild();
	while(!n.isNull())
	{
		QString nodeName = n.nodeName();
		if (nodeName == "typelist")
		{
			QDomNode m = n.toElement().firstChild();
			while (m.isElement())
			{
				QString nameValue = m.toElement().attributeNode("name").value();
				m_typeList.append(nameValue);
				m = m.nextSibling();
			}
		}
		if (nodeName == "propertylist")
		{
			QDomNode m = n.toElement().firstChild();
			while (m.isElement())
			{
				QString nameValue = m.toElement().attributeNode("name").value();
				m_propertyList.append(nameValue);
				m = m.nextSibling();
			}
		}
		n = n.nextSibling();
	}
}
예제 #6
0
bool CAnm2DXml::loadLayers(QDomNode node, AnmLayer *pParent)
{
	while ( !node.isNull() ) {
		if ( node.nodeName() == kAnmXML_ID_Layer ) {
			QDomNamedNodeMap nodeMap = node.attributes() ;
			if ( nodeMap.namedItem(kAnmXML_Attr_Name).isNull()
			  || nodeMap.namedItem(kAnmXML_Attr_FrameNum).isNull()
			  || nodeMap.namedItem(kAnmXML_Attr_ChildNum).isNull() ) {
				return false ;
			}
			QString name ;
			int frameDataNum = 0 ;
			int childNum = 0 ;

			name = nodeMap.namedItem(kAnmXML_Attr_Name).toAttr().value() ;
			frameDataNum = nodeMap.namedItem(kAnmXML_Attr_FrameNum).toAttr().value().toInt() ;
			childNum = nodeMap.namedItem(kAnmXML_Attr_ChildNum).toAttr().value().toInt() ;

			AnmLayer *pLayer = new AnmLayer ;
			pLayer->pParentLayer = pParent ;
			pParent->childPtrs.append(pLayer) ;

			QDomNode child = node.firstChild() ;
			if ( !loadFrameData(child, pLayer, frameDataNum) ) {
				return false ;
			}
			QDomNode layers = node.firstChild() ;
			if ( !loadLayers(layers, pLayer) ) {
				return false ;
			}
		}
		node = node.nextSibling() ;
	}
	return true ;
}
예제 #7
0
void XBELImportCommand::doExecute(const KBookmarkGroup &/*bkGroup*/) {
    // check if already open first???
    KBookmarkManager *pManager = KBookmarkManager::managerForFile(m_fileName, QString());

    QDomDocument doc = GlobalBookmarkManager::self()->mgr()->internalDocument();

    // get the xbel
    QDomNode subDoc = pManager->internalDocument().namedItem("xbel").cloneNode();
    if (subDoc.isProcessingInstruction())
        subDoc = subDoc.nextSibling();
    if (subDoc.isDocumentType())
        subDoc = subDoc.nextSibling();
    if (subDoc.nodeName() != "xbel")
        return;

    if (!folder().isEmpty()) {
        // transform into folder
        subDoc.toElement().setTagName("folder");

        // clear attributes
        QStringList tags;
        for (int i = 0; i < subDoc.attributes().count(); i++)
            tags << subDoc.attributes().item(i).toAttr().name();
        for (QStringList::const_iterator it = tags.constBegin(); it != tags.constEnd(); ++it)
            subDoc.attributes().removeNamedItem((*it));

        subDoc.toElement().setAttribute("icon", m_icon);

        // give the folder a name
        QDomElement textElem = doc.createElement("title");
        subDoc.insertBefore(textElem, subDoc.firstChild());
        textElem.appendChild(doc.createTextNode(folder()));
    }

    // import and add it
    QDomNode node = doc.importNode(subDoc, true);

    if (!folder().isEmpty()) {
        GlobalBookmarkManager::self()->root().internalElement().appendChild(node);
        m_group = KBookmarkGroup(node.toElement()).address();

    } else {
        QDomElement root = GlobalBookmarkManager::self()->root().internalElement();

        QList<QDomElement> childList;

        QDomNode n = subDoc.firstChild().toElement();
        while (!n.isNull()) {
            QDomElement e = n.toElement();
            if (!e.isNull())
                childList.append(e);
            n = n.nextSibling();
        }

        QList<QDomElement>::Iterator it = childList.begin();
        QList<QDomElement>::Iterator end = childList.end();
        for (; it!= end ; ++it)
            root.appendChild((*it));
    }
}
예제 #8
0
/** 
 * \en
 * insert new row in table and replace tag to value
 * \_en
 * \ru
 * Вставляет новую строку в таблицу, заменяет теги на значения, удаляет тег секции из строки таблицы.
 * Выполняет рекурсивный поиск узла, содержащего строку таблицы. У этого узла есть
 * специальное имя(w:r), которое распознается функцией. После того, как узел найден, строка строка дублируется, 
 * а из текущей строки удаляются все теги секции, чтобы избежать мнократного размножения строк таблицы.
 * \_ru
 * \param node - \en context for inserting \_en \ru узел, в который происходит вставка \_ru 
 * \see searchTags()
 */
void 
aMSOTemplate::insertRowValues(QDomNode node)
{
	QDomNode n = node;
	while(!n.parentNode().isNull())
	{
		n = n.parentNode();
		QDomElement e = n.toElement();
		if( n.nodeName()=="Row" ) 
		{	
			QDomAttr a = n.toElement().attributeNode( "ss:Index" );
			n.parentNode().insertAfter(n.cloneNode(true),n);
			clearTags(n,true);
			
			QMap<QString,QString>::Iterator it;
			for ( it = values.begin(); it != values.end(); ++it )
			{
				searchTags(n,it.key());
			}
			int rowIndex = a.value().toInt();
			if (rowIndex == 0) 
			{
				rowIndex = getRowIndex(n);
				n.toElement().setAttribute("ss:Index",rowIndex);	
			}
			n.nextSibling().toElement().setAttribute("ss:Index",rowIndex+1);	
		}
	}
}
예제 #9
0
/**
 * \en
 * Deletes row, having section tag
 * \_en
 * \ru
 * Рекурсивная функция. Удаляет строки, содержащие тег секции
 * \_ru
* \param node - \en context \_en \ru узел из которого нужно удалить строки \_ru
 */
void
aMSOTemplate::clearRow(QDomNode node)
{
QDomNode n = node.lastChild();
	while( !n.isNull() )
	{	
		if(n.isText())
		{
			QString str = n.nodeValue();
			QRegExp re;
			re.setPattern(QString("%1.*%2").arg(open_token_section).arg(close_token_section));
			re.setMinimal(true);
			int pos = re.search(str,0);
			if(pos!=-1)
			{
				QDomNode tmp = n;
				while(!tmp.parentNode().isNull())
				{
					tmp = tmp.parentNode();
					if( tmp.nodeName()=="Row" ) 
					{
						tmp.parentNode().removeChild(tmp);
						break;
					}
				}
			}
		}
		else
		{
			clearRow(n);
		}
		n = n.previousSibling();
	}	
}
예제 #10
0
ReportBands OOoReportBuilder::reportBand(QDomNode row)
{
    if (row.nodeName() != "table:table-row")
        return None;

    QString text = cellText(row.firstChild().toElement());
    QRegExp rx("\\{\\w+\\}");

    int pos = rx.indexIn(text);

    if (pos != -1) {
        text = text.mid(pos + 1,rx.matchedLength() - 2);

        if (!QString::compare(text,"rep_header",Qt::CaseInsensitive))
            return ReportHeader;
        else if (!QString::compare(text,"rep_footer",Qt::CaseInsensitive))
            return ReportFooter;
        else {

            text = text.remove(QRegExp("\\d+"));

            if (!QString::compare(text,"header",Qt::CaseInsensitive))
                return DetailHeader;
            else if (!QString::compare(text,"footer",Qt::CaseInsensitive))
                return DetailFooter;

            else if (!QString::compare(text,"detail",Qt::CaseInsensitive))
                return Detail;
        }
    }

    return None;
}
예제 #11
0
void ImageshackTalker::parseUploadPhotoDone(QByteArray data)
{
    int errCode    = -1;
    QString errMsg = "";
    QDomDocument doc("addPhoto");
    if (!doc.setContent(data))
        return;

    QDomElement elem = doc.documentElement();

    kDebug() << "-------------" << elem.tagName() << "------------";
    kDebug() << data;

    if (elem.tagName() == "imginfo")
    {
        errCode = 0;
    }
    else
    {
        kDebug() << elem.tagName();
        QDomNode node = elem.firstChild();
        if (node.nodeName() == "error") {
            errCode =  parseErrorResponse(elem, errMsg);
        }
    }

    emit signalBusy(false);
    emit signalAddPhotoDone(errCode, errMsg);
}
예제 #12
0
QDomElement OOoReportBuilder::parseRow(QDomNode row)
{
    QDomElement lastElement = row.toElement();

    if (reportBand(row) == Detail) {
        lastElement = processDetail(row.toElement());
    } else {
        QDomNode child = row.firstChild();

        while (!child.isNull()) {
            if (child.nodeName() == "table:table-cell") {
                QString str = processString(cellText(child.toElement()));
                bool ok;
                double value = str.toDouble(&ok);

                if (ok) {
                   setText(child.toElement(), value);
                } else
                    setText(child.toElement(), str);
            }

            child = child.nextSibling();
        }
    }

    return lastElement;
}
예제 #13
0
void InternetServerPlatform::readVariables( QDomNode node )
{
	Logging::logInfo( this, "readVariables()" );

	if( node.isNull() )
		return;

	QDomNode variable = node.firstChild();
	while( false == variable.isNull() )
	{
		if( QDomNode::CommentNode != variable.nodeType() )
		{
			QString variableName = variable.nodeName();

			if( _variableList.contains(variableName) )
				continue;

			QString variableValue = variable.attributes().namedItem("value").nodeValue();

			replaceVariables( variableValue );

			_variableList.insert( variableName, variableValue );

			Logging::logInfo( this, QString("%1 = %2").arg(variableName).arg(variableValue) );

			variable = variable.nextSibling();
		}	
	}	
}
예제 #14
0
QDomNode findChild( QDomNode &parent, const QString &name )
{
  for ( QDomNode n = parent.firstChild(); !n.isNull(); n = n.nextSibling() )
    if ( n.nodeName() == name )
         return n;
  return QDomNode();
}
QTreeWidget* ReadAndWriteXML::parseXMLToQTreeWidget(const QDomDocument *doc, QTreeWidget * treeWidget) {
    //VERIFYING IS A NODE
    if (doc==NULL) {
        QMessageBox::warning(0, "parseXMLToQTreeWidget","NULL POINTER");
        Q_ASSERT(FALSE);
    }
    if (doc->isNull()){
        QMessageBox::warning(0, "parseXMLToQTreeWidget","QDomDocument is null");
        Q_ASSERT(FALSE);
    }
    if (!doc->isDocument()) {
       QMessageBox::warning(0, "parseXMLToQTreeWidget",QObject::tr("QDomDocument is not a document is %1 ").arg(doc->nodeType()));
       Q_ASSERT(FALSE);
    }

    if (treeWidget==NULL) treeWidget=new QTreeWidget();
    else treeWidget->clear();
    qDebug() << "DomParser::parseXMLToQTreeWidget  start parsing " << doc->nodeName() ;

    QDomNode node = doc->firstChild();
    qDebug() << "DomParser::parseXMLToQTreeWidget  first child is " << node.nodeName() ;
    QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget,QStringList(QString("Type: %1").arg(node.nodeName())));
    treeWidget->addTopLevelItem(item);
    treeWidget->setColumnCount(1);

    while (!node.isNull()) {
        parseEntry(node.toElement(), item);
        node = node.nextSibling();
    }
    return treeWidget;
}
예제 #16
0
KReportItemCheckBox::KReportItemCheckBox(const QDomNode &element)
{
    createProperties();
    QDomNodeList nl = element.childNodes();
    QString n;
    QDomNode node;

    nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name")));
    m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source")));
    setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble());
    m_foregroundColor->setValue(QColor(element.toElement().attribute(QLatin1String("fo:foreground-color"))));
    m_checkStyle->setValue(element.toElement().attribute(QLatin1String("report:check-style")));
    m_staticValue->setValue(QVariant(element.toElement().attribute(QLatin1String("report:value"))).toBool());

    parseReportRect(element.toElement());

    for (int i = 0; i < nl.count(); i++) {
        node = nl.item(i);
        n = node.nodeName();

        if (n == QLatin1String("report:line-style")) {
            KReportLineStyle ls;
            if (parseReportLineStyleData(node.toElement(), &ls)) {
                m_lineWeight->setValue(ls.width());
                m_lineColor->setValue(ls.color());
                m_lineStyle->setValue(QPen(ls.penStyle()));
            }
        } else {
            kreportpluginWarning() << "while parsing check element encountered unknow element: " << n;
        }
    }

}
예제 #17
0
QString TextFormatter::getFormattedSection(QDomNode sectionNode)
{
    QDomNodeList itemChildNodes = sectionNode.childNodes();
    QString formattedSection = "";

    for(int i = 0; i < itemChildNodes.length(); i++)
    {
        QDomNode currentNode = itemChildNodes.at(i);
        QString nodeName = currentNode.nodeName();

        if(nodeName.compare("header") == 0)
        {
            formattedSection += getFormattedHeader(currentNode);
        }
        else if(nodeName.compare("description") == 0)
        {
            formattedSection += getFormattedDescription(currentNode);
        }
        else if(nodeName.compare("list") == 0)
        {
            formattedSection += getFormattedList(currentNode);
        }
    }

    formattedSection.append("<br/>");

    return formattedSection;
}
예제 #18
0
bool CGraphicsBanks::deserialize(QDomDocument& doc, QDomNode& node, QString& errors)
{
   QDomNode childNode = node.firstChild();

   if (!childNode.isNull())
   {
      do
      {
         if (childNode.nodeName() == "graphicsbank")
         {
            CGraphicsBank* pGraphicsBank = new CGraphicsBank(this);
            m_graphicsBanks.append(pGraphicsBank);
            appendChild(pGraphicsBank);

            if (!pGraphicsBank->deserialize(doc,childNode,errors))
            {
               return false;
            }

         }
         else
         {
            return false;
         }
      } while (!(childNode = childNode.nextSibling()).isNull());
   }

   return true;
}
예제 #19
0
bool CAttributeTables::deserialize(QDomDocument& doc, QDomNode& node, QString& errors)
{
   QDomNode childNode = node.firstChild();

   if (!childNode.isNull())
   {
      do
      {
         if (childNode.nodeName() == "attributetable")
         {
            CAttributeTable* pNewAttributeTable = new CAttributeTable(this);
            m_attributeTables.append(pNewAttributeTable);
            appendChild(pNewAttributeTable);

            if (!pNewAttributeTable->deserialize(doc,childNode,errors))
            {
               return false;
            }
         }
         else
         {
            return false;
         }
      }
      while (!(childNode = childNode.nextSibling()).isNull());
   }

   return true;
}
예제 #20
0
void ReportSection::initFromXML(QDomNode & section) {
    QDomNodeList nl = section.childNodes();
    QDomNode node;
    QString n;
    for(unsigned int i = 0; i < nl.count(); i++) {
        node = nl.item(i);
        n = node.nodeName();
        if(n == "height") {
            double h = node.firstChild().nodeValue().toDouble() / 100.0;
            h *= dpiY;
            canvas->resize(canvas->width(),(int)h);
        } else if(n == "label") {
            (new ReportEntityLabel(node, canvasview->document(), canvas))->setVisible(TRUE);
        } else if(n == "field") {
            (new ReportEntityField(node, canvasview->document(), canvas))->setVisible(TRUE);
        } else if(n == "text") {
            (new ReportEntityText(node, canvasview->document(), canvas))->setVisible(TRUE);
        } else if(n == "line") {
            (new ReportEntityLine(node, canvasview->document(), canvas))->setVisible(TRUE);
        } else if(n == "barcode") {
            (new ReportEntityBarcode(node, canvasview->document(), canvas))->setVisible(TRUE);
        } else if(n == "image") {
            (new ReportEntityImage(node, canvasview->document(), canvas))->setVisible(TRUE);
        } else if(n == "graph") {
            (new ReportEntityGraph(node, canvasview->document(), canvas))->setVisible(TRUE);
        } else if(n == "key" || n == "firstpage" || n == "lastpage"
                    || n == "odd" || n == "even") {
            // these are all handled elsewhere but we don't want to show errors
            // because they are expected sometimes
        } else {
            qDebug("Encountered unknown node while parsing section: %s", n.latin1());
        }
    }
}
예제 #21
0
ImgSource* ColorSchemeParser::parseFilters(QDomNode filt) {

    // TODO: Move this code into ImgSource
    if (!filt.hasChildNodes()) {
        return 0;
    }

    ImgSource * ret = new ImgLoader();

    QDomNode f = filt.firstChild();

    while (!f.isNull()) {
        QString name = f.nodeName().toLower();
        if (name == "invert") {
            ret = new ImgInvert(ret);
        } else if (name == "hueinv") {
            ret = new ImgHueInv(ret);
        } else if (name == "add") {
            ret = new ImgAdd(ret, XmlParse::selectNodeInt(f, "Amount"));
        } else if (name == "scalewhite") {
            ret = new ImgScaleWhite(ret, XmlParse::selectNodeFloat(f, "Amount"));
        } else if (name == "hsvtweak") {
            int hmin = 0;
            int hmax = 359;
            int smin = 0;
            int smax = 255;
            int vmin = 0;
            int vmax = 255;
            float hfact = 1.0f;
            float sfact = 1.0f;
            float vfact = 1.0f;
            int hconst = 0;
            int sconst = 0;
            int vconst = 0;

            if (!f.namedItem("HMin").isNull()) { hmin = XmlParse::selectNodeInt(f, "HMin"); }
            if (!f.namedItem("HMax").isNull()) { hmax = XmlParse::selectNodeInt(f, "HMax"); }
            if (!f.namedItem("SMin").isNull()) { smin = XmlParse::selectNodeInt(f, "SMin"); }
            if (!f.namedItem("SMax").isNull()) { smax = XmlParse::selectNodeInt(f, "SMax"); }
            if (!f.namedItem("VMin").isNull()) { vmin = XmlParse::selectNodeInt(f, "VMin"); }
            if (!f.namedItem("VMax").isNull()) { vmax = XmlParse::selectNodeInt(f, "VMax"); }

            if (!f.namedItem("HConst").isNull()) { hconst = XmlParse::selectNodeInt(f, "HConst"); }
            if (!f.namedItem("SConst").isNull()) { sconst = XmlParse::selectNodeInt(f, "SConst"); }
            if (!f.namedItem("VConst").isNull()) { vconst = XmlParse::selectNodeInt(f, "VConst"); }

            if (!f.namedItem("HFact").isNull()) { hfact = XmlParse::selectNodeFloat(f, "HFact"); }
            if (!f.namedItem("SFact").isNull()) { sfact = XmlParse::selectNodeFloat(f, "SFact"); }
            if (!f.namedItem("VFact").isNull()) { vfact = XmlParse::selectNodeFloat(f, "VFact"); }

            ret = new ImgHSVTweak(ret, hmin, hmax, smin, smax, vmin, vmax, hfact, hconst,
                                  sfact, sconst, vfact, vconst);
        } else {
            qDebug() << "Unknown image filter:" << name;
        }
        f = f.nextSibling();
    }

    return ret;
}
예제 #22
0
bool XmlHelper::SetChildNodeValue(const QString &parent_tag, const QString &child_tag, QString &text)
{
    QDomElement root = doc_.documentElement();
    QDomNodeList nodelist = root.elementsByTagName(parent_tag);

    if (nodelist.count() == 0)
    {
        return false;
    }

    QDomNodeList childs = nodelist.at(0).childNodes();
    for (int i = 0; i < childs.count(); i++)
    {
        QDomNode child = childs.at(i);

        if (child.nodeName() == child_tag)
        {
            QDomElement elems = child.toElement();
            if (elems.firstChild().isText())
            {
                elems.firstChild().setNodeValue(text);
            }
            else
            {
                QDomText text_node;
                text_node.setNodeValue(text);
                elems.replaceChild(text_node, elems.firstChild());
            }

            return true;
        }
    }

    return false;
}
예제 #23
0
bool Configurator::loadSectionItem( QDomNode sectionItem, QListWidget& listWidget )
{
	if( false == sectionItem.hasChildNodes() )
		return false;

	if( sectionItem.nodeName() != c_sectionItemNodeName )
		return false;

	QDomNamedNodeMap sectionItemAttributes = sectionItem.attributes();
	if( false == sectionItemAttributes.contains(c_attributeName) )
		return false;

	if( false == sectionItemAttributes.contains(c_attributeText) )
		return false;

	// add the item to the section
	QString sectionItemName = sectionItemAttributes.namedItem(c_attributeName).nodeValue();
	QString sectionItemText = sectionItemAttributes.namedItem(c_attributeText).nodeValue();
	
	QListWidgetItem*	listWidgetItem = new QListWidgetItem();
					    listWidgetItem->setText( sectionItemText );
					    listWidgetItem->setData( Qt::UserRole, sectionItemName );

    listWidget.addItem( listWidgetItem );

	return true;
}
예제 #24
0
bool Lvk::Clue::ScriptParser::parseHeader(QDomElement &header, Clue::Script &script)
{
    bool hasCharacter = false;

    for (int i = 0; i < header.childNodes().size(); ++i) {
        QDomNode node = header.childNodes().item(i);

        if (node.childNodes().isEmpty()) {
            continue;
        }

        QString name = node.nodeName().toLower();
        QString value = node.childNodes().at(0).nodeValue().trimmed();

        if (name == "character") {
            script.character = value;
            hasCharacter = true;
        } else if (name == "scriptnumber") {
            script.number = value.toInt();
        } else {
            m_errMsg = QObject::tr("Unknown tag '%1'").arg(name);
            return false;
        }
    }

    return hasCharacter;
}
예제 #25
0
void ScrobblerSubmitter::readSubmitQueue()
{
    m_savePath = Amarok::saveLocation() + "submit.xml";
    QFile file( m_savePath );

    if ( !file.open( IO_ReadOnly ) )
    {
        debug() << "Couldn't open file: " << m_savePath << endl;
        return;
    }

    QTextStream stream( &file );
    stream.setEncoding( QTextStream::UnicodeUTF8 );

    QDomDocument d;
    if( !d.setContent( stream.read() ) )
    {
        debug() << "Couldn't read file: " << m_savePath << endl;
        return;
    }

    uint last = 0;
    if( d.namedItem( "submit" ).isElement() )
        last = d.namedItem( "submit" ).toElement().attribute( "lastSubmissionFinishTime" ).toUInt();
    if(last && last > m_lastSubmissionFinishTime)
        m_lastSubmissionFinishTime = last;

    const QString ITEM( "item" ); //so we don't construct these QStrings all the time

    for( QDomNode n = d.namedItem( "submit" ).firstChild(); !n.isNull() && n.nodeName() == ITEM; n = n.nextSibling() )
        enqueueItem( new SubmitItem( n.toElement() ) );

    m_submitQueue.first();
}
예제 #26
0
bool KivioBaseTargetStencil::loadTargets( const QDomElement &e )
{
    KivioConnectorTarget *p;
    QDomNode node;
    QDomElement targetE;
    QString nodeName;

    m_pTargets->clear();

    node = e.firstChild();
    while( !node.isNull() )
    {
        nodeName = node.nodeName();
        targetE = node.toElement();

        if( nodeName == "KivioConnectorTarget" )
        {
            p = new KivioConnectorTarget();
            p->loadXML( targetE );
            m_pTargets->append(p);
            p = NULL;
        }


        node = node.nextSibling();
    }


    return true;
}
예제 #27
0
void AView::read(QDomNode &element)
{
  QDomNodeList nodeList = element.childNodes();

  for(int i = 0; i < nodeList.count(); ++i) {
    QDomNode node = nodeList.item(i);
    if(!node.isElement())
      continue;
    QDomElement element = node.toElement();

    QString name = node.nodeName();
    AView* newView = createView(name, this);
    if(!newView)
      continue;
    childs.append(newView);
    newView->read(element);
  }

    QDomElement e = element.toElement();
    id = e.attribute("android:id");
    id = explodeName(id);
    id = captializeName(id);

    width = QString::number(atof(qPrintable(e.attribute("android:layout_width"))));
    height = QString::number(atof(qPrintable(e.attribute("android:layout_height"))));
}
예제 #28
0
void InstrumentSoundShaping::loadSettings( const QDomElement & _this )
{
	m_filterModel.loadSettings( _this, "ftype" );
	m_filterCutModel.loadSettings( _this, "fcut" );
	m_filterResModel.loadSettings( _this, "fres" );
	m_filterEnabledModel.loadSettings( _this, "fwet" );

	QDomNode node = _this.firstChild();
	while( !node.isNull() )
	{
		if( node.isElement() )
		{
			for( int i = 0; i < NumTargets; ++i )
			{
				if( node.nodeName() ==
					m_envLfoParameters[i]->nodeName() +
					QString( targetNames[i][1] ).
								toLower() )
				{
					m_envLfoParameters[i]->restoreState( node.toElement() );
				}
			}
		}
		node = node.nextSibling();
	}
}
static QStringList copyFilesFromNode(const QString &parentNode, const QString &childNode, const QString &attr,
    const QString &kind, const QDomNode &package, const PackageInfo &info, const QString &targetDir)
{
    QStringList copiedFiles;
    const QDomNodeList nodes = package.firstChildElement(parentNode).childNodes();
    for (int i = 0; i < nodes.count(); ++i) {
        const QDomNode node = nodes.at(i);
        if (node.nodeName() != childNode)
            continue;

        const QDir dir(QString::fromLatin1("%1/meta").arg(info.directory));
        const QString filter = attr.isEmpty() ? node.toElement().text() : node.toElement().attribute(attr);
        const QStringList files = dir.entryList(QStringList(filter), QDir::Files);
        if (files.isEmpty()) {
            throw QInstaller::Error(QString::fromLatin1("Cannot find any %1 matching \"%2\" "
                "while copying %1 of \"%3\".").arg(kind, filter, info.name));
        }

        foreach (const QString &file, files) {
            const QString source(QString::fromLatin1("%1/meta/%2").arg(info.directory, file));
            const QString target(QString::fromLatin1("%1/%2/%3").arg(targetDir, info.name, file));
            copyWithException(source, target, kind);
            copiedFiles.append(file);
        }
    }
    return copiedFiles;
}
예제 #30
0
QVariant MetricDomModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (role != Qt::DisplayRole)
        return QVariant();

    DomItem *item = static_cast<DomItem*>(index.internalPointer());

    QDomNode node = item->node();

    QStringList attributes;
    QDomNamedNodeMap attributeMap = node.attributes();

    switch (index.column()) {
        case 0:
            return node.nodeName();
        case 1:
        	if( !attributeMap.contains("Type") ) {
        		return QVariant();
        	}
        	return attributeMap.namedItem("Type").nodeValue();
        case 2:
        	if( !attributeMap.contains("Format") ) {
        		return QVariant();
        	}
        	return attributeMap.namedItem("Format").nodeValue();
        default:
            return QVariant();
    }
}