diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-06-28 11:18:26 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-06-29 17:22:34 +0000 |
commit | 0b0100befa7480bbebb82708a98d4932043b9640 (patch) | |
tree | bbcfedc5a31e0b346c246e46f48a95f7f049f83e | |
parent | 5ae8c92aa0dfc70a1e76b8100702a285bc2638e4 (diff) |
Fixup the packet list navigation action behavior.
Change-Id: I124fe3c3755556e81c65443b8b9744a89394dc70
Reviewed-on: https://code.wireshark.org/review/9218
Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r-- | ui/qt/packet_list.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index de4ce5bdeb..c6bea960bd 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -986,24 +986,38 @@ void PacketList::setMonospaceFont(const QFont &mono_font) } void PacketList::goNextPacket(void) { - if (!selectionModel()->hasSelection()) return; - setCurrentIndex(moveCursor(MoveDown, Qt::NoModifier)); + if (selectionModel()->hasSelection()) { + setCurrentIndex(moveCursor(MoveDown, Qt::NoModifier)); + } else { + // First visible packet. + setCurrentIndex(indexAt(viewport()->rect().topLeft())); + } } void PacketList::goPreviousPacket(void) { - if (!selectionModel()->hasSelection()) return; - setCurrentIndex(moveCursor(MoveUp, Qt::NoModifier)); + if (selectionModel()->hasSelection()) { + setCurrentIndex(moveCursor(MoveUp, Qt::NoModifier)); + } else { + // Last visible packet. + QModelIndex last_idx = indexAt(viewport()->rect().bottomLeft()); + if (last_idx.isValid()) { + setCurrentIndex(last_idx); + } else { + goLastPacket(); + } + } } void PacketList::goFirstPacket(void) { if (packet_list_model_->rowCount() < 1) return; setCurrentIndex(packet_list_model_->index(0, 0)); + scrollTo(currentIndex()); } void PacketList::goLastPacket(void) { if (packet_list_model_->rowCount() < 1) return; - setCurrentIndex(packet_list_model_->index(0, 0)); - setCurrentIndex(moveCursor(MoveEnd, Qt::NoModifier)); + setCurrentIndex(packet_list_model_->index(packet_list_model_->rowCount() - 1, 0)); + scrollTo(currentIndex()); } // XXX We can jump to the wrong packet if a display filter is applied |