diff options
author | Gerald Combs <gerald@zing.org> | 2015-09-20 13:17:07 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-09-21 15:40:29 +0000 |
commit | 50ff8ae0c7395454a6483d5013283af7fa288809 (patch) | |
tree | 126997beafbe4544d2e9446c82e6fed5b0f036a5 /ui/qt/packet_list_model.cpp | |
parent | 4680c8b42904d7fdda9ba1175e3e808953912bad (diff) | |
download | wireshark-50ff8ae0c7395454a6483d5013283af7fa288809.tar.gz |
Qt: Add idle dissection.
Features such as sorting and scroll bar colorization require
fully-dissected packets. We currently do dissection at the wrong time --
*after* the user clicks on a packet list column header or moves the
scrollbar.
Add a timer + slot that dissects packets when the UI is idle so that our
packets are at least partially dissected when we need them.
Change-Id: I024c590af2250d67404a520f118e46ec0c49cd71
Reviewed-on: https://code.wireshark.org/review/10593
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/packet_list_model.cpp')
-rw-r--r-- | ui/qt/packet_list_model.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp index 70cc7f3f4e..6757fd75e2 100644 --- a/ui/qt/packet_list_model.cpp +++ b/ui/qt/packet_list_model.cpp @@ -40,6 +40,7 @@ #include "wireshark_application.h" #include <QColor> +#include <QElapsedTimer> #include <QFontMetrics> #include <QModelIndex> #include <QElapsedTimer> @@ -48,13 +49,20 @@ PacketListModel::PacketListModel(QObject *parent, capture_file *cf) : QAbstractItemModel(parent), uniform_row_heights_(true), row_height_(-1), - line_spacing_(0) + line_spacing_(0), + idle_dissection_row_(0) { setCaptureFile(cf); PacketListRecord::clearStringPool(); connect(this, SIGNAL(itemHeightChanged(QModelIndex)), this, SLOT(emitItemHeightChanged(QModelIndex)), Qt::QueuedConnection); + idle_dissection_timer_ = new QElapsedTimer(); +} + +PacketListModel::~PacketListModel() +{ + delete idle_dissection_timer_; } void PacketListModel::setCaptureFile(capture_file *cf) @@ -103,6 +111,7 @@ guint PacketListModel::recreateVisibleRows() } endInsertRows(); return visible_rows_.count(); + idle_dissection_row_ = 0; } void PacketListModel::clear() { @@ -114,6 +123,7 @@ void PacketListModel::clear() { PacketListRecord::clearStringPool(); endResetModel(); uniform_row_heights_ = true; + idle_dissection_row_ = 0; } void PacketListModel::resetColumns() @@ -532,6 +542,34 @@ void PacketListModel::flushVisibleRows() } } +// Fill our column string and colorization cache while the application is +// idle. Try to be as conservative with the CPU and disk as possible. +static const int idle_dissection_interval_ = 5; // ms +void PacketListModel::dissectIdle(bool reset) +{ + if (reset) { +// qDebug() << "=di reset" << idle_dissection_row_; + idle_dissection_row_ = 0; + } else if (!idle_dissection_timer_->isValid()) { + return; + } + + idle_dissection_timer_->restart(); + + while (idle_dissection_timer_->elapsed() < idle_dissection_interval_ + && idle_dissection_row_ < physical_rows_.count()) { + ensureRowColorized(idle_dissection_row_); + idle_dissection_row_++; +// if (idle_dissection_row_ % 1000 == 0) qDebug() << "=di row" << idle_dissection_row_; + } + + if (idle_dissection_row_ < physical_rows_.count()) { + QTimer::singleShot(idle_dissection_interval_, this, SLOT(dissectIdle())); + } else { + idle_dissection_timer_->invalidate(); + } +} + // XXX Pass in cinfo from packet_list_append so that we can fill in // line counts? gint PacketListModel::appendPacket(frame_data *fdata) |