From 448c89e30b2b2ee8168d22fa66fbd030f9cfa22b Mon Sep 17 00:00:00 2001 From: David Morsberger Date: Sun, 3 Jul 2016 19:36:12 -0400 Subject: [PATCH] Remember query after closing Follow Stream Update main filter after follow stream dialog is closed - Use: previous_filter if new 'Back' button (passed in follow() method) filter_out_filter_ if 'Filter Out This Stream' button (built by appending !current_stream to previous_filter) leave filter alone if window closed using Close button or window close. (current stream) Change-Id: Ic02edeaffdc65ff0f33cac4cb9afb8cde28963c7 Reviewed-on: https://code.wireshark.org/review/16277 Reviewed-by: Jim Young Petri-Dish: Jim Young Tested-by: Jim Young Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/qt/follow_stream_dialog.cpp | 32 +++++++++++++++++++++++++++----- ui/qt/follow_stream_dialog.h | 5 +++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index df8764bc1d..4d862d4fac 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -135,6 +135,9 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_ b_save_ = ui->buttonBox->addButton(tr("Save as" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ActionRole); connect(b_save_, SIGNAL(clicked()), this, SLOT(saveAs())); + b_back_ = ui->buttonBox->addButton(tr("Back"), QDialogButtonBox::ActionRole); + connect(b_back_, SIGNAL(clicked()), this, SLOT(backButton())); + ProgressFrame::addToButtonBox(ui->buttonBox, &parent); connect(ui->buttonBox, SIGNAL(helpRequested()), this, SLOT(helpButton())); @@ -300,13 +303,31 @@ void FollowStreamDialog::helpButton() wsApp->helpTopicAction(HELP_FOLLOW_STREAM_DIALOG); } -void FollowStreamDialog::filterOut() +void FollowStreamDialog::backButton() { - emit updateFilter(filter_out_filter_, TRUE); + output_filter_ = previous_filter_; close(); } +void FollowStreamDialog::filterOut() +{ + output_filter_ = filter_out_filter_; + + close(); +} + +void FollowStreamDialog::close() +{ + // Update filter - Use: + // previous_filter if 'Close' (passed in follow() method) + // filter_out_filter_ if 'Filter Out This Stream' (built by appending !current_stream to previous_filter) + // leave filter alone if window closed. (current stream) + emit updateFilter(output_filter_, TRUE); + + WiresharkDialog::close(); +} + void FollowStreamDialog::on_cbDirections_currentIndexChanged(int idx) { switch(idx) @@ -349,7 +370,7 @@ void FollowStreamDialog::on_streamNumberSpinBox_valueChanged(int stream_num) if (file_closed_) return; if (stream_num >= 0) { - follow(QString(), true, stream_num); + follow(previous_filter_, true, stream_num); } } @@ -843,9 +864,9 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index, return false; } - if (follow_type_ == FOLLOW_SSL) + if (follow_type_ == FOLLOW_SSL || follow_type_ == FOLLOW_HTTP) { - /* we got ssl so we can follow */ + /* we got ssl/http so we can follow */ removeStreamControls(); } @@ -865,6 +886,7 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index, return false; } + previous_filter_ = previous_filter; /* append the negation */ if(!previous_filter.isEmpty()) { filter_out_filter_ = QString("%1 and !(%2)") diff --git a/ui/qt/follow_stream_dialog.h b/ui/qt/follow_stream_dialog.h index e4389aed94..0c6996b783 100644 --- a/ui/qt/follow_stream_dialog.h +++ b/ui/qt/follow_stream_dialog.h @@ -70,6 +70,8 @@ private slots: void on_leFind_returnPressed(); void helpButton(); + void backButton(); + void close(); void filterOut(); void useRegexFind(bool use_regex); void findText(bool go_back = true); @@ -108,6 +110,7 @@ private: QPushButton *b_find_; QPushButton *b_print_; QPushButton *b_save_; + QPushButton *b_back_; follow_type_t follow_type_; follow_info_t follow_info_; @@ -116,7 +119,9 @@ private: QString data_out_filename_; static const int max_document_length_; bool truncated_; + QString previous_filter_; QString filter_out_filter_; + QString output_filter_; int client_buffer_count_; int server_buffer_count_; int client_packet_count_;