1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // KERNEL SALOME_Event : Define event posting mechanism
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
31 # if defined LOGWINDOW_EXPORTS || defined LogWindow_EXPORTS
32 # define LOGWINDOW_EXPORT __declspec( dllexport )
34 # define LOGWINDOW_EXPORT __declspec( dllimport )
37 # define LOGWINDOW_EXPORT
40 #include "QtxMsgHandler.h"
41 #include "SUIT_PopupClient.h"
45 #include <QStringList>
48 #pragma warning( disable:4251 )
54 class LOGWINDOW_EXPORT LogWindow : public QWidget, public SUIT_PopupClient, public QtxMsgHandlerCallback
59 //! Context popup menu actions flags
62 CopyId = 0x01, //!< "Copy" menu action
63 ClearId = 0x02, //!< "Clear" menu action
64 SelectAllId = 0x04, //!< "Select All" menu action
65 SaveToFileId = 0x08, //!< "Save To File" menu action
66 All = CopyId | ClearId | SelectAllId | SaveToFileId //!< all menu actions
69 //! Display messages flags
72 DisplayNormal = 0x00, //!< do not display extra data
73 DisplayDate = 0x01, //!< display message date
74 DisplayTime = 0x02, //!< display message time
75 DisplaySeparator = 0x04, //!< display separator between messages
76 DisplayNoColor = 0x08, //!< display non-colored message
77 DisplayDateTime = DisplayDate | DisplayTime //!< display date & time
81 LogWindow( QWidget* );
84 virtual QString popupClientType() const { return QString( "LogWindow" ); }
85 virtual void contextMenuPopup( QMenu* );
87 virtual bool eventFilter( QObject*, QEvent* );
89 QString banner() const;
90 QString separator() const;
92 void setBanner( const QString& );
93 void setSeparator( const QString& );
95 void putMessage( const QString&, const int = DisplayNormal );
96 virtual void putMessage( const QString&, const QColor&, const int = DisplayNormal );
97 void clear( const bool = false );
99 bool saveLog( const QString& );
101 void setMenuActions( const int );
102 int menuActions() const;
104 void handleQtMessages(bool);
113 void append( const QString text );
114 void createActions();
115 void updateActions();
116 void qtMessage( QtMsgType, const QMessageLogContext&, const QString& );
119 QTextEdit* myView; //!< internal view window
120 QString myBanner; //!< current banner
121 QStringList myHistory; //!< messages history
122 QString mySeparator; //!< current separator
123 int myBannerSize; //!< current banner's size
124 QMap<int, QAction*> myActions; //!< popup menu actions
128 #pragma warning( default:4251 )
131 #endif // LOGWINDOW_H