mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2025-03-15 06:46:23 +03:00
Group functions rendering has been optimized
This commit is contained in:
parent
109e216281
commit
9b914b05fd
@ -189,11 +189,45 @@ void ReportRender::initDatasource(const QString& name){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
||||||
|
if (contentItem){
|
||||||
|
QString content = contentItem->content();
|
||||||
|
QVector<QString> functions;
|
||||||
|
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||||
|
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||||
|
rx.setMinimal(true);
|
||||||
|
if (rx.indexIn(content)>=0){
|
||||||
|
functions.append(functionName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (functions.size()>0)
|
||||||
|
m_groupfunctionItems.insert(contentItem->patternName(), functions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportRender::analizeContainer(BaseDesignIntf* item, BandDesignIntf* band){
|
||||||
|
foreach(BaseDesignIntf* child, item->childBaseItems()){
|
||||||
|
ContentItemDesignIntf* contentItem = dynamic_cast<ContentItemDesignIntf*>(child);
|
||||||
|
if (contentItem) analizeItem(contentItem, band);
|
||||||
|
else analizeContainer(child, band);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportRender::analizePage(PageItemDesignIntf* patternPage){
|
||||||
|
foreach(BandDesignIntf* band, patternPage->bands()){
|
||||||
|
if (band->isFooter() || band->isHeader()){
|
||||||
|
analizeContainer(band,band);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool /*isFirst*/, bool /*resetPageNumbers*/)
|
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool /*isFirst*/, bool /*resetPageNumbers*/)
|
||||||
{
|
{
|
||||||
m_currentNameIndex = 0;
|
m_currentNameIndex = 0;
|
||||||
m_patternPageItem = patternPage;
|
m_patternPageItem = patternPage;
|
||||||
|
|
||||||
|
analizePage(patternPage);
|
||||||
|
|
||||||
if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) {
|
if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) {
|
||||||
resetPageNumber(PageReset);
|
resetPageNumber(PageReset);
|
||||||
}
|
}
|
||||||
@ -380,11 +414,11 @@ void ReportRender::extractGroupFunctions(BandDesignIntf *band)
|
|||||||
extractGroupFunctionsFromContainer(band, band);
|
extractGroupFunctionsFromContainer(band, band);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
||||||
if (contentItem){
|
if (contentItem){
|
||||||
|
if (m_groupfunctionItems.contains(contentItem->patternName())){
|
||||||
QString content = contentItem->content();
|
QString content = contentItem->content();
|
||||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){
|
||||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
if (rx.indexIn(content)>=0){
|
if (rx.indexIn(content)>=0){
|
||||||
@ -405,9 +439,10 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
|
|||||||
}
|
}
|
||||||
pos += rx.matchedLength();
|
pos += rx.matchedLength();
|
||||||
}
|
}
|
||||||
contentItem->setContent(content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
contentItem->setContent(content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ private:
|
|||||||
int m_TOCRangeIndex;
|
int m_TOCRangeIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ReportRender: public QObject
|
class ReportRender: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -109,6 +110,10 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void cancelRender();
|
void cancelRender();
|
||||||
private:
|
private:
|
||||||
|
void analizeContainer(BaseDesignIntf *item, BandDesignIntf *band);
|
||||||
|
void analizeItem(ContentItemDesignIntf *item, BandDesignIntf *band);
|
||||||
|
void analizePage(PageItemDesignIntf *patternPage);
|
||||||
|
|
||||||
void initDatasources();
|
void initDatasources();
|
||||||
void initDatasource(const QString &name);
|
void initDatasource(const QString &name);
|
||||||
void initRenderPage();
|
void initRenderPage();
|
||||||
@ -193,7 +198,7 @@ private:
|
|||||||
QMultiMap< BandDesignIntf*, GroupBandsHolder* > m_childBands;
|
QMultiMap< BandDesignIntf*, GroupBandsHolder* > m_childBands;
|
||||||
QList<BandDesignIntf*> m_reprintableBands;
|
QList<BandDesignIntf*> m_reprintableBands;
|
||||||
QList<BandDesignIntf*> m_recalcBands;
|
QList<BandDesignIntf*> m_recalcBands;
|
||||||
|
QMap<QString, QVector<QString>> m_groupfunctionItems;
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
int m_pageCount;
|
int m_pageCount;
|
||||||
|
|
||||||
@ -217,6 +222,7 @@ private:
|
|||||||
bool m_newPageStarted;
|
bool m_newPageStarted;
|
||||||
bool m_lostHeadersMoved;
|
bool m_lostHeadersMoved;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
#endif // LRREPORTRENDER_H
|
#endif // LRREPORTRENDER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user