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 2f566ff..707e0e0 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() @@ -745,6 +746,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 755f263..42dacef 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -376,6 +376,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() ){