From 9de9cc3ebf1bf76d34de2b3dcebbeceef8788b48 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Thu, 25 Jul 2024 18:32:30 +0300 Subject: [PATCH] Layout undo has been fixed --- limereport/items/lrabstractlayout.cpp | 15 ++++++++++++++- limereport/items/lrabstractlayout.h | 3 ++- limereport/items/lrhorizontallayout.cpp | 24 +++++++++++++----------- limereport/items/lrhorizontallayout.h | 2 +- limereport/items/lrverticallayout.cpp | 12 ------------ limereport/items/lrverticallayout.h | 2 +- limereport/lrbasedesignintf.cpp | 5 ----- limereport/lrbasedesignintf.h | 2 +- 8 files changed, 32 insertions(+), 33 deletions(-) diff --git a/limereport/items/lrabstractlayout.cpp b/limereport/items/lrabstractlayout.cpp index 1f59848..b1b9e0c 100644 --- a/limereport/items/lrabstractlayout.cpp +++ b/limereport/items/lrabstractlayout.cpp @@ -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; ipos() == item->pos()){ + layoutsChildren().insert(i, item); + inserted = true; + break; + } + } + if (!inserted) layoutsChildren().append(item); +} + void AbstractLayout::slotOnChildDestroy(QObject* child) { m_children.removeAll(static_cast(child)); diff --git a/limereport/items/lrabstractlayout.h b/limereport/items/lrabstractlayout.h index 84e8807..6d32391 100644 --- a/limereport/items/lrabstractlayout.h +++ b/limereport/items/lrabstractlayout.h @@ -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); diff --git a/limereport/items/lrhorizontallayout.cpp b/limereport/items/lrhorizontallayout.cpp index 5326070..359372b 100644 --- a/limereport/items/lrhorizontallayout.cpp +++ b/limereport/items/lrhorizontallayout.cpp @@ -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; ipos() == item->pos()){ +// layoutsChildren().insert(i, item); +// inserted = true; +// break; +// } +// } +// if (!inserted) layoutsChildren().append(item); +// } } // namespace LimeReport diff --git a/limereport/items/lrhorizontallayout.h b/limereport/items/lrhorizontallayout.h index fa442e2..c26fb1d 100644 --- a/limereport/items/lrhorizontallayout.h +++ b/limereport/items/lrhorizontallayout.h @@ -62,7 +62,7 @@ private: void sortChildren(); void divideSpace(); void placeItemInLayout(BaseDesignIntf* item); - void insertItemInLayout(BaseDesignIntf* item); + // void insertItemInLayout(BaseDesignIntf* item); }; } //namespace LimeReport diff --git a/limereport/items/lrverticallayout.cpp b/limereport/items/lrverticallayout.cpp index f4a6325..2fbd19b 100644 --- a/limereport/items/lrverticallayout.cpp +++ b/limereport/items/lrverticallayout.cpp @@ -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 diff --git a/limereport/items/lrverticallayout.h b/limereport/items/lrverticallayout.h index 90ecb0a..8b54782 100644 --- a/limereport/items/lrverticallayout.h +++ b/limereport/items/lrverticallayout.h @@ -27,7 +27,7 @@ private: void sortChildren(); void divideSpace(); void placeItemInLayout(BaseDesignIntf* item); - void insertItemInLayout(BaseDesignIntf* item); + // void insertItemInLayout(BaseDesignIntf* item); }; } // namespace LimeReport diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index d66efeb..ec9271b 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -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){ diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 22be951..758e2cb 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -449,7 +449,7 @@ private: QFont m_font; QColor m_fontColor; bool m_fixedPos; - qreal m_borderLineSize; + qreal m_borderLineSize; QRectF m_rect;