Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
FilterListModel Class Reference

A list model for managing capture filters, display filters, and display macros. More...

#include <filter_list_model.h>

Inheritance diagram for FilterListModel:

Classes

struct  FilterListValue
 Represents a single filter entry with a name and an expression. More...
 

Public Types

enum  FilterListType { Display , Capture , DisplayMacro }
 Defines the type of filter list. More...
 
enum  { ColumnName , ColumnExpression }
 Enumerates the columns for the filter list model. More...
 

Public Member Functions

 FilterListModel (FilterListType type=FilterListModel::Display, QObject *parent=Q_NULLPTR)
 Constructs a new FilterListModel with a specific type.
 
 FilterListModel (QObject *parent=Q_NULLPTR)
 Constructs a new FilterListModel.
 
void setFilterType (FilterListModel::FilterListType type)
 Sets the filter type for this model.
 
FilterListModel::FilterListType filterType () const
 Retrieves the current filter type of the model.
 
QModelIndex findByName (QString name)
 Finds a filter by its name.
 
QModelIndex findByExpression (QString expression)
 Finds a filter by its expression.
 
QModelIndex addFilter (QString name, QString expression)
 Adds a new filter to the list.
 
void removeFilter (QModelIndex idx)
 Removes a filter at the specified index.
 
void saveList ()
 Saves the current list of filters to persistent storage.
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of rows under a given parent.
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns under a given parent.
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Retrieves data from the model for a given index and role.
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role) override
 Sets data in the model for a given index and role.
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Retrieves the header data for a specific section and role.
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const override
 Retrieves the item flags for a given index.
 
virtual Qt::DropActions supportedDropActions () const override
 Retrieves the drop actions supported by the model.
 
virtual QStringList mimeTypes () const override
 Retrieves the MIME types supported by the model for drag and drop operations.
 
virtual QMimeData * mimeData (const QModelIndexList &indexes) const override
 Creates MIME data representing the given model indices.
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 Handles dropped MIME data to insert items into the model.
 

Detailed Description

A list model for managing capture filters, display filters, and display macros.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Enumerates the columns for the filter list model.

Enumerator
ColumnName 

The filter name column.

ColumnExpression 

The filter expression column.

◆ FilterListType

Defines the type of filter list.

Enumerator
Display 

A list of display filters.

Capture 

A list of capture filters.

DisplayMacro 

A list of display macros.

Constructor & Destructor Documentation

◆ FilterListModel() [1/2]

FilterListModel::FilterListModel ( FilterListModel::FilterListType  type = FilterListModel::Display,
QObject *  parent = Q_NULLPTR 
)
explicit

Constructs a new FilterListModel with a specific type.

Parameters
typeThe type of filter list (defaults to FilterListModel::Display).
parentThe parent QObject, defaults to Q_NULLPTR.

◆ FilterListModel() [2/2]

FilterListModel::FilterListModel ( QObject *  parent = Q_NULLPTR)
explicit

Constructs a new FilterListModel.

Parameters
parentThe parent QObject, defaults to Q_NULLPTR.

Member Function Documentation

◆ addFilter()

QModelIndex FilterListModel::addFilter ( QString  name,
QString  expression 
)

Adds a new filter to the list.

Parameters
nameThe name of the new filter.
expressionThe expression string of the new filter.
Returns
The model index of the newly added filter.

◆ columnCount()

int FilterListModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
overridevirtual

Returns the number of columns under a given parent.

Parameters
parentThe parent model index (defaults to an invalid QModelIndex).
Returns
The number of columns.

◆ data()

QVariant FilterListModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
overridevirtual

Retrieves data from the model for a given index and role.

Parameters
indexThe model index.
roleThe data role requested (defaults to Qt::DisplayRole).
Returns
The data associated with the index and role.

◆ dropMimeData()

bool FilterListModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)
overridevirtual

Handles dropped MIME data to insert items into the model.

Parameters
dataThe MIME data dropped.
actionThe drop action performed.
rowThe row where the drop occurred.
columnThe column where the drop occurred.
parentThe parent model index.
Returns
True if the drop was successfully handled, false otherwise.

◆ filterType()

FilterListModel::FilterListType FilterListModel::filterType ( ) const

Retrieves the current filter type of the model.

Returns
The filter list type.

◆ findByExpression()

QModelIndex FilterListModel::findByExpression ( QString  expression)

Finds a filter by its expression.

Parameters
expressionThe expression to search for.
Returns
The model index of the found filter, or an invalid index if not found.

◆ findByName()

QModelIndex FilterListModel::findByName ( QString  name)

Finds a filter by its name.

Parameters
nameThe name to search for.
Returns
The model index of the found filter, or an invalid index if not found.

◆ flags()

Qt::ItemFlags FilterListModel::flags ( const QModelIndex &  index) const
overridevirtual

Retrieves the item flags for a given index.

Parameters
indexThe model index.
Returns
The item flags.

◆ headerData()

QVariant FilterListModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
overridevirtual

Retrieves the header data for a specific section and role.

Parameters
sectionThe column or row section.
orientationThe orientation of the header.
roleThe data role requested (defaults to Qt::DisplayRole).
Returns
The header data.

◆ mimeData()

QMimeData * FilterListModel::mimeData ( const QModelIndexList &  indexes) const
overridevirtual

Creates MIME data representing the given model indices.

Parameters
indexesThe list of model indices to encode.
Returns
A pointer to the created QMimeData.

◆ mimeTypes()

QStringList FilterListModel::mimeTypes ( ) const
overridevirtual

Retrieves the MIME types supported by the model for drag and drop operations.

Returns
A list of supported MIME types.

◆ removeFilter()

void FilterListModel::removeFilter ( QModelIndex  idx)

Removes a filter at the specified index.

Parameters
idxThe model index of the filter to remove.

◆ rowCount()

int FilterListModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
overridevirtual

Returns the number of rows under a given parent.

Parameters
parentThe parent model index (defaults to an invalid QModelIndex).
Returns
The number of rows.

◆ setData()

bool FilterListModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)
overridevirtual

Sets data in the model for a given index and role.

Parameters
indexThe model index to update.
valueThe value to set.
roleThe role being edited.
Returns
True if successful, false otherwise.

◆ setFilterType()

void FilterListModel::setFilterType ( FilterListModel::FilterListType  type)

Sets the filter type for this model.

Parameters
typeThe filter list type to set.

◆ supportedDropActions()

Qt::DropActions FilterListModel::supportedDropActions ( ) const
overridevirtual

Retrieves the drop actions supported by the model.

Returns
The supported drop actions.

The documentation for this class was generated from the following files: