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_PACKET_HH_
00024 # define WSCOUT_GUI_PACKET_HH_
00025
00026 # include <vector>
00027 # include <map>
00028
00029 # include <QtGui/QFrame>
00030 # include <QtGui/QBoxLayout>
00031
00032 # include "wscout_pcap_trace.hh"
00033 # include "wscout_gui_pcap_header.hh"
00034 # include "wscout_gui_abstract_header.hh"
00035
00036 namespace wscout
00037 {
00038
00039 namespace gui
00040 {
00041
00051 class Packet: public QFrame
00052 {
00053 Q_OBJECT
00054
00055 enum
00056 {
00058 header_spacing = 1,
00059
00061 border_sel = 4,
00062
00064 packet_margin_sel = 0,
00065
00067 border_unsel = 1,
00068
00070 packet_margin_unsel = 3
00071
00072 };
00073
00074 public:
00076 typedef pcap::Trace::iterator::value_type packet;
00077
00079 typedef pcap::Trace::link_type link_type;
00080
00082 Packet(QWidget* parent = 0);
00083
00086 void setup(link_type t, unsigned n, const packet& p);
00087
00089 QBoxLayout* layout();
00090
00092 typedef AbstractHeader* (*header_allocator)();
00093
00107 static void registerProtocol(protocol::id, header_allocator);
00108
00110 typedef std::map<protocol::id, header_allocator> protocol_map;
00111
00118 static protocol_map& protocols();
00119
00120 public slots:
00121
00123 void setSelected(bool state = true);
00124
00125 private:
00126 int lineWidth() const;
00127 int margin() const;
00128 void setupBorders();
00129 void setupLayout();
00130 void updateMinimumSize();
00131
00132
00133 PcapHeader pcap_;
00134 std::vector<AbstractHeader*> headers_;
00135 bool selected_;
00136 };
00137
00138 }
00139
00140 }
00141
00142 #endif // ! WSCOUT_GUI_PACKET_HH_