0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

Old page ranges have been removed

This commit is contained in:
Arin Alexander 2019-01-17 00:26:27 +03:00
parent 83fd13589e
commit ed05f5442e
3 changed files with 27 additions and 56 deletions

View File

@ -223,7 +223,10 @@ namespace LimeReport {
void multiItemsSelected(QList<QObject*>* objectsList);
void miltiItemsSelectionFinished();
void commandHistoryChanged();
void itemPropertyChanged(const QString& objectName, const QString& propertyName, const QVariant& oldValue, const QVariant& newValue);
void itemPropertyChanged(const QString& objectName,
const QString& propertyName,
const QVariant& oldValue,
const QVariant& newValue);
void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band);
@ -275,7 +278,9 @@ namespace LimeReport {
void checkSizeOrPosChanges();
CommandIf::Ptr createChangePosCommand();
CommandIf::Ptr createChangeSizeCommand();
void saveChangeProppertyCommand(const QString& objectName, const QString& propertyName, const QVariant& oldPropertyValue, const QVariant& newPropertyValue);
void saveChangeProppertyCommand(const QString& objectName, const QString& propertyName,
const QVariant& oldPropertyValue,
const QVariant& newPropertyValue);
void changeSelectedGroupProperty(const QString& name,const QVariant& value);
private:

View File

@ -148,7 +148,7 @@ void ReportRender::renameChildItems(BaseDesignIntf *item){
ReportRender::ReportRender(QObject *parent)
:QObject(parent), m_renderPageItem(0), m_pageCount(0),
m_lastRenderedHeader(0), m_lastDataBand(0), m_lastRenderedFooter(0), m_currentColumn(0), m_newPageStarted(false), m_renderingFirstTOC(false)
m_lastRenderedHeader(0), m_lastDataBand(0), m_lastRenderedFooter(0), m_currentColumn(0), m_newPageStarted(false)
{
initColumns();
}
@ -192,7 +192,7 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool
{
m_currentNameIndex = 0;
m_patternPageItem = patternPage;
m_renderingFirstTOC = isTOC && isFirst;
if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) {
resetPageNumber(PageReset);
}
@ -201,14 +201,6 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool
m_pagesRanges.startNewRange();
}
if (m_renderingFirstTOC && resetPageNumbers){
PagesRange range;
range.firstPage = 0;
range.lastPage = 0;
m_ranges.insert(0,range);
m_pageCount = 0;
}
m_renderCanceled = false;
BandDesignIntf* reportFooter = m_patternPageItem->bandByType(BandDesignIntf::ReportFooter);
m_reportFooterHeight = 0;
@ -251,11 +243,6 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool
savePage(true);
if (m_renderingFirstTOC && resetPageNumbers && m_ranges.count()>1){
m_ranges[1].firstPage = m_ranges.first().lastPage+1;
m_ranges[1].lastPage += m_ranges.first().lastPage+1;
}
#ifndef USE_QJSENGINE
ScriptEngineManager::instance().scriptEngine()->popContext();
#endif
@ -1141,15 +1128,15 @@ void ReportRender::secondRenderPass(ReportPages renderedPages)
for(int i=0; i<renderedPages.count(); ++i){
PageItemDesignIntf::Ptr page = renderedPages.at(i);
foreach(BaseDesignIntf* item, page->childBaseItems()){
updateTOC(item, findPageNumber(i));
updateTOC(item, m_pagesRanges.findPageNumber(i));
}
}
}
for(int i=0; i<renderedPages.count(); ++i){
PageItemDesignIntf::Ptr page = renderedPages.at(i);
m_datasources->setReportVariable("#PAGE",findPageNumber(i));
m_datasources->setReportVariable("#PAGE_COUNT",findLastPageNumber(i));
m_datasources->setReportVariable("#PAGE",m_pagesRanges.findPageNumber(i));
m_datasources->setReportVariable("#PAGE_COUNT",m_pagesRanges.findLastPageNumber(i));
foreach(BaseDesignIntf* item, page->childBaseItems()){
item->updateItemSize(m_datasources, SecondPass);
}
@ -1265,37 +1252,10 @@ void ReportRender::startNewPage(bool isFirst)
void ReportRender::resetPageNumber(ResetPageNuberType resetType)
{
m_pagesRanges.startNewRange();
PagesRange range;
if (!m_ranges.isEmpty()){
currentRange().lastPage = (resetType == BandReset)? m_pageCount : m_pageCount-1;
range.firstPage = m_pageCount+((resetType == BandReset)? 1 : 0);
} else {
range.firstPage = m_pageCount;
}
range.lastPage = (resetType == BandReset)? 0 : m_pageCount;
m_ranges.append(range);
if (resetType == PageReset)
m_datasources->setReportVariable("#PAGE",1);
}
int ReportRender::findLastPageNumber(int currentPage)
{
foreach (PagesRange range, m_ranges) {
if ( range.firstPage<= (currentPage) && range.lastPage>= (currentPage) )
return (range.lastPage-(range.firstPage))+1;
}
return 0;
}
int ReportRender::findPageNumber(int currentPage)
{
foreach (PagesRange range, m_ranges) {
if ( range.firstPage<= (currentPage) && range.lastPage>= (currentPage) )
return (currentPage - range.firstPage)+1;
}
return 0;
}
void ReportRender::cutGroups()
{
m_popupedExpression.clear();
@ -1440,14 +1400,12 @@ void ReportRender::savePage(bool isLast)
}
}
if (currentRange(m_renderingFirstTOC).lastPage==0 && m_ranges.count()>1) {
if (m_pagesRanges.currentRange(m_patternPageItem->isTOC()).firstPage == 0) {
m_datasources->setReportVariable("#PAGE",1);
} else {
m_datasources->setReportVariable("#PAGE",m_datasources->variable("#PAGE").toInt()+1);
}
currentRange(m_renderingFirstTOC).lastPage = m_pageCount;
BandDesignIntf* pageFooter = m_renderPageItem->bandByType(BandDesignIntf::PageFooter);
if (pageFooter) pageFooter->setBandIndex(++m_currentIndex);
m_renderedPages.append(PageItemDesignIntf::Ptr(m_renderPageItem));
@ -1493,6 +1451,7 @@ void ReportRender::cancelRender(){
int PagesRanges::findLastPageNumber(int index)
{
index++;
foreach (PagesRange range, m_ranges) {
if ( range.firstPage <= (index) && range.lastPage>= (index) )
return (range.lastPage-(range.firstPage))+1;
@ -1502,6 +1461,7 @@ int PagesRanges::findLastPageNumber(int index)
int PagesRanges::findPageNumber(int index)
{
index++;
foreach (PagesRange range, m_ranges) {
if ( range.firstPage <= (index) && range.lastPage >= (index) )
return (index - range.firstPage)+1;
@ -1509,6 +1469,13 @@ int PagesRanges::findPageNumber(int index)
return 0;
}
PagesRange&PagesRanges::currentRange(bool isTOC)
{
Q_ASSERT( (isTOC && m_TOCRangeIndex!=-1) || !isTOC);
if (isTOC && m_TOCRangeIndex !=-1) return m_ranges[m_TOCRangeIndex];
return m_ranges.last();
}
void PagesRanges::startNewRange(bool isTOC)
{
PagesRange range;

View File

@ -69,6 +69,7 @@ public:
PagesRanges(): m_TOCRangeIndex(-1) {}
int findLastPageNumber(int index);
int findPageNumber(int index);
PagesRange& currentRange(bool isTOC);
void startNewRange(bool isTOC = false);
void addTOCMarker(bool addNewRange);
void addPage();
@ -166,8 +167,8 @@ private:
void startNewColumn();
void startNewPage(bool isFirst = false);
void resetPageNumber(ResetPageNuberType resetType);
int findLastPageNumber(int currentPage);
int findPageNumber(int currentPage);
//int findLastPageNumber(int currentPage);
//int findPageNumber(int currentPage);
void savePage(bool isLast = false);
QString toString();
void initColumns();
@ -180,7 +181,7 @@ private:
void renameChildItems(BaseDesignIntf *item);
void renderGroupFooterByHeader(BandDesignIntf *groupHeader);
void updateTOC(BaseDesignIntf* item, int pageNumber);
PagesRange& currentRange(bool isTOC = false){ return (isTOC) ? m_ranges.first(): m_ranges.last();}
//PagesRange& currentRange(bool isTOC = false){ return (isTOC) ? m_ranges.first(): m_ranges.last();}
void placeBandOnPage(BandDesignIntf *band, int columnIndex);
private:
DataSourceManager* m_datasources;
@ -209,12 +210,10 @@ private:
QVector<qreal> m_maxHeightByColumn;
QVector<qreal> m_currentStartDataPos;
int m_currentColumn;
QList<PagesRange> m_ranges;
PagesRanges m_pagesRanges;
QVector<BandDesignIntf*> m_columnedBandItems;
unsigned long long m_currentNameIndex;
bool m_newPageStarted;
bool m_renderingFirstTOC;
};
} // namespace LimeReport