#ifndef PARSEBACKUPLIST_H #define PARSEBACKUPLIST_H #include #include #include #include "../common/mydefine.h" class ParseBackupList { public: enum ParseResult { // xml解析错误 XML_PARSE_ERR, // 失败 FAIL, // 成功 SUCCESS, }; struct BackupPoint { // 备份或还原指定的UUID QString m_uuid; // 备份名称,用来替换m_comment QString m_backupName; // 备份时间 QString m_time; // 本地备份还是U盘备份: 0-本地备份;1-移动设备备份 int m_iPosition = -1; // 操作类型,如:系统备份, 系统还原 int m_type = -1; // 备份大小 QString m_size; // 备份状态,如是否完成 QString m_state; bool isNull() { return m_uuid.isEmpty(); } }; ParseBackupList(const QString& xmlPath); /** * @brief 出厂备份修改backuplist.xml,仅保留出厂备份信息 * @param factoryBackupUuid,出厂备份的uuid * @return ParseResult枚举类型 * @author zhaominyong * @since 2021/06/27 */ ParseResult updateForFactoryRestore(const QString &factoryBackupUuid); /** * @brief 根据comment查找uuid * @param comment * @return uuid */ QString findUuidByComment(const QString& comment); /** * @brief 根据Uuid查找备份点信息 * @param Uuid * @return 备份点信息 */ BackupPoint findBackupPointByUuid(const QString& Uuid); /** * @brief 获取最后一次系统备份 * @return */ BackupPoint getLastSysBackupPoint(); inline QString getXmlPath() { return m_xmlPath; } private: bool InitXml(); bool isXmlCorrect(); bool Doc_setContent(QDomDocument& doc); void elementNodeToBackupPoint(const QDomElement& eleNode, BackupPoint& backupPoint); void backupPointToElementNode(const BackupPoint& backupPoint, QDomElement& eleNode); QDomElement createTextElement(const QString& tagName, const QString& text); private: QString m_xmlPath; }; #endif // PARSEBACKUPLIST_H