From fa89f21930296590b733dbb1dab561539e4ac284 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 20 Apr 2016 20:59:33 +0400 Subject: [PATCH] Height calculation has been fixed --- limereport/items/lrhorizontallayout.cpp | 37 +++++++++++++++++++------ limereport/items/lrhorizontallayout.h | 2 ++ limereport/lrbanddesignintf.cpp | 6 +++- limereport/lrbasedesignintf.cpp | 8 ++++++ limereport/lrbasedesignintf.h | 7 +++-- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/limereport/items/lrhorizontallayout.cpp b/limereport/items/lrhorizontallayout.cpp index bc764f6..ee07907 100644 --- a/limereport/items/lrhorizontallayout.cpp +++ b/limereport/items/lrhorizontallayout.cpp @@ -196,6 +196,13 @@ void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign) BaseDesignIntf::setItemAlign(itemAlign); } +void HorizontalLayout::setBorderLinesFlags(BaseDesignIntf::BorderLines flags) +{ + BaseDesignIntf::setBorderLinesFlags(flags); + if (flags!=0) + relocateChildren(); +} + void HorizontalLayout::restoreChild(BaseDesignIntf* item){ if (m_children.contains(item)) return; @@ -252,6 +259,7 @@ void HorizontalLayout::addChild(BaseDesignIntf *item, bool updateSize) connect(item,SIGNAL(destroyed(QObject*)),this,SLOT(slotOnChildDestroy(QObject*))); connect(item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))); + connect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),this,SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))); if (updateSize){ relocateChildren(); @@ -284,11 +292,13 @@ void HorizontalLayout::objectLoadFinished() void HorizontalLayout::updateLayoutSize() { - int w = 0; + int w = ((borderLines() != 0) ? borderLineSize() : 0)*2; qreal h = 0; foreach(BaseDesignIntf* item, m_children){ - if (hheight()) h=item->height(); - w+=item->width(); + if (item->isVisible()){ + if (hheight()) h=item->height(); + w+=item->width(); + } } if (h>0) setHeight(h); setWidth(w); @@ -296,6 +306,7 @@ void HorizontalLayout::updateLayoutSize() void HorizontalLayout::relocateChildren() { + int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; if (m_children.count()setPos(curX,0); - curX+=item->width(); - item->setHeight(height()); + if (item->isVisible()){ + item->setPos(curX,spaceBorder); + curX+=item->width(); + item->setHeight(height()-(spaceBorder * 2)); + } } m_isRelocating = false; } @@ -419,7 +432,7 @@ void HorizontalLayout::divideSpace(){ void HorizontalLayout::slotOnChildGeometryChanged(QObject *item, QRectF newGeometry, QRectF oldGeometry) { if (!m_isRelocating){ - setHeight(newGeometry.height()); + //setHeight(newGeometry.height()); if (m_layoutType == Layout){ relocateChildren(); updateLayoutSize(); @@ -442,6 +455,14 @@ void HorizontalLayout::slotOnChildItemAlignChanged(BaseDesignIntf *item, const B item->setPosibleResizeDirectionFlags(ResizeBottom | ResizeRight); } +void HorizontalLayout::slotOnChildVisibleHasChanged(BaseDesignIntf *) +{ + relocateChildren(); + if (m_layoutType == Table && !m_isRelocating){ + divideSpace(); + } +} + HorizontalLayout::LayoutType HorizontalLayout::layoutType() const { return m_layoutType; diff --git a/limereport/items/lrhorizontallayout.h b/limereport/items/lrhorizontallayout.h index c00b92b..67cceef 100644 --- a/limereport/items/lrhorizontallayout.h +++ b/limereport/items/lrhorizontallayout.h @@ -94,10 +94,12 @@ protected: BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0); void setItemAlign(const ItemAlign &itemAlign); + void setBorderLinesFlags(BorderLines flags); private slots: void slotOnChildDestroy(QObject *child); void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry); void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&); + void slotOnChildVisibleHasChanged(BaseDesignIntf*); //void slotOnPosChanged(QObject*, QPointF newPos, QPointF ); private: void divideSpace(); diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index d4445dd..c8d2183 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -581,7 +581,8 @@ qreal BandDesignIntf::findMaxBottom() foreach(QGraphicsItem* item,childItems()){ BaseDesignIntf* subItem = dynamic_cast(item); if(subItem) - if (subItem->geometry().bottom()>maxBottom) maxBottom=subItem->geometry().bottom(); + if ( subItem->isVisible() && (subItem->geometry().bottom()>maxBottom) ) + maxBottom=subItem->geometry().bottom(); } return maxBottom; } @@ -789,6 +790,9 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p { qreal spaceBorder=0; if (keepBottomSpaceOption()) spaceBorder=height()-findMaxBottom(); + if (borderLines()!=0){ + spaceBorder += borderLineSize(); + } snapshotItemsLayout(); arrangeSubItems(pass, dataManager); if (autoHeight()){ diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index bf94c02..5fe5db7 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -641,6 +641,14 @@ void BaseDesignIntf::setBorderColor(const QColor &borderColor) } } +void BaseDesignIntf::setItemVisible(const bool &value) +{ + if (isVisible()!=value){ + setVisible(value); + emit itemVisibleHasChanged(this); + } +} + void BaseDesignIntf::setItemAlign(const ItemAlign &itemAlign) { if (m_itemAlign != itemAlign){ diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 78a60a6..6d164c1 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -92,7 +92,7 @@ class BaseDesignIntf : Q_PROPERTY(BorderLines borders READ borderLines WRITE setBorderLinesFlags) Q_PROPERTY(QString parentName READ parentReportItemName WRITE setParentReportItem DESIGNABLE false) Q_PROPERTY(int borderLineSize READ borderLineSize WRITE setBorderLineSize) - Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible DESIGNABLE false) + Q_PROPERTY(bool isVisible READ isVisible WRITE setItemVisible DESIGNABLE false) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) public: @@ -185,7 +185,7 @@ public: void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode); ItemMode itemMode() const {return m_itemMode;} - void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags); + virtual void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags); void setGeometryProperty(QRectF rect); PageDesignIntf* page(); @@ -244,7 +244,7 @@ public: virtual bool isBand(){return false;} QColor borderColor() const; void setBorderColor(const QColor &borderColor); - + void setItemVisible(const bool& value); protected: //ICollectionContainer @@ -357,6 +357,7 @@ signals: void propertyObjectNameChanged(const QString& oldValue, const QString& newValue); void propertyesChanged(QVector propertyNames); void itemAlignChanged(BaseDesignIntf* item, const ItemAlign& oldValue, const ItemAlign& newValue); + void itemVisibleHasChanged(BaseDesignIntf* item); }; } //namespace LimeReport