0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

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_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}\\\"

View File

@ -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);
}
}
}
}

View File

@ -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;
};

View File

@ -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;

View File

@ -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();}

View File

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

View File

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