Added typedefs for QSharedPointer types

print
Josef Rokos 8 years ago
parent 0f397c4308
commit 707e2dbc0b

@ -11,7 +11,8 @@ class SHOPSHARED_EXPORT ISellableService
public: public:
ISellableService(); ISellableService();
virtual QList<QSharedPointer<ShopItem> > shopItems() = 0; virtual QList<ShopItemPtr> shopItems() = 0;
//virtual void addToReceipt()
}; };
#endif // ISELLABLESERVICE_H #endif // ISELLABLESERVICE_H

@ -30,4 +30,6 @@ public:
virtual QString pluginId() override { return ""; } virtual QString pluginId() override { return ""; }
}; };
typedef QSharedPointer<ShopItem> ShopItemPtr;
#endif // SHOPITEM_H #endif // SHOPITEM_H

@ -7,14 +7,14 @@ ShopService::ShopService()
{ {
} }
QSharedPointer<Voucher> ShopService::createVoucher() VoucherPtr ShopService::createVoucher()
{ {
QSharedPointer<Voucher> voucher(new Voucher); QSharedPointer<Voucher> voucher(new Voucher);
voucher->setStatus(Voucher::NEW); voucher->setStatus(Voucher::NEW);
return voucher; return voucher;
} }
void ShopService::addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IShopItem> item, int count) void ShopService::addShopItem(VoucherPtr voucher, QSharedPointer<IShopItem> item, int count)
{ {
QSharedPointer<VoucherItem> vItem(new VoucherItem); QSharedPointer<VoucherItem> vItem(new VoucherItem);
vItem->setName(item->name()); vItem->setName(item->name());
@ -27,7 +27,7 @@ void ShopService::addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IS
voucher->addItem(vItem); voucher->addItem(vItem);
} }
void ShopService::calculate(QSharedPointer<Voucher> voucher) void ShopService::calculate(VoucherPtr voucher)
{ {
QDecDouble total; QDecDouble total;
@ -66,7 +66,7 @@ void ShopService::calculate(QSharedPointer<Voucher> voucher)
voucher->setTotalPrice(total); voucher->setTotalPrice(total);
} }
void ShopService::calculateItem(QSharedPointer<VoucherItem> item) void ShopService::calculateItem(VoucherItemPtr item)
{ {
loadSettings(); loadSettings();
if (m_gs->vatPayer()) if (m_gs->vatPayer())
@ -82,13 +82,13 @@ void ShopService::calculateItem(QSharedPointer<VoucherItem> item)
} }
} }
void ShopService::loadItems(QSharedPointer<Voucher> voucher) void ShopService::loadItems(VoucherPtr voucher)
{ {
Service<VoucherItem> srv; Service<VoucherItem> srv;
voucher->setItems(srv.all(QString("voucher = %1").arg(voucher->id()))); voucher->setItems(srv.all(QString("voucher = %1").arg(voucher->id())));
} }
void ShopService::pay(QSharedPointer<Voucher> voucher) void ShopService::pay(VoucherPtr voucher)
{ {
Transaction tx; Transaction tx;
NumberSeriesService srvNs; NumberSeriesService srvNs;
@ -106,22 +106,22 @@ void ShopService::pay(QSharedPointer<Voucher> voucher)
tx.commit(); tx.commit();
} }
QList<QSharedPointer<Voucher> > ShopService::savedVouchers() QList<VoucherPtr> ShopService::savedVouchers()
{ {
return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))); return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)));
} }
QList<QSharedPointer<Voucher> > ShopService::tempVouchers() QList<VoucherPtr> ShopService::tempVouchers()
{ {
return all(QString("status = %1").arg(QString::number(Voucher::TEMPORARY))); return all(QString("status = %1").arg(QString::number(Voucher::TEMPORARY)));
} }
QList<QSharedPointer<Voucher> > ShopService::paiedVouchers() QList<VoucherPtr> ShopService::paiedVouchers()
{ {
return all(QString("status = %1").arg(QString::number(Voucher::PAID))); return all(QString("status = %1").arg(QString::number(Voucher::PAID)));
} }
QList<QSharedPointer<ShopItem> > ShopService::allSellableItems() QList<ShopItemPtr> ShopService::allSellableItems()
{ {
QList<QSharedPointer<ShopItem> > items; QList<QSharedPointer<ShopItem> > items;
foreach (IPlugin *plugin, Context::instance().plugins()) { foreach (IPlugin *plugin, Context::instance().plugins()) {
@ -176,7 +176,7 @@ QDecDouble ShopService::vatRate(Enums::VatType vatType)
return vatRate; return vatRate;
} }
void ShopService::saveVoucher(QSharedPointer<Voucher> entity) void ShopService::saveVoucher(VoucherPtr entity)
{ {
Transaction tr; Transaction tr;
odb::database *db = Context::instance().db(); odb::database *db = Context::instance().db();
@ -191,7 +191,7 @@ void ShopService::saveVoucher(QSharedPointer<Voucher> entity)
tr.commit(); tr.commit();
} }
void ShopService::updateVoucher(QSharedPointer<Voucher> entity) void ShopService::updateVoucher(VoucherPtr entity)
{ {
Transaction tr; Transaction tr;
odb::database *db = Context::instance().db(); odb::database *db = Context::instance().db();

@ -13,16 +13,16 @@ class ShopService : public Service<Voucher>
{ {
public: public:
ShopService(); ShopService();
QSharedPointer<Voucher> createVoucher(); VoucherPtr createVoucher();
void addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IShopItem> item, int count); void addShopItem(VoucherPtr voucher, QSharedPointer<IShopItem> item, int count);
void calculate(QSharedPointer<Voucher> voucher); void calculate(VoucherPtr voucher);
void calculateItem(QSharedPointer<VoucherItem> item); void calculateItem(VoucherItemPtr item);
void loadItems(QSharedPointer<Voucher> voucher); void loadItems(VoucherPtr voucher);
void pay(QSharedPointer<Voucher> voucher); void pay(VoucherPtr voucher);
QList<QSharedPointer<Voucher> > savedVouchers(); QList<VoucherPtr> savedVouchers();
QList<QSharedPointer<Voucher> > tempVouchers(); QList<VoucherPtr> tempVouchers();
QList<QSharedPointer<Voucher> > paiedVouchers(); QList<VoucherPtr> paiedVouchers();
QList<QSharedPointer<ShopItem> > allSellableItems(); QList<ShopItemPtr> allSellableItems();
private: private:
QDecDouble includeVat(QDecDouble price, Enums::VatType vatType); QDecDouble includeVat(QDecDouble price, Enums::VatType vatType);
@ -32,8 +32,8 @@ private:
QDecDouble vatRate(Enums::VatType vatType); QDecDouble vatRate(Enums::VatType vatType);
public: public:
void saveVoucher(QSharedPointer<Voucher> entity); void saveVoucher(VoucherPtr entity);
void updateVoucher(QSharedPointer<Voucher> entity); void updateVoucher(VoucherPtr entity);
}; };
#endif // SHOPSERVICE_H #endif // SHOPSERVICE_H

Loading…
Cancel
Save