0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 17:14:40 +03:00

Finish 1.4.127

# Conflicts:
#	limereport/lrpageitemdesignintf.cpp
#	limereport/lrpageitemdesignintf.h
#	limereport/lrreportrender.cpp
This commit is contained in:
Arin Alexander 2019-04-16 01:06:51 +03:00
commit 220dcc3edb
3 changed files with 66 additions and 48 deletions

View File

@ -51,7 +51,7 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
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_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false), m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false),
m_endlessHeight(false), m_printable(true) m_endlessHeight(false), m_printable(true), m_pageFooter(0)
{ {
setFixedPos(true); setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed); setPossibleResizeDirectionFlags(Fixed);
@ -65,7 +65,7 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
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_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false), m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false),
m_endlessHeight(false), m_printable(true) m_endlessHeight(false), m_printable(true), m_pageFooter(0)
{ {
setFixedPos(true); setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed); setPossibleResizeDirectionFlags(Fixed);
@ -75,7 +75,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();
} }
@ -87,10 +88,10 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte
if (isExtendedInDesignMode()) rect.adjust(0,0,0,m_extendedHeight); if (isExtendedInDesignMode()) rect.adjust(0,0,0,m_extendedHeight);
ppainter->save(); ppainter->save();
ppainter->setOpacity(0.8); ppainter->setOpacity(0.8);
ppainter->fillRect(boundingRect(),pageBorderColor()); ppainter->fillRect(boundingRect(), pageBorderColor());
ppainter->setOpacity(1); ppainter->setOpacity(1);
ppainter->fillRect(rect,Qt::white); ppainter->fillRect(rect, Qt::white);
paintGrid(ppainter,rect); paintGrid(ppainter, rect);
ppainter->setPen(gridColor()); ppainter->setPen(gridColor());
ppainter->drawRect(boundingRect()); ppainter->drawRect(boundingRect());
if (m_isExtendedInDesignMode){ if (m_isExtendedInDesignMode){
@ -106,7 +107,7 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte
if (itemMode() & PreviewMode) { if (itemMode() & PreviewMode) {
ppainter->save(); ppainter->save();
ppainter->fillRect(rect(),Qt::white); ppainter->fillRect(rect(), Qt::white);
QPen pen; QPen pen;
pen.setColor(Qt::gray); pen.setColor(Qt::gray);
pen.setWidth(1); pen.setWidth(1);
@ -127,8 +128,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;
@ -144,13 +143,11 @@ 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);
} }
@ -189,7 +186,7 @@ BandDesignIntf *PageItemDesignIntf::bandByType(BandDesignIntf::BandsType bandTyp
bool PageItemDesignIntf::isBandExists(BandDesignIntf::BandsType bandType) bool PageItemDesignIntf::isBandExists(BandDesignIntf::BandsType bandType)
{ {
foreach(BandDesignIntf* band,childBands()){ foreach(BandDesignIntf* band, childBands()){
if (band->bandType()==bandType) return true; if (band->bandType()==bandType) return true;
} }
return false; return false;
@ -197,7 +194,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;
@ -205,7 +202,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;
@ -229,14 +226,14 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe
QSet<BandDesignIntf::BandsType> groupFooterIgnoredBands; QSet<BandDesignIntf::BandsType> groupFooterIgnoredBands;
groupFooterIgnoredBands << BandDesignIntf::DataFooter << BandDesignIntf::GroupHeader; groupFooterIgnoredBands << BandDesignIntf::DataFooter << BandDesignIntf::GroupHeader;
int bandIndex=-1; int bandIndex = -1;
qSort(m_bands.begin(),m_bands.end(),bandSortBandLessThenByIndex); qSort(m_bands.begin(), m_bands.end(), bandSortBandLessThenByIndex);
if (bandType != BandDesignIntf::Data){ if (bandType != BandDesignIntf::Data){
foreach(BandDesignIntf* band,m_bands){ foreach(BandDesignIntf* band,m_bands){
if ((band->bandType() == BandDesignIntf::GroupHeader) && ( band->bandType() > bandType)) break; if ((band->bandType() == BandDesignIntf::GroupHeader) && ( band->bandType() > bandType)) break;
if ((band->bandType() <= bandType)){ if ((band->bandType() <= bandType)){
if (bandIndex <= band->bandIndex()) { if (bandIndex <= band->bandIndex()) {
bandIndex=band->maxChildIndex(bandType)+1; bandIndex=band->maxChildIndex(bandType) + 1;
} }
} else { increaseBandIndex = true; break;} } else { increaseBandIndex = true; break;}
} }
@ -246,11 +243,11 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe
if (band->bandType() == BandDesignIntf::Data) if (band->bandType() == BandDesignIntf::Data)
maxChildIndex = std::max(maxChildIndex, band->maxChildIndex()); maxChildIndex = std::max(maxChildIndex, band->maxChildIndex());
} }
bandIndex = std::max(bandIndex, maxChildIndex+1); bandIndex = std::max(bandIndex, maxChildIndex + 1);
} }
if (bandIndex==-1) { if (bandIndex == -1) {
bandIndex = (int)(bandType); bandIndex = static_cast<int>(bandType);
increaseBandIndex = true; increaseBandIndex = true;
} }
@ -271,12 +268,12 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe
increaseBandIndex = true; increaseBandIndex = true;
break; break;
case BandDesignIntf::SubDetailFooter: case BandDesignIntf::SubDetailFooter:
bandIndex = parentBand->maxChildIndex()+1; bandIndex = parentBand->maxChildIndex() + 1;
increaseBandIndex = true; increaseBandIndex = true;
break; break;
case BandDesignIntf::GroupHeader: case BandDesignIntf::GroupHeader:
if (parentBand->bandType()==BandDesignIntf::GroupHeader) if (parentBand->bandType()==BandDesignIntf::GroupHeader)
bandIndex = parentBand->bandIndex()+1; bandIndex = parentBand->bandIndex() + 1;
else else
bandIndex = parentBand->minChildIndex(BandDesignIntf::GroupHeader); bandIndex = parentBand->minChildIndex(BandDesignIntf::GroupHeader);
increaseBandIndex = true; increaseBandIndex = true;
@ -291,7 +288,7 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe
increaseBandIndex = true; increaseBandIndex = true;
break; break;
case BandDesignIntf::DataFooter: case BandDesignIntf::DataFooter:
bandIndex = parentBand->maxChildIndex()+1; bandIndex = parentBand->maxChildIndex() + 1;
increaseBandIndex = true; increaseBandIndex = true;
break; break;
default : default :
@ -305,9 +302,9 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe
void PageItemDesignIntf::increaseBandIndex(int startIndex) void PageItemDesignIntf::increaseBandIndex(int startIndex)
{ {
if (bandByIndex(startIndex)){ if (bandByIndex(startIndex)){
foreach(BandDesignIntf* band,m_bands){ foreach(BandDesignIntf* band, m_bands){
if (band->bandIndex()>=startIndex){ if (band->bandIndex() >= startIndex){
band->setBandIndex(band->bandIndex()+1); band->setBandIndex(band->bandIndex() + 1);
} }
} }
} }
@ -324,14 +321,13 @@ bool PageItemDesignIntf::isBandRegistred(BandDesignIntf *band)
void PageItemDesignIntf::registerBand(BandDesignIntf *band) void PageItemDesignIntf::registerBand(BandDesignIntf *band)
{ {
if (!isBandRegistred(band)){ if (!isBandRegistred(band)){
if (band->bandIndex()>childBands().count()-1) if (band->bandIndex() > childBands().count() - 1)
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());
connect(band, SIGNAL(destroyed(QObject*)),this,SLOT(bandDeleted(QObject*))); connect(band, SIGNAL(destroyed(QObject*)),this,SLOT(bandDeleted(QObject*)));
connect(band, SIGNAL(posChanged(QObject*, QPointF, QPointF)), connect(band, SIGNAL(posChanged(QObject*, QPointF, QPointF)),
this, SLOT(bandPositionChanged(QObject*, QPointF, QPointF))); this, SLOT(bandPositionChanged(QObject*, QPointF, QPointF)));
@ -430,6 +426,32 @@ void PageItemDesignIntf::setExtendedInDesignMode(bool pageIsExtended)
update(); update();
} }
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;
@ -483,7 +505,7 @@ void PageItemDesignIntf::relocateBands()
QVector<qreal> posByColumn; QVector<qreal> posByColumn;
qSort(m_bands.begin(),m_bands.end(),bandSortBandLessThenByIndex); qSort(m_bands.begin(), m_bands.end(), bandSortBandLessThenByIndex);
int bandIndex = 0; int bandIndex = 0;
if (!(itemMode() & DesignMode)){ if (!(itemMode() & DesignMode)){
@ -535,6 +557,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)
@ -158,6 +158,10 @@ public:
QString printerName() const; QString printerName() const;
void setPrinterName(const QString& printerName); void setPrinterName(const QString& printerName);
void placeTearOffBand();
BandDesignIntf *pageFooter() const;
void setPageFooter(BandDesignIntf *pageFooter);
signals: signals:
void beforeFirstPageRendered(); void beforeFirstPageRendered();
void afterLastPageRendered(); void afterLastPageRendered();
@ -198,6 +202,7 @@ private:
bool m_endlessHeight; bool m_endlessHeight;
bool m_printable; bool m_printable;
QString m_printerName; QString m_printerName;
BandDesignIntf* m_pageFooter;
}; };
typedef QList<PageItemDesignIntf::Ptr> ReportPages; typedef QList<PageItemDesignIntf::Ptr> ReportPages;

View File

@ -659,13 +659,14 @@ void ReportRender::renderPageFooter(PageItemDesignIntf *patternPage)
{ {
BandDesignIntf* band = patternPage->bandByType(BandDesignIntf::PageFooter); BandDesignIntf* band = patternPage->bandByType(BandDesignIntf::PageFooter);
if (band){ if (band){
BandDesignIntf* bandClone = dynamic_cast<BandDesignIntf*>(band->cloneItem(PreviewMode, m_renderPageItem,m_renderPageItem)); BandDesignIntf* bandClone = dynamic_cast<BandDesignIntf*>(band->cloneItem(PreviewMode, m_renderPageItem, m_renderPageItem));
replaceGroupsFunction(bandClone); replaceGroupsFunction(bandClone);
bandClone->updateItemSize(m_datasources); bandClone->updateItemSize(m_datasources);
bandClone->setItemPos(m_patternPageItem->pageRect().x(),m_patternPageItem->pageRect().bottom()-bandClone->height()); bandClone->setItemPos(m_patternPageItem->pageRect().x(),m_patternPageItem->pageRect().bottom()-bandClone->height());
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());
} }
@ -1051,7 +1052,7 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren)
} }
foreach(QList<BandDesignIntf*>* list,m_childBands.values()){ foreach(QList<BandDesignIntf*>* list, m_childBands.values()){
if (registerInChildren && if (registerInChildren &&
band->bandType()!=BandDesignIntf::PageHeader && band->bandType()!=BandDesignIntf::PageHeader &&
band->bandType()!=BandDesignIntf::PageFooter && band->bandType()!=BandDesignIntf::PageFooter &&
@ -1412,19 +1413,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)
{ {
if (m_renderPageItem->isTOC()) if (m_renderPageItem->isTOC())
@ -1471,7 +1459,7 @@ void ReportRender::savePage(bool isLast)
} }
} }
moveTearOffBand(); m_renderPageItem->placeTearOffBand();
m_scriptEngineContext->setCurrentPage(m_renderPageItem); m_scriptEngineContext->setCurrentPage(m_renderPageItem);
emit m_patternPageItem->afterRender(); emit m_patternPageItem->afterRender();
if (isLast) if (isLast)