mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-23 16: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)
|
void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
|
||||||
{
|
{
|
||||||
placeItemInLayout(item);
|
if (updateSize) placeItemInLayout(item);
|
||||||
|
|
||||||
m_children.append(item);
|
m_children.append(item);
|
||||||
item->setParentItem(this);
|
item->setParentItem(this);
|
||||||
@ -321,6 +321,19 @@ BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item)
|
|||||||
return 0;
|
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)
|
void AbstractLayout::slotOnChildDestroy(QObject* child)
|
||||||
{
|
{
|
||||||
m_children.removeAll(static_cast<BaseDesignIntf*>(child));
|
m_children.removeAll(static_cast<BaseDesignIntf*>(child));
|
||||||
|
@ -55,6 +55,7 @@ protected:
|
|||||||
void rebuildChildrenIfNeeded();
|
void rebuildChildrenIfNeeded();
|
||||||
void connectToLayout(BaseDesignIntf* item);
|
void connectToLayout(BaseDesignIntf* item);
|
||||||
void disconnectFromLayout(BaseDesignIntf* item);
|
void disconnectFromLayout(BaseDesignIntf* item);
|
||||||
|
virtual void insertItemInLayout(BaseDesignIntf* item);
|
||||||
private:
|
private:
|
||||||
virtual void sortChildren() = 0;
|
virtual void sortChildren() = 0;
|
||||||
virtual void divideSpace() = 0;
|
virtual void divideSpace() = 0;
|
||||||
@ -63,7 +64,7 @@ private:
|
|||||||
virtual BaseDesignIntf* findNext(BaseDesignIntf *item);
|
virtual BaseDesignIntf* findNext(BaseDesignIntf *item);
|
||||||
virtual BaseDesignIntf* findPrior(BaseDesignIntf *item);
|
virtual BaseDesignIntf* findPrior(BaseDesignIntf *item);
|
||||||
virtual void placeItemInLayout(BaseDesignIntf* item) = 0;
|
virtual void placeItemInLayout(BaseDesignIntf* item) = 0;
|
||||||
virtual void insertItemInLayout(BaseDesignIntf* item) = 0;
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotOnChildDestroy(QObject *child);
|
void slotOnChildDestroy(QObject *child);
|
||||||
void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
|
void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
|
||||||
|
@ -238,16 +238,18 @@ void HorizontalLayout::placeItemInLayout(BaseDesignIntf* item)
|
|||||||
item->setPos(0, 0);
|
item->setPos(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HorizontalLayout::insertItemInLayout(BaseDesignIntf* item)
|
// void HorizontalLayout::insertItemInLayout(BaseDesignIntf* item)
|
||||||
{
|
// {
|
||||||
foreach (BaseDesignIntf* child, childBaseItems()) {
|
// bool inserted = false;
|
||||||
if (child->pos() == item->pos()){
|
// for (int i=0; i<layoutsChildren().length(); ++i){
|
||||||
int index = layoutsChildren().indexOf(child)-1;
|
// BaseDesignIntf* child = layoutsChildren()[i];
|
||||||
layoutsChildren().insert(index, item);
|
// if (child->pos() == item->pos()){
|
||||||
child->setPos(item->pos().x()+item->width(), 0);
|
// layoutsChildren().insert(i, item);
|
||||||
break;
|
// inserted = true;
|
||||||
}
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// if (!inserted) layoutsChildren().append(item);
|
||||||
|
// }
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
void sortChildren();
|
void sortChildren();
|
||||||
void divideSpace();
|
void divideSpace();
|
||||||
void placeItemInLayout(BaseDesignIntf* item);
|
void placeItemInLayout(BaseDesignIntf* item);
|
||||||
void insertItemInLayout(BaseDesignIntf* item);
|
// void insertItemInLayout(BaseDesignIntf* item);
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace LimeReport
|
} //namespace LimeReport
|
||||||
|
@ -187,16 +187,4 @@ void VerticalLayout::placeItemInLayout(BaseDesignIntf* item)
|
|||||||
item->setPos(0, 0);
|
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
|
} // namespace LimeReport
|
||||||
|
@ -27,7 +27,7 @@ private:
|
|||||||
void sortChildren();
|
void sortChildren();
|
||||||
void divideSpace();
|
void divideSpace();
|
||||||
void placeItemInLayout(BaseDesignIntf* item);
|
void placeItemInLayout(BaseDesignIntf* item);
|
||||||
void insertItemInLayout(BaseDesignIntf* item);
|
// void insertItemInLayout(BaseDesignIntf* item);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
@ -432,13 +432,8 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
|
|||||||
drawBorder(ppainter, rect());
|
drawBorder(ppainter, rect());
|
||||||
if(m_shadow)
|
if(m_shadow)
|
||||||
drawShadow(ppainter, rect(), 6);
|
drawShadow(ppainter, rect(), 6);
|
||||||
// if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);}
|
|
||||||
// if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);}
|
|
||||||
drawResizeZone(ppainter);
|
drawResizeZone(ppainter);
|
||||||
ppainter->restore();
|
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){
|
QColor calcColor(QColor color){
|
||||||
|
@ -449,7 +449,7 @@ private:
|
|||||||
QFont m_font;
|
QFont m_font;
|
||||||
QColor m_fontColor;
|
QColor m_fontColor;
|
||||||
bool m_fixedPos;
|
bool m_fixedPos;
|
||||||
qreal m_borderLineSize;
|
qreal m_borderLineSize;
|
||||||
|
|
||||||
|
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
|
Loading…
Reference in New Issue
Block a user