|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
The inventory: one row per part, with totals. Knows nothing about widgets. More...
Public Types | |
| enum | Column { SkuColumn , NameColumn , QuantityColumn , PriceColumn , ValueColumn , ColumnCount } |
| The columns the table shows. | |
| enum | Role { SkuRole = Qt::UserRole + 1 , NameRole , QuantityRole , PriceRole , ValueRole } |
| The roles a QML view uses, the same in every column. | |
Public Member Functions | |
| Inventory (QList< Part > parts, QObject *parent=nullptr) | |
An inventory holding parts. | |
| int | count () const |
| How many kinds of part there are. | |
| int | totalQuantity () const |
| How many pieces there are, of every kind. | |
| double | totalValue () const |
| What the whole stock is worth, in dollars. | |
| int | rowCount (const QModelIndex &parent={ }) const override |
| See QAbstractItemModel. | |
| int | columnCount (const QModelIndex &parent={ }) const override |
| See QAbstractItemModel. | |
| QVariant | data (const QModelIndex &index, int role) const override |
| See QAbstractItemModel. | |
| QVariant | headerData (int section, Qt::Orientation orientation, int role) const override |
| See QAbstractItemModel. | |
| QHash< int, QByteArray > | roleNames () const override |
| See QAbstractItemModel. | |
| bool | addPart (const QString &sku, const QString &name, int quantity, double price) |
| Adds a part. | |
| bool | adjust (const QString &sku, int delta) |
Adds delta to the quantity of sku (never below zero). | |
| bool | removePart (const QString &sku) |
Removes sku. | |
| void | countChanged () |
| The number of parts changed. | |
| void | totalsChanged () |
| A quantity changed, or a part was added or removed. | |
Static Public Member Functions | |
| static QString | money (double dollars) |
dollars as money, "$1,234.50". | |
Private Member Functions | |
| int | rowOf (const QString &sku) const |
The row of sku, or -1. | |
Private Attributes | |
| QList< Part > | m_parts |
| The rows. | |
The inventory: one row per part, with totals. Knows nothing about widgets.
|
inline |
Adds a part.
sku is empty or already used, or name is empty.
|
inline |
Adds delta to the quantity of sku (never below zero).
|
inline |
Removes sku.