From 0505801e3a09218955cdfd761e05f4530cface12 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sun, 19 Mar 2017 14:03:13 +0300 Subject: [PATCH] printBeforePageHeader property has been added to "ReportHeader" band --- limereport/bands/lrreportheader.cpp | 15 ++++++++++++++- limereport/bands/lrreportheader.h | 4 ++++ limereport/lrreportrender.cpp | 21 +++++++++++++++++---- limereport/lrreportrender.h | 4 +++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/limereport/bands/lrreportheader.cpp b/limereport/bands/lrreportheader.cpp index 5b853b7..e08f418 100644 --- a/limereport/bands/lrreportheader.cpp +++ b/limereport/bands/lrreportheader.cpp @@ -46,7 +46,7 @@ bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instanc namespace LimeReport { ReportHeader::ReportHeader(QObject *owner, QGraphicsItem *parent) - : BandDesignIntf(LimeReport::BandDesignIntf::ReportHeader,xmlTag,owner,parent) { + : BandDesignIntf(LimeReport::BandDesignIntf::ReportHeader,xmlTag,owner,parent), m_printBeforePageHeader(false) { setBandTypeText(tr("Report Header")); setMarkerColor(bandColor()); } @@ -60,5 +60,18 @@ QColor ReportHeader::bandColor() const return QColor(152,69,167); } +bool ReportHeader::printBeforePageHeader() const +{ + return m_printBeforePageHeader; +} + +void ReportHeader::setPrintBeforePageHeader(bool printBeforePageHeader) +{ + if (m_printBeforePageHeader != printBeforePageHeader){ + m_printBeforePageHeader = printBeforePageHeader; + notify("printBeforePageHeader",!m_printBeforePageHeader,m_printBeforePageHeader); + } +} + } diff --git a/limereport/bands/lrreportheader.h b/limereport/bands/lrreportheader.h index bc70667..d532ff9 100644 --- a/limereport/bands/lrreportheader.h +++ b/limereport/bands/lrreportheader.h @@ -39,11 +39,15 @@ class ReportHeader : public LimeReport::BandDesignIntf { Q_OBJECT Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable ) + Q_PROPERTY(bool printBeforePageHeader READ printBeforePageHeader WRITE setPrintBeforePageHeader) public: ReportHeader(QObject* owner = 0, QGraphicsItem *parent=0); virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0); + bool printBeforePageHeader() const; + void setPrintBeforePageHeader(bool printBeforePageHeader); protected: QColor bandColor() const; + bool m_printBeforePageHeader; }; } #endif // LRREPORTHEADER_H diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 36f7961..2476930 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -257,11 +257,12 @@ void ReportRender::renderPage(PageDesignIntf* patternPage) } clearPageMap(); - startNewPage(); + startNewPage(true); + renderReportHeader(m_patternPageItem, AfterPageHeader); - renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader), 0, StartNewPageAsNeeded); +// renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader), 0, StartNewPageAsNeeded); BandDesignIntf* lastRenderedBand = 0; for (int i=0;idataBandCount() && !m_renderCanceled;i++){ @@ -605,6 +606,17 @@ void ReportRender::renderPageHeader(PageItemDesignIntf *patternPage) } } +void ReportRender::renderReportHeader(PageItemDesignIntf *patternPage, PageRenderStage stage) +{ + BandDesignIntf* band = patternPage->bandByType(BandDesignIntf::ReportHeader); + if (band){ + if (band->property("printBeforePageHeader").toBool() && stage == BeforePageHeader ) + renderBand(band, 0, StartNewPageAsNeeded); + if (!band->property("printBeforePageHeader").toBool() && stage == AfterPageHeader ) + renderBand(band, 0, StartNewPageAsNeeded); + } +} + void ReportRender::renderPageFooter(PageItemDesignIntf *patternPage) { BandDesignIntf* band = patternPage->bandByType(BandDesignIntf::PageFooter); @@ -897,7 +909,7 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren) } - if (band->height()<=m_maxHeightByColumn[m_currentColumn]){ + if (band->height() <= m_maxHeightByColumn[m_currentColumn]){ if (band->bandType()==BandDesignIntf::PageFooter){ for (int i=0;ibeforeRender(); + if (isFirst) renderReportHeader(m_patternPageItem, BeforePageHeader); renderPageHeader(m_patternPageItem); m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem); diff --git a/limereport/lrreportrender.h b/limereport/lrreportrender.h index 8e62b0b..1759712 100644 --- a/limereport/lrreportrender.h +++ b/limereport/lrreportrender.h @@ -70,6 +70,7 @@ public: enum DataRenderMode {StartNewPageAsNeeded, NotStartNewPage, ForcedStartPage}; enum BandPrintMode {PrintAlwaysPrintable, PrintNotAlwaysPrintable }; enum ResetPageNuberType{BandReset, PageReset}; + enum PageRenderStage{BeforePageHeader, AfterPageHeader}; typedef QSharedPointer Ptr; ~ReportRender(); ReportRender(QObject *parent = 0); @@ -102,6 +103,7 @@ private: BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false); void renderDataBand(BandDesignIntf* dataBand); void renderPageHeader(PageItemDesignIntf* patternPage); + void renderReportHeader(PageItemDesignIntf* patternPage, PageRenderStage stage); void renderPageFooter(PageItemDesignIntf* patternPage); void moveTearOffBand(); void renderPageItems(PageItemDesignIntf* patternPage); @@ -138,7 +140,7 @@ private: BandDesignIntf* saveUppperPartReturnBottom(BandDesignIntf *band, int height, BandDesignIntf *patternBand); BandDesignIntf* renderData(BandDesignIntf* patternBand); void startNewColumn(); - void startNewPage(); + void startNewPage(bool isFirst = false); void resetPageNumber(ResetPageNuberType resetType); int findLastPageNumber(int currentPage); void savePage(bool isLast = false);