UserMsg Pile   version 0.0.1
UserMsg pile.
usermsg.h
Go to the documentation of this file.
1 
10 #ifndef GUARD_USERMSG_H_INCLUDE
11 #define GUARD_USERMSG_H_INCLUDE
12 
13 #include <usermsg/usermsg-config.h>
14 #include <usermsg/usermsgentry.h>
15 
16 #include <QVector>
17 
18 
19 
21 class USERMSG_EXPORT UserMsg {
22 
23  enum StandardReply {
24  // keep this in sync with QMessageBox::StandardButton
25  NoButton = 0x00000000,
26  Ok = 0x00000400,
27  Save = 0x00000800,
28  SaveAll = 0x00001000,
29  Open = 0x00002000,
30  Yes = 0x00004000,
31  YesToAll = 0x00008000,
32  No = 0x00010000,
33  NoToAll = 0x00020000,
34  Abort = 0x00040000,
35  Retry = 0x00080000,
36  Ignore = 0x00100000,
37  Close = 0x00200000,
38  Cancel = 0x00400000,
39  Discard = 0x00800000,
40  Help = 0x01000000,
41  Apply = 0x02000000,
42  Reset = 0x04000000,
43  RestoreDefaults = 0x08000000,
44 
45  };
46 
47 
48 private:
49 
50  QString
51  title_;
53  void *
54  user_payload_;
56  QVector<UserMsgEntry>
57  message_list_;
59 public:
60 
62  UserMsg ();
63 
65  UserMsg (
66  const UserMsg & other);
67 
69  UserMsg (
70  const QString & title,
71  void * user_data = NULL);
72 
73 
75  virtual ~UserMsg();
76 
77 
79  const QString &
80  title () const {
81  return title_;
82  }
83 
85  void
87  const QString & value) {
88  title_ = value;
89  }
90 
91 
93  void *
94  userData () const {
95  return user_payload_;
96  }
97 
99  void
101  void * value) {
102  user_payload_ = value;
103  }
104 
106  void
107  show ();
108 
110  int
111  count () const {
112  return message_list_.count ();
113  }
114 
116  void
117  clear () {
118  message_list_.clear ();
119  }
120 
122  const UserMsgEntry &
123  at (
124  int i) const {
125  return message_list_.at (i);
126  }
127 
129  void
130  remove (
131  int i) {
132  message_list_.removeAt (i);
133  }
134 
136  void
137  append (
138  const UserMsg & other);
139 
140 
141 
143  inline void
145  const QString & s_message) {
146  addMsg (UserMsgEntry::UTERROR, s_message);
147  }
148 
150  inline void
152  const QString & s_message) {
153  addMsg (UserMsgEntry::UTWARNING, s_message);
154  }
155 
157  inline void
159  const QString & s_message) {
160  addMsg (UserMsgEntry::UTINFO, s_message);
161  }
162 
164  inline void
166  const QString & s_message) {
167  addMsg (UserMsgEntry::UTDBG_ERROR, s_message);
168  }
169 
171  inline void
173  const QString & s_message) {
174  addMsg (UserMsgEntry::UTDBG_WARNING, s_message);
175  }
176 
178  inline void
180  const QString & s_message) {
181  addMsg (UserMsgEntry::UTDBG_INFO, s_message);
182  }
183 
185  void
186  addMsg (
188  const QString & s_message);
189 
190 
191 
192 
194  static inline void
195  err (
196  const QString & s_message) {
197  msg (UserMsgEntry::UTERROR, s_message);
198  }
199 
201  static inline void
202  war (
203  const QString & s_message) {
204  msg (UserMsgEntry::UTWARNING, s_message);
205  }
206 
208  static inline void
210  const QString & s_message) {
211  msg (UserMsgEntry::UTINFO, s_message);
212  }
213 
215  static inline void
217  const QString & s_message) {
218  msg (UserMsgEntry::UTDBG_ERROR, s_message);
219  }
220 
222  static inline void
224  const QString & s_message) {
225  msg (UserMsgEntry::UTDBG_ERROR, s_message);
226  }
227 
229  static inline void
231  const QString & s_message) {
232  msg (UserMsgEntry::UTDBG_INFO, s_message);
233  }
234 
236  static void
237  msg (
239  const QString & s_message);
240 
241 
243  static void
244  fatalException (
245  const QString & s_message);
246 
247 
249  static int
250  consoleAskYN (
251  const QString & s_message);
252 
253 protected:
254 
255 private:
256 
257 };
258 
259 #endif // GUARD_USERMSG_H_INCLUDE
Declarations for UserMsgEntry class.
const QString & title() const
Get the title.
Definition: usermsg.h:80
int count() const
The number of entries in the list.
Definition: usermsg.h:111
static void dbgWar(const QString &s_message)
Show a warning entry.
Definition: usermsg.h:223
void addDbgErr(const QString &s_message)
Add an error entry to the list.
Definition: usermsg.h:165
void addInfo(const QString &s_message)
Add an informative entry to the list.
Definition: usermsg.h:158
static void war(const QString &s_message)
Show a warning entry.
Definition: usermsg.h:202
static void dbgInfo(const QString &s_message)
Show an informative entry.
Definition: usermsg.h:230
void setTitle(const QString &value)
Set the title.
Definition: usermsg.h:86
void addDbgInfo(const QString &s_message)
Add an informative entry to the list.
Definition: usermsg.h:179
static void info(const QString &s_message)
Show an informative entry.
Definition: usermsg.h:209
void * userData() const
Get the payload.
Definition: usermsg.h:94
void addErr(const QString &s_message)
Add an error entry to the list.
Definition: usermsg.h:144
void addDbgWar(const QString &s_message)
Add a warning entry to the list.
Definition: usermsg.h:172
const UserMsgEntry & at(int i) const
Get an entry at a specific location.
Definition: usermsg.h:123
user messages mediator
Definition: usermsg.h:21
void clear()
Clear all entries from the list.
Definition: usermsg.h:117
Type
kind of the message
Definition: usermsgentry.h:24
user messages mediator
Definition: usermsgentry.h:19
static void dbgErr(const QString &s_message)
Show an error entry.
Definition: usermsg.h:216
static void err(const QString &s_message)
Show an error entry.
Definition: usermsg.h:195
void addWar(const QString &s_message)
add a warning entry to the list.
Definition: usermsg.h:151
void setUserData(void *value)
Set the payload.
Definition: usermsg.h:100