From c9d378a927ef6db59a80b72e30bb6f66d43eedc2 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Thu, 26 May 2016 23:21:42 +0400 Subject: [PATCH] Generating unique names for page items has been added --- limereport/lrreportrender.cpp | 14 ++++++++++++-- limereport/lrreportrender.h | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 0a7f450..27d3b30 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -139,6 +139,13 @@ qreal ReportRender::maxColumnHeight() return result; } +void ReportRender::renameChildItems(BaseDesignIntf *item){ + foreach(BaseDesignIntf* child, item->childBaseItems()){ + if (!child->childBaseItems().isEmpty()) renameChildItems(child); + child->setObjectName(child->metaObject()->className()+QString::number(++m_curentNameIndex)); + } +} + ReportRender::ReportRender(QObject *parent) :QObject(parent), m_renderPageItem(0), m_pageCount(0), m_currentColumn(0), m_lastDataBand(0), m_lastRenderedFooter(0) @@ -163,8 +170,9 @@ void ReportRender::initDatasources(){ void ReportRender::renderPage(PageDesignIntf* patternPage) { - m_patternPageItem=patternPage->pageItem(); - m_pageCount=1; + m_curentNameIndex = 0; + m_patternPageItem = patternPage->pageItem(); + m_pageCount = 1; m_renderCanceled = false; BandDesignIntf* reportFooter = m_patternPageItem->bandByType(BandDesignIntf::ReportFooter); m_reportFooterHeight = 0; @@ -728,6 +736,8 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren) } if (band->isData()) m_renderedDataBandCount++; + band->setObjectName(band->objectName()+QString::number(++m_curentNameIndex)); + renameChildItems(band); return true; } else return false; } diff --git a/limereport/lrreportrender.h b/limereport/lrreportrender.h index ceda52f..a5c7562 100644 --- a/limereport/lrreportrender.h +++ b/limereport/lrreportrender.h @@ -74,7 +74,6 @@ public: ReportRender(QObject *parent = 0); void setDatasources(DataSourceManager* value); DataSourceManager* datasources(){return m_datasources;} - void renderPage(PageDesignIntf *patternPage); int pageCount(); PageItemDesignIntf::Ptr pageAt(int index); QString renderPageToString(PageDesignIntf *patternPage); @@ -84,6 +83,7 @@ signals: public slots: void cancelRender(); private: + void renderPage(PageDesignIntf *patternPage); void initDatasources(); void initRenderPage(); void initVariables(); @@ -131,8 +131,6 @@ private: int findLastPageNumber(int currentPage); void savePage(); QString toString(); - -private: void initColumns(); bool isNeedToRearrangeColumnsItems(); BandDesignIntf* lastColumnItem(int columnIndex); @@ -140,6 +138,7 @@ private: int columnItemsCount(int columnIndex); qreal columnHeigth(int columnIndex); qreal maxColumnHeight(); + void renameChildItems(BaseDesignIntf *item); private: DataSourceManager* m_datasources; PageItemDesignIntf* m_renderPageItem; @@ -169,6 +168,7 @@ private: int m_currentColumn; QList m_ranges; QVector m_columnedBandItems; + unsigned long long m_curentNameIndex; }; } // namespace LimeReport #endif // LRREPORTRENDER_H