2025-05-08 15:00:13 +00:00
|
|
|
|
#include "WBFZAlgComponetXmlParaseOperator.h"
|
2025-05-09 07:25:29 +00:00
|
|
|
|
|
|
|
|
|
WBFZAlgComponetXmlParamenterItem::WBFZAlgComponetXmlParamenterItem(QDomElement* itemparameter, QObject* parent) :QObject(parent)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr == itemparameter) {
|
|
|
|
|
qDebug() << "itemparameter is nullptr.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this->ParaName = itemparameter->attribute("Name");
|
|
|
|
|
this->ParaChsName = itemparameter->attribute("ChsName");
|
|
|
|
|
this->Description = itemparameter->attribute("Description");
|
|
|
|
|
this->Datatype = itemparameter->attribute("Datatype");
|
|
|
|
|
this->ParaType = itemparameter->attribute("Type");
|
|
|
|
|
this->ValueStr = itemparameter->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WBFZAlgComponetXmlParamenterItem::~WBFZAlgComponetXmlParamenterItem()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WBFZAlgComponetXmlParaseOperator::WBFZAlgComponetXmlParaseOperator(QObject* parent) :QObject(parent)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WBFZAlgComponetXmlParaseOperator::~WBFZAlgComponetXmlParaseOperator()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParaseOperator::loadXmlFile(const QString& fileName)
|
|
|
|
|
{
|
|
|
|
|
this->xmlFilePath = fileName;
|
|
|
|
|
this->parseXmlFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParaseOperator::parseXmlFile()
|
|
|
|
|
{
|
|
|
|
|
// 1. Load the XML file
|
|
|
|
|
QFile file(xmlFilePath);
|
|
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
|
qDebug() << "Failed to open XML file.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 2. Create a QDomDocument object
|
|
|
|
|
QDomDocument doc;
|
|
|
|
|
if (!doc.setContent(&file)) {
|
|
|
|
|
qDebug() << "Failed to parse XML file.";
|
|
|
|
|
file.close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 3. Close the file
|
|
|
|
|
file.close();
|
|
|
|
|
// 4. Get the root element
|
|
|
|
|
QDomElement root = doc.documentElement();
|
|
|
|
|
// 5. Get the child elements of the root
|
|
|
|
|
QDomNodeList childNodes = root.childNodes();
|
|
|
|
|
// 6. get the workspace path node
|
|
|
|
|
QDomNodeList workspacePathNodes = root.elementsByTagName("WorkspacePath");
|
|
|
|
|
if (workspacePathNodes.count() > 0) {
|
|
|
|
|
QDomElement workspacePathElement = workspacePathNodes.at(0).toElement();
|
|
|
|
|
this->workSpacePath = workspacePathElement.text();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
qDebug() << "WorkspacePath not found.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 7. get Root/AlgCompt/Inputs <20>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>Parameter<65>ӽڵ<D3BD>
|
|
|
|
|
QDomNodeList parameterNodes = root.elementsByTagName("Parameter");
|
|
|
|
|
if (parameterNodes.count() > 0) {
|
|
|
|
|
for (int i = 0; i < parameterNodes.count(); ++i) {
|
|
|
|
|
QDomElement parameterElement = parameterNodes.at(i).toElement();
|
|
|
|
|
WBFZAlgComponetXmlParamenterItem* item = new WBFZAlgComponetXmlParamenterItem(¶meterElement,this);
|
|
|
|
|
this->ParameterList.append(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
qDebug() << "Parameter not found.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 8. Display the parsed data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParaseOperator::displayParsedData()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getParaName() const
|
|
|
|
|
{
|
|
|
|
|
return this->ParaName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setParaName(const QString& name)
|
|
|
|
|
{
|
|
|
|
|
this->ParaName = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getParaChsName() const
|
|
|
|
|
{
|
|
|
|
|
return this->ParaChsName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setParaChsName(const QString& name)
|
|
|
|
|
{
|
|
|
|
|
this->ParaChsName = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getDescription() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setDescription(const QString& description)
|
|
|
|
|
{
|
|
|
|
|
this->Description = description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getDatatype() const
|
|
|
|
|
{
|
|
|
|
|
return this->Datatype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setDatatype(const QString& datatype)
|
|
|
|
|
{
|
|
|
|
|
this->Datatype = datatype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getParaType() const
|
|
|
|
|
{
|
|
|
|
|
return this->ParaType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setParaType(const QString& type)
|
|
|
|
|
{
|
|
|
|
|
this->ParaType = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getValueStr() const
|
|
|
|
|
{
|
|
|
|
|
return this->ValueStr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setValueStr(const QString& value)
|
|
|
|
|
{
|
|
|
|
|
this->ValueStr = value;
|
|
|
|
|
}
|