mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
first after fork install
This commit is contained in:
176
DB_IaT/InstructorsAndTrainees/docTasks/doctaskswidget.cpp
Normal file
176
DB_IaT/InstructorsAndTrainees/docTasks/doctaskswidget.cpp
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
#include <QFile>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QDomDocument>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include "doctaskswidget.h"
|
||||||
|
#include "ui_doctaskswidget.h"
|
||||||
|
|
||||||
|
DocTasksWidget::DocTasksWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::DocTasksWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
treeWidget = new QTreeWidget();
|
||||||
|
ui->horizontalLayout_2->addWidget(treeWidget);
|
||||||
|
treeWidget->setStyleSheet(QStringLiteral("font-size: 10pt;"
|
||||||
|
"font-family: Tahoma;"));
|
||||||
|
|
||||||
|
loadDocTasksFromXML();
|
||||||
|
}
|
||||||
|
|
||||||
|
DocTasksWidget::~DocTasksWidget()
|
||||||
|
{
|
||||||
|
deleteAllModuls();
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocTasksWidget::DomElementParser(QDomElement element, Module* moduleParent)
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
|
||||||
|
QDomElement childElement = element.firstChildElement();
|
||||||
|
if(childElement.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Module* module = nullptr;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
name = childElement.nodeName();
|
||||||
|
|
||||||
|
QDomNamedNodeMap nodeMap = childElement.attributes();
|
||||||
|
|
||||||
|
if(name == "pm")
|
||||||
|
{
|
||||||
|
QString modelIdentCode = nodeMap.namedItem("modelIdentCode").nodeValue();
|
||||||
|
QString pmIssuer = nodeMap.namedItem("pmIssuer").nodeValue();
|
||||||
|
QString pmNumber = nodeMap.namedItem("pmNumber").nodeValue();
|
||||||
|
QString pmVolume = nodeMap.namedItem("pmVolume").nodeValue();
|
||||||
|
|
||||||
|
module = new PM();
|
||||||
|
|
||||||
|
PM* PMmodul = static_cast<PM*>(module);
|
||||||
|
|
||||||
|
PMmodul->initialize(modelIdentCode, pmIssuer, pmNumber, pmVolume);
|
||||||
|
|
||||||
|
if(moduleParent)
|
||||||
|
{
|
||||||
|
PM* PMmodulParent = static_cast<PM*>(moduleParent);
|
||||||
|
PMmodulParent->addChildModule(module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(name == "dm")
|
||||||
|
{
|
||||||
|
QString modelIdentCode = nodeMap.namedItem("modelIdentCode").nodeValue();
|
||||||
|
QString systemDiffCode = nodeMap.namedItem("systemDiffCode").nodeValue();
|
||||||
|
QString systemCode = nodeMap.namedItem("systemCode").nodeValue();
|
||||||
|
QString subSystemCode = nodeMap.namedItem("subSystemCode").nodeValue();
|
||||||
|
QString subSubSystemCode = nodeMap.namedItem("subSubSystemCode").nodeValue();
|
||||||
|
QString assyCode = nodeMap.namedItem("assyCode").nodeValue();
|
||||||
|
QString disassyCode = nodeMap.namedItem("disassyCode").nodeValue();
|
||||||
|
QString disassyCodeVariant = nodeMap.namedItem("disassyCodeVariant").nodeValue();
|
||||||
|
QString infoCode = nodeMap.namedItem("infoCode").nodeValue();
|
||||||
|
QString infoCodeVariant = nodeMap.namedItem("infoCodeVariant").nodeValue();
|
||||||
|
QString itemLocationCode = nodeMap.namedItem("itemLocationCode").nodeValue();
|
||||||
|
|
||||||
|
module = new DM();
|
||||||
|
|
||||||
|
DM* PMmodul = static_cast<DM*>(module);
|
||||||
|
|
||||||
|
PMmodul->initialize(modelIdentCode,
|
||||||
|
systemDiffCode,
|
||||||
|
systemCode,
|
||||||
|
subSystemCode,
|
||||||
|
subSubSystemCode,
|
||||||
|
assyCode,
|
||||||
|
disassyCode,
|
||||||
|
disassyCodeVariant,
|
||||||
|
infoCode,
|
||||||
|
infoCodeVariant,
|
||||||
|
itemLocationCode);
|
||||||
|
|
||||||
|
if(moduleParent)
|
||||||
|
{
|
||||||
|
PM* PMmodulParent = static_cast<PM*>(moduleParent);
|
||||||
|
PMmodulParent->addChildModule(module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(name == "rus" || name == "eng")
|
||||||
|
{
|
||||||
|
if(moduleParent)
|
||||||
|
{
|
||||||
|
if(moduleParent->getType() == ModuleType::TYPE_PM)
|
||||||
|
{//PM
|
||||||
|
QString title = nodeMap.namedItem("title").nodeValue();
|
||||||
|
|
||||||
|
PM* PMmodulParent = static_cast<PM*>(moduleParent);
|
||||||
|
|
||||||
|
if(name == "rus")
|
||||||
|
PMmodulParent->setLangStructRus(title);
|
||||||
|
else
|
||||||
|
PMmodulParent->setLangStructEng(title);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//DM
|
||||||
|
QString techName = nodeMap.namedItem("techName").nodeValue();
|
||||||
|
QString infoName = nodeMap.namedItem("infoName").nodeValue();
|
||||||
|
QString pdf = nodeMap.namedItem("pdf").nodeValue();
|
||||||
|
QString bookmark = nodeMap.namedItem("bookmark").nodeValue();
|
||||||
|
QString xml = nodeMap.namedItem("xml").nodeValue();
|
||||||
|
|
||||||
|
DM* DMmodulParent = static_cast<DM*>(moduleParent);
|
||||||
|
|
||||||
|
if(name == "rus")
|
||||||
|
DMmodulParent->setLangStructRus(techName, infoName, pdf, bookmark, xml);
|
||||||
|
else
|
||||||
|
DMmodulParent->setLangStructEng(techName, infoName, pdf, bookmark, xml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DomElementParser(childElement, module);
|
||||||
|
|
||||||
|
if(moduleParent == nullptr)
|
||||||
|
listAllModules.append(module);
|
||||||
|
|
||||||
|
}while (! (childElement = childElement.nextSiblingElement()).isNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocTasksWidget::loadDocTasksFromXML()
|
||||||
|
{
|
||||||
|
QDomDocument docTasksDOM;
|
||||||
|
QString xmlFileName = "./docs.xml";
|
||||||
|
QFile xmlInFile(xmlFileName);
|
||||||
|
if (!xmlInFile.open(QFile::ReadOnly | QFile::Text))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(nullptr, tr("Attention!"), tr("The file could not be opened ") + xmlFileName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
docTasksDOM.setContent(xmlInFile.readAll());
|
||||||
|
xmlInFile.close();
|
||||||
|
|
||||||
|
QDomElement manifestElement = docTasksDOM.firstChildElement("manifest");
|
||||||
|
if(manifestElement.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
deleteAllModuls();
|
||||||
|
|
||||||
|
DomElementParser(manifestElement, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocTasksWidget::deleteAllModuls()
|
||||||
|
{
|
||||||
|
for(Module* module: listAllModules)
|
||||||
|
{
|
||||||
|
if(module->getType() == ModuleType::TYPE_PM)
|
||||||
|
delete static_cast<PM*>(module);
|
||||||
|
else
|
||||||
|
delete static_cast<DM*>(module);
|
||||||
|
}
|
||||||
|
listAllModules.clear();
|
||||||
|
}
|
||||||
|
|
||||||
34
DB_IaT/InstructorsAndTrainees/docTasks/doctaskswidget.h
Normal file
34
DB_IaT/InstructorsAndTrainees/docTasks/doctaskswidget.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef DOCTASKSWIDGET_H
|
||||||
|
#define DOCTASKSWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QTreeWidget>
|
||||||
|
#include <QDomNode>
|
||||||
|
#include "module.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DocTasksWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DocTasksWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DocTasksWidget(QWidget *parent = nullptr);
|
||||||
|
~DocTasksWidget();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void DomElementParser(QDomElement element, Module* moduleParent);
|
||||||
|
void loadDocTasksFromXML();
|
||||||
|
|
||||||
|
void deleteAllModuls();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::DocTasksWidget *ui;
|
||||||
|
QTreeWidget* treeWidget;
|
||||||
|
|
||||||
|
QList<Module*> listAllModules;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DOCTASKSWIDGET_H
|
||||||
43
DB_IaT/InstructorsAndTrainees/docTasks/doctaskswidget.ui
Normal file
43
DB_IaT/InstructorsAndTrainees/docTasks/doctaskswidget.ui
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DocTasksWidget</class>
|
||||||
|
<widget class="QWidget" name="DocTasksWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Tahoma</family>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Document</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
124
DB_IaT/InstructorsAndTrainees/docTasks/module.cpp
Normal file
124
DB_IaT/InstructorsAndTrainees/docTasks/module.cpp
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
#include "module.h"
|
||||||
|
|
||||||
|
Module::Module():
|
||||||
|
type (ModuleType::TYPE_PM),
|
||||||
|
parentModule(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Module::~Module()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PM::PM():
|
||||||
|
modelIdentCode (""),
|
||||||
|
pmIssuer (""),
|
||||||
|
pmNumber (""),
|
||||||
|
pmVolume ("")
|
||||||
|
{
|
||||||
|
type = ModuleType::TYPE_PM;
|
||||||
|
|
||||||
|
langRus.title = "";
|
||||||
|
langEng.title = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
PM::~PM()
|
||||||
|
{
|
||||||
|
for(Module* module: listChildModules)
|
||||||
|
{
|
||||||
|
if(module->getType() == ModuleType::TYPE_PM)
|
||||||
|
delete static_cast<PM*>(module);
|
||||||
|
else
|
||||||
|
delete static_cast<DM*>(module);
|
||||||
|
}
|
||||||
|
listChildModules.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PM::initialize(QString modelIdentCode, QString pmIssuer, QString pmNumber, QString pmVolume)
|
||||||
|
{
|
||||||
|
this->modelIdentCode = modelIdentCode;
|
||||||
|
this->pmIssuer = pmIssuer;
|
||||||
|
this->pmNumber = pmNumber;
|
||||||
|
this->pmVolume = pmVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PM::setLangStructRus(QString title)
|
||||||
|
{
|
||||||
|
langRus.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PM::setLangStructEng(QString title)
|
||||||
|
{
|
||||||
|
langEng.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PM::addChildModule(Module *childModule)
|
||||||
|
{
|
||||||
|
listChildModules.append(childModule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DM::DM():
|
||||||
|
modelIdentCode (""),
|
||||||
|
systemDiffCode (""),
|
||||||
|
systemCode (""),
|
||||||
|
subSystemCode (""),
|
||||||
|
subSubSystemCode (""),
|
||||||
|
assyCode (""),
|
||||||
|
disassyCode (""),
|
||||||
|
disassyCodeVariant (""),
|
||||||
|
infoCode (""),
|
||||||
|
infoCodeVariant (""),
|
||||||
|
itemLocationCode ("")
|
||||||
|
{
|
||||||
|
type = ModuleType::TYPE_DM;
|
||||||
|
|
||||||
|
setLangStructRus("", "", "", "", "");
|
||||||
|
setLangStructEng("", "", "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
DM::~DM()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DM::initialize(QString modelIdentCode, QString systemDiffCode, QString systemCode,
|
||||||
|
QString subSystemCode, QString subSubSystemCode, QString assyCode,
|
||||||
|
QString disassyCode, QString disassyCodeVariant, QString infoCode,
|
||||||
|
QString infoCodeVariant, QString itemLocationCode)
|
||||||
|
{
|
||||||
|
this->modelIdentCode = modelIdentCode;
|
||||||
|
this->systemDiffCode = systemDiffCode;
|
||||||
|
this->systemCode = systemCode;
|
||||||
|
this->subSystemCode = subSystemCode;
|
||||||
|
this->subSubSystemCode = subSubSystemCode;
|
||||||
|
this->assyCode = assyCode;
|
||||||
|
this->disassyCode = disassyCode;
|
||||||
|
this->disassyCodeVariant = disassyCodeVariant;
|
||||||
|
this->infoCode = infoCode;
|
||||||
|
this->infoCodeVariant = infoCodeVariant;
|
||||||
|
this->itemLocationCode = itemLocationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DM::setLangStructRus(QString techName, QString infoName, QString pdf, QString bookmark, QString xml)
|
||||||
|
{
|
||||||
|
langRus.techName = techName;
|
||||||
|
langRus.infoName = infoName;
|
||||||
|
langRus.pdf = pdf;
|
||||||
|
langRus.bookmark = bookmark;
|
||||||
|
langRus.xml = xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DM::setLangStructEng(QString techName, QString infoName, QString pdf, QString bookmark, QString xml)
|
||||||
|
{
|
||||||
|
langEng.techName = techName;
|
||||||
|
langEng.infoName = infoName;
|
||||||
|
langEng.pdf = pdf;
|
||||||
|
langEng.bookmark = bookmark;
|
||||||
|
langEng.xml = xml;
|
||||||
|
}
|
||||||
106
DB_IaT/InstructorsAndTrainees/docTasks/module.h
Normal file
106
DB_IaT/InstructorsAndTrainees/docTasks/module.h
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
#ifndef MODULE_H
|
||||||
|
#define MODULE_H
|
||||||
|
#include <QString>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
enum ModuleType
|
||||||
|
{
|
||||||
|
TYPE_PM = 0,
|
||||||
|
TYPE_DM = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
class Module
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Module();
|
||||||
|
~Module();
|
||||||
|
|
||||||
|
ModuleType getType(){ return type; };
|
||||||
|
void setParentModule(Module* parentModule){ this->parentModule = parentModule; };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ModuleType type;
|
||||||
|
Module* parentModule;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class PM : public Module
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct pmLangStruct
|
||||||
|
{
|
||||||
|
QString title;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
PM();
|
||||||
|
~PM();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void initialize(QString modelIdentCode, QString pmIssuer, QString pmNumber, QString pmVolume);
|
||||||
|
void setLangStructRus(QString title);
|
||||||
|
void setLangStructEng(QString title);
|
||||||
|
void addChildModule(Module* childModule);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString modelIdentCode;
|
||||||
|
QString pmIssuer;
|
||||||
|
QString pmNumber;
|
||||||
|
QString pmVolume;
|
||||||
|
|
||||||
|
pmLangStruct langRus;
|
||||||
|
pmLangStruct langEng;
|
||||||
|
|
||||||
|
QList<Module*> listChildModules;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class DM : public Module
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct dmLangStruct
|
||||||
|
{
|
||||||
|
QString techName;
|
||||||
|
QString infoName;
|
||||||
|
QString pdf;
|
||||||
|
QString bookmark;
|
||||||
|
QString xml;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
DM();
|
||||||
|
~DM();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void initialize(QString modelIdentCode,
|
||||||
|
QString systemDiffCode,
|
||||||
|
QString systemCode,
|
||||||
|
QString subSystemCode,
|
||||||
|
QString subSubSystemCode,
|
||||||
|
QString assyCode,
|
||||||
|
QString disassyCode,
|
||||||
|
QString disassyCodeVariant,
|
||||||
|
QString infoCode,
|
||||||
|
QString infoCodeVariant,
|
||||||
|
QString itemLocationCode);
|
||||||
|
void setLangStructRus(QString techName, QString infoName, QString pdf, QString bookmark, QString xml);
|
||||||
|
void setLangStructEng(QString techName, QString infoName, QString pdf, QString bookmark, QString xml);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString modelIdentCode;
|
||||||
|
QString systemDiffCode;
|
||||||
|
QString systemCode;
|
||||||
|
QString subSystemCode;
|
||||||
|
QString subSubSystemCode;
|
||||||
|
QString assyCode;
|
||||||
|
QString disassyCode;
|
||||||
|
QString disassyCodeVariant;
|
||||||
|
QString infoCode;
|
||||||
|
QString infoCodeVariant;
|
||||||
|
QString itemLocationCode;
|
||||||
|
|
||||||
|
dmLangStruct langRus;
|
||||||
|
dmLangStruct langEng;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MODULE_H
|
||||||
BIN
DB_IaT/InstructorsAndTrainees/icons/docTasks.png
Normal file
BIN
DB_IaT/InstructorsAndTrainees/icons/docTasks.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Reference in New Issue
Block a user