+52
-1
@@ -13,6 +13,8 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QMessageBox>
|
||||
#include "data/favorititem.h"
|
||||
#include "favbutton.h"
|
||||
|
||||
#include "shop-odb.hxx"
|
||||
|
||||
@@ -36,6 +38,8 @@ ShopForm::~ShopForm()
|
||||
|
||||
void ShopForm::loadLast()
|
||||
{
|
||||
loadButtons();
|
||||
|
||||
if (m_itemsModel == NULL)
|
||||
{
|
||||
m_itemsModel = new AutoTableModel<VoucherItem>(this);
|
||||
@@ -91,6 +95,53 @@ void ShopForm::loadLast()
|
||||
}
|
||||
}
|
||||
|
||||
void ShopForm::loadButtons()
|
||||
{
|
||||
SettingsService srv("SHOP");
|
||||
ShopSettingsPtr settings = srv.loadSettings<ShopSettings>();
|
||||
|
||||
Service<FavoritItem> srvFav;
|
||||
QMap<QString, FavoritItemPtr> btnMap;
|
||||
|
||||
foreach (FavoritItemPtr item, srvFav.all()) {
|
||||
btnMap[item->favButtonName()] = item;
|
||||
}
|
||||
|
||||
for (int i = 0; i < settings->favBtnRows(); i++)
|
||||
{
|
||||
for (int j = 0; j < settings->favBtnCols(); j++)
|
||||
{
|
||||
FavButton *btn = new FavButton(ui->favorites);
|
||||
QString btnName = QString::number(i) + "_" + QString::number(j);
|
||||
btn->setObjectName(btnName);
|
||||
|
||||
if (settings->favBtnSize() > 0)
|
||||
{
|
||||
btn->setMinimumHeight(settings->favBtnSize());
|
||||
btn->setMinimumWidth(settings->favBtnSize());
|
||||
}
|
||||
((QGridLayout*)ui->favorites->layout())->addWidget(btn, i + 1, j);
|
||||
|
||||
if (btnMap[btnName] != NULL)
|
||||
{
|
||||
btn->setText(btnMap[btnName]->name());
|
||||
connect(btn, &FavButton::clicked, [this, btnMap, btn](bool){
|
||||
FavoritItemPtr item = btnMap[btn->objectName()];
|
||||
|
||||
IPlugin *plugin = Context::instance().plugin(item->pluginId());
|
||||
IService *service = (plugin != NULL ? plugin->service<IService>() : NULL);
|
||||
ISellableService *selSrv = dynamic_cast<ISellableService*>(service);
|
||||
|
||||
if (selSrv != NULL)
|
||||
{
|
||||
addItem(selSrv->shopItem(item->refId()), 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShopForm::fillRaceiptCombo()
|
||||
{
|
||||
bool oldState = ui->receiptCombo->blockSignals(true);
|
||||
@@ -430,7 +481,7 @@ void ShopForm::on_commoditySearch_textChanged(const QString &text)
|
||||
}
|
||||
}
|
||||
|
||||
void ShopForm::on_lblEetState_linkActivated(const QString &link)
|
||||
void ShopForm::on_lblEetState_linkActivated(const QString &)
|
||||
{
|
||||
ShopService srv;
|
||||
srv.setEetOnline(!srv.isEetOnline());
|
||||
|
||||
Reference in New Issue
Block a user