/** Draws the detail section to the selected painter & x/y-offsets */ void MReportDetail::draw( QPainter* p, int xoffset, int yoffset ) { MFieldObject * field; // Set the offsets int xcalc = xoffset; int ycalc = yoffset; // Draw the base objects drawObjects( p, xoffset, yoffset ); // Draw the field collection for ( field = fields.first(); field != 0; field = fields.next() ) { field->draw( p, xcalc, ycalc ); } }
/** Draws the section base objects to the specified painter & x/y offsets */ void MReportSection::drawObjects( FLStylePainter * p, int xoffset, int yoffset, int &newHeight ) { MLineObject * line; MLabelObject *label; MSpecialObject *special; MCalcObject *calcfield; MFieldObject *field; // Set the offsets int xcalc = xoffset; int ycalc = yoffset; int modifiedHeight = 0; csvData_ = ""; QString fieldValue; QObject::setName( QString( "_##%1-%2" ).arg( strIdSec_ ).arg( level ) ); p->beginSection( xcalc, ycalc, width, height, this ); uint countObj = 0; // Draw the line collection for ( line = lines.first(); line != 0; line = lines.next() ) { line->QObject::setName( QString( "_##Line%1-%2" ).arg( idSec_ ).arg( countObj++ ) ); p->beginMark( line->xpos1, line->ypos1, line ); line->draw( p ); p->endMark(); } // Draw the label collection for ( label = labels.first(); label != 0; label = labels.next() ) { label->QObject::setName( QString( "_##Label%1-%2" ).arg( idSec_ ).arg( countObj++ ) ); p->beginMark( label->getX(), label->getY(), label ); modifiedHeight = label->draw( p ); p->endMark(); if ( modifiedHeight && ( label->getY() + modifiedHeight ) > height ) newHeight = label->getY() + modifiedHeight; } // Draw the calculated field collection for ( calcfield = calculatedFields.first(); calcfield != 0; calcfield = calculatedFields.next() ) { if ( !calcfield->getDrawAtHeader() ) { calcfield->QObject::setName( QString( "_##%1-Calc.%2-%3" ).arg( idSec_ ).arg( calcfield->fieldName ).arg( countObj++ ) ); p->beginMark( calcfield->getX(), calcfield->getY(), calcfield ); modifiedHeight = calcfield->draw( p ); p->endMark(); if ( modifiedHeight && ( calcfield->getY() + modifiedHeight ) > height ) newHeight = calcfield->getY() + modifiedHeight; } if ( calcfield->getCalculationType() == MCalcObject::NoOperation || calcfield->getCalculationType() == MCalcObject::CallFunction ) { fieldValue = calcfield->getText(); fieldValue.replace( "\n", "-" ); csvData_ += "|" + fieldValue; } } // Draw the special field collection for ( special = specialFields.first(); special != 0; special = specialFields.next() ) { special->QObject::setName( QString( "_##SpecialField%1-%2" ).arg( idSec_ ).arg( countObj++ ) ); p->beginMark( special->getX(), special->getY(), special ); switch ( special->getType() ) { case MSpecialObject::Date: special->setText( reportDate ); break; case MSpecialObject::PageNumber: special->setText( pageNumber ); break; } special->draw( p ); p->endMark(); } // Draw the field collection for ( field = fields.first(); field != 0; field = fields.next() ) { field->QObject::setName( QString( "_##%1.%2-%3" ).arg( idSec_ ).arg( field->fieldName ).arg( countObj++ ) ); p->beginMark( field->getX(), field->getY(), field ); modifiedHeight = field->draw( p ); p->endMark(); if ( modifiedHeight && ( field->getY() + modifiedHeight ) > height ) newHeight = field->getY() + modifiedHeight; fieldValue = field->getText(); fieldValue.replace( "\n", "-" ); csvData_ += "|" + fieldValue; } p->endSection(); }
/** Returns the name of the bound field for field object at the given index */ QString MReportSection::getFieldName( int idx ) { MFieldObject * field = fields.at( idx ); return field->getFieldName(); }
void MReportSection::setFieldData( int idx, QString data ) { MFieldObject * field = fields.at( idx ); field->setText( data ); }