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

A model managing the coloring rules for packet display. More...

#include <coloring_rules_model.h>

Inheritance diagram for ColoringRulesModel:

Public Types

enum  ColoringRulesColumn { colName = 0 , colFilter , colColoringRulesMax }
 Defines the columns used in the coloring rules model. More...
 

Public Member Functions

 ColoringRulesModel (QColor defaultForeground, QColor defaultBackground, QObject *parent)
 Constructs a new ColoringRulesModel.
 
virtual ~ColoringRulesModel ()
 Destroys the ColoringRulesModel.
 
void addColor (color_filter_t *colorf)
 Adds a new color rule from a core color filter.
 
void addColor (bool disabled, QString filter, QColor foreground, QColor background)
 Adds a new color rule with specified properties.
 
bool importColors (QString filename, QString &err)
 Imports coloring rules from a specified file.
 
bool exportColors (QString filename, QString &err)
 Exports the current coloring rules to a file.
 
bool writeColors (QString &err)
 Writes the coloring rules to the internal configuration.
 
Qt::ItemFlags flags (const QModelIndex &index) const
 Retrieves the item flags for a given index.
 
QVariant data (const QModelIndex &index, int role) const
 Retrieves data from the model for the given index and role.
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Sets data in the model for the given index and role.
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Retrieves header data for the given section, orientation, and role.
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 Generates an index for the specified row and column.
 
QModelIndex parent (const QModelIndex &indexItem) const
 Retrieves the parent index of the specified index.
 
Qt::DropActions supportedDropActions () const
 Specifies the supported drag and drop actions.
 
QStringList mimeTypes () const
 Retrieves the list of supported MIME types for drag and drop operations.
 
QMimeData * mimeData (const QModelIndexList &indexes) const
 Generates MIME data for the specified list of indexes.
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 Handles dropped MIME data.
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of rows under the given parent.
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of columns under the given parent.
 
bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 Inserts rows into the model.
 
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 Removes rows from the model.
 
bool copyRow (int dst_row, int src_row)
 Copies a row from one index to another.
 

Detailed Description

A model managing the coloring rules for packet display.

Member Enumeration Documentation

◆ ColoringRulesColumn

Defines the columns used in the coloring rules model.

Enumerator
colName 

The name column.

colFilter 

The filter string column.

colColoringRulesMax 

The maximum number of columns.

Constructor & Destructor Documentation

◆ ColoringRulesModel()

ColoringRulesModel::ColoringRulesModel ( QColor  defaultForeground,
QColor  defaultBackground,
QObject *  parent 
)

Constructs a new ColoringRulesModel.

Parameters
defaultForegroundThe default foreground color.
defaultBackgroundThe default background color.
parentThe parent QObject.

Member Function Documentation

◆ addColor() [1/2]

void ColoringRulesModel::addColor ( bool  disabled,
QString  filter,
QColor  foreground,
QColor  background 
)

Adds a new color rule with specified properties.

Parameters
disabledTrue if the rule is disabled.
filterThe filter string for the rule.
foregroundThe foreground color.
backgroundThe background color.

◆ addColor() [2/2]

void ColoringRulesModel::addColor ( color_filter_t colorf)

Adds a new color rule from a core color filter.

Parameters
colorfPointer to the core color filter structure.

◆ columnCount()

int ColoringRulesModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const

Returns the number of columns under the given parent.

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

◆ copyRow()

bool ColoringRulesModel::copyRow ( int  dst_row,
int  src_row 
)

Copies a row from one index to another.

Parameters
dst_rowThe destination row index.
src_rowThe source row index.
Returns
True if the copy was successful, false otherwise.

◆ data()

QVariant ColoringRulesModel::data ( const QModelIndex &  index,
int  role 
) const

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

Parameters
indexThe model index to retrieve data for.
roleThe role for which data is requested.
Returns
The data associated with the index and role.

◆ dropMimeData()

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

Handles dropped MIME data.

Parameters
dataThe MIME data being dropped.
actionThe drop action being performed.
rowThe target row for the drop.
columnThe target column for the drop.
parentThe target parent index.
Returns
True if the drop was successful, false otherwise.

◆ exportColors()

bool ColoringRulesModel::exportColors ( QString  filename,
QString &  err 
)

Exports the current coloring rules to a file.

Parameters
filenameThe name of the file to export to.
errOutput string for error messages.
Returns
True if the export was successful, false otherwise.

◆ flags()

Qt::ItemFlags ColoringRulesModel::flags ( const QModelIndex &  index) const

Retrieves the item flags for a given index.

Parameters
indexThe model index to query.
Returns
The item flags for the specified index.

◆ headerData()

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

Retrieves header data for the given section, orientation, and role.

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

◆ importColors()

bool ColoringRulesModel::importColors ( QString  filename,
QString &  err 
)

Imports coloring rules from a specified file.

Parameters
filenameThe name of the file to import.
errOutput string for error messages.
Returns
True if the import was successful, false otherwise.

◆ index()

QModelIndex ColoringRulesModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const

Generates an index for the specified row and column.

Parameters
rowThe row number.
columnThe column number.
parentThe parent model index (defaults to an invalid QModelIndex).
Returns
The generated model index.

◆ insertRows()

bool ColoringRulesModel::insertRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)

Inserts rows into the model.

Parameters
rowThe starting row index for insertion.
countThe number of rows to insert.
parentThe parent model index (defaults to an invalid QModelIndex).
Returns
True if the insertion was successful, false otherwise.

◆ mimeData()

QMimeData * ColoringRulesModel::mimeData ( const QModelIndexList &  indexes) const

Generates MIME data for the specified list of indexes.

Parameters
indexesThe list of indexes to generate data for.
Returns
A pointer to the generated QMimeData.

◆ mimeTypes()

QStringList ColoringRulesModel::mimeTypes ( ) const

Retrieves the list of supported MIME types for drag and drop operations.

Returns
A list of supported MIME type strings.

◆ parent()

QModelIndex ColoringRulesModel::parent ( const QModelIndex &  indexItem) const

Retrieves the parent index of the specified index.

Parameters
indexItemThe child model index.
Returns
The parent model index.

◆ removeRows()

bool ColoringRulesModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)

Removes rows from the model.

Parameters
rowThe starting row index for removal.
countThe number of rows to remove.
parentThe parent model index (defaults to an invalid QModelIndex).
Returns
True if the removal was successful, false otherwise.

◆ rowCount()

int ColoringRulesModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Returns the number of rows under the given parent.

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

◆ setData()

bool ColoringRulesModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)

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

Parameters
indexThe model index to update.
valueThe value to set.
roleThe role for which data is being set (defaults to Qt::EditRole).
Returns
True if the data was successfully set, false otherwise.

◆ supportedDropActions()

Qt::DropActions ColoringRulesModel::supportedDropActions ( ) const

Specifies the supported drag and drop actions.

Returns
The supported drop actions.

◆ writeColors()

bool ColoringRulesModel::writeColors ( QString &  err)

Writes the coloring rules to the internal configuration.

Parameters
errOutput string for error messages.
Returns
True if writing was successful, false otherwise.

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