more qt code

trying to catch up robin ;)
This commit is contained in:
taipanromania 2008-09-17 17:36:08 +00:00
parent 0704f600f0
commit 3b0a048fa9
3 changed files with 170 additions and 41 deletions

View File

@ -19,14 +19,11 @@ DEFINES += NO_PNG NO_QR
LIBS += -lpng
}
contains(DEFINES, NO_QR){
SOURCES += ../backend/no_qr.c
}else{
SOURCES += ../backend/qr.c
contains(DEFINES, QR_SYSTEM){
LIBS += -lqrencode
}else{
}
contains(DEFINES, QR){
INCLUDEPATH += qrencode
@ -48,8 +45,6 @@ SOURCES += qrencode/bitstream.c \
qrencode/split.c
}
}
HEADERS += ../backend/common.h \
../backend/composite.h \
../backend/dm200.h \
@ -84,6 +79,7 @@ SOURCES += ../backend/2of5.c \
../backend/rss.c \
../backend/telepen.c \
../backend/upcean.c \
../backend/qr.c \
barcoderender.cpp
VERSION = 1.6.0

View File

@ -13,7 +13,6 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include <QPainter>
#include "barcoderender.h"
@ -26,12 +25,13 @@ BareCode::BareCode()
m_height=50;
m_border=NO_BORDER;
m_boderWidth=0;
m_width=0;
m_securityLevel=-1;
m_pdf417CodeWords=928;
m_fgColor=Qt::black;
m_bgColor=Qt::white;
m_zintSymbol=0;
m_excode39SymbologyNumber=m_code39SymbologyNumber=m_msiSymbologyNumber=0;
m_error=0;
}
BareCode::~BareCode()
@ -53,7 +53,24 @@ void BareCode::encode()
m_zintSymbol->whitespace_width=0;
m_zintSymbol->border_width=0;
m_zintSymbol->option_1=m_securityLevel;
m_zintSymbol->option_2=m_width;
switch (m_symbol)
{
case BARCODE_MSI_PLESSEY:
m_zintSymbol->option_2=m_msiSymbologyNumber;
break;
case BARCODE_CODE39:
m_zintSymbol->option_2=m_code39SymbologyNumber;
break;
case BARCODE_EXCODE39:
m_zintSymbol->option_2=m_excode39SymbologyNumber;
break;
default:
m_zintSymbol->option_2=m_width;
break;
}
m_zintSymbol->option_3=m_pdf417CodeWords;
QByteArray bstr=m_text.toAscii();
QByteArray pstr=m_primaryMessage.left(99).toAscii();
@ -78,40 +95,42 @@ void BareCode::encode()
}
}
int BareCode::symbol()
{
return m_symbol;
}
void BareCode::setSymbol(int symbol)
{
m_symbol=symbol;
}
QString BareCode::text()
{
return m_text;
}
void BareCode::setText(const QString & text)
{
m_text=text;
}
QString BareCode::primaryMessage()
{
return m_primaryMessage;
}
void BareCode::setPrimaryMessage(const QString & primaryMessage)
{
m_primaryMessage=primaryMessage;
}
void BareCode::setHeight(int height)
{
m_height=height;
}
int BareCode::height()
{
encode();
return m_zintSymbol->height+(m_border==BOX)?m_boderWidth*2:0;
}
void BareCode::setBorder(BorderType border)
void BareCode::setHeight(int height)
{
m_border=border;
}
void BareCode::setBorderWidth(int boderWidth)
{
m_boderWidth=boderWidth;
m_height=height;
}
void BareCode::setWidth(int width)
@ -125,34 +144,85 @@ int BareCode::width()
return m_zintSymbol->width+(m_border!=NO_BORDER)?m_boderWidth*2:0;
}
void BareCode::setSecurityLevel(int securityLevel)
QColor BareCode::fgColor()
{
m_securityLevel=securityLevel;
return m_fgColor;
}
void BareCode::setPdf417CodeWords(int pdf417CodeWords)
{
m_pdf417CodeWords=pdf417CodeWords;
}
void BareCode::setFgColor(const QColor & fgColor)
{
m_fgColor=fgColor;
}
QColor BareCode::bgColor()
{
return m_bgColor;
}
void BareCode::setBgColor(const QColor & bgColor)
{
m_bgColor=bgColor;
}
const QString & BareCode::lastError()
BareCode::BorderType BareCode::borderType()
{
return m_lastError;
return m_border;
}
void BareCode::setBorderType(BorderType border)
{
m_border=border;
}
bool BareCode::hasErrors()
int BareCode::borderWidth()
{
return m_lastError.length();
return m_boderWidth;
}
void BareCode::setBorderWidth(int boderWidth)
{
m_boderWidth=boderWidth;
}
int BareCode::pdf417CodeWords()
{
return m_pdf417CodeWords;
}
void BareCode::setPdf417CodeWords(int pdf417CodeWords)
{
m_pdf417CodeWords=pdf417CodeWords;
}
int BareCode::securityLevel()
{
return m_securityLevel;
}
void BareCode::setSecurityLevel(int securityLevel)
{
m_securityLevel=securityLevel;
}
int BareCode::msiExtraSymbology()
{
return m_msiSymbologyNumber;
}
void BareCode::setMsiExtraSymbology(int msiSymbologyNumber)
{
m_msiSymbologyNumber=msiSymbologyNumber;
}
int BareCode::code39ExtraSymbology()
{
return m_code39SymbologyNumber;
}
void BareCode::setCode39ExtraSymbology(int m_code39SymbologyNumber)
{
m_code39SymbologyNumber=m_code39SymbologyNumber;
}
int BareCode::excode39ExtraSymbology()
{
return m_excode39SymbologyNumber;
}
void BareCode::setExcode39ExtraSymbology(int excode39SymbologyNumber)
{
m_excode39SymbologyNumber=excode39SymbologyNumber;
}
void BareCode::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode, qreal scaleFactor)
@ -327,5 +397,15 @@ void BareCode::render(QPainter & painter, const QRectF & paintRect, AspectRatioM
painter.restore();
}
const QString & BareCode::lastError()
{
return m_lastError;
}
bool BareCode::hasErrors()
{
return m_lastError.length();
}
}

View File

@ -16,8 +16,8 @@
#ifndef BARCODERENDER_H
#define BARCODERENDER_H
#include <QImage>
#include <QColor>
#include <QPainter>
#include "zint.h"
@ -25,7 +25,29 @@ namespace Zint
{
class BareCode
#ifndef NO_QT_KEYWORDS
: public QObject
#endif
{
#ifndef NO_QT_KEYWORDS
Q_OBJECT
Q_PROPERTY(int symbol READ symbol WRITE setSymbol)
Q_PROPERTY(QString text READ text WRITE setText)
Q_PROPERTY(QString primaryMessage READ primaryMessage WRITE setPrimaryMessage)
Q_PROPERTY(int height READ height WRITE setHeight)
Q_PROPERTY(int width READ width WRITE setWidth)
Q_PROPERTY(QColor fgColor READ fgColor WRITE setFgColor)
Q_PROPERTY(QColor bgColor READ bgColor WRITE setBgColor)
Q_PROPERTY(BorderType borderType READ borderType WRITE setBorderType)
Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth)
Q_PROPERTY(int pdf417CodeWords READ pdf417CodeWords WRITE setPdf417CodeWords)
Q_PROPERTY(int securityLevel READ securityLevel WRITE setSecurityLevel)
Q_PROPERTY(int msiExtraSymbology READ msiExtraSymbology WRITE setMsiExtraSymbology)
Q_PROPERTY(int code39ExtraSymbology READ code39ExtraSymbology WRITE setCode39ExtraSymbology)
Q_PROPERTY(int excode39ExtraSymbology READ excode39ExtraSymbology WRITE setExcode39ExtraSymbology)
Q_ENUMS(BorderType)
#endif
public:
enum BorderType{NO_BORDER=0, BIND=1, BOX=2};
@ -35,25 +57,52 @@ public:
BareCode();
~BareCode();
int symbol();
void setSymbol(int symbol);
QString text();
void setText(const QString & text);
QString primaryMessage();
void setPrimaryMessage(const QString & primaryMessage);
void setHeight(int height);
int height();
void setBorder(BorderType border);
void setBorderWidth(int boderWidth);
void setWidth(int width);
int width();
void setSecurityLevel(int securityLevel);
void setPdf417CodeWords(int pdf417CodeWords);
QColor fgColor();
void setFgColor(const QColor & fgColor);
QColor bgColor();
void setBgColor(const QColor & bgColor);
BorderType borderType();
void setBorderType(BorderType border);
int borderWidth();
void setBorderWidth(int boderWidth);
int pdf417CodeWords();
void setPdf417CodeWords(int pdf417CodeWords);
int securityLevel();
void setSecurityLevel(int securityLevel);
int msiExtraSymbology();
void setMsiExtraSymbology(int msiSymbologyNumber);
int code39ExtraSymbology();
void setCode39ExtraSymbology(int m_code39SymbologyNumber);
int excode39ExtraSymbology();
void setExcode39ExtraSymbology(int excode39SymbologyNumber);
void render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode=IgnoreAspectRatio, qreal scaleFactor=1);
const QString & lastError();
bool hasErrors();
private:
void encode();
@ -67,9 +116,13 @@ private:
int m_width;
int m_securityLevel;
int m_pdf417CodeWords;
int m_msiSymbologyNumber;
int m_code39SymbologyNumber;
int m_excode39SymbologyNumber;
QColor m_fgColor;
QColor m_bgColor;
QString m_lastError;
int m_error;
zint_symbol * m_zintSymbol;
};
}