WLAN stats: make filter + apply button work
authorMartin Mathieson <martin.r.mathieson@googlemail.com>
Sat, 6 Jan 2018 00:01:30 +0000 (00:01 +0000)
committerMartin Mathieson <martin.r.mathieson@googlemail.com>
Sat, 6 Jan 2018 23:27:00 +0000 (23:27 +0000)
Also export as text just the networks.
Change-Id: I228d65cb219792a70c6077932dbe9cf65b92eb6e
Reviewed-on: https://code.wireshark.org/review/25169
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
ui/qt/wlan_statistics_dialog.cpp
ui/qt/wlan_statistics_dialog.h

index 068142e05aa5f02cd586dc05f95faed6f71bd26f..3b87fd8e7510bc0c11e3ff52a2f2fc2f4ba57005 100644 (file)
@@ -550,6 +550,10 @@ WlanStatisticsDialog::WlanStatisticsDialog(QWidget &parent, CaptureFile &cf, con
 
     connect(statsTreeWidget(), SIGNAL(itemSelectionChanged()),
             this, SLOT(updateHeaderLabels()));
+
+    // Set handler for when display filter string is changed.
+    connect(this, SIGNAL(updateFilter(QString)),
+            this, SLOT(filterUpdated(QString)));
 }
 
 WlanStatisticsDialog::~WlanStatisticsDialog()
@@ -641,7 +645,7 @@ void WlanStatisticsDialog::fillTree()
 {
     if (!registerTapListener("wlan",
                              this,
-                             NULL,
+                             displayFilter_.toLatin1().data(),
                              TL_REQUIRES_NOTHING,
                              tapReset,
                              tapPacket,
@@ -702,6 +706,26 @@ void WlanStatisticsDialog::captureFileClosing()
     WiresharkDialog::captureFileClosing();
 }
 
+// Store filter from signal.
+void WlanStatisticsDialog::filterUpdated(QString filter)
+{
+    displayFilter_ = filter;
+}
+
+// This is how an item is represented for exporting.
+QList<QVariant> WlanStatisticsDialog::treeItemData(QTreeWidgetItem *it) const
+{
+    // Cast up to our type.
+    WlanNetworkTreeWidgetItem *nit = dynamic_cast<WlanNetworkTreeWidgetItem*>(it);
+    if (nit) {
+        return nit->rowData();
+    }
+    // TODO: not going to cast to WlanStationTreeWidgetItem* and do the same as
+    // some of the columns are different...
+
+    return QList<QVariant>();
+}
+
 // Stat command + args
 
 static void
index 670feda3b13287e3404a0ea1cfc35bc8606c659b..749425b052b78ecf1aec89125be5068b7c9d33eb 100644 (file)
@@ -40,7 +40,7 @@ private:
     int packet_count_;
     int cur_network_;
     QElapsedTimer *add_station_timer_;
-
+    QString displayFilter_;
 
     // Callbacks for register_tap_listener
     static void tapReset(void *ws_dlg_ptr);
@@ -49,11 +49,15 @@ private:
 
     virtual const QString filterExpression();
 
+    // How each item will be exported
+    virtual QList<QVariant> treeItemData(QTreeWidgetItem *) const;
+
 private slots:
     virtual void fillTree();
     void addStationTreeItems();
     void updateHeaderLabels();
     void captureFileClosing();
+    void filterUpdated(QString filter);
 };
 
 #endif // WLANSTATISTICSDIALOG_H