2014-12-07 17:57:47 +00:00
|
|
|
#ifndef CSM_DOC_MESSAGES_H
|
|
|
|
#define CSM_DOC_MESSAGES_H
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <QMetaType>
|
|
|
|
|
|
|
|
#include <algorithm>
|
2014-12-07 17:57:47 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "../world/universalid.hpp"
|
|
|
|
|
|
|
|
namespace CSMDoc
|
|
|
|
{
|
2015-06-20 14:55:34 +00:00
|
|
|
struct Message
|
|
|
|
{
|
2015-06-20 17:04:19 +00:00
|
|
|
enum Severity
|
|
|
|
{
|
|
|
|
Severity_Info = 0, // no problem
|
|
|
|
Severity_Warning = 1, // a potential problem, but we are probably fine
|
|
|
|
Severity_Error = 2, // an error; we are not fine
|
|
|
|
Severity_SeriousError = 3, // an error so bad we can't even be sure if we are
|
|
|
|
// reporting it correctly
|
|
|
|
Severity_Default = 4
|
|
|
|
};
|
2015-07-16 12:46:02 +00:00
|
|
|
|
2015-06-20 14:55:34 +00:00
|
|
|
CSMWorld::UniversalId mId;
|
|
|
|
std::string mMessage;
|
|
|
|
std::string mHint;
|
2015-06-20 17:04:19 +00:00
|
|
|
Severity mSeverity;
|
2015-06-20 14:55:34 +00:00
|
|
|
|
2015-06-20 15:56:42 +00:00
|
|
|
Message();
|
2015-07-16 12:46:02 +00:00
|
|
|
|
2015-06-20 14:55:34 +00:00
|
|
|
Message(
|
|
|
|
const CSMWorld::UniversalId& id, const std::string& message, const std::string& hint, Severity severity);
|
2015-07-16 12:46:02 +00:00
|
|
|
|
|
|
|
static std::string toString(Severity severity);
|
2015-06-20 14:55:34 +00:00
|
|
|
};
|
2015-07-16 12:46:02 +00:00
|
|
|
|
2014-12-07 17:57:47 +00:00
|
|
|
class Messages
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef std::vector<Message> Collection;
|
|
|
|
|
|
|
|
typedef Collection::const_iterator Iterator;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Collection mMessages;
|
|
|
|
Message::Severity mDefault;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Messages(Message::Severity default_);
|
|
|
|
|
|
|
|
void add(const CSMWorld::UniversalId& id, const std::string& message, const std::string& hint = "",
|
2015-06-20 17:04:19 +00:00
|
|
|
Message::Severity severity = Message::Severity_Default);
|
2014-12-07 17:57:47 +00:00
|
|
|
|
|
|
|
Iterator begin() const;
|
|
|
|
|
|
|
|
Iterator end() const;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-06-20 15:56:42 +00:00
|
|
|
Q_DECLARE_METATYPE(CSMDoc::Message)
|
|
|
|
|
2014-12-07 17:57:47 +00:00
|
|
|
#endif
|