You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#include "commodityform.h"
|
|
#include "ui_commodityform.h"
|
|
#include <combodata.h>
|
|
#include <settingsservice.h>
|
|
#include <helper.h>
|
|
|
|
#include <QSharedPointer>
|
|
#include <QList>
|
|
#include "data/commoditytypedata.h"
|
|
#include "settings/commoditysettings.h"
|
|
|
|
CommodityForm::CommodityForm(QWidget *parent) :
|
|
AutoForm<CommodityData>(parent),
|
|
ui(new Ui::CommodityForm)
|
|
{
|
|
ui->setupUi(this);
|
|
registerBinding(ui->name);
|
|
registerBinding(ui->shortName);
|
|
registerBinding(ui->code);
|
|
registerBinding(ui->price);
|
|
QList<ComboData> vt;
|
|
vt << ComboData(Enums::NONE,tr("None"))
|
|
<< ComboData(Enums::HIGH,tr("High"))
|
|
<< ComboData(Enums::FIRST_LOWER,tr("First Lower"))
|
|
<< ComboData(Enums::SECOND_LOWER,tr("Second Lower"));
|
|
registerBinding(ui->vat, vt);
|
|
registerBinding(ui->count);
|
|
registerBinding(ui->favorite);
|
|
|
|
m_codeAsNumber = false;
|
|
}
|
|
|
|
CommodityForm::~CommodityForm()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
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));
|
|
}
|
|
}
|