-
Notifications
You must be signed in to change notification settings - Fork 0
/
itemsmodel.h
32 lines (27 loc) · 1.05 KB
/
itemsmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef ITEMSMODEL_H
#define ITEMSMODEL_H
#include <QSqlTableModel>
#include <QObject>
#include <QImage>
#include <QTextDocument>
#include <QDebug>
/*! \class ItemsModel
* \brief Simple QSqlTableModel descendant providing data for the items table view. */
class ItemsModel : public QSqlTableModel
{
Q_OBJECT
public:
/*! \brief Generic constructor.
* \param parent Optional parent object or nullptr
* \param db Database instance */
ItemsModel(QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase());
/*! \brief Simple override of generic select() with lazy model population off
* \return true if model is successfuly populated */
bool select() override;
/*! \brief QSqlTableModel::data() override. Removes HTML from descriptions.
* \param idx Index of the data from model
* \param role Role of the data that index is pointing to
* \return QVariant with data or empty QVariant() if data not available */
QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
};
#endif // ITEMSMODEL_H