mixWitPriorPage property has been added to PageItem

This commit is contained in:
Arin Alexander 2021-02-17 21:53:55 +03:00
parent 088a6eadce
commit 38e698fc21
7 changed files with 72 additions and 5 deletions

View File

@ -133,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5 LIMEREPORT_VERSION_MINOR = 5
LIMEREPORT_VERSION_RELEASE = 78 LIMEREPORT_VERSION_RELEASE = 80
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -53,7 +53,7 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false),
m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true), m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true),
m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false), m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false),
m_notPrintIfEmpty(false) m_notPrintIfEmpty(false), m_mixWithPriorPage(false)
{ {
setFixedPos(true); setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed); setPossibleResizeDirectionFlags(Fixed);
@ -69,7 +69,7 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false),
m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true), m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true),
m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false), m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false),
m_notPrintIfEmpty(false) m_notPrintIfEmpty(false), m_mixWithPriorPage(false)
{ {
setFixedPos(true); setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed); setPossibleResizeDirectionFlags(Fixed);
@ -755,6 +755,10 @@ void PageItemDesignIntf::preparePopUpMenu(QMenu &menu)
action->setCheckable(true); action->setCheckable(true);
action->setChecked(getSetPageSizeToPrinter()); action->setChecked(getSetPageSizeToPrinter());
action = menu.addAction(tr("Mix with prior page"));
action->setCheckable(true);
action->setChecked(mixWithPriorPage());
// action = menu.addAction(tr("Transparent")); // action = menu.addAction(tr("Transparent"));
// action->setCheckable(true); // action->setCheckable(true);
// action->setChecked(backgroundMode() == TransparentMode); // action->setChecked(backgroundMode() == TransparentMode);
@ -776,6 +780,10 @@ void PageItemDesignIntf::processPopUpAction(QAction *action)
page()->setPropertyToSelectedItems("setPageSizeToPrinter",action->isChecked()); 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) void PageItemDesignIntf::initPageSize(const PageItemDesignIntf::PageSize &size)
{ {
@ -1058,4 +1066,21 @@ PageItemDesignIntf::Ptr PageItemDesignIntf::create(QObject *owner)
return PageItemDesignIntf::Ptr(new PageItemDesignIntf(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);
}
}
}
} }

View File

@ -63,6 +63,7 @@ class PageItemDesignIntf : public ItemsContainerDesignInft
Q_PROPERTY(PrintBehavior printBehavior READ printBehavior WRITE setPrintBehavior) Q_PROPERTY(PrintBehavior printBehavior READ printBehavior WRITE setPrintBehavior)
Q_PROPERTY(bool dropPrinterMargins READ dropPrinterMargins WRITE setDropPrinterMargins) Q_PROPERTY(bool dropPrinterMargins READ dropPrinterMargins WRITE setDropPrinterMargins)
Q_PROPERTY(bool notPrintIfEmpty READ notPrintIfEmpty WRITE setNotPrintIfEmpty) Q_PROPERTY(bool notPrintIfEmpty READ notPrintIfEmpty WRITE setNotPrintIfEmpty)
Q_PROPERTY(bool mixWithPriorPage READ mixWithPriorPage WRITE setMixWithPriorPage)
friend class ReportRender; friend class ReportRender;
public: public:
enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape }; enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
@ -188,6 +189,9 @@ public:
bool notPrintIfEmpty() const; bool notPrintIfEmpty() const;
void setNotPrintIfEmpty(bool notPrintIfEmpty); void setNotPrintIfEmpty(bool notPrintIfEmpty);
bool mixWithPriorPage() const;
void setMixWithPriorPage(bool value);
signals: signals:
void beforeFirstPageRendered(); void beforeFirstPageRendered();
void afterLastPageRendered(); void afterLastPageRendered();
@ -233,6 +237,7 @@ private:
PrintBehavior m_printBehavior; PrintBehavior m_printBehavior;
bool m_dropPrinterMargins; bool m_dropPrinterMargins;
bool m_notPrintIfEmpty; bool m_notPrintIfEmpty;
bool m_mixWithPriorPage;
}; };

View File

@ -1321,7 +1321,11 @@ ReportPages ReportEnginePrivate::renderToPages()
PageItemDesignIntf* page = m_renderingPages.at(i); PageItemDesignIntf* page = m_renderingPages.at(i);
if (!page->isTOC() && page->isPrintable()){ if (!page->isTOC() && page->isPrintable()){
page->setReportSettings(&m_reportSettings); page->setReportSettings(&m_reportSettings);
result.append(m_reportRender->renderPageToPages(page)); result = appendPages(
result,
m_reportRender->renderPageToPages(page),
page->mixWithPriorPage() ? MixPages : AppendPages
);
} else { } else {
startTOCPage = result.count(); startTOCPage = result.count();
pageAfterTOCIndex = i+1; pageAfterTOCIndex = i+1;
@ -1347,7 +1351,11 @@ ReportPages ReportEnginePrivate::renderToPages()
} }
} else { } 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() QString ReportEnginePrivate::lastError()
{ {
return m_lastError; return m_lastError;

View File

@ -144,6 +144,8 @@ class ReportEnginePrivate : public QObject,
Q_PROPERTY(bool suppressFieldAndVarError READ suppressFieldAndVarError WRITE setSuppressFieldAndVarError) Q_PROPERTY(bool suppressFieldAndVarError READ suppressFieldAndVarError WRITE setSuppressFieldAndVarError)
Q_PROPERTY(ATranslationProperty translation READ fakeTranslationReader) Q_PROPERTY(ATranslationProperty translation READ fakeTranslationReader)
enum AppendType{MixPages, AppendPages};
friend class PreviewReportWidget; friend class PreviewReportWidget;
public: public:
bool printPages(ReportPages pages, QPrinter *printer); bool printPages(ReportPages pages, QPrinter *printer);
@ -304,6 +306,7 @@ private:
void updateTranslations(); void updateTranslations();
//ITranslationContainer //ITranslationContainer
ReportPages renderToPages(); ReportPages renderToPages();
ReportPages appendPages(ReportPages s1, ReportPages s2, AppendType appendType);
QString renderToString(); QString renderToString();
PageItemDesignIntf *getPageByName(const QString& pageName); PageItemDesignIntf *getPageByName(const QString& pageName);
ATranslationProperty fakeTranslationReader(){ return ATranslationProperty();} ATranslationProperty fakeTranslationReader(){ return ATranslationProperty();}

View File

@ -168,6 +168,7 @@ void QObjectPropertyModel::translatePropertyName()
tr("removeGap"); tr("removeGap");
tr("dropPrinterMargins"); tr("dropPrinterMargins");
tr("notPrintIfEmpty"); tr("notPrintIfEmpty");
tr("mixWithPriorPage");
} }
void QObjectPropertyModel::clearObjectsList() void QObjectPropertyModel::clearObjectsList()

View File

@ -1338,6 +1338,10 @@ p, li { white-space: pre-wrap; }
<source>Set page size to printer</source> <source>Set page size to printer</source>
<translation>Отправить параметры страницы в принтер</translation> <translation>Отправить параметры страницы в принтер</translation>
</message> </message>
<message>
<source>Mix with prior page</source>
<translation>Смешивать с предыдущей страницей</translation>
</message>
</context> </context>
<context> <context>
<name>LimeReport::PreviewReportWidget</name> <name>LimeReport::PreviewReportWidget</name>
@ -2042,6 +2046,10 @@ p, li { white-space: pre-wrap; }
<source>notPrintIfEmpty</source> <source>notPrintIfEmpty</source>
<translation>Не печатать, если пусто</translation> <translation>Не печатать, если пусто</translation>
</message> </message>
<message>
<source>mixWithPriorPage</source>
<translation>Смешивать с предыдущей сраницей</translation>
</message>
</context> </context>
<context> <context>
<name>LimeReport::RectPropItem</name> <name>LimeReport::RectPropItem</name>