text encoding configuration (was using hardcoded settings before)

deque
Marc Zinnschlag 11 years ago
parent 5b5bf6f37e
commit 8279d307c4

@ -90,6 +90,9 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
mCfgMgr.readConfiguration(variables, desc);
mDocumentManager.setEncoding (
ToUTF8::calculateEncoding (variables["encoding"].as<std::string>()));
mDocumentManager.setResourceDir (mResources = variables["resources"].as<std::string>());
mFsStrict = variables["fs-strict"].as<bool>();

@ -2204,11 +2204,13 @@ void CSMDoc::Document::createBase()
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
const std::vector< boost::filesystem::path >& files, bool new_,
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir)
: mSavePath (savePath), mContentFiles (files), mNew (new_), mTools (mData), mResDir(resDir),
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
ToUTF8::FromType encoding)
: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding), mTools (mData),
mResDir(resDir),
mProjectPath ((configuration.getUserDataPath() / "projects") /
(savePath.filename().string() + ".project")),
mSaving (*this, mProjectPath)
mSaving (*this, mProjectPath, encoding)
{
if (mContentFiles.empty())
throw std::runtime_error ("Empty content file sequence");

@ -9,6 +9,8 @@
#include <QObject>
#include <QTimer>
#include <components/to_utf8/to_utf8.hpp>
#include "../world/data.hpp"
#include "../tools/tools.hpp"
@ -70,7 +72,8 @@ namespace CSMDoc
Document (const Files::ConfigurationManager& configuration,
const std::vector< boost::filesystem::path >& files, bool new_,
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir);
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
ToUTF8::FromType encoding);
~Document();

@ -13,7 +13,7 @@
#include "document.hpp"
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
: mConfiguration (configuration)
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252)
{
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
@ -52,7 +52,7 @@ CSMDoc::DocumentManager::~DocumentManager()
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
bool new_)
{
Document *document = new Document (mConfiguration, files, new_, savePath, mResDir);
Document *document = new Document (mConfiguration, files, new_, savePath, mResDir, mEncoding);
mDocuments.push_back (document);
@ -80,6 +80,11 @@ void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& par
mResDir = boost::filesystem::system_complete(parResDir);
}
void CSMDoc::DocumentManager::setEncoding (ToUTF8::FromType encoding)
{
mEncoding = encoding;
}
void CSMDoc::DocumentManager::documentLoaded (Document *document)
{
emit documentAdded (document);

@ -9,6 +9,8 @@
#include <QObject>
#include <QThread>
#include <components/to_utf8/to_utf8.hpp>
#include "loader.hpp"
namespace Files
@ -28,6 +30,7 @@ namespace CSMDoc
const Files::ConfigurationManager& mConfiguration;
QThread mLoaderThread;
Loader mLoader;
ToUTF8::FromType mEncoding;
DocumentManager (const DocumentManager&);
DocumentManager& operator= (const DocumentManager&);
@ -45,6 +48,8 @@ namespace CSMDoc
void setResourceDir (const boost::filesystem::path& parResDir);
void setEncoding (ToUTF8::FromType encoding);
private:
boost::filesystem::path mResDir;

@ -8,8 +8,9 @@
#include "savingstages.hpp"
#include "document.hpp"
CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& projectPath)
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath)
CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& projectPath,
ToUTF8::FromType encoding)
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath, encoding)
{
// save project file
appendStage (new OpenSaveStage (mDocument, mState, true));

@ -3,6 +3,8 @@
#include <boost/filesystem/path.hpp>
#include <components/to_utf8/to_utf8.hpp>
#include "operation.hpp"
#include "savingstate.hpp"
@ -19,7 +21,8 @@ namespace CSMDoc
public:
Saving (Document& document, const boost::filesystem::path& projectPath);
Saving (Document& document, const boost::filesystem::path& projectPath,
ToUTF8::FromType encoding);
};
}

@ -4,11 +4,9 @@
#include "operation.hpp"
#include "document.hpp"
CSMDoc::SavingState::SavingState (Operation& operation, const boost::filesystem::path& projectPath)
: mOperation (operation),
/// \todo set encoding properly, once config implementation has been fixed.
mEncoder (ToUTF8::calculateEncoding ("win1252")),
mProjectPath (projectPath), mProjectFile (false)
CSMDoc::SavingState::SavingState (Operation& operation, const boost::filesystem::path& projectPath,
ToUTF8::FromType encoding)
: mOperation (operation), mEncoder (encoding), mProjectPath (projectPath), mProjectFile (false)
{
mWriter.setEncoder (&mEncoder);
}

@ -7,6 +7,8 @@
#include <components/esm/esmwriter.hpp>
#include <components/to_utf8/to_utf8.hpp>
namespace CSMDoc
{
class Operation;
@ -25,7 +27,8 @@ namespace CSMDoc
public:
SavingState (Operation& operation, const boost::filesystem::path& projectPath);
SavingState (Operation& operation, const boost::filesystem::path& projectPath,
ToUTF8::FromType encoding);
bool hasError() const;

@ -55,10 +55,8 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
return number;
}
CSMWorld::Data::Data()
/// \todo set encoding properly, once config implementation has been fixed.
: mEncoder (ToUTF8::calculateEncoding ("win1252")),
mRefs (mCells), mReader (0), mDialogue (0)
CSMWorld::Data::Data (ToUTF8::FromType encoding)
: mEncoder (encoding), mRefs (mCells), mReader (0), mDialogue (0)
{
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
mGlobals.addColumn (new RecordStateColumn<ESM::Global>);

@ -22,6 +22,8 @@
#include <components/esm/loadspel.hpp>
#include <components/esm/loaddial.hpp>
#include <components/to_utf8/to_utf8.hpp>
#include "../filter/filter.hpp"
#include "../doc/stage.hpp"
@ -91,7 +93,7 @@ namespace CSMWorld
public:
Data();
Data (ToUTF8::FromType encoding);
virtual ~Data();

Loading…
Cancel
Save