Add HEIGHTPERROW_MODE_input mode flag (#204)

backend_qt: add encodedWidth, encodedRows
DBAR_EXPSTK: add max rows option (option_3)
CODE16K/CODE49: add min rows option (option_1)
GUI: HIBC xxx -> HIBC
This commit is contained in:
gitlost
2021-11-20 11:32:30 +00:00
parent 96cf5aa668
commit e14d9e99d5
36 changed files with 2453 additions and 608 deletions

View File

@ -69,6 +69,8 @@ namespace Zint {
m_reader_init = false;
m_rotate_angle = 0;
m_debug = false;
m_encodedWidth = 0;
m_encodedRows = 0;
target_size_horiz = 0; /* Legacy */
target_size_vert = 0; /* Legacy */
@ -156,8 +158,12 @@ namespace Zint {
m_borderWidth = m_zintSymbol->border_width;
m_whitespace = m_zintSymbol->whitespace_width;
m_vwhitespace = m_zintSymbol->whitespace_height;
m_encodedWidth = m_zintSymbol->width;
m_encodedRows = m_zintSymbol->rows;
emit encoded();
} else {
m_encodedWidth = 0;
m_encodedRows = 0;
emit errored();
}
}
@ -509,6 +515,14 @@ namespace Zint {
m_debug = debug;
}
int QZint::encodedWidth() const { // Read-only, encoded width (no. of modules encoded)
return m_encodedWidth;
}
int QZint::encodedRows() const { // Read-only, no. of rows encoded
return m_encodedRows;
}
/* Legacy */
void QZint::setWidth(int width) { setOption1(width); }
int QZint::width() const { return m_option_1; }
@ -583,6 +597,8 @@ namespace Zint {
m_rotate_angle);
if (m_error >= ZINT_ERROR) {
m_lastError = m_zintSymbol->errtxt;
m_encodedWidth = 0;
m_encodedRows = 0;
emit errored();
return false;
} else {

View File

@ -139,6 +139,9 @@ public:
bool debug() const;
void setDebug(bool debug);
int encodedWidth() const; // Read-only, encoded width (no. of modules encoded)
int encodedRows() const; // Read-only, no. of rows encoded
/* Legacy property getters/setters */
void setWidth(int width); /* option_1 */
int width() const;
@ -218,6 +221,8 @@ private:
bool m_compliant_height;
bool m_reader_init;
bool m_debug;
int m_encodedWidth;
int m_encodedRows;
int target_size_horiz; /* Legacy */
int target_size_vert; /* Legacy */

View File

@ -223,6 +223,9 @@ private slots:
bool debug = true;
bc.setDebug(debug);
QCOMPARE(bc.debug(), debug);
QCOMPARE(bc.encodedWidth(), 0); // Read-only
QCOMPARE(bc.encodedRows(), 0); // Read-only
}
void setGetECIValueTest_data()
@ -314,10 +317,12 @@ private slots:
QTest::addColumn<QString>("text");
QTest::addColumn<int>("getError");
QTest::addColumn<QString>("error_message");
QTest::addColumn<int>("encodedWidth");
QTest::addColumn<int>("encodedRows");
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0 << "";
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0 << "" << 21 << 21;
if (!m_skipIfFontUsed) {
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << ZINT_ERROR_INVALID_DATA << "Error 205: No input data";
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << ZINT_ERROR_INVALID_DATA << "Error 205: No input data" << 0 << 0;
}
}
@ -340,6 +345,8 @@ private slots:
QFETCH(QString, text);
QFETCH(int, getError);
QFETCH(QString, error_message);
QFETCH(int, encodedWidth);
QFETCH(int, encodedRows);
bc.setSymbol(symbology);
bc.setText(text);
@ -356,6 +363,8 @@ private slots:
QCOMPARE(bc.error_message(), error_message);
QCOMPARE(bc.lastError(), error_message);
QCOMPARE(bc.hasErrors(), getError != 0);
QCOMPARE(bc.encodedWidth(), encodedWidth);
QCOMPARE(bc.encodedRows(), encodedRows);
if (getError) {
QCOMPARE(spyEncoded.count(), 0);