From 8ed24f9f758342de527eb56c285031d2e804566c Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 18 Oct 2016 13:58:26 +0300 Subject: [PATCH] alternateBackgrounColor property has been added --- limereport/bands/lrdataband.h | 1 + limereport/bands/lrsubdetailband.h | 1 + limereport/lrbanddesignintf.cpp | 11 +++++++++++ limereport/lrbanddesignintf.h | 4 ++++ limereport/lrreportrender.cpp | 6 ++++++ 5 files changed, 23 insertions(+) diff --git a/limereport/bands/lrdataband.h b/limereport/bands/lrdataband.h index c6061b3..fd180e8 100644 --- a/limereport/bands/lrdataband.h +++ b/limereport/bands/lrdataband.h @@ -47,6 +47,7 @@ class DataBand : public DataBandDesignIntf Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection) Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage) Q_PROPERTY(bool startFromNewPage READ startFromNewPage WRITE setStartFromNewPage) + Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE setAlternateBackgroundColor) public: DataBand(QObject* owner = 0, QGraphicsItem* parent=0); bool isUnique() const; diff --git a/limereport/bands/lrsubdetailband.h b/limereport/bands/lrsubdetailband.h index ad379b3..c9b4c76 100644 --- a/limereport/bands/lrsubdetailband.h +++ b/limereport/bands/lrsubdetailband.h @@ -42,6 +42,7 @@ class SubDetailBand : public DataBandDesignIntf Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount) Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection) Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether) + Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE setAlternateBackgroundColor) public: SubDetailBand(QObject* owner = 0, QGraphicsItem* parent=0); bool isUnique() const {return false;} diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index a61230e..9f5be63 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -168,6 +168,7 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q m_bandNameLabel = new BandNameLabel(this); m_bandNameLabel->setVisible(false); if (scene()) scene()->addItem(m_bandNameLabel); + m_alternateBackgroundColor = backgroundColor(); } BandDesignIntf::~BandDesignIntf() @@ -738,6 +739,16 @@ void BandDesignIntf::childBandDeleted(QObject *band) m_childBands.removeAt(m_childBands.indexOf(reinterpret_cast(band))); } +QColor BandDesignIntf::alternateBackgroundColor() const +{ + return m_alternateBackgroundColor; +} + +void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgroundColor) +{ + m_alternateBackgroundColor = alternateBackgroundColor; +} + bool BandDesignIntf::repeatOnEachRow() const { return m_repeatOnEachRow; diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 5e1b7d4..1f21919 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -216,6 +216,9 @@ public: void setPrintAlways(bool printAlways); bool repeatOnEachRow() const; void setRepeatOnEachRow(bool repeatOnEachRow); + QColor alternateBackgroundColor() const; + void setAlternateBackgroundColor(const QColor &alternateBackgroundColor); + signals: void bandRendered(BandDesignIntf* band); protected: @@ -270,6 +273,7 @@ private: bool m_printAlways; bool m_repeatOnEachRow; QMap m_slicedItems; + QColor m_alternateBackgroundColor; }; class DataBandDesignIntf : public BandDesignIntf{ diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 7cf8b98..ff6bd3e 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -333,6 +333,12 @@ void ReportRender::renderBand(BandDesignIntf *patternBand, ReportRender::DataRen m_lastRenderedFooter = patternBand; BandDesignIntf* bandClone=renderData(patternBand); + bandClone->setBackgroundColor( + (datasources()->variable(QLatin1String("line_")+patternBand->objectName().toLower()).toInt()%2!=0 ? + patternBand->backgroundColor(): + patternBand->alternateBackgroundColor() + ) + ); patternBand->emitBandRendered(bandClone); if ( isLast && bandClone->keepFooterTogether() && bandClone->sliceLastRow() ){