41 #include "private/qwidget_p.h"
42 #include <private/qprinter_p.h>
44 #include <QtCore/qmath.h>
45 #include <QtWidgets/qboxlayout.h>
46 #include <QtWidgets/qgraphicsitem.h>
47 #include <QtWidgets/qgraphicsview.h>
48 #include <QtWidgets/qscrollbar.h>
49 #include <QtWidgets/qstyleoption.h>
58 : pageNum(_pageNum), pagePicture(_pagePicture),
59 paperSize(_paperSize), pageRect(_pageRect)
61 qreal border = qMax(paperSize.height(), paperSize.width()) / 25;
96 QRectF paperRect(0,0, paperSize.width(), paperSize.height());
128 path.addRect(paperRect);
129 path.addRect(pageRect);
189 void _q_fit(
bool doFitting =
false);
232 PageItem* pg =
static_cast<PageItem*
>(
item);
233 if (pg->pageNumber() ==
curPage)
274 emit q->previewChanged();
287 emit q->previewChanged();
298 PageItem* pg =
static_cast<PageItem*
>(
item);
301 if (area > maxArea) {
303 newPage = pg->pageNumber();
304 }
else if (area == maxArea && pg->pageNumber() < newPage) {
305 newPage = pg->pageNumber();
357 int numPagePlaces = numPages;
370 int rows =
qCeil(
qreal(numPagePlaces) / cols);
375 for (
int i = 0;
i < rows && pageNum <= numPages;
i++) {
376 for (
int j = 0;
j < cols && pageNum <= numPages;
j++) {
398 printer->d_func()->setPreviewMode(
true);
400 printer->d_func()->setPreviewMode(
false);
407 emit q->previewChanged();
412 if (pageNumber < 1 || pageNumber >
pages.
count())
442 int dpi_y =
q->logicalDpiY();
527 d->printer = printer;
528 d->ownPrinter =
false;
544 d->ownPrinter =
true;
581 d->zoomFactor =
d->graphicsView->transform().m11() * (float(
d->printer->logicalDpiY()) /
logicalDpiY());
596 return d->printer->pageLayout().orientation();
607 d->generatePreview();
650 return d->zoomFactor;
675 return d->pages.size();
694 d->setCurrentPage(
page);
796 d->initialized =
true;
797 d->generatePreview();
798 d->graphicsView->updateGeometry();
829 #include "moc_qprintpreviewwidget.cpp"
830 #include "qprintpreviewwidget.moc"
small capitals from c petite p scientific i
[1]
The QBrush class defines the fill pattern of shapes drawn by QPainter.
The QColor class provides colors based on RGB, HSV or CMYK values.
void setColorAt(qreal pos, const QColor &color)
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
QRectF sceneBoundingRect() const
virtual QRectF boundingRect() const =0
void setPos(const QPointF &pos)
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
void removeItem(QGraphicsItem *item)
void addItem(QGraphicsItem *item)
QRectF itemsBoundingRect() const
void setSceneRect(const QRectF &rect)
void setBackgroundBrush(const QBrush &brush)
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
void setInteractive(bool allowed)
QList< QGraphicsItem * > items() const
void centerOn(const QPointF &pos)
void setTransform(const QTransform &matrix, bool combine=false)
void setDragMode(DragMode mode)
QTransform transform() const
void ensureVisible(const QRectF &rect, int xmargin=50, int ymargin=50)
void scale(qreal sx, qreal sy)
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode=Qt::IgnoreAspectRatio)
QTransform viewportTransform() const
void resizeEvent(QResizeEvent *event) override
void setScene(QGraphicsScene *scene)
void showEvent(QShowEvent *event) override
QPoint mapFromScene(const QPointF &point) const
void setViewportUpdateMode(ViewportUpdateMode mode)
void addWidget(QWidget *w)
void setContentsMargins(int left, int top, int right, int bottom)
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush.
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
void append(parameter_type t)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Orientation orientation() const
QRect paintRectPixels(int resolution) const
QRect fullRectPixels(int resolution) const
QPageLayout pageLayout() const
The QPainter class performs low-level painting on widgets and other paint devices.
void drawRect(const QRectF &rect)
void drawPath(const QPainterPath &path)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
void setPen(const QColor &color)
void setBrush(const QBrush &brush)
void drawPicture(const QPointF &p, const QPicture &picture)
void fillRect(const QRectF &, const QBrush &)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
The QPen class defines how a QPainter should draw lines and outlines of shapes.
The QPicture class is a paint device that records and replays QPainter commands.
The QPointF class defines a point in the plane using floating point precision.
constexpr qreal x() const noexcept
constexpr qreal y() const noexcept
The QPrinter class is a paint device that paints on a printer.
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush.
The QRectF class defines a finite rectangle in the plane using floating point precision.
constexpr void setLeft(qreal pos) noexcept
constexpr qreal height() const noexcept
constexpr qreal width() const noexcept
constexpr QPointF bottomLeft() const noexcept
constexpr QPointF topLeft() const noexcept
constexpr QPointF bottomRight() const noexcept
constexpr void moveTop(qreal pos) noexcept
constexpr QPointF topRight() const noexcept
The QRect class defines a rectangle in the plane using integer precision.
constexpr int height() const noexcept
constexpr QSize size() const noexcept
constexpr int width() const noexcept
The QResizeEvent class contains event parameters for resize events. \inmodule QtGui.
The QShowEvent class provides an event that is sent when a widget is shown.
Exception-safe wrapper around QObject::blockSignals().
The QSizeF class defines the size of a two-dimensional object using floating point precision.
The QSize class defines the size of a two-dimensional object using integer point precision.
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
void resizeEvent(QResizeEvent *e) override
void showEvent(QShowEvent *e) override
GraphicsView(QWidget *parent=nullptr)
QRectF boundingRect() const override
PageItem(int _pageNum, const QPicture *_pagePicture, QSize _paperSize, QRect _pageRect)
The QVBoxLayout class lines up widgets vertically.
qDeleteAll(list.begin(), list.end())
@ ContainsItemBoundingRect
int qRound(qfloat16 d) noexcept
QT_END_INCLUDE_NAMESPACE typedef double qreal
GLint GLsizei GLsizei height
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLenum GLenum GLenum GLenum GLenum scale
view setCacheMode(QGraphicsView::CacheBackground)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent