Added seller interface for preparing shop items from other plugins.

This commit is contained in:
2017-05-31 16:11:15 +02:00
parent 1e785fd488
commit 397ec82d06
7 changed files with 68 additions and 8 deletions
+25 -5
View File
@@ -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();