Commodity - added setting for translate czech chars to numbers (bar code scanner fix).

master
Josef Rokos 7 years ago
parent fe3602fcfc
commit 0ddf8bce92

@ -20,7 +20,8 @@ SOURCES += commodity.cpp \
commodityform.cpp \
commoditygrid.cpp \
commoditysettingsform.cpp \
commodityservice.cpp
commodityservice.cpp \
settings/commoditysettings.cpp
HEADERS += commodity.h\
commodity_global.h \
@ -31,7 +32,8 @@ HEADERS += commodity.h\
commodityform.h \
commoditygrid.h \
commoditysettingsform.h \
commodityservice.h
commodityservice.h \
settings/commoditysettings.h
include(../config_plugin.pri)

@ -1,8 +1,12 @@
#include "commodityform.h"
#include "ui_commodityform.h"
#include <combodata.h>
#include <settingsservice.h>
#include <settings/commoditysettings.h>
#include <helper.h>
#include <QSharedPointer>
#include <qlist.h>
#include <QList>
#include "data/commoditytypedata.h"
CommodityForm::CommodityForm(QWidget *parent) :
@ -21,6 +25,8 @@ CommodityForm::CommodityForm(QWidget *parent) :
<< ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
registerBinding(ui->vat, vt);
registerBinding(ui->count);
m_codeAsNumber = false;
}
CommodityForm::~CommodityForm()
@ -33,3 +39,19 @@ void CommodityForm::registerCombos()
Service<CommodityTypeData> srvComTypes;
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:
Ui::CommodityForm *ui;
bool m_codeAsNumber;
// FormBinder interface
protected:
void registerCombos();
void onShow();
private slots:
void on_code_textChanged(const QString &text);
};
#endif // COMMODITYFORM_H

@ -1,16 +1,21 @@
#include "commoditysettingsform.h"
#include "ui_commoditysettingsform.h"
#include <service.h>
#include <settingsservice.h>
#include "commodity-odb.hxx"
CommoditySettingsForm::CommoditySettingsForm(QWidget *parent) :
IForm(parent),
FormBinder<CommoditySettings>(parent),
ui(new Ui::CommoditySettingsForm)
{
ui->setupUi(this);
registerBinding(ui->codeAsNumber);
m_table = new AutoTableModel<CommodityTypeData>();
m_table->setEditableCols(QList<int>() << 0);
ui->commodityTypesTable->setModel(m_table);
ui->commodityTypesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
}
CommoditySettingsForm::~CommoditySettingsForm()
@ -20,12 +25,20 @@ CommoditySettingsForm::~CommoditySettingsForm()
void CommoditySettingsForm::loadEntity()
{
SettingsService srv("COMMODITY");
CommoditySettingsPtr settings = srv.loadSettings<CommoditySettings>();
setEntity(settings);
Service<CommodityTypeData> commodityService;
m_table->setData(commodityService.all());
}
bool CommoditySettingsForm::saveRecord()
{
bindToData();
SettingsService srv("COMMODITY");
srv.saveSettings(entity());
Service<CommodityTypeData> commodityService;
foreach (QSharedPointer<CommodityTypeData> item, m_table->list())
{

@ -2,15 +2,16 @@
#define COMMODITYSETTINGSFORM_H
#include <QWidget>
#include <iform.h>
#include <formbinder.h>
#include "data/commoditytypedata.h"
#include "settings/commoditysettings.h"
#include <autotablemodel.h>
namespace Ui {
class CommoditySettingsForm;
}
class CommoditySettingsForm : public IForm
class CommoditySettingsForm : public FormBinder<CommoditySettings>
{
Q_OBJECT

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>550</width>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
@ -17,36 +17,89 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="1">
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<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="QToolButton" name="addCommodityType">
<property name="text">
<string>+</string>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<normaloff>:/icons/new.svg</normaloff>:/icons/new.svg</iconset>
</property>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="addCommodityType">
<property name="toolTip">
<string>Add type</string>
</property>
<property name="text">
<string>+</string>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<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>
</widget>
</item>
<item>
<widget class="QToolButton" name="delCommodityType">
<property name="toolTip">
<string>Remove type</string>
</property>
<property name="text">
<string>-</string>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<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>
</widget>
</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>
</widget>
</item>
<item>
<widget class="QToolButton" name="delCommodityType">
<property name="text">
<string>-</string>
</property>
<property name="icon">
<iconset resource="../core/rc.qrc">
<normaloff>:/icons/remove.svg</normaloff>:/icons/remove.svg</iconset>
</property>
</widget>
<widget class="QTableView" name="commodityTypesTable"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QTableView" name="commodityTypesTable"/>
<item row="2" column="1">
<widget class="QCheckBox" name="codeAsNumber">
<property name="text">
<string>Code is number allways</string>
</property>
</widget>
</item>
</layout>
</widget>

@ -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)
{
formWidget->onShow();
m_dialog->setForm(formWidget);
m_dialog->setModal(true);
m_dialog->move(QApplication::desktop()->screen()->rect().center() - m_dialog->rect().center());

@ -19,6 +19,7 @@ public:
QString pluginId() const;
void setPluginId(const QString &pluginId);
virtual void loadEntity() {}
virtual void onShow() {}
signals:
void recordAdded();

Loading…
Cancel
Save