Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QPageRanges Class Reference

The QPageRanges class represents a collection of page ranges. More...

#include <qpageranges.h>

+ Collaboration diagram for QPageRanges:

Classes

struct  Range
 \inmodule QtGui More...
 

Public Member Functions

 QPageRanges ()
 Constructs an empty QPageRanges object.
 
 ~QPageRanges ()
 Destroys the page ranges.
 
 QPageRanges (const QPageRanges &other) noexcept
 Constructs a QPageRanges object by copying other.
 
QPageRangesoperator= (const QPageRanges &other) noexcept
 Assigns other to this QPageRanges object.
 
 QPageRanges (QPageRanges &&other) noexcept=default
 Constructs a QPageRanges object by moving from other.
 
void swap (QPageRanges &other) noexcept
 
void addPage (int pageNumber)
 Adds the single page pageNumber to the ranges.
 
void addRange (int from, int to)
 Adds the range specified with from and to to the ranges.
 
QList< RangetoRangeList () const
 Returns a list with the values of the ranges.
 
void clear ()
 Removes all page ranges.
 
QString toString () const
 Returns the string representation of the page ranges.
 
bool contains (int pageNumber) const
 Returns true if the ranges include the page pageNumber; otherwise returns false.
 
bool isEmpty () const
 Returns true if the ranges are empty; otherwise returns false.
 
int firstPage () const
 Returns the index of the first page covered by the page ranges, or 0 if the page ranges are empty.
 
int lastPage () const
 Returns the index of the last page covered by the page ranges, or 0 if the page ranges are empty.
 
void detach ()
 

Static Public Member Functions

static QPageRanges fromString (const QString &ranges)
 Constructs and returns a QPageRanges object populated with the ranges from the string representation.
 

Friends

bool operator== (const QPageRanges &lhs, const QPageRanges &rhs) noexcept
 
bool operator!= (const QPageRanges &lhs, const QPageRanges &rhs) noexcept
 

Related Symbols

(Note that these are not member symbols.)

QDataStreamoperator<< (QDataStream &stream, const QPageRanges &pageRanges)
 Writes pageRanges to stream as a range string.
 
QDataStreamoperator>> (QDataStream &stream, QPageRanges &pageRanges)
 Reads a page ranges string from stream and stores it in pageRanges.
 

Detailed Description

The QPageRanges class represents a collection of page ranges.

\inmodule QtGui

Since
6.0

Use QPagedPaintDevice::pageRanges() to access the collection of page ranges associated with a paged device.

Definition at line 20 of file qpageranges.h.

Constructor & Destructor Documentation

◆ QPageRanges() [1/3]

QPageRanges::QPageRanges ( )
default

Constructs an empty QPageRanges object.

Referenced by fromString().

+ Here is the caller graph for this function:

◆ ~QPageRanges()

QPageRanges::~QPageRanges ( )
default

Destroys the page ranges.

◆ QPageRanges() [2/3]

QPageRanges::QPageRanges ( const QPageRanges & other)
defaultnoexcept

Constructs a QPageRanges object by copying other.

◆ QPageRanges() [3/3]

QPageRanges::QPageRanges ( QPageRanges && other)
defaultnoexcept

Constructs a QPageRanges object by moving from other.

Member Function Documentation

◆ addPage()

void QPageRanges::addPage ( int pageNumber)

Adds the single page pageNumber to the ranges.

Note
Page numbers start with 1. Attempts to add page numbers smaller than 1 will be ignored with a warning.

Definition at line 91 of file qpageranges.cpp.

References QList< T >::append(), detach(), QPageRangesPrivate::intervals, QPageRangesPrivate::mergeIntervals(), and qWarning.

+ Here is the call graph for this function:

◆ addRange()

void QPageRanges::addRange ( int from,
int to )

Adds the range specified with from and to to the ranges.

Note
Page numbers start with 1. Attempts to add page numbers smaller than 1 will be ignored with a warning.

Definition at line 109 of file qpageranges.cpp.

References QList< T >::append(), detach(), QPageRangesPrivate::intervals, QPageRangesPrivate::mergeIntervals(), and qWarning.

Referenced by QPrinter::setFromTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void QPageRanges::clear ( )

Removes all page ranges.

Definition at line 136 of file qpageranges.cpp.

References QExplicitlySharedDataPointer< T >::reset().

Referenced by QPrinter::setFromTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ contains()

bool QPageRanges::contains ( int pageNumber) const

Returns true if the ranges include the page pageNumber; otherwise returns false.

Definition at line 230 of file qpageranges.cpp.

References QPageRangesPrivate::intervals.

Referenced by QTextDocument::print().

+ Here is the caller graph for this function:

◆ detach()

void QPageRanges::detach ( )

Definition at line 287 of file qpageranges.cpp.

References QExplicitlySharedDataPointer< T >::detach(), and QExplicitlySharedDataPointer< T >::reset().

Referenced by addPage(), and addRange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ firstPage()

int QPageRanges::firstPage ( ) const

Returns the index of the first page covered by the page ranges, or 0 if the page ranges are empty.

Definition at line 254 of file qpageranges.cpp.

References QList< T >::constFirst(), QPageRanges::Range::from, QPageRangesPrivate::intervals, and isEmpty().

Referenced by QPrinter::fromPage(), and QTextDocument::print().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromString()

QPageRanges QPageRanges::fromString ( const QString & ranges)
static

Constructs and returns a QPageRanges object populated with the ranges from the string representation.

QPrinter printer;
printer.setPageRanges(ranges);
The QPageRanges class represents a collection of page ranges.
Definition qpageranges.h:21
static QPageRanges fromString(const QString &ranges)
Constructs and returns a QPageRanges object populated with the ranges from the string representation.
virtual void setPageRanges(const QPageRanges &ranges)
\reentrant
Definition qprinter.h:28

In case of parsing error, returns an empty QPageRanges object.

See also
isEmpty()

Definition at line 155 of file qpageranges.cpp.

References QPageRanges(), QGraphicsItem::contains(), item, items, number, ok, QExplicitlySharedDataPointer< T >::reset(), and QString::split().

Referenced by operator>>(), and QPrintDialogPrivate::setupPrinter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEmpty()

bool QPageRanges::isEmpty ( ) const

Returns true if the ranges are empty; otherwise returns false.

Definition at line 245 of file qpageranges.cpp.

References QPageRangesPrivate::intervals, and QList< T >::isEmpty().

Referenced by firstPage(), lastPage(), QTextDocument::print(), and QPrintDialogPrivate::setupPrinter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lastPage()

int QPageRanges::lastPage ( ) const

Returns the index of the last page covered by the page ranges, or 0 if the page ranges are empty.

Definition at line 265 of file qpageranges.cpp.

References QList< T >::constLast(), QPageRangesPrivate::intervals, isEmpty(), and QPageRanges::Range::to.

Referenced by QTextDocument::print(), and QPrinter::toPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

QPageRanges & QPageRanges::operator= ( const QPageRanges & other)
defaultnoexcept

Assigns other to this QPageRanges object.

Moves other into this QPageRanges object.

◆ swap()

void QPageRanges::swap ( QPageRanges & other)
inlinenoexcept

Definition at line 31 of file qpageranges.h.

References d, and other().

+ Here is the call graph for this function:

◆ toRangeList()

QList< QPageRanges::Range > QPageRanges::toRangeList ( ) const

Returns a list with the values of the ranges.

Definition at line 126 of file qpageranges.cpp.

References QPageRangesPrivate::intervals.

◆ toString()

QString QPageRanges::toString ( ) const

Returns the string representation of the page ranges.

Definition at line 205 of file qpageranges.cpp.

References QPageRangesPrivate::intervals, QString::number(), and QStringLiteral.

Referenced by operator<<(), operator<<(), and QPrintDialogPrivate::setupPrinter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const QPageRanges & lhs,
const QPageRanges & rhs )
friend

Definition at line 36 of file qpageranges.h.

◆ operator<<()

QDataStream & operator<< ( QDataStream & stream,
const QPageRanges & pageRanges )
related

Writes pageRanges to stream as a range string.

See also
QPageRanges::toString

Definition at line 305 of file qpageranges.cpp.

References toString().

+ Here is the call graph for this function:

◆ operator==

bool operator== ( const QPageRanges & lhs,
const QPageRanges & rhs )
friend

Definition at line 34 of file qpageranges.h.

◆ operator>>()

QDataStream & operator>> ( QDataStream & stream,
QPageRanges & pageRanges )
related

Reads a page ranges string from stream and stores it in pageRanges.

See also
QPageRanges::fromString

Definition at line 320 of file qpageranges.cpp.

References fromString().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: