新二维码/条形码编辑逻辑
This commit is contained in:
+46
-1
@@ -6,7 +6,26 @@
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include "BarcodeEditor.h"
|
||||
#include <array>
|
||||
#include <QImage>
|
||||
|
||||
/**
|
||||
* @brief 根据日期视图模型和时间生成字符串
|
||||
* @param model 包含日期格式模版和相关配置的视图模型
|
||||
* @param time 用于生成字符串的时间
|
||||
* @return QString 生成的字符串
|
||||
* @remark
|
||||
* 该函数根据 model.datetimePattern 中的格式模版生成字符串,支持以下格式:
|
||||
* - yyyy: 四位数年份,支持替换为自定义字符串(通过 model.yearsMap)
|
||||
* - YY: 两位数年份
|
||||
* - MM: 两位数月份,支持替换为自定义字符串(通过 model.monthsMap)
|
||||
* - dd: 两位数日期,支持替换为自定义字符串(通过 model.daysMap)
|
||||
* - HH: 两位数小时,支持替换为自定义字符串(通过 model.hoursMap)
|
||||
* - mm: 两位数分钟
|
||||
* - ss: 两位数秒钟
|
||||
* - w: 星期几,支持替换为自定义字符串(通过 model.weeksMap)
|
||||
* - c: 年中周数
|
||||
*/
|
||||
QString generateTxtFromDateItemModel(const DateItemModel& model, const QDateTime& time);
|
||||
|
||||
/**
|
||||
@@ -28,4 +47,30 @@ QString generateTxtFromDateItemModel(const DateItemModel& model, const QDateTime
|
||||
*/
|
||||
QString generateTxtFromBarcodeViewModel(const BarcodeViewModel& vm, const std::array<int, 2> counterValues, const QDateTime& time);
|
||||
|
||||
#endif // _ITEM_COMMON_H_
|
||||
/**
|
||||
* @brief 根据条形码类型和内容生成条形码或二维码图像
|
||||
* @param content 已格式化的文本内容
|
||||
* @param type 条码类型
|
||||
* @param format 配置参数
|
||||
* @return QImage 生成的图像;如果失败返回空图像
|
||||
* @note
|
||||
* format 参数类型:
|
||||
* - BARCODE_TYPE_QRCODE: DlgQrcodeFormatVM 或 int
|
||||
* - BARCODE_TYPE_BARCODE: DlgBarcodeFormatVM 或 int
|
||||
* 如果 format 是 int 类型, 对于 QR Code,0 表示 Data Matrix,1 表示 QR Code;对于条形码,int 值对应 DlgBarcodeFormatVM 中 type 的索引。
|
||||
* 如果 format 是 int 类型,则使用默认配置并根据 int 值选择二维码或条形码的子类型;如果 format 是对应的 VM 类型,则使用其中的详细配置。
|
||||
*/
|
||||
QImage generateBarcodeImage(const QString& content, BarcodeType type, const QVariant& format);
|
||||
|
||||
/**
|
||||
* @brief 将文本转换为图像
|
||||
* @param txt 要转换的文本
|
||||
* @param font 文本使用的字体
|
||||
* @param fgColor 文本颜色,默认为黑色
|
||||
* @param bgColor 背景颜色,默认为白色
|
||||
* @return QImage 转换后的图像
|
||||
* @note 返回的字符串图像会裁剪至最小边界以节省空间。例如字符串"aaa"的高度会比"bbbjjj"小,因为前者没有上下行部分。
|
||||
*/
|
||||
QImage txtToImage(const QString& txt, const QFont& font, const QColor& fgColor = Qt::black, const QColor& bgColor = Qt::white);
|
||||
|
||||
#endif // _ITEM_COMMON_H_
|
||||
|
||||
Reference in New Issue
Block a user