diff options
author | Roland Knall <rknall@gmail.com> | 2016-10-02 16:47:04 +0200 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-10-02 18:18:34 +0000 |
commit | 53523a739c41abfdc3f61ba460f8a6d021c02832 (patch) | |
tree | 5157f15fa76902f02bbc2b5b6994583dd0f86a72 /ui | |
parent | fea4d585edc407b7177e3b0481bf59f57942cf18 (diff) |
Interface List: Fix build for no PCAP builds
This is a fix for building without libpcap. Also, changing _U_
to Q_UNUSED for the tree_model
Change-Id: I38a992731a3d3c4062ffab3cca0049cf08050794
Reviewed-on: https://code.wireshark.org/review/18019
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/interface_frame.cpp | 12 | ||||
-rw-r--r-- | ui/qt/interface_frame.h | 2 | ||||
-rw-r--r-- | ui/qt/interface_sort_filter_model.cpp | 12 | ||||
-rw-r--r-- | ui/qt/interface_tree_model.cpp | 35 |
4 files changed, 49 insertions, 12 deletions
diff --git a/ui/qt/interface_frame.cpp b/ui/qt/interface_frame.cpp index d729eb7b76..82cbda8116 100644 --- a/ui/qt/interface_frame.cpp +++ b/ui/qt/interface_frame.cpp @@ -152,11 +152,13 @@ void InterfaceFrame::interfaceListChanged() ui->interfaceTree->setHidden(true); ui->lblNoInterfaces->setHidden(false); +#ifdef HAVE_LIBPCAP if ( global_capture_opts.ifaces_err != 0 ) { ui->lblNoInterfaces->setText(tr(global_capture_opts.ifaces_err_info)); } else +#endif { ui->lblNoInterfaces->setText(tr("No interfaces found")); } @@ -217,7 +219,7 @@ void InterfaceFrame::updateSelectedInterfaces() { if ( sourceModel->rowCount() == 0 ) return; - +#ifdef HAVE_LIBPCAP QItemSelection mySelection; for( int idx = 0; idx < sourceModel->rowCount(); idx++ ) @@ -240,6 +242,7 @@ void InterfaceFrame::updateSelectedInterfaces() ui->interfaceTree->selectionModel()->clearSelection(); ui->interfaceTree->selectionModel()->select(mySelection, QItemSelectionModel::SelectCurrent ); +#endif } void InterfaceFrame::interfaceTreeSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected) @@ -248,7 +251,7 @@ void InterfaceFrame::interfaceTreeSelectionChanged(const QItemSelection & select return; if ( sourceModel->rowCount() == 0 ) return; - +#ifdef HAVE_LIBPCAP QList<int> selectedIndices; /* Take all selected interfaces, not just the newly ones */ @@ -297,6 +300,7 @@ void InterfaceFrame::interfaceTreeSelectionChanged(const QItemSelection & select if ( selectionHasChanged ) emit itemSelectionChanged(); +#endif } void InterfaceFrame::on_interfaceTree_doubleClicked(const QModelIndex &index) @@ -306,7 +310,7 @@ void InterfaceFrame::on_interfaceTree_doubleClicked(const QModelIndex &index) if ( ! realIndex.isValid() ) return; -#ifdef HAVE_EXTCAP +#if defined(HAVE_EXTCAP) && defined(HAVE_LIBPCAP) interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, realIndex.row()); QString extcap_string = device.if_info.extcap; @@ -327,7 +331,7 @@ void InterfaceFrame::on_interfaceTree_doubleClicked(const QModelIndex &index) emit startCapture(); } -#ifdef HAVE_EXTCAP +#if defined(HAVE_EXTCAP) && defined(HAVE_LIBPCAP) void InterfaceFrame::on_interfaceTree_clicked(const QModelIndex &index) { if ( index.column() == 0 ) diff --git a/ui/qt/interface_frame.h b/ui/qt/interface_frame.h index 7d54493d27..88a622ff47 100644 --- a/ui/qt/interface_frame.h +++ b/ui/qt/interface_frame.h @@ -88,7 +88,7 @@ private slots: void interfaceTreeSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); void on_interfaceTree_doubleClicked(const QModelIndex &index); -#ifdef HAVE_EXTCAP +#if defined(HAVE_EXTCAP) && defined(HAVE_LIBPCAP) void on_interfaceTree_clicked(const QModelIndex &index); #endif diff --git a/ui/qt/interface_sort_filter_model.cpp b/ui/qt/interface_sort_filter_model.cpp index 61cd1f4e5a..9503fb16cc 100644 --- a/ui/qt/interface_sort_filter_model.cpp +++ b/ui/qt/interface_sort_filter_model.cpp @@ -75,8 +75,10 @@ bool InterfaceSortFilterModel::filterHidden() const int InterfaceSortFilterModel::interfacesHidden() { +#ifdef HAVE_LIBPCAP if ( ! global_capture_opts.all_ifaces ) return 0; +#endif return sourceModel()->rowCount() - rowCount(); } @@ -84,7 +86,7 @@ int InterfaceSortFilterModel::interfacesHidden() QList<int> InterfaceSortFilterModel::typesDisplayed() { QList<int> shownTypes; - +#ifdef HAVE_LIBPCAP if ( ! global_capture_opts.all_ifaces ) return shownTypes; @@ -97,7 +99,7 @@ QList<int> InterfaceSortFilterModel::typesDisplayed() shownTypes.append(device.if_info.type); } } - +#endif return shownTypes; } @@ -137,6 +139,11 @@ bool InterfaceSortFilterModel::isInterfaceTypeShown(int ifType) const bool InterfaceSortFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const { QModelIndex realIndex = sourceModel()->index(sourceRow, 0, sourceParent); + + if ( ! realIndex.isValid() ) + return false; + +#ifdef HAVE_LIBPCAP int idx = realIndex.row(); /* No data loaded, we do not display anything */ @@ -150,6 +157,7 @@ bool InterfaceSortFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex if ( ! isInterfaceTypeShown(device.if_info.type) ) return false; +#endif return true; } diff --git a/ui/qt/interface_tree_model.cpp b/ui/qt/interface_tree_model.cpp index 518340e448..94e94113d8 100644 --- a/ui/qt/interface_tree_model.cpp +++ b/ui/qt/interface_tree_model.cpp @@ -71,19 +71,29 @@ InterfaceTreeModel::~InterfaceTreeModel(void) #endif // HAVE_LIBPCAP } -int InterfaceTreeModel::rowCount(const QModelIndex & parent _U_) const +int InterfaceTreeModel::rowCount(const QModelIndex & parent) const { + Q_UNUSED(parent); + +#ifdef HAVE_LIBPCAP return (global_capture_opts.all_ifaces ? global_capture_opts.all_ifaces->len : 0); +#else + /* Currently no interfaces available for libpcap-less builds */ + return 0; +#endif } -int InterfaceTreeModel::columnCount(const QModelIndex & parent _U_) const +int InterfaceTreeModel::columnCount(const QModelIndex & parent) const { + Q_UNUSED(parent); + /* IFTREE_COL_MAX is not being displayed, it is the definition for the maximum numbers of columns */ return ((int) IFTREE_COL_MAX); } QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const { +#ifdef HAVE_LIBPCAP bool interfacesLoaded = true; if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len == 0 ) interfacesLoaded = false; @@ -143,6 +153,9 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const { return toolTipForInterface(row); } +#endif + Q_UNUSED(index); + Q_UNUSED(role); return QVariant(); } @@ -168,6 +181,7 @@ void InterfaceTreeModel::interfaceListChanged() */ QVariant InterfaceTreeModel::toolTipForInterface(int idx) const { +#ifdef HAVE_LIBPCAP if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx) return QVariant(); @@ -207,6 +221,11 @@ QVariant InterfaceTreeModel::toolTipForInterface(int idx) const tt_str += "</p>"; return tt_str; +#else + Q_UNUSED(idx); + + return QVariant(); +#endif } #ifdef HAVE_LIBPCAP @@ -222,8 +241,8 @@ void InterfaceTreeModel::stopStatistic() void InterfaceTreeModel::updateStatistic(unsigned int idx) { +#ifdef HAVE_LIBPCAP guint diff; - if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx ) return; @@ -232,7 +251,6 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx) if ( device.if_info.type == IF_PIPE ) return; -#ifdef HAVE_LIBPCAP if ( !stat_cache_ ) { // Start gathering statistics using dumpcap @@ -241,7 +259,6 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx) } if ( !stat_cache_ ) return; -#endif struct pcap_stat stats; @@ -264,14 +281,22 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx) points[device.name]->append(diff); emit dataChanged(index(idx, IFTREE_COL_STATS), index(idx, IFTREE_COL_STATS)); +#else + Q_UNUSED(idx); +#endif } void InterfaceTreeModel::getPoints(int idx, PointList *pts) { +#ifdef HAVE_LIBPCAP if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx ) return; interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); if ( points.contains(device.name) ) pts->append(*points[device.name]); +#else + Q_UNUSED(idx); + Q_UNUSED(pts); +#endif } |