Logo Search packages:      
Sourcecode: facturalux version File versions  Download package

void MReportEngine::drawDetail ( MPageCollection pages,
int  level,
uint &  currRecord 
) [protected]

Draws the detail to the level

Definition at line 402 of file mreportengine.cpp.

References cancelRender, currDate, currHeight, currPage, currY, MReportDetail::draw(), drawDetailFooter(), drawDetailHeader(), findDetail(), findDetailFooter(), MReportSection::getCalcFieldCount(), MReportSection::getCalcFieldIndex(), MReportDetail::getFieldCount(), MReportDetail::getFieldName(), MReportSection::getHeight(), grandTotal, leftMargin, MReportSection::newPage(), newPage(), p, rFooter, MReportDetail::setFieldData(), MReportSection::setPageNumber(), and MReportSection::setReportDate().

Referenced by renderReport().

{
    drawDetailHeader(pages,level);
    MReportDetail *detail = findDetail (level);
    if (!detail)
        {
            drawDetailFooter(pages,level);
            return;
        }

    QPtrList<QMemArray<double> > gDT;
    gDT.setAutoDelete(true);
    int currLevel;
    int chkRow = 0;

    do
        {
            QString detailValue;
              QDomNode record = records.item (currRecord);

            if (record.nodeType () == QDomNode::ElementNode)
                        {
                    if ((chkRow = (currRecord / 2) % 20) == 0)
                        emit signalRenderStatus (currRecord / 2);
                    if (cancelRender)
                        {
                            p.end ();
                            if (pages)
                                delete pages;
                            return;
                        }

                    QDomNamedNodeMap fields = record.attributes ();
                    MReportSection *footer = findDetailFooter (level);
                    if (footer)
                        {
                            for (int i = 0; i < footer->getCalcFieldCount (); i++)
                                gDT.append (new QMemArray < double >);
                        }

                    for ( int i=0; i < detail->getFieldCount(); i++ )
                        {
                            detailValue = fields.namedItem (detail->getFieldName (i)).nodeValue ();
                            detail->setFieldData (i, detailValue);
                            int calcIdx = rFooter.getCalcFieldIndex (detail->getFieldName (i));
                            if (calcIdx != -1)
                                {
                                    int vsize = grandTotal.at (calcIdx)->size ();

                                    grandTotal.at (calcIdx)->resize (vsize + 1);
                                    grandTotal.at (calcIdx)->at (vsize) = detailValue.toDouble ();
                                }
                            if (footer)
                                {
                                    calcIdx = footer->getCalcFieldIndex(detail->getFieldName(i));
                                    if (calcIdx != -1)
                                        {
                                            int vsize = gDT.at (calcIdx)->size ();

                                            gDT.at (calcIdx)->resize (vsize + 1);
                                            gDT.at (calcIdx)->at (vsize) = detailValue.toDouble ();
                                    }
                                }
                        }

                    detail->setPageNumber (currPage);
                    detail->setReportDate (currDate);
                    if ((currY + detail->getHeight ()) > currHeight)
                        newPage (pages);

                    detail->draw (&p, leftMargin, currY);
                    currY += detail->getHeight ();

                    currRecord+=1;

                    if(currRecord < records.count())
                        {
                            record = records.item (currRecord);
                            fields = record.attributes ();

                            detailValue = fields.namedItem ("level").nodeValue ();
                            currLevel = detailValue.toInt();
                        }

                    drawDetail(pages,level+1,currRecord);

                    if(currRecord >= records.count())
                        break;

                    drawDetailHeader(pages,level);

                    if (cancelRender)
                      {
                            p.end ();
                            if (pages)
                                delete pages;
                            return;
                    }
                }
        }
    while (level <=currLevel && currRecord < records.count());

    drawDetailFooter(pages,level,&gDT);
    MReportSection *footer = findDetailFooter (level);
    if (footer && currRecord < records.count())
        if (footer->newPage())
            newPage(pages);
    gDT.clear();
}


Generated by  Doxygen 1.6.0   Back to index