mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-25 04:54:40 +03:00
Render empty data band has been fixed
This commit is contained in:
parent
2cb5f8e71c
commit
32bf7765ec
@ -101,7 +101,7 @@ public:
|
|||||||
|
|
||||||
bool canBeSplitted(int height) const;
|
bool canBeSplitted(int height) const;
|
||||||
bool isSplittable() const { return true;}
|
bool isSplittable() const { return true;}
|
||||||
bool isEmpty() const{return m_text->isEmpty();}
|
bool isEmpty() const{return m_strText.trimmed().isEmpty() /*m_text->isEmpty()*/;}
|
||||||
BaseDesignIntf* cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent);
|
BaseDesignIntf* cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent);
|
||||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent);
|
BaseDesignIntf* cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent);
|
||||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||||
|
@ -227,7 +227,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
|
|||||||
clearPageMap();
|
clearPageMap();
|
||||||
startNewPage();
|
startNewPage();
|
||||||
|
|
||||||
renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader),StartNewPageAsNeeded);
|
renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader), 0, StartNewPageAsNeeded);
|
||||||
|
|
||||||
BandDesignIntf* lastRenderedBand = 0;
|
BandDesignIntf* lastRenderedBand = 0;
|
||||||
for (int i=0;i<m_patternPageItem->dataBandCount() && !m_renderCanceled;i++){
|
for (int i=0;i<m_patternPageItem->dataBandCount() && !m_renderCanceled;i++){
|
||||||
@ -238,13 +238,13 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reportFooter)
|
if (reportFooter)
|
||||||
renderBand(reportFooter,StartNewPageAsNeeded);
|
renderBand(reportFooter, 0, StartNewPageAsNeeded);
|
||||||
if (lastRenderedBand && lastRenderedBand->keepFooterTogether())
|
if (lastRenderedBand && lastRenderedBand->keepFooterTogether())
|
||||||
closeFooterGroup(lastRenderedBand);
|
closeFooterGroup(lastRenderedBand);
|
||||||
|
|
||||||
BandDesignIntf* tearOffBand = m_patternPageItem->bandByType(BandDesignIntf::TearOffBand);
|
BandDesignIntf* tearOffBand = m_patternPageItem->bandByType(BandDesignIntf::TearOffBand);
|
||||||
if (tearOffBand)
|
if (tearOffBand)
|
||||||
renderBand(tearOffBand,StartNewPageAsNeeded);
|
renderBand(tearOffBand, 0, StartNewPageAsNeeded);
|
||||||
|
|
||||||
savePage(true);
|
savePage(true);
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ void ReportRender::replaceGroupsFunction(BandDesignIntf *band)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportRender::renderBand(BandDesignIntf *patternBand, ReportRender::DataRenderMode mode, bool isLast)
|
BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesignIntf* bandData, ReportRender::DataRenderMode mode, bool isLast)
|
||||||
{
|
{
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
if (patternBand){
|
if (patternBand){
|
||||||
@ -372,7 +372,14 @@ void ReportRender::renderBand(BandDesignIntf *patternBand, ReportRender::DataRen
|
|||||||
if (patternBand->isFooter())
|
if (patternBand->isFooter())
|
||||||
m_lastRenderedFooter = patternBand;
|
m_lastRenderedFooter = patternBand;
|
||||||
|
|
||||||
BandDesignIntf* bandClone=renderData(patternBand);
|
BandDesignIntf* bandClone = 0;
|
||||||
|
|
||||||
|
if (bandData){
|
||||||
|
bandClone = bandData;
|
||||||
|
} else {
|
||||||
|
bandClone=renderData(patternBand);
|
||||||
|
}
|
||||||
|
|
||||||
bandClone->setBackgroundColor(
|
bandClone->setBackgroundColor(
|
||||||
(datasources()->variable(QLatin1String("line_")+patternBand->objectName().toLower()).toInt()%2!=0 ?
|
(datasources()->variable(QLatin1String("line_")+patternBand->objectName().toLower()).toInt()%2!=0 ?
|
||||||
patternBand->backgroundColor():
|
patternBand->backgroundColor():
|
||||||
@ -424,10 +431,16 @@ void ReportRender::renderBand(BandDesignIntf *patternBand, ReportRender::DataRen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {delete bandClone;}
|
} else {
|
||||||
|
delete bandClone;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (patternBand->isFooter())
|
if (patternBand->isFooter())
|
||||||
datasources()->clearGroupFunctionValues(patternBand->objectName());
|
datasources()->clearGroupFunctionValues(patternBand->objectName());
|
||||||
|
return bandClone;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportRender::renderDataBand(BandDesignIntf *dataBand)
|
void ReportRender::renderDataBand(BandDesignIntf *dataBand)
|
||||||
@ -440,7 +453,7 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
|
|||||||
BandDesignIntf* header = dataBand->bandHeader();
|
BandDesignIntf* header = dataBand->bandHeader();
|
||||||
BandDesignIntf* footer = dataBand->bandFooter();
|
BandDesignIntf* footer = dataBand->bandFooter();
|
||||||
|
|
||||||
if (header && header->printAlways()) renderBand(header);
|
if (header && header->printAlways()) renderBand(header, 0);
|
||||||
|
|
||||||
if(bandDatasource && !bandDatasource->eof() && !m_renderCanceled){
|
if(bandDatasource && !bandDatasource->eof() && !m_renderCanceled){
|
||||||
|
|
||||||
@ -448,7 +461,7 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
|
|||||||
datasources()->setReportVariable(varName,1);
|
datasources()->setReportVariable(varName,1);
|
||||||
|
|
||||||
if (header && !header->printAlways())
|
if (header && !header->printAlways())
|
||||||
renderBand(header);
|
renderBand(header, 0);
|
||||||
|
|
||||||
if (dataBand->bandHeader() && dataBand->bandHeader()->reprintOnEachPage())
|
if (dataBand->bandHeader() && dataBand->bandHeader()->reprintOnEachPage())
|
||||||
m_reprintableBands.append(dataBand->bandHeader());
|
m_reprintableBands.append(dataBand->bandHeader());
|
||||||
@ -458,8 +471,13 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
|
|||||||
|
|
||||||
bool firstTime = true;
|
bool firstTime = true;
|
||||||
|
|
||||||
|
|
||||||
while(!bandDatasource->eof() && !m_renderCanceled){
|
while(!bandDatasource->eof() && !m_renderCanceled){
|
||||||
|
|
||||||
|
BandDesignIntf* rawData = renderData(dataBand);
|
||||||
|
|
||||||
|
if (!rawData->isEmpty() || dataBand->printIfEmpty()){
|
||||||
|
|
||||||
if ((firstTime && dataBand->startFromNewPage()) ||
|
if ((firstTime && dataBand->startFromNewPage()) ||
|
||||||
(!firstTime && dataBand->startNewPage())) {
|
(!firstTime && dataBand->startNewPage())) {
|
||||||
savePage();
|
savePage();
|
||||||
@ -475,11 +493,13 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
|
|||||||
m_lastDataBand = dataBand;
|
m_lastDataBand = dataBand;
|
||||||
|
|
||||||
if (header && !firstTime && header->repeatOnEachRow())
|
if (header && !firstTime && header->repeatOnEachRow())
|
||||||
renderBand(header,StartNewPageAsNeeded);
|
renderBand(header, 0, StartNewPageAsNeeded);
|
||||||
|
|
||||||
renderBand(dataBand,StartNewPageAsNeeded,!bandDatasource->hasNext());
|
if (renderBand(dataBand, rawData, StartNewPageAsNeeded, !bandDatasource->hasNext()) )
|
||||||
renderChildBands(dataBand);
|
renderChildBands(dataBand);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bandDatasource->next();
|
bandDatasource->next();
|
||||||
|
|
||||||
datasources()->setReportVariable(varName,datasources()->variable(varName).toInt()+1);
|
datasources()->setReportVariable(varName,datasources()->variable(varName).toInt()+1);
|
||||||
@ -499,16 +519,16 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
|
|||||||
renderGroupFooter(dataBand);
|
renderGroupFooter(dataBand);
|
||||||
|
|
||||||
if (footer && !footer->printAlways())
|
if (footer && !footer->printAlways())
|
||||||
renderBand(footer,StartNewPageAsNeeded);
|
renderBand(footer, 0, StartNewPageAsNeeded);
|
||||||
|
|
||||||
datasources()->deleteVariable(varName);
|
datasources()->deleteVariable(varName);
|
||||||
|
|
||||||
} else if (bandDatasource==0) {
|
} else if (bandDatasource==0) {
|
||||||
renderBand(dataBand,StartNewPageAsNeeded);
|
renderBand(dataBand, 0, StartNewPageAsNeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (footer && footer->printAlways())
|
if (footer && footer->printAlways())
|
||||||
renderBand(footer,StartNewPageAsNeeded);
|
renderBand(footer, 0, StartNewPageAsNeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportRender::renderPageHeader(PageItemDesignIntf *patternPage)
|
void ReportRender::renderPageHeader(PageItemDesignIntf *patternPage)
|
||||||
@ -518,7 +538,7 @@ void ReportRender::renderPageHeader(PageItemDesignIntf *patternPage)
|
|||||||
if (m_datasources->variable("#PAGE").toInt()!=1 ||
|
if (m_datasources->variable("#PAGE").toInt()!=1 ||
|
||||||
band->property("printOnFirstPage").toBool()
|
band->property("printOnFirstPage").toBool()
|
||||||
)
|
)
|
||||||
renderBand(band);
|
renderBand(band, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +596,7 @@ void ReportRender::renderChildHeader(BandDesignIntf *parent, BandPrintMode print
|
|||||||
if (band->metaObject()->indexOfProperty("printAlways")>0){
|
if (band->metaObject()->indexOfProperty("printAlways")>0){
|
||||||
printAlways=band->property("printAlways").toBool();
|
printAlways=band->property("printAlways").toBool();
|
||||||
}
|
}
|
||||||
if (printAlways == (printMode==PrintAlwaysPrintable) ) renderBand(band,StartNewPageAsNeeded);
|
if (printAlways == (printMode==PrintAlwaysPrintable) ) renderBand(band, 0, StartNewPageAsNeeded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,7 +609,7 @@ void ReportRender::renderChildFooter(BandDesignIntf *parent, BandPrintMode print
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( (band != m_lastRenderedFooter) && (printAlways == (printMode == PrintAlwaysPrintable)) )
|
if ( (band != m_lastRenderedFooter) && (printAlways == (printMode == PrintAlwaysPrintable)) )
|
||||||
renderBand(band,StartNewPageAsNeeded);
|
renderBand(band, 0, StartNewPageAsNeeded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,13 +634,13 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
|
|||||||
dataSource->prior();
|
dataSource->prior();
|
||||||
foreach (BandDesignIntf* subBand, band->childrenByType(BandDesignIntf::GroupHeader)) {
|
foreach (BandDesignIntf* subBand, band->childrenByType(BandDesignIntf::GroupHeader)) {
|
||||||
foreach(BandDesignIntf* footer, subBand->childrenByType(BandDesignIntf::GroupFooter)){
|
foreach(BandDesignIntf* footer, subBand->childrenByType(BandDesignIntf::GroupFooter)){
|
||||||
renderBand(footer);
|
renderBand(footer, 0);
|
||||||
closeDataGroup(subBand);
|
closeDataGroup(subBand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (BandDesignIntf* footer, band->childrenByType(BandDesignIntf::GroupFooter)) {
|
foreach (BandDesignIntf* footer, band->childrenByType(BandDesignIntf::GroupFooter)) {
|
||||||
renderBand(footer,StartNewPageAsNeeded);
|
renderBand(footer, 0, StartNewPageAsNeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSource->next();
|
dataSource->next();
|
||||||
@ -639,9 +659,9 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
|
|||||||
openDataGroup(band);
|
openDataGroup(band);
|
||||||
if (!firstTime && gb->startNewPage()){
|
if (!firstTime && gb->startNewPage()){
|
||||||
if (gb->resetPageNumber()) resetPageNumber(BandReset);
|
if (gb->resetPageNumber()) resetPageNumber(BandReset);
|
||||||
renderBand(band,ForcedStartPage);
|
renderBand(band, 0, ForcedStartPage);
|
||||||
} else {
|
} else {
|
||||||
renderBand(band,StartNewPageAsNeeded);
|
renderBand(band, 0, StartNewPageAsNeeded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,7 +676,7 @@ void ReportRender::renderGroupFooter(BandDesignIntf *parentBand)
|
|||||||
if (gb && gb->isStarted()){
|
if (gb && gb->isStarted()){
|
||||||
if (band->reprintOnEachPage()) m_reprintableBands.removeOne(band);
|
if (band->reprintOnEachPage()) m_reprintableBands.removeOne(band);
|
||||||
if (band->childBands().count()>0){
|
if (band->childBands().count()>0){
|
||||||
renderBand(band->childBands().at(0),StartNewPageAsNeeded);
|
renderBand(band->childBands().at(0), 0, StartNewPageAsNeeded);
|
||||||
}
|
}
|
||||||
closeDataGroup(band);
|
closeDataGroup(band);
|
||||||
}
|
}
|
||||||
@ -970,7 +990,7 @@ void ReportRender::startNewPage()
|
|||||||
m_currentIndex=0;
|
m_currentIndex=0;
|
||||||
|
|
||||||
renderPageHeader(m_patternPageItem);
|
renderPageHeader(m_patternPageItem);
|
||||||
//renderPageFooter(m_patternPageItem);
|
|
||||||
m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem);
|
m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem);
|
||||||
m_maxHeightByColumn[m_currentColumn] -= m_pageFooterHeight;
|
m_maxHeightByColumn[m_currentColumn] -= m_pageFooterHeight;
|
||||||
m_currentIndex=10;
|
m_currentIndex=10;
|
||||||
@ -978,8 +998,9 @@ void ReportRender::startNewPage()
|
|||||||
m_renderedDataBandCount = 0;
|
m_renderedDataBandCount = 0;
|
||||||
|
|
||||||
foreach (BandDesignIntf* band, m_reprintableBands) {
|
foreach (BandDesignIntf* band, m_reprintableBands) {
|
||||||
renderBand(band);
|
renderBand(band, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkLostHeadersOnPrevPage();
|
checkLostHeadersOnPrevPage();
|
||||||
pasteGroups();
|
pasteGroups();
|
||||||
renderPageItems(m_patternPageItem);
|
renderPageItems(m_patternPageItem);
|
||||||
|
@ -96,7 +96,7 @@ private:
|
|||||||
void initVariables();
|
void initVariables();
|
||||||
bool runInitScript();
|
bool runInitScript();
|
||||||
void clearPageMap();
|
void clearPageMap();
|
||||||
void renderBand(BandDesignIntf *patternBand, DataRenderMode mode = NotStartNewPage, bool isLast = false);
|
BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false);
|
||||||
void renderDataBand(BandDesignIntf* dataBand);
|
void renderDataBand(BandDesignIntf* dataBand);
|
||||||
void renderPageHeader(PageItemDesignIntf* patternPage);
|
void renderPageHeader(PageItemDesignIntf* patternPage);
|
||||||
void renderPageFooter(PageItemDesignIntf* patternPage);
|
void renderPageFooter(PageItemDesignIntf* patternPage);
|
||||||
|
Loading…
Reference in New Issue
Block a user