Diffstat (limited to 'noncore/net/wellenreiter/gui/packetview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/packetview.cpp | 68 |
1 files changed, 60 insertions, 8 deletions
diff --git a/noncore/net/wellenreiter/gui/packetview.cpp b/noncore/net/wellenreiter/gui/packetview.cpp index e0e626c..3d3aa18 100644 --- a/noncore/net/wellenreiter/gui/packetview.cpp +++ b/noncore/net/wellenreiter/gui/packetview.cpp | |||
@@ -17,15 +17,23 @@ | |||
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/opcap.h> | 19 | #include <opie2/opcap.h> |
20 | #include <opie2/odebug.h> | ||
21 | #include <opie2/olistview.h> | ||
20 | 22 | ||
21 | /* QT */ | 23 | /* QT */ |
22 | #include <qtextview.h> | 24 | #include <qfont.h> |
23 | #include <qspinbox.h> | ||
24 | #include <qlabel.h> | 25 | #include <qlabel.h> |
25 | #include <qlayout.h> | 26 | #include <qlayout.h> |
26 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include <qlistview.h> | ||
29 | #include <qobjectlist.h> | ||
30 | #include <qspinbox.h> | ||
31 | #include <qtextview.h> | ||
27 | 32 | ||
28 | using namespace Opie::Net; | 33 | using namespace Opie::Net; |
34 | using namespace Opie::Core; | ||
35 | using namespace Opie::Ui; | ||
36 | |||
29 | PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) | 37 | PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) |
30 | :QFrame( parent, name, f ) | 38 | :QFrame( parent, name, f ) |
31 | { | 39 | { |
@@ -33,8 +41,17 @@ PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) | |||
33 | _number->setPrefix( "Packet # " ); | 41 | _number->setPrefix( "Packet # " ); |
34 | _label = new QLabel( this ); | 42 | _label = new QLabel( this ); |
35 | _label->setText( "eth0 2004/03/08 - 00:00:21" ); | 43 | _label->setText( "eth0 2004/03/08 - 00:00:21" ); |
36 | _list = new QLabel( this ); | 44 | |
45 | _list = new OListView( this ); | ||
46 | _list->addColumn( "#" ); | ||
47 | _list->addColumn( "Packet Type" ); | ||
48 | _list->setColumnAlignment( 0, Qt::AlignCenter ); | ||
49 | _list->setColumnAlignment( 1, Qt::AlignLeft ); | ||
50 | _list->setAllColumnsShowFocus( true ); | ||
51 | _list->setFont( QFont( "Fixed", 8 ) ); | ||
52 | |||
37 | _hex = new QTextView( this ); | 53 | _hex = new QTextView( this ); |
54 | _hex->setFont( QFont( "Fixed", 8 ) ); | ||
38 | 55 | ||
39 | QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); | 56 | QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); |
40 | QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); | 57 | QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); |
@@ -45,13 +62,48 @@ PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) | |||
45 | 62 | ||
46 | _packets.setAutoDelete( true ); | 63 | _packets.setAutoDelete( true ); |
47 | 64 | ||
48 | _list->setText( "<b>[ 802.11 [ LLC [ IP [ UDP [ DHCP ] ] ] ] ]</b>" ); | 65 | connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) ); |
49 | }; | 66 | } |
50 | 67 | ||
51 | void PacketView::add( OPacket* p ) | 68 | void PacketView::add( const OPacket* p ) |
52 | { | 69 | { |
53 | _packets.append( p ); | 70 | _packets.append( p ); |
54 | }; | 71 | // Add Circular Buffer and check for number of elements here |
72 | } | ||
73 | |||
74 | void PacketView::showPacket( int number ) | ||
75 | { | ||
76 | _list->clear(); | ||
77 | _hex->setText(""); | ||
78 | const OPacket* p = _packets.at( number ); | ||
79 | |||
80 | if ( p ) | ||
81 | { | ||
82 | _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 ); | ||
83 | _doHexPacket( p ); | ||
84 | } | ||
85 | else | ||
86 | { | ||
87 | qDebug( "D'oh! No packet!" ); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | void PacketView::_doSubPackets( QObjectList* l, int counter ) | ||
92 | { | ||
93 | if (!l) return; | ||
94 | QObject* o = l->first(); | ||
95 | while ( o ) | ||
96 | { | ||
97 | new OListViewItem( _list, QString::number( counter++ ), o->name() ); | ||
98 | _doSubPackets( const_cast<QObjectList*>( o->children() ), counter ); | ||
99 | o = l->next(); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | void PacketView::_doHexPacket( const OPacket* p ) | ||
104 | { | ||
105 | _hex->setText( p->dump( 16 ) ); | ||
106 | } | ||
55 | 107 | ||
56 | const QString PacketView::getLog() const | 108 | const QString PacketView::getLog() const |
57 | { | 109 | { |
@@ -63,7 +115,7 @@ void PacketView::clear() | |||
63 | _number->setMinValue( 0 ); | 115 | _number->setMinValue( 0 ); |
64 | _number->setMaxValue( 0 ); | 116 | _number->setMaxValue( 0 ); |
65 | _label->setText( "---" ); | 117 | _label->setText( "---" ); |
66 | _list->setText( " <b>-- no Packet available --</b> " ); | 118 | _list->clear(); |
67 | _hex->setText( " <i>-- no Packet available --</i> " ); | 119 | _hex->setText( " <i>-- no Packet available --</i> " ); |
68 | } | 120 | } |
69 | 121 | ||