mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
standarised on the use of the Message struct when passing operations messages around
This commit is contained in:
parent
0e21c61297
commit
8791832c86
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <components/ogreinit/ogreinit.hpp>
|
#include <components/ogreinit/ogreinit.hpp>
|
||||||
|
|
||||||
|
#include "model/doc/messages.hpp"
|
||||||
|
|
||||||
#include "model/world/universalid.hpp"
|
#include "model/world/universalid.hpp"
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
@ -52,6 +54,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
qRegisterMetaType<std::string> ("std::string");
|
qRegisterMetaType<std::string> ("std::string");
|
||||||
qRegisterMetaType<CSMWorld::UniversalId> ("CSMWorld::UniversalId");
|
qRegisterMetaType<CSMWorld::UniversalId> ("CSMWorld::UniversalId");
|
||||||
|
qRegisterMetaType<CSMDoc::Message> ("CSMDoc::Message");
|
||||||
|
|
||||||
OgreInit::OgreInit ogreInit;
|
OgreInit::OgreInit ogreInit;
|
||||||
|
|
||||||
|
@ -2304,8 +2304,8 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
|||||||
connect (&mSaving, SIGNAL (done (int, bool)), this, SLOT (operationDone (int, bool)));
|
connect (&mSaving, SIGNAL (done (int, bool)), this, SLOT (operationDone (int, bool)));
|
||||||
|
|
||||||
connect (
|
connect (
|
||||||
&mSaving, SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)),
|
&mSaving, SIGNAL (reportMessage (const CSMDoc::Message&, int)),
|
||||||
this, SLOT (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)));
|
this, SLOT (reportMessage (const CSMDoc::Message&, int)));
|
||||||
|
|
||||||
connect (&mRunner, SIGNAL (runStateChanged()), this, SLOT (runStateChanged()));
|
connect (&mRunner, SIGNAL (runStateChanged()), this, SLOT (runStateChanged()));
|
||||||
}
|
}
|
||||||
@ -2401,11 +2401,10 @@ void CSMDoc::Document::modificationStateChanged (bool clean)
|
|||||||
emit stateChanged (getState(), this);
|
emit stateChanged (getState(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
|
void CSMDoc::Document::reportMessage (const CSMDoc::Message& message, int type)
|
||||||
const std::string& hint, int type)
|
|
||||||
{
|
{
|
||||||
/// \todo find a better way to get these messages to the user.
|
/// \todo find a better way to get these messages to the user.
|
||||||
std::cout << message << std::endl;
|
std::cout << message.mMessage << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::operationDone (int type, bool failed)
|
void CSMDoc::Document::operationDone (int type, bool failed)
|
||||||
|
@ -158,8 +158,7 @@ namespace CSMDoc
|
|||||||
|
|
||||||
void modificationStateChanged (bool clean);
|
void modificationStateChanged (bool clean);
|
||||||
|
|
||||||
void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
|
void reportMessage (const CSMDoc::Message& message, int type);
|
||||||
const std::string& hint, int type);
|
|
||||||
|
|
||||||
void operationDone (int type, bool failed);
|
void operationDone (int type, bool failed);
|
||||||
|
|
||||||
|
@ -68,7 +68,8 @@ void CSMDoc::Loader::load()
|
|||||||
for (CSMDoc::Messages::Iterator iter (messages.begin());
|
for (CSMDoc::Messages::Iterator iter (messages.begin());
|
||||||
iter!=messages.end(); ++iter)
|
iter!=messages.end(); ++iter)
|
||||||
{
|
{
|
||||||
document->getReport (log)->add (iter->mId, iter->mMessage);
|
document->getReport (log)->add (
|
||||||
|
CSMDoc::Message (iter->mId, iter->mMessage, ""));
|
||||||
emit loadMessage (document, iter->mMessage);
|
emit loadMessage (document, iter->mMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
#include "messages.hpp"
|
#include "messages.hpp"
|
||||||
|
|
||||||
|
CSMDoc::Message::Message() {}
|
||||||
|
|
||||||
CSMDoc::Message::Message (const CSMWorld::UniversalId& id, const std::string& message,
|
CSMDoc::Message::Message (const CSMWorld::UniversalId& id, const std::string& message,
|
||||||
const std::string& hint)
|
const std::string& hint)
|
||||||
: mId (id), mMessage (message), mHint (hint)
|
: mId (id), mMessage (message), mHint (hint)
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
#include "../world/universalid.hpp"
|
#include "../world/universalid.hpp"
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
@ -14,6 +16,8 @@ namespace CSMDoc
|
|||||||
std::string mMessage;
|
std::string mMessage;
|
||||||
std::string mHint;
|
std::string mHint;
|
||||||
|
|
||||||
|
Message();
|
||||||
|
|
||||||
Message (const CSMWorld::UniversalId& id, const std::string& message,
|
Message (const CSMWorld::UniversalId& id, const std::string& message,
|
||||||
const std::string& hint);
|
const std::string& hint);
|
||||||
};
|
};
|
||||||
@ -47,4 +51,6 @@ namespace CSMDoc
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE (CSMDoc::Message)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -129,7 +129,7 @@ void CSMDoc::Operation::executeStage()
|
|||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
emit reportMessage (CSMWorld::UniversalId(), e.what(), "", mType);
|
emit reportMessage (Message (CSMWorld::UniversalId(), e.what(), ""), mType);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ void CSMDoc::Operation::executeStage()
|
|||||||
emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType);
|
emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType);
|
||||||
|
|
||||||
for (Messages::Iterator iter (messages.begin()); iter!=messages.end(); ++iter)
|
for (Messages::Iterator iter (messages.begin()); iter!=messages.end(); ++iter)
|
||||||
emit reportMessage (iter->mId, iter->mMessage, iter->mHint, mType);
|
emit reportMessage (*iter, mType);
|
||||||
|
|
||||||
if (mCurrentStage==mStages.end())
|
if (mCurrentStage==mStages.end())
|
||||||
operationDone();
|
operationDone();
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include "messages.hpp"
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class UniversalId;
|
class UniversalId;
|
||||||
@ -61,8 +63,7 @@ namespace CSMDoc
|
|||||||
|
|
||||||
void progress (int current, int max, int type);
|
void progress (int current, int max, int type);
|
||||||
|
|
||||||
void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
|
void reportMessage (const CSMDoc::Message& message, int type);
|
||||||
const std::string& hint, int type);
|
|
||||||
|
|
||||||
void done (int type, bool failed);
|
void done (int type, bool failed);
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ void CSMDoc::OperationHolder::setOperation (Operation *operation)
|
|||||||
this, SIGNAL (progress (int, int, int)));
|
this, SIGNAL (progress (int, int, int)));
|
||||||
|
|
||||||
connect (
|
connect (
|
||||||
mOperation, SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)),
|
mOperation, SIGNAL (reportMessage (const CSMDoc::Message&, int)),
|
||||||
this, SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)));
|
this, SIGNAL (reportMessage (const CSMDoc::Message&, int)));
|
||||||
|
|
||||||
connect (
|
connect (
|
||||||
mOperation, SIGNAL (done (int, bool)),
|
mOperation, SIGNAL (done (int, bool)),
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
#include "messages.hpp"
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class UniversalId;
|
class UniversalId;
|
||||||
@ -44,8 +46,7 @@ namespace CSMDoc
|
|||||||
|
|
||||||
void progress (int current, int max, int type);
|
void progress (int current, int max, int type);
|
||||||
|
|
||||||
void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
|
void reportMessage (const CSMDoc::Message& message, int type);
|
||||||
const std::string& hint, int type);
|
|
||||||
|
|
||||||
void done (int type, bool failed);
|
void done (int type, bool failed);
|
||||||
|
|
||||||
|
@ -127,12 +127,11 @@ bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& p
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMTools::ReportModel::add (const CSMWorld::UniversalId& id, const std::string& message,
|
void CSMTools::ReportModel::add (const CSMDoc::Message& message)
|
||||||
const std::string& hint)
|
|
||||||
{
|
{
|
||||||
beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
|
beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
|
||||||
|
|
||||||
mRows.push_back (CSMDoc::Message (id, message, hint));
|
mRows.push_back (message);
|
||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@ namespace CSMTools
|
|||||||
|
|
||||||
virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
|
virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
|
||||||
|
|
||||||
void add (const CSMWorld::UniversalId& id, const std::string& message,
|
void add (const CSMDoc::Message& message);
|
||||||
const std::string& hint = "");
|
|
||||||
|
|
||||||
void flagAsReplaced (int index);
|
void flagAsReplaced (int index);
|
||||||
|
|
||||||
|
@ -58,9 +58,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
|
|||||||
|
|
||||||
connect (&mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
connect (&mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
||||||
connect (&mVerifier, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool)));
|
connect (&mVerifier, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool)));
|
||||||
connect (&mVerifier,
|
connect (&mVerifier, SIGNAL (reportMessage (const CSMDoc::Message&, int)),
|
||||||
SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)),
|
this, SLOT (verifierMessage (const CSMDoc::Message&, int)));
|
||||||
this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)));
|
|
||||||
|
|
||||||
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");
|
||||||
@ -125,9 +124,8 @@ CSMTools::Tools::Tools (CSMDoc::Document& document)
|
|||||||
|
|
||||||
connect (&mSearch, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
connect (&mSearch, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
||||||
connect (&mSearch, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool)));
|
connect (&mSearch, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool)));
|
||||||
connect (&mSearch,
|
connect (&mSearch, SIGNAL (reportMessage (const CSMDoc::Message&, int)),
|
||||||
SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)),
|
this, SLOT (verifierMessage (const CSMDoc::Message&, int)));
|
||||||
this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMTools::Tools::~Tools()
|
CSMTools::Tools::~Tools()
|
||||||
@ -215,12 +213,11 @@ CSMTools::ReportModel *CSMTools::Tools::getReport (const CSMWorld::UniversalId&
|
|||||||
return mReports.at (id.getIndex());
|
return mReports.at (id.getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const std::string& message,
|
void CSMTools::Tools::verifierMessage (const CSMDoc::Message& message, int type)
|
||||||
const std::string& hint, 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 (id, message, hint);
|
mReports[iter->second]->add (message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +75,7 @@ namespace CSMTools
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void verifierMessage (const CSMWorld::UniversalId& id, const std::string& message,
|
void verifierMessage (const CSMDoc::Message& message, int type);
|
||||||
const std::string& hint, int type);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user