forked from teamnwah/openmw-tes3coop
Added support for different encodings
This commit is contained in:
parent
433773e0ea
commit
64c348c39e
3 changed files with 19 additions and 2 deletions
|
@ -418,6 +418,13 @@ bool DataFilesPage::setupDataFiles()
|
|||
return false;
|
||||
}
|
||||
|
||||
// Set the charset for reading the esm/esp files
|
||||
QString encoding = QString::fromStdString(variables["encoding"].as<std::string>());
|
||||
if (!encoding.isEmpty() && encoding != QLatin1String("win1252")) {
|
||||
mMastersModel->setEncoding(encoding);
|
||||
mPluginsModel->setEncoding(encoding);
|
||||
}
|
||||
|
||||
// Add the paths to the respective models
|
||||
for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) {
|
||||
QString path = QString::fromStdString(it->string());
|
||||
|
|
|
@ -13,12 +13,18 @@
|
|||
DataFilesModel::DataFilesModel(QObject *parent) :
|
||||
QAbstractTableModel(parent)
|
||||
{
|
||||
mEncoding = QString("win1252");
|
||||
}
|
||||
|
||||
DataFilesModel::~DataFilesModel()
|
||||
{
|
||||
}
|
||||
|
||||
void DataFilesModel::setEncoding(const QString &encoding)
|
||||
{
|
||||
mEncoding = encoding;
|
||||
}
|
||||
|
||||
void DataFilesModel::setCheckState(const QModelIndex &index, Qt::CheckState state)
|
||||
{
|
||||
setData(index, state, Qt::CheckStateRole);
|
||||
|
@ -268,7 +274,7 @@ void DataFilesModel::addMasters(const QString &path)
|
|||
|
||||
try {
|
||||
ESM::ESMReader fileReader;
|
||||
fileReader.setEncoding(std::string("win1252"));
|
||||
fileReader.setEncoding(mEncoding.toStdString());
|
||||
fileReader.open(dir.absoluteFilePath(path).toStdString());
|
||||
|
||||
ESM::ESMReader::MasterList mlist = fileReader.getMasters();
|
||||
|
@ -328,7 +334,7 @@ void DataFilesModel::addPlugins(const QString &path)
|
|||
|
||||
try {
|
||||
ESM::ESMReader fileReader;
|
||||
fileReader.setEncoding(std::string("win1252"));
|
||||
fileReader.setEncoding(mEncoding.toStdString());
|
||||
fileReader.open(dir.absoluteFilePath(path).toStdString());
|
||||
|
||||
ESM::ESMReader::MasterList mlist = fileReader.getMasters();
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
|
||||
{ return QAbstractTableModel::index(row, column, parent); }
|
||||
|
||||
void setEncoding(const QString &encoding);
|
||||
|
||||
void addFile(EsmFile *file);
|
||||
|
||||
void addMasters(const QString &path);
|
||||
|
@ -62,6 +64,8 @@ private:
|
|||
QHash<QString, QStringList> mDependencies;
|
||||
QHash<QString, Qt::CheckState> mCheckStates;
|
||||
|
||||
QString mEncoding;
|
||||
|
||||
};
|
||||
|
||||
#endif // DATAFILESMODEL_HPP
|
||||
|
|
Loading…
Reference in a new issue