alternateBackgrounColor property has been added

This commit is contained in:
Arin Alexander 2016-10-18 13:58:26 +03:00
parent dd40aa1137
commit 8ed24f9f75
5 changed files with 23 additions and 0 deletions

View File

@ -47,6 +47,7 @@ class DataBand : public DataBandDesignIntf
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection) Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage) Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage)
Q_PROPERTY(bool startFromNewPage READ startFromNewPage WRITE setStartFromNewPage) Q_PROPERTY(bool startFromNewPage READ startFromNewPage WRITE setStartFromNewPage)
Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE setAlternateBackgroundColor)
public: public:
DataBand(QObject* owner = 0, QGraphicsItem* parent=0); DataBand(QObject* owner = 0, QGraphicsItem* parent=0);
bool isUnique() const; bool isUnique() const;

View File

@ -42,6 +42,7 @@ class SubDetailBand : public DataBandDesignIntf
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount) Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection) Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether) Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether)
Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE setAlternateBackgroundColor)
public: public:
SubDetailBand(QObject* owner = 0, QGraphicsItem* parent=0); SubDetailBand(QObject* owner = 0, QGraphicsItem* parent=0);
bool isUnique() const {return false;} bool isUnique() const {return false;}

View File

@ -168,6 +168,7 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
m_bandNameLabel = new BandNameLabel(this); m_bandNameLabel = new BandNameLabel(this);
m_bandNameLabel->setVisible(false); m_bandNameLabel->setVisible(false);
if (scene()) scene()->addItem(m_bandNameLabel); if (scene()) scene()->addItem(m_bandNameLabel);
m_alternateBackgroundColor = backgroundColor();
} }
BandDesignIntf::~BandDesignIntf() BandDesignIntf::~BandDesignIntf()
@ -738,6 +739,16 @@ void BandDesignIntf::childBandDeleted(QObject *band)
m_childBands.removeAt(m_childBands.indexOf(reinterpret_cast<BandDesignIntf*>(band))); m_childBands.removeAt(m_childBands.indexOf(reinterpret_cast<BandDesignIntf*>(band)));
} }
QColor BandDesignIntf::alternateBackgroundColor() const
{
return m_alternateBackgroundColor;
}
void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgroundColor)
{
m_alternateBackgroundColor = alternateBackgroundColor;
}
bool BandDesignIntf::repeatOnEachRow() const bool BandDesignIntf::repeatOnEachRow() const
{ {
return m_repeatOnEachRow; return m_repeatOnEachRow;

View File

@ -216,6 +216,9 @@ public:
void setPrintAlways(bool printAlways); void setPrintAlways(bool printAlways);
bool repeatOnEachRow() const; bool repeatOnEachRow() const;
void setRepeatOnEachRow(bool repeatOnEachRow); void setRepeatOnEachRow(bool repeatOnEachRow);
QColor alternateBackgroundColor() const;
void setAlternateBackgroundColor(const QColor &alternateBackgroundColor);
signals: signals:
void bandRendered(BandDesignIntf* band); void bandRendered(BandDesignIntf* band);
protected: protected:
@ -270,6 +273,7 @@ private:
bool m_printAlways; bool m_printAlways;
bool m_repeatOnEachRow; bool m_repeatOnEachRow;
QMap<QString,BaseDesignIntf*> m_slicedItems; QMap<QString,BaseDesignIntf*> m_slicedItems;
QColor m_alternateBackgroundColor;
}; };
class DataBandDesignIntf : public BandDesignIntf{ class DataBandDesignIntf : public BandDesignIntf{

View File

@ -333,6 +333,12 @@ void ReportRender::renderBand(BandDesignIntf *patternBand, ReportRender::DataRen
m_lastRenderedFooter = patternBand; m_lastRenderedFooter = patternBand;
BandDesignIntf* bandClone=renderData(patternBand); BandDesignIntf* bandClone=renderData(patternBand);
bandClone->setBackgroundColor(
(datasources()->variable(QLatin1String("line_")+patternBand->objectName().toLower()).toInt()%2!=0 ?
patternBand->backgroundColor():
patternBand->alternateBackgroundColor()
)
);
patternBand->emitBandRendered(bandClone); patternBand->emitBandRendered(bandClone);
if ( isLast && bandClone->keepFooterTogether() && bandClone->sliceLastRow() ){ if ( isLast && bandClone->keepFooterTogether() && bandClone->sliceLastRow() ){