mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 03:56:39 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			150 lines
		
	
	
	
		
			3.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
	
		
			3.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#include "esmfile.hpp"
 | 
						|
 | 
						|
ContentSelectorModel::EsmFile::EsmFile(const QString& fileName, ModelItem* parent)
 | 
						|
    : ModelItem(parent)
 | 
						|
{
 | 
						|
    setFileName(fileName);
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setFileName(const QString& fileName)
 | 
						|
{
 | 
						|
    mFileName = fileName;
 | 
						|
    mHasGameExtension = (mFileName.endsWith(QLatin1String(".esm"), Qt::CaseInsensitive)
 | 
						|
        || mFileName.endsWith(QLatin1String(".omwgame"), Qt::CaseInsensitive));
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setAuthor(const QString& author)
 | 
						|
{
 | 
						|
    mAuthor = author;
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setDate(const QDateTime& modified)
 | 
						|
{
 | 
						|
    mModified = modified;
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setFormat(const QString& format)
 | 
						|
{
 | 
						|
    mVersion = format;
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setFilePath(const QString& path)
 | 
						|
{
 | 
						|
    mPath = path;
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setGameFiles(const QStringList& gamefiles)
 | 
						|
{
 | 
						|
    mGameFiles = gamefiles;
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setDescription(const QString& description)
 | 
						|
{
 | 
						|
    mDescription = description;
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setBuiltIn(bool builtIn)
 | 
						|
{
 | 
						|
    mBuiltIn = builtIn;
 | 
						|
}
 | 
						|
 | 
						|
void ContentSelectorModel::EsmFile::setFromAnotherConfigFile(bool fromAnotherConfigFile)
 | 
						|
{
 | 
						|
    mFromAnotherConfigFile = fromAnotherConfigFile;
 | 
						|
}
 | 
						|
 | 
						|
bool ContentSelectorModel::EsmFile::isGameFile() const
 | 
						|
{
 | 
						|
    return mHasGameExtension && mGameFiles.empty();
 | 
						|
}
 | 
						|
 | 
						|
QVariant ContentSelectorModel::EsmFile::fileProperty(const FileProperty prop) const
 | 
						|
{
 | 
						|
    switch (prop)
 | 
						|
    {
 | 
						|
        case FileProperty_FileName:
 | 
						|
            return mFileName;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_Author:
 | 
						|
            return mAuthor;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_Format:
 | 
						|
            return mVersion;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_DateModified:
 | 
						|
            return mModified.toString(Qt::ISODate);
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_FilePath:
 | 
						|
            return mPath;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_Description:
 | 
						|
            return mDescription;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_BuiltIn:
 | 
						|
            return mBuiltIn;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_FromAnotherConfigFile:
 | 
						|
            return mFromAnotherConfigFile;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_GameFile:
 | 
						|
            return mGameFiles;
 | 
						|
            break;
 | 
						|
 | 
						|
        default:
 | 
						|
            break;
 | 
						|
    }
 | 
						|
    return QVariant();
 | 
						|
}
 | 
						|
void ContentSelectorModel::EsmFile::setFileProperty(const FileProperty prop, const QString& value)
 | 
						|
{
 | 
						|
    switch (prop)
 | 
						|
    {
 | 
						|
        case FileProperty_FileName:
 | 
						|
            setFileName(value);
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_Author:
 | 
						|
            mAuthor = value;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_Format:
 | 
						|
            mVersion = value;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_DateModified:
 | 
						|
            mModified = QDateTime::fromString(value, Qt::ISODate);
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_FilePath:
 | 
						|
            mPath = value;
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_Description:
 | 
						|
            mDescription = value;
 | 
						|
            break;
 | 
						|
 | 
						|
        // todo: check these work
 | 
						|
        case FileProperty_BuiltIn:
 | 
						|
            mBuiltIn = value == "true";
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_FromAnotherConfigFile:
 | 
						|
            mFromAnotherConfigFile = value == "true";
 | 
						|
            break;
 | 
						|
 | 
						|
        case FileProperty_GameFile:
 | 
						|
            mGameFiles << value;
 | 
						|
            break;
 | 
						|
 | 
						|
        default:
 | 
						|
            break;
 | 
						|
    }
 | 
						|
}
 |