#include "module.h" int Module::lastID = 0; Module::Module(): type (ModuleType::TYPE_PM), parentModule(nullptr), ID(0), isActive(false) { ID = ++lastID; } Module::~Module() { } Module *Module::getModuleByID(int id) { if(getID() == id) return this; if(this->getType() == ModuleType::TYPE_PM) { PM* PMmodul = static_cast(this); Module* ptrModule = nullptr; for(Module* module: PMmodul->getListChildModules()) { ptrModule = module->getModuleByID(id); if(ptrModule) return ptrModule; } } return nullptr; } void Module::setIsActiveTrue() { this->isActive = true; if(parentModule) parentModule->setIsActiveTrue(); } bool Module::getIsActive() { return this->isActive; } void Module::setModeList(ModeList modeList) { this->modeList = modeList; if(modeList.demo || modeList.train || modeList.exam /*|| modeList.autoM*/) setIsActiveTrue(); } 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(module); else delete static_cast(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; } PM::pmLangStruct PM::getLangStructRus() { return langRus; } void PM::setLangStructEng(QString title) { langEng.title = title; } void PM::addChildModule(Module *childModule) { listChildModules.append(childModule); } QList PM::getListChildModules() { return listChildModules; } QString PM::pmCode() { return (modelIdentCode + "-" + pmIssuer + "-" + pmNumber + "-" + pmVolume).toUpper(); } 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; } DM::dmLangStruct DM::getLangStructRus() { return langRus; } 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; } QString DM::dmCode() { return (modelIdentCode + "-" + systemDiffCode + "-" + systemCode + "-" + subSystemCode + subSubSystemCode + "-" + assyCode + "-" + disassyCode + disassyCodeVariant + "-" + infoCode + infoCodeVariant + "-" + itemLocationCode).toUpper(); }