diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 33808b7..ac4f486 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -47,7 +47,8 @@ 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_fullPage(false) + m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false), + m_fullPage(false), m_oldPrintMode(false) { setFixedPos(true); setPosibleResizeDirectionFlags(Fixed); @@ -57,7 +58,8 @@ 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_fullPage(false) + m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false), + m_fullPage(false), m_oldPrintMode(false) { setFixedPos(true); setPosibleResizeDirectionFlags(Fixed); @@ -297,6 +299,16 @@ void PageItemDesignIntf::initColumnsPos(QVector &posByColumns, qreal pos, } } +bool PageItemDesignIntf::oldPrintMode() const +{ + return m_oldPrintMode; +} + +void PageItemDesignIntf::setOldPrintMode(bool oldPrintMode) +{ + m_oldPrintMode = oldPrintMode; +} + bool PageItemDesignIntf::fullPage() const { return m_fullPage; @@ -324,7 +336,7 @@ void PageItemDesignIntf::relocateBands() qSort(m_bands.begin(),m_bands.end(),bandSortBandLessThenByIndex); if (m_bands.count()>0) { - initColumnsPos(posByColumn,pageRect().x(),m_bands[0]->columnsCount()); + initColumnsPos(posByColumn,pageRect().y(),m_bands[0]->columnsCount()); m_bands[0]->setPos(pageRect().x(),pageRect().y()); posByColumn[0]+=m_bands[0]->height()+bandSpace; } diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 36222d8..0bd5445 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -50,6 +50,7 @@ class PageItemDesignIntf : public LimeReport::BaseDesignIntf Q_PROPERTY(PageSize pageSize READ pageSize WRITE setPageSize ) Q_PROPERTY(int gridStep READ gridStep WRITE setGridStep) Q_PROPERTY(bool fullPage READ fullPage WRITE setFullPage) + Q_PROPERTY(bool oldPrintMode READ oldPrintMode WRITE setOldPrintMode) friend class ReportRender; public: enum Orientation { Portrait, Landscape }; @@ -108,6 +109,9 @@ public: bool fullPage() const; void setFullPage(bool fullPage); + bool oldPrintMode() const; + void setOldPrintMode(bool oldPrintMode); + protected slots: void bandDeleted(QObject* band); void bandGeometryChanged(QObject* /*object*/, QRectF newGeometry, QRectF oldGeometry); @@ -133,6 +137,7 @@ private: bool m_sizeChainging; QList m_bands; bool m_fullPage; + bool m_oldPrintMode; }; } #endif // LRPAGEITEM_H diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index f223b20..7a63217 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -175,7 +175,6 @@ void ReportEnginePrivate::printReport(ItemsReaderIntf::Ptr reader, QPrinter& pri } QPainter painter(&printer); - painter.drawRect(printer.pageRect()); renderPage.render(&painter); while (reader->next()){ @@ -211,15 +210,28 @@ void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer, cons page->setPos(0,0); renderPage.setPageItem(page); renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect()); - printer.setFullPage(renderPage.pageItem()->fullPage()); - printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation()); - if (renderPage.pageItem()->pageSize()==PageItemDesignIntf::Custom){ + if (renderPage.pageItem()->oldPrintMode()){ + printer.setPageMargins(renderPage.pageItem()->leftMargin(), + renderPage.pageItem()->topMargin(), + renderPage.pageItem()->rightMargin(), + renderPage.pageItem()->bottomMargin(), + QPrinter::Millimeter); + 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(); + 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()); + printer.setFullPage(renderPage.pageItem()->fullPage()); + printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation()); + 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){