#include "s1000d_manager.h" #include #include #include #include #include #include #include //#include //#include //#include #include #include // DM: Chapter 3.9.5.2.1.2 Common constructs // ICN: 1822 // большинство функций работают с текущим элементом списка, хранимым в item // ВСЕГДА сначала необходимо вызывать setCurItem(int ind) S1000D_Manager::S1000D_Manager() { ru_const.Init_RU_Const(); } S1000D_Manager::~S1000D_Manager() { clearItems(); } QDomNode S1000D_Manager::findElementRec(QDomNode domNode, QString path) { QStringList elementTagNames = path.split('.'); QDomNodeList domNodeList = domNode.childNodes(); //if(DBG) qDebug() << path; if(elementTagNames.isEmpty() || path == "") return domNode; int nodeInd = getNodePathIndex(elementTagNames.first()); QString nodeName = elementTagNames.first(); if(nodeName.indexOf("[") != -1) nodeName = nodeName.mid(0, nodeName.indexOf("[")); //if(DBG) qDebug() << " " << elementTagNames.first() << " -> " << nodeName << "[" << nodeInd << "]" << " childs " << domNodeList.count(); for(int i = 0; i < domNodeList.count(); i++) { //if(DBG) qDebug() << " search for" << nodeName << "=?" << domNodeList.at(i).nodeName(); if(domNodeList.at(i).nodeName().compare(nodeName,Qt::CaseInsensitive) == 0) { //toElement().tagName(). if(nodeInd > 0) { nodeInd--; continue; } elementTagNames.takeFirst(); if(elementTagNames.isEmpty()) return domNodeList.at(i); else return findElementRec(domNodeList.at(i), elementTagNames.join(".")); } } //if(DBG) qDebug() << " Node " << elementTagNames.at(0) << " not found (" << path << ")"; QDomElement nullElement = item->doc.createElement(""); return nullElement; //QDomElement newElement = item->doc.createElement(elementTagNames.at(0)); // если узел отсутствует - создаем //elementTagNames.takeFirst(); //domNode.appendChild(newElement); //return findElementRec(newElement,elementTagNames.join(".")); } QDomNode S1000D_Manager::findElement(QString path) { //if(DBG) qDebug() << item->doc.documentElement().tagName(); //if(DBG) qDebug() << " findElement " << path; return findElementRec(item->doc.documentElement(), path); } QString S1000D_Manager::getNodeText(QString path) { QDomNode element = findElement(path); if(element.isNull()) return ""; else return element.toElement().text(); } void S1000D_Manager::setNodeText(QString path, QString text) { QDomNode element = findElement(path); if(element.isNull()) return; //if(DBG) qDebug() << " element: " << element.firstChild().isText() << element.nodeName(); for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) { QDomText t = n.toText(); if (!t.isNull()) t.setNodeValue(text); } if(element.childNodes().count() == 0) { QDomText t = item->doc.createTextNode(text); element.appendChild(t); } } void S1000D_Manager::deleteNode(QString path) { QDomNode element = findElement(path); if(element.isNull()) return; element.parentNode().removeChild(element); } int S1000D_Manager::createNode(QString path, QString nodeName) { // возвращает номер созданного узла для обращения по индексу: node[i] QDomNode element = findElement(path); if(element.isNull()) return -1; QDomElement newNode = item->doc.createElement(nodeName); element.appendChild(newNode); QDomNodeList lst = element.childNodes(); int index = -1; for(int i=0; idoc.createAttribute(attrName); domAttr.setValue(attrVal); element.toElement().setAttributeNode(domAttr); } */ } void S1000D_Manager::deleteNodeAttr(QString path, QString attrName) { QDomNode element = findElement(path); if(element.isNull()) return; element.toElement().removeAttribute(attrName); } QStringList S1000D_Manager::getNodeAllChilds(QString path) { QStringList nodeList; QDomNode element = findElement(path); if(element.isNull()) return nodeList; QDomNodeList domNodeList = element.childNodes(); for(int i=0;i mask; mask.append(QString("*.xml")); QStringList listFiles = dir.entryList(mask, QDir::Files); //bool validFlag; clearItems(); foreach (QString file, listFiles) { item = new ItemStruct(); item->fileName = dir.absoluteFilePath(file); item->isReady = true; //log.append(QFileInfo(file).fileName()); //if(DBG) qDebug() << "Открытие " << QFileInfo(file).fileName(); QFile xmlFile(item->fileName); if (!xmlFile.open(QFile::ReadOnly | QFile::Text)) { log.append(QString(" Не удалось открыть файл")); continue; } QByteArray fileData = xmlFile.readAll(); xmlFile.close(); item->doc.setContent(fileData); QString curscheme = QFileInfo(item->doc.documentElement().attribute("xsi:noNamespaceSchemaLocation", "")).baseName().toUpper(); item->moduleType = mtUNKNOWN; if(item->doc.documentElement().nodeName().toUpper() == "DMODULE") item->moduleType = mtDM; if(item->doc.documentElement().nodeName().toUpper() == "PM") item->moduleType = mtPM; //log.append(QString(" Тип модуля: ")+item->doc.documentElement().nodeName() + QString(" Файл схемы: ")+curscheme); //if(DBG) qDebug() << " Тип модуля: " << item->doc.documentElement().nodeName() << " Файл схемы: " << curscheme; // Доп. ТЗ № 1 Вертолеты России: // Резрешено использовать только flat схемы, перечисленные ниже: // - brex // - comrep // - crew // - descript // - dml // - fault // - frontmatter // - learning // - pm // - proced item->schemeType = getSchemeTypeByStr(curscheme); if(item->moduleType == mtUNKNOWN) { //log.append(QString(" Тип модуля не поддерживается, файл пропущен")); continue; } if(item->schemeType == stUNKNOWN) { //log.append(QString(" Неизвестная схема файла, пропущен")); continue; } //if((item->schemeType != PM) && (item->schemeType != DESCRIPT) && // (item->schemeType != CREW) && (item->schemeType != LEARNING) ) { // log.append(QString(" Работа с файлами схемы " +curscheme+ " в настоящее время не реализована, файл пропущен")); // continue; //} item->fileCode = ""; // DMC-S1000DLIGHTING-AAA-D00-00-00-00AA-0A1A-D_001-00_EN-US //S1000DLIGHTING-AAA-D00-00-00-00AA-00NA-D_001-00 //dmodule // // QString _language; //_dmCode, _issueInfo, , _pmCode; QString newFileName = item->fileName; if(item->moduleType == mtDM) { item->fileCode = dmIdentString("identAndStatusSection.dmAddress.dmIdent"); if(!isNodeCreated("rdf:Description")) { QDomNode descr = item->doc.createElement("rdf:Description"); findElement("").insertBefore(descr, findElement("").firstChild()); } if(!isNodeCreated("rdf:Description.dc:identifier")) createNode("rdf:Description", "dc:identifier"); setNodeText("rdf:Description.dc:identifier", item->fileCode); _language = "identAndStatusSection.dmAddress.dmIdent.language"; newFileName = QFileInfo(item->fileName).absolutePath()+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_language, "languageIsoCode").toUpper()+"-"+getNodeAttr(_language, "countryIsoCode").toUpper()+".xml"; item->dmDataFilled = true; item->selectedInDMCodeList = -1; } // PMC-BRAKE-C3002-EPWG1-00_000-01_EN-US // BRAKE-C3002-EPWG1-00_000_01 // // if(item->moduleType == mtPM) { //_pmCode = "identAndStatusSection.pmAddress.pmIdent.pmCode"; //_issueInfo = "identAndStatusSection.pmAddress.pmIdent.issueInfo"; _language = "identAndStatusSection.pmAddress.pmIdent.language"; item->fileCode = pmIdentString("identAndStatusSection.pmAddress.pmIdent"); if(!isNodeCreated("rdf:Description")) { QDomNode descr = item->doc.createElement("rdf:Description"); findElement("").insertBefore(descr, findElement("").firstChild()); } if(!isNodeCreated("rdf:Description.dc:identifier")) createNode("rdf:Description", "dc:identifier"); setNodeText("rdf:Description.dc:identifier", item->fileCode); newFileName = QFileInfo(item->fileName).absolutePath()+"/" + "PMC-" + item->fileCode + "_"+getNodeAttr(_language, "languageIsoCode").toUpper()+"-"+getNodeAttr(_language, "countryIsoCode").toUpper()+".xml"; } if(isNodeCreated("rdf:Description.dc:source")) item->importedFromLyX = getNodeText("rdf:Description.dc:source"); else item->importedFromLyX = ""; if(QFileInfo(newFileName.toUpper()).fileName() != QFileInfo(item->fileName.toUpper()).fileName()) if(QFileInfo::exists(item->fileName)) { QFile::rename(item->fileName, newFileName); log.append(QString(" Файл переименован в " + QFileInfo(newFileName).fileName())); item->fileName = newFileName; } item->parent = -1; item->child.clear(); //if(DBG) qDebug() << item->fileCode; items.append(*item); // файл прочтен успешно, добавляем в список } // цикл по файлам for(int i=0;i 1) { nodeClone = lcInteractionNode.lastChild().cloneNode(); lcInteractionNode.removeChild(lcInteractionNode.lastChild()); newInter = item->doc.createElement("lcInteraction"); newInter.appendChild(nodeClone); lcInteractionNode.parentNode().insertAfter(newInter, lcInteractionNode); interCnt++; } } } return true; */ } _schemeType S1000D_Manager::getSchemeTypeByStr(QString str) { _schemeType newSchemeType = stUNKNOWN; if(str == "DDN") newSchemeType = stDDN; if(str == "DML") newSchemeType = stDML; if(str == "PM") newSchemeType = stPM; if(str == "APPLICCROSSREFTABLE") newSchemeType = stAPPLICCROSSREFTABLE; if(str == "PRDCROSSREFTABLE") newSchemeType = stPRDCROSSREFTABLE; if(str == "CONDCROSSREFTABLE") newSchemeType = stCONDCROSSREFTABLE; if(str == "DESCRIPT") newSchemeType = stDESCRIPT; if(str == "PROCED") newSchemeType = stPROCED; if(str == "PROCESS") newSchemeType = stPROCESS; if(str == "COMREP") newSchemeType = stCOMREP; if(str == "FRONTMATTER") newSchemeType = stFRONTMATTER; if(str == "BREX") newSchemeType = stBREX; if(str == "BRDOC") newSchemeType = stBRDOC; if(str == "LEARNING") newSchemeType = stLEARNING; if(str == "CREW") newSchemeType = stCREW; if(str == "FAULT") newSchemeType = stFAULT; if(str == "IPD") newSchemeType = stIPD; if(str == "CHECKLIST") newSchemeType = stCHECKLIST; if(str == "NOTATIONS") newSchemeType = stNOTATIONS; if(str == "CONTAINER") newSchemeType = stCONTAINER; if(str == "XLINK") newSchemeType = stXLINK; if(str == "WRNGFLDS") newSchemeType = stWRNGFLDS; return newSchemeType; } void S1000D_Manager::buildPMTree(int pmItemInd) { setCurItem(pmItemInd); bool isModifyed = false; QString PMCodeStr, DMCodeStr; QDomNode mainEntry, secondEntry, clone, subEntry, subSubEntry; mainEntry = findElement("content.pmEntry[0]"); if(mainEntry.isNull()) return; while(isNodeCreated("content.pmEntry[1]")) { secondEntry = findElement("content.pmEntry[1]"); while(secondEntry.hasChildNodes()) { if(secondEntry.firstChild().nodeName() == "dmRef" || secondEntry.firstChild().nodeName() == "pmRef") { clone = secondEntry.firstChild().cloneNode(); item->doc.importNode(clone, true); mainEntry.appendChild(clone); } if(secondEntry.firstChild().nodeName() == "pmEntry") { subEntry = secondEntry.firstChild(); while(subEntry.hasChildNodes()) { if(subEntry.firstChild().nodeName() == "dmRef" || subEntry.firstChild().nodeName() == "pmRef") { clone = subEntry.firstChild().cloneNode(); item->doc.importNode(clone, true); mainEntry.appendChild(clone); } if(subEntry.firstChild().nodeName() == "pmEntry") { subSubEntry = secondEntry.firstChild(); while(subSubEntry.hasChildNodes()) { if(subSubEntry.firstChild().nodeName() == "dmRef" || subSubEntry.firstChild().nodeName() == "pmRef") { clone = subSubEntry.firstChild().cloneNode(); item->doc.importNode(clone, true); mainEntry.appendChild(clone); } //.. subSubEntry.removeChild(subEntry.firstChild()); } subEntry.removeChild(subEntry.firstChild()); } } } secondEntry.removeChild(secondEntry.firstChild()); } mainEntry.parentNode().removeChild(secondEntry); } int pmRefCnt=-1, dmRefCnt=-1; for(int p=0;p!) в основную pmEntry // QDomNode mainEntry, subEntry; // QDomNodeList subEntryChildList; // while(isNodeCreated(path+".pmEntry["+QString::number(i)+"].pmEntry")) { // mainEntry = findElement(path+".pmEntry["+QString::number(i)+"]"); // int subEntryCnt = getNodeChildsWithNameCount(path+".pmEntry["+QString::number(i)+"]", "pmEntry"); // for(int j=0;jfileCode = ""; // если изменилось кодирование модулей - переименовываем старые файлы QString _issueInfo, _language; QString newFileName = item->fileName; if(item->moduleType == mtDM) { item->fileCode = dmIdentString("identAndStatusSection.dmAddress.dmIdent"); _issueInfo = "identAndStatusSection.dmAddress.dmIdent.issueInfo"; _language = "identAndStatusSection.dmAddress.dmIdent.language"; newFileName = QFileInfo(item->fileName).absolutePath()+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml"; } if(item->moduleType == mtPM) { _issueInfo = "identAndStatusSection.pmAddress.pmIdent.issueInfo"; _language = "identAndStatusSection.pmAddress.pmIdent.language"; item->fileCode = pmIdentString("identAndStatusSection.pmAddress.pmIdent"); newFileName = QFileInfo(item->fileName).absolutePath()+"/" + "PMC-" + item->fileCode + "_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml"; } if(QFileInfo(newFileName.toUpper()).fileName() != QFileInfo(item->fileName.toUpper()).fileName()) if(QFileInfo::exists(item->fileName)) { QFile::rename(item->fileName, newFileName); log.append(QString(" Файл "+QFileInfo(item->fileName).fileName()+" переименован в " + QFileInfo(newFileName).fileName())); } item->fileName = newFileName; } */ } void S1000D_Manager::SaveProject() { qSetGlobalQHashSeed(0); for(int i=0;imoduleType == mtDM) { item->fileCode = dmIdentString("identAndStatusSection.dmAddress.dmIdent"); QDomNode descr = item->doc.namedItem("dmodule").namedItem("rdf:Description"); if(descr.isNull()) { descr = item->doc.createElement("rdf:Description"); item->doc.namedItem("dmodule").insertBefore(descr, item->doc.namedItem("dmodule").namedItem("identAndStatusSection")); } //descr.toElement().setAttribute("flags", QString::number(item->crewFlags, 16)); if(item->isQualifyed) descr.toElement().setAttribute("qualifyed", "true"); else descr.toElement().setAttribute("qualifyed", "false"); } if(item->moduleType == mtPM) { item->fileCode = pmIdentString("identAndStatusSection.pmAddress.pmIdent"); QDomNode descr = item->doc.namedItem("pm").namedItem("rdf:Description"); if(descr.isNull()) { descr = item->doc.createElement("rdf:Description"); item->doc.namedItem("pm").insertBefore(descr, item->doc.namedItem("pm").namedItem("identAndStatusSection")); } //descr.toElement().setAttribute("flags", QString::number(item->crewFlags, 16)); if(item->isQualifyed) descr.toElement().setAttribute("qualifyed", "true"); else descr.toElement().setAttribute("qualifyed", "false"); } QFile xmlFile(projectPath + "/" + item->fileName); if (!xmlFile.open(QFile::WriteOnly | QFile::Text)) { if(DBG) qDebug() << "SaveProject: Не удалось открыть файл "+projectPath + "/" + item->fileName; return; } QTextStream outFile(&xmlFile); item->doc.save(outFile, 4); xmlFile.close(); //qDebug() << "Save ("+item->fileCode+"): " + projectPath + "/" + item->fileName; if(item->moduleType == mtPM) continue; if(item->html.count() > 0) { QString htmlFileName = projectPath + "/" + QString(item->fileName).replace(".xml", ".html"); QFile htmlFile(htmlFileName); if (htmlFile.open(QFile::ReadWrite | QFile::Text)) { QTextStream out(&htmlFile); out.setCodec("UTF-8"); for(int i=0;ihtml.count();i++) out << QString(item->html[i]+"\n").toUtf8(); htmlFile.close(); } } QString lyxLogFileName = projectPath + "/" + item->fileName+"_importlog.txt"; //lyxLogFileName.toStdString() QFile logFile(lyxLogFileName); if (logFile.open(QFile::ReadWrite | QFile::Text)) { QTextStream out(&logFile); out.setCodec("UTF-8"); for(int i=0;ilyxLog.count();i++) out << QString(item->lyxLog[i]+"\n").toUtf8(); logFile.close(); } } SavePackagesXML(); qSetGlobalQHashSeed(-1); // reset hash value } void S1000D_Manager::setCurItem(int ind) { item = &items[ind]; itemIndex = ind; } void S1000D_Manager::replaceCurItem_pmCode(QString new_pmTitle, QString new_modelIdentCode, QString new_pmIssuer, QString new_pmNumber, QString new_pmVolume) { ItemStruct *oldItem = item; QString pmTitle, modelIdentCode, pmIssuer, pmNumber, pmVolume; QString oldPMCodeStr, pmRefCodeStr; pmTitle = getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle"); modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode"); pmIssuer = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer"); pmNumber = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber"); pmVolume = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume"); oldPMCodeStr = pmIdentString("identAndStatusSection.pmAddress.pmIdent"); setNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle", new_pmTitle); setNodeText("content.pmEntry.pmEntryTitle", new_pmTitle); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode", new_modelIdentCode); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer", new_pmIssuer); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber", new_pmNumber); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume", new_pmVolume); if(isNodeCreated("identAndStatusSection.pmAddress.pmAddressItems.shortPmTitle")) deleteNode("identAndStatusSection.pmAddress.pmAddressItems.shortPmTitle"); if(item->parent != -1) { int parent = item->parent; setCurItem(parent); int cntRef = getNodeChildsWithNameCount("content.pmEntry", "pmRef"); for(int p=0;p= pmEntry.childNodes().count()) { if(DBG) qDebug() << " Error: createPM - insertAfterChildNum >= pmEntry.childNodes().count()"; return items.count()-1; } if(isNodeCreated("content.pmEntry.pmEntryTitle")) pmEntry.insertAfter(pmRef, pmEntry.childNodes().at(insertAfterChildNum+1)); else pmEntry.insertAfter(pmRef, pmEntry.childNodes().at(insertAfterChildNum)); setCurItem(items.count()-1); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode", parent_modelIdentCode); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer", parent_pmIssuer); } prepareSaveProject(); return items.count()-1; } int S1000D_Manager::createDM(int parentItemInd, int insertAfterChildNum, QString scheme) { int parent = parentItemInd; while(true) { if(parent == -1) break; if(items[parent].moduleType == mtPM) break; parent = items[parent].parent; } ItemStruct newDM; newDM.parent = parent; newDM.child.clear(); newDM.moduleType = mtDM; newDM.schemeType = getSchemeTypeByStr(scheme); newDM.isReady = false; newDM.fileCode = ""; newDM.fileName = projectPath+"/"+"~NEWFILE"+QString::number(rand())+".xml"; newDM.importedFromLyX = ""; newDM.html.clear(); newDM.isQualifyed = true; //newDM.crewFlags = 0xFFFF; QFile xmlFile(":new/BlankXML/"+scheme.toLower()+".xml"); if (!xmlFile.open(QFile::ReadOnly | QFile::Text)) { if(DBG) qDebug() << " Cant open :new/BlankXML/"+scheme.toLower()+".xml"; return -1; } QByteArray fileData = xmlFile.readAll(); xmlFile.close(); newDM.doc.setContent(fileData); items.append(newDM); if(parent != -1) items[parent].child.insert(insertAfterChildNum+1, items.count()-1); setCurItem(items.count()-1); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "issueNumber", ru_const.issueNumber); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "inWork", ru_const.inWork); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "languageIsoCode", ru_const.languageIsoCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "countryIsoCode", ru_const.countryIsoCode); setNodeAttr("identAndStatusSection.dmStatus.security", "securityClassification", ru_const.security_securityClassification); setNodeAttr("identAndStatusSection.dmStatus.responsiblePartnerCompany", "enterpriseCode", ru_const.responsiblePartnerCompany_enterpriseCode); setNodeText("identAndStatusSection.dmStatus.responsiblePartnerCompany.enterpriseName", ru_const.responsiblePartnerCompany_enterpriseName); setNodeAttr("identAndStatusSection.dmStatus.originator", "enterpriseCode", ru_const.originator_enterpriseCode); setNodeText("identAndStatusSection.dmStatus.originator.enterpriseName", ru_const.originator_enterpriseName); if(parent != -1) { setCurItem(parent); QString parent_modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode"); //QString parent_pmIssuer = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer"); QDomNode pmEntry = findElement("content.pmEntry"); QDomElement dmRef = createEmpty_dmRef(parent_modelIdentCode); if(insertAfterChildNum >= pmEntry.childNodes().count()) { if(DBG) qDebug() << " Error: createDM - insertAfterChildNum >= pmEntry.childNodes().count()"; return items.count()-1; } if(isNodeCreated("content.pmEntry.pmEntryTitle")) pmEntry.insertAfter(dmRef, pmEntry.childNodes().at(insertAfterChildNum+1)); else pmEntry.insertAfter(dmRef, pmEntry.childNodes().at(insertAfterChildNum)); setCurItem(items.count()-1); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode", parent_modelIdentCode); } setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", "Задайте имя и кодирование модуля"); prepareSaveProject(); return items.count()-1; } QDomElement S1000D_Manager::createEmpty_pmRef(QString parent_modelIdentCode, QString parent_pmIssuer) { QDomElement pmRef = item->doc.createElement("pmRef"); QDomElement pmRefIdent = item->doc.createElement("pmRefIdent"); pmRef.appendChild(pmRefIdent); QDomElement pmCode = item->doc.createElement("pmCode"); pmRefIdent.appendChild(pmCode); pmCode.setAttribute("modelIdentCode", parent_modelIdentCode); pmCode.setAttribute("pmIssuer", parent_pmIssuer); pmCode.setAttribute("pmNumber", ""); pmCode.setAttribute("pmVolume", ""); QDomElement issueInfo = item->doc.createElement("issueInfo"); pmRefIdent.appendChild(issueInfo); issueInfo.setAttribute("inWork", ru_const.inWork); issueInfo.setAttribute("issueNumber", ru_const.issueNumber); QDomElement language = item->doc.createElement("language"); pmRefIdent.appendChild(language); language.setAttribute("languageIsoCode", ru_const.languageIsoCode); language.setAttribute("countryIsoCode", ru_const.countryIsoCode); QDomElement pmRefAddressItems = item->doc.createElement("pmRefAddressItems"); pmRef.appendChild(pmRefAddressItems); QDomElement pmTitle = item->doc.createElement("pmTitle"); pmRefAddressItems.appendChild(pmTitle); pmTitle.appendChild(item->doc.createTextNode("")); QDomElement issueDate = item->doc.createElement("issueDate"); pmRefAddressItems.appendChild(issueDate); issueDate.setAttribute("day", ""); issueDate.setAttribute("month", ""); issueDate.setAttribute("year", ""); return pmRef; } QDomElement S1000D_Manager::createEmpty_dmRef(QString parent_modelIdentCode) { QDomElement dmRef = item->doc.createElement("dmRef"); QDomElement dmRefIdent = item->doc.createElement("dmRefIdent"); dmRef.appendChild(dmRefIdent); QDomElement dmCode = item->doc.createElement("dmCode"); dmRefIdent.appendChild(dmCode); dmCode.setAttribute("modelIdentCode", parent_modelIdentCode); dmCode.setAttribute("systemDiffCode", ""); dmCode.setAttribute("systemCode", ""); dmCode.setAttribute("subSystemCode", ""); dmCode.setAttribute("subSubSystemCode", ""); dmCode.setAttribute("assyCode", ""); dmCode.setAttribute("disassyCode", ""); dmCode.setAttribute("disassyCodeVariant", ""); dmCode.setAttribute("infoCode", ""); dmCode.setAttribute("infoCodeVariant", ""); dmCode.setAttribute("itemLocationCode", ""); dmCode.setAttribute("learnCode", ""); dmCode.setAttribute("learnEventCode", ""); QDomElement issueInfo = item->doc.createElement("issueInfo"); dmRefIdent.appendChild(issueInfo); issueInfo.setAttribute("inWork", ru_const.inWork); issueInfo.setAttribute("issueNumber", ru_const.issueNumber); QDomElement language = item->doc.createElement("language"); dmRefIdent.appendChild(language); language.setAttribute("languageIsoCode", ru_const.languageIsoCode); language.setAttribute("countryIsoCode", ru_const.countryIsoCode); QDomElement dmRefAddressItems = item->doc.createElement("dmRefAddressItems"); dmRef.appendChild(dmRefAddressItems); QDomElement dmTitle = item->doc.createElement("dmTitle"); dmRefAddressItems.appendChild(dmTitle); QDomElement dmTechName = item->doc.createElement("techName"); dmTitle.appendChild(dmTechName); dmTechName.appendChild(item->doc.createTextNode("")); QDomElement dmInfoName = item->doc.createElement("infoName"); dmTitle.appendChild(dmInfoName); dmInfoName.appendChild(item->doc.createTextNode("")); QDomElement issueDate = item->doc.createElement("issueDate"); dmRefAddressItems.appendChild(issueDate); issueDate.setAttribute("day", ""); issueDate.setAttribute("month", ""); issueDate.setAttribute("year", ""); return dmRef; } void S1000D_Manager::deleteItem(int itemInd) { prepareSaveProject(); QDomNode oldItemNodeRef; int itemParent = items[itemInd].parent; QString fileName = items[itemInd].fileName; if(items[itemInd].child.count() > 0) return; if(itemParent != -1) { QString refCodeStr = ""; setCurItem(itemParent); int cntRef = getNodeChildsWithNameCount("content.pmEntry", "pmRef"); for(int p=0;p itemInd) items[i].child[j]--; } QFile itemFile(fileName); if(QFileInfo::exists(fileName)) { itemFile.setPermissions(QFileDevice::WriteUser | QFileDevice::ReadUser | QFileDevice::ExeUser); itemFile.remove(); } } void S1000D_Manager::replaceCurItem_dmCode(QString new_techName, QString new_infoName, QString new_modelIdentCode, QString new_systemDiffCode, QString new_systemCode, QString new_subSystemCode, QString new_subSubSystemCode, QString new_assyCode, QString new_disassyCode, QString new_disassyCodeVariant, QString new_infoCode, QString new_infoCodeVariant, QString new_itemLocationCode, QString new_learnCode, QString new_learnEventCode) { if(item->moduleType != mtDM) return; ItemStruct *oldItem = item; QString oldDMCodeStr, dmRefCodeStr; oldDMCodeStr = dmIdentString("identAndStatusSection.dmAddress.dmIdent"); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode", new_modelIdentCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode", new_systemDiffCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode", new_systemCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode", new_subSystemCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode", new_subSubSystemCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode", new_assyCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode", new_disassyCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant", new_disassyCodeVariant); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode", new_infoCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant", new_infoCodeVariant); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode", new_itemLocationCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode", new_learnCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode", new_learnEventCode); setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", new_techName); setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.infoName", new_infoName); if(item->schemeType == stLEARNING) setNodeText("content.learning.learningAssessment.title", new_techName +" - "+ new_infoName); if(item->parent != -1) { int parent = item->parent; setCurItem(parent); int cntRef = getNodeChildsWithNameCount("content.pmEntry", "dmRef"); for(int p=0;pmoduleType == mtPM) return "ICN-ERROR-PM"; QString modelIdentCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode"); QString systemDiffCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode"); QString systemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode"); QString subSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode"); QString subSubSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode"); QString issueNumber = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "issueNumber"); QString z; z.fill('0',5-QString::number(ICN_UI).length()); QString icn_ui = z + QString::number(ICN_UI); ICN_UI++; QString icn = "ICN-"+modelIdentCode+"-"+systemDiffCode+"-"+systemCode+subSystemCode+subSubSystemCode+"-A-"+ ru_const.originator_enterpriseCode+"-"+icn_ui+"-"+ru_const.icn_variantCode+"-"+issueNumber+"-1"; return icn; } bool S1000D_Manager::copyDir(const QString &srcPath, const QString &dstPath) { QDir dstdir = QDir(dstPath); //if (dstdir.exists()) dstdir.removeRecursively(); // не удаляем существующую // QDir parentDstDir(QFileInfo(dstPath).path()); if (!dstdir.exists()) { // if (!parentDstDir.mkdir(QFileInfo(dstPath).fileName())) if (!dstdir.mkpath(dstPath)) return false; } QDir srcDir(srcPath); foreach(const QFileInfo &info, srcDir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { QString srcItemPath = srcPath + "/" + info.fileName(); QString dstItemPath = dstPath + "/" + info.fileName(); if (info.isDir()) { if (!copyDir(srcItemPath, dstItemPath)) return false; } else if (info.isFile()) { if(!QFileInfo(dstItemPath).exists()) if (!QFile::copy(srcItemPath, dstItemPath)) return false; } else { qDebug() << "Unhandled item in copyDir: " + info.filePath(); } } return true; } void S1000D_Manager::ParsePackageContent(QDomNode node, int parentItem) { for(int i=0;imoduleType == mtDM) title = getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName"); else title = getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle"); QString nodeName = node.childNodes().at(i).toElement().attribute("name"); QString nodeOrigTitle = node.childNodes().at(i).toElement().attribute("origTitle"); if(nodeOrigTitle == "") nodeOrigTitle = nodeName; if(nodeOrigTitle != item->origTitle) continue; if(nodeName != nodeOrigTitle && nodeName != "") { if(item->moduleType == mtDM) setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", nodeName); else setNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle", nodeName); } else { if(item->moduleType == mtDM) setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", nodeOrigTitle); else setNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle", nodeOrigTitle); } QString t = node.childNodes().at(i).toElement().attribute("packs"); QStringList packNames = node.childNodes().at(i).toElement().attribute("packs").split(","); foreach(PackageStruct pck, packages) if(pck.cfgName != "" && packNames.contains(pck.cfgName)) if(!item->inPackages.contains(pck.cfgName)) item->inPackages.append(pck.cfgName); QString infoCode, learnCode, disassyCode, systemCode, subSubSystemCode, subSystemCode, learnEventCode, itemLocationCode, systemDiffCode, modelIdentCode, infoCodeVariant, assyCode, disassyCodeVariant, pmIssuer, pmNumber, pmVolume; if(item->moduleType == mtDM) { modelIdentCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode"); if(modelIdentCode == "") { setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode", node.childNodes().at(i).toElement().attribute("infoCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode", node.childNodes().at(i).toElement().attribute("learnCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode", node.childNodes().at(i).toElement().attribute("disassyCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode", node.childNodes().at(i).toElement().attribute("systemCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode", node.childNodes().at(i).toElement().attribute("subSubSystemCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode", node.childNodes().at(i).toElement().attribute("subSystemCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode", node.childNodes().at(i).toElement().attribute("learnEventCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode", node.childNodes().at(i).toElement().attribute("itemLocationCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode", node.childNodes().at(i).toElement().attribute("systemDiffCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode", node.childNodes().at(i).toElement().attribute("modelIdentCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant", node.childNodes().at(i).toElement().attribute("infoCodeVariant")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode", node.childNodes().at(i).toElement().attribute("assyCode")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant", node.childNodes().at(i).toElement().attribute("disassyCodeVariant")); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "languageIsoCode", ru_const.languageIsoCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "countryIsoCode", ru_const.countryIsoCode); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "inWork", ru_const.inWork); setNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "issueNumber", ru_const.issueNumber); item->isQualifyed = (node.childNodes().at(i).toElement().attribute("isQualifyed") == "1"); } } else { modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode"); if(modelIdentCode == "") { setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer", node.childNodes().at(i).toElement().attribute("pmIssuer")); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber", node.childNodes().at(i).toElement().attribute("pmNumber")); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume", node.childNodes().at(i).toElement().attribute("pmVolume")); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode", node.childNodes().at(i).toElement().attribute("modelIdentCode")); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.language", "languageIsoCode", ru_const.languageIsoCode); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.language", "countryIsoCode", ru_const.countryIsoCode); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.issueInfo", "inWork", ru_const.inWork); setNodeAttr("identAndStatusSection.pmAddress.pmIdent.issueInfo", "issueNumber", ru_const.issueNumber); item->isQualifyed = (node.childNodes().at(i).toElement().attribute("isQualifyed") == "1"); } } ParsePackageContent(node.childNodes().at(i), j); } } void S1000D_Manager::LoadPackagesXML() { QDomDocument packDOM; QString xmlFileName = rootLyXfile; xmlFileName.replace(".lyx", ".xml"); QFile packFile(xmlFileName); //QFileInfo(rootLyXfile).path()+"/packages.xml" if (!packFile.open(QFile::ReadOnly | QFile::Text)) { //if(DBG) qDebug() << "LoadPackagesXML: Не удалось открыть файл "+xmlFileName; return; } packDOM.setContent(packFile.readAll()); packFile.close(); //QString lyxFileName = packDOM.namedItem("packages").namedItem("lyx").toElement().attribute("filename"); //if(lyxFileName != QFileInfo(rootLyXfile).fileName()) { // qDebug() << "LoadPackagesXML: Ошибка импорта - имена исходных файлов LyX отличаются."; // return; //} QDomNode packList = packDOM.namedItem("packages").namedItem("packlist"); QDomNode contents = packDOM.namedItem("packages").namedItem("contents"); timeConvert = packList.toElement().attribute("tConvert").toInt(); timeSCORM = packList.toElement().attribute("tSCORM").toInt(); timeS1000D = packList.toElement().attribute("tS1000D").toInt(); packages.clear(); for(int i=0;imoduleType == mtDM) { node = parent.ownerDocument().createElement("DM"); title = getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName"); node.toElement().setAttribute("name", title); infoCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode"); node.toElement().setAttribute("infoCode", infoCode); learnCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode"); node.toElement().setAttribute("learnCode", learnCode); disassyCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode"); node.toElement().setAttribute("disassyCode", disassyCode); systemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode"); node.toElement().setAttribute("systemCode", systemCode); subSubSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode"); node.toElement().setAttribute("subSubSystemCode", subSubSystemCode); subSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode"); node.toElement().setAttribute("subSystemCode", subSystemCode); learnEventCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode"); node.toElement().setAttribute("learnEventCode", learnEventCode); itemLocationCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode"); node.toElement().setAttribute("itemLocationCode", itemLocationCode); systemDiffCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode"); node.toElement().setAttribute("systemDiffCode", systemDiffCode); modelIdentCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode"); node.toElement().setAttribute("modelIdentCode", modelIdentCode); infoCodeVariant = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant"); node.toElement().setAttribute("infoCodeVariant", infoCodeVariant); assyCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode"); node.toElement().setAttribute("assyCode", assyCode); disassyCodeVariant = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant"); node.toElement().setAttribute("disassyCodeVariant", disassyCodeVariant); node.toElement().setAttribute("isQualifyed", (int)item->isQualifyed); node.toElement().setAttribute("origTitle", item->origTitle); //infoCode="043" learnCode="T40" disassyCode="00" systemCode="05" subSubSystemCode="2" subSystemCode="6" //learnEventCode="C" itemLocationCode="A" systemDiffCode="A" modelIdentCode="MI38" infoCodeVariant="A" assyCode="00" disassyCodeVariant="A" } else { node = parent.ownerDocument().createElement("PM"); title = getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle"); node.toElement().setAttribute("name", title); pmIssuer = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer"); node.toElement().setAttribute("pmIssuer", pmIssuer); pmNumber = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber"); node.toElement().setAttribute("pmNumber", pmNumber); pmVolume = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume"); node.toElement().setAttribute("pmVolume", pmVolume); modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode"); node.toElement().setAttribute("modelIdentCode", modelIdentCode); node.toElement().setAttribute("isQualifyed", (int)item->isQualifyed); node.toElement().setAttribute("origTitle", item->origTitle); //pmIssuer="RHC01" pmNumber="FTC01" pmVolume="00" modelIdentCode="MI38" } parent.appendChild(node); QString liststr = item->inPackages.join(","); node.toElement().setAttribute("packs", liststr); for(int i=0;i 0) fontsize = 16; int padtop = 15; if(lvl > 0) padtop = 5; addHTML(8+lvl*2, "
▸ "+title+"
"); for(int i=0;i
● "+title+"
"); } //
▸ 1 Общие сведения о вертолете
//
▸ 2 Фюзеляж вертолета
//
● Компоненты фюзеляжа
} void S1000D_Manager::addHTML(int lvl, QString s) { QString spc = ""; for(int j=0;jSetTitle("Копирование служебных файлов..."); QApplication::processEvents(); } copyDir(QCoreApplication::applicationDirPath()+"/Scorm", SCORMpath); if(!isConsole) splash->SetTitle("Формирование SCORM-пакета..."); QApplication::processEvents(); // enum OperatingSytem {OS_WINDOWS, OS_UNIX, OS_LINUX, OS_MAC} os; // #if (defined (Q_OS_WIN) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64)) // os = OS_WINDOWS; // #elif (defined (Q_OS_UNIX)) // os = OS_UNIX; // #elif (defined (Q_OS_LINUX)) // os = OS_LINUX; // #elif (defined (Q_OS_MAC)) // os = OS_MAC; // #endif // QStringList params; // if(os == OS_WINDOWS) { // QString winpath1 = SCORMpath; winpath1.replace("/","\\"); // params << "/C"<<"xcopy"<<"/E" << "/C" << "/Y"<< QCoreApplication::applicationDirPath().replace("/","\\")+"\\Scorm\\*.*" << winpath1+"\\" << ">nul"; // QProcess::startDetached("cmd.exe", params); // } else { // params << "-R"<< QCoreApplication::applicationDirPath()+"/Scorm/*" << SCORMpath+"/" << "> /dev/null"; // QProcess::startDetached("cp", params); // } resetICN(); for(int i=0;ischemeType == stLEARNING) { item->SCORM_fileName = "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml"; if(QFile::exists(SCORMpath+"/" + item->SCORM_fileName)) QFile::remove(SCORMpath+"/" + item->SCORM_fileName); if(!QFile::copy(projectPath+"/"+item->fileName, SCORMpath+"/" + item->SCORM_fileName)) if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+item->fileName << "to" << SCORMpath+"/" + item->SCORM_fileName; continue; } item->SCORM_fileName = "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".html"; } for(int i=0;iSetTitle("Формирование SCORM-пакета..."); splash->Step(); QApplication::processEvents(); } setCurItem(i); if (!QFile::exists(projectPath + "/" + item->fileName)) { if(!isConsole) { splash->hide(); splash->ErrMessage("Ошибка","Файл "+projectPath + "/" + item->fileName+" не найден."); QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); } return false; } QString htmlFileName = projectPath + "/" + item->fileName; htmlFileName.replace(".xml", ".html"); if (item->moduleType == mtDM && !QFile::exists(htmlFileName) && item->schemeType != stLEARNING) { if(!isConsole) { splash->hide(); splash->ErrMessage("Ошибка","Файл "+htmlFileName+" не найден."); QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); } return false; } QFile htmlFile(htmlFileName); if (!htmlFile.open(QFile::ReadOnly | QFile::Text)){ qDebug() << "scorm: file.open error "+htmlFileName; return false; } QStringList htmlText = QString(htmlFile.readAll()).split("\n"); htmlFile.close(); for(int j=0;jStep(); QString s = "class=\"S1000Dmultimediaobj\""; int k = htmlText[j].indexOf(s); if(k > -1) { s = "val=\""; int m = htmlText[j].indexOf(s); QString fn = htmlText[j].mid(m+s.length(), htmlText[j].indexOf("\"",m+s.length())-m-s.length()); QString icn = genICN(); QString icnfn = icn+"."+fn.split(".").last(); htmlText[j].replace(fn, icnfn); //if(QFile::exists(SCORMpath+"/"+icnfn)) QFile::remove(SCORMpath+"/"+icnfn); if(!QFile::exists(SCORMpath+"/"+icnfn)) if(!QFile::copy(projectPath+"/"+fn, SCORMpath+"/"+icnfn)) if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+fn << "to" << SCORMpath+"/"+icnfn; } s = " -1) { s = "src=\""; int m = htmlText[j].indexOf(s); QString fn = htmlText[j].mid(m+s.length(), htmlText[j].indexOf("\"",m+s.length())-m-s.length()); if(!fn.startsWith("app/")) { QString icn = genICN(); QString icnfn = icn+"."+fn.split(".").last(); htmlText[j].replace(fn, icnfn); //if(QFile::exists(SCORMpath+"/"+icnfn)) QFile::remove(SCORMpath+"/"+icnfn); if(!QFile::exists(SCORMpath+"/"+icnfn)) if(!QFile::copy(projectPath+"/"+fn, SCORMpath+"/"+icnfn)) if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+fn << "to" << SCORMpath+"/"+icnfn; } } s = "onmousemove=\"showTooltipImg(evt, '"; k = htmlText[j].indexOf(s); if(k > -1) { QString fn = htmlText[j].mid(k+s.length(), htmlText[j].indexOf("'",k+s.length())-k-s.length()); QString icn = genICN(); QString icnfn = icn+"."+fn.split(".").last(); htmlText[j].replace(fn, icnfn); //if(QFile::exists(SCORMpath+"/"+icnfn)) QFile::remove(SCORMpath+"/"+icnfn); if(!QFile::exists(SCORMpath+"/"+icnfn)) if(!QFile::copy(projectPath+"/"+fn, SCORMpath+"/"+icnfn)) if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+fn << "to" << SCORMpath+"/"+icnfn; } s = " -1) { QString fn = htmlText[j].mid(k+s.length(), htmlText[j].indexOf("\"",k+s.length())-k-s.length()); if(!fn.startsWith("#")) { if(fn.contains(".html#")) { // межмодульная ссылка fn = fn.left(fn.indexOf("#")); QString name; for(int n=0;nSCORM - hide(); splash->ErrMessage("Ошибка", "href: Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+SCORMpath+"/"+fn.split("/")[0]+"'"); QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); } return false; } } } //# } // -1) { //s = "src=\""; //int m = htmlText[j].indexOf(s); //QString fn = htmlText[j].mid(m+s.length(), htmlText[j].indexOf("\"",m+s.length())-m-s.length()); //scRegister('01060301-003.xml', 'title', 'd1', 'models/sc1.html'); QList htmlSplit = htmlText[j].split("'"); QString fn = htmlSplit[ htmlSplit.count()-2]; QDir dir(projectPath+"/"+fn.split("/")[0]); QDir dir2(SCORMpath+"/"+fn.split("/")[0]); if(!dir.exists()) { if(!isConsole) { splash->hide(); splash->ErrMessage("Ошибка","ИМВС: Папка "+projectPath+"/"+fn.split("/")[0]+" не найдена."); QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); } return false; } //qDebug() << "copy 3D: '"+projectPath+"/"+fn.split("/")[0]+"' to '"+S1000Dpath+"/"+fn.split("/")[0]+"'"; if(!dir2.exists()) if(!copyDir(projectPath+"/"+fn.split("/")[0], SCORMpath+"/"+fn.split("/")[0])) { if(!isConsole) { splash->hide(); splash->ErrMessage("Ошибка", "ИМВС: Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+SCORMpath+"/"+fn.split("/")[0]+"'"); QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); } return false; } } //