summaryrefslogtreecommitdiff
path: root/interchange/catalog.hxx
blob: 9e96a3e1860576d9c364971cd1685b2d62c521ac (plain)
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
33
34
#ifndef INTERCHANGE_CATALOG_HXX
#define INTERCHANGE_CATALOG_HXX

#include <QAbstractListModel>
#include "product.hxx"

struct interchange_catalog;

namespace QInterchange {

	class Catalog : public QAbstractListModel
	{
		Q_OBJECT

		public:
			Catalog(QObject* parent = nullptr) : QAbstractListModel{parent} {}
			Catalog(struct interchange_catalog* catalog, QObject* parent = nullptr);
			~Catalog();
			int rowCount(QModelIndex const& parent = QModelIndex()) const Q_DECL_OVERRIDE;
			QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
			struct interchange_catalog const* constData() const { return m_data; }
			void addProduct(Product const& product);

		protected:
			QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;

		private:
			QList<Product> products;
			struct interchange_catalog* m_data;
	};

}

#endif