Added seller interface for preparing shop items from other plugins.
This commit is contained in:
+25
-5
@@ -370,11 +370,31 @@ void ShopForm::addItem(QSharedPointer<IShopItem> item, int count)
|
||||
createVoucher();
|
||||
}
|
||||
|
||||
ShopService srv;
|
||||
srv.addShopItem(m_voucher, item, count);
|
||||
this->m_itemsModel->addRow(m_voucher->items()[m_voucher->items().count() - 1]);
|
||||
connect(m_voucher->items()[m_voucher->items().count() - 1].data(), SIGNAL(countChanged(int)), this, SLOT(onCountChanged(int)));
|
||||
onCountChanged();
|
||||
IPlugin *plugin = Context::instance().plugin(item->pluginId());
|
||||
IService *service = (plugin != NULL ? plugin->service<IService>() : NULL);
|
||||
ISellableService *selSrv = dynamic_cast<ISellableService*>(service);
|
||||
|
||||
auto addFunc = [this](QSharedPointer<IShopItem> shopItem, int itemCount){
|
||||
ShopService srv;
|
||||
srv.addShopItem(m_voucher, shopItem, itemCount);
|
||||
this->m_itemsModel->addRow(m_voucher->items()[m_voucher->items().count() - 1]);
|
||||
connect(m_voucher->items()[m_voucher->items().count() - 1].data(), SIGNAL(countChanged(int)), this, SLOT(onCountChanged(int)));
|
||||
onCountChanged();
|
||||
};
|
||||
|
||||
if (selSrv != NULL && selSrv->seller() != NULL)
|
||||
{
|
||||
ISeller *seller = selSrv->seller();
|
||||
|
||||
seller->disconnect();
|
||||
connect(seller, &ISeller::itemPrepared, addFunc);
|
||||
|
||||
seller->prepareItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
addFunc(item, count);
|
||||
}
|
||||
|
||||
ui->actualReceipt->scrollToBottom();
|
||||
ui->commoditySearch->setFocus();
|
||||
|
||||
Reference in New Issue
Block a user