NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
Public Member Functions | List of all members
NetSim::PackageTableModel Class Reference

Custom table model to represent a list of Package objects. More...

#include <packagetablemodel.h>

Inheritance diagram for NetSim::PackageTableModel:
Inheritance graph
[legend]
Collaboration diagram for NetSim::PackageTableModel:
Collaboration graph
[legend]

Public Member Functions

 PackageTableModel (QList< Package > *packageList, QObject *parent=nullptr)
 Constructs a new table model with a given list of packages and parent.
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Returns the data for the given role and section in the header with the specified orientation.
 
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.
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Returns the data stored under the given role for the item referred to by the index.
 
void addPackage (const Package &package)
 Adds a new package to the table model.
 

Detailed Description

Custom table model to represent a list of Package objects.

The PackageTableModel class provides functionalities to represent and manage a list of Package objects in a table view, building upon Qt's QAbstractTableModel.

Constructor & Destructor Documentation

◆ PackageTableModel()

PackageTableModel::PackageTableModel ( QList< Package > *  packageList,
QObject *  parent = nullptr 
)
explicit

Constructs a new table model with a given list of packages and parent.

Parameters
packageListPointer to the list of packages.
parentThe parent QObject.

Member Function Documentation

◆ addPackage()

void PackageTableModel::addPackage ( const Package package)

Adds a new package to the table model.

Parameters
packageThe package to add.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ columnCount()

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

Returns the number of columns under the given parent.

Parameters
parentThe parent QModelIndex.
Return values
intNumber of columns.

◆ data()

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

Returns the data stored under the given role for the item referred to by the index.

Parameters
indexThe QModelIndex.
roleThe role of the data.
Return values
QVariantData for the given role and index.
Here is the call graph for this function:

◆ headerData()

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

Returns the data for the given role and section in the header with the specified orientation.

Parameters
sectionThe section of the header.
orientationHorizontal or Vertical.
roleThe role of the data.
Return values
QVariantData for the given role and section.

◆ rowCount()

int PackageTableModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Returns the number of rows under the given parent.

Parameters
parentThe parent QModelIndex.
Return values
intNumber of rows.
Here is the caller graph for this function:

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