summaryrefslogtreecommitdiff
path: root/ui/qt/interface_tree_model.h
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2016-10-01 08:54:57 +0200
committerRoland Knall <rknall@gmail.com>2016-10-01 13:18:51 +0000
commit99097dd3c65358a525e40767cc1501c4116c3a4d (patch)
tree1ad9637554aebded5ff4bf8a400a6c3fc2ed4b4e /ui/qt/interface_tree_model.h
parentb6ad91520fd602710f5afe4a4eb8787a6bca22d4 (diff)
downloadwireshark-99097dd3c65358a525e40767cc1501c4116c3a4d.tar.gz
Interface List: Change display to view/model
This changes the underlying model of the main interface tree. Because of that, we can resort to a view/model approach, enlisting the global interfaces list as only data source. The interface list works identical to the old list, but allows for filtering of the displayed interfaces by type. Only types, which are present and whose interfaces are not hidden, are being displayed for selection. Change-Id: If8475b227daa026dc0ad3d25bc7fe050d5bf2ac3 Reviewed-on: https://code.wireshark.org/review/17940 Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt/interface_tree_model.h')
-rw-r--r--ui/qt/interface_tree_model.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/ui/qt/interface_tree_model.h b/ui/qt/interface_tree_model.h
new file mode 100644
index 0000000000..fee19e80d7
--- /dev/null
+++ b/ui/qt/interface_tree_model.h
@@ -0,0 +1,95 @@
+/* interface_tree_model.h
+ * Model for the interface data for display in the interface frame
+ *
+ * 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 INTERFACE_TREE_MODEL_H
+#define INTERFACE_TREE_MODEL_H
+
+#include <config.h>
+
+#ifdef HAVE_LIBPCAP
+#include "ui/capture.h"
+#include "ui/capture_globals.h"
+#endif
+
+#include <glib.h>
+
+#include <QAbstractTableModel>
+#include <QList>
+#include <QMap>
+
+typedef QList<int> PointList;
+
+enum InterfaceTreeColumns
+{
+#ifdef HAVE_EXTCAP
+ IFTREE_COL_EXTCAP,
+#endif
+ IFTREE_COL_NAME,
+ IFTREE_COL_STATS,
+ IFTREE_COL_MAX /*< is not being displayed, it is the definition for the maximum numbers of columns */
+};
+
+class InterfaceTreeModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ InterfaceTreeModel(QObject *parent);
+ ~InterfaceTreeModel();
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const;
+
+ void updateStatistic(unsigned int row);
+#ifdef HAVE_LIBPCAP
+ void stopStatistic();
+#endif
+
+public slots:
+ void getPoints(int idx, PointList *pts);
+
+protected slots:
+ void interfaceListChanged();
+
+private:
+ QVariant toolTipForInterface(int idx) const;
+ QMap<QString, PointList *> points;
+
+#ifdef HAVE_LIBPCAP
+ if_stat_cache_t *stat_cache_;
+#endif // HAVE_LIBPCAP
+};
+
+#endif // INTERFACE_TREE_MODEL_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:
+ */