]> SALOME platform Git repositories - modules/gui.git/blob - src/LogWindow/LogWindow.h
Salome HOME
c6aeeecc6925bce9ee3da9cb47e4a5c502c73150
[modules/gui.git] / src / LogWindow / LogWindow.h
1 //  KERNEL SALOME_Event : Define event posting mechanism
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //  File   : LogWindow.h
23 //  Author : 
24 //  Module : KERNEL
25
26 #ifndef LogWindow_HeaderFile
27 #define LogWindow_HeaderFile
28
29 #if defined LOGWINDOW_EXPORTS
30 #if defined WIN32
31 #define LOGWINDOW_EXPORT __declspec( dllexport )
32 #else
33 #define LOGWINDOW_EXPORT
34 #endif
35 #else
36 #if defined WIN32
37 #define LOGWINDOW_EXPORT __declspec( dllimport )
38 #else
39 #define LOGWINDOW_EXPORT
40 #endif
41 #endif
42
43 #include <SUIT_PopupClient.h>
44
45 #include <qframe.h>
46 #include <qstringlist.h>
47
48 #ifdef WIN32
49 #pragma warning( disable:4251 )
50 #endif
51
52 class QAction;
53 class QTextBrowser;
54
55 /*!
56   \class LogWindow
57   Widget, showing logs message. Allows to show, to clear, to copy messages and to save then to file
58 */
59 class LOGWINDOW_EXPORT LogWindow : public QFrame, public SUIT_PopupClient
60 {
61   Q_OBJECT
62
63   enum { CopyId, ClearId, SelectAllId, SaveToFileId };
64
65 public:
66         LogWindow( QWidget* theParent );
67         virtual ~LogWindow();
68
69   virtual             QString popupClientType() const { return QString( "LogWindow" ); }
70   virtual void        contextMenuPopup( QPopupMenu* );
71
72   bool                eventFilter( QObject* o, QEvent* e );
73
74   void                setBanner( const QString& banner );
75   void                setSeparator( const QString& separator );
76
77   virtual void        putMessage( const QString& message, bool addSeparator = true );
78   void                clear( bool clearHistory = false );
79
80   bool                saveLog( const QString& fileName );
81
82 protected slots:
83   void                onSaveToFile();
84   void                onSelectAll();
85   void                onClear();
86   void                onCopy();
87
88 private:
89   void                createActions();
90   void                updateActions();
91
92 private:
93   QTextBrowser*       myView;
94   QString             myBanner;
95   QString             mySeparator;
96   QStringList         myHistory;
97   int                 myBannerSize;
98   QMap<int, QAction*> myActions;
99 };
100
101 #ifdef WIN32
102 #pragma warning( default:4251 )
103 #endif
104
105 #endif