Qt: add info for extcap disabled in main window.

Add an item to the end of the interface list, if the extcap
interfaces have been disabled.

Change-Id: I2643efb5dda9045e9e00fa3f815014f26a78085f
Reviewed-on: https://code.wireshark.org/review/25218
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Roland Knall 2018-01-12 13:15:58 +01:00 committed by Roland Knall
parent f98cf967bd
commit 42100cb868
4 changed files with 23 additions and 7 deletions

View File

@ -88,7 +88,11 @@ InterfaceFrame::InterfaceFrame(QWidget * parent)
proxyModel->setColumns(columns);
proxyModel->setStoreOnChange(true);
proxyModel->setSourceModel(sourceModel);
ui->interfaceTree->setModel(proxyModel);
infoModel = new InfoProxyModel(2, this);
infoModel->setSourceModel(proxyModel);
ui->interfaceTree->setModel(infoModel);
ui->interfaceTree->setItemDelegateForColumn(proxyModel->mapSourceToColumn(IFTREE_COL_STATS), new SparkLineDelegate(this));
@ -168,7 +172,7 @@ void InterfaceFrame::ensureSelectedInterface()
if (interfacesPresent() < 1) return;
if (sourceModel->selectedDevices().count() < 1) {
QModelIndex first_idx = proxyModel->index(0, 0);
QModelIndex first_idx = infoModel->mapFromSource(proxyModel->index(0, 0));
ui->interfaceTree->setCurrentIndex(first_idx);
}
@ -218,6 +222,10 @@ void InterfaceFrame::triggeredIfTypeButton()
void InterfaceFrame::interfaceListChanged()
{
infoModel->clearInfos();
if ( prefs.capture_no_extcap )
infoModel->appendInfo(tr("Extcap interfaces disabled."));
resetInterfaceTreeDisplay();
// Ensure that device selection is consistent with the displayed selection.
updateSelectedInterfaces();
@ -272,7 +280,7 @@ void InterfaceFrame::updateSelectedInterfaces()
return;
#ifdef HAVE_LIBPCAP
QItemSelection sourceSelection = sourceModel->selectedDevices();
QItemSelection mySelection = proxyModel->mapSelectionFromSource(sourceSelection);
QItemSelection mySelection = infoModel->mapSelectionFromSource(proxyModel->mapSelectionFromSource(sourceSelection));
ui->interfaceTree->selectionModel()->clearSelection();
ui->interfaceTree->selectionModel()->select(mySelection, QItemSelectionModel::SelectCurrent );
@ -289,7 +297,7 @@ void InterfaceFrame::interfaceTreeSelectionChanged(const QItemSelection & select
#ifdef HAVE_LIBPCAP
/* Take all selected interfaces, not just the newly ones */
QItemSelection allSelected = ui->interfaceTree->selectionModel()->selection();
QItemSelection sourceSelection = proxyModel->mapSelectionToSource(allSelected);
QItemSelection sourceSelection = proxyModel->mapSelectionToSource(infoModel->mapSelectionToSource(allSelected));
if ( sourceModel->updateSelectedDevices(sourceSelection) )
emit itemSelectionChanged();
@ -298,7 +306,7 @@ void InterfaceFrame::interfaceTreeSelectionChanged(const QItemSelection & select
void InterfaceFrame::on_interfaceTree_doubleClicked(const QModelIndex &index)
{
QModelIndex realIndex = proxyModel->mapToSource(index);
QModelIndex realIndex = proxyModel->mapToSource(infoModel->mapToSource(index));
if ( ! realIndex.isValid() )
return;
@ -328,7 +336,7 @@ void InterfaceFrame::on_interfaceTree_clicked(const QModelIndex &index)
{
if ( index.column() == 0 )
{
QModelIndex realIndex = proxyModel->mapToSource(index);
QModelIndex realIndex = proxyModel->mapToSource(infoModel->mapToSource(index));
if ( ! realIndex.isValid() )
return;
@ -360,7 +368,7 @@ void InterfaceFrame::updateStatistics(void)
for( int idx = 0; idx < proxyModel->rowCount(); idx++ )
{
QModelIndex selectIndex = proxyModel->mapFromSource(sourceModel->index(idx, 0));
QModelIndex selectIndex = infoModel->mapFromSource(proxyModel->mapFromSource(sourceModel->index(idx, 0)));
/* Proxy model has not masked out the interface */
if ( selectIndex.isValid() )

View File

@ -28,6 +28,7 @@
#include <glib.h>
#include <ui/qt/models/info_proxy_model.h>
#include <ui/qt/models/interface_tree_model.h>
#include <ui/qt/models/interface_sort_filter_model.h>
@ -82,6 +83,7 @@ private:
InterfaceSortFilterModel * proxyModel;
InterfaceTreeModel * sourceModel;
InfoProxyModel * infoModel;
QMap<int, QString> ifTypeDescription;

View File

@ -30,6 +30,11 @@ void InfoProxyModel::appendInfo(QString info)
infos_ << info;
}
void InfoProxyModel::clearInfos()
{
infos_.clear();
}
int InfoProxyModel::rowCount(const QModelIndex &parent) const
{
return sourceModel()->rowCount(parent) + infos_.count();

View File

@ -34,6 +34,7 @@ public:
virtual QModelIndex mapFromSource(const QModelIndex &fromIndex) const;
void appendInfo(QString info);
void clearInfos();
private: