mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
cfiController ID -> GUID
This commit is contained in:
@@ -24,7 +24,7 @@ void CfiController::unLockAccessToCfiXML()
|
||||
}
|
||||
|
||||
|
||||
bool CfiController::parsingCfiXML(QMap<int, CfiObject>& mapCfiObjects)
|
||||
bool CfiController::parsingCfiXML(QMap<QString, CfiObject>& mapCfiObjects)
|
||||
{
|
||||
QMutexLocker locker(&mtxAccess);
|
||||
|
||||
@@ -62,8 +62,8 @@ bool CfiController::updateCfiXML(const QByteArray &array)
|
||||
if(! Tools::loadByteArrayXMLtoDOM(array, &docCfiListDOM_New))
|
||||
return false;
|
||||
|
||||
QMap<int, CfiObject> mapCfiObjects_Orig;
|
||||
QMap<int, CfiObject> mapCfiObjects_New;
|
||||
QMap<QString, CfiObject> mapCfiObjects_Orig;
|
||||
QMap<QString, CfiObject> mapCfiObjects_New;
|
||||
|
||||
if(!parsingCfiXML_DOM(docCfiListDOM_Orig, mapCfiObjects_Orig))
|
||||
return false;
|
||||
@@ -111,7 +111,7 @@ double CfiController::roundDoubleVal(double value, int cntNumAfterPoint)
|
||||
return round(value * pow(10, cntNumAfterPoint)) / pow(10, cntNumAfterPoint);
|
||||
}
|
||||
|
||||
bool CfiController::parsingCfiXML_DOM(QDomDocument &domDoc, QMap<int, CfiObject>& mapCfiObjects)
|
||||
bool CfiController::parsingCfiXML_DOM(QDomDocument &domDoc, QMap<QString, CfiObject>& mapCfiObjects)
|
||||
{
|
||||
QDomElement CFIObjectsElement = domDoc.firstChildElement("CFIObjects");
|
||||
if(CFIObjectsElement.isNull())
|
||||
@@ -138,7 +138,7 @@ bool CfiController::parsingCfiXML_DOM(QDomDocument &domDoc, QMap<int, CfiObject>
|
||||
|
||||
//атрибуты CFIObject
|
||||
QDomNamedNodeMap nodeMapOneCFIObject = oneCFIObjectElement.attributes();
|
||||
cfiObj.setId(nodeMapOneCFIObject.namedItem("id").nodeValue().toInt());
|
||||
cfiObj.setGuid(nodeMapOneCFIObject.namedItem("guid").nodeValue());
|
||||
cfiObj.setIsChanged(nodeMapOneCFIObject.namedItem("isChanged").nodeValue() == "True" ? true : false);
|
||||
|
||||
//childs CFIObject
|
||||
@@ -201,54 +201,54 @@ bool CfiController::parsingCfiXML_DOM(QDomDocument &domDoc, QMap<int, CfiObject>
|
||||
|
||||
cfiObj.setSetCameraPos(setCamPos);
|
||||
|
||||
mapCfiObjects.insert(cfiObj.getId(), cfiObj);
|
||||
mapCfiObjects.insert(cfiObj.getGuid(), cfiObj);
|
||||
}
|
||||
}while (! (oneCFIObjectElement = oneCFIObjectElement.nextSiblingElement()).isNull());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CfiController::merge2map(QMap<int, CfiObject> &mapCfiObjects_orig, QMap<int, CfiObject> &mapCfiObjects_new)
|
||||
bool CfiController::merge2map(QMap<QString, CfiObject> &mapCfiObjects_orig, QMap<QString, CfiObject> &mapCfiObjects_new)
|
||||
{
|
||||
//Проверка на удаление
|
||||
for(CfiObject cfiObj : mapCfiObjects_orig)
|
||||
{
|
||||
int id = cfiObj.getId();
|
||||
QString guid = cfiObj.getGuid();
|
||||
|
||||
if(!mapCfiObjects_new.contains(id))
|
||||
if(!mapCfiObjects_new.contains(guid))
|
||||
{//Удаляем
|
||||
mapCfiObjects_orig.take(id);
|
||||
mapCfiObjects_orig.take(guid);
|
||||
}
|
||||
}
|
||||
|
||||
//Замена, Добавление
|
||||
for(CfiObject cfiObj : mapCfiObjects_new)
|
||||
{
|
||||
int id = cfiObj.getId();
|
||||
QString guid = cfiObj.getGuid();
|
||||
|
||||
if(mapCfiObjects_orig.contains(id))
|
||||
if(mapCfiObjects_orig.contains(guid))
|
||||
{//Такой есть
|
||||
if(cfiObj.getIsChanged())
|
||||
{//Заменяем
|
||||
mapCfiObjects_orig.take(id);
|
||||
mapCfiObjects_orig.take(guid);
|
||||
|
||||
cfiObj.setIsChanged(false);
|
||||
cfiObj.resetIsChangedInDomElement();
|
||||
mapCfiObjects_orig.insert(id, cfiObj);
|
||||
mapCfiObjects_orig.insert(guid, cfiObj);
|
||||
}
|
||||
}
|
||||
else
|
||||
{//Добавляем
|
||||
cfiObj.setIsChanged(false);
|
||||
cfiObj.resetIsChangedInDomElement();
|
||||
mapCfiObjects_orig.insert(id, cfiObj);
|
||||
mapCfiObjects_orig.insert(guid, cfiObj);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CfiController::saveNewCfiListFile(QMap<int, CfiObject> &mapCfiObjects)
|
||||
bool CfiController::saveNewCfiListFile(QMap<QString, CfiObject> &mapCfiObjects)
|
||||
{
|
||||
QDomDocument commonDOM;
|
||||
if(! Tools::loadFileXMLtoDOM(":/resources/blankXML/ListCFI.xml", &commonDOM))
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void unLockAccessToCfiXML();
|
||||
|
||||
//Распарсивание файла CfiList.xml
|
||||
bool parsingCfiXML(QMap<int, CfiObject>& mapCfiObjects);
|
||||
bool parsingCfiXML(QMap<QString, CfiObject>& mapCfiObjects);
|
||||
|
||||
//Слияние (обновление) с новыми данными
|
||||
bool updateCfiXML(const QByteArray& array);
|
||||
@@ -34,19 +34,17 @@ private:
|
||||
|
||||
double roundDoubleVal(double value, int cntNumAfterPoint);
|
||||
|
||||
bool parsingCfiXML_DOM(QDomDocument& domDoc, QMap<int, CfiObject>& mapCfiObjects);
|
||||
bool parsingCfiXML_DOM(QDomDocument& domDoc, QMap<QString, CfiObject>& mapCfiObjects);
|
||||
|
||||
bool merge2map(QMap<int, CfiObject>& mapCfiObjects_orig, QMap<int, CfiObject>& mapCfiObjects_new);
|
||||
bool merge2map(QMap<QString, CfiObject>& mapCfiObjects_orig, QMap<QString, CfiObject>& mapCfiObjects_new);
|
||||
|
||||
bool saveNewCfiListFile(QMap<int, CfiObject>& mapCfiObjects);
|
||||
bool saveNewCfiListFile(QMap<QString, CfiObject>& mapCfiObjects);
|
||||
|
||||
private:
|
||||
UpdateController* updateController;
|
||||
|
||||
QMutex mtxAccess;
|
||||
|
||||
//QList<CfiObject> listCfiObjects;
|
||||
|
||||
QLocale* germanLocale;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@ CfiObject::CfiObject()
|
||||
|
||||
}
|
||||
|
||||
int CfiObject::getId() const
|
||||
QString CfiObject::getGuid() const
|
||||
{
|
||||
return id;
|
||||
return guid;
|
||||
}
|
||||
|
||||
void CfiObject::setId(int value)
|
||||
void CfiObject::setGuid(QString value)
|
||||
{
|
||||
id = value;
|
||||
guid = value;
|
||||
}
|
||||
|
||||
QString CfiObject::getCfiName() const
|
||||
|
||||
@@ -42,8 +42,8 @@ class CfiObject
|
||||
public:
|
||||
CfiObject();
|
||||
|
||||
int getId() const;
|
||||
void setId(int value);
|
||||
QString getGuid() const;
|
||||
void setGuid(QString value);
|
||||
|
||||
QString getCfiName() const;
|
||||
void setCfiName(const QString &value);
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
void resetIsChangedInDomElement();
|
||||
|
||||
private:
|
||||
int id;
|
||||
QString guid;
|
||||
bool isChanged;
|
||||
QString cfiName;
|
||||
QString cfi;
|
||||
|
||||
Reference in New Issue
Block a user