mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 12:12:59 +03:00
Fix undoing layout inside layout
This commit is contained in:
parent
02ee5864a3
commit
a94bedad06
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -195,7 +195,7 @@ void HorizontalLayout::relocateChildren()
|
||||
setIsRelocating(false);
|
||||
|
||||
for (BaseDesignIntf* item : newChildren) {
|
||||
connectTolayout(item);
|
||||
connectToLayout(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ void VerticalLayout::relocateChildren()
|
||||
setIsRelocating(false);
|
||||
|
||||
for (BaseDesignIntf* item : newChildren) {
|
||||
connectTolayout(item);
|
||||
connectToLayout(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
LayoutDesignIntf(const QString& xmlTypeName, QObject* owner = 0,QGraphicsItem* parent = 0):
|
||||
ItemDesignIntf(xmlTypeName,owner,parent){}
|
||||
virtual void addChild(BaseDesignIntf *item,bool updateSize=true) = 0;
|
||||
virtual void removeChild(BaseDesignIntf *item) = 0;
|
||||
virtual void restoreChild(BaseDesignIntf *item) = 0;
|
||||
virtual int childrenCount() = 0;
|
||||
friend class BaseDesignIntf;
|
||||
|
@ -2007,6 +2007,9 @@ CommandIf::Ptr DeleteLayoutCommand::create(PageDesignIntf *page, LayoutDesignInt
|
||||
foreach (BaseDesignIntf* childItem, item->childBaseItems()){
|
||||
command->m_childItems.append(childItem->objectName());
|
||||
}
|
||||
LayoutDesignIntf* layout = dynamic_cast<LayoutDesignIntf*>(item->parent());
|
||||
if (layout)
|
||||
command->m_layoutName = layout->objectName();
|
||||
return CommandIf::Ptr(command);
|
||||
}
|
||||
|
||||
@ -2031,9 +2034,20 @@ void DeleteLayoutCommand::undoIt()
|
||||
BaseDesignIntf *item = page()->addReportItem(m_itemType);
|
||||
ItemsReaderIntf::Ptr reader = StringXMLreader::create(m_itemXML);
|
||||
if (reader->first()) reader->readItem(item);
|
||||
if (!m_layoutName.isEmpty()) {
|
||||
LayoutDesignIntf* layout = dynamic_cast<LayoutDesignIntf*>(page()->reportItemByName(m_layoutName));
|
||||
if (layout){
|
||||
layout->restoreChild(item);
|
||||
}
|
||||
page()->emitRegisterdItem(item);
|
||||
}
|
||||
foreach(QString ci, m_childItems){
|
||||
BaseDesignIntf* ri = page()->reportItemByName(ci);
|
||||
if (ri){
|
||||
LayoutDesignIntf* parentLayout = dynamic_cast<LayoutDesignIntf*>(ri->parent());
|
||||
if (parentLayout) {
|
||||
parentLayout->removeChild(ri);
|
||||
}
|
||||
dynamic_cast<LayoutDesignIntf*>(item)->addChild(ri);
|
||||
}
|
||||
page()->emitRegisterdItem(item);
|
||||
|
@ -415,6 +415,7 @@ namespace LimeReport {
|
||||
void setItem(BaseDesignIntf* item);
|
||||
private:
|
||||
QStringList m_childItems;
|
||||
QString m_layoutName;
|
||||
QString m_itemXML;
|
||||
QString m_itemType;
|
||||
QString m_itemName;
|
||||
|
Loading…
Reference in New Issue
Block a user