diff --git a/limereport/lrdatadesignintf.cpp b/limereport/lrdatadesignintf.cpp index 37b3d4c..c3e9344 100644 --- a/limereport/lrdatadesignintf.cpp +++ b/limereport/lrdatadesignintf.cpp @@ -673,12 +673,15 @@ void CallbackDatasource::first(){ QVariant CallbackDatasource::data(const QString& columnName) { - CallbackInfo info; - info.dataType = CallbackInfo::ColumnData; - info.columnName = columnName; - info.index = m_currentRow; 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; } diff --git a/limereport/lrdatadesignintf.h b/limereport/lrdatadesignintf.h index e2f8134..8737bb2 100644 --- a/limereport/lrdatadesignintf.h +++ b/limereport/lrdatadesignintf.h @@ -53,6 +53,7 @@ public: virtual bool next() = 0; virtual bool hasNext() = 0; virtual bool prior() = 0; + virtual void undoPrior() = 0; virtual void first() = 0; virtual void last() = 0; virtual bool bof() = 0; @@ -354,6 +355,7 @@ public: bool next(); bool hasNext(); bool prior(); + void undoPrior() {m_curRow++;} void first(); void last(); bool eof(); @@ -384,6 +386,7 @@ public: bool next(); 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;} + void undoPrior() {m_currentRow++;} void first(); void last(){} bool bof(){return m_currentRow == -1;} diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 9e6ea4c..bb88770 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -675,7 +675,7 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da IGroupBand* gb = dynamic_cast(band); if (gb&&gb->isNeedToClose(m_datasources)){ if (band->childBands().count()>0){ - dataSource->prior(); + bool didGoBack = dataSource->prior(); foreach (BandDesignIntf* subBand, band->childrenByType(BandDesignIntf::GroupHeader)) { foreach(BandDesignIntf* footer, subBand->childrenByType(BandDesignIntf::GroupFooter)){ renderBand(footer, 0); @@ -687,7 +687,12 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da 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); // if (gb->isNeedToStartNewPage()){