From 96e8fd06bdec3304a6b685a025531c10400ed7cf Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Mon, 14 Aug 2017 22:39:38 +0300 Subject: [PATCH 1/2] Splittable band has been fixed --- limereport/items/lrhorizontallayout.h | 1 + limereport/items/lrtextitem.cpp | 2 +- limereport/lrbanddesignintf.cpp | 29 +++++++++++++++--------- limereport/lrbanddesignintf.h | 16 ++++++++++++- limereport/lritemscontainerdesignitf.cpp | 4 ++-- limereport/lritemscontainerdesignitf.h | 4 ++-- 6 files changed, 39 insertions(+), 17 deletions(-) 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 543b34e..3144c66 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -783,7 +783,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 47f398c..26c1100 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -122,7 +122,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q m_startNewPage(false), m_startFromNewPage(false), m_printAlways(false), - m_repeatOnEachRow(false) + m_repeatOnEachRow(false), + m_bottomSpace() { setPossibleResizeDirectionFlags(ResizeBottom); setPossibleMoveFlags(TopBotom); @@ -488,7 +489,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); @@ -534,6 +536,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; @@ -550,17 +553,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); @@ -731,6 +733,11 @@ void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgrou m_alternateBackgroundColor = alternateBackgroundColor; } +qreal BandDesignIntf::bottomSpace() const +{ + return m_bottomSpace.isValid() ? m_bottomSpace.value() : height()-findMaxBottom(); +} + void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName) { update(); @@ -872,7 +879,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 5b71de3..5c4b1e3 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 @@ -221,6 +233,7 @@ public: void setRepeatOnEachRow(bool repeatOnEachRow); QColor alternateBackgroundColor() const; void setAlternateBackgroundColor(const QColor &alternateBackgroundColor); + qreal bottomSpace() const; signals: void bandRendered(BandDesignIntf* band); protected: @@ -275,7 +288,8 @@ private: bool m_printAlways; bool m_repeatOnEachRow; QMap m_slicedItems; - QColor m_alternateBackgroundColor; + QColor m_alternateBackgroundColor; + 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; From ea844a04058c350e415ad2a788ac855ef9a42b85 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 15 Aug 2017 01:21:59 +0300 Subject: [PATCH 2/2] Context menu for multi selected items has been fixed --- common.pri | 2 +- limereport/items/lrtextitem.cpp | 8 ++--- limereport/lrbanddesignintf.cpp | 53 ++++++++++++++++++++++++++++----- limereport/lrbanddesignintf.h | 2 +- limereport/lrpagedesignintf.cpp | 8 +++++ limereport/lrpagedesignintf.h | 2 ++ 6 files changed, 61 insertions(+), 14 deletions(-) diff --git a/common.pri b/common.pri index bbf28ba..b371859 100644 --- a/common.pri +++ b/common.pri @@ -62,7 +62,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 4 -LIMEREPORT_VERSION_RELEASE = 34 +LIMEREPORT_VERSION_RELEASE = 38 LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"' DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\" diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 3144c66..c76185a 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -113,16 +113,16 @@ void TextItem::processPopUpAction(QAction *action) this->showEditorDialog(); } if (action->text().compare(tr("Auto height")) == 0){ - setProperty("autoHeight",action->isChecked()); + page()->setPropertyToSelectedItems("autoHeight",action->isChecked()); } if (action->text().compare(tr("Allow HTML")) == 0){ - setProperty("allowHTML",action->isChecked()); + page()->setPropertyToSelectedItems("allowHTML",action->isChecked()); } if (action->text().compare(tr("Allow HTML in fields")) == 0){ - setProperty("allowHTMLInFields",action->isChecked()); + page()->setPropertyToSelectedItems("allowHTMLInFields",action->isChecked()); } if (action->text().compare(tr("Stretch to max height")) == 0){ - setProperty("stretchToMaxHeight",action->isChecked()); + page()->setPropertyToSelectedItems("stretchToMaxHeight",action->isChecked()); } } diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 26c1100..f68c61a 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -292,6 +292,14 @@ void BandDesignIntf::setDataSourceName(const QString &datasource){ m_dataSourceName=datasource; } +void BandDesignIntf::setKeepBottomSpaceOption(bool value){ + if (m_keepBottomSpace!=value){ + m_keepBottomSpace=value; + if (!isLoading()) + notify("keepBottomSpace",!value,value); + } +} + void BandDesignIntf::addChildBand(BandDesignIntf *band) { m_childBands.append(band); @@ -466,13 +474,25 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu) } menu.addSeparator(); - QAction* autoHeightAction = menu.addAction(tr("Auto height")); - autoHeightAction->setCheckable(true); - autoHeightAction->setChecked(autoHeight()); + QAction* currAction = menu.addAction(tr("Auto height")); + currAction->setCheckable(true); + currAction->setChecked(autoHeight()); - QAction* autoSplittableAction = menu.addAction(tr("Splittable")); - autoSplittableAction->setCheckable(true); - autoSplittableAction->setChecked(isSplittable()); + currAction = menu.addAction(tr("Splittable")); + currAction->setCheckable(true); + currAction->setChecked(isSplittable()); + + currAction = menu.addAction(tr("Keep bottom space")); + currAction->setCheckable(true); + currAction->setChecked(keepBottomSpaceOption()); + + currAction = menu.addAction(tr("Start from new page")); + currAction->setCheckable(true); + currAction->setChecked(startFromNewPage()); + + currAction = menu.addAction(tr("Start new page")); + currAction->setCheckable(true); + currAction->setChecked(startNewPage()); } void BandDesignIntf::processPopUpAction(QAction *action) @@ -483,6 +503,15 @@ void BandDesignIntf::processPopUpAction(QAction *action) if (action->text().compare(tr("Splittable")) == 0){ setProperty("splittable",action->isChecked()); } + if (action->text().compare(tr("Keep bottom space")) == 0){ + setProperty("keepBottomSpace",action->isChecked()); + } + if (action->text().compare(tr("Start new page")) == 0){ + setProperty("startNewPage",action->isChecked()); + } + if (action->text().compare(tr("Start from new page")) == 0){ + setProperty("startFromNewPage",action->isChecked()); + } } BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent) @@ -772,7 +801,11 @@ bool BandDesignIntf::startFromNewPage() const void BandDesignIntf::setStartFromNewPage(bool startWithNewPage) { - m_startFromNewPage = startWithNewPage; + if (m_startFromNewPage != startWithNewPage){ + m_startFromNewPage = startWithNewPage; + if (!isLoading()) + notify("startFromNewPage", !startWithNewPage, startWithNewPage); + } } bool BandDesignIntf::startNewPage() const @@ -782,7 +815,11 @@ bool BandDesignIntf::startNewPage() const void BandDesignIntf::setStartNewPage(bool startNewPage) { - m_startNewPage = startNewPage; + if (m_startNewPage != startNewPage){ + m_startNewPage = startNewPage; + if (!isLoading()) + notify("startNewPage", !startNewPage, startNewPage); + } } void BandDesignIntf::setAutoHeight(bool value){ diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 5c4b1e3..f1cd43a 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -150,7 +150,7 @@ public: QString datasourceName(); void setDataSourceName(const QString& datasourceName); - void setKeepBottomSpaceOption(bool value){m_keepBottomSpace=value;} + void setKeepBottomSpaceOption(bool value); bool keepBottomSpaceOption() const {return m_keepBottomSpace;} void addChildBand(BandDesignIntf* band); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 2a3a068..67d8408 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1071,6 +1071,14 @@ void PageDesignIntf::setReportSettings(ReportSettings *reportSettings) m_pageItem->setReportSettings(m_reportSettings); } +void PageDesignIntf::setPropertyToSelectedItems(const char* name, const QVariant& value) +{ + foreach(QGraphicsItem* gi, selectedItems()){ + BaseDesignIntf* item = dynamic_cast(gi); + if(item && item->metaObject()->indexOfProperty(name) != -1 ) item->setProperty(name,value); + } +} + bool PageDesignIntf::magneticMovement() const { return m_magneticMovement; diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index d2ff996..684df0b 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -182,6 +182,8 @@ namespace LimeReport { ReportSettings *getReportSettings() const; void setReportSettings(ReportSettings *reportSettings); + void setPropertyToSelectedItems(const char *name, const QVariant &value); + protected: virtual void keyPressEvent(QKeyEvent *event);