diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 444d05b2a..512c4b2f8 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -1,6 +1,9 @@ #include "datafilespage.hpp" -#include +#include +#include +#include +#include #include @@ -97,7 +100,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam connect(mastersTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); - + connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter())); diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 3caae2c36..8d09cf3c0 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -1,6 +1,8 @@ #include "graphicspage.hpp" -#include +#include +#include +#include #include diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 5d11421d0..e435bd391 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -1,6 +1,15 @@ #include "maindialog.hpp" -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include "utils/checkablemessagebox.hpp" @@ -203,10 +212,15 @@ bool MainDialog::showFirstRunDialog() // Construct the arguments to run the importer QStringList arguments; + if (msgBox.isChecked()) - arguments.append(QString("-g")); + arguments.append(QString("--game-files")); + arguments.append(QString("--encoding")); + arguments.append(mGameSettings.value(QString("encoding"), QString("win1252"))); + arguments.append(QString("--ini")); arguments.append(iniPaths.first()); + arguments.append(QString("--cfg")); arguments.append(path); if (!startProgram(QString("mwiniimport"), arguments, false)) @@ -659,7 +673,7 @@ bool MainDialog::startProgram(const QString &name, const QStringList &arguments, return false; } - if (process.exitCode() != 0) { + if (process.exitCode() != 0 || process.exitStatus() == QProcess::CrashExit) { QString error(process.readAllStandardError()); error.append(tr("\nArguments:\n")); error.append(arguments.join(" ")); diff --git a/apps/launcher/playpage.cpp b/apps/launcher/playpage.cpp index d6d25d71d..46900c595 100644 --- a/apps/launcher/playpage.cpp +++ b/apps/launcher/playpage.cpp @@ -1,6 +1,10 @@ #include "playpage.hpp" -#include +#include + +#ifdef Q_OS_MAC +#include +#endif PlayPage::PlayPage(QWidget *parent) : QWidget(parent) { diff --git a/components/fileorderlist/model/datafilesmodel.cpp b/components/fileorderlist/model/datafilesmodel.cpp index b33e2e12a..316534124 100644 --- a/components/fileorderlist/model/datafilesmodel.cpp +++ b/components/fileorderlist/model/datafilesmodel.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include @@ -157,7 +159,7 @@ Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const if (!file) return Qt::NoItemFlags; - if (canBeChecked(file)) { + if (canBeChecked(file)) { if (index.column() == 0) { return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; } else { @@ -226,7 +228,7 @@ bool lessThanEsmFile(const EsmFile *e1, const EsmFile *e2) return true; if (!e1->fileName().endsWith(".esm") && e2->fileName().endsWith(".esm")) return false; - + return e1->fileName().toLower() < e2->fileName().toLower(); } @@ -237,10 +239,6 @@ bool lessThanDate(const EsmFile *e1, const EsmFile *e2) } else { return false; } -// if (!e1->fileName().endsWith(".esm") && e2->fileName().endsWith(".esm")) -// return false; - -// return e1->fileName().toLower() < e2->fileName().toLower(); } void DataFilesModel::sort(int column, Qt::SortOrder order) @@ -270,17 +268,32 @@ void DataFilesModel::addFiles(const QString &path) filters << "*.esp" << "*.esm"; dir.setNameFilters(filters); + // Create a decoder for non-latin characters in esx metadata + QTextCodec *codec; + + if (mEncoding == QLatin1String("win1252")) { + codec = QTextCodec::codecForName("windows-1252"); + } else if (mEncoding == QLatin1String("win1251")) { + codec = QTextCodec::codecForName("windows-1251"); + } else if (mEncoding == QLatin1String("win1250")) { + codec = QTextCodec::codecForName("windows-1250"); + } else { + return; // This should never happen; + } + + QTextDecoder *decoder = codec->makeDecoder(); + foreach (const QString &path, dir.entryList()) { QFileInfo info(dir.absoluteFilePath(path)); EsmFile *file = new EsmFile(path); - try { ESM::ESMReader fileReader; - ToUTF8::Utf8Encoder encoder (ToUTF8::calculateEncoding(mEncoding.toStdString())); + ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(mEncoding.toStdString())); fileReader.setEncoder(&encoder); fileReader.open(dir.absoluteFilePath(path).toStdString()); + ESM::ESMReader::MasterList mlist = fileReader.getMasters(); QStringList masters; @@ -289,13 +302,13 @@ void DataFilesModel::addFiles(const QString &path) masters.append(master); } - file->setAuthor(QString::fromStdString(fileReader.getAuthor())); + file->setAuthor(decoder->toUnicode(fileReader.getAuthor().c_str())); file->setSize(info.size()); file->setDates(info.lastModified(), info.lastRead()); file->setVersion(fileReader.getFVer()); file->setPath(info.absoluteFilePath()); file->setMasters(masters); - file->setDescription(QString::fromStdString(fileReader.getDesc())); + file->setDescription(decoder->toUnicode(fileReader.getDesc().c_str())); // Put the file in the table @@ -308,6 +321,8 @@ void DataFilesModel::addFiles(const QString &path) } } + + delete decoder; } QModelIndex DataFilesModel::indexFromItem(EsmFile *item) const @@ -369,10 +384,10 @@ QStringList DataFilesModel::checkedItems() QStringList DataFilesModel::checkedItemsPaths() { QStringList list; - + QList::ConstIterator it; QList::ConstIterator itEnd = mFiles.constEnd(); - + int i = 0; for (it = mFiles.constBegin(); it != itEnd; ++it) { EsmFile *file = item(i); @@ -381,7 +396,7 @@ QStringList DataFilesModel::checkedItemsPaths() if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file)) list << file->path(); } - + return list; }