Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
TaggingRulesModel Class Reference

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

#include <tagging_rules_model.h>

Inheritance diagram for TaggingRulesModel:

Public Types

enum  TaggingRulesColumn {
  colName = 0 , colFilter = 1 , colTag = 2 , colLink = 3 ,
  colComment = 4 , colCount
}
 Defines the columns used in the tagging rules model. More...
enum  TaggingRulesRole { TagContentRole = Qt::UserRole + 1 , TagUrlRole = Qt::UserRole + 2 }
 Custom data roles for TaggingRulesModel. More...

Public Member Functions

 TaggingRulesModel (QObject *parent)
 Constructs a new TaggingRulesModel, cloning the current active rule list.
virtual ~TaggingRulesModel ()
 Destroys the TaggingRulesModel.
void addRule (bool disabled, const QString &name, const QString &filter, const QString &tag_content, const QString &tag_url, const QString &comment)
 Adds a new rule with specified properties.
void addRule (tag_rule_t *rule)
 Adds a rule from a core tag_rule_t structure (used during cloning).
bool loadFromPath (const QString &path, QString &err)
 Load rules from an arbitrary path into the model (replaces current contents).
bool writeToPath (const QString &path, const tag_prefs_t *prefs, QString &err)
 Write current model rules to an arbitrary path.
bool importRules (const QString &path, QString &err)
 Imports tagging rules from a file, appending to the current model.
bool exportRules (const QString &path, QString &err)
 Exports the current tagging rules to a file.
bool writeTags ()
 Applies the model rules as the active list and writes to the active profile's file.
Qt::ItemFlags flags (const QModelIndex &index) const override
 Retrieves the item flags for a given index.
QVariant data (const QModelIndex &index, int role) const override
 Retrieves data from the model for the given index and role.
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 Sets data in the model for the given index and role.
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Retrieves header data for the given section, orientation, and role.
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 Generates an index for the specified row and column.
QModelIndex parent (const QModelIndex &indexItem) const override
 Retrieves the parent index of the specified index.
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of rows under the given parent.
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns under the given parent.
bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) override
 Inserts rows into the model.
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) override
 Removes rows from the model.
bool moveRows (const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override
 Moves rows from one location to another within the model.
Qt::DropActions supportedDropActions () const override
 Specifies the supported drag and drop actions.
QStringList mimeTypes () const override
 Retrieves the list of supported MIME types for drag and drop operations.
QMimeData * mimeData (const QModelIndexList &indexes) const override
 Generates MIME data for the specified list of indexes.
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 Handles dropped MIME data.

Detailed Description

A model managing the tagging rules for packet display.

Member Enumeration Documentation

◆ TaggingRulesColumn

Defines the columns used in the tagging rules model.

Enumerator
colName 

The rule name column (with enabled checkbox).

colFilter 

The filter expression column.

colTag 

The visual tag content column (emoji / text).

colLink 

The URL column (right-click → Follow Link).

colComment 

The comment column.

colCount 

Sentinel: total number of columns.

◆ TaggingRulesRole

Custom data roles for TaggingRulesModel.

Enumerator
TagContentRole 

Role for accessing the tag_content_ field.

TagUrlRole 

Role for accessing the tag_url_ field.

Constructor & Destructor Documentation

◆ TaggingRulesModel()

TaggingRulesModel::TaggingRulesModel ( QObject * parent)
explicit

Constructs a new TaggingRulesModel, cloning the current active rule list.

Parameters
parentThe parent QObject.

Member Function Documentation

◆ addRule()

void TaggingRulesModel::addRule ( tag_rule_t * rule)

Adds a rule from a core tag_rule_t structure (used during cloning).

Copies the rule data and frees the original rule.

Parameters
rulePointer to the core tag rule structure; freed after copying.

◆ columnCount()

int TaggingRulesModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
override

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.

◆ data()

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

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 TaggingRulesModel::dropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent )
override

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.

◆ exportRules()

bool TaggingRulesModel::exportRules ( const QString & path,
QString & err )

Exports the current tagging rules to a file.

Parameters
pathPath of the file to write.
errOutput string set to an error message on failure.
Returns
True if the export succeeded, false otherwise.

◆ flags()

Qt::ItemFlags TaggingRulesModel::flags ( const QModelIndex & index) const
override

Retrieves the item flags for a given index.

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

◆ headerData()

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

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.

◆ importRules()

bool TaggingRulesModel::importRules ( const QString & path,
QString & err )

Imports tagging rules from a file, appending to the current model.

Parameters
pathPath of the file to import.
errOutput string set to an error message on failure.
Returns
True if the import succeeded, false otherwise.

◆ index()

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

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 TaggingRulesModel::insertRows ( int row,
int count,
const QModelIndex & parent = QModelIndex() )
override

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.

◆ loadFromPath()

bool TaggingRulesModel::loadFromPath ( const QString & path,
QString & err )

Load rules from an arbitrary path into the model (replaces current contents).

Parameters
pathFull path to a tagrules.jsonc file.
errSet to error message on failure.
Returns
True on success.

◆ mimeData()

QMimeData * TaggingRulesModel::mimeData ( const QModelIndexList & indexes) const
override

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 TaggingRulesModel::mimeTypes ( ) const
override

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

Returns
A list of supported MIME type strings.

◆ moveRows()

bool TaggingRulesModel::moveRows ( const QModelIndex & sourceParent,
int sourceRow,
int count,
const QModelIndex & destinationParent,
int destinationChild )
override

Moves rows from one location to another within the model.

Parameters
sourceParentThe parent of the source rows.
sourceRowThe first source row.
countThe number of rows to move.
destinationParentThe parent of the destination.
destinationChildThe destination row index.
Returns
True if the move was successful, false otherwise.

◆ parent()

QModelIndex TaggingRulesModel::parent ( const QModelIndex & indexItem) const
override

Retrieves the parent index of the specified index.

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

◆ removeRows()

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

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 TaggingRulesModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

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 TaggingRulesModel::setData ( const QModelIndex & index,
const QVariant & value,
int role = Qt::EditRole )
override

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 TaggingRulesModel::supportedDropActions ( ) const
override

Specifies the supported drag and drop actions.

Returns
The supported drop actions.

◆ writeTags()

bool TaggingRulesModel::writeTags ( )

Applies the model rules as the active list and writes to the active profile's file.

Returns
True if writing succeeded, false otherwise.

◆ writeToPath()

bool TaggingRulesModel::writeToPath ( const QString & path,
const tag_prefs_t * prefs,
QString & err )

Write current model rules to an arbitrary path.

Parameters
pathFull path to write.
prefsPrefs to embed in the file header (may be NULL).
errSet to error message on failure.
Returns
True on success.

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