#include "commodityservice.h" QList > CommodityService::shopItems(const QString& category/* = ""*/) { QList > ret; foreach (QSharedPointer data, all()) { if (category.isEmpty() || (data->favorite() && data->category() == category)) { ret.append(qSharedPointerDynamicCast(data)); } } return ret; } void CommodityService::addedToVoucher(int itemId, int countAdded) { QSharedPointer commodity = loadById(itemId); if (!commodity.isNull()) { commodity->setCount(commodity->count() - countAdded); } update(commodity); } IShopItemPtr CommodityService::shopItem(int itemId) { CommodityDataPtr item = this->loadById(itemId); return qSharedPointerDynamicCast(item); } ISeller *CommodityService::seller() { return nullptr; } QString CommodityService::defaultSort() { return "name"; }