summaryrefslogtreecommitdiff
path: root/qicclient/product.hxx
blob: 57f9641c2ab749461f4a0e147a9c161eae9a5417 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef QICCLIENT_PRODUCT_HXX
#define QICCLIENT_PRODUCT_HXX

#include <icclient.h>

namespace QICClient {

	struct Product
	{
		enum ProductRoles {
			SkuRole = Qt::UserRole + 1,
			DescriptionRole,
			CommentRole,
			ThumbRole,
			ImageRole,
			PriceRole,
			ProdGroupRole,
			WeightRole,
			AuthorRole,
			CrossSellRole
		};

		Product() {}
		Product(struct icclient_product* product) :
			price{product->price},
			weight{product->weight}
		{
			if (product->sku)
				sku = QString{product->sku};
			if (product->description)
				description = QString{product->description};
			if (product->comment)
				comment = QString{product->comment};
			if (product->thumb)
				thumb = QString{product->thumb};
			if (product->image)
				image = QString{product->image};
			if (product->prod_group)
				prodGroup = QString{product->prod_group};
			if (product->author)
				author = QString{product->author};
			if (product->crosssell) {
				auto crosssell = product->crosssell;
				for (size_t i = 0; i < crosssell->length; i++)
					crossSell << QString{crosssell->skus[i]};
			}
		}

		QString sku;
		QString description;
		QString comment;
		QString thumb;
		QString image;
		double price;
		QString prodGroup;
		double weight;
		QString author;
		QStringList crossSell;
	};

}

#endif