This commit is contained in:
flower_linux
2026-03-18 16:31:32 +08:00
parent 9a2224f185
commit 91a3361d1f
26 changed files with 478 additions and 119 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <QJsonObject>
#include <QJsonArray>
#include <QVector>
#include <QString>
#include <QHash>
@@ -27,9 +28,17 @@ public:
bool loadFromDaemonConfig(const QJsonObject& root, QString* errorMessage = nullptr);
const QVector<DeviceTreeNode>& nodes() const { return m_nodes; }
QVector<DeviceTreeNode>& nodesMutable() { return m_nodes; }
const DeviceTreeNode* findById(const QString& id) const;
// 序列化为 daemon_config.json 所需格式
QJsonArray toDeviceTreeJson() const;
QJsonObject toDaemonConfigRoot() const;
// 当外部直接修改 nodesMutable() 后,需要重建索引
void rebuildIndex();
private:
QVector<DeviceTreeNode> m_nodes;
QHash<QString, int> m_indexById;