/*! * * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file MLogFile.h * \author (last) Vy * \date (last) 18-Jul-2023 * \author (original) Vy * \date (original) 18-Jul-2023 * */ #pragma once // Qt #include #include #include // Project #include "StorageGlobals.h" #include "Logger.h" // forward declarations class tst_models; namespace Model { /*! * \brief The Log File class * Provides abstraction for a Log File * \details Holds information about the Log File such as filename and size * */ class MLogFile { public: struct Data { public: bool operator==(const Data &d1) { const QString otherFilePath(QString("%1/%2").arg(d1.filePath()).arg(d1.fileName())); QFileInfo otherFile(otherFilePath); if(_fileInfo.exists() && otherFile.exists()) return _fileInfo == otherFile; return false; } explicit Data() {} explicit Data(Storage::Logger::LogType vLogType, const QFileInfo &vFileInfo) : _fileInfo(vFileInfo), _logType(vLogType) { } explicit Data(const QString &vFilePath) : _fileInfo(QFileInfo(vFilePath)) { } QString filePath() const { return _fileInfo.path(); } QString fileName() const { return _fileInfo.fileName (); } qint64 fileSize_bytes() const { return _fileInfo.size (); } int logType () const { return _logType; } QDateTime lastModificationDateTime() const {return _fileInfo.fileTime(QFile::FileModificationTime);} private: QFileInfo _fileInfo; Storage::Logger::LogType _logType; }; }; } typedef Model::MLogFile::Data LogFileData;