Version: 9.12.0
LogWindow.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, 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 "QtxMsgHandler.h"
41 #include "SUIT_PopupClient.h"
42 
43 #include <QWidget>
44 #include <QMap>
45 #include <QStringList>
46 
47 #ifdef WIN32
48 #pragma warning( disable:4251 )
49 #endif
50 
51 class QAction;
52 class QTextEdit;
53 
55 {
56  Q_OBJECT
57 
58 public:
60  enum
61  {
62  CopyId = 0x01,
63  ClearId = 0x02,
64  SelectAllId = 0x04,
65  SaveToFileId = 0x08,
66  All = CopyId | ClearId | SelectAllId | SaveToFileId
67  };
68 
70  enum
71  {
72  DisplayNormal = 0x00,
73  DisplayDate = 0x01,
74  DisplayTime = 0x02,
75  DisplaySeparator = 0x04,
76  DisplayNoColor = 0x08,
77  DisplayDateTime = DisplayDate | DisplayTime
78  };
79 
80 public:
81  LogWindow( QWidget* );
82  virtual ~LogWindow();
83 
84  virtual QString popupClientType() const { return QString( "LogWindow" ); }
85  virtual void contextMenuPopup( QMenu* );
86 
87  virtual bool eventFilter( QObject*, QEvent* );
88 
89  QString banner() const;
90  QString separator() const;
91 
92  void setBanner( const QString& );
93  void setSeparator( const QString& );
94 
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 );
98 
99  bool saveLog( const QString& );
100 
101  void setMenuActions( const int );
102  int menuActions() const;
103 
104  void handleQtMessages(bool);
105 
106 protected slots:
107  void onSaveToFile();
108  void onSelectAll();
109  void onClear();
110  void onCopy();
111 
112 private:
113  void append( const QString text );
114  void createActions();
115  void updateActions();
116  void qtMessage( QtMsgType, const QMessageLogContext&, const QString& );
117 
118 private:
119  QTextEdit* myView;
120  QString myBanner;
121  QStringList myHistory;
122  QString mySeparator;
124  QMap<int, QAction*> myActions;
125 };
126 
127 #ifdef WIN32
128 #pragma warning( default:4251 )
129 #endif
130 
131 #endif // LOGWINDOW_H
#define LOGWINDOW_EXPORT
Definition: LogWindow.h:37
Widget, displaying log messages.
Definition: LogWindow.h:55
QTextEdit * myView
internal view window
Definition: LogWindow.h:119
QString mySeparator
current separator
Definition: LogWindow.h:122
QStringList myHistory
messages history
Definition: LogWindow.h:121
virtual QString popupClientType() const
Get popup client symbolic name, used in popup menu management system.
Definition: LogWindow.h:84
int myBannerSize
current banner's size
Definition: LogWindow.h:123
QMap< int, QAction * > myActions
popup menu actions
Definition: LogWindow.h:124
QString myBanner
current banner
Definition: LogWindow.h:120
For more information see QT documentation.
Definition: SUIT_Application.h:42
Definition: QtxMsgHandler.h:32
virtual void qtMessage(QtMsgType, const QMessageLogContext &, const QString &)
Definition: SUIT_PopupClient.h:37
virtual void contextMenuPopup(QMenu *)
Definition: SUIT_PopupClient.h:49