5#include "private/qwidget_p.h"
6#include <private/qprinter_p.h>
8#include <QtCore/qmath.h>
9#include <QtWidgets/qboxlayout.h>
10#include <QtWidgets/qgraphicsitem.h>
11#include <QtWidgets/qgraphicsview.h>
12#include <QtWidgets/qscrollbar.h>
13#include <QtWidgets/qstyleoption.h>
22 : pageNum(_pageNum), pagePicture(_pagePicture),
23 paperSize(_paperSize), pageRect(_pageRect)
92 path.addRect(paperRect);
93 path.addRect(pageRect);
156 void _q_fit(
bool doFitting =
false);
188 if (curPage < 1 || curPage >
pages.
size())
241 emit q->previewChanged();
254 emit q->previewChanged();
268 if (
area > maxArea) {
324 int numPagePlaces = numPages;
337 int rows =
qCeil(
qreal(numPagePlaces) / cols);
342 for (
int i = 0;
i < rows && pageNum <= numPages;
i++) {
343 for (
int j = 0;
j < cols && pageNum <= numPages;
j++) {
365 printer->d_func()->setPreviewMode(
true);
367 printer->d_func()->setPreviewMode(
false);
374 emit q->previewChanged();
379 if (pageNumber < 1 || pageNumber >
pages.
size())
409 int dpi_y =
q->logicalDpiY();
494 d->printer = printer;
495 d->ownPrinter =
false;
511 d->ownPrinter =
true;
548 d->zoomFactor =
d->graphicsView->transform().m11() * (float(
d->printer->logicalDpiY()) /
logicalDpiY());
563 return d->printer->pageLayout().orientation();
574 d->generatePreview();
617 return d->zoomFactor;
632 d->setZoomFactor(factor);
642 return d->pages.size();
661 d->setCurrentPage(
page);
763 d->initialized =
true;
764 d->generatePreview();
765 d->graphicsView->updateGeometry();
796#include "moc_qprintpreviewwidget.cpp"
797#include "qprintpreviewwidget.moc"
The QColor class provides colors based on RGB, HSV or CMYK values.
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
QPointF pos() const
Returns the position of the item in parent coordinates.
QRectF sceneBoundingRect() const
Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with bound...
virtual QRectF boundingRect() const =0
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
void setPos(const QPointF &pos)
Sets the position of the item to pos, which is in parent coordinates.
void setCacheMode(CacheMode mode, const QSize &cacheSize=QSize())
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
void removeItem(QGraphicsItem *item)
Removes the item item and all its children from the scene.
void addItem(QGraphicsItem *item)
Adds or moves the item and all its children to this scene.
QRectF itemsBoundingRect() const
Calculates and returns the bounding rect of all items on the scene.
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
Returns a list of all the items in the associated scene, in descending stacking order (i....
void centerOn(const QPointF &pos)
Scrolls the contents of the viewport to ensure that the scene coordinate pos, is centered in the view...
void setTransform(const QTransform &matrix, bool combine=false)
Sets the view's current transformation matrix to matrix.
void setDragMode(DragMode mode)
QTransform transform() const
Returns the current transformation matrix for the view.
void resetTransform()
Resets the view transformation to the identity matrix.
void ensureVisible(const QRectF &rect, int xmargin=50, int ymargin=50)
Scrolls the contents of the viewport so that the scene rectangle rect is visible, with margins specif...
void scale(qreal sx, qreal sy)
Scales the current view transformation by (sx, sy).
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode=Qt::IgnoreAspectRatio)
Scales the view matrix and scrolls the scroll bars to ensure that the scene rectangle rect fits insid...
QTransform viewportTransform() const
Returns a matrix that maps scene coordinates to viewport coordinates.
void resizeEvent(QResizeEvent *event) override
\reimp
void setScene(QGraphicsScene *scene)
Sets the current scene to scene.
void showEvent(QShowEvent *event) override
\reimp
QPoint mapFromScene(const QPointF &point) const
Returns the scene coordinate point to viewport coordinates.
void setViewportUpdateMode(ViewportUpdateMode mode)
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
void setContentsMargins(int left, int top, int right, int bottom)
qsizetype size() const noexcept
const_reference at(qsizetype i) 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)
\threadsafe
Orientation orientation() const
Returns the page orientation of the page layout.
QRect paintRectPixels(int resolution) const
Returns the paintable rectangle in rounded device pixels for the given resolution.
Orientation
This enum type defines the page orientation.
QRect fullRectPixels(int resolution) const
Returns the full page rectangle in device pixels for the given resolution.
QPageLayout pageLayout() const
The QPainter class performs low-level painting on widgets and other paint devices.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void restore()
Restores the current painter state (pops a saved state off the stack).
void save()
Saves the current painter state (pushes the state onto a stack).
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void drawPicture(const QPointF &p, const QPicture &picture)
Replays the given picture at the given point.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
The QPicture class is a paint device that records and replays QPainter commands.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
int resolution() const
Returns the current assumed resolution of the printer, as set by setResolution() or by the printer dr...
\inmodule QtCore\reentrant
constexpr void setLeft(qreal pos) noexcept
Sets the left edge of the rectangle to the given finite x coordinate.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr QPointF bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
constexpr void moveTop(qreal pos) noexcept
Moves the rectangle vertically, leaving the rectangle's top line at the given finite y coordinate.
constexpr QPointF topRight() const noexcept
Returns the position of the rectangle's top-right corner.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
The QResizeEvent class contains event parameters for resize events.
The QShowEvent class provides an event that is sent when a widget is shown.
Exception-safe wrapper around QObject::blockSignals().
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
The QVBoxLayout class lines up widgets vertically.
GraphicsView(QWidget *parent=nullptr)
void resizeEvent(QResizeEvent *e) override
void showEvent(QShowEvent *e) override
QRectF boundingRect() const override
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override
This function, which is usually called by QGraphicsView, paints the contents of an item in local coor...
PageItem(int _pageNum, const QPicture *_pagePicture, QSize _paperSize, QRect _pageRect)
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
@ ContainsItemBoundingRect
qfloat16 qSqrt(qfloat16 f)
int qRound(qfloat16 d) noexcept
static int area(const QSize &s)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
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
static const QRectF boundingRect(const QPointF *points, int pointCount)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent