summaryrefslogtreecommitdiff
path: root/ui/qt/simple_statistics_dialog.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-08-31 16:06:33 -0700
committerGerald Combs <gerald@wireshark.org>2015-09-01 01:01:32 +0000
commit54d2ff1c3e74e57a59a57b9b3fdeb50e64cceb0f (patch)
tree7ed6e6d0b300803378f549d3e310d4aec49ed08c /ui/qt/simple_statistics_dialog.cpp
parent377d215e0fd1022a093fa44b32f396948e70c119 (diff)
downloadwireshark-54d2ff1c3e74e57a59a57b9b3fdeb50e64cceb0f.tar.gz
Convert the WSP stats to generic stat API.
Add support for multiple tables to SimpleStatisticsDialog. Change-Id: I843d901db092d2f2856d3d1a16f29f85fb41374b Reviewed-on: https://code.wireshark.org/review/10339 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/simple_statistics_dialog.cpp')
-rw-r--r--ui/qt/simple_statistics_dialog.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/ui/qt/simple_statistics_dialog.cpp b/ui/qt/simple_statistics_dialog.cpp
index 9ed61324aa..d9d235456e 100644
--- a/ui/qt/simple_statistics_dialog.cpp
+++ b/ui/qt/simple_statistics_dialog.cpp
@@ -68,7 +68,7 @@ enum {
class SimpleStatisticsTreeWidgetItem : public QTreeWidgetItem
{
public:
- SimpleStatisticsTreeWidgetItem(QTreeWidget *parent, int num_fields, const stat_tap_table_item_type *fields) :
+ SimpleStatisticsTreeWidgetItem(QTreeWidgetItem *parent, int num_fields, const stat_tap_table_item_type *fields) :
QTreeWidgetItem (parent, simple_row_type_),
num_fields_(num_fields),
fields_(fields)
@@ -196,15 +196,26 @@ void SimpleStatisticsDialog::addMissingRows(struct _new_stat_data_t *stat_data)
// For multiple table support we might want to add them as subtrees, with
// the top-level tree item text set to the column labels for that table.
- // Add any missing rows.
- guint table_index = 0;
- new_stat_tap_table* st_table = g_array_index(stat_data->new_stat_tap_data->tables, new_stat_tap_table*, table_index);
- for (guint element = statsTreeWidget()->topLevelItemCount(); element < st_table->num_elements; element++) {
- stat_tap_table_item_type* fields = new_stat_tap_get_field_data(st_table, element, 0);
- SimpleStatisticsTreeWidgetItem *ss_ti = new SimpleStatisticsTreeWidgetItem(statsTreeWidget(), st_table->num_fields, fields);
- for (int col = 0; col < (int) stu_->nfields; col++) {
- if (stu_->fields[col].align == TAP_ALIGN_RIGHT) {
- ss_ti->setTextAlignment(col, Qt::AlignRight);
+ // Add any missing tables and rows.
+ for (guint table_idx = 0; table_idx < stat_data->new_stat_tap_data->tables->len; table_idx++) {
+ new_stat_tap_table* st_table = g_array_index(stat_data->new_stat_tap_data->tables, new_stat_tap_table*, table_idx);
+ QTreeWidgetItem *ti = NULL;
+
+ if ((int) table_idx >= statsTreeWidget()->topLevelItemCount()) {
+ ti = new QTreeWidgetItem(statsTreeWidget());
+ ti->setText(0, st_table->title);
+ ti->setFirstColumnSpanned(true);
+ ti->setExpanded(true);
+ } else {
+ ti = statsTreeWidget()->topLevelItem(table_idx);
+ }
+ for (guint element = ti->childCount(); element < st_table->num_elements; element++) {
+ stat_tap_table_item_type* fields = new_stat_tap_get_field_data(st_table, element, 0);
+ SimpleStatisticsTreeWidgetItem *ss_ti = new SimpleStatisticsTreeWidgetItem(ti, st_table->num_fields, fields);
+ for (int col = 0; col < (int) stu_->nfields; col++) {
+ if (stu_->fields[col].align == TAP_ALIGN_RIGHT) {
+ ss_ti->setTextAlignment(col, Qt::AlignRight);
+ }
}
}
}
@@ -265,6 +276,11 @@ void SimpleStatisticsDialog::fillTree()
cap_file_.retapPackets();
+ // We only have one table. Move its tree items up one level.
+ if (statsTreeWidget()->invisibleRootItem()->childCount() == 1) {
+ statsTreeWidget()->setRootIndex(statsTreeWidget()->model()->index(0, 0));
+ }
+
tapDraw(&stat_data);
removeTapListeners();