Implemented base functionality for commodity grid on shop form.
							parent
							
								
									f9d7df9ab5
								
							
						
					
					
						commit
						fb6b4fe027
					
				@ -0,0 +1,19 @@
 | 
			
		||||
#include "commodityservice.h"
 | 
			
		||||
 | 
			
		||||
#include "commodity-odb.hxx"
 | 
			
		||||
 | 
			
		||||
CommodityService::CommodityService()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QList<QSharedPointer<ShopItem> > CommodityService::shopItems()
 | 
			
		||||
{
 | 
			
		||||
    QList<QSharedPointer<ShopItem> > ret;
 | 
			
		||||
 | 
			
		||||
    foreach (QSharedPointer<CommodityData> data, all()) {
 | 
			
		||||
        ret.append(qSharedPointerDynamicCast<ShopItem, CommodityData>(data));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,18 @@
 | 
			
		||||
#ifndef COMMODITYSERVICE_H
 | 
			
		||||
#define COMMODITYSERVICE_H
 | 
			
		||||
 | 
			
		||||
#include <service.h>
 | 
			
		||||
#include <isellableservice.h>
 | 
			
		||||
#include "data/commodity-data.h"
 | 
			
		||||
 | 
			
		||||
class CommodityService : public Service<CommodityData>, public ISellableService
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    CommodityService();
 | 
			
		||||
 | 
			
		||||
    // ISellableService interface
 | 
			
		||||
public:
 | 
			
		||||
    QList<QSharedPointer<ShopItem> > shopItems() override;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // COMMODITYSERVICE_H
 | 
			
		||||
@ -0,0 +1,5 @@
 | 
			
		||||
#include "isellableservice.h"
 | 
			
		||||
 | 
			
		||||
ISellableService::ISellableService()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,6 @@
 | 
			
		||||
#include "shopitem.h"
 | 
			
		||||
 | 
			
		||||
ShopItem::ShopItem(QObject *parent) : QObject(parent)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,33 @@
 | 
			
		||||
#ifndef SHOPITEM_H
 | 
			
		||||
#define SHOPITEM_H
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
 | 
			
		||||
#include "shop_global.h"
 | 
			
		||||
#include "ishopitem.h"
 | 
			
		||||
 | 
			
		||||
class SHOPSHARED_EXPORT ShopItem : public QObject, public IShopItem
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
    Q_PROPERTY(QString name READ name)
 | 
			
		||||
    Q_PROPERTY(QDecDouble unitPrice READ unitPrice)
 | 
			
		||||
    Q_PROPERTY(Enums::VatType vatType READ vatType)
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit ShopItem(QObject *parent = 0);
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
 | 
			
		||||
    // IShopItem interface
 | 
			
		||||
public:
 | 
			
		||||
    virtual int id() override { return 0; }
 | 
			
		||||
    virtual QString name() override { return ""; }
 | 
			
		||||
    virtual QDecDouble unitPrice() override { return QDecDouble(); }
 | 
			
		||||
    virtual Enums::VatType vatType() override { return Enums::NONE; }
 | 
			
		||||
    virtual QString pluginId() override { return ""; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // SHOPITEM_H
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue