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

Table model for representing and managing User Accessible Tables (UAT). More...

#include <uat_model.h>

Inheritance diagram for UatModel:

Public Member Functions

 UatModel (QObject *parent, uat_t *uat=0)
 Constructs a new UatModel object using a UAT structure.
 
 UatModel (QObject *parent, QString tableName)
 Constructs a new UatModel object using a UAT table name.
 
Qt::ItemFlags flags (const QModelIndex &index) const
 Returns the item flags for a given index.
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 Retrieves data for a given index and role.
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Retrieves header data for the table.
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of rows under a given parent.
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of columns under a given parent.
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Sets the data for a specific index.
 
bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 Inserts a specified number of rows into the model.
 
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 Removes a specified number of rows from the model.
 
QModelIndex appendEntry (QVariantList row)
 Appends a new entry to the end of the table.
 
QModelIndex copyRow (QModelIndex original)
 Copies an existing row and inserts the copy.
 
bool moveRow (int src_row, int dst_row)
 Moves a row from one position to another.
 
bool moveRows (const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
 Moves multiple rows from one position to another.
 
Qt::DropActions supportedDropActions () const
 Returns the supported drag and drop actions for the model.
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 Handles dropped MIME data to perform drag and drop operations.
 
void reloadUat ()
 Reloads the UAT data from the underlying structure.
 
bool hasErrors () const
 Checks if any records in the model currently have validation errors.
 
void clearAll ()
 Clears all entries from the model.
 
bool applyChanges (QString &error)
 
bool revertChanges (QString &error)
 
QModelIndex findRowForColumnContent (QVariant columnContent, int columnToCheckAgainst, int role=Qt::DisplayRole)
 Finds the first row containing specific content in a given column.
 

Detailed Description

Table model for representing and managing User Accessible Tables (UAT).

Constructor & Destructor Documentation

◆ UatModel() [1/2]

UatModel::UatModel ( QObject *  parent,
uat_t uat = 0 
)

Constructs a new UatModel object using a UAT structure.

Parameters
parentThe parent object.
uatPointer to the UAT structure.

◆ UatModel() [2/2]

UatModel::UatModel ( QObject *  parent,
QString  tableName 
)

Constructs a new UatModel object using a UAT table name.

Parameters
parentThe parent object.
tableNameThe name of the UAT table to load.

Member Function Documentation

◆ appendEntry()

QModelIndex UatModel::appendEntry ( QVariantList  row)

Appends a new entry to the end of the table.

Parameters
rowA list of variants representing the new row data.
Returns
The model index of the newly appended row.

◆ applyChanges()

bool UatModel::applyChanges ( QString &  error)

If the UAT has changed, save the contents to file and invoke the UAT post_update_cb.

Parameters
errorAn error while saving changes, if any.
Returns
true if anything changed, false otherwise.

◆ columnCount()

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

Returns the number of columns under a given parent.

Parameters
parentThe parent model index.
Returns
The number of columns.

◆ copyRow()

QModelIndex UatModel::copyRow ( QModelIndex  original)

Copies an existing row and inserts the copy.

Parameters
originalThe model index of the row to copy.
Returns
The model index of the new copied row.

◆ data()

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

Retrieves data for a given index and role.

Parameters
indexThe model index.
roleThe requested data role.
Returns
The data as a QVariant.

◆ dropMimeData()

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

Handles dropped MIME data to perform drag and drop operations.

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

◆ findRowForColumnContent()

QModelIndex UatModel::findRowForColumnContent ( QVariant  columnContent,
int  columnToCheckAgainst,
int  role = Qt::DisplayRole 
)

Finds the first row containing specific content in a given column.

Parameters
columnContentThe content to search for.
columnToCheckAgainstThe column index to search within.
roleThe data role to compare against.
Returns
The model index of the found row, or an invalid index if not found.

◆ flags()

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

Returns the item flags for a given index.

Parameters
indexThe model index.
Returns
The item flags (e.g., selectable, editable).

◆ hasErrors()

bool UatModel::hasErrors ( ) const

Checks if any records in the model currently have validation errors.

Returns
True if there are errors, false otherwise.

◆ headerData()

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

Retrieves header data for the table.

Parameters
sectionThe column or row index.
orientationThe orientation of the header.
roleThe requested data role.
Returns
The header data as a QVariant.

◆ insertRows()

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

Inserts a specified number of rows into the model.

Parameters
rowThe starting row index.
countThe number of rows to insert.
parentThe parent model index.
Returns
True if successful, false otherwise.

◆ moveRow()

bool UatModel::moveRow ( int  src_row,
int  dst_row 
)

Moves a row from one position to another.

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

◆ moveRows()

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

Moves multiple rows from one position to another.

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

◆ removeRows()

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

Removes a specified number of rows from the model.

Parameters
rowThe starting row index.
countThe number of rows to remove.
parentThe parent model index.
Returns
True if successful, false otherwise.

◆ revertChanges()

bool UatModel::revertChanges ( QString &  error)

Undo any changes to the UAT.

Parameters
errorAn error while restoring the original UAT, if any.
Returns
true if anything changed, false otherwise.

◆ rowCount()

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

Returns the number of rows under a given parent.

Parameters
parentThe parent model index.
Returns
The number of rows.

◆ setData()

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

Sets the data for a specific index.

Parameters
indexThe model index.
valueThe new value to set.
roleThe role for the data being set.
Returns
True if successful, false otherwise.

◆ supportedDropActions()

Qt::DropActions UatModel::supportedDropActions ( ) const

Returns the supported drag and drop actions for the model.

Returns
The supported drop actions.

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