From 38e698fc2161abc01895b32b2eaba867b0996213 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 17 Feb 2021 21:53:55 +0300 Subject: [PATCH] mixWitPriorPage property has been added to PageItem --- common.pri | 2 +- limereport/lrpageitemdesignintf.cpp | 29 +++++++++++++++++-- limereport/lrpageitemdesignintf.h | 5 ++++ limereport/lrreportengine.cpp | 29 +++++++++++++++++-- limereport/lrreportengine_p.h | 3 ++ .../objectinspector/lrobjectitemmodel.cpp | 1 + translations/limereport_ru.ts | 8 +++++ 7 files changed, 72 insertions(+), 5 deletions(-) diff --git a/common.pri b/common.pri index dd4bb53..8fe2096 100644 --- a/common.pri +++ b/common.pri @@ -133,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 78 +LIMEREPORT_VERSION_RELEASE = 80 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index fb27fda..850319b 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -53,7 +53,7 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) : m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true), m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false), - m_notPrintIfEmpty(false) + m_notPrintIfEmpty(false), m_mixWithPriorPage(false) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); @@ -69,7 +69,7 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true), m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false), - m_notPrintIfEmpty(false) + m_notPrintIfEmpty(false), m_mixWithPriorPage(false) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); @@ -755,6 +755,10 @@ void PageItemDesignIntf::preparePopUpMenu(QMenu &menu) action->setCheckable(true); action->setChecked(getSetPageSizeToPrinter()); + action = menu.addAction(tr("Mix with prior page")); + action->setCheckable(true); + action->setChecked(mixWithPriorPage()); + // action = menu.addAction(tr("Transparent")); // action->setCheckable(true); // action->setChecked(backgroundMode() == TransparentMode); @@ -776,6 +780,10 @@ void PageItemDesignIntf::processPopUpAction(QAction *action) page()->setPropertyToSelectedItems("setPageSizeToPrinter",action->isChecked()); } + if (action->text().compare(tr("Mix with prior page")) == 0){ + page()->setPropertyToSelectedItems("mixWithPriorPage",action->isChecked()); + } + } void PageItemDesignIntf::initPageSize(const PageItemDesignIntf::PageSize &size) { @@ -1058,4 +1066,21 @@ PageItemDesignIntf::Ptr PageItemDesignIntf::create(QObject *owner) return PageItemDesignIntf::Ptr(new PageItemDesignIntf(owner)); } +bool PageItemDesignIntf::mixWithPriorPage() const +{ + return m_mixWithPriorPage; +} + +void PageItemDesignIntf::setMixWithPriorPage(bool value) +{ + if (m_mixWithPriorPage != value){ + m_mixWithPriorPage = value; + if (!isLoading()){ + update(); + notify("mixWithPriorPage", !value, value); + } + } + +} + } diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 07b078e..d297b5f 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -63,6 +63,7 @@ class PageItemDesignIntf : public ItemsContainerDesignInft Q_PROPERTY(PrintBehavior printBehavior READ printBehavior WRITE setPrintBehavior) Q_PROPERTY(bool dropPrinterMargins READ dropPrinterMargins WRITE setDropPrinterMargins) Q_PROPERTY(bool notPrintIfEmpty READ notPrintIfEmpty WRITE setNotPrintIfEmpty) + Q_PROPERTY(bool mixWithPriorPage READ mixWithPriorPage WRITE setMixWithPriorPage) friend class ReportRender; public: enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape }; @@ -188,6 +189,9 @@ public: bool notPrintIfEmpty() const; void setNotPrintIfEmpty(bool notPrintIfEmpty); + bool mixWithPriorPage() const; + void setMixWithPriorPage(bool value); + signals: void beforeFirstPageRendered(); void afterLastPageRendered(); @@ -233,6 +237,7 @@ private: PrintBehavior m_printBehavior; bool m_dropPrinterMargins; bool m_notPrintIfEmpty; + bool m_mixWithPriorPage; }; diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 0165e9d..8595a74 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -1321,7 +1321,11 @@ ReportPages ReportEnginePrivate::renderToPages() PageItemDesignIntf* page = m_renderingPages.at(i); if (!page->isTOC() && page->isPrintable()){ page->setReportSettings(&m_reportSettings); - result.append(m_reportRender->renderPageToPages(page)); + result = appendPages( + result, + m_reportRender->renderPageToPages(page), + page->mixWithPriorPage() ? MixPages : AppendPages + ); } else { startTOCPage = result.count(); pageAfterTOCIndex = i+1; @@ -1347,7 +1351,11 @@ ReportPages ReportEnginePrivate::renderToPages() } } else { - result.append(m_reportRender->renderPageToPages(page)); + result = appendPages( + result, + m_reportRender->renderPageToPages(page), + page->mixWithPriorPage() ? MixPages : AppendPages + ); } } } @@ -1369,6 +1377,23 @@ ReportPages ReportEnginePrivate::renderToPages() } } +ReportPages ReportEnginePrivate::appendPages(ReportPages s1, ReportPages s2, AppendType appendType) +{ + if (!s1.isEmpty()>0 && s1.size() == s2.size() && appendType == MixPages){ + ReportPages result; + ReportPages::Iterator s1It; + ReportPages::Iterator s2It; + for (s1It = s1.begin(), s2It = s2.begin(); s1It != s1.end(); ++s1It,++s2It){ + result.append(*s1It); + result.append(*s2It); + } + return result; + } else { + s1.append(s2); + return s1; + } +} + QString ReportEnginePrivate::lastError() { return m_lastError; diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index d49743e..dd501b9 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -144,6 +144,8 @@ class ReportEnginePrivate : public QObject, Q_PROPERTY(bool suppressFieldAndVarError READ suppressFieldAndVarError WRITE setSuppressFieldAndVarError) Q_PROPERTY(ATranslationProperty translation READ fakeTranslationReader) + enum AppendType{MixPages, AppendPages}; + friend class PreviewReportWidget; public: bool printPages(ReportPages pages, QPrinter *printer); @@ -304,6 +306,7 @@ private: void updateTranslations(); //ITranslationContainer ReportPages renderToPages(); + ReportPages appendPages(ReportPages s1, ReportPages s2, AppendType appendType); QString renderToString(); PageItemDesignIntf *getPageByName(const QString& pageName); ATranslationProperty fakeTranslationReader(){ return ATranslationProperty();} diff --git a/limereport/objectinspector/lrobjectitemmodel.cpp b/limereport/objectinspector/lrobjectitemmodel.cpp index 982103b..65e2f4a 100644 --- a/limereport/objectinspector/lrobjectitemmodel.cpp +++ b/limereport/objectinspector/lrobjectitemmodel.cpp @@ -168,6 +168,7 @@ void QObjectPropertyModel::translatePropertyName() tr("removeGap"); tr("dropPrinterMargins"); tr("notPrintIfEmpty"); + tr("mixWithPriorPage"); } void QObjectPropertyModel::clearObjectsList() diff --git a/translations/limereport_ru.ts b/translations/limereport_ru.ts index e37ae33..1f3a1f8 100644 --- a/translations/limereport_ru.ts +++ b/translations/limereport_ru.ts @@ -1338,6 +1338,10 @@ p, li { white-space: pre-wrap; } Set page size to printer Отправить параметры страницы в принтер + + Mix with prior page + Смешивать с предыдущей страницей + LimeReport::PreviewReportWidget @@ -2042,6 +2046,10 @@ p, li { white-space: pre-wrap; } notPrintIfEmpty Не печатать, если пусто + + mixWithPriorPage + Смешивать с предыдущей сраницей + LimeReport::RectPropItem