mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-25 00:54:39 +03:00
Multicolumn bands rendering has been fixed
This commit is contained in:
commit
5a199a2e82
@ -880,8 +880,10 @@ void BandDesignIntf::setPrintIfEmpty(bool printIfEmpty)
|
|||||||
BandDesignIntf *BandDesignIntf::bandHeader()
|
BandDesignIntf *BandDesignIntf::bandHeader()
|
||||||
{
|
{
|
||||||
foreach (BandDesignIntf* band, childBands()) {
|
foreach (BandDesignIntf* band, childBands()) {
|
||||||
if (band->isHeader() && !band->isGroupHeader())
|
if (band->isHeader() && !band->isGroupHeader()){
|
||||||
|
if (band->columnsCount() > 1) band->setColumnsFillDirection(this->columnsFillDirection());
|
||||||
return band;
|
return band;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ void ReportRender::initColumns(){
|
|||||||
m_currentStartDataPos.clear();
|
m_currentStartDataPos.clear();
|
||||||
m_maxHeightByColumn.append(0);
|
m_maxHeightByColumn.append(0);
|
||||||
m_currentStartDataPos.append(0);
|
m_currentStartDataPos.append(0);
|
||||||
|
m_currentColumn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReportRender::isNeedToRearrangeColumnsItems()
|
bool ReportRender::isNeedToRearrangeColumnsItems()
|
||||||
@ -142,7 +143,7 @@ qreal ReportRender::maxColumnHeight()
|
|||||||
void ReportRender::renameChildItems(BaseDesignIntf *item){
|
void ReportRender::renameChildItems(BaseDesignIntf *item){
|
||||||
foreach(BaseDesignIntf* child, item->childBaseItems()){
|
foreach(BaseDesignIntf* child, item->childBaseItems()){
|
||||||
if (!child->childBaseItems().isEmpty()) renameChildItems(child);
|
if (!child->childBaseItems().isEmpty()) renameChildItems(child);
|
||||||
child->setObjectName(child->metaObject()->className()+QString::number(++m_curentNameIndex));
|
child->setObjectName(child->metaObject()->className()+QString::number(++m_currentNameIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +208,7 @@ void ReportRender::initDatasource(const QString& name){
|
|||||||
|
|
||||||
void ReportRender::renderPage(PageDesignIntf* patternPage)
|
void ReportRender::renderPage(PageDesignIntf* patternPage)
|
||||||
{
|
{
|
||||||
m_curentNameIndex = 0;
|
m_currentNameIndex = 0;
|
||||||
m_patternPageItem = patternPage->pageItem();
|
m_patternPageItem = patternPage->pageItem();
|
||||||
|
|
||||||
|
|
||||||
@ -250,11 +251,11 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
|
|||||||
renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader), 0, 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++){
|
||||||
lastRenderedBand = m_patternPageItem->dataBandAt(i);
|
lastRenderedBand = m_patternPageItem->dataBandAt(i);
|
||||||
initDatasource(lastRenderedBand->datasourceName());
|
initDatasource(lastRenderedBand->datasourceName());
|
||||||
renderDataBand(lastRenderedBand);
|
renderDataBand(lastRenderedBand);
|
||||||
if (i<m_patternPageItem->dataBandCount()-1) closeFooterGroup(lastRenderedBand);
|
if ( i < m_patternPageItem->dataBandCount()-1) closeFooterGroup(lastRenderedBand);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reportFooter)
|
if (reportFooter)
|
||||||
@ -515,7 +516,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, 0);
|
if (header && header->printAlways()) renderBand(header, 0, StartNewPageAsNeeded);
|
||||||
|
|
||||||
if(bandDatasource && !bandDatasource->eof() && !m_renderCanceled){
|
if(bandDatasource && !bandDatasource->eof() && !m_renderCanceled){
|
||||||
|
|
||||||
@ -523,12 +524,11 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
|
|||||||
datasources()->setReportVariable(varName,1);
|
datasources()->setReportVariable(varName,1);
|
||||||
|
|
||||||
if (header && !header->printAlways())
|
if (header && !header->printAlways())
|
||||||
renderBand(header, 0);
|
renderBand(header, 0, StartNewPageAsNeeded);
|
||||||
|
|
||||||
if (dataBand->bandHeader() && dataBand->bandHeader()->reprintOnEachPage())
|
if (dataBand->bandHeader() && dataBand->bandHeader()->reprintOnEachPage())
|
||||||
m_reprintableBands.append(dataBand->bandHeader());
|
m_reprintableBands.append(dataBand->bandHeader());
|
||||||
|
|
||||||
//renderChildHeader(dataBand,PrintNotAlwaysPrintable);
|
|
||||||
renderGroupHeader(dataBand, bandDatasource, true);
|
renderGroupHeader(dataBand, bandDatasource, true);
|
||||||
|
|
||||||
bool firstTime = true;
|
bool firstTime = true;
|
||||||
@ -634,7 +634,6 @@ void ReportRender::renderPageItems(PageItemDesignIntf* patternPage)
|
|||||||
m_renderPageItem,
|
m_renderPageItem,
|
||||||
m_renderPageItem);
|
m_renderPageItem);
|
||||||
pageItems.append(cloneItem);
|
pageItems.append(cloneItem);
|
||||||
//cloneItem->updateItemSize(m_datasources);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_renderPageItem->restoreLinks();
|
m_renderPageItem->restoreLinks();
|
||||||
@ -691,9 +690,7 @@ void ReportRender::renderChildBands(BandDesignIntf *parentBand)
|
|||||||
if (!band->datasourceName().isEmpty())
|
if (!band->datasourceName().isEmpty())
|
||||||
ds = m_datasources->dataSource(band->datasourceName());
|
ds = m_datasources->dataSource(band->datasourceName());
|
||||||
if (ds) ds->first();
|
if (ds) ds->first();
|
||||||
//renderChildHeader(band,PrintAlwaysPrintable);
|
|
||||||
renderDataBand(band);
|
renderDataBand(band);
|
||||||
//renderChildFooter(band,PrintAlwaysPrintable);
|
|
||||||
closeFooterGroup(band);
|
closeFooterGroup(band);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,7 +704,7 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
|
|||||||
bool didGoBack = dataSource->prior();
|
bool didGoBack = 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, 0);
|
renderBand(footer, 0, StartNewPageAsNeeded);
|
||||||
}
|
}
|
||||||
closeDataGroup(subBand);
|
closeDataGroup(subBand);
|
||||||
}
|
}
|
||||||
@ -721,10 +718,6 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
closeDataGroup(band);
|
closeDataGroup(band);
|
||||||
// if (gb->isNeedToStartNewPage()){
|
|
||||||
// savePage();
|
|
||||||
// startNewPage();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gb && !gb->isStarted()){
|
if (gb && !gb->isStarted()){
|
||||||
@ -887,10 +880,31 @@ qreal minVectorValue(QVector<qreal> vector){
|
|||||||
return curValue;
|
return curValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReportRender::placeBandOnPage(BandDesignIntf* band, int columnIndex){
|
||||||
|
|
||||||
|
qreal bandPos = m_currentStartDataPos[columnIndex];
|
||||||
|
|
||||||
|
m_currentStartDataPos[columnIndex] += band->height();
|
||||||
|
m_maxHeightByColumn[columnIndex] -= band->height();
|
||||||
|
band->setPos(m_renderPageItem->pageRect().x()+band->width()*columnIndex, bandPos);
|
||||||
|
band->setBandIndex(++m_currentIndex);
|
||||||
|
band->setColumnIndex(columnIndex);
|
||||||
|
|
||||||
|
m_renderPageItem->registerBand(band);
|
||||||
|
m_currentColumn = columnIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMultiColumnHeader(BandDesignIntf* band){
|
||||||
|
return ( (band->columnsCount() > 1 ) &&
|
||||||
|
(band->isHeader() &&
|
||||||
|
((band->bandNestingLevel() == 0) || (band->columnsFillDirection() == BandDesignIntf::Horizontal))));
|
||||||
|
}
|
||||||
|
|
||||||
bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren)
|
bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren)
|
||||||
{
|
{
|
||||||
if (band->columnsCount()==1 && m_maxHeightByColumn.size()>1){
|
|
||||||
if (band->bandType()!=BandDesignIntf::PageFooter){
|
if (band->columnsCount() == 1 && m_maxHeightByColumn.size() > 1 ){
|
||||||
|
if (band->bandType() != BandDesignIntf::PageFooter){
|
||||||
rearrangeColumnsItems();
|
rearrangeColumnsItems();
|
||||||
m_currentColumn = 0;
|
m_currentColumn = 0;
|
||||||
qreal minValue = minVectorValue(m_maxHeightByColumn);
|
qreal minValue = minVectorValue(m_maxHeightByColumn);
|
||||||
@ -902,63 +916,62 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (band->columnsCount()>1) &&
|
if (band->columnsCount() != m_maxHeightByColumn.size()){
|
||||||
(!band->isHeader() || (band->bandNestingLevel()>0 && band->columnsFillDirection() != BandDesignIntf::Horizontal ))){
|
for(int i=1;i<band->columnsCount();++i){
|
||||||
|
m_maxHeightByColumn.append(m_maxHeightByColumn[0]);
|
||||||
|
m_currentStartDataPos.append(m_currentStartDataPos[0]);
|
||||||
|
}
|
||||||
|
m_currentColumn = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_maxHeightByColumn.size()!=band->columnsCount()){
|
|
||||||
for(int i=1;i<band->columnsCount();++i){
|
if ( (band->columnsCount() > 1) &&
|
||||||
m_maxHeightByColumn.append(m_maxHeightByColumn[0]);
|
(!band->isHeader() || (band->bandNestingLevel() > 0 && band->columnsFillDirection() != BandDesignIntf::Horizontal ))){
|
||||||
m_currentStartDataPos.append(m_currentStartDataPos[0]);
|
|
||||||
}
|
if (band->columnsFillDirection() == BandDesignIntf::Horizontal){
|
||||||
m_currentColumn = 0;
|
if (m_currentColumn<band->columnsCount()-1)
|
||||||
|
m_currentColumn = m_currentColumn+1;
|
||||||
|
else
|
||||||
|
m_currentColumn = 0;
|
||||||
} else {
|
} else {
|
||||||
if (band->columnsFillDirection()==BandDesignIntf::Horizontal){
|
if ( (m_maxHeightByColumn[0] == m_maxHeightByColumn[m_currentColumn]) && (m_maxHeightByColumn[0] >= band->height()) ){
|
||||||
if (m_currentColumn<band->columnsCount()-1)
|
m_currentColumn = 0;
|
||||||
m_currentColumn = m_currentColumn+1;
|
|
||||||
else
|
|
||||||
m_currentColumn = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (band->height()<=m_maxHeightByColumn[m_currentColumn]){
|
if ( (isMultiColumnHeader(band) && band->height() <= m_maxHeightByColumn[0]) ||
|
||||||
|
(band->height() <= m_maxHeightByColumn[m_currentColumn])){
|
||||||
|
|
||||||
if (band->bandType()==BandDesignIntf::PageFooter){
|
if ( (band->bandType() == BandDesignIntf::PageFooter) ){
|
||||||
for (int i=0;i<m_maxHeightByColumn.size();++i)
|
for (int i=0; i < m_maxHeightByColumn.size(); ++i)
|
||||||
m_maxHeightByColumn[i]+=band->height();
|
m_maxHeightByColumn[i]+=band->height();
|
||||||
} else {
|
|
||||||
m_maxHeightByColumn[m_currentColumn]-=band->height();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (band->columnsCount()>1) &&
|
if ( isMultiColumnHeader(band)){
|
||||||
(band->isHeader() && (band->bandNestingLevel()==0 || band->columnsFillDirection()==BandDesignIntf::Horizontal))){
|
|
||||||
|
|
||||||
qreal bandPos = m_currentStartDataPos[m_currentColumn];
|
if (!band->parent()){
|
||||||
m_currentStartDataPos[m_currentColumn]+=band->height();
|
for (int i = 0; i < band->columnsCount(); ++i){
|
||||||
for (int i=0;i<band->columnsCount();++i){
|
m_currentColumn = i;
|
||||||
if (i!=0) band = dynamic_cast<BandDesignIntf*>(band->cloneItem(PreviewMode));
|
if (i != 0) band = dynamic_cast<BandDesignIntf*>(band->cloneItem(PreviewMode));
|
||||||
band->setPos(m_renderPageItem->pageRect().x()+band->width()*i,bandPos);
|
placeBandOnPage(band, i);
|
||||||
band->setBandIndex(++m_currentIndex);
|
}
|
||||||
band->setColumnIndex(i);
|
} else {
|
||||||
m_renderPageItem->registerBand(band);
|
placeBandOnPage(band, band->columnIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (band->bandType()!=BandDesignIntf::PageFooter){
|
if (band->bandType() != BandDesignIntf::PageFooter){
|
||||||
band->setPos(m_renderPageItem->pageRect().x()+band->width()*m_currentColumn,
|
placeBandOnPage(band, m_currentColumn);
|
||||||
m_currentStartDataPos[m_currentColumn]);
|
|
||||||
m_currentStartDataPos[m_currentColumn]+=band->height();
|
|
||||||
band->setBandIndex(++m_currentIndex);
|
|
||||||
band->setColumnIndex(m_currentColumn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (band->columnsCount()>1){
|
if (band->columnsCount() > 1){
|
||||||
m_columnedBandItems.append(band);
|
m_columnedBandItems.append(band);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_renderPageItem->registerBand(band);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(QList<BandDesignIntf*>* list,m_childBands.values()){
|
foreach(QList<BandDesignIntf*>* list,m_childBands.values()){
|
||||||
@ -974,7 +987,7 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (band->isData()) m_renderedDataBandCount++;
|
if (band->isData()) m_renderedDataBandCount++;
|
||||||
band->setObjectName(band->objectName()+QString::number(++m_curentNameIndex));
|
band->setObjectName(band->objectName()+QString::number(++m_currentNameIndex));
|
||||||
renameChildItems(band);
|
renameChildItems(band);
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
@ -1090,9 +1103,7 @@ void ReportRender::startNewColumn(){
|
|||||||
void ReportRender::startNewPage()
|
void ReportRender::startNewPage()
|
||||||
{
|
{
|
||||||
m_renderPageItem = 0;
|
m_renderPageItem = 0;
|
||||||
m_currentColumn = 0;
|
|
||||||
m_newPageStarted = true;
|
m_newPageStarted = true;
|
||||||
|
|
||||||
initColumns();
|
initColumns();
|
||||||
initRenderPage();
|
initRenderPage();
|
||||||
|
|
||||||
@ -1192,8 +1203,14 @@ void ReportRender::pasteGroups()
|
|||||||
m_popupedValues.clear();
|
m_popupedValues.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bandLessThen(BandDesignIntf* b1, BandDesignIntf* b2){
|
||||||
|
return b1->bandIndex() < b2->bandIndex();
|
||||||
|
}
|
||||||
|
|
||||||
void ReportRender::checkLostHeadersOnPrevPage()
|
void ReportRender::checkLostHeadersOnPrevPage()
|
||||||
{
|
{
|
||||||
|
QVector<BandDesignIntf*> lostHeaders;
|
||||||
|
|
||||||
if (m_renderedPages.isEmpty()) return;
|
if (m_renderedPages.isEmpty()) return;
|
||||||
PageItemDesignIntf::Ptr page = m_renderedPages.last();
|
PageItemDesignIntf::Ptr page = m_renderedPages.last();
|
||||||
if (page->bands().isEmpty()) return;
|
if (page->bands().isEmpty()) return;
|
||||||
@ -1212,12 +1229,19 @@ void ReportRender::checkLostHeadersOnPrevPage()
|
|||||||
if (it.value()->isHeader()){
|
if (it.value()->isHeader()){
|
||||||
if (it.value()->reprintOnEachPage()){
|
if (it.value()->reprintOnEachPage()){
|
||||||
delete it.value();
|
delete it.value();
|
||||||
} else { registerBand(it.value());}
|
} else { lostHeaders.append(it.value());}
|
||||||
it.remove();
|
it.remove();
|
||||||
it.previous();
|
it.previous();
|
||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lostHeaders.size() > 0){
|
||||||
|
qSort(lostHeaders.begin(), lostHeaders.end(), bandLessThen);
|
||||||
|
foreach(BandDesignIntf* header, lostHeaders){
|
||||||
|
registerBand(header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BandDesignIntf* ReportRender::findEnclosingGroup()
|
BandDesignIntf* ReportRender::findEnclosingGroup()
|
||||||
|
@ -154,6 +154,8 @@ private:
|
|||||||
qreal maxColumnHeight();
|
qreal maxColumnHeight();
|
||||||
void renameChildItems(BaseDesignIntf *item);
|
void renameChildItems(BaseDesignIntf *item);
|
||||||
void renderGroupFooterByHeader(BandDesignIntf *groupHeader);
|
void renderGroupFooterByHeader(BandDesignIntf *groupHeader);
|
||||||
|
void placeBandOnPage(BandDesignIntf *band, int columnIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DataSourceManager* m_datasources;
|
DataSourceManager* m_datasources;
|
||||||
ScriptEngineContext* m_scriptEngineContext;
|
ScriptEngineContext* m_scriptEngineContext;
|
||||||
@ -184,10 +186,9 @@ private:
|
|||||||
int m_currentColumn;
|
int m_currentColumn;
|
||||||
QList<PagesRange> m_ranges;
|
QList<PagesRange> m_ranges;
|
||||||
QVector<BandDesignIntf*> m_columnedBandItems;
|
QVector<BandDesignIntf*> m_columnedBandItems;
|
||||||
unsigned long long m_curentNameIndex;
|
unsigned long long m_currentNameIndex;
|
||||||
bool m_newPageStarted;
|
bool m_newPageStarted;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
#endif // LRREPORTRENDER_H
|
#endif // LRREPORTRENDER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user