0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-10-01 11:31:10 +03:00

Fix undoing layout inside layout

This commit is contained in:
Emil Sawicki
2022-02-06 15:14:04 +01:00
parent 02ee5864a3
commit a94bedad06
7 changed files with 57 additions and 12 deletions

View File

@@ -48,7 +48,6 @@ void AbstractLayout::setLayoutType(const LayoutType& layoutType)
void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
{
placeItemInLayout(item);
m_children.append(item);
@@ -57,7 +56,7 @@ void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
item->setFixedPos(true);
item->setPossibleResizeDirectionFlags(ResizeRight | ResizeBottom);
connectTolayout(item);
connectToLayout(item);
if (updateSize){
relocateChildren();
@@ -65,19 +64,23 @@ void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
}
}
void AbstractLayout::removeChild(BaseDesignIntf *item)
{
if (!item) {
return;
}
m_children.removeAll(item);
disconnectFromLayout(item);
}
void AbstractLayout::restoreChild(BaseDesignIntf* item)
{
if (m_children.contains(item)) return;
m_isRelocating=true;
insertItemInLayout(item);
connect(item,SIGNAL(destroyed(QObject*)),this,SLOT(slotOnChildDestroy(QObject*)));
connect(item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF)));
connect(item, SIGNAL(itemAlignChanged(BaseDesignIntf*,ItemAlign,ItemAlign)),
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,ItemAlign,ItemAlign)));
connectToLayout(item);
item->setFixedPos(true);
item->setPossibleResizeDirectionFlags(ResizeRight | ResizeBottom);
@@ -252,7 +255,7 @@ void AbstractLayout::rebuildChildrenIfNeeded(){
}
}
void AbstractLayout::connectTolayout(BaseDesignIntf *item)
void AbstractLayout::connectToLayout(BaseDesignIntf *item)
{
connect(
item, SIGNAL(destroyed(QObject*)),
@@ -270,6 +273,30 @@ void AbstractLayout::connectTolayout(BaseDesignIntf *item)
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
);
connect(item, SIGNAL(itemAlignChanged(BaseDesignIntf*,ItemAlign,ItemAlign)),
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,ItemAlign,ItemAlign)));
}
void AbstractLayout::disconnectFromLayout(BaseDesignIntf *item)
{
disconnect(
item, SIGNAL(destroyed(QObject*)),
this, SLOT(slotOnChildDestroy(QObject*))
);
disconnect(
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))
);
disconnect(
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),
this, SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))
);
disconnect(
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
);
disconnect(item, SIGNAL(itemAlignChanged(BaseDesignIntf*,ItemAlign,ItemAlign)),
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,ItemAlign,ItemAlign)));
}
BaseDesignIntf *AbstractLayout::findNext(BaseDesignIntf *item)

View File

@@ -28,6 +28,7 @@ public:
void setLayoutType(const LayoutType& layoutType);
void addChild(BaseDesignIntf *item,bool updateSize=true);
void removeChild(BaseDesignIntf *item);
void restoreChild(BaseDesignIntf *item);
bool isEmpty() const;
void paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter);
@@ -52,7 +53,8 @@ protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
void rebuildChildrenIfNeeded();
void connectTolayout(BaseDesignIntf* item);
void connectToLayout(BaseDesignIntf* item);
void disconnectFromLayout(BaseDesignIntf* item);
private:
virtual void sortChildren() = 0;
virtual void divideSpace() = 0;

View File

@@ -195,7 +195,7 @@ void HorizontalLayout::relocateChildren()
setIsRelocating(false);
for (BaseDesignIntf* item : newChildren) {
connectTolayout(item);
connectToLayout(item);
}
}

View File

@@ -81,7 +81,7 @@ void VerticalLayout::relocateChildren()
setIsRelocating(false);
for (BaseDesignIntf* item : newChildren) {
connectTolayout(item);
connectToLayout(item);
}
}