From 1fb652e134ec0cec41d82e59c3e92829d33298c1 Mon Sep 17 00:00:00 2001 From: Arin Alexandex Date: Wed, 12 Aug 2020 16:45:05 +0300 Subject: [PATCH] #286 Alternate colors issue has been fixed --- common.pri | 2 +- limereport/lrbanddesignintf.cpp | 6 ++++++ limereport/lrbanddesignintf.h | 2 +- limereport/lrreportrender.cpp | 21 +++++++++++---------- limereport/lrreportrender.h | 5 +---- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/common.pri b/common.pri index 7837d48..fd781a9 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 = 64 +LIMEREPORT_VERSION_RELEASE = 65 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 19e63c0..6bd6af8 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -249,6 +249,12 @@ bool BandDesignIntf::isNeedUpdateSize(RenderPass pass) const{ return false; } +void BandDesignIntf::copyBandAttributes(BandDesignIntf *source) +{ + this->copyBookmarks(source); + this->setBackgroundColor(source->backgroundColor()); +} + void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { prepareRect(painter, option, widget); diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 6c33d08..59bec04 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -272,7 +272,7 @@ public: int shiftItems() const; void setShiftItems(int shiftItems); bool isNeedUpdateSize(RenderPass) const; - + void copyBandAttributes(BandDesignIntf* source); signals: void bandRendered(BandDesignIntf* band); void bandReRendered(BandDesignIntf* oldBand, BandDesignIntf* newBand); diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index b18c71c..8d270a3 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -466,6 +466,15 @@ void ReportRender::replaceGroupsFunction(BandDesignIntf *band) replaceGroupFunctionsInContainer(band, band); } +QColor ReportRender::makeBackgroundColor(BandDesignIntf* band){ + if (band->useAlternateBackgroundColor()){ + return datasources()->variable(QLatin1String("line_") + band->objectName().toLower()).toInt() %2 == 0 ? + band->backgroundColor() : + band->alternateBackgroundColor(); + } + return band->backgroundColor(); +} + BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesignIntf* bandData, ReportRender::DataRenderMode mode, bool isLast) { QCoreApplication::processEvents(); @@ -493,15 +502,7 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign if (patternBand->isFooter()) m_lastRenderedFooter = patternBand; - if (bandClone->useAlternateBackgroundColor()){ - bandClone->setBackgroundColor( - (datasources()->variable(QLatin1String("line_")+patternBand->objectName().toLower()).toInt() %2 == 0 ? - bandClone->backgroundColor() : - bandClone->alternateBackgroundColor() - ) - ); - } - + bandClone->setBackgroundColor(makeBackgroundColor(patternBand)); patternBand->emitBandRendered(bandClone); m_scriptEngineContext->setCurrentBand(bandClone); emit(patternBand->afterRender()); @@ -549,7 +550,7 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign startNewPage(); if (!bandIsSliced){ BandDesignIntf* t = renderData(patternBand); - t->copyBookmarks(bandClone); + t->copyBandAttributes(bandClone); patternBand->emitBandReRendered(bandClone, t); delete bandClone; bandClone = t; diff --git a/limereport/lrreportrender.h b/limereport/lrreportrender.h index 739018e..104f8c2 100644 --- a/limereport/lrreportrender.h +++ b/limereport/lrreportrender.h @@ -173,8 +173,6 @@ private: void startNewColumn(); void startNewPage(bool isFirst = false); void resetPageNumber(ResetPageNuberType resetType); - //int findLastPageNumber(int currentPage); - //int findPageNumber(int currentPage); void savePage(bool isLast = false); QString toString(); void initColumns(); @@ -187,8 +185,8 @@ private: void renameChildItems(BaseDesignIntf *item); void renderGroupFooterByHeader(BandDesignIntf *groupHeader); void updateTOC(BaseDesignIntf* item, int pageNumber); - //PagesRange& currentRange(bool isTOC = false){ return (isTOC) ? m_ranges.first(): m_ranges.last();} void placeBandOnPage(BandDesignIntf *band, int columnIndex); + QColor makeBackgroundColor(BandDesignIntf *band); private: DataSourceManager* m_datasources; ScriptEngineContext* m_scriptEngineContext; @@ -223,7 +221,6 @@ private: bool m_newPageStarted; bool m_lostHeadersMoved; - }; } // namespace LimeReport #endif // LRREPORTRENDER_H