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

Extended area has been added to page in design mode

This commit is contained in:
Arin Alexander 2017-06-02 22:11:53 +03:00
parent c4f20b78c1
commit fb494db947
3 changed files with 74 additions and 16 deletions

View File

@ -130,7 +130,7 @@ void PageDesignIntf::updatePageRect()
} }
this->setSceneRect(-Const::SCENE_MARGIN, -Const::SCENE_MARGIN, this->setSceneRect(-Const::SCENE_MARGIN, -Const::SCENE_MARGIN,
pageItem()->geometry().width() + Const::SCENE_MARGIN*2, pageItem()->geometry().width() + Const::SCENE_MARGIN*2,
pageItem()->geometry().height() + Const::SCENE_MARGIN*2); pageItem()->boundingRect().height() + Const::SCENE_MARGIN*2);
emit sceneRectChanged(sceneRect()); emit sceneRectChanged(sceneRect());
} }

View File

@ -49,7 +49,8 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
ItemsContainerDesignInft("PageItem",owner,parent), ItemsContainerDesignInft("PageItem",owner,parent),
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0), 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), m_oldPrintMode(false), m_resetPageNumber(false) m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
m_isExtendedInDesignMode(false), m_extendedHeight(1000)
{ {
setFixedPos(true); setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed); setPossibleResizeDirectionFlags(Fixed);
@ -61,7 +62,8 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
ItemsContainerDesignInft("PageItem",owner,parent), ItemsContainerDesignInft("PageItem",owner,parent),
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0), 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), m_oldPrintMode(false), m_resetPageNumber(false) m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
m_isExtendedInDesignMode(false), m_extendedHeight(1000)
{ {
setFixedPos(true); setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed); setPossibleResizeDirectionFlags(Fixed);
@ -79,14 +81,24 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte
{ {
if (itemMode() & DesignMode){ if (itemMode() & DesignMode){
QRectF rect = pageRect();
if (isExtendedInDesignMode()) rect.adjust(0,0,0,m_extendedHeight);
ppainter->save(); ppainter->save();
ppainter->setOpacity(0.8); ppainter->setOpacity(0.8);
ppainter->fillRect(boundingRect(),pageBorderColor()); ppainter->fillRect(boundingRect(),pageBorderColor());
ppainter->setOpacity(1); ppainter->setOpacity(1);
ppainter->fillRect(pageRect(),Qt::white); ppainter->fillRect(rect,Qt::white);
paintGrid(ppainter); paintGrid(ppainter,rect);
ppainter->setPen(gridColor()); ppainter->setPen(gridColor());
ppainter->drawRect(boundingRect()); 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(); ppainter->restore();
} }
@ -140,6 +152,16 @@ QColor PageItemDesignIntf::gridColor() const
return QColor(170,200,150); 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() void PageItemDesignIntf::clear()
{ {
foreach(QGraphicsItem* item, childItems()){ foreach(QGraphicsItem* item, childItems()){
@ -303,6 +325,32 @@ void PageItemDesignIntf::initColumnsPos(QVector<qreal> &posByColumns, qreal pos,
} }
} }
int PageItemDesignIntf::extendedHeight() const
{
return m_extendedHeight;
}
void PageItemDesignIntf::setExtendedHeight(int extendedHeight)
{
m_extendedHeight = extendedHeight;
PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(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<PageDesignIntf*>(scene());
if (page) page->updatePageRect();
update();
}
bool PageItemDesignIntf::resetPageNumber() const bool PageItemDesignIntf::resetPageNumber() const
{ {
return m_resetPageNumber; return m_resetPageNumber;
@ -630,27 +678,27 @@ void PageItemDesignIntf::updateMarginRect()
update(); update();
} }
void PageItemDesignIntf::paintGrid(QPainter *ppainter) void PageItemDesignIntf::paintGrid(QPainter *ppainter, QRectF rect)
{ {
ppainter->save(); ppainter->save();
ppainter->setPen(QPen(gridColor())); ppainter->setPen(QPen(gridColor()));
ppainter->setOpacity(0.5); ppainter->setOpacity(0.5);
for (int i=0;i<=(pageRect().height()-50)/100;i++){ for (int i=0;i<=(rect.height()-50)/100;i++){
ppainter->drawLine(pageRect().x(),(i*100)+pageRect().y()+50,pageRect().right(),i*100+pageRect().y()+50); 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++){ for (int i=0;i<=((rect.width()-50)/100);i++){
ppainter->drawLine(i*100+pageRect().x()+50,pageRect().y(),i*100+pageRect().x()+50,pageRect().bottom()); ppainter->drawLine(i*100+rect.x()+50,rect.y(),i*100+rect.x()+50,rect.bottom());
}; };
ppainter->setPen(QPen(gridColor())); ppainter->setPen(QPen(gridColor()));
ppainter->setOpacity(1); ppainter->setOpacity(1);
for (int i=0;i<=(pageRect().width()/100);i++){ for (int i=0;i<=(rect.width()/100);i++){
ppainter->drawLine(i*100+pageRect().x(),pageRect().y(),i*100+pageRect().x(),pageRect().bottom()); ppainter->drawLine(i*100+rect.x(),rect.y(),i*100+rect.x(),rect.bottom());
}; };
for (int i=0;i<=pageRect().height()/100;i++){ for (int i=0;i<=rect.height()/100;i++){
ppainter->drawLine(pageRect().x(),i*100+pageRect().y(),pageRect().right(),i*100+pageRect().y()); ppainter->drawLine(rect.x(),i*100+rect.y(),rect.right(),i*100+rect.y());
}; };
ppainter->drawRect(pageRect()); ppainter->drawRect(rect);
ppainter->restore(); ppainter->restore();
} }

View File

@ -53,6 +53,8 @@ class PageItemDesignIntf : public LimeReport::ItemsContainerDesignInft
Q_PROPERTY(bool fullPage READ fullPage WRITE setFullPage) Q_PROPERTY(bool fullPage READ fullPage WRITE setFullPage)
Q_PROPERTY(bool oldPrintMode READ oldPrintMode WRITE setOldPrintMode) Q_PROPERTY(bool oldPrintMode READ oldPrintMode WRITE setOldPrintMode)
Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber) 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; friend class ReportRender;
public: public:
enum Orientation { Portrait, Landscape }; enum Orientation { Portrait, Landscape };
@ -74,6 +76,7 @@ public:
virtual QColor selectionColor() const; virtual QColor selectionColor() const;
virtual QColor pageBorderColor() const; virtual QColor pageBorderColor() const;
virtual QColor gridColor() const; virtual QColor gridColor() const;
virtual QRectF boundingRect() const;
void clear(); void clear();
const BandsList& childBands() const {return m_bands;} const BandsList& childBands() const {return m_bands;}
BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const; BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const;
@ -118,6 +121,11 @@ public:
void setResetPageNumber(bool resetPageNumber); void setResetPageNumber(bool resetPageNumber);
void updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager); void updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager);
bool isExtendedInDesignMode() const;
void setExtendedInDesignMode(bool isExtendedInDesignMode);
int extendedHeight() const;
void setExtendedHeight(int extendedHeight);
protected slots: protected slots:
void bandDeleted(QObject* band); void bandDeleted(QObject* band);
void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
@ -131,7 +139,7 @@ protected:
QColor selectionMarkerColor(){return Qt::transparent;} QColor selectionMarkerColor(){return Qt::transparent;}
void preparePopUpMenu(QMenu &menu); void preparePopUpMenu(QMenu &menu);
private: private:
void paintGrid(QPainter *ppainter); void paintGrid(QPainter *ppainter, QRectF rect);
void initColumnsPos(QVector<qreal>&posByColumns, qreal pos, int columnCount); void initColumnsPos(QVector<qreal>&posByColumns, qreal pos, int columnCount);
private: private:
int m_topMargin; int m_topMargin;
@ -146,6 +154,8 @@ private:
bool m_fullPage; bool m_fullPage;
bool m_oldPrintMode; bool m_oldPrintMode;
bool m_resetPageNumber; bool m_resetPageNumber;
bool m_isExtendedInDesignMode;
int m_extendedHeight;
}; };
typedef QList<PageItemDesignIntf::Ptr> ReportPages; typedef QList<PageItemDesignIntf::Ptr> ReportPages;