1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 09:06:43 +00:00

fixed encoding problems

This commit is contained in:
Marc Zinnschlag 2014-03-21 11:56:48 +01:00
parent 10ce47938b
commit fc8ae2b9b5
9 changed files with 24 additions and 24 deletions

View file

@ -61,7 +61,7 @@ void CS::Editor::setupDataFiles (const Files::PathContainer& dataDirs)
{ {
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter) for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
{ {
QString path = QString::fromStdString(iter->string()); QString path = QString::fromUtf8 (iter->string().c_str());
mFileDialog.addFiles(path); mFileDialog.addFiles(path);
} }
} }
@ -148,7 +148,7 @@ void CS::Editor::openFiles (const boost::filesystem::path &savePath)
std::vector<boost::filesystem::path> files; std::vector<boost::filesystem::path> files;
foreach (const QString &path, mFileDialog.selectedFilePaths()) foreach (const QString &path, mFileDialog.selectedFilePaths())
files.push_back(path.toStdString()); files.push_back(path.toUtf8().constData());
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, false); CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, false);
@ -161,10 +161,10 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
std::vector<boost::filesystem::path> files; std::vector<boost::filesystem::path> files;
foreach (const QString &path, mFileDialog.selectedFilePaths()) { foreach (const QString &path, mFileDialog.selectedFilePaths()) {
files.push_back(path.toStdString()); files.push_back(path.toUtf8().constData());
} }
files.push_back(mFileDialog.filename().toStdString()); files.push_back(mFileDialog.filename().toUtf8().constData());
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, true); CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, true);

View file

@ -143,6 +143,6 @@ void CSMTools::Tools::verifierMessage (const QString& message, int type)
std::map<int, int>::iterator iter = mActiveReports.find (type); std::map<int, int>::iterator iter = mActiveReports.find (type);
if (iter!=mActiveReports.end()) if (iter!=mActiveReports.end())
mReports[iter->second]->add (message.toStdString()); mReports[iter->second]->add (message.toUtf8().constData());
} }

View file

@ -8,7 +8,7 @@ CSMWorld::TableMimeData::TableMimeData (UniversalId id, const CSMDoc::Document&
mDocument(document) mDocument(document)
{ {
mUniversalId.push_back (id); mUniversalId.push_back (id);
mObjectsFormats << QString::fromStdString ("tabledata/" + id.getTypeName()); mObjectsFormats << QString::fromUtf8 (("tabledata/" + id.getTypeName()).c_str());
} }
CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id, const CSMDoc::Document& document) : CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id, const CSMDoc::Document& document) :
@ -16,7 +16,7 @@ CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id
{ {
for (std::vector<UniversalId>::iterator it (mUniversalId.begin()); it != mUniversalId.end(); ++it) for (std::vector<UniversalId>::iterator it (mUniversalId.begin()); it != mUniversalId.end(); ++it)
{ {
mObjectsFormats << QString::fromStdString ("tabledata/" + it->getTypeName()); mObjectsFormats << QString::fromUtf8 (("tabledata/" + it->getTypeName()).c_str());
} }
} }

View file

@ -40,7 +40,7 @@ OpenDialog::OpenDialog(QWidget * parent) : QDialog(parent)
mCfgMgr.processPaths(mDataLocal); mCfgMgr.processPaths(mDataLocal);
// Set the charset for reading the esm/esp files // Set the charset for reading the esm/esp files
QString encoding = QString::fromStdString(variables["encoding"].as<std::string>()); QString encoding = QString::fromUtf8 (variables["encoding"].as<std::string>().c_str());
Files::PathContainer dataDirs; Files::PathContainer dataDirs;
dataDirs.insert(dataDirs.end(), mDataDirs.begin(), mDataDirs.end()); dataDirs.insert(dataDirs.end(), mDataDirs.begin(), mDataDirs.end());

View file

@ -4,7 +4,7 @@ CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id)
{ {
/// \todo add a button to the title bar that clones this sub view /// \todo add a button to the title bar that clones this sub view
setWindowTitle (mUniversalId.toString().c_str()); setWindowTitle (QString::fromUtf8 (mUniversalId.toString().c_str()));
} }
CSMWorld::UniversalId CSVDoc::SubView::getUniversalId() const CSMWorld::UniversalId CSVDoc::SubView::getUniversalId() const

View file

@ -120,7 +120,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
{ {
ss<<"!or("; ss<<"!or(";
} else { } else {
ss << orAnd << oldContent.toStdString() << ','; ss << orAnd << oldContent.toUtf8().constData() << ',';
} }
for (unsigned i = 0; i < count; ++i) for (unsigned i = 0; i < count; ++i)
@ -137,7 +137,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
} else { } else {
if (!replaceMode) if (!replaceMode)
{ {
ss << orAnd << oldContent.toStdString() <<','; ss << orAnd << oldContent.toUtf8().constData() <<',';
} else { } else {
ss<<'!'; ss<<'!';
} }

View file

@ -444,7 +444,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
mMainLayout = new QVBoxLayout(mainWidget); mMainLayout = new QVBoxLayout(mainWidget);
mEditWidget = new EditWidget(mainWidget, mRow, mTable, mUndoStack, false); mEditWidget = new EditWidget(mainWidget, mRow, mTable, mUndoStack, false);
connect(mEditWidget, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)), connect(mEditWidget, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
this, SLOT(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*))); this, SLOT(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
mMainLayout->addWidget(mEditWidget); mMainLayout->addWidget(mEditWidget);
@ -490,7 +490,7 @@ void CSVWorld::DialogueSubView::prevId()
{ {
mEditWidget->remake(newRow); mEditWidget->remake(newRow);
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()), setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
mTable->data (mTable->index (newRow, 0)).toString().toStdString())); mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
mRow = newRow; mRow = newRow;
mEditWidget->setDisabled(mLocked); mEditWidget->setDisabled(mLocked);
return; return;
@ -522,7 +522,7 @@ void CSVWorld::DialogueSubView::nextId()
{ {
mEditWidget->remake(newRow); mEditWidget->remake(newRow);
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()), setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
mTable->data (mTable->index (newRow, 0)).toString().toStdString())); mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
mRow = newRow; mRow = newRow;
mEditWidget->setDisabled(mLocked); mEditWidget->setDisabled(mLocked);
return; return;
@ -580,7 +580,7 @@ void CSVWorld::DialogueSubView::revertRecord()
if (state!=CSMWorld::RecordBase::State_BaseOnly) if (state!=CSMWorld::RecordBase::State_BaseOnly)
{ {
mUndoStack.push(new CSMWorld::RevertCommand(*mTable, mTable->data(mTable->index (mRow, 0)).toString().toStdString())); mUndoStack.push(new CSMWorld::RevertCommand(*mTable, mTable->data(mTable->index (mRow, 0)).toString().toUtf8().constData()));
} }
if (rows != mTable->rowCount()) if (rows != mTable->rowCount())
{ {
@ -613,7 +613,7 @@ void CSVWorld::DialogueSubView::deleteRecord()
mRow < rows && mRow < rows &&
mBottom->canCreateAndDelete()) mBottom->canCreateAndDelete())
{ {
mUndoStack.push(new CSMWorld::DeleteCommand(*mTable, mTable->data(mTable->index (mRow, 0)).toString().toStdString())); mUndoStack.push(new CSMWorld::DeleteCommand(*mTable, mTable->data(mTable->index (mRow, 0)).toString().toUtf8().constData()));
if (rows != mTable->rowCount()) if (rows != mTable->rowCount())
{ {
if (mTable->rowCount() == 0) if (mTable->rowCount() == 0)
@ -639,7 +639,7 @@ void CSVWorld::DialogueSubView::requestFocus (const std::string& id)
void CSVWorld::DialogueSubView::cloneRequest () void CSVWorld::DialogueSubView::cloneRequest ()
{ {
mBottom->cloneRequest(mTable->data(mTable->index (mRow, 0)).toString().toStdString(), mBottom->cloneRequest(mTable->data(mTable->index (mRow, 0)).toString().toUtf8().constData(),
static_cast<CSMWorld::UniversalId::Type>(mTable->data(mTable->index(mRow, 2)).toInt())); static_cast<CSMWorld::UniversalId::Type>(mTable->data(mTable->index(mRow, 2)).toInt()));
} }
@ -647,7 +647,7 @@ void CSVWorld::DialogueSubView::showPreview ()
{ {
if (mTable->hasPreview() && mRow < mTable->rowCount()) if (mTable->hasPreview() && mRow < mTable->rowCount())
{ {
emit focusId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, mTable->data(mTable->index (mRow, 0)).toString().toStdString()), ""); emit focusId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, mTable->data(mTable->index (mRow, 0)).toString().toUtf8().constData()), "");
} }
} }

View file

@ -71,9 +71,9 @@ void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event)
{ {
if (stringNeedsQuote(it->getId())) if (stringNeedsQuote(it->getId()))
{ {
insertPlainText(QString::fromStdString ('"' + it->getId() + '"')); insertPlainText(QString::fromUtf8 (('"' + it->getId() + '"').c_str()));
} else { } else {
insertPlainText(QString::fromStdString (it->getId())); insertPlainText(QString::fromUtf8 (it->getId().c_str()));
} }
} }
} }
@ -82,7 +82,7 @@ void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event)
bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const
{ {
const QString string(QString::fromStdString(id)); //<regex> is only for c++11, so let's use qregexp for now. const QString string(QString::fromUtf8(id.c_str())); //<regex> is only for c++11, so let's use qregexp for now.
//I'm not quite sure when do we need to put quotes. To be safe we will use quotes for anything other than… //I'm not quite sure when do we need to put quotes. To be safe we will use quotes for anything other than…
return !(string.contains(mWhiteListQoutes)); return !(string.contains(mWhiteListQoutes));
} }

View file

@ -289,7 +289,7 @@ CSMWorld::UniversalId CSVWorld::Table::getUniversalId (int row) const
{ {
return CSMWorld::UniversalId ( return CSMWorld::UniversalId (
static_cast<CSMWorld::UniversalId::Type> (mProxyModel->data (mProxyModel->index (row, 2)).toInt()), static_cast<CSMWorld::UniversalId::Type> (mProxyModel->data (mProxyModel->index (row, 2)).toInt()),
mProxyModel->data (mProxyModel->index (row, 0)).toString().toStdString()); mProxyModel->data (mProxyModel->index (row, 0)).toString().toUtf8().constData());
} }
void CSVWorld::Table::revertRecord() void CSVWorld::Table::revertRecord()
@ -533,7 +533,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event)
} }
drag->setMimeData (mime); drag->setMimeData (mime);
drag->setPixmap (QString::fromStdString (mime->getIcon())); drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str()));
drag->exec(Qt::CopyAction); drag->exec(Qt::CopyAction);
} }
@ -588,7 +588,7 @@ std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::Column
if (display == columndisplay) if (display == columndisplay)
{ {
titles.push_back(mModel->headerData (i, Qt::Horizontal).toString().toStdString()); titles.push_back(mModel->headerData (i, Qt::Horizontal).toString().toUtf8().constData());
} }
} }
return titles; return titles;