diff --git a/limereport/items/lrabstractlayout.cpp b/limereport/items/lrabstractlayout.cpp index 47283b7..3b143c7 100644 --- a/limereport/items/lrabstractlayout.cpp +++ b/limereport/items/lrabstractlayout.cpp @@ -259,6 +259,34 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight); } +void AbstractLayout::rebuildChildrenIfNeeded(){ + if (layoutsChildren().count() < childItems().size()-1){ + layoutsChildren().clear(); + foreach (BaseDesignIntf* childItem, childBaseItems()) { + layoutsChildren().append(childItem); + } + sortChildren(); + } +} + +BaseDesignIntf *AbstractLayout::findNext(BaseDesignIntf *item) +{ + rebuildChildrenIfNeeded(); + for (int i=0; ii+1){ return layoutsChildren()[i+1];} + } + return 0; +} + +BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item) +{ + rebuildChildrenIfNeeded(); + for (int i=0; i(child)); @@ -323,6 +351,13 @@ void AbstractLayout::setHideEmptyItems(bool hideEmptyItems) } } +BaseDesignIntf *AbstractLayout::at(int index) +{ + rebuildChildrenIfNeeded(); + if (layoutsChildren().size() > index) return layoutsChildren()[index]; + return 0; +} + LayoutMarker* AbstractLayout::layoutMarker() const { return m_layoutMarker; diff --git a/limereport/items/lrabstractlayout.h b/limereport/items/lrabstractlayout.h index 6f5e796..90d9b9d 100644 --- a/limereport/items/lrabstractlayout.h +++ b/limereport/items/lrabstractlayout.h @@ -29,7 +29,7 @@ public: bool hideEmptyItems() const; void setHideEmptyItems(bool hideEmptyItems); - + BaseDesignIntf* at(int index); protected: int childrenCount(); void beforeDelete(); @@ -42,12 +42,14 @@ protected: bool isNeedUpdateSize(RenderPass pass) const; QVariant itemChange(GraphicsItemChange change, const QVariant &value); void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight); + void rebuildChildrenIfNeeded(); private: + virtual void sortChildren() = 0; virtual void divideSpace() = 0; virtual void updateLayoutSize() = 0; virtual void relocateChildren() = 0; - virtual BaseDesignIntf *findNext(BaseDesignIntf *item) = 0; - virtual BaseDesignIntf *findPrior(BaseDesignIntf *item) = 0; + virtual BaseDesignIntf* findNext(BaseDesignIntf *item); + virtual BaseDesignIntf* findPrior(BaseDesignIntf *item); virtual void placeItemInLayout(BaseDesignIntf* item) = 0; virtual void insertItemInLayout(BaseDesignIntf* item) = 0; private slots: diff --git a/limereport/items/lrhorizontallayout.cpp b/limereport/items/lrhorizontallayout.cpp index 0fd3207..e5cd0af 100644 --- a/limereport/items/lrhorizontallayout.cpp +++ b/limereport/items/lrhorizontallayout.cpp @@ -138,6 +138,11 @@ void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign) BaseDesignIntf::setItemAlign(itemAlign); } +void HorizontalLayout::sortChildren() +{ + qSort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen); +} + void HorizontalLayout::updateLayoutSize() { int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; @@ -183,34 +188,6 @@ void HorizontalLayout::relocateChildren() setIsRelocating(false); } -BaseDesignIntf* HorizontalLayout::findNext(BaseDesignIntf* item){ - if (layoutsChildren().count() < childItems().size()-1){ - layoutsChildren().clear(); - foreach (BaseDesignIntf* childItem, childBaseItems()) { - layoutsChildren().append(childItem); - } - } - qSort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen); - for (int i=0; ii+1){ return layoutsChildren()[i+1];} - } - return 0; -} - -BaseDesignIntf* HorizontalLayout::findPrior(BaseDesignIntf* item){ - if (layoutsChildren().count()i+1){ return layoutsChildren()[i+1];} - } - return 0; -} - -BaseDesignIntf*VerticalLayout::findPrior(BaseDesignIntf* item) -{ - if (layoutsChildren().count()