summaryrefslogtreecommitdiff
path: root/ui/qt/expert_info_dialog.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-08-12 10:49:34 -0700
committerGerald Combs <gerald@wireshark.org>2015-08-12 19:27:34 +0000
commit412f5b3716bce91d1b26a82012e5c28a611d91da (patch)
tree30f8515ced972bbfe35f156d9c417557e0daf9b4 /ui/qt/expert_info_dialog.cpp
parentbde416afcc6233225ab990390361bad67de45463 (diff)
downloadwireshark-412f5b3716bce91d1b26a82012e5c28a611d91da.tar.gz
Expert information dialog performance improvements.
Inserting QTreeWidgetItems individually is slow. This isn't a problem if you only have a few items but the Expert Information dialog can have thousands. Add "packet" tree items in groups, which should be much faster. Note that we still add "group" tree items individually since that gives us a nice progress indicator. While we're here, make sure we show the dialog before tapping packets. Bug: 11439 Change-Id: I8a182f4158d078cae5f42b8d1355414197f423e1 Reviewed-on: https://code.wireshark.org/review/10000 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/expert_info_dialog.cpp')
-rw-r--r--ui/qt/expert_info_dialog.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/ui/qt/expert_info_dialog.cpp b/ui/qt/expert_info_dialog.cpp
index e1423e7b3d..8472727871 100644
--- a/ui/qt/expert_info_dialog.cpp
+++ b/ui/qt/expert_info_dialog.cpp
@@ -91,8 +91,8 @@ public:
class ExpertPacketTreeWidgetItem : public QTreeWidgetItem
{
public:
- ExpertPacketTreeWidgetItem(QTreeWidgetItem *parent, expert_info_t *expert_info = NULL) :
- QTreeWidgetItem (parent, packet_type_),
+ ExpertPacketTreeWidgetItem(expert_info_t *expert_info = NULL) :
+ QTreeWidgetItem (packet_type_),
packet_num_(0),
hf_id_(-1)
{
@@ -143,10 +143,13 @@ ExpertInfoDialog::ExpertInfoDialog(QWidget &parent, CaptureFile &capture_file) :
// Clicking on an item jumps to its associated packet. Make the dialog
// narrow so that we avoid obscuring the packet list.
// XXX Use recent settings instead
- int dlg_width = parent.width() / 2;
+ int dlg_width = parent.width() * 3 / 5;
if (dlg_width < width()) dlg_width = width();
resize(dlg_width, parent.height());
+ int one_em = fontMetrics().height();
+ ui->expertInfoTreeWidget->setColumnWidth(severity_col_, one_em * 25); // Arbitrary
+
severity_actions_ = QList<QAction *>() << ui->actionShowError << ui->actionShowWarning
<< ui->actionShowNote << ui->actionShowChat
<< ui->actionShowComment;
@@ -199,8 +202,7 @@ ExpertInfoDialog::ExpertInfoDialog(QWidget &parent, CaptureFile &capture_file) :
}
setDisplayFilter();
- retapPackets();
-
+ QTimer::singleShot(0, this, SLOT(retapPackets()));
}
ExpertInfoDialog::~ExpertInfoDialog()
@@ -220,6 +222,7 @@ void ExpertInfoDialog::clearAllData()
need_show_hide_ = false;
ei_to_ti_.clear();
+ gti_packets_.clear();
}
void ExpertInfoDialog::setDisplayFilter(const QString &display_filter)
@@ -261,14 +264,22 @@ void ExpertInfoDialog::retapPackets()
cap_file_.retapPackets();
- updateWidgets();
-
+ setUpdatesEnabled(false);
+ // Adding a list of ExpertPacketTreeWidgetItems is much faster than
+ // adding them individually. We still add ExpertGroupTreeWidgetItems
+ // individually since that gives us a nice progress indicator.
for (int i = 0; i < ui->expertInfoTreeWidget->topLevelItemCount(); i++) {
QTreeWidgetItem *group_ti = ui->expertInfoTreeWidget->topLevelItem(i);
- if (group_ti->childCount() <= auto_expand_threshold_) {
- group_ti->setExpanded(true);
+ if (gti_packets_.contains(group_ti)) {
+ group_ti->addChildren(gti_packets_[group_ti]);
+ if (group_ti->childCount() <= auto_expand_threshold_) {
+ group_ti->setExpanded(true);
+ }
}
}
+ setUpdatesEnabled(true);
+
+ updateWidgets();
}
void ExpertInfoDialog::addExpertInfo(struct expert_info_s *expert_info)
@@ -313,9 +324,10 @@ void ExpertInfoDialog::addExpertInfo(struct expert_info_s *expert_info)
}
}
ei_to_ti_[key] = group_ti;
+ gti_packets_[group_ti] = QList<QTreeWidgetItem *>();
}
- new ExpertPacketTreeWidgetItem(group_ti, expert_info);
+ gti_packets_[group_ti] << new ExpertPacketTreeWidgetItem(expert_info);
// XXX Use plain colors until our users demand to be blinded.
// if (background.isValid()) {
@@ -346,7 +358,7 @@ gboolean ExpertInfoDialog::tapPacket(void *eid_ptr, struct _packet_info *pinfo,
expert_info_t *expert_info = (expert_info_t *) data;
gboolean draw_required = FALSE;
- if (!pinfo || !eid || !expert_info) return 0;
+ if (!pinfo || !eid || !expert_info) return FALSE;
eid->addExpertInfo(expert_info);