Diffstat (limited to 'noncore/net/wellenreiter/gui/packetview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/packetview.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/gui/packetview.cpp b/noncore/net/wellenreiter/gui/packetview.cpp index 69438fa..d71111f 100644 --- a/noncore/net/wellenreiter/gui/packetview.cpp +++ b/noncore/net/wellenreiter/gui/packetview.cpp @@ -50,65 +50,76 @@ PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) _list->setFont( QFont( "Fixed", 8 ) ); _hex = new QTextView( this ); _hex->setMargin( 0 ); _hex->setFont( QFont( "Fixed", 8 ) ); QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); hb->addWidget( _label, 5 ); hb->addWidget( _number, 2 ); vb->addWidget( _list, 3 ); vb->addWidget( _hex, 4 ); // allow a bit (4/3) more space _packets.setAutoDelete( true ); connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) ); connect( parent, SIGNAL( currentChanged( QWidget *) ), this, SLOT( activated( QWidget* ) ) ); clear(); } void PacketView::add( const OPacket* p, int size ) { + /* + * don't scroll away when somebody views packages + * while scanning + */ + int value = _number->value(); + bool last = (value == static_cast<int>( _packets.count() ) ); + odebug << "PacketView::add() size = " << size << oendl; if ( size == -1 ) // unlimited buffer { _packets.append( p ); } else { // limited buffer, limit = size - while ( _packets.count() >= size ) + while ( _packets.count() >= static_cast<uint>( size ) ) { _packets.removeFirst(); + --value; } + + /* check if we lost our packet */ + last = ( value < 1 ); _packets.append( p ); } _number->setMinValue( 1 ); _number->setMaxValue( _packets.count() ); - _number->setValue( _packets.count() ); + _number->setValue( last ? _packets.count() : value ); } void PacketView::showPacket( int number ) { _list->clear(); _hex->setText(""); const OPacket* p = _packets.at( number-1 ); if ( p ) { _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 ); _doHexPacket( p ); QDateTime dt; dt.setTime_t( p->timeval().tv_sec ); _label->setText( dt.toString() + QString().sprintf( " Len=%d", p->len() ) ); } else { odebug << "D'oh! No packet!" << oendl; } } void PacketView::activated( QWidget* w ) { if ( ( this == w ) && _packets.count() ) @@ -118,36 +129,37 @@ void PacketView::activated( QWidget* w ) } void PacketView::_doSubPackets( QObjectList* l, int counter ) { if (!l) return; QObject* o = l->first(); while ( o ) { new OListViewItem( _list, QString::number( counter++ ), o->name() ); _doSubPackets( const_cast<QObjectList*>( o->children() ), counter ); o = l->next(); } } void PacketView::_doHexPacket( const OPacket* p ) { if ( oApp->desktop()->width() > 320 ) _hex->setText( p->dump( 16 ) ); else _hex->setText( p->dump( 8 ) ); } const QString PacketView::getLog() const { + return QString::null; } void PacketView::clear() { _packets.clear(); _number->setMinValue( 0 ); _number->setMaxValue( 0 ); _label->setText( "---" ); _list->clear(); _hex->setText( " <center><i>-- no Packet available --</i></center> " ); } |