本文整理汇总了C++中QPrinter::paperRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrinter::paperRect方法的具体用法?C++ QPrinter::paperRect怎么用?C++ QPrinter::paperRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrinter
的用法示例。
在下文中一共展示了QPrinter::paperRect方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paperRect
QRectF QPrinterProto::paperRect(QPrinter::Unit unit) const
{
QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
if (item)
return item->paperRect(unit);
return QRectF();
}
示例2: exportToPDF
void MainWindowController:: exportToPDF()
{
QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Choose PDF location"), "", tr("PDF File(*.pdf)"));
QPrinter prn;
prn.setOutputFileName(QString(fileName));
//QPrintDialog(&prn, mainWindow).exec();
prn.setOrientation(QPrinter::Landscape);
QPainter painter;
painter.begin(&prn);
double x = this->view->getUi()->gameLayout_2->width();
painter.translate(prn.paperRect().x() + 20,
prn.paperRect().y()+20);
this->view->getUi()->gameLayout_2->render(&painter);
painter.translate(prn.paperRect().x() + x,
prn.paperRect().y());
QFont font;
font.setPixelSize(12);
painter.setFont(font);
for (int i = 0 ; i < this->view->getUi()->definitionWidget->count() ; i++)
{
painter.drawText(QPoint(10,10),this->view->getUi()->definitionWidget->item(i)->text() );
if(i %40 == 0&&i>1)
{
painter.translate(QPoint(prn.paperRect().x()+200,
-600));
}
else
{
painter.translate(QPoint(prn.paperRect().x(),
prn.paperRect().y()+15));
}
}
}
示例3: print
void LigneCom::print(QPainter *painter , int &y , QPrinter &printer){
float scaleP = printer.paperRect().width()/A4_X;
int y0 = y;
QFont f = painter->font();
Ligne::print(painter,y,printer);
painter->setFont(font);
if (y0 > y)
y0 = (MARGIN+6)*scaleP;
QRectF rect(MARGIN*scaleP,y0 ,(A4_X-2*MARGIN)*scaleP, LINE_HEIGHT*scaleP);
painter->drawText(rect , infoText , QTextOption(Qt::AlignCenter));
painter->setFont(f);
}
示例4: print
//.........这里部分代码省略.........
QFont header = QFont("Helvetica", 12, QFont::Normal);
QFont headlines = QFont("Helvetica", 12, QFont::Normal, true);
QFont body = QFont("Helvetica", 12, QFont::Normal);
QFont fixed = QFont("Courier", 12, QFont::Normal);
QFont comment = QFont("Helvetica", 10, QFont::Normal);
// store the configuration settings:
KConfigGroup config = KGlobal::config()->group(ConfigSectionName);
useKDEFonts = mPageAppearance->cbStandardFonts->isChecked();
config.writeEntry( UseKDEFonts, useKDEFonts );
// read the font and color selections from the wizard pages:
useBGColor=mPageAppearance->cbBackgroundColor->isChecked();
config.writeEntry( ColoredContactHeaders, useBGColor );
// use colored contact headers, otherwise use plain black and white):
if ( useBGColor ) {
headerColor = mPageAppearance->kcbHeaderTextColor->color();
backColor = mPageAppearance->kcbHeaderBGColor->color();
config.writeEntry( ContactHeaderForeColor, headerColor );
config.writeEntry( ContactHeaderBGColor, backColor );
}
if ( mPageAppearance->cbStandardFonts->isChecked() ) {
QFont standard = KGlobalSettings::generalFont();
header = standard;
headlines = standard;
body = standard;
fixed = KGlobalSettings::fixedFont();
comment = standard;
} else {
header.setFamily( mPageAppearance->kfcHeaderFont->currentText() );
header.setPointSize( mPageAppearance->kisbHeaderFontSize->value() );
config.writeEntry( HeaderFont, header );
// headlines:
headlines.setFamily( mPageAppearance->kfcHeadlineFont->currentText() );
headlines.setPointSize( mPageAppearance->kisbHeadlineFontSize->value() );
config.writeEntry( HeadlinesFont, headlines );
// body:
body.setFamily( mPageAppearance->kfcBodyFont->currentText() );
body.setPointSize( mPageAppearance->kisbBodyFontSize->value() );
config.writeEntry( BodyFont, body );
// details:
comment.setFamily( mPageAppearance->kfcDetailsFont->currentText() );
comment.setPointSize( mPageAppearance->kisbDetailsFontSize->value() );
config.writeEntry( DetailsFont, comment );
// fixed:
fixed.setFamily( mPageAppearance->kfcFixedFont->currentText() );
fixed.setPointSize( mPageAppearance->kisbFixedFontSize->value() );
config.writeEntry( FixedFont, fixed );
}
mPainter = new KABEntryPainter;
mPainter->setForegroundColor( foreColor );
mPainter->setHeaderColor( headerColor );
mPainter->setBackgroundColor( backColor );
mPainter->setUseHeaderColor( useHeaderColor );
mPainter->setHeaderFont( header );
mPainter->setHeadLineFont( headlines );
mPainter->setBodyFont( body );
mPainter->setFixedFont( fixed );
mPainter->setCommentFont( comment );
// Printing "Work Address:" / "Telephones:" headlines adds
// no interesting information and just take space.
// So I added this setter, but I leave it true by default because
// otherwise the indenting looks a bit weird -- ## TODO.
mPainter->setPrintHeadLines( true ); // TODO a checkbox for it
QPrinter *printer = wizard()->printer();
progress->addMessage( i18n( "Setting up margins and spacing" ) );
int marginTop = 0,
marginLeft = 64, // to allow stapling, need refinement with two-side prints
marginRight = 0,
marginBottom = 0;
register int left, top, width, height;
QPainter painter( printer );
left = qMax( printer->pageRect().left() - printer->paperRect().left(), marginLeft );
top = qMax( printer->pageRect().top() - printer->paperRect().top(), marginTop );
width = printer->width() - left - qMax( printer->paperRect().right() - printer->pageRect().right(), marginRight );
height = printer->height() - top - qMax( printer->paperRect().bottom() - printer->pageRect().bottom(), marginBottom );
printer->setFullPage( true ); // use whole page
painter.setViewport( left, top, width, height );
progress->addMessage( i18n( "Printing" ) );
printEntries( contacts, printer, &painter,
QRect( 0, 0, printer->width(), printer->height() ) );
progress->addMessage( i18n( "Done" ) );
config.sync();
}
示例5: print
bool ChequePrinter::print()
{
// 0. Amount to readable string
QString amount;
QStringList vals = Utils::doubleToHumanReadableString(d->_amount);
if (vals.count() == 0) {
LOG_ERROR_FOR("ChecquePrinter", "Wrong amount to string values");
} else {
amount = vals.at(0) + " " + QLocale().currencySymbol(QLocale::CurrencyDisplayName) + "s";
if (vals.count() == 2)
amount += QString(" %1 %2").arg(tkTr(Trans::Constants::AND)).arg(vals.at(1));
}
// Method 1. use pdkcompleter
// Internal::PdfTkWrapper *pdftk = Internal::PdfTkWrapper::instance();
// if (!pdftk->initialize())
// return false;
// pdftk->beginFdfEncoding();
// pdftk->addFdfValue("date", QLocale().toString(d->_date, QLocale::ShortFormat));
// pdftk->addFdfValue("lieu", d->_place);
// pdftk->addFdfValue("ordre", d->_order);
// pdftk->addFdfValue("montant1", lines.at(0));
// if (lines.count() >= 2)
// pdftk->addFdfValue("montant2", lines.at(1));
// // Amount to translated number
// QSystemLocale::CurrencyToStringArgument arg;
// arg.value = d->_amount;
// QVariant var;
// var.setValue<QSystemLocale::CurrencyToStringArgument>(arg);
// pdftk->addFdfValue("num", QString::number(d->_amount, 'f', 2)); //QSystemLocale().query(QSystemLocale::CurrencyToString, var).toString());
// QString filename = "/Users/eric/Desktop/cheque.pdf";
// pdftk->endFdfEncoding(filename);
// pdftk->fillPdfWithFdf(filename, pdftk->getFdfContent(), "/Users/eric/Desktop/test_cheque.pdf", "ISO-8859-1");
// return true;
// Method 2. use QPainter/QPrinter
// try to use the default printer
QPrintDialog dlg;
if (dlg.exec()==QDialog::Rejected)
return false;
QPrinter *printer = dlg.printer();
// printer->setPaperSource(QPrinter::PaperSource);
printer->setFullPage(true);
printer->setPaperSize(QPrinter::A4);
printer->setResolution(150);
printer->setOrientation(QPrinter::Landscape);
d->_axisHelper.setPageSize(printer->paperRect(), printer->paperSize(QPrinter::Millimeter));
QPainter painter;
if (!painter.begin(printer)) { // failed to open file
qWarning("failed to open file, is it writable?");
return false;
}
painter.save();
QFont font;
font.setPointSize(10);
painter.setFont(font);
painter.translate(d->_axisHelper.pointToPixels(120, 61));
// 25,17 pour certains
// 45,13 pour d'autres
QRectF amountLines(d->_axisHelper.pointToPixels(45,13), d->_axisHelper.sizeToPixels(90, 10));
// QRect amountLine2(d->_axisHelper.pointToPixels(10,23), d->size(110, 5));
QRectF orderLine(d->_axisHelper.pointToPixels(10,28), d->_axisHelper.sizeToPixels(110, 5));
QRectF numberLine(d->_axisHelper.pointToPixels(133,28), d->_axisHelper.sizeToPixels(41, 10));
QRectF placeLine(d->_axisHelper.pointToPixels(133,38), d->_axisHelper.sizeToPixels(40, 4));
QRectF dateLine(d->_axisHelper.pointToPixels(133,42), d->_axisHelper.sizeToPixels(40, 4));
if (DrawChequeRects) {
painter.drawRect(amountLines);
painter.drawRect(orderLine);
painter.drawRect(numberLine);
painter.drawRect(placeLine);
painter.drawRect(dateLine);
}
if (amount.count() > 50)
amount = Utils::lineWrapString(amount, 50);
amount = QString("****%1****").arg(amount.toUpper());
QFontMetrics metrics(font);
while (metrics.width(amount) > amountLines.width() || font.pointSize() == 6) {
font.setPointSizeF(font.pointSizeF() - .1);
metrics = QFontMetrics(font);
}
painter.setFont(font);
painter.drawText(amountLines, Qt::AlignLeft, amount);
font.setPointSize(10);
painter.setFont(font);
// QStringList lines = amount.split("\n", QString::SkipEmptyParts);
// painter.drawText(amountLine1, Qt::AlignLeft | Qt::AlignVCenter, lines.at(0));
// if (lines.count() >= 2)
// painter.drawText(amountLine2, Qt::AlignLeft | Qt::AlignVCenter, lines.at(1));
//.........这里部分代码省略.........
示例6: GraphicsSceneToPrinter
void SceneImageExporter::GraphicsSceneToPrinter(
QGraphicsScene *scene, QPrinter& printer,
QString fileName, QString documentName __attribute__((unused)),
bool bSizeToOneSheet)
{
if (!fileName.isEmpty() && fileName != "" && fileName.endsWith(".pdf",Qt::CaseInsensitive))
{
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
}
// When printing, use full page mode, IE ignore hardware margins. It's up
// to users to set them as they desire.
printer.setFullPage(true);
printer.setPaperSize(QSizeF(PrintingPreferences::prefs().selectedMeasure().width(),
PrintingPreferences::prefs().selectedMeasure().height()),
QPrinter::Millimeter);
printer.setPageMargins(PrintingPreferences::prefs().leftMargin(),
PrintingPreferences::prefs().topMargin(),
PrintingPreferences::prefs().rightMargin(),
PrintingPreferences::prefs().bottomMargin(),
QPrinter::Millimeter);
if (!bSizeToOneSheet) {
//here, I print using selected sheets and divisions.
QPainter painter(&printer);
qreal left,top,right,bottom;
printer.getPageMargins(&left,&top,&right,&bottom,QPrinter::DevicePixel);
// get the FULL PAGE RECTANGLE and adjust margins.
QRectF pageRect = printer.paperRect();
pageRect.adjust(left,top,-right, -bottom);
//get height/width page rect ratio
double pageRatio = pageRect.width()/pageRect.height();
//get scene rectangle and calculating pages.
int stepY = PrintingPreferences::prefs().yDivisions();
QRectF sceneRect = scene->sceneRect();
double scene_dy = sceneRect.height()/( (double)stepY);
double scene_dx = scene_dy * pageRatio;
double o_scene_dx = scene_dx * 1.1;
double o_scene_dy = scene_dy * 1.1;
double o_rect_dx = pageRect.width() / 1.1;
double o_rect_dy = pageRect.height() / 1.1;
double odx = ( pageRect.width() -o_rect_dx)/2.0;
double ody = (pageRect.height() - o_rect_dy)/ 2.0;
QRectF pageRectInner = QRectF (pageRect.left() + odx,
pageRect.top() + ody,
o_rect_dx, o_rect_dy);
int stepX = 1+ (int)(sceneRect.width() / scene_dx);
//ok, calculated my boxes. NOW, let's print everything out.
QColor transparent(0,0,0,0);
QColor transBorder (0,0,0,128);
QPen pen (transBorder);
pen.setStyle(Qt::DotLine);
QBrush brush(transparent);
bool bNewPage = false;
for (int y = 0; y < stepY; y++) {
for (int x = 0; x < stepX; x++) {
if (bNewPage)
printer.newPage();
else
bNewPage = true;
//I've already got my target rectangle
QRectF sourceRect = QRectF (
sceneRect.left()+((double)x * scene_dx + (o_scene_dx - scene_dx)/2.0 ),
sceneRect.top()+((double)y * scene_dy + (o_scene_dy - scene_dy)/2.0),
o_scene_dx,o_scene_dy);
scene->render(&painter,pageRect, sourceRect);
QBrush oldBrush = painter.brush();
QPen oldPen = painter.pen();
//qDebug() << "pageRect " << pageRect;
//qDebug() << "pageRectInner " << pageRectInner;
painter.setPen(pen);
painter.setBrush(brush);
painter.drawRect(pageRect);
painter.drawRect(pageRectInner);
painter.setPen(oldPen);
painter.setBrush(oldBrush);
//.........这里部分代码省略.........
示例7: PageGraphicsSceneToPrinter
void SceneImageExporter::PageGraphicsSceneToPrinter(QGraphicsScene *scene, QPrinter &printer,
QList<SectorRectHolder>& pageRegions, QString fileName,
QString documentName __attribute__((unused)))
{
PrintingPreferences &pref __attribute__ ((unused)) = PrintingPreferences::prefs();
//qDebug() << pref.yDivisions();
//qDebug() << pref.selectedMeasure();
//qDebug() << pref.measures();
if (!fileName.isEmpty() && fileName != "" && fileName.endsWith(".pdf",Qt::CaseInsensitive))
{
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
}
// When printing, use full page mode, IE ignore hardware margins. It's up
// to users to set them as they desire.
printer.setFullPage(true);
printer.setPaperSize(QSizeF(PrintingPreferences::prefs().selectedMeasure().width(),
PrintingPreferences::prefs().selectedMeasure().height()),
QPrinter::Millimeter);
printer.setPageMargins(PrintingPreferences::prefs().leftMargin(),
PrintingPreferences::prefs().topMargin(),
PrintingPreferences::prefs().rightMargin(),
PrintingPreferences::prefs().bottomMargin(),
QPrinter::Millimeter);
//here, I print using selected sheets and divisions.
QPainter painter(&printer);
qreal left,top,right,bottom;
printer.getPageMargins(&left,&top,&right,&bottom,QPrinter::DevicePixel);
// get the FULL PAGE RECTANGLE and adjust margins.
QRectF pageRect = printer.paperRect();
pageRect.adjust(left,top,-right, -bottom);
QColor transparent(0,0,0,0);
QColor transBorder (0,0,0,128);
QPen pen (transBorder);
pen.setStyle(Qt::DotLine);
QBrush brush;
QGraphicsScene sceneFirst;
QPen pen2 (QColor(0,0,0));
pen2.setStyle(Qt::DotLine);
pen2.setWidthF(2.0);
QBrush brush2;
for (int h = 0; h < pageRegions.count(); h++)
{
QRectF rect = pageRegions[h].rectInner();
sceneFirst.addRect (rect.left(), rect.top(), rect.width(),rect.height(),pen2, brush2);
rect = pageRegions[h].rectOuter();
sceneFirst.addRect (rect.left(), rect.top(), rect.width(),rect.height(),pen2, brush2);
}
scene->render(&painter, pageRect, scene->itemsBoundingRect(),Qt::KeepAspectRatio);
sceneFirst.render(&painter,pageRect, sceneFirst.sceneRect(),Qt::KeepAspectRatio);
for (int h = 0; h < pageRegions.count(); h++)
{
QRectF rect = pageRegions[h].rectOuter();
double ratio = rect.width()/rect.height();
QRectF rectTarget = QRectF(pageRect.left(), pageRect.top(), pageRect.width(), pageRect.width()/ratio);
printer.newPage();
scene->render(&painter,rectTarget, rect);
painter.setPen(pen2);
painter.setBrush(brush);
painter.drawRect(rectTarget);
QRectF rect2 = pageRegions[h].rectInner();
double ratioX = rectTarget.width()/rect.width();
double ratioY = rectTarget.height()/rect.height();
double dy = rect2.top()-rect.top();
double dx = rect2.left() - rect.left();
//qDebug() << "rect outer: " << rect
// << "\nrect inner: " << rect2
// << "\nrect target: " << rectTarget
// << "\nx: " << dx << ",y:" << dy;
QRectF rectTarget2 (rectTarget.top()+ dx*ratioX,
rectTarget.left()+dy*ratioY,
rect2.width()*ratioX,
rect2.height()*ratioY);
painter.drawRect(rectTarget2);
}
painter.end();
}
示例8: actionsCommonSlot
//---------------------------------------------------------------
void SkewTWindow::actionsCommonSlot ()
{
setCursor (Qt::WaitCursor);
QObject *send = sender ();
if (send == acExit) {
this->hide ();
this->destroy ();
if (skewt) {
delete skewt;
skewt = nullptr;
}
}
else if (send == cbTempMax) {
int v = cbTempMax->itemData (cbTempMax->currentIndex()).toInt();
Util::setSetting ("skewt_tempCMax", v);
skewt->setTempPressLimits (v, skewt->getHpaMin());
}
else if (send == cbHpaMin) {
int v = cbHpaMin->itemData (cbHpaMin->currentIndex()).toInt();
Util::setSetting ("skewt_hpaMin", v);
skewt->setTempPressLimits (skewt->getTempCMax(), v-10);
}
else if (send == cbSizeW) {
double sz = cbSizeW->itemData (cbSizeW->currentIndex()).toDouble();
Util::setSetting ("skewt_sizeW", sz);
skewt->setSkewTSize (sz, skewt->height());
}
else if (send == cbSizeH) {
double sz = cbSizeH->itemData (cbSizeH->currentIndex()).toDouble();
Util::setSetting ("skewt_sizeH", sz);
skewt->setSkewTSize (skewt->width(), sz);
}
else if (send == cbConvBase) {
QString cbase = cbConvBase->itemData (cbConvBase->currentIndex()).toString();
Util::setSetting ("skewt_convectiveBase", cbase);
skewt->setConvectiveBase (cbase);
}
else if (send == chkShowConv) {
Util::setSetting ("skewt_showConvectiveCurves", chkShowConv->isChecked());
skewt->resetGraphic ();
cbConvBase->setEnabled (chkShowConv->isChecked());
}
else if (send == acPrint) {
QPrinter printer;
printer.setOutputFormat (QPrinter::PdfFormat);
printer.setResolution (150);
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle (tr("Print Document"));
if (dialog->exec() == QDialog::Accepted)
{
QPainter painter;
painter.begin(&printer);
double xscale = printer.pageRect().width()/double(skewt->width());
double yscale = printer.pageRect().height()/double(skewt->height());
double scale = qMin(xscale, yscale);
painter.translate(printer.paperRect().x() + printer.pageRect().width()/2,
printer.paperRect().y() + printer.pageRect().height()/2);
painter.scale(scale, scale);
painter.translate(-skewt->width()/2, -skewt->height()/2);
skewt->setPrinterRendering (true);
skewt->render (&painter);
skewt->setPrinterRendering (false);
}
}
else if (send == acSaveImage) {
QString filename = Util::getSetting("skewt_imageSaveFilename", "").toString();
filename = Util::getSaveFileName (this,
tr("Save JPEG image"),
filename,
tr("Images (*.jpg *.jpeg)") );
if (filename != "") {
if ( ! filename.endsWith(".jpg", Qt::CaseInsensitive)
&& ! filename.endsWith(".jpeg", Qt::CaseInsensitive) )
filename += ".jpg";
Util::setSetting("skewt_imageSaveFilename", filename);
QImage image (skewt->size(), QImage::Format_RGB32);
skewt->setPrinterRendering (true);
skewt->render (&image);
skewt->setPrinterRendering (false);
image.save (filename, "JPEG", 96);
}
}
else if (send == acExportData) {
QString path = Util::getSetting("slkFilePath", "").toString();
if (path == "")
path = "./";
else
path += "/";
QString fileName;
fileName = Util::getSaveFileName (this,
tr("Save SYLK file"), path, "*.slk");
if (fileName != "")
{
if (! fileName.endsWith(".slk", Qt::CaseInsensitive))
fileName += ".slk";
SylkFile slk (fileName, "XyGrib");
//.........这里部分代码省略.........
示例9: paperRect
int Printer::paperRect(lua_State * L) // const : QRect
{
QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
*ValueBinding<QRectF>::create( L ) = lhs->paperRect();
return 1;
}
示例10: print
void PrintTool::print()
{
const QString processTitle = i18nc( "@title:window", "Print Byte Array %1", mDocument->title() );
QPrinter printer;
// LayoutDialogPage* layoutPage = new LayoutDialogPage();
QList<QWidget*> customDialogPages;
// customDialogPages << layoutPage;
QPrintDialog *printDialog = new QPrintDialog( &printer, 0 );
// Disable PrintPageRange, this tells Qt we can't do client-side page selection,
// so it will try do server-side page selection if supported
printDialog->setOption(QPrintDialog::PrintPageRange, false);
// printDialog->setOptionTabs(customDialogPages);
printDialog->setWindowTitle( processTitle );
if( printDialog->exec() )
{
QString creator = QString::fromLatin1( "Print Plugin for Okteta " ); // no i18n(), keep space at end as separator
// creator += KDEUTILS_VERSION_STRING; // TODO: change to OKTETA_VERSION_STRING
printer.setCreator( creator );
FramesToPaperPrinter framesPrinter;
framesPrinter.setPaperRect( printer.paperRect() );
framesPrinter.setPageRect( printer.pageRect() );
printer.setFullPage( true );
PrintInfo info;
const QRect pageRect = framesPrinter.pageRect();
const int left = pageRect.left();
const int width = pageRect.width();
HeaderFooterFrameRenderer *headerFrameRenderer = new HeaderFooterFrameRenderer( &info );
headerFrameRenderer->setTexts( QStringLiteral("%d"),
QStringLiteral("%f"),
i18nc("in the header of the printed page, e.g. Page 2 of 20","Page %p of %P") );
headerFrameRenderer->setWidth( width );
headerFrameRenderer->setPos( pageRect.topLeft() );
HeaderFooterFrameRenderer *footerFrameRenderer = new HeaderFooterFrameRenderer( &info );
footerFrameRenderer->setTexts( i18nc("in the footer of the printed page, e.g. Printed by: Joe User",
"Printed by: %U"),
QString(),
QStringLiteral("%F") );
footerFrameRenderer->setWidth( width );
const int footerTop = pageRect.bottom() - footerFrameRenderer->height();
footerFrameRenderer->setPos( left, footerTop );
const int contentHeight = pageRect.height() - footerFrameRenderer->height() - headerFrameRenderer->height();
const int contentTop = pageRect.top() + headerFrameRenderer->height();
ByteArrayFrameRenderer *byteArrayFrameRenderer = new ByteArrayFrameRenderer;
byteArrayFrameRenderer->setPos( left, contentTop );
byteArrayFrameRenderer->setWidth( width );
byteArrayFrameRenderer->setHeight( contentHeight );
Okteta::AddressRange range = mByteArrayView->selection();
if( ! range.isValid() )
range.setByWidth( 0, mByteArrayModel->size() );
byteArrayFrameRenderer->setByteArrayModel( mByteArrayModel, range.start(), range.width() );
// TODO: use noOfBytesPerLine of view, scale resolution down if it does not fit the page
const int noOfBytesPerLine = mByteArrayView->noOfBytesPerLine();
// byteArrayFrameRenderer->setNoOfBytesPerLine( mByteArrayView->noOfBytesPerLine() );
const Okteta::Address startOffset = mByteArrayView->startOffset() + range.start();
const int line = startOffset / noOfBytesPerLine;
const Okteta::Address firstLineOffset = mByteArrayView->firstLineOffset() + line*noOfBytesPerLine;
byteArrayFrameRenderer->setFirstLineOffset( firstLineOffset );
byteArrayFrameRenderer->setStartOffset( startOffset );
byteArrayFrameRenderer->setCharCoding( mByteArrayView->charCodingName() );
byteArrayFrameRenderer->setBufferSpacing( mByteArrayView->byteSpacingWidth(),
mByteArrayView->noOfGroupedBytes(),
mByteArrayView->groupSpacingWidth() );
byteArrayFrameRenderer->setBinaryGapWidth( mByteArrayView->binaryGapWidth() );
byteArrayFrameRenderer->setValueCoding( (Okteta::ValueCoding)mByteArrayView->valueCoding() );
byteArrayFrameRenderer->setShowsNonprinting( mByteArrayView->showsNonprinting() );
byteArrayFrameRenderer->setSubstituteChar( mByteArrayView->substituteChar() );
byteArrayFrameRenderer->setUndefinedChar( mByteArrayView->undefinedChar() );
byteArrayFrameRenderer->showByteArrayColumns( mByteArrayView->visibleByteArrayCodings() );
// if( !confirmPrintPageNumber( byteArrayFrameRenderer->framesCount()) )
// return;
framesPrinter.addFrameRenderer( headerFrameRenderer );
framesPrinter.addFrameRenderer( byteArrayFrameRenderer );
framesPrinter.addFrameRenderer( footerFrameRenderer );
info.setNoOfPages( byteArrayFrameRenderer->framesCount() );
AbstractModelSynchronizer* synchronizer = mDocument->synchronizer();
if (synchronizer) {
info.setUrl( synchronizer->url() );
}
QApplication::setOverrideCursor( Qt::WaitCursor );
PrintJob *printJob = new PrintJob( &framesPrinter, 0, byteArrayFrameRenderer->framesCount()-1, &printer );
const bool success = printJob->exec();
//.........这里部分代码省略.........