1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 12:45:36 +00:00
openmw/components/contentselector/model/esmfile.hpp

90 lines
2.5 KiB
C++
Raw Permalink Normal View History

#ifndef ESMFILE_HPP
#define ESMFILE_HPP
#include <QDateTime>
#include <QStringList>
#include <components/esm3/formatversion.hpp>
#include "modelitem.hpp"
2013-09-18 07:36:23 +00:00
class QMimeData;
namespace ContentSelectorModel
{
class EsmFile : public ModelItem
{
Q_OBJECT
Q_PROPERTY(QString filename READ fileName)
public:
enum FileProperty
{
2022-09-22 18:26:05 +00:00
FileProperty_FileName = 0,
FileProperty_Author = 1,
FileProperty_Format = 2,
FileProperty_DateModified = 3,
FileProperty_FilePath = 4,
FileProperty_Description = 5,
FileProperty_GameFile = 6
};
2022-09-22 18:26:05 +00:00
EsmFile(QString fileName = QString(), ModelItem* parent = nullptr);
// EsmFile(const EsmFile &);
2022-09-22 18:26:05 +00:00
~EsmFile() {}
2022-09-22 18:26:05 +00:00
void setFileProperty(const FileProperty prop, const QString& value);
2013-09-18 07:36:23 +00:00
2022-09-22 18:26:05 +00:00
void setFileName(const QString& fileName);
void setAuthor(const QString& author);
void setSize(const int size);
2022-09-22 18:26:05 +00:00
void setDate(const QDateTime& modified);
void setFormat(const int format);
2022-09-22 18:26:05 +00:00
void setFilePath(const QString& path);
void setGameFiles(const QStringList& gameFiles);
void setDescription(const QString& description);
2023-03-20 22:03:39 +00:00
void addGameFile(const QString& name) { mGameFiles.append(name); }
2022-09-22 18:26:05 +00:00
QVariant fileProperty(const FileProperty prop) const;
2023-03-20 22:03:39 +00:00
QString fileName() const { return mFileName; }
QString author() const { return mAuthor; }
QDateTime modified() const { return mModified; }
ESM::FormatVersion formatVersion() const { return mVersion; }
2023-03-20 22:03:39 +00:00
QString filePath() const { return mPath; }
/// @note Contains file names, not paths.
2023-03-20 22:03:39 +00:00
const QStringList& gameFiles() const { return mGameFiles; }
QString description() const { return mDescription; }
QString toolTip() const
2022-09-22 18:26:05 +00:00
{
return sToolTip.arg(mAuthor)
.arg(mVersion)
2022-09-22 18:26:05 +00:00
.arg(mModified.toString(Qt::ISODate))
.arg(mPath)
.arg(mDescription)
.arg(mGameFiles.join(", "));
}
bool isGameFile() const;
2013-09-18 07:36:23 +00:00
QByteArray encodedData() const;
public:
static int sPropertyCount;
static QString sToolTip;
private:
QString mFileName;
QString mAuthor;
QDateTime mModified;
ESM::FormatVersion mVersion = ESM::DefaultFormatVersion;
QString mPath;
QStringList mGameFiles;
QString mDescription;
QString mToolTip;
};
}
#endif