diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2018-10-05 23:35:14 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-10-07 05:37:48 +0000 |
commit | d7cf0086fcb1c9e692c0c34aa6afb0dad4bf02f3 (patch) | |
tree | cd58c9f12458cbf4ed24facd5aaa644cfd8a4f9a /ui/qt/io_graph_dialog.cpp | |
parent | 3e78bdcccede58bf983db9ac4f7df24082a1cc5b (diff) |
Qt: Add copy from another profile for IO Graphs
Add a new button to the IO Graphs dialog to copy entries from
another profile. Add a clear all button to easily remove all
existing entries before copying.
Change-Id: I66cb27163663e5f2223d0dd3f8566f0fbebb553c
Reviewed-on: https://code.wireshark.org/review/30043
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/io_graph_dialog.cpp')
-rw-r--r-- | ui/qt/io_graph_dialog.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ui/qt/io_graph_dialog.cpp b/ui/qt/io_graph_dialog.cpp index 4720c95ee4..43b0fa9e80 100644 --- a/ui/qt/io_graph_dialog.cpp +++ b/ui/qt/io_graph_dialog.cpp @@ -29,6 +29,7 @@ #include <wsutil/report_message.h> #include <ui/qt/utils/tango_colors.h> //provides some default colors +#include <ui/qt/widgets/copy_from_profile_button.h> #include "ui/qt/widgets/wireshark_file_dialog.h" #include <QClipboard> @@ -42,6 +43,7 @@ #include <QSpacerItem> #include <QTimer> #include <QVariant> +#include <QMenu> // Bugs and uncertainties: // - Regular (non-stacked) bar graphs are drawn on top of each other on the Z axis. @@ -313,6 +315,10 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) : QPushButton *copy_bt = ui->buttonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole); connect (copy_bt, SIGNAL(clicked()), this, SLOT(copyAsCsvClicked())); + QPushButton *copy_from_bt = new CopyFromProfileButton("io_graphs"); + ui->buttonBox->addButton(copy_from_bt, QDialogButtonBox::ActionRole); + connect(copy_from_bt->menu(), SIGNAL(triggered(QAction *)), this, SLOT(copyFromProfile(QAction *))); + QPushButton *close_bt = ui->buttonBox->button(QDialogButtonBox::Close); if (close_bt) { close_bt->setDefault(true); @@ -387,6 +393,8 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) : iop->rescaleAxes(); + ui->clearToolButton->setEnabled(uat_model_->rowCount() != 0); + //XXX - resize columns? ProgressFrame::addToButtonBox(ui->buttonBox, &parent); @@ -407,6 +415,24 @@ IOGraphDialog::~IOGraphDialog() ui = NULL; } +void IOGraphDialog::copyFromProfile(QAction *action) +{ + QString filename = action->data().toString(); + guint orig_data_len = iog_uat_->raw_data->len; + + gchar *err = NULL; + if (uat_load(iog_uat_, filename.toUtf8().constData(), &err)) { + iog_uat_->changed = TRUE; + uat_model_->reloadUat(); + for (guint i = orig_data_len; i < iog_uat_->raw_data->len; i++) { + createIOGraph(i); + } + } else { + report_failure("Error while loading %s: %s", iog_uat_->name, err); + g_free(err); + } +} + void IOGraphDialog::addGraph(bool checked, QString name, QString dfilter, int color_idx, IOGraph::PlotStyles style, io_graph_item_unit_t value_units, QString yfield, int moving_average) { // should not fail, but you never know. @@ -1147,6 +1173,7 @@ void IOGraphDialog::loadProfileGraphs() connect(uat_model_, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelDataChanged(QModelIndex))); + connect(uat_model_, SIGNAL(modelReset()), this, SLOT(modelRowsReset())); } // Slots @@ -1189,14 +1216,23 @@ void IOGraphDialog::on_todCheckBox_toggled(bool checked) mouseMoved(NULL); // Update hint } +void IOGraphDialog::modelRowsReset() +{ + ui->deleteToolButton->setEnabled(false); + ui->copyToolButton->setEnabled(false); + ui->clearToolButton->setEnabled(uat_model_->rowCount() != 0); +} + void IOGraphDialog::on_graphUat_currentItemChanged(const QModelIndex ¤t, const QModelIndex&) { if (current.isValid()) { ui->deleteToolButton->setEnabled(true); ui->copyToolButton->setEnabled(true); + ui->clearToolButton->setEnabled(true); } else { ui->deleteToolButton->setEnabled(false); ui->copyToolButton->setEnabled(false); + ui->clearToolButton->setEnabled(false); } } @@ -1252,6 +1288,20 @@ void IOGraphDialog::on_copyToolButton_clicked() addGraph(true); } +void IOGraphDialog::on_clearToolButton_clicked() +{ + if (uat_model_) { + foreach(IOGraph* iog, ioGraphs_) { + delete iog; + } + ioGraphs_.clear(); + uat_model_->clearAll(); + } + + hint_err_.clear(); + mouseMoved(NULL); +} + void IOGraphDialog::on_dragRadioButton_toggled(bool checked) { if (checked) mouse_drags_ = true; |