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

Nested groups has been fixed for callback datasources (Thanks to Louis Coetzer)

This commit is contained in:
Arin Alexander 2017-06-12 13:36:30 +03:00
parent a726104669
commit 41d09a15ea
3 changed files with 18 additions and 7 deletions

View File

@ -673,12 +673,15 @@ void CallbackDatasource::first(){
QVariant CallbackDatasource::data(const QString& columnName) QVariant CallbackDatasource::data(const QString& columnName)
{ {
CallbackInfo info;
info.dataType = CallbackInfo::ColumnData;
info.columnName = columnName;
info.index = m_currentRow;
QVariant result; QVariant result;
emit getCallbackData(info,result); if (!eof()) //Don't read past the end
{
CallbackInfo info;
info.dataType = CallbackInfo::ColumnData;
info.columnName = columnName;
info.index = m_currentRow;
emit getCallbackData(info,result);
}
return result; return result;
} }

View File

@ -53,6 +53,7 @@ public:
virtual bool next() = 0; virtual bool next() = 0;
virtual bool hasNext() = 0; virtual bool hasNext() = 0;
virtual bool prior() = 0; virtual bool prior() = 0;
virtual void undoPrior() = 0;
virtual void first() = 0; virtual void first() = 0;
virtual void last() = 0; virtual void last() = 0;
virtual bool bof() = 0; virtual bool bof() = 0;
@ -354,6 +355,7 @@ public:
bool next(); bool next();
bool hasNext(); bool hasNext();
bool prior(); bool prior();
void undoPrior() {m_curRow++;}
void first(); void first();
void last(); void last();
bool eof(); bool eof();
@ -384,6 +386,7 @@ public:
bool next(); bool next();
bool hasNext(){ if (!m_eof) return checkNextRecord(m_currentRow); else return false;} bool hasNext(){ if (!m_eof) return checkNextRecord(m_currentRow); else return false;}
bool prior(){ if (m_currentRow !=-1) {m_currentRow--; return true;} else return false;} bool prior(){ if (m_currentRow !=-1) {m_currentRow--; return true;} else return false;}
void undoPrior() {m_currentRow++;}
void first(); void first();
void last(){} void last(){}
bool bof(){return m_currentRow == -1;} bool bof(){return m_currentRow == -1;}

View File

@ -675,7 +675,7 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
IGroupBand* gb = dynamic_cast<IGroupBand*>(band); IGroupBand* gb = dynamic_cast<IGroupBand*>(band);
if (gb&&gb->isNeedToClose(m_datasources)){ if (gb&&gb->isNeedToClose(m_datasources)){
if (band->childBands().count()>0){ if (band->childBands().count()>0){
dataSource->prior(); bool didGoBack = dataSource->prior();
foreach (BandDesignIntf* subBand, band->childrenByType(BandDesignIntf::GroupHeader)) { foreach (BandDesignIntf* subBand, band->childrenByType(BandDesignIntf::GroupHeader)) {
foreach(BandDesignIntf* footer, subBand->childrenByType(BandDesignIntf::GroupFooter)){ foreach(BandDesignIntf* footer, subBand->childrenByType(BandDesignIntf::GroupFooter)){
renderBand(footer, 0); renderBand(footer, 0);
@ -687,7 +687,12 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
renderBand(footer, 0, StartNewPageAsNeeded); renderBand(footer, 0, StartNewPageAsNeeded);
} }
dataSource->next(); if (didGoBack)
{
//New Method to undo prior... Alternatively pass in bool isUndoPrior into next()
dataSource->undoPrior();
//dataSource->next(); //Also emit changePos, which it should not at this point
}
} }
closeDataGroup(band); closeDataGroup(band);
// if (gb->isNeedToStartNewPage()){ // if (gb->isNeedToStartNewPage()){