TableBuilder has been fixed

This commit is contained in:
Arin Alexander 2019-02-05 22:34:38 +03:00
parent 87d0bd5f28
commit 65a3a36770
3 changed files with 17 additions and 7 deletions

View File

@ -1844,12 +1844,19 @@ QObject* DatasourceFunctions::createTableBuilder(BaseDesignIntf* horizontalLayou
return new TableBuilder(dynamic_cast<LimeReport::HorizontalLayout*>(horizontalLayout), dynamic_cast<DataSourceManager*>(m_dataManager));
}
TableBuilder::TableBuilder(HorizontalLayout* layout, DataSourceManager* dataManager)
: m_horizontalLayout(layout), m_baseLayout(0), m_dataManager(dataManager)
{
if (m_horizontalLayout)
m_patternLayout = dynamic_cast<HorizontalLayout*>(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<BaseDesignIntf*>(m_horizontalLayout->at(i));
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(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()

View File

@ -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;
};