NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
CustomTableWidget Class Reference

The CustomTableWidget class is a subclass of QTableWidget that provides additional functionality and customization for table widgets. More...

#include <customtablewidget.h>

Inheritance diagram for CustomTableWidget:

Signals

void keyPress (QKeyEvent *event)
 Signal emitted when a key press event occurs in the table.
 
void cannotDeleteRow ()
 Signal emitted when row deletion is not allowed.
 

Public Member Functions

 CustomTableWidget (QWidget *parent=nullptr)
 Constructs a CustomTableWidget object.
 
bool hasEmptyCell (const QList< int > &exceptionColumns=QList< int >())
 Checks if the table has any empty cells.
 
bool isRowEmpty (int row, const QList< int > &exceptionColumns=QList< int >())
 Checks if a row is empty.
 
bool isTableIncomplete (const QList< int > &exceptionColumns=QList< int >())
 Checks if the table is incomplete, i.e., if it does not have at least one complete row of data.
 
void setCheckboxDelegateForColumns (int row, const QList< int > &columns)
 Sets a checkbox delegate for the specified columns in a row.
 
void setNumericDelegateForColumns (int row, const QList< int > &columns)
 Sets a numeric delegate for the specified columns in a row.
 
void setupTable ()
 Performs initial setup for the table.
 
int generateUniqueID ()
 Generates a unique ID.
 

Protected Member Functions

void keyPressEvent (QKeyEvent *event) override
 Overridden keyPressEvent() method to handle key press events in the table.
 
void setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Overridden setData() method for custom handling of data changes in the table.
 

Detailed Description

The CustomTableWidget class is a subclass of QTableWidget that provides additional functionality and customization for table widgets.

Constructor & Destructor Documentation

◆ CustomTableWidget()

CustomTableWidget::CustomTableWidget ( QWidget *  parent = nullptr)

Constructs a CustomTableWidget object.

Parameters
parentThe parent widget.

Member Function Documentation

◆ cannotDeleteRow

void CustomTableWidget::cannotDeleteRow ( )
signal

Signal emitted when row deletion is not allowed.

This signal indicates that a row cannot be deleted.

◆ generateUniqueID()

int CustomTableWidget::generateUniqueID ( )

Generates a unique ID.

This method can be used to generate unique identifiers for table entries.

Returns
The generated unique ID.

◆ hasEmptyCell()

bool CustomTableWidget::hasEmptyCell ( const QList< int > &  exceptionColumns = QList<int>())

Checks if the table has any empty cells.

Parameters
exceptionColumnsThe columns to exclude from the check.
Returns
True if there is at least one empty cell, false otherwise.

◆ isRowEmpty()

bool CustomTableWidget::isRowEmpty ( int  row,
const QList< int > &  exceptionColumns = QList<int>() 
)

Checks if a row is empty.

Parameters
rowThe row index.
exceptionColumnsThe columns to exclude from the check.
Returns
True if the row is empty, false otherwise.

◆ isTableIncomplete()

bool CustomTableWidget::isTableIncomplete ( const QList< int > &  exceptionColumns = QList<int>())

Checks if the table is incomplete, i.e., if it does not have at least one complete row of data.

A row is considered complete if all cells in the row have non-empty data.

Parameters
exceptionColumns(optional) A list of column indices to exclude from the completeness check. Any rows that only have empty cells in the specified columns will still be considered incomplete. Defaults to an empty list, which means all columns will be considered for completeness.
Returns
true if the table is incomplete, i.e., it does not have at least one complete row of data. false if the table has at least one complete row.

◆ keyPress

void CustomTableWidget::keyPress ( QKeyEvent *  event)
signal

Signal emitted when a key press event occurs in the table.

Parameters
eventThe key event.

◆ keyPressEvent()

void CustomTableWidget::keyPressEvent ( QKeyEvent *  event)
overrideprotected

Overridden keyPressEvent() method to handle key press events in the table.

Parameters
eventThe key event.

◆ setCheckboxDelegateForColumns()

void CustomTableWidget::setCheckboxDelegateForColumns ( int  row,
const QList< int > &  columns 
)

Sets a checkbox delegate for the specified columns in a row.

Parameters
rowThe row index.
columnsThe columns to set the checkbox delegate for.

◆ setData()

void CustomTableWidget::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
protected

Overridden setData() method for custom handling of data changes in the table.

Parameters
indexThe model index of the item.
valueThe new value for the item.
roleThe role for the item.

◆ setNumericDelegateForColumns()

void CustomTableWidget::setNumericDelegateForColumns ( int  row,
const QList< int > &  columns 
)

Sets a numeric delegate for the specified columns in a row.

Parameters
rowThe row index.
columnsThe columns to set the numeric delegate for.

◆ setupTable()

void CustomTableWidget::setupTable ( )

Performs initial setup for the table.

This includes setting up default properties and signals/slots connections.