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_dataSourceName(""),
m_autoHeight(true), m_autoHeight(true),
m_keepBottomSpace(false), m_keepBottomSpace(false),
m_keepTopSpace(true),
m_parentBand(0), m_parentBand(0),
m_parentBandName(""), m_parentBandName(""),
m_bandMarker(0), m_bandMarker(0),
@ -821,6 +822,20 @@ void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QStrin
m_bandNameLabel->updateLabel(newName); 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 bool BandDesignIntf::repeatOnEachRow() const
{ {
return m_repeatOnEachRow; return m_repeatOnEachRow;
@ -969,9 +984,14 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
} }
restoreLinks(); restoreLinks();
snapshotItemsLayout(); snapshotItemsLayout();
arrangeSubItems(pass, dataManager); arrangeSubItems(pass, dataManager);
if (autoHeight()){ if (autoHeight()){
//if keepBottomSpace()&& height()<findMaxBottom() if (!keepTopSpace()) {
qreal minTop = findMinTop();
foreach (BaseDesignIntf* item, childBaseItems()) {
item->setY(item->y() - minTop);
}
}
setHeight(findMaxBottom()+spaceBorder); setHeight(findMaxBottom()+spaceBorder);
} }
if ((maxHeight>0)&&(height()>maxHeight)){ 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(bool autoHeight READ autoHeight WRITE setAutoHeight )
Q_PROPERTY(int bandIndex READ bandIndex WRITE setBandIndex DESIGNABLE false ) Q_PROPERTY(int bandIndex READ bandIndex WRITE setBandIndex DESIGNABLE false )
Q_PROPERTY(bool keepBottomSpace READ keepBottomSpaceOption WRITE setKeepBottomSpaceOption ) 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(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false )
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle) Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
@ -155,6 +156,9 @@ public:
void setKeepBottomSpaceOption(bool value); void setKeepBottomSpaceOption(bool value);
bool keepBottomSpaceOption() const {return m_keepBottomSpace;} bool keepBottomSpaceOption() const {return m_keepBottomSpace;}
bool keepTopSpace() const;
void setKeepTopSpace(bool value);
void addChildBand(BandDesignIntf* band); void addChildBand(BandDesignIntf* band);
bool hasChildren(){return !m_childBands.isEmpty();} bool hasChildren(){return !m_childBands.isEmpty();}
void removeChildBand(BandDesignIntf* band); void removeChildBand(BandDesignIntf* band);
@ -245,7 +249,7 @@ public:
void copyBookmarks(BandDesignIntf* sourceBand); void copyBookmarks(BandDesignIntf* sourceBand);
signals: signals:
void bandRendered(BandDesignIntf* band); void bandRendered(BandDesignIntf* band);
void bandRegistred(); void bandRegistred();
protected: protected:
void trimToMaxHeight(int maxHeight); void trimToMaxHeight(int maxHeight);
@ -279,6 +283,7 @@ private:
QString m_dataSourceName; QString m_dataSourceName;
bool m_autoHeight; bool m_autoHeight;
bool m_keepBottomSpace; bool m_keepBottomSpace;
bool m_keepTopSpace;
BandDesignIntf* m_parentBand; BandDesignIntf* m_parentBand;
QString m_parentBandName; QString m_parentBandName;
QList<BandDesignIntf*> m_childBands; QList<BandDesignIntf*> m_childBands;

View File

@ -93,16 +93,27 @@ void ItemsContainerDesignInft::arrangeSubItems(RenderPass pass, DataSourceManage
qreal ItemsContainerDesignInft::findMaxBottom() const qreal ItemsContainerDesignInft::findMaxBottom() const
{ {
qreal maxBottom=0; qreal maxBottom = 0;
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->isVisible() && (subItem->geometry().bottom()>maxBottom) ) if ( subItem->isVisible() && (subItem->geometry().bottom()>maxBottom) )
maxBottom=subItem->geometry().bottom(); maxBottom = subItem->geometry().bottom();
} }
return maxBottom; 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 ItemsContainerDesignInft::findMaxHeight() const
{ {
qreal maxHeight=0; qreal maxHeight=0;

View File

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