Tear-off band relocation has been fixed

This commit is contained in:
Arin Alexander 2019-04-16 00:23:12 +03:00
parent c2ac8bfec9
commit 80e3a4dd64
4 changed files with 80 additions and 52 deletions

View File

@ -203,7 +203,7 @@ public:
void setItemPos(const QPointF &newPos); void setItemPos(const QPointF &newPos);
void setItemPos(qreal x, qreal y); void setItemPos(qreal x, qreal y);
void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode); virtual void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode);
ItemMode itemMode() const {return m_itemMode;} ItemMode itemMode() const {return m_itemMode;}
virtual void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags); virtual void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags);

View File

@ -49,7 +49,8 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
ItemsContainerDesignInft("PageItem",owner,parent), ItemsContainerDesignInft("PageItem",owner,parent),
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0), m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false), m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false),
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false) m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
m_pageFooter(0)
{ {
setFixedPos(true); setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed); setPossibleResizeDirectionFlags(Fixed);
@ -61,7 +62,8 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
ItemsContainerDesignInft("PageItem",owner,parent), ItemsContainerDesignInft("PageItem",owner,parent),
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0), m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false), m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false),
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false) m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
m_pageFooter(0)
{ {
setFixedPos(true); setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed); setPossibleResizeDirectionFlags(Fixed);
@ -71,7 +73,8 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
PageItemDesignIntf::~PageItemDesignIntf() PageItemDesignIntf::~PageItemDesignIntf()
{ {
foreach(BandDesignIntf* band,m_bands) band->disconnect(this); foreach(BandDesignIntf* band, m_bands)
band->disconnect(this);
m_bands.clear(); m_bands.clear();
} }
@ -113,8 +116,6 @@ BaseDesignIntf *PageItemDesignIntf::createSameTypeItem(QObject *owner, QGraphics
void PageItemDesignIntf::geometryChangedEvent(QRectF newRect, QRectF) void PageItemDesignIntf::geometryChangedEvent(QRectF newRect, QRectF)
{ {
// if (scene())
// scene()->setSceneRect(newRect);
Q_UNUSED(newRect) Q_UNUSED(newRect)
updateMarginRect(); updateMarginRect();
PageSize oldSize = m_pageSize; PageSize oldSize = m_pageSize;
@ -130,16 +131,20 @@ QColor PageItemDesignIntf::selectionColor() const
QColor PageItemDesignIntf::pageBorderColor() const QColor PageItemDesignIntf::pageBorderColor() const
{ {
//return QColor(180,220,150);
return QColor(100,150,50); return QColor(100,150,50);
} }
QColor PageItemDesignIntf::gridColor() const QColor PageItemDesignIntf::gridColor() const
{ {
//return QColor(240,240,240);
return QColor(170,200,150); return QColor(170,200,150);
} }
void PageItemDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode)
{
ItemsContainerDesignInft::setItemMode(mode);
relocateBands();
}
void PageItemDesignIntf::clear() void PageItemDesignIntf::clear()
{ {
foreach(QGraphicsItem* item, childItems()){ foreach(QGraphicsItem* item, childItems()){
@ -167,7 +172,7 @@ bool PageItemDesignIntf::isBandExists(BandDesignIntf::BandsType bandType)
bool PageItemDesignIntf::isBandExists(const QString &bandType) bool PageItemDesignIntf::isBandExists(const QString &bandType)
{ {
foreach(BandDesignIntf* band, m_bands){ foreach(BandDesignIntf* band, childBands()){
if (band->bandTitle()==bandType) return true; if (band->bandTitle()==bandType) return true;
} }
return false; return false;
@ -175,7 +180,7 @@ bool PageItemDesignIntf::isBandExists(const QString &bandType)
BandDesignIntf* PageItemDesignIntf::bandByIndex(int index) BandDesignIntf* PageItemDesignIntf::bandByIndex(int index)
{ {
foreach(BandDesignIntf* band,m_bands){ foreach(BandDesignIntf* band, childBands()){
if (band->bandIndex()==index) return band; if (band->bandIndex()==index) return band;
} }
return 0; return 0;
@ -220,7 +225,7 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe
} }
if (bandIndex == -1) { if (bandIndex == -1) {
bandIndex = (int)(bandType); bandIndex = static_cast<int>(bandType);
increaseBandIndex = true; increaseBandIndex = true;
} }
@ -298,7 +303,6 @@ void PageItemDesignIntf::registerBand(BandDesignIntf *band)
m_bands.append(band); m_bands.append(band);
else else
m_bands.insert(band->bandIndex(), band); m_bands.insert(band->bandIndex(), band);
band->setParent(this); band->setParent(this);
band->setParentItem(this); band->setParentItem(this);
band->setWidth(pageRect().width() / band->columnsCount()); band->setWidth(pageRect().width() / band->columnsCount());
@ -318,6 +322,33 @@ void PageItemDesignIntf::initColumnsPos(QVector<qreal> &posByColumns, qreal pos,
} }
} }
BandDesignIntf *PageItemDesignIntf::pageFooter() const
{
return m_pageFooter;
}
void PageItemDesignIntf::setPageFooter(BandDesignIntf *pageFooter)
{
m_pageFooter = pageFooter;
}
void PageItemDesignIntf::placeTearOffBand()
{
BandDesignIntf* tearOffBand = bandByType(BandDesignIntf::TearOffBand);
if (tearOffBand){
BandDesignIntf* pf = pageFooter();
if (pf){
qreal bottomSpace = pageRect().bottom() - (tearOffBand->height() + pf->height() + bottomMargin());
tearOffBand->setItemPos(pageRect().x(),
bottomSpace);
} else {
qreal bottomSpace = pageRect().bottom() - (tearOffBand->height() + bottomMargin());
tearOffBand->setItemPos(pageRect().x(), bottomSpace);
}
}
}
bool PageItemDesignIntf::resetPageNumber() const bool PageItemDesignIntf::resetPageNumber() const
{ {
return m_resetPageNumber; return m_resetPageNumber;
@ -392,7 +423,7 @@ void PageItemDesignIntf::relocateBands()
posByColumn[0]+=m_bands[bandIndex]->height()+bandSpace; posByColumn[0]+=m_bands[bandIndex]->height()+bandSpace;
} }
if(m_bands.count()>1){ if(m_bands.count()>0){
for(int i=0; i<(m_bands.count()-1); i++){ for(int i=0; i<(m_bands.count()-1); i++){
if (((m_bands[i+1]->bandType() != BandDesignIntf::PageFooter) && if (((m_bands[i+1]->bandType() != BandDesignIntf::PageFooter) &&
(m_bands[i+1]->bandType() != BandDesignIntf::TearOffBand)) || (itemMode() & DesignMode)){ (m_bands[i+1]->bandType() != BandDesignIntf::TearOffBand)) || (itemMode() & DesignMode)){
@ -425,6 +456,9 @@ void PageItemDesignIntf::relocateBands()
if (band->isSelected()) band->updateBandNameLabel(); if (band->isSelected()) band->updateBandNameLabel();
} }
} }
if (!(itemMode() & DesignMode))
placeTearOffBand();
} }
void PageItemDesignIntf::removeBand(BandDesignIntf *band) void PageItemDesignIntf::removeBand(BandDesignIntf *band)

View File

@ -39,7 +39,7 @@
namespace LimeReport{ namespace LimeReport{
class ReportRender; class ReportRender;
class PageItemDesignIntf : public LimeReport::ItemsContainerDesignInft class PageItemDesignIntf : public ItemsContainerDesignInft
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(Orientation) Q_ENUMS(Orientation)
@ -82,6 +82,7 @@ public:
virtual QColor selectionColor() const; virtual QColor selectionColor() const;
virtual QColor pageBorderColor() const; virtual QColor pageBorderColor() const;
virtual QColor gridColor() const; virtual QColor gridColor() const;
void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode);
void clear(); void clear();
const BandsList& childBands() const {return m_bands;} const BandsList& childBands() const {return m_bands;}
BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const; BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const;
@ -130,6 +131,10 @@ public:
QList<BandDesignIntf *> createBandGroup(int beginIndex, int endIndex); QList<BandDesignIntf *> createBandGroup(int beginIndex, int endIndex);
void placeTearOffBand();
BandDesignIntf *pageFooter() const;
void setPageFooter(BandDesignIntf *pageFooter);
protected slots: protected slots:
void bandDeleted(QObject* band); void bandDeleted(QObject* band);
void bandPositionChanged(QObject* object, QPointF newPos, QPointF oldPos); void bandPositionChanged(QObject* object, QPointF newPos, QPointF oldPos);
@ -159,6 +164,7 @@ private:
bool m_fullPage; bool m_fullPage;
bool m_oldPrintMode; bool m_oldPrintMode;
bool m_resetPageNumber; bool m_resetPageNumber;
BandDesignIntf* m_pageFooter;
}; };
typedef QList<PageItemDesignIntf::Ptr> ReportPages; typedef QList<PageItemDesignIntf::Ptr> ReportPages;

View File

@ -637,6 +637,7 @@ void ReportRender::renderPageFooter(PageItemDesignIntf *patternPage)
bandClone->setHeight(m_pageFooterHeight); bandClone->setHeight(m_pageFooterHeight);
for(int i=0;i<m_maxHeightByColumn.size();++i) for(int i=0;i<m_maxHeightByColumn.size();++i)
m_maxHeightByColumn[i]+=m_pageFooterHeight; m_maxHeightByColumn[i]+=m_pageFooterHeight;
m_renderPageItem->setPageFooter(bandClone);
registerBand(bandClone); registerBand(bandClone);
datasources()->clearGroupFunctionValues(band->objectName()); datasources()->clearGroupFunctionValues(band->objectName());
} }
@ -1268,19 +1269,6 @@ BandDesignIntf* ReportRender::findEnclosingGroup()
return result; return result;
} }
void ReportRender::moveTearOffBand(){
BandDesignIntf* tearOffBand = m_renderPageItem->bandByType(BandDesignIntf::TearOffBand);
if (tearOffBand){
BandDesignIntf* pageFooter = m_renderPageItem->bandByType(BandDesignIntf::PageFooter);
if (pageFooter){
tearOffBand->setItemPos(m_patternPageItem->pageRect().x(),
m_patternPageItem->pageRect().bottom()-(tearOffBand->height()+pageFooter->height()));
} else {
tearOffBand->setItemPos(m_patternPageItem->pageRect().x(),m_patternPageItem->pageRect().bottom()-tearOffBand->height());
}
}
}
void ReportRender::savePage(bool isLast) void ReportRender::savePage(bool isLast)
{ {
@ -1325,7 +1313,7 @@ void ReportRender::savePage(bool isLast)
} }
} }
moveTearOffBand(); m_renderPageItem->placeTearOffBand();
emit m_patternPageItem->afterRender(); emit m_patternPageItem->afterRender();
} }