Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpageranges.h
Go to the documentation of this file.
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
14QT_BEGIN_NAMESPACE
15
16class QDebug;
17class QDataStream;
18class QPageRangesPrivate;
19QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPageRangesPrivate, Q_GUI_EXPORT)
20
21class Q_GUI_EXPORT QPageRanges
22{
23public:
24 QPageRanges();
25 ~QPageRanges();
26
27 QPageRanges(const QPageRanges &other) noexcept;
28 QPageRanges &operator=(const QPageRanges &other) noexcept;
29
30 QPageRanges(QPageRanges &&other) noexcept = default;
31 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageRanges)
32 void swap(QPageRanges &other) noexcept
33 { d.swap(other.d); }
34
35 friend bool operator==(const QPageRanges &lhs, const QPageRanges &rhs) noexcept
36 { return lhs.isEqual(rhs); }
37 friend bool operator!=(const QPageRanges &lhs, const QPageRanges &rhs) noexcept
38 { return !lhs.isEqual(rhs); }
39
40 struct Range {
41 int from = -1;
42 int to = -1;
43 bool contains(int pageNumber) const noexcept
44 { return from <= pageNumber && to >= pageNumber; }
45 friend bool operator==(Range lhs, Range rhs) noexcept
46 { return lhs.from == rhs.from && lhs.to == rhs.to; }
47 friend bool operator!=(Range lhs, Range rhs) noexcept
48 { return !(lhs == rhs); }
49 friend bool operator<(Range lhs, Range rhs) noexcept
50 { 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
68private:
69 bool isEqual(const QPageRanges &other) const noexcept;
70
71 QExplicitlySharedDataPointer<QPageRangesPrivate> d;
72};
73
74#ifndef QT_NO_DATASTREAM
75Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPageRanges &);
76Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPageRanges &);
77#endif
78
79#ifndef QT_NO_DEBUG_STREAM
80Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageRanges &pageRanges);
81#endif
82
84Q_DECLARE_TYPEINFO(QPageRanges::Range, Q_RELOCATABLE_TYPE);
85
86QT_END_NAMESPACE
87
88QT_DECL_METATYPE_EXTERN(QPageRanges, Q_GUI_EXPORT)
89
90#endif // QPAGERANGES_H
\inmodule QtCore\reentrant
Definition qdatastream.h:50
The QPageRanges class represents a collection of page ranges.
Definition qpageranges.h:22
Combined button and popup list for selecting options.
QDataStream & operator>>(QDataStream &s, QKeyCombination &combination)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582