--- qsampler/trunk/src/qsamplerMessages.h 2004/05/26 15:55:36 91 +++ qsampler/trunk/src/qsamplerMessages.h 2021/01/25 10:07:17 3853 @@ -1,7 +1,8 @@ // qsamplerMessages.h // /**************************************************************************** - Copyright (C) 2003-2004, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2007, Christian Schoenebeck This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -13,78 +14,103 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *****************************************************************************/ #ifndef __qsamplerMessages_h #define __qsamplerMessages_h -#include +#include class QSocketNotifier; -class QTextEdit; +class QTextBrowser; +class QFile; +namespace QSampler { //------------------------------------------------------------------------- -// qsamplerMessages - Messages log dockable window. +// QSampler::Messages - Messages log dockable window. // -class qsamplerMessages : public QDockWindow +class Messages : public QDockWidget { - Q_OBJECT + Q_OBJECT public: - // Constructor. - qsamplerMessages(QWidget *pParent, const char *pszName = 0); - // Destructor. - ~qsamplerMessages(); - - // Stdout/stderr capture accessors. - bool isCaptureEnabled(); - void setCaptureEnabled(bool bCapture); - - // Message font accessors. - QFont messagesFont(); - void setMessagesFont(const QFont & font); - - // Maximum number of message lines accessors. - int messagesLimit(); - void setMessagesLimit(int iMessagesLimit); - - // The main utility methods. - void appendMessages(const QString& s); - void appendMessagesColor(const QString& s, const QString &c); - void appendMessagesText(const QString& s); - - void scrollToBottom(); - - // Stdout capture functions. - void appendStdoutBuffer(const QString& s); - void flushStdoutBuffer(); + // Constructor. + Messages(QWidget *pParent); + // Destructor. + ~Messages(); + + // Stdout/stderr capture accessors. + bool isCaptureEnabled(); + void setCaptureEnabled(bool bCapture); + + // Message font accessors. + QFont messagesFont(); + void setMessagesFont(const QFont& font); + + // Maximum number of message lines accessors. + int messagesLimit(); + void setMessagesLimit(int iMessagesLimit); + + // Logging settings. + bool isLogging() const; + void setLogging(bool bEnabled, const QString& sFilename = QString()); + + // The main utility methods. + void appendMessages(const QString& s); + void appendMessagesColor(const QString& s, const QColor& rgb); + void appendMessagesText(const QString& s); + + // Stdout capture functions. + void appendStdoutBuffer(const QString& s); + void flushStdoutBuffer(); + + // History reset. + void clear(); + +protected: + + // Message executives. + void appendMessagesLine(const QString& s); + void appendMessagesLog(const QString& s); + + // Set stdout/stderr blocking mode. + bool stdoutBlock(int fd, bool bBlock) const; + + // Split stdout/stderr into separate lines... + void processStdoutBuffer(); protected slots: - // Stdout capture slot. - void stdoutNotify(int fd); + // Stdout capture slot. + void stdoutNotify(int fd); private: - // The maximum number of message lines. - int m_iMessagesLimit; - - // The textview main widget. - QTextEdit *m_pTextView; - - // Stdout capture variables. - QSocketNotifier *m_pStdoutNotifier; - QString m_sStdoutBuffer; - int m_fdStdout[2]; + // The maximum number of message lines. + int m_iMessagesLines; + int m_iMessagesLimit; + int m_iMessagesHigh; + + // The textview main widget. + QTextBrowser *m_pMessagesTextView; + + // Stdout capture variables. + QSocketNotifier *m_pStdoutNotifier; + QString m_sStdoutBuffer; + int m_fdStdout[2]; + + // Logging stuff. + QFile *m_pMessagesLog; }; +} // namespace QSampler #endif // __qsamplerMessages_h