1 |
// qsamplerMessages.cpp |
// qsamplerMessages.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2006, 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 |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
GNU General Public License for more details. |
GNU General Public License for more details. |
15 |
|
|
16 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
17 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
18 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
|
20 |
*****************************************************************************/ |
*****************************************************************************/ |
21 |
|
|
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); |
79 |
QDockWindow::setOrientation(Qt::Horizontal); |
QDockWindow::setOrientation(Qt::Horizontal); |
80 |
QDockWindow::setCloseMode(QDockWindow::Always); |
QDockWindow::setCloseMode(QDockWindow::Always); |
81 |
QDockWindow::setResizeEnabled(true); |
QDockWindow::setResizeEnabled(true); |
82 |
|
// Some specialties to this kind of dock window... |
83 |
|
QDockWindow::setFixedExtentHeight(120); |
84 |
|
|
85 |
// Finally set the default caption and tooltip. |
// Finally set the default caption and tooltip. |
86 |
QString sCaption = tr("Messages"); |
QString sCaption = tr("Messages"); |
198 |
void qsamplerMessages::setMessagesLimit ( int iMessagesLimit ) |
void qsamplerMessages::setMessagesLimit ( int iMessagesLimit ) |
199 |
{ |
{ |
200 |
m_iMessagesLimit = iMessagesLimit; |
m_iMessagesLimit = iMessagesLimit; |
201 |
|
m_iMessagesHigh = iMessagesLimit + (iMessagesLimit / 3); |
202 |
|
#if QT_VERSION >= 0x030200 |
203 |
|
m_pTextView->setMaxLogLines(iMessagesLimit); |
204 |
|
#endif |
205 |
} |
} |
206 |
|
|
207 |
|
|
218 |
|
|
219 |
void qsamplerMessages::appendMessagesText ( const QString& s ) |
void qsamplerMessages::appendMessagesText ( const QString& s ) |
220 |
{ |
{ |
221 |
|
#if QT_VERSION < 0x030200 |
222 |
// Check for message line limit... |
// Check for message line limit... |
223 |
if (m_iMessagesLimit > 0) { |
if (m_iMessagesLimit > 0) { |
224 |
int iParagraphs = m_pTextView->paragraphs(); |
int iParagraphs = m_pTextView->paragraphs(); |
225 |
if (iParagraphs > m_iMessagesLimit) { |
if (iParagraphs > m_iMessagesHigh) { |
226 |
m_pTextView->setUpdatesEnabled(false); |
m_pTextView->setUpdatesEnabled(false); |
227 |
while (iParagraphs > m_iMessagesLimit) { |
while (iParagraphs > m_iMessagesLimit) { |
228 |
m_pTextView->removeParagraph(0); |
m_pTextView->removeParagraph(0); |
232 |
m_pTextView->setUpdatesEnabled(true); |
m_pTextView->setUpdatesEnabled(true); |
233 |
} |
} |
234 |
} |
} |
235 |
|
#endif |
236 |
m_pTextView->append(s); |
m_pTextView->append(s); |
237 |
} |
} |
238 |
|
|