mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 04:33:03 +03:00
Layouts have been refactored
This commit is contained in:
parent
d32b42d933
commit
72fb6692c6
@ -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; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && layoutsChildren().size()>i+1){ return layoutsChildren()[i+1];}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item)
|
||||
{
|
||||
rebuildChildrenIfNeeded();
|
||||
for (int i=0; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && i!=0){ return layoutsChildren()[i-1];}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildDestroy(QObject* child)
|
||||
{
|
||||
m_children.removeAll(static_cast<BaseDesignIntf*>(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;
|
||||
|
@ -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:
|
||||
|
@ -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; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && layoutsChildren().size()>i+1){ return layoutsChildren()[i+1];}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BaseDesignIntf* HorizontalLayout::findPrior(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; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && i!=0){ return layoutsChildren()[i-1];}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HorizontalLayout::divideSpace(){
|
||||
setIsRelocating(true);
|
||||
qreal itemsSumSize = 0;
|
||||
|
@ -53,16 +53,13 @@ public:
|
||||
protected:
|
||||
void updateLayoutSize();
|
||||
void relocateChildren();
|
||||
BaseDesignIntf *findNext(BaseDesignIntf *item);
|
||||
BaseDesignIntf *findPrior(BaseDesignIntf *item);
|
||||
|
||||
bool canBeSplitted(int height) const;
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
|
||||
|
||||
void setItemAlign(const ItemAlign &itemAlign);
|
||||
|
||||
private:
|
||||
void sortChildren();
|
||||
void divideSpace();
|
||||
void placeItemInLayout(BaseDesignIntf* item);
|
||||
void insertItemInLayout(BaseDesignIntf* item);
|
||||
|
@ -142,6 +142,11 @@ BaseDesignIntf* VerticalLayout::cloneBottomPart(int height, QObject* owner, QGra
|
||||
return bottomPart;
|
||||
}
|
||||
|
||||
void VerticalLayout::sortChildren()
|
||||
{
|
||||
qSort(layoutsChildren().begin(),layoutsChildren().end(),verticalLessThen);
|
||||
}
|
||||
|
||||
void VerticalLayout::divideSpace()
|
||||
{
|
||||
setIsRelocating(true);
|
||||
@ -187,34 +192,4 @@ void VerticalLayout::insertItemInLayout(BaseDesignIntf* item)
|
||||
}
|
||||
}
|
||||
|
||||
BaseDesignIntf*VerticalLayout::findNext(BaseDesignIntf* item)
|
||||
{
|
||||
if (layoutsChildren().count() < childItems().size()-1){
|
||||
layoutsChildren().clear();
|
||||
foreach (BaseDesignIntf* childItem, childBaseItems()) {
|
||||
layoutsChildren().append(childItem);
|
||||
}
|
||||
}
|
||||
qSort(layoutsChildren().begin(),layoutsChildren().end(),verticalLessThen);
|
||||
for (int i=0; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && layoutsChildren().size()>i+1){ return layoutsChildren()[i+1];}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BaseDesignIntf*VerticalLayout::findPrior(BaseDesignIntf* item)
|
||||
{
|
||||
if (layoutsChildren().count()<childItems().size()-1){
|
||||
layoutsChildren().clear();
|
||||
foreach (BaseDesignIntf* childItem, childBaseItems()) {
|
||||
layoutsChildren().append(childItem);
|
||||
}
|
||||
}
|
||||
qSort(layoutsChildren().begin(),layoutsChildren().end(),verticalLessThen);
|
||||
for (int i=0; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && i!=0){ return layoutsChildren()[i-1];}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -24,13 +24,10 @@ protected:
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
|
||||
private:
|
||||
void sortChildren();
|
||||
void divideSpace();
|
||||
void placeItemInLayout(BaseDesignIntf* item);
|
||||
void insertItemInLayout(BaseDesignIntf* item);
|
||||
BaseDesignIntf *findNext(BaseDesignIntf *item);
|
||||
BaseDesignIntf *findPrior(BaseDesignIntf* item);
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
Loading…
Reference in New Issue
Block a user