最新备份点放到最后面

This commit is contained in:
zhaominyong 2022-03-21 15:16:04 +08:00
parent a99dda1eab
commit 9a81d1dfea
1 changed files with 10 additions and 4 deletions

View File

@ -457,7 +457,8 @@ ParseBackupList::ParseResult ParseBackupList::updateItem(const BackupPoint & bac
QDomElement root = doc.documentElement();
QDomNodeList list = root.childNodes();
for (int i = 0; i < list.count(); i++) {
int i = 0;
for (; i < list.count(); i++) {
QDomNode node = list.at(i);
if (!node.isElement())
continue;
@ -466,11 +467,16 @@ ParseBackupList::ParseResult ParseBackupList::updateItem(const BackupPoint & bac
if (eleUuid.isNull() || backupPoint.m_uuid != eleUuid.text())
continue;
break ;
}
// 找到了旧节点
if (i < list.count()) {
// 移除旧节点,更新后的节点放到最后
root.removeChild(list.at(i));
QDomElement newNode = doc.createElement(BACKUPPOINT);
backupPointToElementNode(backupPoint, doc, newNode);
root.replaceChild(newNode, node);
break ;
root.appendChild(newNode);
}
QFile xmlFile(m_xmlPath);