MCPcopy Create free account
hub / github.com/Palm1r/QodeAssist / loadFromFile

Method loadFromFile

ChatView/ChatSerializer.cpp:41–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41SerializationResult ChatSerializer::loadFromFile(ChatModel *model, const QString &filePath)
42{
43 QFile file(filePath);
44 if (!file.open(QIODevice::ReadOnly)) {
45 return {false, QString("Failed to open file for reading: %1").arg(filePath)};
46 }
47
48 QJsonParseError error;
49 QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &error);
50 if (error.error != QJsonParseError::NoError) {
51 return {false, QString("JSON parse error: %1").arg(error.errorString())};
52 }
53
54 QJsonObject root = doc.object();
55 QString version = root["version"].toString();
56
57 if (!validateVersion(version)) {
58 return {false, QString("Unsupported version: %1").arg(version)};
59 }
60
61 if (!deserializeChat(model, root, filePath)) {
62 return {false, "Failed to deserialize chat data"};
63 }
64
65 return {true, QString()};
66}
67
68QJsonObject ChatSerializer::serializeMessage(
69 const ChatModel::Message &message, const QString &chatFilePath)

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected