Book Shelf
Loading...
Searching...
No Matches
BookTableModel Class Reference

The BookTableModel class is a table model that stores a list of books. More...

#include <booktablemodel.h>

Inheritance diagram for BookTableModel:

Public Member Functions

 BookTableModel (QObject *parent=nullptr)
 Construct a new Book Table Model object.
 
 ~BookTableModel ()
 Destroy the Book Table Model object.
 
int rowCount (const QModelIndex &parent) const override
 Returns the number of rows in the model.
 
int columnCount (const QModelIndex &parent) const override
 Returns the number of columns in the model.
 
QVariant data (const QModelIndex &index, int role) const override
 Returns the data stored under the given role for the item referred to by the index.
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const override
 Returns the data for the given role and section in the header with the specified orientation.
 
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 Sets the role data for the item at index to value.
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Returns the item flags for the given index.
 
void addBook (Book *book)
 Adds a book to the model.
 
QList< Book * > getBookList () const
 Returns the list of books in the model.
 

Detailed Description

The BookTableModel class is a table model that stores a list of books.

Constructor & Destructor Documentation

◆ BookTableModel()

BookTableModel::BookTableModel ( QObject * parent = nullptr)
explicit

Construct a new Book Table Model object.

Parameters
parentThe parent object.

Member Function Documentation

◆ addBook()

void BookTableModel::addBook ( Book * book)

Adds a book to the model.

Parameters
bookThe book to add.

◆ columnCount()

int BookTableModel::columnCount ( const QModelIndex & parent) const
override

Returns the number of columns in the model.

Parameters
parentThe parent index.
Returns
int The number of columns in the model.

◆ data()

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

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

Parameters
indexThe index of the item.
roleThe role for which to return data.
Returns
QVariant The data stored under the given role for the item referred to by the index.

◆ flags()

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

Returns the item flags for the given index.

Parameters
indexThe index of the item.
Returns
Qt::ItemFlags The item flags for the given index.

◆ getBookList()

QList< Book * > BookTableModel::getBookList ( ) const

Returns the list of books in the model.

Returns
QList<Book *> The list of books in the model.

◆ headerData()

QVariant BookTableModel::headerData ( int section,
Qt::Orientation orientation,
int role ) const
override

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

Parameters
sectionThe section of the header.
orientationThe orientation of the header.
roleThe role for which to return data.
Returns
QVariant The data for the given role and section in the header with the specified orientation.

◆ rowCount()

int BookTableModel::rowCount ( const QModelIndex & parent) const
override

Returns the number of rows in the model.

Parameters
parentThe parent index.
Returns
int The number of rows in the model.

◆ setData()

bool BookTableModel::setData ( const QModelIndex & index,
const QVariant & value,
int role )
override

Sets the role data for the item at index to value.

Parameters
indexThe index of the item.
valueThe value to set.
roleThe role to set.
Returns
true If the data was set successfully.
false If the data was not set successfully.

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