Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LogWindow.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // KERNEL SALOME_Event : Define event posting mechanism
24 // File : LogWindow.h
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 //
27 #ifndef LOGWINDOW_H
28 #define LOGWINDOW_H
29 
30 #if defined WIN32
31 # if defined LOGWINDOW_EXPORTS || defined LogWindow_EXPORTS
32 # define LOGWINDOW_EXPORT __declspec( dllexport )
33 # else
34 # define LOGWINDOW_EXPORT __declspec( dllimport )
35 # endif
36 #else
37 # define LOGWINDOW_EXPORT
38 #endif
39 
40 #include <SUIT_PopupClient.h>
41 
42 #include <QWidget>
43 #include <QMap>
44 #include <QStringList>
45 
46 #ifdef WIN32
47 #pragma warning( disable:4251 )
48 #endif
49 
50 class QAction;
51 class QTextEdit;
52 
54 {
55  Q_OBJECT
56 
57 public:
59  enum
60  {
61  CopyId = 0x01,
62  ClearId = 0x02,
63  SelectAllId = 0x04,
64  SaveToFileId = 0x08,
65  All = CopyId | ClearId | SelectAllId | SaveToFileId
66  };
67 
69  enum
70  {
71  DisplayNormal = 0x00,
72  DisplayDate = 0x01,
73  DisplayTime = 0x02,
74  DisplaySeparator = 0x04,
75  DisplayNoColor = 0x08,
76  DisplayDateTime = DisplayDate | DisplayTime
77  };
78 
79 public:
80  LogWindow( QWidget* theParent );
81  virtual ~LogWindow();
82 
83  virtual QString popupClientType() const { return QString( "LogWindow" ); }
84  virtual void contextMenuPopup( QMenu* );
85 
86  virtual bool eventFilter( QObject*, QEvent* );
87 
88  QString banner() const;
89  QString separator() const;
90 
91  void setBanner( const QString& );
92  void setSeparator( const QString& );
93 
94  void putMessage( const QString&, const int = DisplayNormal );
95  virtual void putMessage( const QString&, const QColor&, const int = DisplayNormal );
96  void clear( const bool = false );
97 
98  bool saveLog( const QString& );
99 
100  void setMenuActions( const int );
101  int menuActions() const;
102 
103 protected slots:
104  void onSaveToFile();
105  void onSelectAll();
106  void onClear();
107  void onCopy();
108 
109 private:
110  void createActions();
111  void updateActions();
112 
113 private:
114  QTextEdit* myView;
115  QString myBanner;
116  QStringList myHistory;
117  QString mySeparator;
119  QMap<int, QAction*> myActions;
120 };
121 
122 #ifdef WIN32
123 #pragma warning( default:4251 )
124 #endif
125 
126 #endif // LOGWINDOW_H