mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 20:22:58 +03:00
Layout undo has been fixed
This commit is contained in:
parent
f3d2efe8ca
commit
9de9cc3ebf
@ -48,7 +48,7 @@ void AbstractLayout::setLayoutType(const LayoutType& layoutType)
|
||||
|
||||
void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
|
||||
{
|
||||
placeItemInLayout(item);
|
||||
if (updateSize) placeItemInLayout(item);
|
||||
|
||||
m_children.append(item);
|
||||
item->setParentItem(this);
|
||||
@ -321,6 +321,19 @@ BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AbstractLayout::insertItemInLayout(BaseDesignIntf *item){
|
||||
bool inserted = false;
|
||||
for (int i=0; i<layoutsChildren().length(); ++i){
|
||||
BaseDesignIntf* child = layoutsChildren()[i];
|
||||
if (child->pos() == item->pos()){
|
||||
layoutsChildren().insert(i, item);
|
||||
inserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inserted) layoutsChildren().append(item);
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildDestroy(QObject* child)
|
||||
{
|
||||
m_children.removeAll(static_cast<BaseDesignIntf*>(child));
|
||||
|
@ -55,6 +55,7 @@ protected:
|
||||
void rebuildChildrenIfNeeded();
|
||||
void connectToLayout(BaseDesignIntf* item);
|
||||
void disconnectFromLayout(BaseDesignIntf* item);
|
||||
virtual void insertItemInLayout(BaseDesignIntf* item);
|
||||
private:
|
||||
virtual void sortChildren() = 0;
|
||||
virtual void divideSpace() = 0;
|
||||
@ -63,7 +64,7 @@ private:
|
||||
virtual BaseDesignIntf* findNext(BaseDesignIntf *item);
|
||||
virtual BaseDesignIntf* findPrior(BaseDesignIntf *item);
|
||||
virtual void placeItemInLayout(BaseDesignIntf* item) = 0;
|
||||
virtual void insertItemInLayout(BaseDesignIntf* item) = 0;
|
||||
|
||||
private slots:
|
||||
void slotOnChildDestroy(QObject *child);
|
||||
void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
|
||||
|
@ -238,16 +238,18 @@ void HorizontalLayout::placeItemInLayout(BaseDesignIntf* item)
|
||||
item->setPos(0, 0);
|
||||
}
|
||||
|
||||
void HorizontalLayout::insertItemInLayout(BaseDesignIntf* item)
|
||||
{
|
||||
foreach (BaseDesignIntf* child, childBaseItems()) {
|
||||
if (child->pos() == item->pos()){
|
||||
int index = layoutsChildren().indexOf(child)-1;
|
||||
layoutsChildren().insert(index, item);
|
||||
child->setPos(item->pos().x()+item->width(), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// void HorizontalLayout::insertItemInLayout(BaseDesignIntf* item)
|
||||
// {
|
||||
// bool inserted = false;
|
||||
// for (int i=0; i<layoutsChildren().length(); ++i){
|
||||
// BaseDesignIntf* child = layoutsChildren()[i];
|
||||
// if (child->pos() == item->pos()){
|
||||
// layoutsChildren().insert(i, item);
|
||||
// inserted = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!inserted) layoutsChildren().append(item);
|
||||
// }
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -62,7 +62,7 @@ private:
|
||||
void sortChildren();
|
||||
void divideSpace();
|
||||
void placeItemInLayout(BaseDesignIntf* item);
|
||||
void insertItemInLayout(BaseDesignIntf* item);
|
||||
// void insertItemInLayout(BaseDesignIntf* item);
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
|
@ -187,16 +187,4 @@ void VerticalLayout::placeItemInLayout(BaseDesignIntf* item)
|
||||
item->setPos(0, 0);
|
||||
}
|
||||
|
||||
void VerticalLayout::insertItemInLayout(BaseDesignIntf* item)
|
||||
{
|
||||
foreach (BaseDesignIntf* child, childBaseItems()) {
|
||||
if (child->pos() == item->pos()){
|
||||
int index = layoutsChildren().indexOf(child)-1;
|
||||
layoutsChildren().insert(index, item);
|
||||
child->setPos(0, item->pos().y()+item->height());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -27,7 +27,7 @@ private:
|
||||
void sortChildren();
|
||||
void divideSpace();
|
||||
void placeItemInLayout(BaseDesignIntf* item);
|
||||
void insertItemInLayout(BaseDesignIntf* item);
|
||||
// void insertItemInLayout(BaseDesignIntf* item);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -432,13 +432,8 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
|
||||
drawBorder(ppainter, rect());
|
||||
if(m_shadow)
|
||||
drawShadow(ppainter, rect(), 6);
|
||||
// if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);}
|
||||
// if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);}
|
||||
drawResizeZone(ppainter);
|
||||
ppainter->restore();
|
||||
// if (m_hovered) ppainter->drawImage(
|
||||
// QRectF(QPointF(rect().topRight().x()-24, rect().bottomLeft().y()-24),
|
||||
// QSizeF(24, 24)),QImage(":/items/images/settings.png"));
|
||||
}
|
||||
|
||||
QColor calcColor(QColor color){
|
||||
|
@ -449,7 +449,7 @@ private:
|
||||
QFont m_font;
|
||||
QColor m_fontColor;
|
||||
bool m_fixedPos;
|
||||
qreal m_borderLineSize;
|
||||
qreal m_borderLineSize;
|
||||
|
||||
|
||||
QRectF m_rect;
|
||||
|
Loading…
Reference in New Issue
Block a user