Back to index

salome-gui  6.5.0
LogWindow.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  KERNEL SALOME_Event : Define event posting mechanism
00024 // File   : LogWindow.h
00025 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00026 //
00027 #ifndef LOGWINDOW_H
00028 #define LOGWINDOW_H
00029 
00030 #if defined WIN32
00031 #  if defined LOGWINDOW_EXPORTS || defined LogWindow_EXPORTS
00032 #    define LOGWINDOW_EXPORT __declspec( dllexport )
00033 #  else
00034 #    define LOGWINDOW_EXPORT __declspec( dllimport )
00035 #  endif
00036 #else
00037 #  define LOGWINDOW_EXPORT
00038 #endif
00039 
00040 #include <SUIT_PopupClient.h>
00041 
00042 #include <QWidget>
00043 #include <QMap>
00044 #include <QStringList>
00045 
00046 #ifdef WIN32
00047 #pragma warning( disable:4251 )
00048 #endif
00049 
00050 class QAction;
00051 class QTextEdit;
00052 
00053 class LOGWINDOW_EXPORT LogWindow : public QWidget, public SUIT_PopupClient
00054 {
00055   Q_OBJECT
00056 
00057 public:
00059   enum
00060   {
00061     CopyId       = 0x01,                                
00062     ClearId      = 0x02,                                
00063     SelectAllId  = 0x04,                                
00064     SaveToFileId = 0x08,                                
00065     All = CopyId | ClearId | SelectAllId | SaveToFileId 
00066   };
00067 
00069   enum
00070   {
00071     DisplayNormal    = 0x00,                     
00072     DisplayDate      = 0x01,                     
00073     DisplayTime      = 0x02,                     
00074     DisplaySeparator = 0x04,                     
00075     DisplayNoColor   = 0x08,                     
00076     DisplayDateTime  = DisplayDate | DisplayTime 
00077   };
00078 
00079 public:
00080   LogWindow( QWidget* theParent );
00081   virtual ~LogWindow();
00082 
00083   virtual             QString popupClientType() const { return QString( "LogWindow" ); }
00084   virtual void        contextMenuPopup( QMenu* );
00085 
00086   virtual bool        eventFilter( QObject*, QEvent* );
00087 
00088   QString             banner() const;
00089   QString             separator() const;
00090 
00091   void                setBanner( const QString& );
00092   void                setSeparator( const QString& );
00093 
00094   void                putMessage( const QString&, const int = DisplayNormal );
00095   virtual void        putMessage( const QString&, const QColor&, const int = DisplayNormal );
00096   void                clear( const bool = false );
00097 
00098   bool                saveLog( const QString& );
00099 
00100   void                setMenuActions( const int );
00101   int                 menuActions() const;
00102 
00103 protected slots:
00104   void                onSaveToFile();
00105   void                onSelectAll();
00106   void                onClear();
00107   void                onCopy();
00108 
00109 private:
00110   void                createActions();
00111   void                updateActions();
00112 
00113 private:
00114   QTextEdit*          myView;           
00115   QString             myBanner;         
00116   QStringList         myHistory;        
00117   QString             mySeparator;      
00118   int                 myBannerSize;     
00119   QMap<int, QAction*> myActions;        
00120 };
00121 
00122 #ifdef WIN32
00123 #pragma warning( default:4251 )
00124 #endif
00125 
00126 #endif // LOGWINDOW_H