Use signals for user preference setting updates.

c++11
cc9cii 10 years ago
parent 734e52d1c8
commit 393cee406f

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

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

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

@ -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;
}

@ -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

@ -10,6 +10,8 @@
#include "../world/data.hpp"
#include "../world/universalid.hpp"
#include "../settings/usersettings.hpp"
#include "reportmodel.hpp"
#include "mandatoryid.hpp"
#include "skillcheck.hpp"
@ -27,6 +29,7 @@
#include "startscriptcheck.hpp"
#include "searchoperation.hpp"
#include "pathgridcheck.hpp"
#include "signalhandler.hpp"
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)),
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!
mandatoryIds.push_back ("Day");
mandatoryIds.push_back ("DaysPassed");
@ -97,7 +102,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )),
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);
}
@ -213,4 +219,3 @@ void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const st
if (iter!=mActiveReports.end())
mReports[iter->second]->add (id, message, hint);
}

@ -64,7 +64,7 @@ namespace CSMTools
CSMWorld::UniversalId newSearch();
void runSearch (const CSMWorld::UniversalId& searchId, const Search& search);
void abortOperation (int type);
///< \attention The operation is not aborted immediately.

Loading…
Cancel
Save