/src/qtbase/src/gui/painting/qpageranges.h
Line | Count | Source |
1 | | // Copyright (C) 2020 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #ifndef QPAGERANGES_H |
6 | | #define QPAGERANGES_H |
7 | | |
8 | | #include <QtGui/qtguiglobal.h> |
9 | | #include <QtCore/qstring.h> |
10 | | #include <QtCore/qlist.h> |
11 | | #include <QtCore/qshareddata.h> |
12 | | #include <QtCore/qmetatype.h> |
13 | | |
14 | | QT_BEGIN_NAMESPACE |
15 | | |
16 | | class QDebug; |
17 | | class QDataStream; |
18 | | class QPageRangesPrivate; |
19 | | QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPageRangesPrivate, Q_GUI_EXPORT) |
20 | | |
21 | | class Q_GUI_EXPORT QPageRanges |
22 | | { |
23 | | public: |
24 | | QPageRanges(); |
25 | | ~QPageRanges(); |
26 | | |
27 | | QPageRanges(const QPageRanges &other) noexcept; |
28 | | QPageRanges &operator=(const QPageRanges &other) noexcept; |
29 | | |
30 | 0 | QPageRanges(QPageRanges &&other) noexcept = default; |
31 | 0 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageRanges) |
32 | 0 | void swap(QPageRanges &other) noexcept |
33 | 0 | { d.swap(other.d); } |
34 | | |
35 | | friend bool operator==(const QPageRanges &lhs, const QPageRanges &rhs) noexcept |
36 | 0 | { return lhs.isEqual(rhs); } |
37 | | friend bool operator!=(const QPageRanges &lhs, const QPageRanges &rhs) noexcept |
38 | 0 | { return !lhs.isEqual(rhs); } |
39 | | |
40 | | struct Range { |
41 | | int from = -1; |
42 | | int to = -1; |
43 | | bool contains(int pageNumber) const noexcept |
44 | 0 | { return from <= pageNumber && to >= pageNumber; } |
45 | | friend bool operator==(Range lhs, Range rhs) noexcept |
46 | 0 | { return lhs.from == rhs.from && lhs.to == rhs.to; } |
47 | | friend bool operator!=(Range lhs, Range rhs) noexcept |
48 | 0 | { return !(lhs == rhs); } |
49 | | friend bool operator<(Range lhs, Range rhs) noexcept |
50 | 0 | { return lhs.from < rhs.from || (!(rhs.from < lhs.from) && lhs.to < rhs.to); } |
51 | | }; |
52 | | |
53 | | void addPage(int pageNumber); |
54 | | void addRange(int from, int to); |
55 | | QList<Range> toRangeList() const; |
56 | | void clear(); |
57 | | |
58 | | QString toString() const; |
59 | | static QPageRanges fromString(const QString &ranges); |
60 | | |
61 | | bool contains(int pageNumber) const; |
62 | | bool isEmpty() const; |
63 | | int firstPage() const; |
64 | | int lastPage() const; |
65 | | |
66 | | void detach(); |
67 | | |
68 | | private: |
69 | | bool isEqual(const QPageRanges &other) const noexcept; |
70 | | |
71 | | QExplicitlySharedDataPointer<QPageRangesPrivate> d; |
72 | | }; |
73 | | |
74 | | #ifndef QT_NO_DATASTREAM |
75 | | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPageRanges &); |
76 | | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPageRanges &); |
77 | | #endif |
78 | | |
79 | | #ifndef QT_NO_DEBUG_STREAM |
80 | | Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageRanges &pageRanges); |
81 | | #endif |
82 | | |
83 | 0 | Q_DECLARE_SHARED(QPageRanges) |
84 | 0 | Q_DECLARE_TYPEINFO(QPageRanges::Range, Q_RELOCATABLE_TYPE); |
85 | 0 |
|
86 | 0 | QT_END_NAMESPACE |
87 | 0 |
|
88 | | QT_DECL_METATYPE_EXTERN(QPageRanges, Q_GUI_EXPORT) Unexecuted instantiation: int qRegisterNormalizedMetaType<QPageRanges>(QByteArray const&) Unexecuted instantiation: QMetaTypeId<QPageRanges>::qt_metatype_id() |
89 | | |
90 | | #endif // QPAGERANGES_H |