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

FullPage property has been added

This commit is contained in:
Arin Alexander 2016-04-21 01:09:15 +04:00
parent b770669b64
commit 34e114d7a4
3 changed files with 44 additions and 24 deletions

View File

@ -47,7 +47,7 @@ bool bandSortBandLessThenByIndex(const BandDesignIntf *c1, const BandDesignIntf
PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
BaseDesignIntf("PageItem",owner,parent),
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false)
m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false), m_fullPage(false)
{
setFixedPos(true);
setPosibleResizeDirectionFlags(Fixed);
@ -57,7 +57,7 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &rect, QObject *owner, QGraphicsItem *parent) :
BaseDesignIntf("PageItem",owner,parent),
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false)
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false), m_fullPage(false)
{
setFixedPos(true);
setPosibleResizeDirectionFlags(Fixed);
@ -297,6 +297,22 @@ void PageItemDesignIntf::initColumnsPos(QVector<qreal> &posByColumns, qreal pos,
}
}
bool PageItemDesignIntf::fullPage() const
{
return m_fullPage;
}
void PageItemDesignIntf::setFullPage(bool fullPage)
{
if (m_fullPage != fullPage){
m_fullPage = fullPage;
if (!isLoading()){
updateMarginRect();
notify("fullPage", !m_fullPage, m_fullPage);
}
}
}
void PageItemDesignIntf::relocateBands()
{
if (isLoading()) return;
@ -444,8 +460,8 @@ QSizeF PageItemDesignIntf::getRectByPageSize(const PageSize& size)
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOrientation((QPrinter::Orientation)pageOrientation());
printer.setPageSize((QPrinter::PageSize)size);
return QSizeF(printer.paperRect(QPrinter::Millimeter).width() * 10,
printer.setPaperSize((QPrinter::PageSize)size);
return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * 10,
printer.paperSize(QPrinter::Millimeter).height() * 10);
}

View File

@ -49,6 +49,7 @@ class PageItemDesignIntf : public LimeReport::BaseDesignIntf
Q_PROPERTY(Orientation pageOrientation READ pageOrientation WRITE setPageOrientation)
Q_PROPERTY(PageSize pageSize READ pageSize WRITE setPageSize )
Q_PROPERTY(int gridStep READ gridStep WRITE setGridStep)
Q_PROPERTY(bool fullPage READ fullPage WRITE setFullPage)
friend class ReportRender;
public:
enum Orientation { Portrait, Landscape };
@ -104,6 +105,9 @@ public:
void setGridStep(int value);
int gridStep();
void objectLoadFinished();
bool fullPage() const;
void setFullPage(bool fullPage);
protected slots:
void bandDeleted(QObject* band);
void bandGeometryChanged(QObject* /*object*/, QRectF newGeometry, QRectF oldGeometry);
@ -128,6 +132,7 @@ private:
QRectF m_pageRect;
bool m_sizeChainging;
QList<BandDesignIntf*> m_bands;
bool m_fullPage;
};
}
#endif // LRPAGEITEM_H

View File

@ -158,20 +158,21 @@ void ReportEnginePrivate::printReport(ItemsReaderIntf::Ptr reader, QPrinter& pri
renderPage.setItemMode(PrintMode);
if (reader->first()){
reader->readItem(renderPage.pageItem());
printer.setPageMargins(renderPage.pageItem()->leftMargin(),
renderPage.pageItem()->topMargin(),
renderPage.pageItem()->rightMargin(),
renderPage.pageItem()->bottomMargin(),
QPrinter::Millimeter);
printer.setFullPage(renderPage.pageItem()->fullPage());
printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation());
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect());
QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)?
QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()):
renderPage.pageItem()->sizeMM();
printer.setPaperSize(pageSize,QPrinter::Millimeter);
if (renderPage.pageItem()->pageSize()==PageItemDesignIntf::Custom){
QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)?
QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()):
renderPage.pageItem()->sizeMM();
printer.setPaperSize(pageSize,QPrinter::Millimeter);
} else {
printer.setPaperSize((QPrinter::PageSize)renderPage.pageItem()->pageSize());
}
QPainter painter(&printer);
painter.drawRect(printer.pageRect());
renderPage.render(&painter);
while (reader->next()){
@ -206,19 +207,17 @@ void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer, cons
QPointF pagePos = page->pos();
page->setPos(0,0);
renderPage.setPageItem(page);
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect());
printer.setPageMargins(renderPage.pageItem()->leftMargin(),
renderPage.pageItem()->topMargin(),
renderPage.pageItem()->rightMargin(),
renderPage.pageItem()->bottomMargin(),
QPrinter::Millimeter);
printer.setFullPage(renderPage.pageItem()->fullPage());
printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation());
QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)?
QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()):
renderPage.pageItem()->sizeMM();
printer.setPaperSize(pageSize,QPrinter::Millimeter);
if (renderPage.pageItem()->pageSize()==PageItemDesignIntf::Custom){
QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)?
QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()):
renderPage.pageItem()->sizeMM();
printer.setPaperSize(pageSize,QPrinter::Millimeter);
} else {
printer.setPaperSize((QPrinter::PageSize)renderPage.pageItem()->pageSize());
}
if (!isFirst){
printer.newPage();