V6.7.5_beta
This commit is contained in:
+13
-87
@@ -8,34 +8,13 @@
|
||||
#include "DlgQrcodeFormat.h"
|
||||
|
||||
// 使用SysPara的相关参数构造CounterEditorVM
|
||||
CounterEditorVM makeCounterVM(SysPara* sysPara, COUNTER_TYPE type, int digitalNum)
|
||||
CounterEditorVM makeCounterVM(COUNTER_TYPE type, int digitalNum, const CounterSettings& cnt1Settings, const CounterSettings& cnt2Settings)
|
||||
{
|
||||
CounterEditorVM vm;
|
||||
if(!sysPara)
|
||||
return vm;
|
||||
|
||||
vm.counterType = type;
|
||||
vm.digitalNum = digitalNum;
|
||||
|
||||
auto& cnt1 = vm.counter1;
|
||||
cnt1.startValue = sysPara->para.cnt1StartValue;
|
||||
cnt1.endValue = sysPara->para.cnt1EndValue;
|
||||
cnt1.repeatValue = sysPara->para.cnt1RepeateValue;
|
||||
cnt1.stepValue = sysPara->para.cnt1StepValue;
|
||||
cnt1.currValue = sysPara->para.cnt1CurrValue;
|
||||
// cnt1CurrentValueInitDoneFlag 与 checkBoxResetCnt1CurrValue 的勾选互为反向
|
||||
cnt1.editCurrValue = !sysPara->status.cnt1CurrentValueInitDoneFlag;
|
||||
cnt1.eleEyeIncEn = (sysPara->para.eleEyeClearCntInSynMode & 0x10) != 0;
|
||||
|
||||
auto& cnt2 = vm.counter2;
|
||||
cnt2.startValue = sysPara->para.cnt2StartValue;
|
||||
cnt2.endValue = sysPara->para.cnt2EndValue;
|
||||
cnt2.repeatValue = sysPara->para.cnt2RepeateValue;
|
||||
cnt2.stepValue = sysPara->para.cnt2StepValue;
|
||||
cnt2.currValue = sysPara->para.cnt2CurrValue;
|
||||
cnt2.editCurrValue = !sysPara->status.cnt2CurrentValueInitDoneFlag;
|
||||
cnt2.eleEyeIncEn = (sysPara->para.eleEyeClearCntInSynMode & 0x20) != 0;
|
||||
|
||||
vm.counter1 = cnt1Settings;
|
||||
vm.counter2 = cnt2Settings;
|
||||
return vm;
|
||||
}
|
||||
|
||||
@@ -90,15 +69,6 @@ BarcodeEditor::~BarcodeEditor()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void BarcodeEditor::bindSysPara(SysPara *sysPara)
|
||||
{
|
||||
if (!sysPara) {
|
||||
qWarning() << "BarcodeEditor::bindSysPara: null pointer passed, ignored";
|
||||
return;
|
||||
}
|
||||
m_sysPara = sysPara;
|
||||
}
|
||||
|
||||
void BarcodeEditor::bindViewModel(const BarcodeViewModel &vm)
|
||||
{
|
||||
m_vm = vm;
|
||||
@@ -171,9 +141,11 @@ void BarcodeEditor::bindViewModel(const BarcodeViewModel &vm)
|
||||
if(ui->tabWidget->indexOf(m_counterEditor) == -1) {
|
||||
ui->tabWidget->addTab(m_counterEditor, tr(u8"计数器"));
|
||||
}
|
||||
m_counterEditor->setViewModel(makeCounterVM(m_sysPara,
|
||||
m_counterEditor->setViewModel(makeCounterVM(
|
||||
static_cast<COUNTER_TYPE>(m_vm.counterViewModel.counterType),
|
||||
m_vm.counterViewModel.digitalNum));
|
||||
m_vm.counterViewModel.digitalNum,
|
||||
m_vm.counterViewModel.cnt1Settings,
|
||||
m_vm.counterViewModel.cnt2Settings));
|
||||
m_counterEditor->setFixedSize(ui->tabBarcode->size());
|
||||
}
|
||||
else {
|
||||
@@ -226,6 +198,8 @@ BarcodeViewModel BarcodeEditor::viewModel()
|
||||
CounterEditorVM cnt = m_counterEditor->viewModel();
|
||||
m_vm.counterViewModel.counterType = cnt.counterType;
|
||||
m_vm.counterViewModel.digitalNum = cnt.digitalNum;
|
||||
m_vm.counterViewModel.cnt1Settings = cnt.counter1;
|
||||
m_vm.counterViewModel.cnt2Settings = cnt.counter2;
|
||||
}
|
||||
|
||||
return m_vm;
|
||||
@@ -242,53 +216,6 @@ void BarcodeEditor::restoreViewModel()
|
||||
bindViewModel(m_vm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 逻辑基本类似 CounterVarSet::applyUIPara
|
||||
*
|
||||
*/
|
||||
void BarcodeEditor::applyCounterConfigToSysPara()
|
||||
{
|
||||
if(!m_vm.contentPattern.contains("{c}"))
|
||||
return;
|
||||
|
||||
if (!m_sysPara) {
|
||||
qWarning() << "BarcodeEditor::applyCounterConfigToSysPara: m_sysPara is null, skipping";
|
||||
return;
|
||||
}
|
||||
|
||||
CounterEditorVM cnt = m_counterEditor->viewModel();
|
||||
if(cnt.counterType == COUNTER_TYPE_1) {
|
||||
m_sysPara->para.cnt1StartValue = cnt.counter1.startValue;
|
||||
m_sysPara->para.cnt1EndValue = cnt.counter1.endValue;
|
||||
m_sysPara->para.cnt1RepeateValue = cnt.counter1.repeatValue;
|
||||
m_sysPara->para.cnt1StepValue = cnt.counter1.stepValue;
|
||||
m_sysPara->para.cnt1CurrValue = cnt.counter1.currValue;
|
||||
m_sysPara->status.cnt1CurrentValueInitDoneFlag = cnt.counter1.editCurrValue;
|
||||
|
||||
if(cnt.counter1.eleEyeIncEn)
|
||||
m_sysPara->para.eleEyeClearCntInSynMode = (m_sysPara->para.eleEyeClearCntInSynMode | 0x10); // CNT1 +1
|
||||
else
|
||||
m_sysPara->para.eleEyeClearCntInSynMode = (m_sysPara->para.eleEyeClearCntInSynMode & 0xef); // CNT1 = current
|
||||
|
||||
}
|
||||
else if(cnt.counterType == COUNTER_TYPE_2) {
|
||||
m_sysPara->para.cnt2StartValue = cnt.counter2.startValue;
|
||||
m_sysPara->para.cnt2EndValue = cnt.counter2.endValue;
|
||||
m_sysPara->para.cnt2RepeateValue = cnt.counter2.repeatValue;
|
||||
m_sysPara->para.cnt2StepValue = cnt.counter2.stepValue;
|
||||
m_sysPara->para.cnt2CurrValue = cnt.counter2.currValue;
|
||||
m_sysPara->status.cnt2CurrentValueInitDoneFlag = cnt.counter2.editCurrValue;
|
||||
|
||||
if(cnt.counter2.eleEyeIncEn)
|
||||
m_sysPara->para.eleEyeClearCntInSynMode = (m_sysPara->para.eleEyeClearCntInSynMode | 0x20); // CNT2 +1
|
||||
else
|
||||
m_sysPara->para.eleEyeClearCntInSynMode = (m_sysPara->para.eleEyeClearCntInSynMode & 0xdf); // CNT2 = current
|
||||
}
|
||||
|
||||
if(m_sysPara->devOp)
|
||||
m_sysPara->devOp->writeFpgaCalandar(0);
|
||||
}
|
||||
|
||||
void BarcodeEditor::onBtnFormatClicked()
|
||||
{
|
||||
if(m_vm.type == BARCODE_TYPE_BARCODE) {
|
||||
@@ -330,7 +257,6 @@ void BarcodeEditor::onBtnCounterClicked()
|
||||
void BarcodeEditor::onCheckBtnClicked()
|
||||
{
|
||||
m_vm = viewModel();
|
||||
applyCounterConfigToSysPara();
|
||||
emit accepted();
|
||||
hide();
|
||||
}
|
||||
@@ -466,11 +392,11 @@ void BarcodeEditor::onContentChanged(QString content)
|
||||
else {
|
||||
if(ui->tabWidget->indexOf(m_counterEditor) == -1) {
|
||||
ui->tabWidget->addTab(m_counterEditor, tr(u8"计数器"));
|
||||
if(m_sysPara) {
|
||||
m_counterEditor->setViewModel(makeCounterVM(m_sysPara,
|
||||
m_counterEditor->setViewModel(makeCounterVM(
|
||||
static_cast<COUNTER_TYPE>(m_vm.counterViewModel.counterType),
|
||||
m_vm.counterViewModel.digitalNum));
|
||||
}
|
||||
m_vm.counterViewModel.digitalNum,
|
||||
m_vm.counterViewModel.cnt1Settings,
|
||||
m_vm.counterViewModel.cnt2Settings));
|
||||
}
|
||||
m_counterEditor->setFixedSize(ui->tabBarcode->size());
|
||||
}
|
||||
|
||||
@@ -94,19 +94,6 @@ public:
|
||||
explicit BarcodeEditor(QWidget *parent = nullptr);
|
||||
~BarcodeEditor();
|
||||
|
||||
/**
|
||||
* @brief 绑定系统参数
|
||||
*
|
||||
* 计数器配置选项卡所需的各个计数器的配置通过此方式提供;
|
||||
* @note
|
||||
* BarcodeEditor 将在 @see bindViewModel 中读取 sysPara->para.cnt1*** 或 sysPara->para.cnt2*** 相关参数,并在用户点击确认按钮时修改它们。
|
||||
*
|
||||
* @remark 沿用的是旧逻辑
|
||||
*
|
||||
* @param sysPara
|
||||
*/
|
||||
void bindSysPara(SysPara* sysPara);
|
||||
|
||||
/**
|
||||
* @brief 注入条形码视图模型(纯结构体,按值拷贝)
|
||||
*
|
||||
|
||||
@@ -31,6 +31,8 @@ struct CounterEditorVM {
|
||||
CounterSlot counter1, counter2;
|
||||
};
|
||||
|
||||
using CounterSettings = CounterEditorVM::CounterSlot;
|
||||
|
||||
class CounterEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "SysPara.h"
|
||||
#include <QMap>
|
||||
#include <QXmlStreamAttributes>
|
||||
#include "CounterEditor.h"
|
||||
|
||||
enum InkType {
|
||||
INK_TYPE_BLACK,
|
||||
@@ -34,6 +35,10 @@ struct CounterViewModel {
|
||||
int charWidth = 0; // 字符宽度,仅在 enbCustomCharWidth == true 时有意义
|
||||
bool enbCustomCharWidth = false;
|
||||
|
||||
CounterSettings cnt1Settings;
|
||||
|
||||
CounterSettings cnt2Settings;
|
||||
|
||||
static void loadFromXml(CounterViewModel& vm, const QXmlStreamAttributes& attrs);
|
||||
static void saveToXml(CounterViewModel& vm, QXmlStreamAttributes& attrs);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user