aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/models/interface_tree_model.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/models/interface_tree_model.cpp')
-rw-r--r--ui/qt/models/interface_tree_model.cpp144
1 files changed, 72 insertions, 72 deletions
diff --git a/ui/qt/models/interface_tree_model.cpp b/ui/qt/models/interface_tree_model.cpp
index 14e0944250..27a329b317 100644
--- a/ui/qt/models/interface_tree_model.cpp
+++ b/ui/qt/models/interface_tree_model.cpp
@@ -62,12 +62,12 @@ InterfaceTreeModel::~InterfaceTreeModel(void)
QString InterfaceTreeModel::interfaceError()
{
QString errorText;
- if ( rowCount() == 0 )
+ if (rowCount() == 0)
{
errorText = tr("No Interfaces found.");
}
#ifdef HAVE_LIBPCAP
- else if ( global_capture_opts.ifaces_err != 0 )
+ else if (global_capture_opts.ifaces_err != 0)
{
errorText = tr(global_capture_opts.ifaces_err_info);
}
@@ -76,7 +76,7 @@ QString InterfaceTreeModel::interfaceError()
return errorText;
}
-int InterfaceTreeModel::rowCount(const QModelIndex & ) const
+int InterfaceTreeModel::rowCount(const QModelIndex &) const
{
#ifdef HAVE_LIBPCAP
return (global_capture_opts.all_ifaces ? global_capture_opts.all_ifaces->len : 0);
@@ -86,7 +86,7 @@ int InterfaceTreeModel::rowCount(const QModelIndex & ) const
#endif
}
-int InterfaceTreeModel::columnCount(const QModelIndex & ) const
+int InterfaceTreeModel::columnCount(const QModelIndex &) const
{
/* IFTREE_COL_MAX is not being displayed, it is the definition for the maximum numbers of columns */
return ((int) IFTREE_COL_MAX);
@@ -96,71 +96,71 @@ 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 )
+ if (! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len == 0)
interfacesLoaded = false;
- if ( !index.isValid() )
+ if (!index.isValid())
return QVariant();
int row = index.row();
InterfaceTreeColumns col = (InterfaceTreeColumns) index.column();
- if ( interfacesLoaded )
+ if (interfacesLoaded)
{
interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, row);
/* Data for display in cell */
- if ( role == Qt::DisplayRole )
+ if (role == Qt::DisplayRole)
{
/* Only the name is being displayed */
- if ( col == IFTREE_COL_NAME )
+ if (col == IFTREE_COL_NAME)
{
return QString(device->name);
}
- else if ( col == IFTREE_COL_DESCRIPTION )
+ else if (col == IFTREE_COL_DESCRIPTION)
{
return QString(device->friendly_name);
}
- else if ( col == IFTREE_COL_DISPLAY_NAME )
+ else if (col == IFTREE_COL_DISPLAY_NAME)
{
return QString(device->display_name);
}
- else if ( col == IFTREE_COL_PIPE_PATH )
+ else if (col == IFTREE_COL_PIPE_PATH)
{
return QString(device->if_info.name);
}
- else if ( col == IFTREE_COL_CAPTURE_FILTER )
+ else if (col == IFTREE_COL_CAPTURE_FILTER)
{
- if ( device->cfilter && strlen(device->cfilter) > 0 )
+ if (device->cfilter && strlen(device->cfilter) > 0)
return html_escape(QString(device->cfilter));
}
- else if ( col == IFTREE_COL_EXTCAP_PATH )
+ else if (col == IFTREE_COL_EXTCAP_PATH)
{
return QString(device->if_info.extcap);
}
- else if ( col == IFTREE_COL_SNAPLEN )
+ else if (col == IFTREE_COL_SNAPLEN)
{
return device->has_snaplen ? QString::number(device->snaplen) : DefaultNumericValue;
}
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- else if ( col == IFTREE_COL_BUFFERLEN )
+ else if (col == IFTREE_COL_BUFFERLEN)
{
return QString::number(device->buffer);
}
#endif
- else if ( col == IFTREE_COL_TYPE )
+ else if (col == IFTREE_COL_TYPE)
{
return QVariant::fromValue((int)device->if_info.type);
}
- else if ( col == IFTREE_COL_COMMENT )
+ else if (col == IFTREE_COL_COMMENT)
{
QString comment = gchar_free_to_qstring(capture_dev_user_descr_find(device->name));
- if ( comment.length() > 0 )
+ if (comment.length() > 0)
return comment;
else
return QString(device->if_info.vendor_description);
}
- else if ( col == IFTREE_COL_DLT )
+ else if (col == IFTREE_COL_DLT)
{
// XXX - this is duplicated in
// InterfaceTreeWidgetItem::updateInterfaceColumns;
@@ -187,55 +187,55 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const
return QVariant();
}
}
- else if ( role == Qt::CheckStateRole )
+ else if (role == Qt::CheckStateRole)
{
- if ( col == IFTREE_COL_HIDDEN )
+ if (col == IFTREE_COL_HIDDEN)
{
/* Hidden is a de-selection, therefore inverted logic here */
return device->hidden ? Qt::Unchecked : Qt::Checked;
}
- else if ( col == IFTREE_COL_PROMISCUOUSMODE )
+ else if (col == IFTREE_COL_PROMISCUOUSMODE)
{
return device->pmode ? Qt::Checked : Qt::Unchecked;
}
#ifdef HAVE_PCAP_CREATE
- else if ( col == IFTREE_COL_MONITOR_MODE )
+ else if (col == IFTREE_COL_MONITOR_MODE)
{
return device->monitor_mode_enabled ? Qt::Checked : Qt::Unchecked;
}
#endif
}
/* Used by SparkLineDelegate for loading the data for the statistics line */
- else if ( role == Qt::UserRole )
+ else if (role == Qt::UserRole)
{
- if ( col == IFTREE_COL_STATS )
+ if (col == IFTREE_COL_STATS)
{
- if ( points.contains(device->name) )
+ if (points.contains(device->name))
return QVariant::fromValue(points[device->name]);
}
- else if ( col == IFTREE_COL_HIDDEN )
+ else if (col == IFTREE_COL_HIDDEN)
{
return QVariant::fromValue((bool)device->hidden);
}
}
/* Displays the configuration icon for extcap interfaces */
- else if ( role == Qt::DecorationRole )
+ else if (role == Qt::DecorationRole)
{
- if ( col == IFTREE_COL_EXTCAP )
+ if (col == IFTREE_COL_EXTCAP)
{
- if ( device->if_info.type == IF_EXTCAP )
+ if (device->if_info.type == IF_EXTCAP)
return QIcon(StockIcon("x-capture-options"));
}
}
- else if ( role == Qt::TextAlignmentRole )
+ else if (role == Qt::TextAlignmentRole)
{
- if ( col == IFTREE_COL_EXTCAP )
+ if (col == IFTREE_COL_EXTCAP)
{
return Qt::AlignRight;
}
}
/* Displays the tooltip for each row */
- else if ( role == Qt::ToolTipRole )
+ else if (role == Qt::ToolTipRole)
{
return toolTipForInterface(row);
}
@@ -250,59 +250,59 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const
QVariant InterfaceTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
{
- if ( orientation == Qt::Horizontal )
+ if (orientation == Qt::Horizontal)
{
- if ( role == Qt::DisplayRole )
+ if (role == Qt::DisplayRole)
{
- if ( section == IFTREE_COL_HIDDEN )
+ if (section == IFTREE_COL_HIDDEN)
{
return tr("Show");
}
- else if ( section == IFTREE_COL_NAME )
+ else if (section == IFTREE_COL_NAME)
{
return tr("Interface Name");
}
- else if ( section == IFTREE_COL_DESCRIPTION )
+ else if (section == IFTREE_COL_DESCRIPTION)
{
return tr("Friendly Name");
}
- else if ( section == IFTREE_COL_DISPLAY_NAME )
+ else if (section == IFTREE_COL_DISPLAY_NAME)
{
return tr("Friendly Name");
}
- else if ( section == IFTREE_COL_PIPE_PATH )
+ else if (section == IFTREE_COL_PIPE_PATH)
{
return tr("Local Pipe Path");
}
- else if ( section == IFTREE_COL_COMMENT )
+ else if (section == IFTREE_COL_COMMENT)
{
return tr("Comment");
}
- else if ( section == IFTREE_COL_DLT )
+ else if (section == IFTREE_COL_DLT)
{
return tr("Link-Layer Header");
}
- else if ( section == IFTREE_COL_PROMISCUOUSMODE )
+ else if (section == IFTREE_COL_PROMISCUOUSMODE)
{
return tr("Promiscuous");
}
- else if ( section == IFTREE_COL_SNAPLEN )
+ else if (section == IFTREE_COL_SNAPLEN)
{
return tr("Snaplen (B)");
}
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- else if ( section == IFTREE_COL_BUFFERLEN )
+ else if (section == IFTREE_COL_BUFFERLEN)
{
return tr("Buffer (MB)");
}
#endif
#ifdef HAVE_PCAP_CREATE
- else if ( section == IFTREE_COL_MONITOR_MODE )
+ else if (section == IFTREE_COL_MONITOR_MODE)
{
return tr("Monitor Mode");
}
#endif
- else if ( section == IFTREE_COL_CAPTURE_FILTER )
+ else if (section == IFTREE_COL_CAPTURE_FILTER)
{
return tr("Capture Filter");
}
@@ -321,7 +321,7 @@ QVariant InterfaceTreeModel::getColumnContent(int idx, int col, int role)
bool InterfaceTreeModel::isRemote(int idx)
{
interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx);
- if ( device->remote_opts.src_type == CAPTURE_IFREMOTE )
+ if (device->remote_opts.src_type == CAPTURE_IFREMOTE)
return true;
return false;
}
@@ -347,20 +347,20 @@ 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)
+ if (! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx)
return QVariant();
interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx);
QString tt_str = "<p>";
- if ( device->no_addresses > 0 )
+ if (device->no_addresses > 0)
{
tt_str += QString("%1: %2")
.arg(device->no_addresses > 1 ? tr("Addresses") : tr("Address"))
.arg(html_escape(device->addresses))
.replace('\n', ", ");
}
- else if ( device->if_info.type == IF_EXTCAP )
+ else if (device->if_info.type == IF_EXTCAP)
{
tt_str = QString(tr("Extcap interface: %1")).arg(get_basename(device->if_info.extcap));
}
@@ -371,7 +371,7 @@ QVariant InterfaceTreeModel::toolTipForInterface(int idx) const
tt_str += "<br/>";
QString cfilter = device->cfilter;
- if ( cfilter.isEmpty() )
+ if (cfilter.isEmpty())
{
tt_str += tr("No capture filter");
}
@@ -394,7 +394,7 @@ QVariant InterfaceTreeModel::toolTipForInterface(int idx) const
#ifdef HAVE_LIBPCAP
void InterfaceTreeModel::stopStatistic()
{
- if ( stat_cache_ )
+ if (stat_cache_)
{
capture_stat_stop(stat_cache_);
stat_cache_ = NULL;
@@ -405,15 +405,15 @@ void InterfaceTreeModel::stopStatistic()
void InterfaceTreeModel::updateStatistic(unsigned int idx)
{
#ifdef HAVE_LIBPCAP
- if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx )
+ 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 ( device->if_info.type == IF_PIPE )
+ if (device->if_info.type == IF_PIPE)
return;
- if ( !stat_cache_ )
+ if (!stat_cache_)
{
// Start gathering statistics using dumpcap
// We crash (on macOS at least) if we try to do this from ::showEvent.
@@ -423,9 +423,9 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx)
struct pcap_stat stats;
unsigned diff = 0;
- if ( capture_stats(stat_cache_, device->name, &stats) )
+ if (capture_stats(stat_cache_, device->name, &stats))
{
- if ( (int)(stats.ps_recv - device->last_packets) >= 0 )
+ if ((int)(stats.ps_recv - device->last_packets) >= 0)
{
diff = stats.ps_recv - device->last_packets;
device->packet_diff = diff;
@@ -443,11 +443,11 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx)
void InterfaceTreeModel::getPoints(int idx, PointList *pts)
{
#ifdef HAVE_LIBPCAP
- if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx )
+ 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) )
+ if (points.contains(device->name))
pts->append(points[device->name]);
#else
Q_UNUSED(idx)
@@ -459,15 +459,15 @@ QItemSelection InterfaceTreeModel::selectedDevices()
{
QItemSelection mySelection;
#ifdef HAVE_LIBPCAP
- for( int idx = 0; idx < rowCount(); idx++ )
+ for (int idx = 0; idx < rowCount(); idx++)
{
interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx);
- if ( device->selected )
+ if (device->selected)
{
QModelIndex selectIndex = index(idx, 0);
mySelection.merge(
- QItemSelection( selectIndex, index(selectIndex.row(), columnCount() - 1) ),
+ QItemSelection(selectIndex, index(selectIndex.row(), columnCount() - 1)),
QItemSelectionModel::SelectCurrent
);
}
@@ -483,15 +483,15 @@ bool InterfaceTreeModel::updateSelectedDevices(QItemSelection sourceSelection)
QList<int> selectedIndices;
QItemSelection::const_iterator it = sourceSelection.constBegin();
- while(it != sourceSelection.constEnd())
+ while (it != sourceSelection.constEnd())
{
QModelIndexList indeces = ((QItemSelectionRange) (*it)).indexes();
QModelIndexList::const_iterator cit = indeces.constBegin();
- while(cit != indeces.constEnd())
+ while (cit != indeces.constEnd())
{
QModelIndex index = (QModelIndex) (*cit);
- if ( ! selectedIndices.contains(index.row()) )
+ if (! selectedIndices.contains(index.row()))
{
selectedIndices.append(index.row());
}
@@ -502,17 +502,17 @@ bool InterfaceTreeModel::updateSelectedDevices(QItemSelection sourceSelection)
global_capture_opts.num_selected = 0;
- for ( unsigned int idx = 0; idx < global_capture_opts.all_ifaces->len; idx++ )
+ for (unsigned int idx = 0; idx < global_capture_opts.all_ifaces->len; idx++)
{
interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx);
- if ( selectedIndices.contains(idx) )
+ if (selectedIndices.contains(idx))
{
- if (! device->selected )
+ if (! device->selected)
selectionHasChanged = true;
device->selected = TRUE;
global_capture_opts.num_selected++;
} else {
- if ( device->selected )
+ if (device->selected)
selectionHasChanged = true;
device->selected = FALSE;
}