Commodity - added setting for translate czech chars to numbers (bar code scanner fix).
This commit is contained in:
@@ -20,7 +20,8 @@ SOURCES += commodity.cpp \
|
|||||||
commodityform.cpp \
|
commodityform.cpp \
|
||||||
commoditygrid.cpp \
|
commoditygrid.cpp \
|
||||||
commoditysettingsform.cpp \
|
commoditysettingsform.cpp \
|
||||||
commodityservice.cpp
|
commodityservice.cpp \
|
||||||
|
settings/commoditysettings.cpp
|
||||||
|
|
||||||
HEADERS += commodity.h\
|
HEADERS += commodity.h\
|
||||||
commodity_global.h \
|
commodity_global.h \
|
||||||
@@ -31,7 +32,8 @@ HEADERS += commodity.h\
|
|||||||
commodityform.h \
|
commodityform.h \
|
||||||
commoditygrid.h \
|
commoditygrid.h \
|
||||||
commoditysettingsform.h \
|
commoditysettingsform.h \
|
||||||
commodityservice.h
|
commodityservice.h \
|
||||||
|
settings/commoditysettings.h
|
||||||
|
|
||||||
include(../config_plugin.pri)
|
include(../config_plugin.pri)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
#include "commodityform.h"
|
#include "commodityform.h"
|
||||||
#include "ui_commodityform.h"
|
#include "ui_commodityform.h"
|
||||||
#include <combodata.h>
|
#include <combodata.h>
|
||||||
|
#include <settingsservice.h>
|
||||||
|
#include <settings/commoditysettings.h>
|
||||||
|
#include <helper.h>
|
||||||
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <qlist.h>
|
#include <QList>
|
||||||
#include "data/commoditytypedata.h"
|
#include "data/commoditytypedata.h"
|
||||||
|
|
||||||
CommodityForm::CommodityForm(QWidget *parent) :
|
CommodityForm::CommodityForm(QWidget *parent) :
|
||||||
@@ -21,6 +25,8 @@ CommodityForm::CommodityForm(QWidget *parent) :
|
|||||||
<< ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
|
<< ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
|
||||||
registerBinding(ui->vat, vt);
|
registerBinding(ui->vat, vt);
|
||||||
registerBinding(ui->count);
|
registerBinding(ui->count);
|
||||||
|
|
||||||
|
m_codeAsNumber = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommodityForm::~CommodityForm()
|
CommodityForm::~CommodityForm()
|
||||||
@@ -33,3 +39,19 @@ void CommodityForm::registerCombos()
|
|||||||
Service<CommodityTypeData> srvComTypes;
|
Service<CommodityTypeData> srvComTypes;
|
||||||
registerBinding(ui->type, ComboData::createComboData(srvComTypes.all()));
|
registerBinding(ui->type, ComboData::createComboData(srvComTypes.all()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommodityForm::onShow()
|
||||||
|
{
|
||||||
|
SettingsService srv("COMMODITY");
|
||||||
|
CommoditySettingsPtr settings = srv.loadSettings<CommoditySettings>();
|
||||||
|
|
||||||
|
m_codeAsNumber = settings->codeAsNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommodityForm::on_code_textChanged(const QString &text)
|
||||||
|
{
|
||||||
|
if (m_codeAsNumber)
|
||||||
|
{
|
||||||
|
ui->code->setText(Helper::replaceByNumbers(text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,9 +21,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
Ui::CommodityForm *ui;
|
Ui::CommodityForm *ui;
|
||||||
|
|
||||||
|
bool m_codeAsNumber;
|
||||||
|
|
||||||
// FormBinder interface
|
// FormBinder interface
|
||||||
protected:
|
protected:
|
||||||
void registerCombos();
|
void registerCombos();
|
||||||
|
void onShow();
|
||||||
|
private slots:
|
||||||
|
void on_code_textChanged(const QString &text);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COMMODITYFORM_H
|
#endif // COMMODITYFORM_H
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
#include "commoditysettingsform.h"
|
#include "commoditysettingsform.h"
|
||||||
#include "ui_commoditysettingsform.h"
|
#include "ui_commoditysettingsform.h"
|
||||||
#include <service.h>
|
#include <service.h>
|
||||||
|
#include <settingsservice.h>
|
||||||
#include "commodity-odb.hxx"
|
#include "commodity-odb.hxx"
|
||||||
|
|
||||||
CommoditySettingsForm::CommoditySettingsForm(QWidget *parent) :
|
CommoditySettingsForm::CommoditySettingsForm(QWidget *parent) :
|
||||||
IForm(parent),
|
FormBinder<CommoditySettings>(parent),
|
||||||
ui(new Ui::CommoditySettingsForm)
|
ui(new Ui::CommoditySettingsForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
registerBinding(ui->codeAsNumber);
|
||||||
|
|
||||||
m_table = new AutoTableModel<CommodityTypeData>();
|
m_table = new AutoTableModel<CommodityTypeData>();
|
||||||
m_table->setEditableCols(QList<int>() << 0);
|
m_table->setEditableCols(QList<int>() << 0);
|
||||||
ui->commodityTypesTable->setModel(m_table);
|
ui->commodityTypesTable->setModel(m_table);
|
||||||
|
ui->commodityTypesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommoditySettingsForm::~CommoditySettingsForm()
|
CommoditySettingsForm::~CommoditySettingsForm()
|
||||||
@@ -20,12 +25,20 @@ CommoditySettingsForm::~CommoditySettingsForm()
|
|||||||
|
|
||||||
void CommoditySettingsForm::loadEntity()
|
void CommoditySettingsForm::loadEntity()
|
||||||
{
|
{
|
||||||
|
SettingsService srv("COMMODITY");
|
||||||
|
CommoditySettingsPtr settings = srv.loadSettings<CommoditySettings>();
|
||||||
|
setEntity(settings);
|
||||||
|
|
||||||
Service<CommodityTypeData> commodityService;
|
Service<CommodityTypeData> commodityService;
|
||||||
m_table->setData(commodityService.all());
|
m_table->setData(commodityService.all());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommoditySettingsForm::saveRecord()
|
bool CommoditySettingsForm::saveRecord()
|
||||||
{
|
{
|
||||||
|
bindToData();
|
||||||
|
SettingsService srv("COMMODITY");
|
||||||
|
srv.saveSettings(entity());
|
||||||
|
|
||||||
Service<CommodityTypeData> commodityService;
|
Service<CommodityTypeData> commodityService;
|
||||||
foreach (QSharedPointer<CommodityTypeData> item, m_table->list())
|
foreach (QSharedPointer<CommodityTypeData> item, m_table->list())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,15 +2,16 @@
|
|||||||
#define COMMODITYSETTINGSFORM_H
|
#define COMMODITYSETTINGSFORM_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <iform.h>
|
#include <formbinder.h>
|
||||||
#include "data/commoditytypedata.h"
|
#include "data/commoditytypedata.h"
|
||||||
|
#include "settings/commoditysettings.h"
|
||||||
#include <autotablemodel.h>
|
#include <autotablemodel.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class CommoditySettingsForm;
|
class CommoditySettingsForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommoditySettingsForm : public IForm
|
class CommoditySettingsForm : public FormBinder<CommoditySettings>
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>550</width>
|
||||||
<height>300</height>
|
<height>358</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -17,39 +17,92 @@
|
|||||||
<property name="fieldGrowthPolicy">
|
<property name="fieldGrowthPolicy">
|
||||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Commodity types</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
<widget class="QWidget" name="widget" native="true">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="addCommodityType">
|
<widget class="QToolButton" name="addCommodityType">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add type</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>+</string>
|
<string>+</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../core/rc.qrc">
|
<iconset resource="../core/rc.qrc">
|
||||||
<normaloff>:/icons/new.svg</normaloff>:/icons/new.svg</iconset>
|
<normaloff>:/icons/new_24x24.png</normaloff>:/icons/new_24x24.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="delCommodityType">
|
<widget class="QToolButton" name="delCommodityType">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove type</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>-</string>
|
<string>-</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../core/rc.qrc">
|
<iconset resource="../core/rc.qrc">
|
||||||
<normaloff>:/icons/remove.svg</normaloff>:/icons/remove.svg</iconset>
|
<normaloff>:/icons/remove_24x24.png</normaloff>:/icons/remove_24x24.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<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>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item>
|
||||||
<widget class="QTableView" name="commodityTypesTable"/>
|
<widget class="QTableView" name="commodityTypesTable"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="codeAsNumber">
|
||||||
|
<property name="text">
|
||||||
|
<string>Code is number allways</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../core/rc.qrc"/>
|
<include location="../core/rc.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include "commoditysettings.h"
|
||||||
|
|
||||||
|
CommoditySettings::CommoditySettings(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
m_codeAsNumber = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CommoditySettings::codeAsNumber() const
|
||||||
|
{
|
||||||
|
return m_codeAsNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommoditySettings::setCodeAsNumber(bool codeAsNumber)
|
||||||
|
{
|
||||||
|
m_codeAsNumber = codeAsNumber;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef COMMODITYSETTINGS_H
|
||||||
|
#define COMMODITYSETTINGS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
class CommoditySettings : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool codeAsNumber READ codeAsNumber WRITE setCodeAsNumber)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CommoditySettings(QObject *parent = 0);
|
||||||
|
|
||||||
|
bool codeAsNumber() const;
|
||||||
|
void setCodeAsNumber(bool codeAsNumber);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_codeAsNumber;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QSharedPointer<CommoditySettings> CommoditySettingsPtr;
|
||||||
|
|
||||||
|
#endif // COMMODITYSETTINGS_H
|
||||||
@@ -16,6 +16,7 @@ DefaultFormHandler::~DefaultFormHandler()
|
|||||||
|
|
||||||
void DefaultFormHandler::showForm(IForm *formWidget)
|
void DefaultFormHandler::showForm(IForm *formWidget)
|
||||||
{
|
{
|
||||||
|
formWidget->onShow();
|
||||||
m_dialog->setForm(formWidget);
|
m_dialog->setForm(formWidget);
|
||||||
m_dialog->setModal(true);
|
m_dialog->setModal(true);
|
||||||
m_dialog->move(QApplication::desktop()->screen()->rect().center() - m_dialog->rect().center());
|
m_dialog->move(QApplication::desktop()->screen()->rect().center() - m_dialog->rect().center());
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
QString pluginId() const;
|
QString pluginId() const;
|
||||||
void setPluginId(const QString &pluginId);
|
void setPluginId(const QString &pluginId);
|
||||||
virtual void loadEntity() {}
|
virtual void loadEntity() {}
|
||||||
|
virtual void onShow() {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void recordAdded();
|
void recordAdded();
|
||||||
|
|||||||
Reference in New Issue
Block a user