Menu

Data group header and footer overlaps with page footer

puterk
2014-11-24
2014-11-26
  • puterk

    puterk - 2014-11-24

    Hello,

    The data group header and footer paints over the page footer on preview so i tried to add some lines from other functions to prcessGroupHeader.

    This is my prcessGroupHeader:

    void QtRPT::prcessGroupHeader(QPrinter *printer, int &y, bool draw, int pageReport) {
    m_recNo = 0;
    if (dataGroupHeader.isNull()) {

        processMHeader(y,draw);
        processPFooter(draw);
        processMasterData(printer,y,draw,pageReport);
        processMFooter(printer,y,draw);
    } else {
        fillListOfValue(masterData);
        if (listOfPair.size() > 0) {
            QDomElement e  = dataGroupHeader.toElement();
            QDomElement e1 = dataGroupFooter.toElement();
            QString groupingField = e.attribute("groupingField");
    
            for (int i = 0; i < recordCount.at(pageReport); i++) {
                m_recNo = i;                
                sectionField(e, groupingField, false, true);
            }
    
            listOfGroup.clear();
            mg_recNo = 0;
    
            if (masterHeader.toElement().attribute("showInGroup").toInt() == 0)
                processMHeader(y,draw);
    
            int grpNo = 0;
            for (int j = 0; j < listOfPair.size(); ++j) {
                if (listOfPair.at(j).pageReport == pageReport && listOfPair.at(j).paramName == groupingField) {
                    bool founded = false;
                    for (int i=0; i < listOfGroup.size(); ++i) {
                        if (listOfGroup.at(i) == listOfPair.at(j).paramValue)
                            founded = true;
                    }
    
                    listIdxOfGroup.clear();
                    for (int k=0; k < listOfPair.size(); ++k) {
                        if (listOfPair.at(k).paramName == groupingField &&
                            listOfPair.at(k).pageReport == pageReport &&
                            listOfPair.at(k).paramValue.toString() == listOfPair.at(j).paramValue.toString()
                           ) {
                            //fill the idx for current group
                            listIdxOfGroup << listOfPair.at(k).lnNo;
                        }
                    }
    
                    if (!founded) { //Start new group
                        grpNo += 1;
    
                        //Added codes here
                        int yPF = 0;
    
                        if (!pageFooter.isNull()) {
                            QDomElement pf = pageFooter.toElement();
                            yPF = pf.attribute("height").toInt();
                        }
    
                        int yMF = 0;
                        if (!masterFooter.isNull()) {
                            QDomElement mf = masterFooter.toElement();
                            yMF = mf.attribute("height").toInt();
                        }  
                        //ends here
    
                        listOfGroup << listOfPair.at(j).paramValue.toString();
    
                        if (e.attribute("startNewPage").toInt() == 1 && grpNo != 1) //Start new page for each Data group
                            newPage(printer, y, draw);
    
                        m_recNo = listOfPair.at(j).lnNo;
    
                        //Start new numeration for group
                        if (e.attribute("startNewNumeration").toInt() != 0)
                            mg_recNo = 0;
    
                        //Added codes here
                        if (y + e.attribute("realHeight").toInt() > ph-mb-mt-yPF-yMF)
                            newPage(printer, y, draw);
                        //ends here
    
                        if (allowPrintPage(draw,curPage))  //Draw header of the group
                            drawBandRow(dataGroupHeader,y);
                        y += e.attribute("height").toInt();
    
                        if (masterHeader.toElement().attribute("showInGroup").toInt() == 1)
                            processMHeader(y,draw);
                        processPFooter(draw);
                        processMasterData(printer,y,draw,pageReport);
                        if (masterFooter.toElement().attribute("showInGroup").toInt() == 1)
                            processMFooter(printer,y,draw);
                        //---
                        m_recNo = listOfPair.at(j).lnNo;
    
                        //Added codes here
                        if (y + e.attribute("realHeight").toInt() > ph-mb-mt-yPF-yMF)
                            newPage(printer, y, draw);
                        //ends here
    
                        if (allowPrintPage(draw,curPage)) { //Draw footer of the group
                            drawBandRow(dataGroupFooter,y);
                        }
                        y += e1.attribute("height").toInt();
                    }
                }
            }
            if (masterFooter.toElement().attribute("showInGroup").toInt() == 0)
                processMFooter(printer,y,draw);
        }
    }
    

    }

     
    • aliks-os

      aliks-os - 2014-11-24

      May you make a screenshoot of preview with a bug?

       
  • aliks-os

    aliks-os - 2014-11-24

    Thank you for your correction. I made changes in the source code. Today evening I will upload to SVN.

     
  • puterk

    puterk - 2014-11-25

    Hello again,

    Thanks for all your efforts.

    By the way, The codes I inserted might have affected the page count (TotalPages). I don't know how to fix this one.

     
  • aliks-os

    aliks-os - 2014-11-25

    So please give me your xml file and if possible some example code to fill the data of the report to simulate the situatuin

     

    Last edit: aliks-os 2014-11-25

Log in to post a comment.

MongoDB Logo MongoDB