Fix game:addSpawnShapesByZone
[ryzomcore.git] / studio / src / plugins / log / qt_displayer.cpp
blob81f78a967cbb8ad8db2761e5ec27de68599a5555
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2011 Adrian JAEKEL <aj@elane2k.com>
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 //
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/>.
20 // Nel includes
21 #include "qt_displayer.h"
22 #include <nel/misc/common.h>
23 #include <nel/misc/file.h>
25 namespace NLQT
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)
47 m_DlgDebug=dlgDebug;
48 //dlgDebug->dlgDbgText->WriteText("test");
51 void CQtDisplayer::doDisplay ( const NLMISC::CLog::TDisplayInfo& args, const char *message )
53 bool needSpace = false;
54 std::string str;
56 if(m_DlgDebug==NULL)
57 return;
59 QTextCharFormat format;
61 if (args.Date != 0 && !_Raw) {
62 str += dateToHumanString(args.Date);
63 needSpace = true;
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")));
72 else
73 format.setForeground(QBrush(QColor("black")));
74 needSpace = true;
77 // Write thread identifier
78 /*if ( args.ThreadId != 0 && !_Raw) {
79 if (needSpace) { str += " "; needSpace = false; }
80 str += NLMISC::toString(args.ThreadId);
81 needSpace = true;
82 }*/
83 /*if (!args.ProcessName.empty() && !_Raw) {
84 if (needSpace) { str += " "; needSpace = false; }
85 str += args.ProcessName;
86 needSpace = true;
87 }*/
89 //if (args.FileName != NULL && !_Raw) {
90 // if (needSpace) { str += " "; needSpace = false; }
91 // str += NLMISC::CFile::getFilename(args.FileName);
92 // needSpace = true;
93 //}
95 /*if (args.Line != -1 && !_Raw) {
96 if (needSpace) { str += " "; needSpace = false; }
97 str += NLMISC::toString(args.Line);
98 needSpace = true;
99 }*/
101 if (args.FuncName != NULL && !_Raw)
103 if (needSpace)
105 str += " "; needSpace = false;
107 str += args.FuncName;
108 needSpace = true;
111 if (needSpace)
113 str += " : "; needSpace = false;
115 str += message;
119 m_DlgDebug->textCursor().insertText(str.c_str(), format);
120 //m_DlgDebug->setCenterOnScroll(true);
121 m_DlgDebug->centerCursor();
122 //m_DlgDebug->ensureCursorVisible();