aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/traffic_table_dialog.h
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2014-08-06 10:07:42 -0700
committerGerald Combs <gerald@wireshark.org>2014-09-05 01:06:53 +0000
commit30f3d524411445c26418c757ac9deb0940afc409 (patch)
treed60cadae8fdfb0612ee6e00bc5f17b550534af29 /ui/qt/traffic_table_dialog.h
parent382815d6bdd9a66421ae2e07c734df4c8a4ac398 (diff)
Qt: Refactor ConversationDialog for endpoints.
Create a TrafficTableDialog (for lack of a better name) parent class from the general parts of ConversationDialog. Use it to create EndpointsDialog. Move the contents of conversation_tree_widget.{cpp,h} to conversation_dialog.{cpp,h} to match endpoint_dialog and traffic_table_dialog. Fill in GeoIP columns dynamically instead of using a hard-coded limit. Use "endp_" and "ENDP_" prefixes for a lot of endpoint variables and defines. Try to make geoip_db_lookup_ipv4 and geoip_db_lookup_ipv6 more robust. Clean up some includes. Fix a shadowed variable. Change-Id: I23054816ac7f8c6edb3b1f01c8536db37ba4122d Reviewed-on: https://code.wireshark.org/review/3462 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/traffic_table_dialog.h')
-rw-r--r--ui/qt/traffic_table_dialog.h168
1 files changed, 168 insertions, 0 deletions
diff --git a/ui/qt/traffic_table_dialog.h b/ui/qt/traffic_table_dialog.h
new file mode 100644
index 0000000000..9c1bde51cf
--- /dev/null
+++ b/ui/qt/traffic_table_dialog.h
@@ -0,0 +1,168 @@
+/* traffic_table_dialog.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef TRAFFIC_TABLE_DIALOG_H
+#define TRAFFIC_TABLE_DIALOG_H
+
+#include "config.h"
+
+#include "file.h"
+
+#include "epan/conversation_table.h"
+
+#include "ui/follow.h"
+
+#include "filter_action.h"
+
+#include <QPushButton>
+#include <QCheckBox>
+#include <QDialog>
+#include <QDialogButtonBox>
+#include <QMenu>
+#include <QTabWidget>
+#include <QTreeWidget>
+
+namespace Ui {
+class TrafficTableDialog;
+}
+
+class TrafficTableTreeWidgetItem : public QTreeWidgetItem
+{
+public:
+ TrafficTableTreeWidgetItem(QTreeWidget *tree) : QTreeWidgetItem(tree) {}
+ TrafficTableTreeWidgetItem(QTreeWidget *parent, const QStringList &strings)
+ : QTreeWidgetItem (parent, strings) {}
+ virtual QVariant colData(int col, bool resolve_names) const = 0;
+};
+
+class TrafficTableTreeWidget : public QTreeWidget
+{
+ Q_OBJECT
+public:
+ explicit TrafficTableTreeWidget(QWidget *parent, register_ct_t* table);
+ ~TrafficTableTreeWidget();
+
+ // String, int, or double data for each column in a row.
+ // Passing -1 returns titles.
+ QList<QVariant> rowData(int row) const;
+
+public slots:
+ void setNameResolutionEnabled(bool enable);
+
+ // Title string plus optional count
+ const QString &trafficTreeTitle() { return title_; }
+ conv_hash_t* trafficTreeHash() {return &hash_;}
+
+protected:
+ register_ct_t* table_;
+ QString title_;
+ conv_hash_t hash_;
+ bool resolve_names_;
+ QMenu ctx_menu_;
+
+ void contextMenuEvent(QContextMenuEvent *event);
+
+private:
+
+private slots:
+ virtual void updateItems() {}
+
+signals:
+ void titleChanged(QWidget *tree, const QString &text);
+ void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type);
+};
+
+class TrafficTableDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ /** Create a new conversation window.
+ *
+ * @param parent Parent widget.
+ * @param cf Capture file. No statistics will be calculated if this is NULL.
+ * @param proto_id If valid, add this protocol and bring it to the front.
+ * @param filter Display filter to apply.
+ */
+ explicit TrafficTableDialog(QWidget *parent = 0, capture_file *cf = NULL, const char *filter = NULL, const QString &table_name = tr("Unknown"));
+ ~TrafficTableDialog();
+
+public slots:
+ virtual void setCaptureFile(capture_file *cf) { Q_UNUSED(cf) }
+
+signals:
+ void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type);
+ void openFollowStreamDialog(follow_type_t type);
+ void openTcpStreamGraph(int graph_type);
+
+protected:
+ Ui::TrafficTableDialog *ui;
+
+ capture_file *cap_file_;
+ QString filter_;
+ QMenu traffic_type_menu_;
+ QPushButton *copy_bt_;
+ QMap<int, TrafficTableTreeWidget *> proto_id_to_tree_;
+
+ const QList<int> defaultProtos() const;
+ void fillTypeMenu(QList<int> &enabled_protos);
+ // Adds a conversation tree. Returns true if the tree was freshly created, false if it was cached.
+ virtual bool addTrafficTable(register_ct_t* table) { Q_UNUSED(table) return false; }
+
+ // UI getters
+ QDialogButtonBox *buttonBox() const;
+ QTabWidget *trafficTableTabWidget() const;
+ QCheckBox *displayFilterCheckBox() const;
+ QCheckBox *nameResolutionCheckBox() const;
+ QPushButton *enabledTypesPushButton() const;
+
+protected slots:
+ virtual void itemSelectionChanged() {}
+ void updateWidgets();
+
+private:
+ QList<QVariant> curTreeRowData(int row) const;
+
+private slots:
+ void on_nameResolutionCheckBox_toggled(bool checked);
+ void on_displayFilterCheckBox_toggled(bool checked);
+ void setTabText(QWidget *tree, const QString &text);
+ void toggleConversation();
+
+ void copyAsCsv();
+ void copyAsYaml();
+ virtual void on_buttonBox_helpRequested() = 0;
+};
+
+#endif // TRAFFIC_TABLE_DIALOG_H
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */