File: esmfile.cpp

package info (click to toggle)
openmw 0.50.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,076 kB
  • sloc: cpp: 380,958; xml: 2,192; sh: 1,449; python: 911; makefile: 26; javascript: 5
file content (150 lines) | stat: -rw-r--r-- 3,463 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#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;
    }
}