0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-03-15 06:46:00 +03:00

Height calculation has been fixed

This commit is contained in:
Arin Alexander 2016-04-20 20:59:33 +04:00
parent 6a25ac752f
commit fa89f21930
5 changed files with 48 additions and 12 deletions

View File

@ -196,6 +196,13 @@ void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign)
BaseDesignIntf::setItemAlign(itemAlign); BaseDesignIntf::setItemAlign(itemAlign);
} }
void HorizontalLayout::setBorderLinesFlags(BaseDesignIntf::BorderLines flags)
{
BaseDesignIntf::setBorderLinesFlags(flags);
if (flags!=0)
relocateChildren();
}
void HorizontalLayout::restoreChild(BaseDesignIntf* item){ void HorizontalLayout::restoreChild(BaseDesignIntf* item){
if (m_children.contains(item)) return; 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(destroyed(QObject*)),this,SLOT(slotOnChildDestroy(QObject*)));
connect(item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))); connect(item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF)));
connect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),this,SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*)));
if (updateSize){ if (updateSize){
relocateChildren(); relocateChildren();
@ -284,18 +292,21 @@ void HorizontalLayout::objectLoadFinished()
void HorizontalLayout::updateLayoutSize() void HorizontalLayout::updateLayoutSize()
{ {
int w = 0; int w = ((borderLines() != 0) ? borderLineSize() : 0)*2;
qreal h = 0; qreal h = 0;
foreach(BaseDesignIntf* item, m_children){ foreach(BaseDesignIntf* item, m_children){
if (item->isVisible()){
if (h<item->height()) h=item->height(); if (h<item->height()) h=item->height();
w+=item->width(); w+=item->width();
} }
}
if (h>0) setHeight(h); if (h>0) setHeight(h);
setWidth(w); setWidth(w);
} }
void HorizontalLayout::relocateChildren() void HorizontalLayout::relocateChildren()
{ {
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
if (m_children.count()<childItems().size()-1){ if (m_children.count()<childItems().size()-1){
m_children.clear(); m_children.clear();
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* item, childBaseItems()) {
@ -303,12 +314,14 @@ void HorizontalLayout::relocateChildren()
} }
} }
qSort(m_children.begin(),m_children.end(),lessThen); qSort(m_children.begin(),m_children.end(),lessThen);
qreal curX = 0; qreal curX = spaceBorder;
m_isRelocating = true; m_isRelocating = true;
foreach (BaseDesignIntf* item, m_children) { foreach (BaseDesignIntf* item, m_children) {
item->setPos(curX,0); if (item->isVisible()){
item->setPos(curX,spaceBorder);
curX+=item->width(); curX+=item->width();
item->setHeight(height()); item->setHeight(height()-(spaceBorder * 2));
}
} }
m_isRelocating = false; m_isRelocating = false;
} }
@ -419,7 +432,7 @@ void HorizontalLayout::divideSpace(){
void HorizontalLayout::slotOnChildGeometryChanged(QObject *item, QRectF newGeometry, QRectF oldGeometry) void HorizontalLayout::slotOnChildGeometryChanged(QObject *item, QRectF newGeometry, QRectF oldGeometry)
{ {
if (!m_isRelocating){ if (!m_isRelocating){
setHeight(newGeometry.height()); //setHeight(newGeometry.height());
if (m_layoutType == Layout){ if (m_layoutType == Layout){
relocateChildren(); relocateChildren();
updateLayoutSize(); updateLayoutSize();
@ -442,6 +455,14 @@ void HorizontalLayout::slotOnChildItemAlignChanged(BaseDesignIntf *item, const B
item->setPosibleResizeDirectionFlags(ResizeBottom | ResizeRight); item->setPosibleResizeDirectionFlags(ResizeBottom | ResizeRight);
} }
void HorizontalLayout::slotOnChildVisibleHasChanged(BaseDesignIntf *)
{
relocateChildren();
if (m_layoutType == Table && !m_isRelocating){
divideSpace();
}
}
HorizontalLayout::LayoutType HorizontalLayout::layoutType() const HorizontalLayout::LayoutType HorizontalLayout::layoutType() const
{ {
return m_layoutType; return m_layoutType;

View File

@ -94,10 +94,12 @@ protected:
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0); BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
void setItemAlign(const ItemAlign &itemAlign); void setItemAlign(const ItemAlign &itemAlign);
void setBorderLinesFlags(BorderLines flags);
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);
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&); void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
void slotOnChildVisibleHasChanged(BaseDesignIntf*);
//void slotOnPosChanged(QObject*, QPointF newPos, QPointF ); //void slotOnPosChanged(QObject*, QPointF newPos, QPointF );
private: private:
void divideSpace(); void divideSpace();

View File

@ -581,7 +581,8 @@ qreal BandDesignIntf::findMaxBottom()
foreach(QGraphicsItem* item,childItems()){ foreach(QGraphicsItem* item,childItems()){
BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(item); BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(item);
if(subItem) if(subItem)
if (subItem->geometry().bottom()>maxBottom) maxBottom=subItem->geometry().bottom(); if ( subItem->isVisible() && (subItem->geometry().bottom()>maxBottom) )
maxBottom=subItem->geometry().bottom();
} }
return maxBottom; return maxBottom;
} }
@ -789,6 +790,9 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
{ {
qreal spaceBorder=0; qreal spaceBorder=0;
if (keepBottomSpaceOption()) spaceBorder=height()-findMaxBottom(); if (keepBottomSpaceOption()) spaceBorder=height()-findMaxBottom();
if (borderLines()!=0){
spaceBorder += borderLineSize();
}
snapshotItemsLayout(); snapshotItemsLayout();
arrangeSubItems(pass, dataManager); arrangeSubItems(pass, dataManager);
if (autoHeight()){ if (autoHeight()){

View File

@ -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) void BaseDesignIntf::setItemAlign(const ItemAlign &itemAlign)
{ {
if (m_itemAlign != itemAlign){ if (m_itemAlign != itemAlign){

View File

@ -92,7 +92,7 @@ class BaseDesignIntf :
Q_PROPERTY(BorderLines borders READ borderLines WRITE setBorderLinesFlags) Q_PROPERTY(BorderLines borders READ borderLines WRITE setBorderLinesFlags)
Q_PROPERTY(QString parentName READ parentReportItemName WRITE setParentReportItem DESIGNABLE false) Q_PROPERTY(QString parentName READ parentReportItemName WRITE setParentReportItem DESIGNABLE false)
Q_PROPERTY(int borderLineSize READ borderLineSize WRITE setBorderLineSize) 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) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
public: public:
@ -185,7 +185,7 @@ public:
void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode); void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode);
ItemMode itemMode() const {return m_itemMode;} ItemMode itemMode() const {return m_itemMode;}
void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags); virtual void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags);
void setGeometryProperty(QRectF rect); void setGeometryProperty(QRectF rect);
PageDesignIntf* page(); PageDesignIntf* page();
@ -244,7 +244,7 @@ public:
virtual bool isBand(){return false;} virtual bool isBand(){return false;}
QColor borderColor() const; QColor borderColor() const;
void setBorderColor(const QColor &borderColor); void setBorderColor(const QColor &borderColor);
void setItemVisible(const bool& value);
protected: protected:
//ICollectionContainer //ICollectionContainer
@ -357,6 +357,7 @@ signals:
void propertyObjectNameChanged(const QString& oldValue, const QString& newValue); void propertyObjectNameChanged(const QString& oldValue, const QString& newValue);
void propertyesChanged(QVector<QString> propertyNames); void propertyesChanged(QVector<QString> propertyNames);
void itemAlignChanged(BaseDesignIntf* item, const ItemAlign& oldValue, const ItemAlign& newValue); void itemAlignChanged(BaseDesignIntf* item, const ItemAlign& oldValue, const ItemAlign& newValue);
void itemVisibleHasChanged(BaseDesignIntf* item);
}; };
} //namespace LimeReport } //namespace LimeReport