10#ifndef BOOKTABLEMODEL_H
11#define BOOKTABLEMODEL_H
13#include <QAbstractTableModel>
44 int rowCount(
const QModelIndex &parent)
const override;
52 int columnCount(
const QModelIndex &parent)
const override;
61 QVariant
data(
const QModelIndex &index,
int role)
const override;
71 QVariant
headerData(
int section, Qt::Orientation orientation,
int role)
const override;
82 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
90 Qt::ItemFlags
flags(
const QModelIndex &index)
const override;
107 QList<Book*> bookList;
The Book class represents a book object.
Definition book.h:23
The BookTableModel class is a table model that stores a list of books.
Definition booktablemodel.h:23
int rowCount(const QModelIndex &parent) const override
Returns the number of rows in the model.
Definition booktablemodel.cpp:23
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.
Definition booktablemodel.cpp:42
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
Definition booktablemodel.cpp:128
void addBook(Book *book)
Adds a book to the model.
Definition booktablemodel.cpp:140
BookTableModel(QObject *parent=nullptr)
Construct a new Book Table Model object.
Definition booktablemodel.cpp:14
int columnCount(const QModelIndex &parent) const override
Returns the number of columns in the model.
Definition booktablemodel.cpp:32
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.
Definition booktablemodel.cpp:72
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Sets the role data for the item at index to value.
Definition booktablemodel.cpp:100
QList< Book * > getBookList() const
Returns the list of books in the model.
Definition booktablemodel.cpp:148
~BookTableModel()
Destroy the Book Table Model object.
Definition booktablemodel.cpp:18