0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 08:34:38 +03:00

Merge pull request #187 from AndrzejWoronko/aw

Adding barcode field from the data source
This commit is contained in:
fralx 2019-05-11 10:01:29 +03:00 committed by GitHub
commit b768285cd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 1 deletions

View File

@ -115,6 +115,36 @@ void BarcodeItem::setContent(const QString &content)
}
}
QString BarcodeItem::datasource() const
{
return m_datasource;
}
void BarcodeItem::setDatasource(const QString &datasource)
{
if (m_datasource != datasource){
QString oldValue = m_datasource;
m_datasource = datasource;
update();
notify("datasource", oldValue, datasource);
}
}
QString BarcodeItem::field() const
{
return m_field;
}
void BarcodeItem::setField(const QString &field)
{
if (m_field != field){
QString oldValue = m_field;
m_field = field;
update();
notify("field", oldValue, field);
}
}
void BarcodeItem::setBarcodeType(BarcodeItem::BarcodeType value)
{
if (m_barcodeType!=value){
@ -268,13 +298,39 @@ void BarcodeItem::setHideText(bool hideText)
void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{
switch(pass){
if (content().isEmpty())
{
if (!m_datasource.isEmpty() && !m_field.isEmpty())
{
IDataSource* ds = dataManager->dataSource(m_datasource);
if (ds)
{
QVariant data = ds->data(m_field);
if (data.isValid())
{
switch(pass)
{
case FirstPass:
setContent(expandUserVariables(data.toString(),pass,NoEscapeSymbols, dataManager));
setContent(expandDataFields(data.toString(), NoEscapeSymbols, dataManager));
break;
default:;
}
}
}
}
}
else
{
switch(pass)
{
case FirstPass:
setContent(expandUserVariables(content(),pass,NoEscapeSymbols, dataManager));
setContent(expandDataFields(content(), NoEscapeSymbols, dataManager));
break;
default:;
}
}
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}

View File

@ -41,6 +41,8 @@ class BarcodeItem : public LimeReport::ContentItemDesignIntf {
Q_ENUMS(InputMode)
Q_PROPERTY(QString content READ content WRITE setContent)
Q_PROPERTY(BarcodeType barcodeType READ barcodeType WRITE setBarcodeType )
Q_PROPERTY(QString datasource READ datasource WRITE setDatasource)
Q_PROPERTY(QString field READ field WRITE setField)
Q_PROPERTY(QString testValue READ designTestValue WRITE setDesignTestValue)
Q_PROPERTY(QColor foregroundColor READ foregroundColor WRITE setForegroundColor)
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
@ -148,6 +150,10 @@ public:
QString content() const {return m_content;}
void setBarcodeType(BarcodeType value);
BarcodeType barcodeType(){return m_barcodeType;}
QString datasource() const;
void setDatasource(const QString &datasource);
QString field() const;
void setField(const QString &field);
void setDesignTestValue(QString value);
QString designTestValue(){return m_designTestValue;}
QColor foregroundColor(){return m_foregroundColor;}
@ -174,6 +180,8 @@ public:
private:
Zint::QZint m_bc;
QString m_content;
QString m_datasource;
QString m_field;
QString m_designTestValue;
BarcodeType m_barcodeType;
QColor m_foregroundColor;

View File

@ -54,6 +54,12 @@ namespace{
bool VARIABLE_IS_NOT_USED registredImageFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("field","LimeReport::ImageItem"),QObject::tr("field"),createFieldPropItem
);
bool VARIABLE_IS_NOT_USED registredBarcodeDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("datasource","LimeReport::BarcodeItem"),QObject::tr("datasource"),createDatasourcePropItem
);
bool VARIABLE_IS_NOT_USED registredBarcodeFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("field","LimeReport::BarcodeItem"),QObject::tr("field"),createFieldPropItem
);
}
QWidget* LimeReport::DatasourcePropItem::createProperyEditor(QWidget *parent) const{