2013-08-18 15:11:29 -05:00
|
|
|
#include "esmfile.hpp"
|
|
|
|
|
2023-07-29 11:44:39 +04:00
|
|
|
ContentSelectorModel::EsmFile::EsmFile(const QString& fileName, ModelItem* parent)
|
2013-09-21 23:06:29 -05:00
|
|
|
: ModelItem(parent)
|
|
|
|
, mFileName(fileName)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
|
|
|
}
|
2013-09-18 02:36:23 -05:00
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
void ContentSelectorModel::EsmFile::setFileName(const QString& fileName)
|
2013-08-18 15:11:29 -05:00
|
|
|
{
|
|
|
|
mFileName = fileName;
|
|
|
|
}
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
void ContentSelectorModel::EsmFile::setAuthor(const QString& author)
|
2013-08-18 15:11:29 -05:00
|
|
|
{
|
|
|
|
mAuthor = author;
|
|
|
|
}
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
void ContentSelectorModel::EsmFile::setDate(const QDateTime& modified)
|
2013-08-18 15:11:29 -05:00
|
|
|
{
|
|
|
|
mModified = modified;
|
|
|
|
}
|
|
|
|
|
2024-01-01 14:56:48 +04:00
|
|
|
void ContentSelectorModel::EsmFile::setFormat(const QString& format)
|
2013-08-18 15:11:29 -05:00
|
|
|
{
|
2023-02-10 13:16:52 +01:00
|
|
|
mVersion = format;
|
2013-08-18 15:11:29 -05:00
|
|
|
}
|
|
|
|
|
2013-11-01 21:47:26 -05:00
|
|
|
void ContentSelectorModel::EsmFile::setFilePath(const QString& path)
|
2013-08-18 15:11:29 -05:00
|
|
|
{
|
|
|
|
mPath = path;
|
|
|
|
}
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
void ContentSelectorModel::EsmFile::setGameFiles(const QStringList& gamefiles)
|
2013-08-18 15:11:29 -05:00
|
|
|
{
|
2013-09-21 23:06:29 -05:00
|
|
|
mGameFiles = gamefiles;
|
2013-08-18 15:11:29 -05:00
|
|
|
}
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
void ContentSelectorModel::EsmFile::setDescription(const QString& description)
|
2013-08-18 15:11:29 -05:00
|
|
|
{
|
|
|
|
mDescription = description;
|
|
|
|
}
|
2013-09-18 02:36:23 -05:00
|
|
|
|
2024-02-28 00:58:30 +00:00
|
|
|
void ContentSelectorModel::EsmFile::setBuiltIn(bool builtIn)
|
|
|
|
{
|
|
|
|
mBuiltIn = builtIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContentSelectorModel::EsmFile::setFromAnotherConfigFile(bool fromAnotherConfigFile)
|
|
|
|
{
|
|
|
|
mFromAnotherConfigFile = fromAnotherConfigFile;
|
|
|
|
}
|
|
|
|
|
2015-02-28 17:13:21 +13:00
|
|
|
bool ContentSelectorModel::EsmFile::isGameFile() const
|
|
|
|
{
|
|
|
|
return (mGameFiles.size() == 0)
|
2022-01-22 15:58:41 +01:00
|
|
|
&& (mFileName.endsWith(QLatin1String(".esm"), Qt::CaseInsensitive)
|
2015-02-28 20:25:03 +13:00
|
|
|
|| mFileName.endsWith(QLatin1String(".omwgame"), Qt::CaseInsensitive));
|
2015-02-28 17:13:21 +13:00
|
|
|
}
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
QVariant ContentSelectorModel::EsmFile::fileProperty(const FileProperty prop) const
|
2013-09-19 06:53:09 -05:00
|
|
|
{
|
|
|
|
switch (prop)
|
|
|
|
{
|
|
|
|
case FileProperty_FileName:
|
|
|
|
return mFileName;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FileProperty_Author:
|
|
|
|
return mAuthor;
|
|
|
|
break;
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
case FileProperty_Format:
|
2023-02-10 13:16:52 +01:00
|
|
|
return mVersion;
|
2013-09-19 06:53:09 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FileProperty_DateModified:
|
|
|
|
return mModified.toString(Qt::ISODate);
|
|
|
|
break;
|
|
|
|
|
2013-11-01 21:47:26 -05:00
|
|
|
case FileProperty_FilePath:
|
2013-09-19 06:53:09 -05:00
|
|
|
return mPath;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FileProperty_Description:
|
|
|
|
return mDescription;
|
|
|
|
break;
|
|
|
|
|
2024-02-28 00:58:30 +00:00
|
|
|
case FileProperty_BuiltIn:
|
|
|
|
return mBuiltIn;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FileProperty_FromAnotherConfigFile:
|
|
|
|
return mFromAnotherConfigFile;
|
|
|
|
break;
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
case FileProperty_GameFile:
|
|
|
|
return mGameFiles;
|
2013-09-19 06:53:09 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
2013-09-21 23:06:29 -05:00
|
|
|
void ContentSelectorModel::EsmFile::setFileProperty(const FileProperty prop, const QString& value)
|
2013-09-18 02:36:23 -05:00
|
|
|
{
|
|
|
|
switch (prop)
|
|
|
|
{
|
2013-09-19 06:53:09 -05:00
|
|
|
case FileProperty_FileName:
|
2013-09-18 02:36:23 -05:00
|
|
|
mFileName = value;
|
|
|
|
break;
|
|
|
|
|
2013-09-19 06:53:09 -05:00
|
|
|
case FileProperty_Author:
|
2013-09-18 02:36:23 -05:00
|
|
|
mAuthor = value;
|
|
|
|
break;
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
case FileProperty_Format:
|
2024-01-07 06:49:56 +03:00
|
|
|
mVersion = value;
|
2013-09-18 02:36:23 -05:00
|
|
|
break;
|
|
|
|
|
2013-09-19 06:53:09 -05:00
|
|
|
case FileProperty_DateModified:
|
2024-01-07 06:49:56 +03:00
|
|
|
mModified = QDateTime::fromString(value, Qt::ISODate);
|
2013-09-18 02:36:23 -05:00
|
|
|
break;
|
|
|
|
|
2013-11-01 21:47:26 -05:00
|
|
|
case FileProperty_FilePath:
|
2013-09-18 02:36:23 -05:00
|
|
|
mPath = value;
|
|
|
|
break;
|
|
|
|
|
2013-09-19 06:53:09 -05:00
|
|
|
case FileProperty_Description:
|
2013-09-18 02:36:23 -05:00
|
|
|
mDescription = value;
|
|
|
|
break;
|
|
|
|
|
2024-02-28 00:58:30 +00:00
|
|
|
// todo: check these work
|
|
|
|
case FileProperty_BuiltIn:
|
|
|
|
mBuiltIn = value == "true";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FileProperty_FromAnotherConfigFile:
|
|
|
|
mFromAnotherConfigFile = value == "true";
|
|
|
|
break;
|
|
|
|
|
2013-09-21 23:06:29 -05:00
|
|
|
case FileProperty_GameFile:
|
|
|
|
mGameFiles << value;
|
2013-09-18 02:36:23 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|