Camp wizard is now able to open from shop plugin

master
Josef Rokos 8 years ago
parent 397ec82d06
commit 13d90445cc

@ -2,6 +2,7 @@
#include "campgrid.h"
#include "campform.h"
#include "campservice.h"
#include "settings/campsettingsform.h"
Camp::Camp()
@ -10,7 +11,7 @@ Camp::Camp()
void Camp::initServiceUi()
{
m_service = new Service<CampData>();
m_service = new CampService();
m_ui = new CampGrid();
((CampGrid*)m_ui)->setForm(new CampForm());
m_settingsUi = new CampSettingsForm();

@ -34,7 +34,9 @@ SOURCES += camp.cpp \
settings/campsettings.cpp \
campwizard.cpp \
campservice.cpp \
addservicedialog.cpp
addservicedialog.cpp \
campshopitem.cpp \
campseller.cpp
HEADERS += camp.h\
camp_global.h \
@ -50,7 +52,9 @@ HEADERS += camp.h\
settings/campsettings.h \
campwizard.h \
campservice.h \
addservicedialog.h
addservicedialog.h \
campshopitem.h \
campseller.h
include(../config_plugin.pri)

@ -0,0 +1,28 @@
#include "campseller.h"
#include "campwizard.h"
#include "campservice.h"
#include "data/camp-data.h"
#include "campshopitem.h"
CampSeller::CampSeller(QObject *parent)
:ISeller(parent)
{
}
void CampSeller::prepareItem()
{
CampWizard *wizard = new CampWizard();
wizard->setAttribute(Qt::WA_DeleteOnClose);
CampService srv;
CampDataPtr data = srv.create();
wizard->setData(data);
wizard->show();
connect(wizard, &QDialog::accepted, [this, data](){
CampShopItemPtr item(new CampShopItem);
item->setUnitPrice(data->totalPrice());
emit itemPrepared(item, 1);
});
}

@ -0,0 +1,17 @@
#ifndef CAMPSELLER_H
#define CAMPSELLER_H
#include <iseller.h>
class CampSeller : public ISeller
{
Q_OBJECT
public:
explicit CampSeller(QObject *parent = 0);
// ISeller interface
public:
void prepareItem();
};
#endif // CAMPSELLER_H

@ -2,13 +2,14 @@
#include <settingsservice.h>
#include <seasonservice.h>
#include <numberseriesservice.h>
#include "campshopitem.h"
#include "campseller.h"
#include <math.h>
CampService::CampService()
{
SettingsService srv("CAMP");
m_settings = srv.loadSettings<CampSettings>();
m_pluginId = "CAMP";
m_seller = new CampSeller(this);
}
void CampService::addPerson(CampDataPtr data, AddressbookDataPtr address)
@ -73,6 +74,9 @@ CampDataPtr CampService::create()
void CampService::calculate(CampDataPtr data)
{
SettingsService srv("CAMP");
m_settings = srv.loadSettings<CampSettings>();
calcServices(data);
calcPeople(data);
calcPrice(data);
@ -268,6 +272,31 @@ void CampService::addAccFee(CampDataPtr data, AddressItemPtr item, int startAge,
}
}
QList<ShopItemPtr> CampService::shopItems()
{
CampShopItemPtr item(new CampShopItem);
QList<ShopItemPtr> items;
items.append(item);
return items;
}
ShopItemPtr CampService::shopItem(int )
{
return CampShopItemPtr(new CampShopItem);
}
void CampService::addedToVoucher(int , int )
{
}
ISeller *CampService::seller()
{
return m_seller;
}
ServiceItemPtr CampService::addServiceInt(CampDataPtr data, AccServicePtr service)
{
ServiceItemPtr serviceItem(new ServiceItem);

@ -4,14 +4,16 @@
#include <core.h>
#include <addressbookdata.h>
#include <accservice.h>
#include <isellableservice.h>
#include "data/camp-data.h"
#include "settings/campsettings.h"
#include "camp-odb.hxx"
class CampService : public Service<CampData>
class CampService : public Service<CampData>, public ISellableService
{
public:
CampService();
void addPerson(CampDataPtr data, AddressbookDataPtr address);
void addService(CampDataPtr data, AccServicePtr service);
void addService(CampDataPtr data, AccServicePtr service, QDecDouble price, QString description);
@ -27,6 +29,14 @@ private:
void calcPrice(CampDataPtr data);
void addAccFee(CampDataPtr data, AddressItemPtr item, int startAge, int endAge, int days);
CampSettingsPtr m_settings;
ISeller *m_seller;
// ISellableService interface
public:
QList<ShopItemPtr> shopItems();
ShopItemPtr shopItem(int itemId);
void addedToVoucher(int itemId, int countAdded);
ISeller *seller();
};
#endif // CAMPSERVICE_H

@ -0,0 +1,48 @@
#include "campshopitem.h"
CampShopItem::CampShopItem(QObject *parent)
:ShopItem(parent)
{
m_unitPrice = QDecDouble(0);
m_vatType = Enums::NONE;
}
QString CampShopItem::name()
{
return "Camp";
}
QString CampShopItem::shortName()
{
return "Camp";
}
QDecDouble CampShopItem::unitPrice()
{
return m_unitPrice;
}
Enums::VatType CampShopItem::vatType()
{
return m_vatType;
}
QString CampShopItem::pluginId()
{
return "CAMP";
}
QString CampShopItem::code()
{
return "Camp";
}
void CampShopItem::setUnitPrice(const QDecDouble &unitPrice)
{
m_unitPrice = unitPrice;
}
void CampShopItem::setVatType(const Enums::VatType &vatType)
{
m_vatType = vatType;
}

@ -0,0 +1,34 @@
#ifndef CAMPSHOPITEM_H
#define CAMPSHOPITEM_H
#include <shopitem.h>
class CampShopItem : public ShopItem
{
public:
CampShopItem(QObject *parent = 0);
// IShopItem interface
public:
QString name();
QString shortName();
QDecDouble unitPrice();
Enums::VatType vatType();
QString pluginId();
// ShopItem interface
public:
QString code();
void setUnitPrice(const QDecDouble &unitPrice);
void setVatType(const Enums::VatType &vatType);
private:
QDecDouble m_unitPrice;
Enums::VatType m_vatType;
};
typedef QSharedPointer<CampShopItem> CampShopItemPtr;
#endif // CAMPSHOPITEM_H
Loading…
Cancel
Save