示例#1
0
bool TestBaseLine::isDeepEqual(const QDomNode &n1, const QDomNode &n2)
{
    if(n1.nodeType() != n2.nodeType())
        return false;

    switch(n1.nodeType())
    {
        case QDomNode::CommentNode:
        /* Fallthrough. */
        case QDomNode::TextNode:
        {
            return static_cast<const QDomCharacterData &>(n1).data() ==
                   static_cast<const QDomCharacterData &>(n2).data();
        }
        case QDomNode::ProcessingInstructionNode:
        {
            return n1.nodeName() == n2.nodeName() &&
                   n1.nodeValue() == n2.nodeValue();
        }
        case QDomNode::DocumentNode:
            return isChildrenDeepEqual(n1.childNodes(), n2.childNodes());
        case QDomNode::ElementNode:
        {
            return n1.localName() == n2.localName()                     &&
                   n1.namespaceURI() == n2.namespaceURI()               &&
                   n1.nodeName() == n2.nodeName()                       && /* Yes, this one is needed in addition to localName(). */
                   isAttributesEqual(n1.attributes(), n2.attributes())  &&
                   isChildrenDeepEqual(n1.childNodes(), n2.childNodes());
        }
        /* Fallthrough all these. */
        case QDomNode::EntityReferenceNode:
        case QDomNode::CDATASectionNode:
        case QDomNode::EntityNode:
        case QDomNode::DocumentTypeNode:
        case QDomNode::DocumentFragmentNode:
        case QDomNode::NotationNode:
        case QDomNode::BaseNode:
        case QDomNode::CharacterDataNode:
        {
            Q_ASSERT_X(false, Q_FUNC_INFO,
                       "An unsupported node type was encountered.");
            return false;
        }
        case QDomNode::AttributeNode:
        {
            Q_ASSERT_X(false, Q_FUNC_INFO,
                       "This should never happen. QDom doesn't allow us to compare DOM attributes "
                       "properly.");
            return false;
        }
        default:
        {
            Q_ASSERT_X(false, Q_FUNC_INFO, "Unhandled QDom::NodeType value.");
            return false;
        }
    }
}
示例#2
0
void KScoringManager::createInternalFromXML( QDomNode n )
{
  static KScoringRule *cR = 0; // the currentRule
  // the XML file was parsed and now we simply traverse the resulting tree
  if ( !n.isNull() ) {
    kDebug(5100) <<"inspecting node of type" << n.nodeType()
                  << "named" << n.toElement().tagName();

    switch ( n.nodeType() ) {
    case QDomNode::DocumentNode:
    {
      // the document itself
      break;
    }
    case QDomNode::ElementNode:
    {
      // Server, Newsgroup, Rule, Expression, Action
      QDomElement e = n.toElement();
      QString s = e.tagName();
      if ( s == "Rule" ) {
        cR = new KScoringRule( e.attribute( "name" ) );
        cR->setLinkMode( e.attribute( "linkmode" ) );
        cR->setExpire( e.attribute( "expires" ) );
        addRuleInternal( cR );
      } else if ( s == "Group" ) {
        Q_CHECK_PTR( cR );
        cR->addGroup( e.attribute( "name" ) );
      } else if ( s == "Expression" ) {
        cR->addExpression( new KScoringExpression( e.attribute( "header" ),
                                                   e.attribute( "type" ),
                                                   e.attribute( "expr" ),
                                                   e.attribute( "neg" ) ) );
      } else if ( s == "Action" ) {
        Q_CHECK_PTR( cR );
        cR->addAction( ActionBase::getTypeForName( e.attribute( "type" ) ),
                       e.attribute( "value" ) );
      }
      break;
    }
    default:
      ;
    }
    QDomNodeList nodelist = n.childNodes();
    int cnt = nodelist.count();
    for ( int i=0; i<cnt; ++i ) {
      createInternalFromXML( nodelist.item( i ) );
    }
  }
}
PackageMetainfo PackageMetainfo::fromXML(const QByteArray& data){
    QDomDocument dom;
    dom.setContent(data);
    QDomElement eleInfo = dom.documentElement();
    QDomNodeList nodeList = eleInfo.childNodes();

    PackageMetainfo info;

    for(int i=0;i<nodeList.count();++i){
        QDomNode node = nodeList.at(i);
        qDebug()<<"name : "<<node.nodeName()
                <<" type: "<<node.nodeType()
                <<" text: "<<node.toElement().text();
        if(node.nodeName() == "gameid"){
            info.setGameId(node.toElement().text().toInt());
        }else if(node.nodeName() == "name"){
            info.setName(node.toElement().text());
        }else if(node.nodeName() == "version"){
            info.setVersion(node.toElement().text());
        }else if(node.nodeName() == "author"){
            info.setAuthor(node.toElement().text());
        }else if(node.nodeName() == "organization"){
            info.setOrganization(node.toElement().text());
        }else if(node.nodeName() == "introduction"){
            info.setIntroduction(node.toElement().text());
        }else if(node.nodeName() == "os"){
            info.setOsStr(node.toElement().text());
        }else if(node.nodeName() == "runfilepath"){
            info.setRunFilePath(node.toElement().text());
        }
    }

    return info;
}
示例#4
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();
		}	
	}	
}
示例#5
0
int QDomNodeProto::nodeType() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->nodeType();
  return 0;
}
示例#6
0
CContextMenuConfig* CConfiguration::createContextMenuEntry(const QString&     nodeName,
                                                           const QDomElement& element)
{
   QString  itemName;
   QString  commandLine;
   QDomNode currentNode = element.firstChild();

   while(!currentNode.isNull()) {
      if(QDomNode::ElementNode == currentNode.nodeType()) {
         if(currentNode.toElement().tagName() == QString(g_CMDTag)) {
            commandLine = currentNode.toElement().text();
         }
         else if(currentNode.toElement().tagName() == QString(g_NameTag)) {
            itemName = currentNode.toElement().text();
         }
         else {
            QMessageBox::critical(0, "Error!", "Found unknown tag in config file: " +
                                  currentNode.toElement().tagName());
         }
      }
      currentNode = currentNode.nextSibling();
   }

   CContextMenuConfig* node = new CContextMenuConfig(m_CanvasWidget, nodeName, itemName, commandLine);
   return node;
}
示例#7
0
QString getTextFromNode(QDomNode* nodePtr) {
	QDomNode childNode = nodePtr->firstChild();
	while (!childNode.isNull()) {
		if (childNode.nodeType() == QDomNode::TextNode) {
			return childNode.toText().data().trimmed();
		}
		childNode = childNode.nextSibling();
	}
	return "";
}
示例#8
0
void DomParser::_parseEntry(const QDomElement &element, int &l)
{
  if(ready2Parse==FALSE)
    return;

  QDomNode node = element.firstChild();
   
  // Block: only save *complete* o-t pairs
  // Drawback: o must be the first element of e. Is that a problem? We'll see.
  if (node.toElement().tagName() == "o") {
    QDomNode c = node.firstChild();
    if (c.nodeType() == QDomNode::TextNode)
    {
      l++;
    }
  }

  while (!node.isNull()) {
    if (node.toElement().tagName() == "e") {
      _parseEntry(node.toElement(), l);
    } else if (node.toElement().tagName() == "o") {
        QDomNode childNode = node.firstChild();
        while (!childNode.isNull()) {
          if (childNode.nodeType() == QDomNode::TextNode) {
            iTitles[l] = QString(childNode.toText().data());
            break;
          }
          childNode = childNode.nextSibling();
        }
    } else if (node.toElement().tagName() == "t") {
      QDomNode childNode = node.firstChild();
      while (!childNode.isNull()) 
      {
        if (childNode.nodeType() == QDomNode::TextNode && !iTitles[l].isEmpty()) {
          iTexts[l] = QString(childNode.toText().data());
          break;
        }
        childNode = childNode.nextSibling();
      }
    }
    node = node.nextSibling();
  }
}
示例#9
0
/**
 * @brief XmlEditWidgetPrivate::findDomNodeScan find the nearest match to a position
 * @param node
 * @param nodeTarget
 * @param lineSearched
 * @param columnSearched
 * @param lastKnownNode: last known "good" position
 * @return
 */
bool XmlEditWidgetPrivate::findDomNodeScan(QDomNode node, QDomNode nodeTarget, const int lineSearched, const int columnSearched, FindNodeWithLocationInfo &info)
{
    int row = node.lineNumber();
    int col = node.columnNumber();
    if(!node.isDocument()) {
        if((lineSearched == row) && (columnSearched == col)) {
            info.matchedNode = nodeTarget ;
            return true ;
        }

        if((lineSearched == row) && (columnSearched == col)) {
            info.matchedNode = nodeTarget ;
            return true ;
        }
        if((lineSearched == row) && (columnSearched < col)) {
            info.matchedNode = nodeTarget ;
            return true ;
        }
        if((lineSearched < row)) {
            info.matchedNode = nodeTarget ;
            return true ;
        }
        if((lineSearched <= row)) {
            info.lastKnownNode = nodeTarget ;
        }

        if(node.nodeType() == QDomNode::ElementNode) {
            QDomElement element = node.toElement();
            QDomNamedNodeMap attributes = element.attributes();
            int numAttrs = attributes.length();
            for(int i = 0 ; i < numAttrs ; i++) {
                QDomNode node = attributes.item(i);
                QDomAttr attr = node.toAttr();
                if(findDomNodeScan(attr, nodeTarget, lineSearched, columnSearched, info)) {
                    return true;
                }
            } // for
        }
    }

    int nodes = node.childNodes().count();
    for(int i = 0 ; i < nodes ; i ++) {
        QDomNode childNode = node.childNodes().item(i) ;
        if(childNode.isText() || childNode.isCDATASection()) {
            if(findDomNodeScan(childNode, nodeTarget, lineSearched, columnSearched, info)) {
                return true;
            }
        } else {
            if(findDomNodeScan(childNode, childNode, lineSearched, columnSearched, info)) {
                return true ;
            }
        }
    }
    return false ;
}
示例#10
0
void TreeModel::recursiveRead(QDomNode dNode, TreeItem *item)
{
    do
    {
        int totalOfChilds = dNode.childNodes().size();

        if (dNode.nodeType() != QDomNode::CommentNode)
        {
            if (totalOfChilds == 0)
            {
                if (dNode.nodeType() == QDomNode::TextNode)
                    item->setValue(dNode.nodeValue());
                else
                {
                    TreeItem *subItem = new TreeItem(dNode.nodeName());

                    for (int i = 0; i < dNode.attributes().size(); i++)
                        subItem->addAttribute(dNode.attributes().item(i).nodeName(), dNode.attributes().item(i).nodeValue());

                    item->appendRow(subItem);

                }
            }
            else
            {
                TreeItem *item2 = new TreeItem(dNode.nodeName());

                for (int i = 0; i < dNode.attributes().size(); i++)
                    item->addAttribute(dNode.attributes().item(i).nodeName(), dNode.attributes().item(i).nodeValue());

                for (int i = 0; i < totalOfChilds; i++)
                    if (dNode.childNodes().size() > 0 and i == 0)
                        recursiveRead(dNode.childNodes().at(i), item2);

                item->appendRow(item2);
            }
        }

        dNode = dNode.nextSibling();
    }
    while (!dNode.isNull());
}
示例#11
0
文件: xml.cpp 项目: gthomas/MuseScore
void Xml::htmlToString(QDomElement e, int level, QString* s)
      {
      *s += QString("<%1").arg(e.tagName());
      QDomNamedNodeMap map = e.attributes();
      int n = map.size();
      for (int i = 0; i < n; ++i) {
            QDomAttr a = map.item(i).toAttr();
            *s += QString(" %1=\"%2\"").arg(a.name()).arg(a.value());
            }
      *s += ">";
      ++level;
      for (QDomNode ee = e.firstChild(); !ee.isNull(); ee = ee.nextSibling()) {
            if (ee.nodeType() == QDomNode::ElementNode)
                  htmlToString(ee.toElement(), level, s);
            else if (ee.nodeType() == QDomNode::TextNode)
                  *s += Qt::escape(ee.toText().data());
            }
      *s += QString("</%1>").arg(e.tagName());
      --level;
      }
示例#12
0
void Platform::processNode(const QDomNode &node)
{
    if (node.isNull())
        return;

//    vc_dbg << "Node Name: " << node.nodeName();
//    vc_dbg << "Node type: " << node.nodeType();

    if (node.nodeType() == QDomNode::ElementNode)
        processNodeAttributes(node.toElement());
}
示例#13
0
QString QDomNodeProto::toString() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return QString("[QDomNode(%1=%2, %3, %4)]")
                    .arg(item->nodeName())
                    .arg(item->nodeValue())
                    .arg(item->nodeType())
                    .arg(item->hasChildNodes() ? "has children" : "leaf node");
  return QString("[QDomNode(unknown)]");
}
示例#14
0
void QtXmlWrapper::getparstr(const std::string &name, char *par, int maxstrlen) const
{
    ZERO(par, maxstrlen);
    QDomNode tmp = findElement( d->m_node, "string", "name", name.c_str() );
    if( tmp.isNull() || !tmp.hasChildNodes() )
    {
        return;
    }

    tmp = tmp.firstChild();
    if( tmp.nodeType() == QDomNode::ElementNode )
    {
        snprintf(par, maxstrlen, "%s", tmp.toElement().tagName().toUtf8().constData() );
        return;
    }
    if( tmp.nodeType() == QDomNode::TextNode )
    {
        snprintf(par, maxstrlen, "%s", tmp.toText().data().toUtf8().constData() );
        return;
    }
}
示例#15
0
std::string QtXmlWrapper::getparstr(const std::string &name,
                                    const std::string &defaultpar) const
{
    QDomNode tmp = findElement( d->m_node, "string", "name", name.c_str() );
    if( tmp.isNull() || !tmp.hasChildNodes() )
    {
        return defaultpar;
    }

    tmp = tmp.firstChild();
    if( tmp.nodeType() == QDomNode::ElementNode && !tmp.toElement().tagName().isEmpty() )
    {
        return tmp.toElement().tagName().toUtf8().constData();
    }
    if( tmp.nodeType() == QDomNode::TextNode && !tmp.toText().data().isEmpty() )
    {
        return tmp.toText().data().toUtf8().constData();
    }

    return defaultpar;
}
示例#16
0
void SvgView::updateField(QDomNode &e, QString tag, QString value)
{
    if ( e.nodeType() == QDomNode::TextNode)
    {
        if (e.nodeValue() == tag)
            e.setNodeValue(value);
    }
    else
    {
        for(QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling())
            updateField(n, tag, value);
    }
}
void ItemDefinitionGroup::processNodeAttributes(const QDomElement &nodeElement)
{
    // process attributes
    QDomNamedNodeMap namedNodeMap = nodeElement.attributes();
    QDomNode domNode = namedNodeMap.item(0);

    if (domNode.nodeType() == QDomNode::AttributeNode) {
        QDomAttr domElement = domNode.toAttr();

        if (domElement.name() == QLatin1String("Condition"))
            m_condition = domElement.value();
    }
}
示例#18
0
/** Sets the layout attributes for the given report section */
void MReportEngine::setSectionAttributes(MReportSection *section, QDomNode *report)
{
  // Get the attributes for the section
  QDomNamedNodeMap attributes = report->attributes();

  // Get the section attributes
  section->setHeight(attributes.namedItem("Height").nodeValue().toInt());
  section->setPrintFrequency(attributes.namedItem("PrintFrequency").nodeValue().toInt());
  if (attributes.contains("SectionId"))
    section->setIdSec(attributes.namedItem("SectionId").nodeValue().toUInt());

  // Process the sections labels
  QDomNodeList children = report->childNodes();
  int childCount = children.length();

  // For each label, extract the attr list and add the new label
  // to the sections's label collection

  for (int j = 0; j < childCount; j++) {
    QDomNode child = children.item(j);

    if (child.nodeType() == QDomNode::ElementNode) {
      if (child.nodeName() == "Line") {
        QDomNamedNodeMap attributes = child.attributes();
        MLineObject *line = new MLineObject();

        setLineAttributes(line, &attributes);
        section->addLine(line);
      } else if (child.nodeName() == "Label") {
        QDomNamedNodeMap attributes = child.attributes();
        MLabelObject *label = new MLabelObject();

        setLabelAttributes(label, &attributes);
        section->addLabel(label);
      } else if (child.nodeName() == "Special") {
        QDomNamedNodeMap attributes = child.attributes();
        MSpecialObject *field = new MSpecialObject();

        setSpecialAttributes(field, &attributes);
        section->addSpecialField(field);
      } else if (child.nodeName() == "CalculatedField") {
        QDomNamedNodeMap attributes = child.attributes();
        MCalcObject *field = new MCalcObject();

        setCalculatedFieldAttributes(field, &attributes);
        section->addCalculatedField(field);
      }
    }
  }
}
示例#19
0
void DebuggerTool::processNodeAttributes(const QDomElement &element)
{
    QDomNamedNodeMap namedNodeMap = element.attributes();

    for (int i = 0; i < namedNodeMap.size(); ++i) {
        QDomNode domNode = namedNodeMap.item(i);

        if (domNode.nodeType() == QDomNode::AttributeNode) {
            QDomAttr domElement = domNode.toAttr();
            m_anyAttribute.insert(domElement.name(), domElement.value());
//            vc_dbg << "Any AttributeNode: name: " << domElement.name() << " value: " << domElement.value();
        }
    }
}
示例#20
0
void OnError::processNodeAttributes(const QDomElement &nodeElement)
{
    // process attributes
    QDomNamedNodeMap namedNodeMap = nodeElement.attributes();
    QDomNode domNode = namedNodeMap.item(0);

    if (domNode.nodeType() == QDomNode::AttributeNode) {
        QDomAttr domElement = domNode.toAttr();

        if (domElement.name() == QLatin1String("Condition"))
            m_condition = domElement.value();
        else if (domElement.name() == QLatin1String("ExecuteTargets"))
            m_executeTargets = domElement.value().split(QLatin1Char(';'));
    }
}
示例#21
0
void Platform::processNodeAttributes(const QDomElement &element)
{
    QDomNamedNodeMap namedNodeMap = element.attributes();

    if (namedNodeMap.size() == 1) {
        QDomNode domNode = namedNodeMap.item(0);

        if (domNode.nodeType() == QDomNode::AttributeNode) {
            QDomAttr domElement = domNode.toAttr();

            if (domElement.name() == QString("Name")) {
                m_name = domElement.value();
//                vc_dbg << "AttributeNode: name: " << domElement.name() << " value: " << domElement.value();
            }
        }
    }
}
void AssemblyReference_Private::processNode(const QDomNode &node)
{
    if (node.isNull())
        return;
    
//    vc_dbg << "Node Name: " << node.nodeName();
//    vc_dbg << "Node type: " << node.nodeType();
    
    if (node.nodeType() == QDomNode::ElementNode)
        processNodeAttributes(node.toElement());
    
    if (node.hasChildNodes()) {
        QDomNode firstChild = node.firstChild();
        if (!firstChild.isNull())
            processReferenceConfig(firstChild);
    }
}
示例#23
0
bool InternetServerPlatform::readSockets( QDomNode node )
{
	Logging::logInfo( this, "readSockets()" );

	if( node.isNull() )
		return false;

    QString applicationPath = QCoreApplication::applicationDirPath();
	
	QDomNode socket = IspComponents::Dom::getChildNodeByName( node, "socket" );
	while( false == socket.isNull() )
	{
		if( QDomNode::CommentNode != socket.nodeType() )
		{
			SocketSettings* socketSettings = new SocketSettings();

            // read the logfile read on
			socketSettings->_on = socket.attributes().namedItem( "on" ).nodeValue();

            // read the daemon
			socketSettings->_daemon	= socket.attributes().namedItem( "daemon" ).nodeValue();
		    socketSettings->_daemon = socketSettings->_daemon.startsWith("/")
                ? socketSettings->_daemon
                : QString( "%1/%2" ).arg( applicationPath ).arg( socketSettings->_daemon );

			// read the logfile
			QDomNode logFile = IspComponents::Dom::getChildNodeByName( socket, "logFile" );	
			socketSettings->_logFile = logFile.attributes().namedItem("value").nodeValue();
		    socketSettings->_logFile = socketSettings->_logFile.startsWith("/")
                ? socketSettings->_logFile
                : QString( "%1/%2" ).arg( applicationPath ).arg( socketSettings->_logFile );

			// read the block-from
			QDomNode blockFrom = IspComponents::Dom::getChildNodeByName( socket, "blockFrom" );
			readBlockFrom( blockFrom, socketSettings->_blockFrom );

			_socketSettingsList.append( socketSettings );
		}

		socket = socket.nextSibling();
	}

	return true;
}
示例#24
0
void mafPluginConfigurator::parseDocument(QDomNode current) {
    mafEventBus::mafEventArgumentsList argList;
    mafCore::mafPluggedObjectsHash pluginHash;
    QByteArray ba = current.nodeName().toAscii();
    char *name = ba.data();
    QDomNodeList dnl = current.childNodes();
    for (int n=0; n < dnl.count(); ++n) {
        QDomNode node = dnl.item(n);
        if (node.nodeType() == QDomNode::ElementNode) {
            QDomElement ce = node.toElement();
            QDomNamedNodeMap attributes = ce.attributes();
            QString elem_name = ce.tagName();
            if (elem_name == "plug") {
                QString label = attributes.namedItem("label").nodeValue();
                QString classType = attributes.namedItem("classtype").nodeValue();
                QString baseClass = attributes.namedItem("baseclass").nodeValue();
                mafCore::mafPluggedObjectInformation plugInfo(label, classType);
                pluginHash.insertMulti(baseClass, plugInfo);
            } else if (elem_name == "codec") {
                argList.clear();
                QString encodeType = attributes.namedItem("encodetype").nodeValue();
                QString codec = attributes.namedItem("classtype").nodeValue();
                argList.append(mafEventArgument(QString, encodeType));
                argList.append(mafEventArgument(QString, codec));
                mafEventBusManager::instance()->notifyEvent("maf.local.serialization.plugCodec", mafEventTypeLocal, &argList);
            } else if (elem_name == "serializer") {
                argList.clear();
                QString schemaType = attributes.namedItem("schematype").nodeValue();
                QString serializer = attributes.namedItem("classtype").nodeValue();
                argList.append(mafEventArgument(QString, schemaType));
                argList.append(mafEventArgument(QString, serializer));
                mafEventBusManager::instance()->notifyEvent("maf.local.serialization.plugSerializer", mafEventTypeLocal, &argList);
            } else {
                qWarning() << mafTr("Unrecognized element named: ") << elem_name;
            }
        }
    }

    if (pluginHash.size() != 0) {
        argList.clear();
        argList.append(mafEventArgument(mafCore::mafPluggedObjectsHash, pluginHash));
        mafEventBusManager::instance()->notifyEvent("maf.local.resources.plugin.registerLibrary", mafEventTypeLocal, &argList);
    }
}
示例#25
0
/**
 * Removes all QDomComment objects from the specified node and all its children.
 */
static void removeDOMComments( QDomNode &node )
{
    QDomNode n = node.firstChild();
    while ( !n.isNull() )
    {
        if ( n.nodeType() == QDomNode::CommentNode )
        {
            QDomNode tmp = n;
            n = n.nextSibling();
            node.removeChild( tmp );
        }
        else
        {
            QDomNode tmp = n;
            n = n.nextSibling();
            removeDOMComments( tmp );
        }
    }
}
示例#26
0
bool Configurator::loadSection( QDomNode section )
{
	// make some checks
	if( false == section.hasChildNodes() )
		return false;

	if( section.nodeName() != c_sectionNodeName )
		return false;

	QDomNamedNodeMap sectionAttributes = section.attributes();
	if( false == sectionAttributes.contains(c_attributeName) )
		return false;

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

	// we have all the attribbutes for this section, now build it usign GUI controls
	QString sectionName = sectionAttributes.namedItem(c_attributeName).nodeValue();
	QString sectionText = sectionAttributes.namedItem(c_attributeText).nodeValue();
	
	// build the UI
	QListWidget*	listWidget = new QListWidget();
				    listWidget->setObjectName( sectionName );
				    listWidget->setSelectionBehavior( QAbstractItemView::SelectRows );

	connect( listWidget,    SIGNAL	(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
			 this,		    SLOT	(currentItemChanged(QListWidgetItem*,QListWidgetItem*))	);

	_sections->addItem( listWidget, sectionText );
			
	// adding items for this section
	QDomNode sectionItem = section.firstChild();
	while( false == sectionItem.isNull() )
	{
	    if( QDomNode::CommentNode != section.nodeType() )
		if( false == loadSectionItem(sectionItem,*listWidget) )
			return false;
	
		sectionItem = sectionItem.nextSibling();				
	}

	return true;
}
示例#27
0
bool Configurator::loadSettingsFile()
{
	// check if we can read the file
	QFile configurationFile( _configurationFileName );
	if( false == configurationFile.open(QIODevice::ReadOnly) )
		return false;
	
	// loading settings file into memory
	if( false == _domDocument.setContent(&configurationFile) )
	{
		configurationFile.close();
		return false;
	}
	configurationFile.close();

	// validating the root node
	QDomNode configurator = _domDocument.documentElement();
	if( configurator.isNull() )
		return false;

	if( configurator.nodeName() != c_configuratorNodeName )
		return false;

	if( false == configurator.hasChildNodes() )
		return false;

	// set title text
	QDomNamedNodeMap configuratorAttributes = configurator.attributes();
	setWindowTitle( configuratorAttributes.namedItem(c_attributeTitleText).nodeValue() );	
	
	// validating and adding the sections nodes
	QDomNode section = configurator.firstChild();
	while( false == section.isNull() )
	{
	    if( QDomNode::CommentNode != section.nodeType() )
		if( false == loadSection(section) )
			return false;

		section = section.nextSibling();		
	}

	return true;
}
示例#28
0
bool StylePersistence::collectIds(VStyle *style, QDomNodeList &nodes)
{
    bool isOk = true ;
    int nodi = nodes.count();
    for(int i = 0 ; i < nodi ; i ++) {
        QDomNode childNode = nodes.item(i) ;
        D(printf("K1 trovato %d %s=%s\n", childNode.nodeType(), childNode.nodeName().toAscii().data(), childNode.nodeValue().toAscii().data()));

        if(childNode.isElement()) {
            QDomElement element = childNode.toElement();
            if(IDATTRS_TAGNAME == element.tagName()) {
                if(!collectAnId(style, &element)) {
                    isOk = false;
                }
            }
        }
    }
    return isOk ;
} // collectIds
示例#29
0
bool StylePersistence::collectStyles(VStyle *style, QDomNodeList &nodes)
{
    bool isOk = true ;
    int nodi = nodes.count();
    for(int i = 0 ; i < nodi ; i ++) {
        QDomNode childNode = nodes.item(i) ;
        D(printf("K1 trovato %d %s=%s\n", childNode.nodeType(), childNode.nodeName().toAscii().data(), childNode.nodeValue().toAscii().data()));

        if(childNode.isElement()) {
            QDomElement element = childNode.toElement();
            if(STYLE_TAGNAME == element.tagName()) {
                if(!collectAStyle(style, &element)) {
                    isOk = false;
                }
            } else if(STYLE_TAGDEFAULT == element.tagName()) {
                collectDefault(style, element.childNodes());
            }// default
        }
    }
    return isOk ;
} // collectStyles
示例#30
0
void Filter::processNode(const QDomNode &node)
{
    if (node.isNull())
        return;

//    vc_dbg << "Node Name: " << node.nodeName();
//    vc_dbg << "Node type: " << node.nodeType();

    if (node.nodeType() == QDomNode::ElementNode)
        processNodeAttributes(node.toElement());

    if (node.hasChildNodes()) {
        QDomNode firstChild = node.firstChild();
        if (!firstChild.isNull()) {
            if (firstChild.nodeName() == QString("Filter"))
                processFilter(firstChild);
            else if (firstChild.nodeName() == QString("File"))
                processFile(firstChild);
        }
    }
}