Unsolved Second Listview based on first displaying only items when variable is not null
-
I'm working on warehouse application. In first tab I created list of items, where the user can add products to bucket. The amount of products is variable. I used following code:
class Product : public QObject { Q_OBJECT Q_PROPERTY(QString name READ getName CONSTANT) Q_PROPERTY(double price READ getPrice CONSTANT) Q_PROPERTY(int amount READ getAmount WRITE setAmount NOTIFY amountChanged) //amount in bucket Q_INVOKABLE void increaseAmount() ... class Warehouse: public QObject { Q_OBJECT Q_PROPERTY(QList<Product*> wares READ getWares NOTIFY wareAdded) Warehouse { id: mainWarehouse ... ListView { model: mainWarehouse.wares delegate: {Grid {Text{ // info about product} Button{ onClicked: {model.modelData.increaseAmount();
Now I want to create a second tab in my application, where I display only products added to bucket. What's the best way of doing this? Should I create second Q_PROPERTY QList<Product*> with getter, in which will be checked if amount > 0? It seems for me as not the best solution here, but I have no idea how to solve it better. I'm not sure, if my approach with QList as Q_Property is correct. Besides of that, I'm not sure, if the new List will correctly recognize, when new items will be added to bucket.
A side question: how to catch the signal amountChanged, which is called, when the button from listElement is clicked (calling method increaseAmount)? I would like to display a dialog, when the user is informed, that a product was added to bucket. The best would be, if I will be able to display a info about added product.