1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-02 16:20:23 +00:00

Use signals for user preference setting updates.

This commit is contained in:
cc9cii 2015-05-29 19:28:25 +10:00
parent 734e52d1c8
commit 393cee406f
7 changed files with 75 additions and 9 deletions

View File

@ -34,7 +34,7 @@ opencs_hdrs_noqt (model/world
opencs_units (model/tools opencs_units (model/tools
tools reportmodel tools reportmodel signalhandler
) )
opencs_units_noqt (model/tools opencs_units_noqt (model/tools

View File

@ -10,14 +10,21 @@
#include "../settings/usersettings.hpp" #include "../settings/usersettings.hpp"
CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids) #include "signalhandler.hpp"
: mPathgrids (pathgrids)
CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids,
CSMTools::SignalHandler *signalHandler)
: mPathgrids (pathgrids), mSigHandler(signalHandler)
{} {}
CSMTools::PathgridCheckStage::~PathgridCheckStage ()
{
delete mSigHandler;
}
int CSMTools::PathgridCheckStage::setup() int CSMTools::PathgridCheckStage::setup()
{ {
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); mExtraCheck = mSigHandler->extraCheck();
mExtraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true";
return mPathgrids.getSize(); return mPathgrids.getSize();
} }

View File

@ -14,6 +14,7 @@ namespace CSMWorld
namespace CSMTools namespace CSMTools
{ {
class SignalHandler;
struct Point struct Point
{ {
@ -25,13 +26,17 @@ namespace CSMTools
class PathgridCheckStage : public CSMDoc::Stage class PathgridCheckStage : public CSMDoc::Stage
{ {
bool mExtraCheck; bool mExtraCheck;
CSMTools::SignalHandler *mSigHandler;
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid, const CSMWorld::SubCellCollection<CSMWorld::Pathgrid,
CSMWorld::IdAccessor<CSMWorld::Pathgrid> >& mPathgrids; CSMWorld::IdAccessor<CSMWorld::Pathgrid> >& mPathgrids;
public: public:
PathgridCheckStage (const CSMWorld::SubCellCollection<CSMWorld::Pathgrid, PathgridCheckStage (const CSMWorld::SubCellCollection<CSMWorld::Pathgrid,
CSMWorld::IdAccessor<CSMWorld::Pathgrid> >& pathgrids); CSMWorld::IdAccessor<CSMWorld::Pathgrid> >& pathgrids, CSMTools::SignalHandler *signallHandler);
~PathgridCheckStage ();
virtual int setup(); virtual int setup();

View File

@ -0,0 +1,23 @@
#include "signalhandler.hpp"
#include "../settings/usersettings.hpp"
CSMTools::SignalHandler::SignalHandler(bool extraCheck)
: mExtraCheck(extraCheck)
{
connect (&CSMSettings::UserSettings::instance(),
SIGNAL (userSettingUpdated(const QString &, const QStringList &)),
this,
SLOT (updateUserSetting (const QString &, const QStringList &)));
}
void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStringList &list)
{
if (name=="verifier/pathgrid-extra-check")
mExtraCheck = list.at(0) == "true";
}
bool CSMTools::SignalHandler::extraCheck ()
{
return mExtraCheck;
}

View File

@ -0,0 +1,26 @@
#ifndef CSM_TOOLS_SIGNALHANDLER_H
#define CSM_TOOLS_SIGNALHANDLER_H
#include <QObject>
namespace CSMTools
{
class SignalHandler : public QObject
{
Q_OBJECT
bool mExtraCheck;
public:
SignalHandler (bool extraCheck);
bool extraCheck ();
public slots:
void updateUserSetting (const QString &name, const QStringList &list);
};
}
#endif

View File

@ -10,6 +10,8 @@
#include "../world/data.hpp" #include "../world/data.hpp"
#include "../world/universalid.hpp" #include "../world/universalid.hpp"
#include "../settings/usersettings.hpp"
#include "reportmodel.hpp" #include "reportmodel.hpp"
#include "mandatoryid.hpp" #include "mandatoryid.hpp"
#include "skillcheck.hpp" #include "skillcheck.hpp"
@ -27,6 +29,7 @@
#include "startscriptcheck.hpp" #include "startscriptcheck.hpp"
#include "searchoperation.hpp" #include "searchoperation.hpp"
#include "pathgridcheck.hpp" #include "pathgridcheck.hpp"
#include "signalhandler.hpp"
CSMDoc::OperationHolder *CSMTools::Tools::get (int type) CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
{ {
@ -56,6 +59,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)), SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)),
this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int))); this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)));
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
std::vector<std::string> mandatoryIds; // I want C++11, damn it! std::vector<std::string> mandatoryIds; // I want C++11, damn it!
mandatoryIds.push_back ("Day"); mandatoryIds.push_back ("Day");
mandatoryIds.push_back ("DaysPassed"); mandatoryIds.push_back ("DaysPassed");
@ -97,7 +102,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )), CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )),
mData.getRaces() )); mData.getRaces() ));
mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids())); mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids(),
new SignalHandler(userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true")));
mVerifier.setOperation (mVerifierOperation); mVerifier.setOperation (mVerifierOperation);
} }
@ -213,4 +219,3 @@ void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const st
if (iter!=mActiveReports.end()) if (iter!=mActiveReports.end())
mReports[iter->second]->add (id, message, hint); mReports[iter->second]->add (id, message, hint);
} }