diff options
author | Gerald Combs <gerald@wireshark.org> | 2012-08-20 04:34:23 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2012-08-20 04:34:23 +0000 |
commit | 2f9b5d31e485af4ac0afd63fe0176c0114defe35 (patch) | |
tree | ae12019f9b9b46bd4d640c0f53e2c8e6e5c6a02f /ui | |
parent | 66115d1200e1041c1f805ee6cff7dec2bc24eadf (diff) |
Basic "Go to Packet" implementation.
svn path=/trunk/; revision=44594
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/main_window.cpp | 41 | ||||
-rw-r--r-- | ui/qt/main_window.h | 4 | ||||
-rw-r--r-- | ui/qt/main_window.ui | 52 | ||||
-rw-r--r-- | ui/qt/packet_list.cpp | 4 | ||||
-rw-r--r-- | ui/qt/proto_tree.cpp | 2 |
5 files changed, 98 insertions, 5 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index f85b99d6fc..8a5e2b341a 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -82,6 +82,10 @@ MainWindow::MainWindow(QWidget *parent) : #endif main_ui_->mainToolBar->addWidget(df_combo_box_); + main_ui_->utilityToolBar->hide(); + + main_ui_->goToFrame->hide(); + splitter_v_ = new QSplitter(main_ui_->mainStack); splitter_v_->setObjectName(QString::fromUtf8("splitterV")); splitter_v_->setOrientation(Qt::Vertical); @@ -157,9 +161,10 @@ void MainWindow::keyPressEvent(QKeyEvent *event) { // The user typed some text. Start filling in a filter. // XXX We need to install an event filter for the packet list and proto tree - if ((event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier) && event->text().length() > 0) { - QApplication::sendEvent(df_combo_box_, event); - } + // XXX Disabled for now. For some reason we crash here when pressing enter in "go to packet". +// if ((event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier) && event->text().length() > 0) { +// QApplication::sendEvent(df_combo_box_, event); +// } // Move up & down the packet list. if (event->key() == Qt::Key_F7) { @@ -417,3 +422,33 @@ void MainWindow::recentActionTriggered() { openRecentCaptureFile(cfPath); } } + +void MainWindow::on_actionGoGoToPacket_triggered() { + if (packet_list_->model()->rowCount() < 1) { + return; + } + main_ui_->goToFrame->show(); + main_ui_->goToLineEdit->setFocus(); +} + +void MainWindow::on_goToCancel_clicked() +{ + main_ui_->goToFrame->hide(); +} + + +void MainWindow::on_goToGo_clicked() +{ + int packet_num = main_ui_->goToLineEdit->text().toInt(); + + main_ui_->goToFrame->hide(); + + if (packet_num > 0) { + packet_list_->goToPacket(packet_num); + } +} + +void MainWindow::on_goToLineEdit_returnPressed() +{ + on_goToGo_clicked(); +} diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index e8e8449ec8..486ff6bb73 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -79,12 +79,16 @@ private slots: void openRecentCaptureFile(QString& cfPath = *new QString()); void on_actionFileClose_triggered(); void recentActionTriggered(); + void on_actionGoGoToPacket_triggered(); void on_actionHelpWebsite_triggered(); void on_actionHelpFAQ_triggered(); void on_actionHelpAsk_triggered(); void on_actionHelpDownloads_triggered(); void on_actionHelpWiki_triggered(); void on_actionHelpSampleCaptures_triggered(); + void on_goToCancel_clicked(); + void on_goToGo_clicked(); + void on_goToLineEdit_returnPressed(); }; diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui index f0e019cb31..587f1bd6de 100644 --- a/ui/qt/main_window.ui +++ b/ui/qt/main_window.ui @@ -34,6 +34,46 @@ <number>0</number> </property> <item row="0" column="0"> + <widget class="QFrame" name="goToFrame"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLineEdit" name="goToLineEdit"> + <property name="inputMask"> + <string>900000000; </string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="goToGo"> + <property name="text"> + <string>Go to packet</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="goToCancel"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> <widget class="QStackedWidget" name="mainStack"> <widget class="MainWelcome" name="welcomePage"/> <widget class="QWidget" name="packetPage"/> @@ -114,6 +154,7 @@ <property name="title"> <string>Go</string> </property> + <addaction name="actionGoGoToPacket"/> <addaction name="separator"/> <addaction name="actionGoNextPacket"/> <addaction name="actionGoPreviousPacket"/> @@ -441,6 +482,17 @@ <string>Ctrl+Left</string> </property> </action> + <action name="actionGoGoToPacket"> + <property name="text"> + <string>Go to Packet...</string> + </property> + <property name="toolTip"> + <string>Go to specified packet</string> + </property> + <property name="shortcut"> + <string>Ctrl+G</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <customwidgets> diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 68b74f118b..fe46b42d4d 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -400,5 +400,7 @@ void PacketList::goLastPacket(void) { } void PacketList::goToPacket(int packet) { - setCurrentIndex(packet_list_model_->index(packet, 0)); + if (packet > 0 && packet <= packet_list_model_->rowCount()) { + setCurrentIndex(packet_list_model_->index(packet - 1, 0)); + } } diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 1c490a3b47..a2c1cacde8 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -328,7 +328,7 @@ void ProtoTree::itemDoubleClick(QTreeWidgetItem *item, int column) { fi = item->data(0, Qt::UserRole).value<field_info *>(); if(fi->hfinfo->type == FT_FRAMENUM) { - emit goToFrame(fi->value.value.uinteger - 1); + emit goToFrame(fi->value.value.uinteger); } if(FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type)) { |