mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 00:33:02 +03:00
commit
61672e3b7a
@ -91,6 +91,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
stringListModel->setStringList(simpleData);
|
||||
|
||||
report->dataManager()->addModel("string_list",stringListModel,true);
|
||||
QStringList strList;
|
||||
strList<<"value1"<<"value2";
|
||||
QScriptValue value = qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList);
|
||||
report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value);
|
||||
|
||||
|
||||
}
|
||||
@ -152,6 +156,9 @@ void MainWindow::renderFinished()
|
||||
void MainWindow::prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant &data)
|
||||
{
|
||||
switch (info.dataType) {
|
||||
case LimeReport::CallbackInfo::ColumnCount:
|
||||
data = ds->record().count();
|
||||
break;
|
||||
case LimeReport::CallbackInfo::IsEmpty:
|
||||
data = !ds->first();
|
||||
break;
|
||||
|
@ -4,7 +4,7 @@
|
||||
namespace LimeReport {
|
||||
|
||||
struct CallbackInfo{
|
||||
enum DataType{IsEmpty, HasNext, ColumnHeaderData, ColumnData};
|
||||
enum DataType{IsEmpty, HasNext, ColumnHeaderData, ColumnData, ColumnCount, RowCount};
|
||||
enum ChangePosType{First, Next};
|
||||
DataType dataType;
|
||||
int index;
|
||||
|
@ -48,7 +48,7 @@ namespace LimeReport{
|
||||
BarcodeItem::BarcodeItem(QObject* owner,QGraphicsItem* parent)
|
||||
: ContentItemDesignIntf(xmlTag,owner,parent),m_designTestValue("1"), m_barcodeType(CODE128),
|
||||
m_foregroundColor(Qt::black), m_backgroundColor(Qt::white), m_whitespace(10), m_angle(Angle0),
|
||||
m_barcodeWidth(0), m_securityLevel(0), m_pdf417CodeWords(928)
|
||||
m_barcodeWidth(0), m_securityLevel(0), m_pdf417CodeWords(928), m_inputMode(UNICODE_INPUT_MODE)
|
||||
{}
|
||||
|
||||
BarcodeItem::~BarcodeItem()
|
||||
@ -65,6 +65,7 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti
|
||||
Zint::QZint bc;
|
||||
if (itemMode() & DesignMode) bc.setText(m_designTestValue);
|
||||
else bc.setText(m_content);
|
||||
bc.setInputMode(m_inputMode);
|
||||
bc.setSymbol(m_barcodeType);
|
||||
bc.setWhitespace(m_whitespace);
|
||||
bc.setFgColor(m_foregroundColor);
|
||||
@ -231,6 +232,23 @@ void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords)
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeItem::InputMode BarcodeItem::inputMode() const
|
||||
{
|
||||
return m_inputMode;
|
||||
}
|
||||
|
||||
void BarcodeItem::setInputMode(const InputMode &inputMode)
|
||||
{
|
||||
if (m_inputMode != inputMode){
|
||||
InputMode oldValue = m_inputMode;
|
||||
m_inputMode = inputMode;
|
||||
if (!isLoading()){
|
||||
update();
|
||||
notify("inputMode",oldValue,inputMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
{
|
||||
switch(pass){
|
||||
|
@ -38,6 +38,7 @@ class BarcodeItem : public LimeReport::ContentItemDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_ENUMS(BarcodeType)
|
||||
Q_ENUMS(AngleType)
|
||||
Q_ENUMS(InputMode)
|
||||
Q_PROPERTY(QString content READ content WRITE setContent)
|
||||
Q_PROPERTY(BarcodeType barcodeType READ barcodeType WRITE setBarcodeType )
|
||||
Q_PROPERTY(QString testValue READ designTestValue WRITE setDesignTestValue)
|
||||
@ -48,6 +49,7 @@ class BarcodeItem : public LimeReport::ContentItemDesignIntf {
|
||||
Q_PROPERTY(int barcodeWidth READ barcodeWidth WRITE setBarcodeWidth)
|
||||
Q_PROPERTY(int securityLevel READ securityLevel WRITE setSecurityLevel)
|
||||
Q_PROPERTY(int pdf417CodeWords READ pdf417CodeWords WRITE setPdf417CodeWords)
|
||||
Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
|
||||
public:
|
||||
// enum BarcodeType {QRCODE=58,CODE128=20,DATAMATRIX=71,MAXICODE=57,MICROPDF417=84};
|
||||
// enum BarcodeType {CODE_11=1,C25MATRIX=2,QRCODE=58,CODE128=20,DATAMATRIX=71,MAXICODE=57,MICROPDF417=84,
|
||||
@ -128,6 +130,13 @@ public:
|
||||
|
||||
};
|
||||
enum AngleType{Angle0,Angle90,Angle180,Angle270};
|
||||
enum InputMode{
|
||||
DATA_INPUT_MODE = 0,
|
||||
UNICODE_INPUT_MODE = 1,
|
||||
GS1_INPUT_MODE = 2,
|
||||
KANJI_INPUT_MODE = 3,
|
||||
SJIS_INPUT_MODE = 4
|
||||
};
|
||||
BarcodeItem(QObject *owner, QGraphicsItem *parent);
|
||||
~BarcodeItem();
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
|
||||
@ -155,6 +164,9 @@ public:
|
||||
int pdf417CodeWords() const;
|
||||
void setPdf417CodeWords(int pdf417CodeWords);
|
||||
|
||||
InputMode inputMode() const;
|
||||
void setInputMode(const InputMode &inputMode);
|
||||
|
||||
private:
|
||||
Zint::QZint m_bc;
|
||||
QString m_content;
|
||||
@ -167,6 +179,7 @@ private:
|
||||
int m_barcodeWidth;
|
||||
int m_securityLevel;
|
||||
int m_pdf417CodeWords;
|
||||
InputMode m_inputMode;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
namespace LimeReport {
|
||||
|
||||
struct CallbackInfo{
|
||||
enum DataType{IsEmpty, HasNext, ColumnHeaderData, ColumnData};
|
||||
enum DataType{IsEmpty, HasNext, ColumnHeaderData, ColumnData, ColumnCount, RowCount};
|
||||
enum ChangePosType{First, Next};
|
||||
DataType dataType;
|
||||
int index;
|
||||
|
@ -594,8 +594,17 @@ bool CallbackDatasource::next(){
|
||||
m_currentRow++;
|
||||
bool result = false;
|
||||
emit changePos(CallbackInfo::Next,result);
|
||||
m_eof = !result; // !checkNextRecord(m_currentRow);
|
||||
return result;
|
||||
if (m_rowCount != -1){
|
||||
if (m_rowCount>0 && m_currentRow<m_rowCount){
|
||||
m_eof = false;
|
||||
} else {
|
||||
m_eof = true;
|
||||
}
|
||||
return !m_eof;
|
||||
} else {
|
||||
m_eof = !result;
|
||||
return result;
|
||||
}
|
||||
} else return false;
|
||||
}
|
||||
|
||||
@ -603,8 +612,16 @@ void CallbackDatasource::first(){
|
||||
m_currentRow = 0;
|
||||
m_eof=checkIfEmpty();
|
||||
bool result=false;
|
||||
if (m_rowCount == -1){
|
||||
QVariant rowCount;
|
||||
CallbackInfo info;
|
||||
info.dataType = CallbackInfo::RowCount;
|
||||
emit getCallbackData(info,rowCount);
|
||||
if (rowCount.isValid()) m_rowCount = rowCount.toInt();
|
||||
}
|
||||
emit changePos(CallbackInfo::First,result);
|
||||
m_eof = !result;
|
||||
if (m_rowCount>0) m_eof = false;
|
||||
else m_eof = !result;
|
||||
}
|
||||
|
||||
QVariant CallbackDatasource::data(const QString& columnName)
|
||||
@ -619,21 +636,40 @@ QVariant CallbackDatasource::data(const QString& columnName)
|
||||
}
|
||||
|
||||
int CallbackDatasource::columnCount(){
|
||||
if (m_headers.size()==0){
|
||||
int currIndex = 0;
|
||||
do {
|
||||
QVariant columnName;
|
||||
CallbackInfo info;
|
||||
info.dataType = CallbackInfo::ColumnHeaderData;
|
||||
info.index = currIndex;
|
||||
emit getCallbackData(info,columnName);
|
||||
if (columnName.isValid()){
|
||||
m_headers.append(columnName.toString());
|
||||
currIndex++;
|
||||
} else break;
|
||||
} while (true);
|
||||
CallbackInfo info;
|
||||
if (m_columnCount == -1){
|
||||
QVariant columnCount;
|
||||
info.dataType = CallbackInfo::ColumnCount;
|
||||
emit getCallbackData(info,columnCount);
|
||||
if (columnCount.isValid()){
|
||||
m_columnCount = columnCount.toInt();
|
||||
}
|
||||
if (m_columnCount != -1){
|
||||
for(int i=0;i<m_columnCount;++i) {
|
||||
QVariant columnName;
|
||||
info.dataType = CallbackInfo::ColumnHeaderData;
|
||||
info.index = i;
|
||||
emit getCallbackData(info,columnName);
|
||||
if (columnName.isValid())
|
||||
m_headers.append(columnName.toString());
|
||||
}
|
||||
} else {
|
||||
int currIndex = 0;
|
||||
do {
|
||||
QVariant columnName;
|
||||
CallbackInfo info;
|
||||
info.dataType = CallbackInfo::ColumnHeaderData;
|
||||
info.index = currIndex;
|
||||
emit getCallbackData(info,columnName);
|
||||
if (columnName.isValid()){
|
||||
m_headers.append(columnName.toString());
|
||||
currIndex++;
|
||||
} else break;
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
return m_headers.size();
|
||||
if (m_headers.size()>0) m_columnCount = m_headers.size();
|
||||
return m_columnCount;
|
||||
}
|
||||
|
||||
QString CallbackDatasource::columnNameByIndex(int columnIndex)
|
||||
@ -658,4 +694,29 @@ int CallbackDatasource::columnIndexByName(QString name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CallbackDatasource::checkNextRecord(int recordNum){
|
||||
if (m_rowCount>0 && m_currentRow<m_rowCount){
|
||||
return true;
|
||||
} else {
|
||||
QVariant result = false;
|
||||
CallbackInfo info;
|
||||
info.dataType = CallbackInfo::HasNext;
|
||||
info.index = recordNum;
|
||||
emit getCallbackData(info,result);
|
||||
return result.toBool();
|
||||
}
|
||||
}
|
||||
|
||||
bool CallbackDatasource::checkIfEmpty(){
|
||||
if (m_rowCount == 0) {
|
||||
return true;
|
||||
} else {
|
||||
QVariant result = true;
|
||||
CallbackInfo info;
|
||||
info.dataType = CallbackInfo::IsEmpty;
|
||||
emit getCallbackData(info,result);
|
||||
return result.toBool();
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
|
@ -366,7 +366,7 @@ private:
|
||||
class CallbackDatasource :public ICallbackDatasource, public IDataSource {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CallbackDatasource(): m_currentRow(-1), m_eof(false){}
|
||||
CallbackDatasource(): m_currentRow(-1), m_eof(false), m_columnCount(-1), m_rowCount(-1){}
|
||||
bool next();
|
||||
bool hasNext(){ if (!m_eof) return checkNextRecord(m_currentRow); else return false;}
|
||||
bool prior(){ if (m_currentRow !=-1) {m_currentRow--; return true;} else return false;}
|
||||
@ -382,26 +382,14 @@ public:
|
||||
QString lastError(){ return "";}
|
||||
QAbstractItemModel *model(){return 0;}
|
||||
private:
|
||||
bool checkNextRecord(int recordNum){
|
||||
QVariant result = false;
|
||||
CallbackInfo info;
|
||||
info.dataType = CallbackInfo::HasNext;
|
||||
info.index = recordNum;
|
||||
emit getCallbackData(info,result);
|
||||
return result.toBool();
|
||||
}
|
||||
bool checkIfEmpty(){
|
||||
QVariant result = true;
|
||||
CallbackInfo info;
|
||||
info.dataType = CallbackInfo::IsEmpty;
|
||||
emit getCallbackData(info,result);
|
||||
//emit getIsEmpty(result);
|
||||
return result.toBool();
|
||||
}
|
||||
bool checkNextRecord(int recordNum);
|
||||
bool checkIfEmpty();
|
||||
private:
|
||||
QVector<QString> m_headers;
|
||||
int m_currentRow;
|
||||
bool m_eof;
|
||||
int m_columnCount;
|
||||
int m_rowCount;
|
||||
};
|
||||
|
||||
class CallbackDatasourceHolder :public QObject, public IDataSourceHolder{
|
||||
|
@ -552,7 +552,7 @@ void ReportRender::popPageFooterGroupValues(BandDesignIntf *dataBand)
|
||||
// FIXME Probably coincidence Field and Variables
|
||||
if ((!m_popupedExpression.contains(dataBand))||(!m_popupedExpression.values(dataBand).contains(gf->data()))){
|
||||
m_popupedExpression.insert(dataBand,gf->data());
|
||||
m_popupedValues.insert(QString::number((long)dataBand,16)+'|'+gf->data(), gf->values()[gf->values().count()-1]);
|
||||
m_popupedValues.insert(QString("%1").arg((quintptr)dataBand)+'|'+gf->data(), gf->values()[gf->values().count()-1]);
|
||||
gf->values().pop_back();
|
||||
}
|
||||
}
|
||||
@ -568,7 +568,7 @@ void ReportRender::pushPageFooterGroupValues(BandDesignIntf *dataBand)
|
||||
if ((gf->dataBandName()==dataBand->objectName())){
|
||||
// FIXME Probably coincidence Field and Variables
|
||||
if ((m_popupedExpression.contains(dataBand))&&(m_popupedExpression.values(dataBand).contains(gf->data()))){
|
||||
gf->values().push_back(m_popupedValues.value(QString::number((long)dataBand,16)+'|'+gf->data()));
|
||||
gf->values().push_back(m_popupedValues.value(QString("%1").arg((quintptr)dataBand)+'|'+gf->data()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -743,7 +743,7 @@ BandDesignIntf* ReportRender::sliceBand(BandDesignIntf *band, BandDesignIntf* pa
|
||||
}
|
||||
}
|
||||
if (registerBand(band)) break;
|
||||
}
|
||||
} else break;
|
||||
}
|
||||
|
||||
if (band->isEmpty()) {
|
||||
@ -923,7 +923,8 @@ void ReportRender::checkLostHeadersOnPrevPage()
|
||||
it.toBack();
|
||||
if (it.hasPrevious())
|
||||
if (it.previous()->isFooter())
|
||||
it.previous();
|
||||
if (it.hasPrevious()) it.previous();
|
||||
else return;
|
||||
|
||||
while (it.hasPrevious()){
|
||||
if (it.value()->isHeader()){
|
||||
|
Loading…
Reference in New Issue
Block a user