Add keyboard shortcuts for the packet list.

svn path=/trunk/; revision=44462
This commit is contained in:
Gerald Combs 2012-08-13 01:50:14 +00:00
parent e211327f65
commit 603787f0ad
5 changed files with 122 additions and 49 deletions

View File

@ -35,7 +35,6 @@
#include "ui/main_statusbar.h"
#include "wireshark_application.h"
#include "packet_list.h"
#include "proto_tree.h"
#include "byte_view_tab.h"
#include "capture_file_dialog.h"
@ -86,7 +85,7 @@ MainWindow::MainWindow(QWidget *parent) :
splitterV->setObjectName(QString::fromUtf8("splitterV"));
splitterV->setOrientation(Qt::Vertical);
PacketList *packetList = new PacketList(splitterV);
m_packetList = new PacketList(splitterV);
ProtoTree *protoTree = new ProtoTree(splitterV);
protoTree->setHeaderHidden(true);
@ -95,10 +94,10 @@ MainWindow::MainWindow(QWidget *parent) :
byteViewTab->setTabPosition(QTabWidget::South);
byteViewTab->setDocumentMode(true);
packetList->setProtoTree(protoTree);
packetList->setByteViewTab(byteViewTab);
m_packetList->setProtoTree(protoTree);
m_packetList->setByteViewTab(byteViewTab);
splitterV->addWidget(packetList);
splitterV->addWidget(m_packetList);
splitterV->addWidget(protoTree);
splitterV->addWidget(byteViewTab);
@ -138,6 +137,12 @@ void MainWindow::keyPressEvent(QKeyEvent *event) {
return;
}
if (event->key() == Qt::Key_F7) {
m_packetList->goToPrev();
} else if (event->key() == Qt::Key_F8) {
m_packetList->goToNext();
}
QMainWindow::keyPressEvent(event);
}
@ -191,9 +196,26 @@ void MainWindow::captureFileClosing(const capture_file *cf) {
// gtk_widget_show(expert_info_none);
}
/* Help Menu */
void MainWindow::on_actionHelpWebsite_triggered() {
// Go Menu
void MainWindow::on_actionGoNextPacket_triggered() {
m_packetList->goToNext();
}
void MainWindow::on_actionGoPreviousPacket_triggered() {
m_packetList->goToPrev();
}
void MainWindow::on_actionGoFirstPacket_triggered() {
m_packetList->goToFirst();
}
void MainWindow::on_actionGoLastPacket_triggered() {
m_packetList->goToLast();
}
// Help Menu
void MainWindow::on_actionHelpWebsite_triggered() {
QDesktopServices::openUrl(QUrl("http://www.wireshark.org"));
}

View File

@ -35,6 +35,7 @@
#include <QMainWindow>
#include <QSplitter>
#include "main_welcome.h"
#include "packet_list.h"
#include "display_filter_combo.h"
#include "progress_bar.h"
@ -62,6 +63,7 @@ private:
MainWelcome *mainWelcome;
DisplayFilterCombo *dfComboBox;
capture_file *capFile;
PacketList *m_packetList;
signals:
void showProgress(progdlg_t **dlg_p, bool animate, const QString message, bool terminate_is_stop, bool *stop_flag, float pct);
@ -77,6 +79,10 @@ private slots:
void updateRecentFiles();
void openCaptureFile(QString& cfPath = *new QString());
void recentActionTriggered();
void on_actionGoNextPacket_triggered();
void on_actionGoPreviousPacket_triggered();
void on_actionGoFirstPacket_triggered();
void on_actionGoLastPacket_triggered();
void on_actionHelpWebsite_triggered();
void on_actionHelpFAQ_triggered();
void on_actionHelpAsk_triggered();

View File

@ -47,7 +47,7 @@
<x>0</x>
<y>0</y>
<width>960</width>
<height>23</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -110,8 +110,19 @@
<addaction name="separator"/>
<addaction name="actionHelpAbout"/>
</widget>
<widget class="QMenu" name="menuGo">
<property name="title">
<string>Go</string>
</property>
<addaction name="separator"/>
<addaction name="actionGoNextPacket"/>
<addaction name="actionGoPreviousPacket"/>
<addaction name="actionGoFirstPacket"/>
<addaction name="actionGoLastPacket"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuGo"/>
<addaction name="menuCapture"/>
<addaction name="menuHelp"/>
</widget>
@ -331,6 +342,50 @@
<string>Ask (Q&amp;&amp;A)</string>
</property>
</action>
<action name="actionGoNextPacket">
<property name="text">
<string>Next Packet</string>
</property>
<property name="toolTip">
<string>Go to the next packet</string>
</property>
<property name="shortcut">
<string>Ctrl+Down</string>
</property>
</action>
<action name="actionGoPreviousPacket">
<property name="text">
<string>Previous Packet</string>
</property>
<property name="toolTip">
<string>Go to the previous packet</string>
</property>
<property name="shortcut">
<string>Ctrl+Up</string>
</property>
</action>
<action name="actionGoFirstPacket">
<property name="text">
<string>First Packet</string>
</property>
<property name="toolTip">
<string>Go to the first packet</string>
</property>
<property name="shortcut">
<string>Ctrl+Home</string>
</property>
</action>
<action name="actionGoLastPacket">
<property name="text">
<string>Last Packet</string>
</property>
<property name="toolTip">
<string>Go to the last packet</string>
</property>
<property name="shortcut">
<string>Ctrl+End</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View File

@ -94,27 +94,19 @@ g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_resize_column %d", col);
void
new_packet_list_select_first_row(void)
{
cur_packet_list->setCurrentIndex(cur_packet_list->packetListModel()->index(0,0));
if (!cur_packet_list)
return;
cur_packet_list->goToFirst();
cur_packet_list->setFocus();
}
void
new_packet_list_select_last_row(void)
{
g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_select_last_row");
// GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
// GtkTreeIter iter;
// gint children;
// guint last_row;
// if((children = gtk_tree_model_iter_n_children(model, NULL)) == 0)
// return;
// last_row = children-1;
// if(!gtk_tree_model_iter_nth_child(model, &iter, NULL, last_row))
// return;
// scroll_to_and_select_iter(model, NULL, &iter);
if (!cur_packet_list)
return;
cur_packet_list->goToLast();
cur_packet_list->setFocus();
}
/*
@ -224,32 +216,8 @@ new_packet_list_get_row_data(gint row)
void
new_packet_list_moveto_end(void)
{
// GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
// GtkTreeIter iter;
// GtkTreePath *path;
// gint children;
// guint last_row;
g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_moveto_end");
// if((children = gtk_tree_model_iter_n_children(model, NULL)) == 0)
// return;
// last_row = children-1;
// if(!gtk_tree_model_iter_nth_child(model, &iter, NULL, last_row))
// return;
// path = gtk_tree_model_get_path(model, &iter);
// gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(packetlist->view),
// path,
// NULL,
// TRUE, /* use_align */
// 0.5, /* row_align determines where the row is placed, 0.5 means center */
// 0); /* The horizontal alignment of the column */
// gtk_tree_path_free(path);
if (cur_packet_list)
cur_packet_list->goToLast();
}
/* Redraw the packet list *and* currently-selected detail */
@ -410,3 +378,21 @@ void PacketList::writeRecent(FILE *rf) {
fprintf (rf, "\n");
}
#include <QDebug>
void PacketList::goToNext(void) {
setCurrentIndex(moveCursor(MoveDown, Qt::NoModifier));
}
void PacketList::goToPrev(void) {
setCurrentIndex(moveCursor(MoveUp, Qt::NoModifier));
}
void PacketList::goToFirst(void) {
setCurrentIndex(moveCursor(MoveHome, Qt::NoModifier));
}
void PacketList::goToLast(void) {
setCurrentIndex(moveCursor(MoveEnd, Qt::NoModifier));
}

View File

@ -42,6 +42,10 @@ public:
void setByteViewTab(ByteViewTab *byteViewTab);
void clear();
void writeRecent(FILE *rf);
void goToNext();
void goToPrev();
void goToFirst();
void goToLast();
protected:
void showEvent (QShowEvent *event);