コード例 #1
0
ファイル: parser.cpp プロジェクト: aboduo/leechcraft
uint qHash (const QDomNode& node)
{
	if (node.lineNumber () == -1 ||
			node.columnNumber () == -1)
	{
		qWarning () << Q_FUNC_INFO
			<< "node is unhasheable";
		return -1;
	}
	return (node.lineNumber () << 24) + node.columnNumber ();
}
コード例 #2
0
int QDomNodeProto:: lineNumber() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->lineNumber();
  return 0;
}
コード例 #3
0
ファイル: skincontext.cpp プロジェクト: GorgiAstro/mixxx
QDebug SkinContext::logWarning(const char* file, const int line,
                               const QDomNode& node) const {
    return qWarning() << QString("%1:%2 SKIN ERROR at %3:%4 <%5>:")
                             .arg(file, QString::number(line), m_xmlPath,
                                  QString::number(node.lineNumber()),
                                  node.nodeName())
                             .toUtf8()
                             .constData();
}
コード例 #4
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 ;
}
コード例 #5
0
ファイル: xml.cpp プロジェクト: starchimpsgroup/3dvv
QList<GLObject*> XML::readXML(const QString &path)
{
    _error     = false;
    _errorText = "";

    QDomDocument doc("vd");
    QFile file(path);

    if (!file.open(QIODevice::ReadOnly))
    {
        _error     = true;
        _errorText = "Can not open XML-File!";
        return QList<GLObject*>();
    }

    QString xmlError;
    int     xmlErrorLine;

    if (!doc.setContent(&file,false,&xmlError,&xmlErrorLine))
    {
        _error     = true;
        _errorText = "XML parser error: " + xmlError + "<br/>"
                     "Line: " + QString::number(xmlErrorLine);

        file.close();
        return QList<GLObject*>();
    }

    QDomElement root = doc.documentElement();

    if( root.tagName() != "vd" )
    {
        _error     = true;
        _errorText = "XML root tag is not valid!";
        return QList<GLObject*>();
    }

    QList<GLObject*> objectList;
    QDomNode node = root.firstChild();

    QProgressDialog progress("Read XML-File...", "Cancel", 0, root.childNodes().size());
    progress.setCancelButton(0);
    progress.show();
    int count = 0;

    while (!node.isNull())
    {
        progress.setValue(count);

        if (QDomNode::ElementNode == node.nodeType())
        {
            QDomElement object = node.toElement();
            QString type = object.attribute("type");

            if (type == "point")
                objectList.append(GLPoint::fromXml(object));
            else if (type == "vector")
                objectList.append(GLVector::fromXml(object));
            else if (type == "plane")
                objectList.append(GLPlane::fromXml(object));
            else if (type == "line")
                objectList.append(GLLine::fromXml(object));
            else if (type == "angle")
                objectList.append(GLAngle::fromXml(object, objectList));
            else if (type == "delete")
                objectList.append(GLDelete::fromXml(object, objectList));
            else
            {
                _error     = true;
                _errorText = "Object type not found!<br/>"
                             "Line: " + QString::number(node.lineNumber()) + ", Type: " + type;
            }

        }

        for(int i = 0; i < objectList.size()-1; i++)
        {
            if(objectList.at(i)->id() == objectList.last()->id())
            {
                _error     = true;
                _errorText = "Another object with this id was found!<br/>"
                             "Line: " + QString::number(node.lineNumber()) + ", ID: " + objectList.last()->id();
                qDeleteAll(objectList);
                return QList<GLObject*>();
            }
        }

        node = node.nextSibling();        
        count++;
    }

    return objectList;
}
コード例 #6
0
ファイル: configparser.cpp プロジェクト: ZSchneidi/Projekt-42
/**
 * This method is designed to parse the object config file
 * and to initialize the required objects in the UIObjectHandler
 */
bool ConfigParser::buildObjects(const QString object_cfgv)
    {
    this->getNodeList(object_cfgv,OBJECT_CFG_TAG);
    /*if at least 1 tag was found proceed otherwise return false*/
    if(!this->temp_node_list->count() > 0)
		{
        this->core->configLogError(QString(MISSING_OBJ_TAG));
		return false;
		}
    /*iterate through the dom nodes*/
    for(int i = 0;i <this->temp_node_list->count();i++)
		{
		QDomNode node = this->temp_node_list->item(i);
		QDomNamedNodeMap map = node.attributes();
		/*iterate through the attributes*/
		for(uint i = 1; i <= map.length();i++)
			{
			if(map.item(i-1).isAttr())
				{
				QDomAttr attr = map.item(i-1).toAttr();
				/* handle the different object types */
				if(attr.name() == OBJECT_CFG_TYPE_ATTR)
					{
					if(attr.value() == OBJECT_TYPE_SCREEN)
						{
						ScreenObject* temp_screen = new ScreenObject();
						temp_screen->buildScreenObject(this,map);
						this->screen_list_ref->append(temp_screen);
						this->core->configLogInfo(this->screen_list_ref->last()->getObjLogEntry());
						}
					else if(attr.value() == OBJECT_TYPE_BUTTON_C)
						{
						ButtonCObject *temp_buttonc = new ButtonCObject();
						temp_buttonc->buildButtonCObject(this,map);
						this->buttonc_list_ref->append(temp_buttonc);
						this->core->configLogInfo(this->buttonc_list_ref->last()->getObjLogEntry());
						}
					else
						{
						this->core->configLogWarning(QString(UNHA_OBJ_TYPE_MSG).replace("#_1",attr.value())+"in "+object_cfgv+" on line "+QString::number(node.lineNumber()));
						}
					}
				}
			}
		}
    return true;
    }