1 |
// qsamplerMessages.cpp |
// qsamplerMessages.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
7 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
30 |
|
|
31 |
#include "config.h" |
#include "config.h" |
32 |
|
|
33 |
|
#if !defined(WIN32) |
34 |
|
#include <unistd.h> |
35 |
|
#endif |
36 |
|
|
37 |
// The default maximum number of message lines. |
// The default maximum number of message lines. |
38 |
#define QSAMPLER_MESSAGES_MAXLINES 1000 |
#define QSAMPLER_MESSAGES_MAXLINES 1000 |
39 |
|
|
51 |
qsamplerMessages::qsamplerMessages ( QWidget *pParent, const char *pszName ) |
qsamplerMessages::qsamplerMessages ( QWidget *pParent, const char *pszName ) |
52 |
: QDockWindow(pParent, pszName) |
: QDockWindow(pParent, pszName) |
53 |
{ |
{ |
|
// Initialize default message limit. |
|
|
m_iMessagesLimit = QSAMPLER_MESSAGES_MAXLINES; |
|
|
|
|
54 |
// Intialize stdout capture stuff. |
// Intialize stdout capture stuff. |
55 |
m_pStdoutNotifier = NULL; |
m_pStdoutNotifier = NULL; |
56 |
m_fdStdout[QSAMPLER_MESSAGES_FDREAD] = QSAMPLER_MESSAGES_FDNIL; |
m_fdStdout[QSAMPLER_MESSAGES_FDREAD] = QSAMPLER_MESSAGES_FDNIL; |
68 |
m_pTextView->setWordWrap(QTextEdit::NoWrap); |
m_pTextView->setWordWrap(QTextEdit::NoWrap); |
69 |
m_pTextView->setReadOnly(true); |
m_pTextView->setReadOnly(true); |
70 |
m_pTextView->setUndoRedoEnabled(false); |
m_pTextView->setUndoRedoEnabled(false); |
71 |
|
#if QT_VERSION >= 0x030200 |
72 |
|
m_pTextView->setTextFormat(Qt::LogText); |
73 |
|
#endif |
74 |
|
// Initialize default message limit. |
75 |
|
setMessagesLimit(QSAMPLER_MESSAGES_MAXLINES); |
76 |
|
|
77 |
// Prepare the dockable window stuff. |
// Prepare the dockable window stuff. |
78 |
QDockWindow::setWidget(m_pTextView); |
QDockWindow::setWidget(m_pTextView); |
196 |
void qsamplerMessages::setMessagesLimit ( int iMessagesLimit ) |
void qsamplerMessages::setMessagesLimit ( int iMessagesLimit ) |
197 |
{ |
{ |
198 |
m_iMessagesLimit = iMessagesLimit; |
m_iMessagesLimit = iMessagesLimit; |
199 |
|
m_iMessagesHigh = iMessagesLimit + (iMessagesLimit / 3); |
200 |
|
#if QT_VERSION >= 0x030200 |
201 |
|
m_pTextView->setMaxLogLines(iMessagesLimit); |
202 |
|
#endif |
203 |
} |
} |
204 |
|
|
205 |
|
|
216 |
|
|
217 |
void qsamplerMessages::appendMessagesText ( const QString& s ) |
void qsamplerMessages::appendMessagesText ( const QString& s ) |
218 |
{ |
{ |
219 |
|
#if QT_VERSION < 0x030200 |
220 |
// Check for message line limit... |
// Check for message line limit... |
221 |
if (m_iMessagesLimit > 0) { |
if (m_iMessagesLimit > 0) { |
222 |
int iParagraphs = m_pTextView->paragraphs(); |
int iParagraphs = m_pTextView->paragraphs(); |
223 |
if (iParagraphs > m_iMessagesLimit) { |
if (iParagraphs > m_iMessagesHigh) { |
224 |
m_pTextView->setUpdatesEnabled(false); |
m_pTextView->setUpdatesEnabled(false); |
225 |
while (iParagraphs > m_iMessagesLimit) { |
while (iParagraphs > m_iMessagesLimit) { |
226 |
m_pTextView->removeParagraph(0); |
m_pTextView->removeParagraph(0); |
230 |
m_pTextView->setUpdatesEnabled(true); |
m_pTextView->setUpdatesEnabled(true); |
231 |
} |
} |
232 |
} |
} |
233 |
|
#endif |
234 |
m_pTextView->append(s); |
m_pTextView->append(s); |
235 |
} |
} |
236 |
|
|