New properties have been added to BarcodeItem.

This commit is contained in:
Arin Alex
2026-02-10 21:17:45 +03:00
parent ea4bd2f60f
commit 2e72a9a48e
2 changed files with 74 additions and 1 deletions
+53 -1
View File
@@ -55,6 +55,7 @@ BarcodeItem::BarcodeItem(QObject* owner, QGraphicsItem* parent):
m_foregroundColor(Qt::black),
m_backgroundColor(Qt::white),
m_whitespace(10),
m_vWhitespace(0),
m_angle(Angle0),
m_barcodeWidth(0),
m_securityLevel(0),
@@ -62,7 +63,9 @@ BarcodeItem::BarcodeItem(QObject* owner, QGraphicsItem* parent):
m_inputMode(UNICODE_INPUT_MODE),
m_hideText(false),
m_option3(0),
m_hideIfEmpty(false)
m_hideIfEmpty(false),
m_borderType(BARCODE_DEFAULT),
m_borderWidth(1)
{
}
@@ -81,9 +84,11 @@ void BarcodeItem::paint(QPainter* ppainter, const QStyleOptionGraphicsItem* opti
bc.setText(m_designTestValue);
else
bc.setText(m_content);
bc.setInputMode(m_inputMode);
bc.setSymbol(m_barcodeType);
bc.setWhitespace(m_whitespace);
bc.setVWhitespace(m_vWhitespace);
bc.setFgColor(m_foregroundColor);
bc.setBgColor(m_backgroundColor);
bc.setWidth(m_barcodeWidth);
@@ -91,6 +96,8 @@ void BarcodeItem::paint(QPainter* ppainter, const QStyleOptionGraphicsItem* opti
bc.setPdf417CodeWords(m_pdf417CodeWords);
bc.setHideText(m_hideText);
bc.setOption3(m_option3);
bc.setBorderType(m_borderType);
bc.setBorderWidth(m_borderWidth);
if (isSelected())
ppainter->setOpacity(Const::SELECTION_OPACITY);
@@ -207,6 +214,17 @@ void BarcodeItem::setWhitespace(int value)
}
}
void BarcodeItem::setVWhitespace(int value)
{
if (m_vWhitespace != value) {
const int oldValue = m_vWhitespace;
m_vWhitespace = value;
if (!isLoading()) {
update();
notify("vWhitespace", oldValue, value);
}
}
}
BarcodeItem::AngleType BarcodeItem::angle() const { return m_angle; }
void BarcodeItem::setAngle(const AngleType& angle)
@@ -221,6 +239,40 @@ void BarcodeItem::setAngle(const AngleType& angle)
}
}
BarcodeItem::BorderType BarcodeItem::borderType() const
{
return m_borderType;
}
void BarcodeItem::setBorderType(const BorderType value)
{
if (m_borderType != value) {
const BorderType oldValue = m_borderType;
m_borderType = value;
if (!isLoading()) {
update();
notify("borderType", oldValue, value);
}
}
}
int BarcodeItem::borderWidth() const
{
return m_borderWidth;
}
void BarcodeItem::setBorderWidth(const int value)
{
if (m_borderWidth != value) {
const int oldValue = m_borderWidth;
m_borderWidth = value;
if (!isLoading()) {
update();
notify("borderWidth", oldValue, value);
}
}
}
int BarcodeItem::barcodeWidth() const { return m_barcodeWidth; }
void BarcodeItem::setBarcodeWidth(int barcodeWidth)
+21
View File
@@ -45,7 +45,10 @@ class BarcodeItem: public LimeReport::ContentItemDesignIntf {
Q_PROPERTY(QColor foregroundColor READ foregroundColor WRITE setForegroundColor)
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(int whitespace READ whitespace WRITE setWhitespace)
Q_PROPERTY(int vWhitespace READ vWhitespace WRITE setWhitespace)
Q_PROPERTY(AngleType angle READ angle WRITE setAngle)
Q_PROPERTY(BorderType borderType READ borderType WRITE setBorderType)
Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth)
Q_PROPERTY(int barcodeWidth READ barcodeWidth WRITE setBarcodeWidth)
Q_PROPERTY(int securityLevel READ securityLevel WRITE setSecurityLevel)
Q_PROPERTY(int pdf417CodeWords READ pdf417CodeWords WRITE setPdf417CodeWords)
@@ -166,14 +169,23 @@ public:
KANJI_INPUT_MODE = 3,
SJIS_INPUT_MODE = 4
};
enum BorderType {
BARCODE_DEFAULT = 0,
BARCODE_BIND = 1,
BARCODE_BOX = 2,
};
#if QT_VERSION >= 0x050500
Q_ENUM(BarcodeType)
Q_ENUM(AngleType)
Q_ENUM(InputMode)
Q_ENUM(BorderType)
#else
Q_ENUMS(BarcodeType)
Q_ENUMS(AngleType)
Q_ENUMS(InputMode)
Q_ENUMS(BorderType)
#endif
BarcodeItem(QObject* owner, QGraphicsItem* parent);
~BarcodeItem();
@@ -197,8 +209,14 @@ public:
void setBackgroundColor(QColor value);
int whitespace() { return m_whitespace; }
void setWhitespace(int value);
int vWhitespace() { return m_vWhitespace; }
void setVWhitespace(int value);
AngleType angle() const;
void setAngle(const AngleType& angle);
BorderType borderType() const;
void setBorderType(BorderType value);
int borderWidth() const;
void setBorderWidth(int value);
int barcodeWidth() const;
void setBarcodeWidth(int barcodeWidth);
int securityLevel() const;
@@ -235,6 +253,9 @@ private:
bool m_hideText;
int m_option3;
bool m_hideIfEmpty;
BorderType m_borderType;
int m_borderWidth;
int m_vWhitespace;
};
} // namespace LimeReport