Qt: IOGraph display filter graph added

Add a graph for the currently display filter if none exists, upon
opening IOGraph

Change-Id: Ic25b014484898dd1917b13f2616fd519e2e8183b
Reviewed-on: https://code.wireshark.org/review/34984
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Roland Knall 2019-11-05 13:36:18 +00:00
parent 499d912f4b
commit a218460e22
4 changed files with 19 additions and 3 deletions

View File

@ -37,6 +37,8 @@ since version 3.1.0:
* You can once again mark and unmark packets using the middle mouse button. * You can once again mark and unmark packets using the middle mouse button.
This feature went missing around 2009 or so. This feature went missing around 2009 or so.
* The Windows packages are now built using Microsoft Visual Studio 2019. * The Windows packages are now built using Microsoft Visual Studio 2019.
* IOGraph automatically adds a graph for the selected display filter if no
previous graph exists
The following features are new (or have been significantly updated) The following features are new (or have been significantly updated)
since version 3.0.0: since version 3.0.0:

View File

@ -286,7 +286,7 @@ static void io_graph_free_cb(void* p) {
} // extern "C" } // extern "C"
IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) : IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf, QString displayFilter) :
WiresharkDialog(parent, cf), WiresharkDialog(parent, cf),
ui(new Ui::IOGraphDialog), ui(new Ui::IOGraphDialog),
uat_model_(NULL), uat_model_(NULL),
@ -393,13 +393,22 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) :
tracer_ = new QCPItemTracer(iop); tracer_ = new QCPItemTracer(iop);
loadProfileGraphs(); loadProfileGraphs();
bool filterExists = false;
if (num_io_graphs_ > 0) { if (num_io_graphs_ > 0) {
for (guint i = 0; i < num_io_graphs_; i++) { for (guint i = 0; i < num_io_graphs_; i++) {
createIOGraph(i); createIOGraph(i);
if ( ioGraphs_.at(i)->filter().compare(displayFilter) == 0 )
filterExists = true;
} }
if ( ! filterExists && displayFilter.length() > 0 )
addGraph(true, tr("Filtered packets"), displayFilter, ColorUtils::graphColor(num_io_graphs_),
IOGraph::psLine, IOG_ITEM_UNIT_PACKETS, QString(), DEFAULT_MOVING_AVERAGE);
} else { } else {
addDefaultGraph(true, 0); addDefaultGraph(true, 0);
addDefaultGraph(true, 1); addDefaultGraph(true, 1);
if ( displayFilter.length() > 0 )
addGraph(true, tr("Filtered packets"), displayFilter, ColorUtils::graphColor(num_io_graphs_),
IOGraph::psLine, IOG_ITEM_UNIT_PACKETS, QString(), DEFAULT_MOVING_AVERAGE);
} }
toggleTracerStyle(true); toggleTracerStyle(true);

View File

@ -130,7 +130,7 @@ class IOGraphDialog : public WiresharkDialog
Q_OBJECT Q_OBJECT
public: public:
explicit IOGraphDialog(QWidget &parent, CaptureFile &cf); explicit IOGraphDialog(QWidget &parent, CaptureFile &cf, QString displayFilter = QString());
~IOGraphDialog(); ~IOGraphDialog();
enum UatColumns { colEnabled = 0, colName, colDFilter, colColor, colStyle, colYAxis, colYField, colSMAPeriod, colMaxNum}; enum UatColumns { colEnabled = 0, colName, colDFilter, colColor, colStyle, colYAxis, colYField, colSMAPeriod, colMaxNum};

View File

@ -3131,7 +3131,12 @@ void MainWindow::on_actionStatisticsPacketLengths_triggered()
// -z io,stat // -z io,stat
void MainWindow::statCommandIOGraph(const char *, void *) void MainWindow::statCommandIOGraph(const char *, void *)
{ {
IOGraphDialog *iog_dialog = new IOGraphDialog(*this, capture_file_); const DisplayFilterEdit *df_edit = qobject_cast<DisplayFilterEdit *>(df_combo_box_->lineEdit());
QString displayFilter;
if ( df_edit )
displayFilter = df_edit->text();
IOGraphDialog *iog_dialog = new IOGraphDialog(*this, capture_file_, displayFilter);
connect(iog_dialog, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int))); connect(iog_dialog, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
connect(this, SIGNAL(reloadFields()), iog_dialog, SLOT(reloadFields())); connect(this, SIGNAL(reloadFields()), iog_dialog, SLOT(reloadFields()));
iog_dialog->show(); iog_dialog->show();