src/wscout_gui_main_window.hh

00001 /*
00002  * WScout - Lightweight PCAP visualizer.
00003  * Copyright (C) 2007, 2008  Universite Pierre et Marie Curie - Paris 6
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00018  * MA  02110-1301  USA
00019  *
00020  * Author: Thomas Claveirole <thomas.claveirole@lip6.fr>
00021  */
00022 
00023 #ifndef WSCOUT_GUI_MAIN_WINDOW_HH_
00024 # define WSCOUT_GUI_MAIN_WINDOW_HH_
00025 
00026 # include <QtGui/QMainWindow>
00027 # include <QtGui/QLabel>
00028 # include <QtGui/QProgressDialog>
00029 # include <QtGui/QSpinBox>
00030 # include <QtGui/QShortcut>
00031 # include <QtGui/QComboBox>
00032 # include <QtGui/QCheckBox>
00033 # include <QtGui/QTabWidget>
00034 
00035 # include "wscout_gui_trace.hh"
00036 # include "wscout_gui_hex_dump_dock.hh"
00037 # include "wscout_gui_find_dialog.hh"
00038 
00039 namespace wscout
00040 {
00041 
00042   namespace gui
00043   {
00044 
00046     class MainWindow : public QMainWindow
00047     {
00048       Q_OBJECT
00049 
00050       enum
00051       {
00052         status_bar_vmargin      = 1,    
00053         status_bar_hmargin      = 4     
00054       };
00055 
00056     public:
00058       MainWindow();
00059 
00061       MainWindow(const MainWindow&);
00062 
00063     public slots:
00065       bool              open(const QString& directoryHint = QString ());
00066 
00068       bool              openTrace(const QString&);
00069 
00071       bool              openInNewWindow() const;
00072 
00074       MainWindow*       duplicateWindow() const;
00075 
00077       MainWindow*       newWindow(bool show = true) const;
00078 
00084       void      closeTab();
00085 
00087       void      filter();
00088 
00090       void      find(bool show = true);
00091 
00093       void      stepTab(int);
00094 
00096       void      prevTab();
00097 
00099       void      nextTab();
00100 
00102       void      begin();
00103 
00104 
00106       void      end();
00107 
00109       void      forward();
00110 
00112       void      backward();
00113 
00115       void      about();
00116 
00117     private slots:
00118       void      found(int pos);
00119       void      notFound();
00120       void      tabChanged(int pos);
00121       void      updateTrace();
00122       void      updatePosition(int);
00123       void      FinderEditingFinished();
00124       void      swapContent(int);
00125       void      updateHexDock(int);
00126       void      showHexDock(int);
00127 
00128     private:
00129       struct NewProgressDialog
00130       {
00131         NewProgressDialog(QProgressDialog**, QMainWindow*);
00132 
00133         void    operator () (std::streampos, std::streampos);
00134       private:
00135         QProgressDialog**       d_;
00136         QMainWindow*            w_;
00137       };
00138 
00139       struct UpdateProgressDialog
00140       {
00141         UpdateProgressDialog(QProgressDialog**);
00142 
00143         const std::string*      operator () (std::streampos);
00144       private:
00145         QProgressDialog**       d_;
00146       };
00147 
00148       void              addTrace(Trace*);
00149       Trace*            trace();
00150       const Trace*      trace() const;
00151       QString           openDirectoryHint() const;
00152 
00153       void                      initWidgets(const MainWindow* w = 0);
00154       void                      setupMenuBar();
00155       void                      setupToolBar();
00156       void                      setupCentralWidget();
00157       void                      setupStatusBar();
00158       void                      setupHexDock(const MainWindow* w);
00159       static MainWindow*        setupNewWindow(MainWindow* w, bool show);
00160 
00161       QTabWidget                tabs_;
00162       QLabel                    trace_name_;
00163       QLabel                    trace_size_;
00164       QLabel                    position_;
00165       QComboBox                 step_;
00166       QSpinBox                  finder_;
00167       QCheckBox                 swap_;
00168       QShortcut                 focus_finder_;
00169       HexDumpDock               hexFrameDock_;
00170       std::vector<QAction*>     trace_related_actions_;
00171       std::vector<QAction*>     tabs_related_actions_;
00172       FindDialog                current_search_;
00173     };
00174 
00175   } // End of namespace gui.
00176 
00177 } // End of namespace wscout.
00178 
00179 # include "wscout_gui_main_window.hxx"
00180 
00181 #endif // ! WSCOUT_GUI_MAIN_WINDOW_HH_

Generated on Wed Jan 30 19:02:27 2008 for WScout by  doxygen 1.5.4