新二维码/条形码编辑逻辑
This commit is contained in:
+58
-5
@@ -8,6 +8,7 @@
|
||||
#include "dlgQrcodeFormat.h"
|
||||
#include "DlgBarcodeFormat.h"
|
||||
#include <QVariant>
|
||||
#include "ItemGeneralSettings.h"
|
||||
|
||||
class DateFormatEditor;
|
||||
class DateReplaceEditor;
|
||||
@@ -25,11 +26,57 @@ enum BarcodeType {
|
||||
* 仅当 contentPattern 含有相应变量时,counterViewModel / dateViewModel 字段才有意义。
|
||||
*/
|
||||
struct BarcodeViewModel {
|
||||
QString contentPattern; // 条形码内容模版,例如 "ABC{t}{c1}"
|
||||
CounterViewModel counterViewModel; // 计数器视图模型
|
||||
DateItemModel dateViewModel; // 日期视图模型
|
||||
BarcodeType type = BARCODE_TYPE_BARCODE;
|
||||
QVariant format;
|
||||
ItemGeneralSettingsVM 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);
|
||||
@@ -75,6 +122,10 @@ public:
|
||||
*/
|
||||
BarcodeViewModel viewModel();
|
||||
|
||||
void restoreViewModel();
|
||||
|
||||
void applyCounterConfigToSysPara();
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
@@ -126,6 +177,8 @@ private slots:
|
||||
*/
|
||||
void onQrcodeFormatConfirmed();
|
||||
|
||||
void onTypeChanged(int i);
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user