diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 0928856..cbd2161 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -130,7 +130,7 @@ void PageDesignIntf::updatePageRect() } this->setSceneRect(-Const::SCENE_MARGIN, -Const::SCENE_MARGIN, pageItem()->geometry().width() + Const::SCENE_MARGIN*2, - pageItem()->geometry().height() + Const::SCENE_MARGIN*2); + pageItem()->boundingRect().height() + Const::SCENE_MARGIN*2); emit sceneRectChanged(sceneRect()); } diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 150df06..7c23d12 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -49,7 +49,8 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) : ItemsContainerDesignInft("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_oldPrintMode(false), m_resetPageNumber(false) + m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false), + m_isExtendedInDesignMode(false), m_extendedHeight(1000) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); @@ -61,7 +62,8 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re ItemsContainerDesignInft("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_oldPrintMode(false), m_resetPageNumber(false) + m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false), + m_isExtendedInDesignMode(false), m_extendedHeight(1000) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); @@ -79,14 +81,24 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte { if (itemMode() & DesignMode){ + QRectF rect = pageRect(); + if (isExtendedInDesignMode()) rect.adjust(0,0,0,m_extendedHeight); ppainter->save(); ppainter->setOpacity(0.8); ppainter->fillRect(boundingRect(),pageBorderColor()); ppainter->setOpacity(1); - ppainter->fillRect(pageRect(),Qt::white); - paintGrid(ppainter); + ppainter->fillRect(rect,Qt::white); + paintGrid(ppainter,rect); ppainter->setPen(gridColor()); ppainter->drawRect(boundingRect()); + if (m_isExtendedInDesignMode){ + QPen pen; + pen.setColor(Qt::red); + pen.setStyle(Qt::DashLine); + pen.setWidth(2); + ppainter->setPen(pen); + ppainter->drawLine(pageRect().bottomLeft(),pageRect().bottomRight()); + } ppainter->restore(); } @@ -140,6 +152,16 @@ QColor PageItemDesignIntf::gridColor() const return QColor(170,200,150); } +QRectF PageItemDesignIntf::boundingRect() const +{ + if (!isExtendedInDesignMode()) + return BaseDesignIntf::boundingRect(); + else { + QRectF result = BaseDesignIntf::boundingRect(); + return result.adjusted(0,0,0,m_extendedHeight); + } +} + void PageItemDesignIntf::clear() { foreach(QGraphicsItem* item, childItems()){ @@ -303,6 +325,32 @@ void PageItemDesignIntf::initColumnsPos(QVector &posByColumns, qreal pos, } } +int PageItemDesignIntf::extendedHeight() const +{ + return m_extendedHeight; +} + +void PageItemDesignIntf::setExtendedHeight(int extendedHeight) +{ + m_extendedHeight = extendedHeight; + PageDesignIntf* page = dynamic_cast(scene()); + if (page) page->updatePageRect(); + update(); +} + +bool PageItemDesignIntf::isExtendedInDesignMode() const +{ + return m_isExtendedInDesignMode; +} + +void PageItemDesignIntf::setExtendedInDesignMode(bool pageIsExtended) +{ + m_isExtendedInDesignMode = pageIsExtended; + PageDesignIntf* page = dynamic_cast(scene()); + if (page) page->updatePageRect(); + update(); +} + bool PageItemDesignIntf::resetPageNumber() const { return m_resetPageNumber; @@ -630,27 +678,27 @@ void PageItemDesignIntf::updateMarginRect() update(); } -void PageItemDesignIntf::paintGrid(QPainter *ppainter) +void PageItemDesignIntf::paintGrid(QPainter *ppainter, QRectF rect) { ppainter->save(); ppainter->setPen(QPen(gridColor())); ppainter->setOpacity(0.5); - for (int i=0;i<=(pageRect().height()-50)/100;i++){ - ppainter->drawLine(pageRect().x(),(i*100)+pageRect().y()+50,pageRect().right(),i*100+pageRect().y()+50); + for (int i=0;i<=(rect.height()-50)/100;i++){ + ppainter->drawLine(rect.x(),(i*100)+rect.y()+50,rect.right(),i*100+rect.y()+50); }; - for (int i=0;i<=((pageRect().width()-50)/100);i++){ - ppainter->drawLine(i*100+pageRect().x()+50,pageRect().y(),i*100+pageRect().x()+50,pageRect().bottom()); + for (int i=0;i<=((rect.width()-50)/100);i++){ + ppainter->drawLine(i*100+rect.x()+50,rect.y(),i*100+rect.x()+50,rect.bottom()); }; ppainter->setPen(QPen(gridColor())); ppainter->setOpacity(1); - for (int i=0;i<=(pageRect().width()/100);i++){ - ppainter->drawLine(i*100+pageRect().x(),pageRect().y(),i*100+pageRect().x(),pageRect().bottom()); + for (int i=0;i<=(rect.width()/100);i++){ + ppainter->drawLine(i*100+rect.x(),rect.y(),i*100+rect.x(),rect.bottom()); }; - for (int i=0;i<=pageRect().height()/100;i++){ - ppainter->drawLine(pageRect().x(),i*100+pageRect().y(),pageRect().right(),i*100+pageRect().y()); + for (int i=0;i<=rect.height()/100;i++){ + ppainter->drawLine(rect.x(),i*100+rect.y(),rect.right(),i*100+rect.y()); }; - ppainter->drawRect(pageRect()); + ppainter->drawRect(rect); ppainter->restore(); } diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index ef9b06d..f488b07 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -53,6 +53,8 @@ class PageItemDesignIntf : public LimeReport::ItemsContainerDesignInft Q_PROPERTY(bool fullPage READ fullPage WRITE setFullPage) Q_PROPERTY(bool oldPrintMode READ oldPrintMode WRITE setOldPrintMode) Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber) + Q_PROPERTY(bool isExtendedInDesignMode READ isExtendedInDesignMode WRITE setExtendedInDesignMode) + Q_PROPERTY(int extendedHeight READ extendedHeight WRITE setExtendedHeight) friend class ReportRender; public: enum Orientation { Portrait, Landscape }; @@ -74,6 +76,7 @@ public: virtual QColor selectionColor() const; virtual QColor pageBorderColor() const; virtual QColor gridColor() const; + virtual QRectF boundingRect() const; void clear(); const BandsList& childBands() const {return m_bands;} BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const; @@ -118,6 +121,11 @@ public: void setResetPageNumber(bool resetPageNumber); void updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager); + bool isExtendedInDesignMode() const; + void setExtendedInDesignMode(bool isExtendedInDesignMode); + int extendedHeight() const; + void setExtendedHeight(int extendedHeight); + protected slots: void bandDeleted(QObject* band); void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); @@ -131,7 +139,7 @@ protected: QColor selectionMarkerColor(){return Qt::transparent;} void preparePopUpMenu(QMenu &menu); private: - void paintGrid(QPainter *ppainter); + void paintGrid(QPainter *ppainter, QRectF rect); void initColumnsPos(QVector&posByColumns, qreal pos, int columnCount); private: int m_topMargin; @@ -146,6 +154,8 @@ private: bool m_fullPage; bool m_oldPrintMode; bool m_resetPageNumber; + bool m_isExtendedInDesignMode; + int m_extendedHeight; }; typedef QList ReportPages;