@@ -29,3 +29,9 @@ void CommodityService::addedToVoucher(int itemId, int countAdded)
|
||||
|
||||
update(commodity);
|
||||
}
|
||||
|
||||
ShopItemPtr CommodityService::shopItem(int itemId)
|
||||
{
|
||||
CommodityDataPtr item = this->loadById(itemId);
|
||||
return qSharedPointerDynamicCast<ShopItem, CommodityData>(item);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ public:
|
||||
|
||||
// ISellableService interface
|
||||
public:
|
||||
QList<QSharedPointer<ShopItem> > shopItems() override;
|
||||
QList<ShopItemPtr> shopItems() override;
|
||||
void addedToVoucher(int itemId, int countAdded) override;
|
||||
virtual ShopItemPtr shopItem(int itemId) override;
|
||||
|
||||
};
|
||||
|
||||
#endif // COMMODITYSERVICE_H
|
||||
|
||||
@@ -68,4 +68,6 @@ public:
|
||||
QString pluginId() override;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<CommodityData> CommodityDataPtr;
|
||||
|
||||
#endif // COMMODITYDATA_H
|
||||
|
||||
@@ -67,3 +67,13 @@ void FavoritItem::setFavButtonName(const QString &favButtonName)
|
||||
{
|
||||
m_favButtonName = favButtonName;
|
||||
}
|
||||
|
||||
int FavoritItem::refId() const
|
||||
{
|
||||
return m_refId;
|
||||
}
|
||||
|
||||
void FavoritItem::setRefId(int refId)
|
||||
{
|
||||
m_refId = refId;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class FavoritItem : public QObject, public IShopItem
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(int id READ id WRITE setId)
|
||||
Q_PROPERTY(int refId READ refId WRITE setRefId)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
|
||||
Q_PROPERTY(Enums::VatType vatType READ vatType WRITE setVatType)
|
||||
@@ -46,10 +47,14 @@ public:
|
||||
QString favButtonName() const;
|
||||
void setFavButtonName(const QString &favButtonName);
|
||||
|
||||
int refId() const;
|
||||
void setRefId(int refId);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
int m_refId;
|
||||
QString m_name;
|
||||
int m_unitPrice;
|
||||
Enums::VatType m_vatType;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef FAVBUTTON_H
|
||||
#define FAVBUTTON_H
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
class FavButton : public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FavButton(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void itemDropped();
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
||||
virtual void dropEvent(QDropEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // FAVBUTTON_H
|
||||
@@ -11,7 +11,8 @@ class SHOPSHARED_EXPORT ISellableService
|
||||
public:
|
||||
ISellableService();
|
||||
|
||||
virtual QList<QSharedPointer<ShopItem> > shopItems() = 0;
|
||||
virtual QList<ShopItemPtr> shopItems() = 0;
|
||||
virtual ShopItemPtr shopItem(int itemId) = 0;
|
||||
virtual void addedToVoucher(int itemId, int countAdded) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#include "favoriteservice.h"
|
||||
|
||||
FavoriteService::FavoriteService()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef FAVORITESERVICE_H
|
||||
#define FAVORITESERVICE_H
|
||||
|
||||
#include <core.h>
|
||||
#include "data/favorititem.h"
|
||||
|
||||
class FavoriteService : public Service<FavoritItem>
|
||||
{
|
||||
public:
|
||||
FavoriteService();
|
||||
};
|
||||
|
||||
#endif // FAVORITESERVICE_H
|
||||
@@ -9,6 +9,10 @@ ShopSettings::ShopSettings(QObject *parent) : QObject(parent)
|
||||
m_eetMode = 1;
|
||||
m_eetTest = 0;
|
||||
m_eetPlayground = 0;
|
||||
|
||||
m_favBtnCols = 0;
|
||||
m_favBtnRows = 0;
|
||||
m_favBtnSize = 0;
|
||||
}
|
||||
|
||||
QString ShopSettings::output() const
|
||||
@@ -130,3 +134,33 @@ void ShopSettings::setEetPlayground(bool eetPlayground)
|
||||
{
|
||||
m_eetPlayground = eetPlayground;
|
||||
}
|
||||
|
||||
int ShopSettings::favBtnCols() const
|
||||
{
|
||||
return m_favBtnCols;
|
||||
}
|
||||
|
||||
void ShopSettings::setFavBtnCols(int favBtnCols)
|
||||
{
|
||||
m_favBtnCols = favBtnCols;
|
||||
}
|
||||
|
||||
int ShopSettings::favBtnRows() const
|
||||
{
|
||||
return m_favBtnRows;
|
||||
}
|
||||
|
||||
void ShopSettings::setFavBtnRows(int favBtnRows)
|
||||
{
|
||||
m_favBtnRows = favBtnRows;
|
||||
}
|
||||
|
||||
int ShopSettings::favBtnSize() const
|
||||
{
|
||||
return m_favBtnSize;
|
||||
}
|
||||
|
||||
void ShopSettings::setFavBtnSize(int favBtnSize)
|
||||
{
|
||||
m_favBtnSize = favBtnSize;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ class ShopSettings : public QObject
|
||||
Q_PROPERTY(bool eetTest READ eetTest WRITE setEetTest)
|
||||
Q_PROPERTY(bool eetPlayground READ eetPlayground WRITE setEetPlayground)
|
||||
|
||||
Q_PROPERTY(int favBtnCols READ favBtnCols WRITE setFavBtnCols)
|
||||
Q_PROPERTY(int favBtnRows READ favBtnRows WRITE setFavBtnRows)
|
||||
Q_PROPERTY(int favBtnSize READ favBtnSize WRITE setFavBtnSize)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@@ -64,6 +68,15 @@ public:
|
||||
bool eetPlayground() const;
|
||||
void setEetPlayground(bool eetPlayground);
|
||||
|
||||
int favBtnCols() const;
|
||||
void setFavBtnCols(int favBtnCols);
|
||||
|
||||
int favBtnRows() const;
|
||||
void setFavBtnRows(int favBtnRows);
|
||||
|
||||
int favBtnSize() const;
|
||||
void setFavBtnSize(int favBtnSize);
|
||||
|
||||
private:
|
||||
QString m_output;
|
||||
CODEPAGE m_codepage;
|
||||
@@ -78,6 +91,10 @@ private:
|
||||
QString m_eetKeyPassword;
|
||||
bool m_eetTest;
|
||||
bool m_eetPlayground;
|
||||
|
||||
int m_favBtnCols;
|
||||
int m_favBtnRows;
|
||||
int m_favBtnSize;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<ShopSettings> ShopSettingsPtr;
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
#include <settingsservice.h>
|
||||
#include <combodata.h>
|
||||
#include <QFileDialog>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDebug>
|
||||
#include "shopservice.h"
|
||||
#include "shop-odb.hxx"
|
||||
|
||||
|
||||
ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
|
||||
FormBinder<ShopSettings>(parent),
|
||||
@@ -27,7 +31,13 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
|
||||
registerBinding(ui->eetTest);
|
||||
registerBinding(ui->eetPlayground);
|
||||
|
||||
registerBinding(ui->favBtnCols);
|
||||
registerBinding(ui->favBtnRows);
|
||||
registerBinding(ui->favBtnSize);
|
||||
|
||||
m_itemModel = new AutoTableModel<ShopItem>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
ShopSettingsForm::~ShopSettingsForm()
|
||||
@@ -35,6 +45,51 @@ ShopSettingsForm::~ShopSettingsForm()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ShopSettingsForm::drawButtons()
|
||||
{
|
||||
foreach (QWidget *child, ui->btnWidget->findChildren<QWidget*>()) {
|
||||
delete child;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entity()->favBtnRows(); i++)
|
||||
{
|
||||
for (int j = 0; j < entity()->favBtnCols(); j++)
|
||||
{
|
||||
FavButton *btn = new FavButton(ui->btnWidget);
|
||||
btn->setObjectName(QString::number(i) + "_" + QString::number(j));
|
||||
btn->setAcceptDrops(true);
|
||||
|
||||
if (m_btnMap[btn->objectName()] != NULL)
|
||||
{
|
||||
btn->setText(m_btnMap[btn->objectName()]->name());
|
||||
}
|
||||
|
||||
if (entity()->favBtnSize() > 0)
|
||||
{
|
||||
btn->setMinimumHeight(entity()->favBtnSize());
|
||||
btn->setMinimumWidth(entity()->favBtnSize());
|
||||
}
|
||||
((QGridLayout*)ui->btnWidget->layout())->addWidget(btn, i, j);
|
||||
|
||||
connect(btn, &FavButton::clicked, [this, btn](bool){
|
||||
btn->setText("");
|
||||
m_btnMap.remove(btn->objectName());
|
||||
});
|
||||
|
||||
connect(btn, &FavButton::itemDropped, [this, btn](){
|
||||
ShopItemPtr item = m_itemModel->itemFromIndex(ui->tableItems->currentIndex());
|
||||
FavoritItemPtr favItem = QSharedPointer<FavoritItem>(new FavoritItem);
|
||||
favItem->setFavButtonName(btn->objectName());
|
||||
favItem->setName(item->name());
|
||||
favItem->setRefId(item->id());
|
||||
favItem->setPluginId(item->pluginId());
|
||||
m_btnMap[btn->objectName()] = favItem;
|
||||
btn->setText(item->name());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShopSettingsForm::loadEntity()
|
||||
{
|
||||
SettingsService srv("SHOP");
|
||||
@@ -43,7 +98,18 @@ void ShopSettingsForm::loadEntity()
|
||||
|
||||
ShopService srvShop;
|
||||
m_itemModel->setData(srvShop.allSellableItems());
|
||||
m_itemModel->setTranslations(Context::instance().plugin("SHOP")->translations());
|
||||
ui->tableItems->setModel(m_itemModel);
|
||||
ui->tableItems->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
ui->tableItems->setColumnHidden(0, true);
|
||||
ui->tableItems->setColumnHidden(3, true);
|
||||
|
||||
Service<FavoritItem> srvFav;
|
||||
|
||||
foreach (FavoritItemPtr favItem, srvFav.all()) {
|
||||
m_btnMap[favItem->favButtonName()] = favItem;
|
||||
}
|
||||
drawButtons();
|
||||
}
|
||||
|
||||
bool ShopSettingsForm::saveRecord()
|
||||
@@ -52,6 +118,18 @@ bool ShopSettingsForm::saveRecord()
|
||||
SettingsService srv("SHOP");
|
||||
srv.saveSettings(entity());
|
||||
|
||||
Service<FavoritItem> srvFav;
|
||||
foreach (FavoritItemPtr item, srvFav.all()) {
|
||||
srvFav.erase(item);
|
||||
}
|
||||
|
||||
foreach (QString btnName, m_btnMap.keys()) {
|
||||
if (m_btnMap[btnName] != NULL)
|
||||
{
|
||||
srvFav.save(m_btnMap[btnName]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,3 +142,35 @@ void ShopSettingsForm::on_btnCertBrowse_clicked()
|
||||
ui->eetCertificate->setText(certFile);
|
||||
}
|
||||
}
|
||||
|
||||
void ShopSettingsForm::on_favBtnCols_textChanged(const QString &arg1)
|
||||
{
|
||||
entity()->setFavBtnCols(arg1.toInt());
|
||||
drawButtons();
|
||||
}
|
||||
|
||||
void ShopSettingsForm::on_favBtnRows_textChanged(const QString &arg1)
|
||||
{
|
||||
entity()->setFavBtnRows(arg1.toInt());
|
||||
drawButtons();
|
||||
}
|
||||
|
||||
void ShopSettingsForm::on_favBtnSize_textChanged(const QString &arg1)
|
||||
{
|
||||
entity()->setFavBtnSize(arg1.toInt());
|
||||
drawButtons();
|
||||
}
|
||||
|
||||
FavButton::FavButton(QWidget *parent) : QToolButton(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void FavButton::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void FavButton::dropEvent(QDropEvent *)
|
||||
{
|
||||
emit itemDropped();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
#define SHOPSETTINGSFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QToolButton>
|
||||
#include <formbinder.h>
|
||||
#include <QMap>
|
||||
#include "shopsettings.h"
|
||||
#include <core.h>
|
||||
#include "shopitem.h"
|
||||
#include "data/favorititem.h"
|
||||
#include "favbutton.h"
|
||||
|
||||
namespace Ui {
|
||||
class ShopSettingsForm;
|
||||
@@ -22,6 +26,11 @@ public:
|
||||
private:
|
||||
Ui::ShopSettingsForm *ui;
|
||||
AutoTableModel<ShopItem> *m_itemModel;
|
||||
int m_favBtnRows;
|
||||
int m_favBtnCols;
|
||||
int m_favBtnSize;
|
||||
QMap<QString, FavoritItemPtr> m_btnMap;
|
||||
void drawButtons();
|
||||
|
||||
// IForm interface
|
||||
public:
|
||||
@@ -29,8 +38,12 @@ public:
|
||||
|
||||
public slots:
|
||||
bool saveRecord();
|
||||
|
||||
private slots:
|
||||
void on_btnCertBrowse_clicked();
|
||||
void on_favBtnCols_textChanged(const QString &arg1);
|
||||
void on_favBtnRows_textChanged(const QString &arg1);
|
||||
void on_favBtnSize_textChanged(const QString &arg1);
|
||||
};
|
||||
|
||||
#endif // SHOPSETTINGSFORM_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>645</width>
|
||||
<height>463</height>
|
||||
<width>760</width>
|
||||
<height>505</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -33,7 +33,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
<enum>QAbstractItemView::DragOnly</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
@@ -48,138 +48,13 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="3">
|
||||
<widget class="QToolButton" name="toolButton_9">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QToolButton" name="toolButton_10">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="toolButton_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QToolButton" name="toolButton_6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="btnWidget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="toolButton_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="toolButton_8">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="toolButton_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QToolButton" name="toolButton_5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QToolButton" name="toolButton_7">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -192,6 +67,55 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Columns</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="favBtnCols"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Rows</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="favBtnRows"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="favBtnSize"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
+11
-1
@@ -8,7 +8,7 @@
|
||||
"default" : "",
|
||||
"CZ" : ""
|
||||
},
|
||||
"schemaVersion" : 3,
|
||||
"schemaVersion" : 4,
|
||||
"sql" : [
|
||||
"CREATE TABLE \"VoucherItem\" (
|
||||
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -60,6 +60,16 @@ CREATE TABLE \"Voucher\" (
|
||||
"ALTER TABLE \"VoucherItem\" ADD \"insertDate\" TEXT NULL;
|
||||
",
|
||||
"ALTER TABLE \"Voucher\" ADD \"saveDateTime\" TEXT NULL;
|
||||
",
|
||||
|
||||
"CREATE TABLE \"FavoritItem\" (
|
||||
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
\"refId\" INTEGER NOT NULL,
|
||||
\"name\" TEXT NULL,
|
||||
\"unitPrice\" INTEGER NOT NULL,
|
||||
\"vatType\" INTEGER NOT NULL,
|
||||
\"pluginId\" TEXT NULL,
|
||||
\"favButtonName\" TEXT NULL);
|
||||
"
|
||||
],
|
||||
"dependencies" : [ "ADDRESSBOOK" ],
|
||||
|
||||
+2
-3
@@ -31,7 +31,6 @@ SOURCES += shop.cpp \
|
||||
shopitem.cpp \
|
||||
isellableservice.cpp \
|
||||
data/favorititem.cpp \
|
||||
settings/favoriteservice.cpp \
|
||||
eetbatchdialog.cpp
|
||||
|
||||
HEADERS += shop.h\
|
||||
@@ -55,8 +54,8 @@ HEADERS += shop.h\
|
||||
paydvouchersdialog.h \
|
||||
shopitem.h \
|
||||
data/favorititem.h \
|
||||
settings/favoriteservice.h \
|
||||
eetbatchdialog.h
|
||||
eetbatchdialog.h \
|
||||
favbutton.h
|
||||
|
||||
include(../config_plugin.pri)
|
||||
|
||||
|
||||
+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());
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
explicit ShopForm(QWidget *parent = 0);
|
||||
~ShopForm();
|
||||
void loadLast();
|
||||
void loadButtons();
|
||||
void fillRaceiptCombo();
|
||||
|
||||
private slots:
|
||||
|
||||
+15
-226
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>959</width>
|
||||
<width>975</width>
|
||||
<height>643</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -108,21 +108,8 @@
|
||||
<widget class="QWidget" name="widgetButtons" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="favorites1" native="true">
|
||||
<widget class="QWidget" name="favorites" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QToolButton" name="directSale">
|
||||
<property name="font">
|
||||
@@ -157,220 +144,22 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_5" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QToolButton" name="toolFav1">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QToolButton" name="toolFav5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="toolFav2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="toolFav3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="toolFav4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_6" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="toolFav7">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QToolButton" name="toolFav6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="toolFav8">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="toolFav9">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QToolButton" name="toolFav10">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user