0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-01-11 17:18:10 +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);
}
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 (h<item->height()) h=item->height();
w+=item->width();
if (item->isVisible()){
if (h<item->height()) 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()<childItems().size()-1){
m_children.clear();
foreach (BaseDesignIntf* item, childBaseItems()) {
@ -303,12 +314,14 @@ void HorizontalLayout::relocateChildren()
}
}
qSort(m_children.begin(),m_children.end(),lessThen);
qreal curX = 0;
qreal curX = spaceBorder;
m_isRelocating = true;
foreach (BaseDesignIntf* item, m_children) {
item->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;

View File

@ -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();

View File

@ -581,7 +581,8 @@ qreal BandDesignIntf::findMaxBottom()
foreach(QGraphicsItem* item,childItems()){
BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(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()){

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)
{
if (m_itemAlign != itemAlign){

View File

@ -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<QString> propertyNames);
void itemAlignChanged(BaseDesignIntf* item, const ItemAlign& oldValue, const ItemAlign& newValue);
void itemVisibleHasChanged(BaseDesignIntf* item);
};
} //namespace LimeReport