From 65a3a367706bf248779c07b26839ec0bf4557c67 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 5 Feb 2019 22:34:38 +0300 Subject: [PATCH] TableBuilder has been fixed --- limereport/items/lrhorizontallayout.cpp | 2 +- limereport/lrscriptenginemanager.cpp | 16 +++++++++++++--- limereport/lrscriptenginemanager.h | 6 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/limereport/items/lrhorizontallayout.cpp b/limereport/items/lrhorizontallayout.cpp index e5cd0af..c981e40 100644 --- a/limereport/items/lrhorizontallayout.cpp +++ b/limereport/items/lrhorizontallayout.cpp @@ -169,7 +169,7 @@ void HorizontalLayout::updateLayoutSize() void HorizontalLayout::relocateChildren() { int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; - if (layoutsChildren().count()(horizontalLayout), dynamic_cast(m_dataManager)); } +TableBuilder::TableBuilder(HorizontalLayout* layout, DataSourceManager* dataManager) + : m_horizontalLayout(layout), m_baseLayout(0), m_dataManager(dataManager) +{ + if (m_horizontalLayout) + m_patternLayout = dynamic_cast(m_horizontalLayout->cloneItem(m_horizontalLayout->itemMode())); +} + QObject* TableBuilder::addRow() { checkBaseLayout(); HorizontalLayout* newRow = new HorizontalLayout(m_baseLayout, m_baseLayout); for(int i = 0; i < m_horizontalLayout->childrenCount(); ++i){ - BaseDesignIntf* item = dynamic_cast(m_horizontalLayout->at(i)); + BaseDesignIntf* item = dynamic_cast(m_patternLayout->at(i)); BaseDesignIntf* cloneItem = item->cloneItem(item->itemMode(), newRow, newRow); newRow->addChild(cloneItem); } @@ -1883,11 +1890,14 @@ void TableBuilder::buildTable(const QString& datasourceName) checkBaseLayout(); m_dataManager->dataSourceHolder(datasourceName)->invalidate(IDataSource::RENDER_MODE); m_dataManager->dataSource(datasourceName)->first(); + bool firstTime = true; + QObject* row = m_horizontalLayout; while(!m_dataManager->dataSource(datasourceName)->eof()){ - fillInRowData(addRow()); + if (!firstTime) row = addRow(); + else firstTime = false; + fillInRowData(row); m_dataManager->dataSource(datasourceName)->next(); } - m_horizontalLayout->setHeight(0); } void TableBuilder::checkBaseLayout() diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 3e8db0c..0295055 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -307,9 +307,8 @@ private: class TableBuilder: public QObject{ Q_OBJECT public: - TableBuilder(LimeReport::HorizontalLayout* layout, DataSourceManager* dataManager) - : m_horizontalLayout(layout), m_baseLayout(0), m_dataManager(dataManager){} - ~TableBuilder(){} + TableBuilder(LimeReport::HorizontalLayout* layout, DataSourceManager* dataManager); + ~TableBuilder(){delete m_patternLayout;} Q_INVOKABLE QObject* addRow(); Q_INVOKABLE QObject* currentRow(); Q_INVOKABLE void fillInRowData(QObject* row); @@ -318,6 +317,7 @@ private: void checkBaseLayout(); private: LimeReport::HorizontalLayout* m_horizontalLayout; + LimeReport::HorizontalLayout* m_patternLayout; LimeReport::VerticalLayout* m_baseLayout; DataSourceManager* m_dataManager; };