-rw-r--r-- | noncore/net/wellenreiter/gui/packetview.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/noncore/net/wellenreiter/gui/packetview.cpp b/noncore/net/wellenreiter/gui/packetview.cpp index f0f16ff..69438fa 100644 --- a/noncore/net/wellenreiter/gui/packetview.cpp +++ b/noncore/net/wellenreiter/gui/packetview.cpp | |||
@@ -48,67 +48,69 @@ PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) | |||
48 | _list->setColumnAlignment( 1, Qt::AlignLeft ); | 48 | _list->setColumnAlignment( 1, Qt::AlignLeft ); |
49 | _list->setAllColumnsShowFocus( true ); | 49 | _list->setAllColumnsShowFocus( true ); |
50 | _list->setFont( QFont( "Fixed", 8 ) ); | 50 | _list->setFont( QFont( "Fixed", 8 ) ); |
51 | 51 | ||
52 | _hex = new QTextView( this ); | 52 | _hex = new QTextView( this ); |
53 | _hex->setMargin( 0 ); | 53 | _hex->setMargin( 0 ); |
54 | _hex->setFont( QFont( "Fixed", 8 ) ); | 54 | _hex->setFont( QFont( "Fixed", 8 ) ); |
55 | 55 | ||
56 | QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); | 56 | QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); |
57 | QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); | 57 | QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); |
58 | hb->addWidget( _label, 5 ); | 58 | hb->addWidget( _label, 5 ); |
59 | hb->addWidget( _number, 2 ); | 59 | hb->addWidget( _number, 2 ); |
60 | vb->addWidget( _list, 3 ); | 60 | vb->addWidget( _list, 3 ); |
61 | vb->addWidget( _hex, 4 ); // allow a bit (4/3) more space | 61 | vb->addWidget( _hex, 4 ); // allow a bit (4/3) more space |
62 | 62 | ||
63 | _packets.setAutoDelete( true ); | 63 | _packets.setAutoDelete( true ); |
64 | 64 | ||
65 | connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) ); | 65 | connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) ); |
66 | connect( parent, SIGNAL( currentChanged( QWidget *) ), this, SLOT( activated( QWidget* ) ) ); | 66 | connect( parent, SIGNAL( currentChanged( QWidget *) ), this, SLOT( activated( QWidget* ) ) ); |
67 | 67 | ||
68 | clear(); | 68 | clear(); |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | void PacketView::add( const OPacket* p, int size ) | 72 | void PacketView::add( const OPacket* p, int size ) |
73 | { | 73 | { |
74 | odebug << "PacketView::add() size = " << size << oendl; | 74 | odebug << "PacketView::add() size = " << size << oendl; |
75 | if ( size == -1 ) // unlimited buffer | 75 | if ( size == -1 ) // unlimited buffer |
76 | { | 76 | { |
77 | _packets.append( p ); | 77 | _packets.append( p ); |
78 | } | 78 | } |
79 | else | 79 | else |
80 | // limited buffer, limit = size | 80 | { // limited buffer, limit = size |
81 | if ( _packets.count() < size ) | 81 | while ( _packets.count() >= size ) |
82 | { | 82 | { |
83 | _packets.removeFirst(); | ||
84 | } | ||
83 | _packets.append( p ); | 85 | _packets.append( p ); |
84 | } | 86 | } |
85 | 87 | ||
86 | _number->setMinValue( 1 ); | 88 | _number->setMinValue( 1 ); |
87 | _number->setMaxValue( _packets.count() ); | 89 | _number->setMaxValue( _packets.count() ); |
88 | _number->setValue( _packets.count() ); | 90 | _number->setValue( _packets.count() ); |
89 | } | 91 | } |
90 | 92 | ||
91 | void PacketView::showPacket( int number ) | 93 | void PacketView::showPacket( int number ) |
92 | { | 94 | { |
93 | _list->clear(); | 95 | _list->clear(); |
94 | _hex->setText(""); | 96 | _hex->setText(""); |
95 | const OPacket* p = _packets.at( number-1 ); | 97 | const OPacket* p = _packets.at( number-1 ); |
96 | 98 | ||
97 | if ( p ) | 99 | if ( p ) |
98 | { | 100 | { |
99 | _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 ); | 101 | _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 ); |
100 | _doHexPacket( p ); | 102 | _doHexPacket( p ); |
101 | QDateTime dt; dt.setTime_t( p->timeval().tv_sec ); | 103 | QDateTime dt; dt.setTime_t( p->timeval().tv_sec ); |
102 | _label->setText( dt.toString() + QString().sprintf( " Len=%d", p->len() ) ); | 104 | _label->setText( dt.toString() + QString().sprintf( " Len=%d", p->len() ) ); |
103 | } | 105 | } |
104 | else | 106 | else |
105 | { | 107 | { |
106 | odebug << "D'oh! No packet!" << oendl; | 108 | odebug << "D'oh! No packet!" << oendl; |
107 | } | 109 | } |
108 | } | 110 | } |
109 | 111 | ||
110 | void PacketView::activated( QWidget* w ) | 112 | void PacketView::activated( QWidget* w ) |
111 | { | 113 | { |
112 | if ( ( this == w ) && _packets.count() ) | 114 | if ( ( this == w ) && _packets.count() ) |
113 | { | 115 | { |
114 | _number->setValue( 1 ); | 116 | _number->setValue( 1 ); |