修改文件换行符,修正轮班图元长度计算问题
This commit is contained in:
+192
-192
@@ -1,192 +1,192 @@
|
||||
#ifndef BARCODEEDITOR_H
|
||||
#define BARCODEEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ViewModels.h"
|
||||
#include "SysPara.h"
|
||||
#include "dlgQrcodeFormat.h"
|
||||
#include "DlgBarcodeFormat.h"
|
||||
#include <QVariant>
|
||||
#include "ItemGeneralSettings.h"
|
||||
|
||||
class DateFormatEditor;
|
||||
class DateReplaceEditor;
|
||||
class CounterEditor;
|
||||
|
||||
enum BarcodeType {
|
||||
BARCODE_TYPE_BARCODE = 0,
|
||||
BARCODE_TYPE_QRCODE = 1,
|
||||
BARCODE_TYPE_DMCODE = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 条码设置界面所用的视图模型
|
||||
*
|
||||
* @remark contentPattern 内可包含变量,如 {t} 表示日期/时间、{c} 表示计数器。
|
||||
* 仅当 contentPattern 含有相应变量时,counterViewModel / dateViewModel 字段才有意义。
|
||||
*/
|
||||
struct BarcodeViewModel {
|
||||
TextItemModel generalSettingsVM; // 通用设置视图模型
|
||||
QString contentPattern; // 条形码内容模版,例如 "ABC{t}{c1}"
|
||||
CounterViewModel counterViewModel; // 计数器视图模型
|
||||
DateItemModel dateViewModel; // 日期视图模型
|
||||
BarcodeType type = BARCODE_TYPE_BARCODE; // 条形码 或 二维码
|
||||
QVariant format; // 条形码/二维码 格式设置,如果是条形码,则实际类型为 DlgBarcodeFormatVM,如果是二维码,则实际类型为 DlgQrcodeFormatVM
|
||||
|
||||
std::function<QImage()> imageGenerator; // 条形码/二维码 图片生成函数
|
||||
|
||||
/**
|
||||
* @brief 将vm保存到xml属性集
|
||||
*
|
||||
* @param vm 条码视图模型
|
||||
* @param attrs xml属性集
|
||||
*/
|
||||
static void saveToXml(const BarcodeViewModel& vm, QXmlStreamAttributes& attrs);
|
||||
|
||||
/**
|
||||
* @brief 从xml属性集加载条码视图模型
|
||||
*
|
||||
* @param attrs xml属性集
|
||||
* @return BarcodeViewModel 条码视图模型
|
||||
*/
|
||||
static BarcodeViewModel loadFromXml(const QXmlStreamAttributes& attrs);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param vm 条码视图模型
|
||||
* @return QString 字符串表示
|
||||
*
|
||||
* @example
|
||||
* type: 0
|
||||
* contentPattern: ABC{t}{c1}
|
||||
* counterViewModel:
|
||||
* \t counter type: 7
|
||||
* \t digital number: 2
|
||||
* \t letter space: 2
|
||||
* dateViewModel:
|
||||
* \t pattern: "yyyy-MM-dd HH:mm:ss"
|
||||
* \t expirationValue: 0
|
||||
* \t expirationType: 0
|
||||
* format:
|
||||
* \t type: "BARCODE_128"
|
||||
* \t height: 9
|
||||
* \t width: 36
|
||||
* \t scale: 1
|
||||
* \t inkType: 0
|
||||
* \t txtVisible: false
|
||||
*/
|
||||
static QString toString(const BarcodeViewModel& vm);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(BarcodeViewModel);
|
||||
|
||||
namespace Ui {
|
||||
class BarcodeEditor;
|
||||
}
|
||||
|
||||
class BarcodeEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BarcodeEditor(QWidget *parent = nullptr);
|
||||
~BarcodeEditor();
|
||||
|
||||
/**
|
||||
* @brief 注入条形码视图模型(纯结构体,按值拷贝)
|
||||
*
|
||||
* @param vm
|
||||
*/
|
||||
void bindViewModel(const BarcodeViewModel& vm);
|
||||
|
||||
/**
|
||||
* @brief 获取当前视图模型
|
||||
*
|
||||
* @note 调用前会先从各子编辑器收集最新值回写到内部 m_vm,再返回。
|
||||
*
|
||||
* @return BarcodeViewModel
|
||||
*/
|
||||
BarcodeViewModel viewModel();
|
||||
|
||||
void restoreViewModel();
|
||||
|
||||
void applyCounterConfigToSysPara();
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
* @brief 条形码内容改变时触发
|
||||
*
|
||||
* @param content
|
||||
*/
|
||||
void onContentChanged(QString content);
|
||||
|
||||
/**
|
||||
* @brief 条形码、二维码格式更改按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onBtnFormatClicked();
|
||||
|
||||
/**
|
||||
* @brief 日期按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onBtnDatetimeClicked();
|
||||
|
||||
/**
|
||||
* @brief 计数器按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onBtnCounterClicked();
|
||||
|
||||
/**
|
||||
* @brief 确定按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onCheckBtnClicked();
|
||||
|
||||
/**
|
||||
* @brief 取消按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onCloseBtnClicked();
|
||||
|
||||
/**
|
||||
* @brief 条形码格式确认时触发
|
||||
*
|
||||
*/
|
||||
void onBarcodeFormatConfirmed();
|
||||
|
||||
/**
|
||||
* @brief 二维码格式确认时触发
|
||||
*
|
||||
*/
|
||||
void onQrcodeFormatConfirmed();
|
||||
|
||||
void onTypeChanged(int i);
|
||||
|
||||
void on_cbBoxType_currentIndexChanged(int index);
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
|
||||
private:
|
||||
Ui::BarcodeEditor *ui;
|
||||
|
||||
void applyStyleSheet();
|
||||
|
||||
BarcodeViewModel m_vm;
|
||||
|
||||
DateFormatEditor *m_dateFormatEditor = nullptr;
|
||||
DateReplaceEditor *m_dateReplaceEditor = nullptr;
|
||||
CounterEditor *m_counterEditor = nullptr;
|
||||
|
||||
SysPara* m_sysPara = nullptr;
|
||||
|
||||
DlgBarcodeFormat m_barcodeFormatEditor;
|
||||
DlgQrcodeFormat m_qrcodeFormatEditor;
|
||||
};
|
||||
|
||||
#endif // BARCODEEDITOR_H
|
||||
#ifndef BARCODEEDITOR_H
|
||||
#define BARCODEEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ViewModels.h"
|
||||
#include "SysPara.h"
|
||||
#include "dlgQrcodeFormat.h"
|
||||
#include "DlgBarcodeFormat.h"
|
||||
#include <QVariant>
|
||||
#include "ItemGeneralSettings.h"
|
||||
|
||||
class DateFormatEditor;
|
||||
class DateReplaceEditor;
|
||||
class CounterEditor;
|
||||
|
||||
enum BarcodeType {
|
||||
BARCODE_TYPE_BARCODE = 0,
|
||||
BARCODE_TYPE_QRCODE = 1,
|
||||
BARCODE_TYPE_DMCODE = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 条码设置界面所用的视图模型
|
||||
*
|
||||
* @remark contentPattern 内可包含变量,如 {t} 表示日期/时间、{c} 表示计数器。
|
||||
* 仅当 contentPattern 含有相应变量时,counterViewModel / dateViewModel 字段才有意义。
|
||||
*/
|
||||
struct BarcodeViewModel {
|
||||
TextItemModel generalSettingsVM; // 通用设置视图模型
|
||||
QString contentPattern; // 条形码内容模版,例如 "ABC{t}{c1}"
|
||||
CounterViewModel counterViewModel; // 计数器视图模型
|
||||
DateItemModel dateViewModel; // 日期视图模型
|
||||
BarcodeType type = BARCODE_TYPE_BARCODE; // 条形码 或 二维码
|
||||
QVariant format; // 条形码/二维码 格式设置,如果是条形码,则实际类型为 DlgBarcodeFormatVM,如果是二维码,则实际类型为 DlgQrcodeFormatVM
|
||||
|
||||
std::function<QImage()> imageGenerator; // 条形码/二维码 图片生成函数
|
||||
|
||||
/**
|
||||
* @brief 将vm保存到xml属性集
|
||||
*
|
||||
* @param vm 条码视图模型
|
||||
* @param attrs xml属性集
|
||||
*/
|
||||
static void saveToXml(const BarcodeViewModel& vm, QXmlStreamAttributes& attrs);
|
||||
|
||||
/**
|
||||
* @brief 从xml属性集加载条码视图模型
|
||||
*
|
||||
* @param attrs xml属性集
|
||||
* @return BarcodeViewModel 条码视图模型
|
||||
*/
|
||||
static BarcodeViewModel loadFromXml(const QXmlStreamAttributes& attrs);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param vm 条码视图模型
|
||||
* @return QString 字符串表示
|
||||
*
|
||||
* @example
|
||||
* type: 0
|
||||
* contentPattern: ABC{t}{c1}
|
||||
* counterViewModel:
|
||||
* \t counter type: 7
|
||||
* \t digital number: 2
|
||||
* \t letter space: 2
|
||||
* dateViewModel:
|
||||
* \t pattern: "yyyy-MM-dd HH:mm:ss"
|
||||
* \t expirationValue: 0
|
||||
* \t expirationType: 0
|
||||
* format:
|
||||
* \t type: "BARCODE_128"
|
||||
* \t height: 9
|
||||
* \t width: 36
|
||||
* \t scale: 1
|
||||
* \t inkType: 0
|
||||
* \t txtVisible: false
|
||||
*/
|
||||
static QString toString(const BarcodeViewModel& vm);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(BarcodeViewModel);
|
||||
|
||||
namespace Ui {
|
||||
class BarcodeEditor;
|
||||
}
|
||||
|
||||
class BarcodeEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BarcodeEditor(QWidget *parent = nullptr);
|
||||
~BarcodeEditor();
|
||||
|
||||
/**
|
||||
* @brief 注入条形码视图模型(纯结构体,按值拷贝)
|
||||
*
|
||||
* @param vm
|
||||
*/
|
||||
void bindViewModel(const BarcodeViewModel& vm);
|
||||
|
||||
/**
|
||||
* @brief 获取当前视图模型
|
||||
*
|
||||
* @note 调用前会先从各子编辑器收集最新值回写到内部 m_vm,再返回。
|
||||
*
|
||||
* @return BarcodeViewModel
|
||||
*/
|
||||
BarcodeViewModel viewModel();
|
||||
|
||||
void restoreViewModel();
|
||||
|
||||
void applyCounterConfigToSysPara();
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
* @brief 条形码内容改变时触发
|
||||
*
|
||||
* @param content
|
||||
*/
|
||||
void onContentChanged(QString content);
|
||||
|
||||
/**
|
||||
* @brief 条形码、二维码格式更改按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onBtnFormatClicked();
|
||||
|
||||
/**
|
||||
* @brief 日期按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onBtnDatetimeClicked();
|
||||
|
||||
/**
|
||||
* @brief 计数器按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onBtnCounterClicked();
|
||||
|
||||
/**
|
||||
* @brief 确定按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onCheckBtnClicked();
|
||||
|
||||
/**
|
||||
* @brief 取消按钮点击时触发
|
||||
*
|
||||
*/
|
||||
void onCloseBtnClicked();
|
||||
|
||||
/**
|
||||
* @brief 条形码格式确认时触发
|
||||
*
|
||||
*/
|
||||
void onBarcodeFormatConfirmed();
|
||||
|
||||
/**
|
||||
* @brief 二维码格式确认时触发
|
||||
*
|
||||
*/
|
||||
void onQrcodeFormatConfirmed();
|
||||
|
||||
void onTypeChanged(int i);
|
||||
|
||||
void on_cbBoxType_currentIndexChanged(int index);
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
|
||||
private:
|
||||
Ui::BarcodeEditor *ui;
|
||||
|
||||
void applyStyleSheet();
|
||||
|
||||
BarcodeViewModel m_vm;
|
||||
|
||||
DateFormatEditor *m_dateFormatEditor = nullptr;
|
||||
DateReplaceEditor *m_dateReplaceEditor = nullptr;
|
||||
CounterEditor *m_counterEditor = nullptr;
|
||||
|
||||
SysPara* m_sysPara = nullptr;
|
||||
|
||||
DlgBarcodeFormat m_barcodeFormatEditor;
|
||||
DlgQrcodeFormat m_qrcodeFormatEditor;
|
||||
};
|
||||
|
||||
#endif // BARCODEEDITOR_H
|
||||
|
||||
Reference in New Issue
Block a user