diff --git a/limereport/items/lrhorizontallayout.h b/limereport/items/lrhorizontallayout.h index 67cceef..c2a52e3 100644 --- a/limereport/items/lrhorizontallayout.h +++ b/limereport/items/lrhorizontallayout.h @@ -74,6 +74,7 @@ public: bool isEmpty() const; LayoutType layoutType() const; void setLayoutType(const LayoutType &layoutType); + bool isSplittable() const { return true;} protected: void collectionLoadFinished(const QString &collectionName); void objectLoadFinished(); diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index b604766..3e7b208 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -794,7 +794,7 @@ QString TextItem::getTextPart(int height, int skipHeight){ int textPos = 0; TextPtr text = textDocument(); - + text->documentLayout(); QTextBlock curBlock = text->begin(); QString resultText = ""; diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index d3a02d3..85c3859 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -123,7 +123,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q m_startFromNewPage(false), m_printAlways(false), m_repeatOnEachRow(false), - m_useAlternateBackgroundColor(false) + m_useAlternateBackgroundColor(false), + m_bottomSpace() { setPossibleResizeDirectionFlags(ResizeBottom); setPossibleMoveFlags(TopBotom); @@ -502,7 +503,8 @@ BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGrap { int maxBottom = 0; BandDesignIntf* upperPart = dynamic_cast(createSameTypeItem(owner,parent)); - BaseDesignIntf* upperItem; + upperPart->m_bottomSpace = this->bottomSpace(); + BaseDesignIntf* upperItem = 0; upperPart->initFromItem(this); @@ -548,6 +550,7 @@ bool itemLessThen(QGraphicsItem* i1, QGraphicsItem* i2){ BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent) { BandDesignIntf* bottomPart = dynamic_cast(createSameTypeItem(owner,parent)); + bottomPart->m_bottomSpace = this->bottomSpace(); bottomPart->initFromItem(this); QList bandItems; @@ -564,17 +567,16 @@ BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGra } else if ((item->geometry().top()geometry().bottom()>height)){ int sliceHeight = height-item->geometry().top(); - if (item->canBeSplitted(sliceHeight)) { + if (item->isSplittable() && item->canBeSplitted(sliceHeight)) { BaseDesignIntf* tmpItem=item->cloneBottomPart(sliceHeight,bottomPart,bottomPart); tmpItem->setPos(tmpItem->pos().x(),0); if (tmpItem->pos().y()<0) tmpItem->setPos(tmpItem->pos().x(),0); - qreal sizeOffset = (m_slicedItems.value(tmpItem->objectName())->height()+tmpItem->height()) - item->height(); - qreal bottomOffset = (height - m_slicedItems.value(tmpItem->objectName())->pos().y())-m_slicedItems.value(tmpItem->objectName())->height(); - moveItemsDown(item->pos().y()+item->height(), sizeOffset + bottomOffset); - } - else if (item->isSplittable()){ - BaseDesignIntf* tmpItem = item->cloneItem(item->itemMode(),bottomPart,bottomPart); - tmpItem->setPos(tmpItem->pos().x(),0); + BaseDesignIntf* slicedItem = m_slicedItems.value(tmpItem->objectName()); + if (slicedItem){ + qreal sizeOffset = (slicedItem->height()+tmpItem->height()) - item->height(); + qreal bottomOffset = (height - slicedItem->pos().y())-m_slicedItems.value(tmpItem->objectName())->height(); + moveItemsDown(item->pos().y()+item->height(), sizeOffset + bottomOffset); + } } else { if ((item->geometry().bottom()-height)>height){ BaseDesignIntf* tmpItem = item->cloneItem(item->itemMode(),bottomPart,bottomPart); @@ -765,6 +767,11 @@ void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgrou } } +qreal BandDesignIntf::bottomSpace() const +{ + return m_bottomSpace.isValid() ? m_bottomSpace.value() : height()-findMaxBottom(); +} + void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName) { update(); @@ -906,7 +913,7 @@ void BandDesignIntf::setKeepFooterTogether(bool value) void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { qreal spaceBorder=0; - if (keepBottomSpaceOption()) spaceBorder=height()-findMaxBottom(); + if (keepBottomSpaceOption()) spaceBorder = bottomSpace(); if (borderLines()!=0){ spaceBorder += borderLineSize(); } diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index aa313ab..e17c807 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -82,6 +82,18 @@ private: BandDesignIntf* m_band; }; +class InitializedValue{ +public: + InitializedValue(): m_value(-1), m_isInitialized(false){} + InitializedValue(qreal value): m_value(value), m_isInitialized(true){} + qreal value() const { return m_value;} + void setValue( qreal value){ m_value = value; m_isInitialized = true;} + bool isValid() const{ return m_isInitialized;} +private: + qreal m_value; + bool m_isInitialized; +}; + class BandDesignIntf : public ItemsContainerDesignInft { Q_OBJECT @@ -225,6 +237,7 @@ public: bool useAlternateBackgroundColor() const; void setUseAlternateBackgroundColor(bool useAlternateBackgroundColor); void replaceGroupsFunction(BandDesignIntf *band); + qreal bottomSpace() const; signals: void bandRendered(BandDesignIntf* band); protected: @@ -279,8 +292,9 @@ private: bool m_printAlways; bool m_repeatOnEachRow; QMap m_slicedItems; - QColor m_alternateBackgroundColor; - bool m_useAlternateBackgroundColor; + QColor m_alternateBackgroundColor; + bool m_useAlternateBackgroundColor; + InitializedValue m_bottomSpace; }; class DataBandDesignIntf : public BandDesignIntf{ diff --git a/limereport/lritemscontainerdesignitf.cpp b/limereport/lritemscontainerdesignitf.cpp index dcad6ee..0e31eb8 100644 --- a/limereport/lritemscontainerdesignitf.cpp +++ b/limereport/lritemscontainerdesignitf.cpp @@ -91,7 +91,7 @@ void ItemsContainerDesignInft::arrangeSubItems(RenderPass pass, DataSourceManage } } -qreal ItemsContainerDesignInft::findMaxBottom() +qreal ItemsContainerDesignInft::findMaxBottom() const { qreal maxBottom=0; foreach(QGraphicsItem* item,childItems()){ @@ -103,7 +103,7 @@ qreal ItemsContainerDesignInft::findMaxBottom() return maxBottom; } -qreal ItemsContainerDesignInft::findMaxHeight() +qreal ItemsContainerDesignInft::findMaxHeight() const { qreal maxHeight=0; foreach(QGraphicsItem* item,childItems()){ diff --git a/limereport/lritemscontainerdesignitf.h b/limereport/lritemscontainerdesignitf.h index 86b2509..26e3f11 100644 --- a/limereport/lritemscontainerdesignitf.h +++ b/limereport/lritemscontainerdesignitf.h @@ -44,8 +44,8 @@ public: protected: void snapshotItemsLayout(); void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded); - qreal findMaxBottom(); - qreal findMaxHeight(); + qreal findMaxBottom() const; + qreal findMaxHeight() const; private: QVector m_containerItems;