0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

Merge remote-tracking branch 'origin/feature/not_print_empty_pages' into master

This commit is contained in:
Arin Alexander 2021-01-20 22:40:44 +03:00
commit ab2d8b315a
3 changed files with 34 additions and 6 deletions

View File

@ -52,7 +52,8 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false),
m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true),
m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false)
m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false),
m_notPrintIfEmpty(false)
{
setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed);
@ -67,7 +68,8 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false),
m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true),
m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false)
m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false),
m_notPrintIfEmpty(false)
{
setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed);
@ -347,6 +349,16 @@ void PageItemDesignIntf::initColumnsPos(QVector<qreal> &posByColumns, qreal pos,
}
}
bool PageItemDesignIntf::notPrintIfEmpty() const
{
return m_notPrintIfEmpty;
}
void PageItemDesignIntf::setNotPrintIfEmpty(bool notPrintIfEmpty)
{
m_notPrintIfEmpty = notPrintIfEmpty;
}
bool PageItemDesignIntf::dropPrinterMargins() const
{
return m_dropPrinterMargins;
@ -357,6 +369,11 @@ void PageItemDesignIntf::setDropPrinterMargins(bool dropPrinterMargins)
m_dropPrinterMargins = dropPrinterMargins;
}
bool PageItemDesignIntf::isEmpty() const
{
return childBaseItems().isEmpty();
}
void PageItemDesignIntf::setPrintBehavior(const PrintBehavior &printBehavior)
{
m_printBehavior = printBehavior;

View File

@ -62,6 +62,7 @@ class PageItemDesignIntf : public ItemsContainerDesignInft
Q_PROPERTY(UnitType units READ unitType WRITE setUnitTypeProperty)
Q_PROPERTY(PrintBehavior printBehavior READ printBehavior WRITE setPrintBehavior)
Q_PROPERTY(bool dropPrinterMargins READ dropPrinterMargins WRITE setDropPrinterMargins)
Q_PROPERTY(bool notPrintIfEmpty READ notPrintIfEmpty WRITE setNotPrintIfEmpty)
friend class ReportRender;
public:
enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
@ -182,6 +183,11 @@ public:
bool dropPrinterMargins() const;
void setDropPrinterMargins(bool dropPrinterMargins);
bool isEmpty() const;
bool notPrintIfEmpty() const;
void setNotPrintIfEmpty(bool notPrintIfEmpty);
signals:
void beforeFirstPageRendered();
void afterLastPageRendered();
@ -226,6 +232,7 @@ private:
BandDesignIntf* m_pageFooter;
PrintBehavior m_printBehavior;
bool m_dropPrinterMargins;
bool m_notPrintIfEmpty;
};

View File

@ -1484,15 +1484,19 @@ BandDesignIntf* ReportRender::findEnclosingGroup()
void ReportRender::savePage(bool isLast)
{
if (m_renderPageItem->isTOC())
m_pagesRanges.addTOCPage();
else
m_pagesRanges.addPage();
m_datasources->setReportVariable("#IS_LAST_PAGEFOOTER",isLast);
m_datasources->setReportVariable("#IS_FIRST_PAGEFOOTER",m_datasources->variable("#PAGE").toInt()==1);
renderPageItems(m_patternPageItem);
if (m_renderPageItem->isEmpty() && m_renderPageItem->notPrintIfEmpty()) return;
if (m_renderPageItem->isTOC())
m_pagesRanges.addTOCPage();
else
m_pagesRanges.addPage();
checkFooterGroup(m_lastDataBand);
cutGroups();
rearrangeColumnsItems();