0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 08:34:38 +03:00

keepTopSpace property added to band

This commit is contained in:
Arin Alexander 2017-12-18 20:28:26 +03:00
parent 3867527c21
commit 207d7daaa9
4 changed files with 42 additions and 5 deletions

View File

@ -106,6 +106,7 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
m_dataSourceName(""),
m_autoHeight(true),
m_keepBottomSpace(false),
m_keepTopSpace(true),
m_parentBand(0),
m_parentBandName(""),
m_bandMarker(0),
@ -821,6 +822,20 @@ void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QStrin
m_bandNameLabel->updateLabel(newName);
}
bool BandDesignIntf::keepTopSpace() const
{
return m_keepTopSpace;
}
void BandDesignIntf::setKeepTopSpace(bool value)
{
if (m_keepTopSpace != value){
m_keepTopSpace = value;
if (!isLoading())
notify("keepTopSpace",!value,value);
}
}
bool BandDesignIntf::repeatOnEachRow() const
{
return m_repeatOnEachRow;
@ -971,7 +986,12 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
snapshotItemsLayout();
arrangeSubItems(pass, dataManager);
if (autoHeight()){
//if keepBottomSpace()&& height()<findMaxBottom()
if (!keepTopSpace()) {
qreal minTop = findMinTop();
foreach (BaseDesignIntf* item, childBaseItems()) {
item->setY(item->y() - minTop);
}
}
setHeight(findMaxBottom()+spaceBorder);
}
if ((maxHeight>0)&&(height()>maxHeight)){

View File

@ -100,6 +100,7 @@ class BandDesignIntf : public ItemsContainerDesignInft
Q_PROPERTY(bool autoHeight READ autoHeight WRITE setAutoHeight )
Q_PROPERTY(int bandIndex READ bandIndex WRITE setBandIndex DESIGNABLE false )
Q_PROPERTY(bool keepBottomSpace READ keepBottomSpaceOption WRITE setKeepBottomSpaceOption )
Q_PROPERTY(bool keepTopSpace READ keepTopSpace WRITE setKeepTopSpace)
Q_PROPERTY(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false )
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
@ -155,6 +156,9 @@ public:
void setKeepBottomSpaceOption(bool value);
bool keepBottomSpaceOption() const {return m_keepBottomSpace;}
bool keepTopSpace() const;
void setKeepTopSpace(bool value);
void addChildBand(BandDesignIntf* band);
bool hasChildren(){return !m_childBands.isEmpty();}
void removeChildBand(BandDesignIntf* band);
@ -279,6 +283,7 @@ private:
QString m_dataSourceName;
bool m_autoHeight;
bool m_keepBottomSpace;
bool m_keepTopSpace;
BandDesignIntf* m_parentBand;
QString m_parentBandName;
QList<BandDesignIntf*> m_childBands;

View File

@ -93,16 +93,27 @@ void ItemsContainerDesignInft::arrangeSubItems(RenderPass pass, DataSourceManage
qreal ItemsContainerDesignInft::findMaxBottom() const
{
qreal maxBottom=0;
qreal maxBottom = 0;
foreach(QGraphicsItem* item,childItems()){
BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(item);
if(subItem)
if ( subItem->isVisible() && (subItem->geometry().bottom()>maxBottom) )
maxBottom=subItem->geometry().bottom();
maxBottom = subItem->geometry().bottom();
}
return maxBottom;
}
qreal ItemsContainerDesignInft::findMinTop() const{
qreal minTop = height();
foreach(QGraphicsItem* item,childItems()){
BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(item);
if(subItem)
if ( subItem->isVisible() && (subItem->geometry().top()<minTop) )
minTop = subItem->geometry().top();
}
return minTop > 0 ? minTop : 0;
}
qreal ItemsContainerDesignInft::findMaxHeight() const
{
qreal maxHeight=0;

View File

@ -46,6 +46,7 @@ protected:
void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded);
qreal findMaxBottom() const;
qreal findMaxHeight() const;
qreal findMinTop() const;
private:
QVector<PItemSortContainer> m_containerItems;