diff options
author | Michael Mann <mmann78@netscape.net> | 2017-11-23 14:22:45 -0500 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2017-11-23 20:45:41 +0000 |
commit | 76d7b7a519792fb51ad6694ddc11a506247aba40 (patch) | |
tree | c0061bd178593e1e4c578b5b07fdb6af30e6a764 | |
parent | ea6204cab695d5a9d15fc5b26379a8eb8a8fc463 (diff) |
Qt: Add menu option to remove all packet comments
Bug: 14186
Change-Id: I8793078ea50379b2f9697787e6b7a8ab2d9e3e0e
Reviewed-on: https://code.wireshark.org/review/24558
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r-- | ui/qt/main_window.h | 1 | ||||
-rw-r--r-- | ui/qt/main_window.ui | 9 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 19 | ||||
-rw-r--r-- | ui/qt/packet_list.cpp | 19 | ||||
-rw-r--r-- | ui/qt/packet_list.h | 1 |
5 files changed, 49 insertions, 0 deletions
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index b722ae2061..ad7e6c8a23 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -471,6 +471,7 @@ private slots: void on_actionEditPreviousTimeReference_triggered(); void on_actionEditTimeShift_triggered(); void on_actionEditPacketComment_triggered(); + void on_actionDeleteAllPacketComments_triggered(); void on_actionEditConfigurationProfiles_triggered(); void showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane = PreferencesDialog::ppAppearance); void showPreferencesDialog(QString module_name); diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui index 32bc227961..17d5d3242c 100644 --- a/ui/qt/main_window.ui +++ b/ui/qt/main_window.ui @@ -656,6 +656,7 @@ <addaction name="actionEditTimeShift"/> <addaction name="separator"/> <addaction name="actionEditPacketComment"/> + <addaction name="actionDeleteAllPacketComments"/> <addaction name="separator"/> <addaction name="actionEditConfigurationProfiles"/> <addaction name="actionEditPreferences"/> @@ -1635,6 +1636,14 @@ <string notr="true">Ctrl+Alt+C</string> </property> </action> + <action name="actionDeleteAllPacketComments"> + <property name="text"> + <string>Delete All Packet Comments</string> + </property> + <property name="toolTip"> + <string>Remove all packet comments in the capture file</string> + </property> + </action> <action name="actionEditConfigurationProfiles"> <property name="checkable"> <bool>false</bool> diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index e86d885f40..3b626411c3 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -1322,6 +1322,7 @@ void MainWindow::setMenusForSelectedPacket() // frame_selected); #endif // WANT_PACKET_EDITOR main_ui_->actionEditPacketComment->setEnabled(frame_selected && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET)); + main_ui_->actionDeleteAllPacketComments->setEnabled((capture_file_.capFile() != NULL) && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET)); main_ui_->actionEditIgnorePacket->setEnabled(frame_selected); main_ui_->actionEditIgnoreAllDisplayed->setEnabled(have_filtered); @@ -2248,6 +2249,24 @@ void MainWindow::on_actionEditPacketComment_triggered() } } +void MainWindow::on_actionDeleteAllPacketComments_triggered() +{ + QMessageBox msg_dialog; + + msg_dialog.setIcon(QMessageBox::Question); + msg_dialog.setText(tr("Are you sure you want to remove all packet comments?")); + + msg_dialog.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msg_dialog.setDefaultButton(QMessageBox::Ok); + + if (msg_dialog.exec() == QMessageBox::Ok) + { + /* XXX Do we need a wait/hourglass for large files? */ + packet_list_->deleteAllPacketComments(); + updateForUnsavedChanges(); + } +} + void MainWindow::on_actionEditConfigurationProfiles_triggered() { ProfileDialog cp_dialog; diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 20d9edf742..b2c53a9e63 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -1141,6 +1141,25 @@ QString PacketList::allPacketComments() return buf_str; } +void PacketList::deleteAllPacketComments() +{ + guint32 framenum; + frame_data *fdata; + QString buf_str; + + if (!cap_file_) + return; + + for (framenum = 1; framenum <= cap_file_->count ; framenum++) { + fdata = frame_data_sequence_find(cap_file_->frames, framenum); + + cf_set_user_packet_comment(cap_file_, fdata, NULL); + } + + redrawVisiblePackets(); +} + + // Slots void PacketList::setCaptureFile(capture_file *cf) diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index 93714844ce..95f5031a8e 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -84,6 +84,7 @@ public: QString packetComment(); void setPacketComment(QString new_comment); QString allPacketComments(); + void deleteAllPacketComments(); void setVerticalAutoScroll(bool enabled = true); void setCaptureInProgress(bool in_progress = false) { capture_in_progress_ = in_progress; tail_at_end_ = in_progress; } void captureFileReadFinished(); |