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 | |
parent | e38d103d30f8131efd22742d6b03d7f34a226936 (diff) | |
download | wireshark-fea4d585edc407b7177e3b0481bf59f57942cf18.tar.gz |
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')
-rw-r--r-- | ui/qt/interface_frame.cpp | 20 | ||||
-rw-r--r-- | ui/qt/interface_frame.ui | 72 |
2 files changed, 54 insertions, 38 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)); diff --git a/ui/qt/interface_frame.ui b/ui/qt/interface_frame.ui index 0c9ec9210a..46d4135eb1 100644 --- a/ui/qt/interface_frame.ui +++ b/ui/qt/interface_frame.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>550</width> + <width>555</width> <height>350</height> </rect> </property> @@ -59,34 +59,48 @@ </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Show Interfaces</string> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="wdgButtons" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QWidget" name="wdgTypeSelector" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Show Interfaces</string> + </property> + </widget> + </item> + <item> + <widget class="QWidget" name="wdgButtons" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::MinimumExpanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>429</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> </item> </layout> </widget> |