diff options
-rw-r--r-- | ui/qt/wlan_statistics_dialog.cpp | 30 | ||||
-rw-r--r-- | ui/qt/wlan_statistics_dialog.h | 6 |
2 files changed, 33 insertions, 3 deletions
diff --git a/ui/qt/wlan_statistics_dialog.cpp b/ui/qt/wlan_statistics_dialog.cpp index 1040c4c999..4a3f18ccc9 100644 --- a/ui/qt/wlan_statistics_dialog.cpp +++ b/ui/qt/wlan_statistics_dialog.cpp @@ -27,6 +27,7 @@ #include <epan/dissectors/packet-ieee80211.h> +#include <QElapsedTimer> #include <QTreeWidget> #include <QTreeWidgetItem> @@ -491,7 +492,9 @@ static const QString node_col_11_title_ = QObject::tr("Comment"); WlanStatisticsDialog::WlanStatisticsDialog(QWidget &parent, CaptureFile &cf, const char *filter) : TapParameterDialog(parent, cf, HELP_STATS_WLAN_TRAFFIC_DIALOG), - packet_count_(0) + packet_count_(0), + cur_network_(0), + add_station_timer_(0) { setWindowSubtitle(tr("Wireless LAN Statistics")); loadGeometry(parent.width() * 4 / 5, parent.height() * 3 / 4, "WlanStatisticsDialog"); @@ -535,12 +538,15 @@ WlanStatisticsDialog::WlanStatisticsDialog(QWidget &parent, CaptureFile &cf, con setDisplayFilter(filter); } + add_station_timer_ = new QElapsedTimer(); + connect(statsTreeWidget(), SIGNAL(itemSelectionChanged()), this, SLOT(updateHeaderLabels())); } WlanStatisticsDialog::~WlanStatisticsDialog() { + delete add_station_timer_; } void WlanStatisticsDialog::tapReset(void *ws_dlg_ptr) @@ -567,6 +573,8 @@ gboolean WlanStatisticsDialog::tapPacket(void *ws_dlg_ptr, _packet_info *, epan_ ws_dlg->packet_count_++; + // XXX This is very slow for large numbers of networks. We might be + // able to store networks in a cache keyed on BSSID+SSID instead. WlanNetworkTreeWidgetItem *wn_ti = NULL; for (int i = 0; i < ws_dlg->statsTreeWidget()->topLevelItemCount(); i++) { QTreeWidgetItem *ti = ws_dlg->statsTreeWidget()->topLevelItem(i); @@ -634,16 +642,32 @@ void WlanStatisticsDialog::fillTree() return; } + statsTreeWidget()->setSortingEnabled(false); cap_file_.retapPackets(); tapDraw(this); removeTapListeners(); + statsTreeWidget()->setSortingEnabled(true); + + // Don't freeze if we have a large number of stations. + cur_network_ = 0; + QTimer::singleShot(0, this, SLOT(addStationTreeItems())); +} - for (int i = 0; i < statsTreeWidget()->topLevelItemCount(); i++) { - QTreeWidgetItem *ti = statsTreeWidget()->topLevelItem(i); +static const int add_station_interval_ = 5; // ms +void WlanStatisticsDialog::addStationTreeItems() +{ + add_station_timer_->start(); + while (add_station_timer_->elapsed() < add_station_interval_ && cur_network_ < statsTreeWidget()->topLevelItemCount()) { + QTreeWidgetItem *ti = statsTreeWidget()->topLevelItem(cur_network_); if (ti->type() != wlan_network_row_type_) continue; WlanNetworkTreeWidgetItem *wn_ti = static_cast<WlanNetworkTreeWidgetItem*>(ti); wn_ti->addStations(); + ++cur_network_; + } + + if (cur_network_ < statsTreeWidget()->topLevelItemCount()) { + QTimer::singleShot(0, this, SLOT(addStationTreeItems())); } } diff --git a/ui/qt/wlan_statistics_dialog.h b/ui/qt/wlan_statistics_dialog.h index e39f4b6427..670feda3b1 100644 --- a/ui/qt/wlan_statistics_dialog.h +++ b/ui/qt/wlan_statistics_dialog.h @@ -24,6 +24,8 @@ #include "tap_parameter_dialog.h" +class QElapsedTimer; + class WlanStatisticsDialog : public TapParameterDialog { Q_OBJECT @@ -36,6 +38,9 @@ protected: private: int packet_count_; + int cur_network_; + QElapsedTimer *add_station_timer_; + // Callbacks for register_tap_listener static void tapReset(void *ws_dlg_ptr); @@ -46,6 +51,7 @@ private: private slots: virtual void fillTree(); + void addStationTreeItems(); void updateHeaderLabels(); void captureFileClosing(); }; |