2025-06-17 11:48:13 +08:00
|
|
|
#ifndef INFO_MSG_H
|
2025-06-15 14:31:54 +08:00
|
|
|
#define INFO_MSG_H
|
|
|
|
|
|
|
|
|
|
#include <QBuffer>
|
|
|
|
|
#include <QDataStream>
|
|
|
|
|
#include <QIODevice>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QVector>
|
2025-11-05 23:09:37 +08:00
|
|
|
#include <QMap>
|
|
|
|
|
|
|
|
|
|
struct PropertyData {
|
|
|
|
|
QString key;
|
|
|
|
|
QString mark;
|
|
|
|
|
QString properA;
|
|
|
|
|
QString properB;
|
|
|
|
|
QString properC;
|
2025-11-06 23:12:13 +08:00
|
|
|
qint32 properD;
|
|
|
|
|
qint32 properE;
|
2025-11-05 23:09:37 +08:00
|
|
|
};
|
2025-06-15 14:31:54 +08:00
|
|
|
|
|
|
|
|
struct InfoMsg {
|
|
|
|
|
qint32 mark{};
|
2025-11-05 10:57:40 +08:00
|
|
|
QString command;
|
2025-06-15 14:31:54 +08:00
|
|
|
QString msg;
|
2025-06-17 16:42:39 +08:00
|
|
|
QString fromPath;
|
|
|
|
|
QString toPath;
|
|
|
|
|
quint64 size{};
|
|
|
|
|
quint32 permissions{};
|
2025-11-05 10:57:40 +08:00
|
|
|
QVector<QString> list;
|
2025-11-05 23:09:37 +08:00
|
|
|
QMap<QString, PropertyData> mapData;
|
2025-06-15 14:31:54 +08:00
|
|
|
|
|
|
|
|
void serialize(QDataStream& data) const
|
|
|
|
|
{
|
2025-11-05 10:57:40 +08:00
|
|
|
data << mark << command << msg << fromPath << toPath << size << permissions;
|
|
|
|
|
data << list.size();
|
|
|
|
|
for (const auto& item : list) {
|
|
|
|
|
data << item;
|
|
|
|
|
}
|
2025-11-05 23:09:37 +08:00
|
|
|
data << mapData.size();
|
|
|
|
|
for (const auto& item : mapData) {
|
|
|
|
|
data << item.key << item.mark << item.properA << item.properB << item.properC << item.properD << item.properE;
|
|
|
|
|
}
|
2025-06-15 14:31:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void deserialize(QDataStream& data)
|
|
|
|
|
{
|
2025-11-05 10:57:40 +08:00
|
|
|
data >> mark >> command >> msg >> fromPath >> toPath >> size >> permissions;
|
|
|
|
|
qint32 listSize;
|
|
|
|
|
data >> listSize;
|
|
|
|
|
list.resize(listSize);
|
|
|
|
|
for (auto& item : list) {
|
|
|
|
|
data >> item;
|
|
|
|
|
}
|
2025-11-05 23:09:37 +08:00
|
|
|
qint32 mapSize;
|
|
|
|
|
data >> mapSize;
|
|
|
|
|
data >> mapSize;
|
|
|
|
|
for (int i = 0; i < mapSize; ++i) {
|
|
|
|
|
PropertyData prop;
|
|
|
|
|
data >> prop.key >> prop.mark >> prop.properA >> prop.properB >> prop.properC >> prop.properD >> prop.properE;
|
|
|
|
|
mapData.insert(prop.key, prop);
|
|
|
|
|
}
|
2025-06-15 14:31:54 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
QDataStream& operator<<(QDataStream& data, const InfoMsg& info);
|
|
|
|
|
QDataStream& operator>>(QDataStream& data, InfoMsg& info);
|
|
|
|
|
|
2025-06-17 16:42:39 +08:00
|
|
|
#endif // INFO_MSG_H
|