1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2011 Adrian JAEKEL <aj@elane2k.com>
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "qt_displayer.h"
22 #include <nel/misc/common.h>
23 #include <nel/misc/file.h>
28 CQtDisplayer::CQtDisplayer(QPlainTextEdit
*dlgDebug
, bool eraseLastLog
,
29 const char *displayerName
, bool raw
)
30 : NLMISC::IDisplayer (displayerName
), _NeedHeader(true), _LastLogSizeChecked(0), _Raw(raw
)
32 setParam(dlgDebug
,eraseLastLog
);
35 CQtDisplayer::CQtDisplayer()
36 : IDisplayer (""), _NeedHeader(true), _LastLogSizeChecked(0), _Raw(false)
41 CQtDisplayer::~CQtDisplayer() {
45 void CQtDisplayer::setParam (QPlainTextEdit
*dlgDebug
, bool eraseLastLog
)
48 //dlgDebug->dlgDbgText->WriteText("test");
51 void CQtDisplayer::doDisplay ( const NLMISC::CLog::TDisplayInfo
& args
, const char *message
)
53 bool needSpace
= false;
59 QTextCharFormat format
;
61 if (args
.Date
!= 0 && !_Raw
) {
62 str
+= dateToHumanString(args
.Date
);
66 if (args
.LogType
!= NLMISC::CLog::LOG_NO
&& !_Raw
)
68 if (needSpace
) { str
+= " "; needSpace
= false; }
69 str
+= logTypeToString(args
.LogType
);
70 if (args
.LogType
== NLMISC::CLog::LOG_WARNING
)
71 format
.setForeground(QBrush(QColor("red")));
73 format
.setForeground(QBrush(QColor("black")));
77 // Write thread identifier
78 /*if ( args.ThreadId != 0 && !_Raw) {
79 if (needSpace) { str += " "; needSpace = false; }
80 str += NLMISC::toString(args.ThreadId);
83 /*if (!args.ProcessName.empty() && !_Raw) {
84 if (needSpace) { str += " "; needSpace = false; }
85 str += args.ProcessName;
89 //if (args.FileName != NULL && !_Raw) {
90 // if (needSpace) { str += " "; needSpace = false; }
91 // str += NLMISC::CFile::getFilename(args.FileName);
95 /*if (args.Line != -1 && !_Raw) {
96 if (needSpace) { str += " "; needSpace = false; }
97 str += NLMISC::toString(args.Line);
101 if (args
.FuncName
!= NULL
&& !_Raw
)
105 str
+= " "; needSpace
= false;
107 str
+= args
.FuncName
;
113 str
+= " : "; needSpace
= false;
119 m_DlgDebug
->textCursor().insertText(str
.c_str(), format
);
120 //m_DlgDebug->setCenterOnScroll(true);
121 m_DlgDebug
->centerCursor();
122 //m_DlgDebug->ensureCursorVisible();