diff options
author | Roland Knall <rknall@gmail.com> | 2016-10-02 16:22:27 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2016-10-02 17:56:54 +0000 |
commit | fea4d585edc407b7177e3b0481bf59f57942cf18 (patch) | |
tree | 9e0a7308838901a8c0815213874e8b5b044439b7 /ui/qt/interface_frame.cpp | |
parent | e38d103d30f8131efd22742d6b03d7f34a226936 (diff) |
Interface List: Hide button for only one interface
If only one interface type exists, the button row is being hidden.
Change-Id: Ieed9c363ab1ebc4bc15d0e09bceeb79a04d6e76e
Reviewed-on: https://code.wireshark.org/review/18017
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt/interface_frame.cpp')
-rw-r--r-- | ui/qt/interface_frame.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/ui/qt/interface_frame.cpp b/ui/qt/interface_frame.cpp index 1fdd1c4dca..d729eb7b76 100644 --- a/ui/qt/interface_frame.cpp +++ b/ui/qt/interface_frame.cpp @@ -147,7 +147,7 @@ QAbstractButton * InterfaceFrame::createButton(QString text, QString prop, QVari void InterfaceFrame::interfaceListChanged() { - if (sourceModel->rowCount() == 0) + if ( sourceModel->rowCount() == 0 ) { ui->interfaceTree->setHidden(true); ui->lblNoInterfaces->setHidden(false); @@ -174,7 +174,9 @@ void InterfaceFrame::resetInterfaceButtons() { QAbstractButton * button = 0; - if ( ! global_capture_opts.all_ifaces ) + ui->wdgTypeSelector->setVisible( proxyModel->typesDisplayed().count() > 1 ); + + if ( sourceModel->rowCount() == 0 ) return; foreach (QWidget * w, ui->wdgButtons->findChildren<QWidget *>()) @@ -213,12 +215,12 @@ void InterfaceFrame::resetInterfaceButtons() void InterfaceFrame::updateSelectedInterfaces() { - if ( ! global_capture_opts.all_ifaces ) + if ( sourceModel->rowCount() == 0 ) return; QItemSelection mySelection; - for(unsigned int idx = 0; idx < global_capture_opts.all_ifaces->len; idx++) + for( int idx = 0; idx < sourceModel->rowCount(); idx++ ) { interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); @@ -244,7 +246,7 @@ void InterfaceFrame::interfaceTreeSelectionChanged(const QItemSelection & select { if (selected.count() == 0 && deselected.count() == 0) return; - if ( ! global_capture_opts.all_ifaces ) + if ( sourceModel->rowCount() == 0 ) return; QList<int> selectedIndices; @@ -301,7 +303,7 @@ void InterfaceFrame::on_interfaceTree_doubleClicked(const QModelIndex &index) { QModelIndex realIndex = proxyModel->mapToSource(index); - if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) realIndex.row() ) + if ( ! realIndex.isValid() ) return; #ifdef HAVE_EXTCAP @@ -332,7 +334,7 @@ void InterfaceFrame::on_interfaceTree_clicked(const QModelIndex &index) { QModelIndex realIndex = proxyModel->mapToSource(index); - if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) realIndex.row() ) + if ( ! realIndex.isValid() ) return; interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, realIndex.row()); @@ -358,12 +360,12 @@ void InterfaceFrame::on_interfaceTree_clicked(const QModelIndex &index) void InterfaceFrame::updateStatistics(void) { - if ( ! global_capture_opts.all_ifaces ) + if ( sourceModel->rowCount() == 0 ) return; #ifdef HAVE_LIBPCAP - for( unsigned int idx = 0; idx < global_capture_opts.all_ifaces->len; idx++ ) + for( int idx = 0; idx < proxyModel->rowCount(); idx++ ) { QModelIndex selectIndex = proxyModel->mapFromSource(sourceModel->index(idx, 0)); |