2025-12-23 10:14:13 +01:00
|
|
|
#ifndef FILEHANDLER_H
|
|
|
|
|
#define FILEHANDLER_H
|
|
|
|
|
|
2026-01-04 13:38:54 +01:00
|
|
|
#include <QVariant>
|
|
|
|
|
|
2026-02-02 16:13:44 +01:00
|
|
|
typedef QMap<int, QVariant> ModelItemValues;
|
2026-01-04 17:48:27 +01:00
|
|
|
|
2025-12-23 10:14:13 +01:00
|
|
|
class QJsonDocument;
|
|
|
|
|
class QString;
|
2025-12-23 13:40:33 +01:00
|
|
|
class QByteArray;
|
2025-12-23 10:14:13 +01:00
|
|
|
|
|
|
|
|
class FileHandler {
|
|
|
|
|
public:
|
2026-01-04 13:38:54 +01:00
|
|
|
/// JSON
|
2025-12-23 10:14:13 +01:00
|
|
|
static bool saveToFile(const QJsonDocument& doc, const QString& fileName);
|
2025-12-23 13:40:33 +01:00
|
|
|
static QByteArray loadJSONDataFromFile(const QString fileName);
|
2025-12-23 10:14:13 +01:00
|
|
|
|
2026-01-04 13:38:54 +01:00
|
|
|
/// CSV
|
2026-01-04 17:48:27 +01:00
|
|
|
static QList<ModelItemValues> getItemValuesFromCSVFile(const QString& filePath);
|
2026-01-06 10:04:26 +01:00
|
|
|
static bool exportToCSVFile(const QList<QStringList>& rows, const QString& filePath);
|
2026-01-04 13:38:54 +01:00
|
|
|
|
2025-12-23 10:14:13 +01:00
|
|
|
private:
|
|
|
|
|
explicit FileHandler();
|
2026-01-04 13:38:54 +01:00
|
|
|
|
|
|
|
|
static QPair<QString, QByteArray> getFileContent(const QString& filePath);
|
2025-12-23 10:14:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // FILEHANDLER_H
|