diff options
author | Roland Knall <roland.knall@br-automation.com> | 2016-10-13 09:11:50 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2016-10-13 11:53:46 +0000 |
commit | 4f6ed3852dcba51ef19604a090ecfc91bc997940 (patch) | |
tree | ee40d30c2aff3c6322175f14fcc1445ca94db4a7 /ui/qt | |
parent | 8b0e66f22c059533643195ba7571cafe9f006f58 (diff) | |
download | wireshark-4f6ed3852dcba51ef19604a090ecfc91bc997940.tar.gz |
Interface List: Fix display of zero entries
If WS is started with zero entries, no text is being displayed, and
pushing a button does not yield the display of the list. This fixes
it.
Change-Id: I70b0637e5f95e805b54780afb7eb2e43b3e5f21c
Reviewed-on: https://code.wireshark.org/review/18180
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Roland Knall <rknall@gmail.com>
Tested-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/interface_frame.cpp | 27 | ||||
-rw-r--r-- | ui/qt/interface_frame.h | 1 | ||||
-rw-r--r-- | ui/qt/interface_frame.ui | 9 | ||||
-rw-r--r-- | ui/qt/interface_sort_filter_model.cpp | 15 | ||||
-rw-r--r-- | ui/qt/interface_sort_filter_model.h | 2 |
5 files changed, 42 insertions, 12 deletions
diff --git a/ui/qt/interface_frame.cpp b/ui/qt/interface_frame.cpp index b53a0747b4..b94178693d 100644 --- a/ui/qt/interface_frame.cpp +++ b/ui/qt/interface_frame.cpp @@ -124,6 +124,7 @@ void InterfaceFrame::hideEvent(QHideEvent *) { } void InterfaceFrame::showEvent(QShowEvent *) { + #ifdef HAVE_LIBPCAP if (stat_timer_) stat_timer_->start(stat_update_interval_); @@ -136,10 +137,9 @@ void InterfaceFrame::actionButton_toggled(bool checked) if ( ifType.isValid() ) { proxyModel->setInterfaceTypeVisible(ifType.toInt(), checked); -#ifdef HAVE_EXTCAP - ui->interfaceTree->resizeColumnToContents(proxyModel->mapSourceToColumn(IFTREE_COL_EXTCAP)); -#endif } + + resetInterfaceTreeDisplay(); } QAbstractButton * InterfaceFrame::createButton(QString text, QString prop, QVariant content ) @@ -159,20 +159,29 @@ QAbstractButton * InterfaceFrame::createButton(QString text, QString prop, QVari void InterfaceFrame::interfaceListChanged() { + resetInterfaceTreeDisplay(); + resetInterfaceButtons(); +} + +void InterfaceFrame::resetInterfaceTreeDisplay() +{ if ( proxyModel->rowCount() == 0 ) { ui->interfaceTree->setHidden(true); ui->lblNoInterfaces->setHidden(false); - ui->lblNoInterfaces->setText( sourceModel->interfaceError() ); + ui->lblNoInterfaces->setText( proxyModel->interfaceError() ); } else { ui->interfaceTree->setHidden(false); ui->lblNoInterfaces->setHidden(true); +#ifdef HAVE_EXTCAP + ui->interfaceTree->resizeColumnToContents(proxyModel->mapSourceToColumn(IFTREE_COL_EXTCAP)); +#endif + ui->interfaceTree->resizeColumnToContents(proxyModel->mapSourceToColumn(IFTREE_COL_NAME)); + ui->interfaceTree->resizeColumnToContents(proxyModel->mapSourceToColumn(IFTREE_COL_STATS)); } - - resetInterfaceButtons(); } void InterfaceFrame::resetInterfaceButtons() @@ -196,12 +205,6 @@ void InterfaceFrame::resetInterfaceButtons() buttonLayout->addWidget(button); } -#ifdef HAVE_EXTCAP - ui->interfaceTree->resizeColumnToContents(proxyModel->mapSourceToColumn(IFTREE_COL_EXTCAP)); -#endif - ui->interfaceTree->resizeColumnToContents(proxyModel->mapSourceToColumn(IFTREE_COL_NAME)); - ui->interfaceTree->resizeColumnToContents(proxyModel->mapSourceToColumn(IFTREE_COL_STATS)); - #ifdef HAVE_LIBPCAP if (!stat_timer_) { updateStatistics(); diff --git a/ui/qt/interface_frame.h b/ui/qt/interface_frame.h index 88a622ff47..fb2a0d80b6 100644 --- a/ui/qt/interface_frame.h +++ b/ui/qt/interface_frame.h @@ -70,6 +70,7 @@ private: QAbstractButton * createButton(QString text, QString property = QString(), QVariant content = QVariant()); void resetInterfaceButtons(); + void resetInterfaceTreeDisplay(); Ui::InterfaceFrame *ui; diff --git a/ui/qt/interface_frame.ui b/ui/qt/interface_frame.ui index 46d4135eb1..0878379d81 100644 --- a/ui/qt/interface_frame.ui +++ b/ui/qt/interface_frame.ui @@ -40,9 +40,18 @@ </property> <item> <widget class="QLabel" name="lblNoInterfaces"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text"> <string>No interfaces found</string> </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> </widget> </item> <item> diff --git a/ui/qt/interface_sort_filter_model.cpp b/ui/qt/interface_sort_filter_model.cpp index b96674eea7..f0265e1a7a 100644 --- a/ui/qt/interface_sort_filter_model.cpp +++ b/ui/qt/interface_sort_filter_model.cpp @@ -146,6 +146,7 @@ void InterfaceSortFilterModel::setInterfaceTypeVisible(int ifType, bool visible) prefs_main_write(); + invalidateFilter(); invalidate(); } @@ -238,6 +239,20 @@ QModelIndex InterfaceSortFilterModel::mapFromSource(const QModelIndex &sourceInd return index(newIndex.row(), _columns.indexOf((InterfaceTreeColumns) sourceIndex.column())); } +QString InterfaceSortFilterModel::interfaceError() +{ + QString result; + + InterfaceTreeModel * sourceModel = dynamic_cast<InterfaceTreeModel *>(this->sourceModel()); + if ( sourceModel != NULL ) + result = sourceModel->interfaceError(); + + if ( result.size() == 0 && rowCount() == 0 ) + result = QString(tr("No interfaces to be displayed. %1 interfaces filtered.")).arg(interfacesHidden()); + + return result; +} + /* * Editor modelines * diff --git a/ui/qt/interface_sort_filter_model.h b/ui/qt/interface_sort_filter_model.h index 187c00e3ab..9e2d323a3b 100644 --- a/ui/qt/interface_sort_filter_model.h +++ b/ui/qt/interface_sort_filter_model.h @@ -54,6 +54,8 @@ public: QModelIndex mapToSource(const QModelIndex &proxyIndex) const; QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; + QString interfaceError(); + protected: bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; bool filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const; |