1 #ifndef CSM_DOC_MESSAGES_H 2 #define CSM_DOC_MESSAGES_H 3 4 #include <string> 5 #include <vector> 6 7 #include <QMetaType> 8 9 #include "../world/universalid.hpp" 10 11 namespace CSMDoc 12 { 13 struct Message 14 { 15 enum Severity 16 { 17 Severity_Info = 0, // no problem 18 Severity_Warning = 1, // a potential problem, but we are probably fine 19 Severity_Error = 2, // an error; we are not fine 20 Severity_SeriousError = 3, // an error so bad we can't even be sure if we are 21 // reporting it correctly 22 Severity_Default = 4 23 }; 24 25 CSMWorld::UniversalId mId; 26 std::string mMessage; 27 std::string mHint; 28 Severity mSeverity; 29 30 Message(); 31 32 Message (const CSMWorld::UniversalId& id, const std::string& message, 33 const std::string& hint, Severity severity); 34 35 static std::string toString (Severity severity); 36 }; 37 38 class Messages 39 { 40 public: 41 42 typedef std::vector<Message> Collection; 43 44 typedef Collection::const_iterator Iterator; 45 46 private: 47 48 Collection mMessages; 49 Message::Severity mDefault; 50 51 public: 52 53 Messages (Message::Severity default_); 54 55 void add (const CSMWorld::UniversalId& id, const std::string& message, 56 const std::string& hint = "", 57 Message::Severity severity = Message::Severity_Default); 58 59 Iterator begin() const; 60 61 Iterator end() const; 62 }; 63 } 64 65 Q_DECLARE_METATYPE (CSMDoc::Message) 66 67 #endif 68