| 1 |
/* |
| 2 |
* TjMessageHandler.h - TaskJuggler |
| 3 |
* |
| 4 |
* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
| 5 |
* by Chris Schlaeger <[email protected]> |
| 6 |
* SPDX-FileCopyrightText: 2011 Dag Andersen <[email protected]> |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of version 2 of the GNU General Public License as |
| 10 |
* published by the Free Software Foundation. |
| 11 |
* |
| 12 |
* $Id$ |
| 13 |
*/ |
| 14 |
|
| 15 |
// clazy:excludeall=qstring-arg |
| 16 |
#include "TjMessageHandler.h" |
| 17 |
#include "taskjuggler.h" |
| 18 |
#include "Utility.h" |
| 19 |
|
| 20 |
#include <QDebug> |
| 21 |
|
| 22 |
namespace TJ |
| 23 |
{ |
| 24 |
|
| 25 |
TjMessageHandler TJMH(false); |
| 26 |
|
| 27 |
void |
| 28 |
TjMessageHandler::warningMessage(const QString& msg, const CoreAttributes *object) |
| 29 |
{ |
| 30 |
warningMessage(msg, QString()); |
| 31 |
Q_EMIT message((int)TJ::WarningMsg, msg, const_cast<CoreAttributes*>(object)); |
| 32 |
} |
| 33 |
void |
| 34 |
TjMessageHandler::warningMessage(const QString& msg, const QString& file, int |
| 35 |
line) |
| 36 |
{ |
| 37 |
warnings++; |
| 38 |
warningPositions << messages.count(); |
| 39 |
messages << msg; |
| 40 |
|
| 41 |
if (consoleMode) |
| 42 |
{ |
| 43 |
if (file.isEmpty()) |
| 44 |
qWarning()<<msg; |
| 45 |
else |
| 46 |
qWarning()<<file<<":"<<line<<":"<<msg; |
| 47 |
} |
| 48 |
else |
| 49 |
Q_EMIT printWarning(msg, file, line); |
| 50 |
} |
| 51 |
|
| 52 |
void |
| 53 |
TjMessageHandler::errorMessage(const QString& msg, const CoreAttributes *object) |
| 54 |
{ |
| 55 |
errorMessage(msg, QString()); |
| 56 |
Q_EMIT message((int)TJ::ErrorMsg, msg, const_cast<CoreAttributes*>(object)); |
| 57 |
} |
| 58 |
|
| 59 |
void |
| 60 |
TjMessageHandler::errorMessage(const QString& msg, const QString& file, int |
| 61 |
line) |
| 62 |
{ |
| 63 |
errors++; |
| 64 |
errorPositions << messages.count(); |
| 65 |
messages << msg; |
| 66 |
|
| 67 |
if (consoleMode) |
| 68 |
{ |
| 69 |
if (file.isEmpty()) |
| 70 |
qWarning()<<msg; |
| 71 |
else |
| 72 |
qWarning()<<file<<":"<<line<<":"<<msg; |
| 73 |
} |
| 74 |
else |
| 75 |
Q_EMIT printError(msg, file, line); |
| 76 |
} |
| 77 |
|
| 78 |
void |
| 79 |
TjMessageHandler::fatalMessage(const QString& msg, const QString& file, int |
| 80 |
line) |
| 81 |
{ |
| 82 |
if (consoleMode) |
| 83 |
{ |
| 84 |
if (file.isEmpty()) |
| 85 |
qWarning()<<msg; |
| 86 |
else |
| 87 |
qWarning()<<file<<":"<<line<<":"<<msg; |
| 88 |
} |
| 89 |
else |
| 90 |
Q_EMIT printFatal(msg, file, line); |
| 91 |
} |
| 92 |
|
| 93 |
void |
| 94 |
TjMessageHandler::infoMessage(const QString &msg, const CoreAttributes *object) |
| 95 |
{ |
| 96 |
++infos; |
| 97 |
infoPositions << messages.count(); |
| 98 |
messages << msg; |
| 99 |
Q_EMIT message((int)TJ::InfoMsg, msg, const_cast<CoreAttributes*>(object)); |
| 100 |
} |
| 101 |
void |
| 102 |
TjMessageHandler::debugMessage(const QString &msg, const CoreAttributes *object) |
| 103 |
{ |
| 104 |
++debugs; |
| 105 |
debugPositions << messages.count(); |
| 106 |
messages << msg; |
| 107 |
Q_EMIT message((int)TJ::DebugMsg, msg, const_cast<CoreAttributes*>(object)); |
| 108 |
} |
| 109 |
|
| 110 |
} // namespace TJ |