The BookTableModel class is a table model that stores a list of books.
More...
#include <booktablemodel.h>
|
| 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.
|
|
The BookTableModel class is a table model that stores a list of books.
◆ BookTableModel()
BookTableModel::BookTableModel |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
Construct a new Book Table Model object.
- Parameters
-
◆ addBook()
void BookTableModel::addBook |
( |
Book * | book | ) |
|
Adds a book to the model.
- Parameters
-
◆ columnCount()
int BookTableModel::columnCount |
( |
const QModelIndex & | parent | ) |
const |
|
override |
Returns the number of columns in the model.
- Parameters
-
- 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
-
index | The index of the item. |
role | The 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
-
index | The 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
-
section | The section of the header. |
orientation | The orientation of the header. |
role | The 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
-
- 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
-
index | The index of the item. |
value | The value to set. |
role | The 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: