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

Layout painting has been refactored

This commit is contained in:
Arin Alexander 2019-01-15 13:59:00 +03:00
parent 10015ed783
commit 7bc3a7e1cd
3 changed files with 27 additions and 14 deletions

View File

@ -116,22 +116,32 @@ bool AbstractLayout::isEmpty() const
return (isEmpty && allItemsIsText);
}
void AbstractLayout::paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget)
void AbstractLayout::paintChild(BaseDesignIntf *child, QPointF parentPos, QPainter *painter)
{
if (isSelected()){
foreach( BaseDesignIntf* item, m_children){
ppainter->save();
ppainter->setPen(Qt::red);
ppainter->drawRect(
QRectF(item->pos().x(),item->pos().y(),
item->rect().bottomRight().rx(),
item->rect().bottomRight().ry()
)
);
ppainter->restore();
if (!child->childBaseItems().isEmpty()){
foreach (BaseDesignIntf* item, child->childBaseItems()) {
paintChild(item, child->pos(),painter);
}
}
LayoutDesignIntf::paint(ppainter, option, widget);
painter->drawRect(
QRectF(parentPos.x()+child->pos().x(), parentPos.y()+child->pos().y(),
child->rect().bottomRight().rx(),
child->rect().bottomRight().ry()
)
);
}
void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
if (isSelected()){
painter->save();
painter->setPen(Qt::red);
foreach( BaseDesignIntf* item, m_children){
paintChild(item, QPointF(0,0), painter);
}
painter->restore();
}
LayoutDesignIntf::paint(painter, option, widget);
}
int AbstractLayout::childrenCount()

View File

@ -24,7 +24,8 @@ public:
void addChild(BaseDesignIntf *item,bool updateSize=true);
void restoreChild(BaseDesignIntf *item);
bool isEmpty() const;
void paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget);
void paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter);
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
bool hideEmptyItems() const;
void setHideEmptyItems(bool hideEmptyItems);

View File

@ -2200,6 +2200,7 @@ void InsertHLayoutCommand::undoIt()
bi->setPos(m_elements.value(bi->objectName()));
bi->setFixedPos(false);
bi->setPossibleResizeDirectionFlags(BaseDesignIntf::AllDirections);
bi->setVisible(true);
}
}
page()->removeReportItem(layout,false);
@ -2384,6 +2385,7 @@ void InsertVLayoutCommand::undoIt()
bi->setPos(m_elements.value(bi->objectName()));
bi->setFixedPos(false);
bi->setPossibleResizeDirectionFlags(BaseDesignIntf::AllDirections);
bi->setVisible(true);
}
}
page()->removeReportItem(layout,false);