00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00118 bool writeSelection(QString file = QString (),
00119 bool open = true);
00120
00121 private slots:
00122 void found(int pos);
00123 void notFound();
00124 void tabChanged(int pos);
00125 void updateTrace();
00126 void updatePosition(int);
00127 void FinderEditingFinished();
00128 void swapContent(int);
00129 void updateHexDock(int);
00130 void showHexDock(int);
00131
00132 private:
00133 typedef wpl::pcap::indexed_file<> indexed_file;
00134 typedef indexed_file::packet packet;
00135
00136 struct NewProgressDialog
00137 {
00138 NewProgressDialog(QProgressDialog**, QMainWindow*);
00139
00140 void operator () (std::streampos, std::streampos);
00141 private:
00142 QProgressDialog** d_;
00143 QMainWindow* w_;
00144 };
00145
00146 struct UpdateProgressDialog
00147 {
00148 UpdateProgressDialog(QProgressDialog**);
00149
00150 const std::string* operator () (std::streampos);
00151 private:
00152 QProgressDialog** d_;
00153 };
00154
00155 void addTrace(Trace*);
00156 Trace* trace();
00157 const Trace* trace() const;
00158 QString openDirectoryHint() const;
00159
00160 void initWidgets(const MainWindow* w = 0);
00161 void setupMenuBar();
00162 void setupToolBar();
00163 void setupCentralWidget();
00164 void setupStatusBar();
00165 void setupHexDock(const MainWindow* w);
00166 static MainWindow* setupNewWindow(MainWindow* w, bool show);
00167
00168 QTabWidget tabs_;
00169 QLabel trace_name_;
00170 QLabel trace_size_;
00171 QLabel position_;
00172 QComboBox step_;
00173 QSpinBox finder_;
00174 QCheckBox swap_;
00175 QShortcut focus_finder_;
00176 HexDumpDock hexFrameDock_;
00177 std::vector<QAction*> trace_related_actions_;
00178 std::vector<QAction*> tabs_related_actions_;
00179 FindDialog current_search_;
00180 };
00181
00182 }
00183
00184 }
00185
00186 # include "wscout_gui_main_window.hxx"
00187
00188 #endif // ! WSCOUT_GUI_MAIN_WINDOW_HH_