Implemented base functionality of DirectSaleForm.
							parent
							
								
									049314a245
								
							
						
					
					
						commit
						2ed7d7077b
					
				@ -0,0 +1,46 @@
 | 
			
		||||
#include "directsaleitem.h"
 | 
			
		||||
 | 
			
		||||
DirectSaleItem::DirectSaleItem(QObject *parent) : QObject(parent)
 | 
			
		||||
{
 | 
			
		||||
    m_count = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int DirectSaleItem::id()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString DirectSaleItem::name()
 | 
			
		||||
{
 | 
			
		||||
    return m_name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QDecDouble DirectSaleItem::unitPrice()
 | 
			
		||||
{
 | 
			
		||||
    return m_unitPrice;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString DirectSaleItem::pluginId()
 | 
			
		||||
{
 | 
			
		||||
    return "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int DirectSaleItem::count() const
 | 
			
		||||
{
 | 
			
		||||
    return m_count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DirectSaleItem::setCount(int count)
 | 
			
		||||
{
 | 
			
		||||
    m_count = count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DirectSaleItem::setName(const QString &name)
 | 
			
		||||
{
 | 
			
		||||
    m_name = name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DirectSaleItem::setUnitPrice(const QDecDouble &unitPrice)
 | 
			
		||||
{
 | 
			
		||||
    m_unitPrice = unitPrice;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,42 @@
 | 
			
		||||
#ifndef DIRECTSALEITEM_H
 | 
			
		||||
#define DIRECTSALEITEM_H
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include "ishopitem.h"
 | 
			
		||||
 | 
			
		||||
class DirectSaleItem : public QObject, public IShopItem
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
    Q_PROPERTY(QString name READ name WRITE setName)
 | 
			
		||||
    Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
 | 
			
		||||
    Q_PROPERTY(int count READ count WRITE setCount)
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit DirectSaleItem(QObject *parent = 0);
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
 | 
			
		||||
    // IShopItem interface
 | 
			
		||||
public:
 | 
			
		||||
    int id() override;
 | 
			
		||||
    QString name() override;
 | 
			
		||||
    QDecDouble unitPrice() override;
 | 
			
		||||
    QString pluginId() override;
 | 
			
		||||
 | 
			
		||||
    int count() const;
 | 
			
		||||
    void setCount(int count);
 | 
			
		||||
 | 
			
		||||
    void setName(const QString &name);
 | 
			
		||||
 | 
			
		||||
    void setUnitPrice(const QDecDouble &unitPrice);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QString m_name;
 | 
			
		||||
    QDecDouble m_unitPrice;
 | 
			
		||||
    int m_count;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // DIRECTSALEITEM_H
 | 
			
		||||
@ -1,11 +1,20 @@
 | 
			
		||||
#ifndef SHOPSERVICE_H
 | 
			
		||||
#define SHOPSERVICE_H
 | 
			
		||||
 | 
			
		||||
#include <QSharedPointer>
 | 
			
		||||
 | 
			
		||||
class ShopService
 | 
			
		||||
#include <core.h>
 | 
			
		||||
 | 
			
		||||
#include "data/shop-data.h"
 | 
			
		||||
#include "ishopitem.h"
 | 
			
		||||
 | 
			
		||||
class ShopService : public Service<Voucher>
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    ShopService();
 | 
			
		||||
    QSharedPointer<Voucher> createVoucher();
 | 
			
		||||
    void addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IShopItem> item, int count);
 | 
			
		||||
    void calculate(QSharedPointer<Voucher> voucher);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // SHOPSERVICE_H
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue