casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
logviewer.qo.h
Go to the documentation of this file.
00001 //# Copyright (C) 2005
00002 //# Associated Universities, Inc. Washington DC, USA.
00003 //#
00004 //# This library is free software; you can redistribute it and/or modify it
00005 //# under the terms of the GNU Library General Public License as published by
00006 //# the Free Software Foundation; either version 2 of the License, or (at your
00007 //# option) any later version.
00008 //#
00009 //# This library is distributed in the hope that it will be useful, but WITHOUT
00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012 //# License for more details.
00013 //#
00014 //# You should have received a copy of the GNU Library General Public License
00015 //# along with this library; if not, write to the Free Software Foundation,
00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00017 //#
00018 //# Correspondence concerning AIPS++ should be addressed as follows:
00019 //#        Internet email: aips2-request@nrao.edu.
00020 //#        Postal address: AIPS++ Project Office
00021 //#                        National Radio Astronomy Observatory
00022 //#                        520 Edgemont Road
00023 //#                        Charlottesville, VA 22903-2475 USA
00024 //#
00025 //# $Id: $
00026 
00027 
00028 #ifndef LOGVIEWER_H
00029 #define LOGVIEWER_H
00030 
00031 #if ! defined(__APPLE__) || defined(__USE_WS_X11__)
00032 #include <graphics/X11/X_enter.h>
00033 #endif
00034 
00035 #include <fstream>
00036 #include <QMainWindow>
00037 #include <QMap>
00038 #include <QModelIndex>
00039 #include <QPointer>
00040 #include <QMutex>
00041 #include <QTime>
00042 #include <QFileSystemWatcher>
00043 #include <QTextStream>
00044 
00045 
00046 class QAction;
00047 class QComboBox;
00048 class QLineEdit;
00049 class QTreeView;
00050 class QTreeWidget;
00051 class QMenu;
00052 class QFile;
00053 class QSortFilterProxyModel;
00054 class QCheckBox;
00055 class QLabel;
00056 
00057 #if ! defined(__APPLE__) || defined(__USE_WS_X11__)
00058 #include <graphics/X11/X_exit.h>
00059 #endif
00060 
00061 namespace casa {
00062 
00063 class LogModel;
00064 class FileWatcher;
00065 
00066 class LogViewer : public QMainWindow
00067 {
00068     Q_OBJECT
00069 
00070 public:
00071     LogViewer(QString logger = 0, QWidget *parent = 0);
00072 
00073 protected:
00074     virtual void closeEvent(QCloseEvent *e);
00075     virtual void moveEvent(QMoveEvent *e);
00076 
00077 private:
00078     void setupFileActions();
00079     void setupEditActions();
00080     void setupInsertActions();
00081     void updateMenus();
00082     bool load(const QString &f);
00083     bool maybeSave();
00084 
00085 private slots:
00086     void fileOpen();
00087     bool fileSave();
00088     bool fileSaveAs();
00089     void filePrint();
00090     void filePrintPdf();
00091     void fileChanged(const QString&);
00092     void logOpen();
00093     
00094     void search();
00095     void findNext();
00096     void remove();
00097     void purge();
00098     void copy();
00099     void insert();
00100     void changeFilterText();
00101     void changeFilterColumn(int);
00102     void doFilter();
00103     void refresh();
00104     void reload();
00105     void hide();
00106     void changeFont();
00107 
00108     void clicked(const QModelIndex &index);
00109 
00110     virtual QSize sizeHint () const;
00111 
00112 private:
00113 
00114     QAction *actionOpen,
00115         *actionSave,
00116         *actionSaveAs,
00117         *actionSearch,
00118         *actionNext,
00119         *actionFilter,
00120         *actionInsert,
00121         *actionCopy,
00122         *actionDelete,
00123         *actionDeleteAll,
00124         *actionPrint,
00125         *actionPdf,
00126         *actionHideDate,
00127         *actionHidePrio,
00128         *actionHideFrom,
00129         *actionWrite,
00130         *actionRefresh,
00131         *actionReload,
00132         *actionLarge,
00133         *actionSmall;
00134 
00135     QLineEdit *searchText,
00136               *insertText,
00137               *filterText;
00138 
00139     QComboBox *filterColumn;
00140 
00141     QToolBar *tb;
00142     QLabel *searchLabel;
00143     QLabel *filterLabel;
00144     QLabel *insertLabel;
00145 
00146     int currentColumn;
00147     QModelIndex currentLogRow;
00148     QString currentFilter;
00149     QString currentSearch;
00150     int nextRow;
00151 
00152     QString fileName;
00153 
00154     //#
00155     //# Switched from QTextStream to ifstream because QTextStream seemed broken
00156     //# on RHEL5 (qt4-4.2.1-1). If this is changed, test on RHEL5 *and* qt 4.2.1.
00157     //#
00158     std::ifstream *logStream;
00159 
00160     QTreeView *logView;
00161     LogModel *logModel;
00162     QSortFilterProxyModel *proxyModel;
00163     QFileSystemWatcher *logWatcher;
00164     qint64 logPos;    
00165     bool canClose;
00166     QCheckBox* lockScroll;
00167     
00168     QMutex mutex;
00169 };
00170 
00171 }
00172 #endif