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

printBeforePageHeader property has been added to "ReportHeader" band

This commit is contained in:
Arin Alexander 2017-03-19 14:03:13 +03:00
parent 1cb6c1f02e
commit 0505801e3a
4 changed files with 38 additions and 6 deletions

View File

@ -46,7 +46,7 @@ bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instanc
namespace LimeReport { namespace LimeReport {
ReportHeader::ReportHeader(QObject *owner, QGraphicsItem *parent) 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")); setBandTypeText(tr("Report Header"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
@ -60,5 +60,18 @@ QColor ReportHeader::bandColor() const
return QColor(152,69,167); 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);
}
}
} }

View File

@ -39,11 +39,15 @@ class ReportHeader : public LimeReport::BandDesignIntf
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable ) Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable )
Q_PROPERTY(bool printBeforePageHeader READ printBeforePageHeader WRITE setPrintBeforePageHeader)
public: public:
ReportHeader(QObject* owner = 0, QGraphicsItem *parent=0); ReportHeader(QObject* owner = 0, QGraphicsItem *parent=0);
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0); virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
bool printBeforePageHeader() const;
void setPrintBeforePageHeader(bool printBeforePageHeader);
protected: protected:
QColor bandColor() const; QColor bandColor() const;
bool m_printBeforePageHeader;
}; };
} }
#endif // LRREPORTHEADER_H #endif // LRREPORTHEADER_H

View File

@ -257,11 +257,12 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
} }
clearPageMap(); 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; 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++){
@ -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) void ReportRender::renderPageFooter(PageItemDesignIntf *patternPage)
{ {
BandDesignIntf* band = patternPage->bandByType(BandDesignIntf::PageFooter); 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){ if (band->bandType()==BandDesignIntf::PageFooter){
for (int i=0;i<m_maxHeightByColumn.size();++i) for (int i=0;i<m_maxHeightByColumn.size();++i)
@ -1061,7 +1073,7 @@ void ReportRender::startNewColumn(){
} }
} }
void ReportRender::startNewPage() void ReportRender::startNewPage(bool isFirst)
{ {
m_renderPageItem=0; m_renderPageItem=0;
m_currentColumn=0; m_currentColumn=0;
@ -1078,6 +1090,7 @@ void ReportRender::startNewPage()
emit m_patternPageItem->beforeRender(); emit m_patternPageItem->beforeRender();
if (isFirst) renderReportHeader(m_patternPageItem, BeforePageHeader);
renderPageHeader(m_patternPageItem); renderPageHeader(m_patternPageItem);
m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem); m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem);

View File

@ -70,6 +70,7 @@ public:
enum DataRenderMode {StartNewPageAsNeeded, NotStartNewPage, ForcedStartPage}; enum DataRenderMode {StartNewPageAsNeeded, NotStartNewPage, ForcedStartPage};
enum BandPrintMode {PrintAlwaysPrintable, PrintNotAlwaysPrintable }; enum BandPrintMode {PrintAlwaysPrintable, PrintNotAlwaysPrintable };
enum ResetPageNuberType{BandReset, PageReset}; enum ResetPageNuberType{BandReset, PageReset};
enum PageRenderStage{BeforePageHeader, AfterPageHeader};
typedef QSharedPointer<ReportRender> Ptr; typedef QSharedPointer<ReportRender> Ptr;
~ReportRender(); ~ReportRender();
ReportRender(QObject *parent = 0); ReportRender(QObject *parent = 0);
@ -102,6 +103,7 @@ private:
BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, 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 renderReportHeader(PageItemDesignIntf* patternPage, PageRenderStage stage);
void renderPageFooter(PageItemDesignIntf* patternPage); void renderPageFooter(PageItemDesignIntf* patternPage);
void moveTearOffBand(); void moveTearOffBand();
void renderPageItems(PageItemDesignIntf* patternPage); void renderPageItems(PageItemDesignIntf* patternPage);
@ -138,7 +140,7 @@ private:
BandDesignIntf* saveUppperPartReturnBottom(BandDesignIntf *band, int height, BandDesignIntf *patternBand); BandDesignIntf* saveUppperPartReturnBottom(BandDesignIntf *band, int height, BandDesignIntf *patternBand);
BandDesignIntf* renderData(BandDesignIntf* patternBand); BandDesignIntf* renderData(BandDesignIntf* patternBand);
void startNewColumn(); void startNewColumn();
void startNewPage(); void startNewPage(bool isFirst = false);
void resetPageNumber(ResetPageNuberType resetType); void resetPageNumber(ResetPageNuberType resetType);
int findLastPageNumber(int currentPage); int findLastPageNumber(int currentPage);
void savePage(bool isLast = false); void savePage(bool isLast = false);