OSDN Git Service

adjust integer's signedness
[tjqt4port/tj2qt4.git] / taskjuggler / TjMessageHandler.h
1 /*
2  * TjMessageHandler.h - TaskJuggler
3  *
4  * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007
5  *               by Chris Schlaeger <cs@kde.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of version 2 of the GNU General Public License as
9  * published by the Free Software Foundation.
10  *
11  * $Id$
12  */
13 #ifndef _TjMessageHandler_h_
14 #define _TjMessageHandler_h_
15
16 #include <qobject.h>
17 #include <qstring.h>
18
19 /**
20  * This class handles all error or warning messages that the library functions
21  * can send out. Depending on the mode it either send the messages to STDERR
22  * or raises a Qt signal.
23  *
24  * @short Handles all error or warning messages.
25  * @author Chris Schlaeger <cs@kde.org>
26  */
27 class TjMessageHandler : public QObject
28 {
29     Q_OBJECT
30 public:
31     TjMessageHandler(bool cm = true) :
32         QObject(),
33         consoleMode(cm),
34         warnings(0),
35         errors(0)
36     { }
37     virtual ~TjMessageHandler() { }
38
39     void warningMessage(const QString& msg, const QString& file = QString::null,
40                         int line = -1);
41     void errorMessage(const QString& msg, const QString& file = QString::null,
42                       int line = -1);
43     void fatalMessage(const QString& msg, const QString& file = QString::null,
44                       int line = -1);
45
46     void setConsoleMode(bool cm) { consoleMode = cm; }
47
48     void resetCounters() { warnings = errors = 0; }
49
50     int getWarnings() const { return warnings; }
51     int getErrors() const { return errors; }
52
53 signals:
54     void printWarning(const QString& msg, const QString& file, int line);
55     void printError(const QString& msg, const QString& file, int line);
56     void printFatal(const QString& msg, const QString& file, int line);
57
58 private:
59     bool consoleMode;
60     int warnings;
61     int errors;
62 } ;
63
64 extern TjMessageHandler TJMH;
65
66 #endif
67