1 /*
2  * DQt - D bindings for the Qt Toolkit
3  *
4  * GNU Lesser General Public License Usage
5  * This file may be used under the terms of the GNU Lesser
6  * General Public License version 3 as published by the Free Software
7  * Foundation and appearing in the file LICENSE.LGPL3 included in the
8  * packaging of this file. Please review the following information to
9  * ensure the GNU Lesser General Public License version 3 requirements
10  * will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
11  */
12 module qt.gui.pageranges;
13 extern(C++):
14 
15 import qt.config;
16 import qt.core.list;
17 import qt.core.shareddata;
18 import qt.core.string;
19 import qt.core.typeinfo;
20 import qt.helpers;
21 
22 /+ class QDebug; +/
23 extern(C++, class) struct QPageRangesPrivate;
24 /+ QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPageRangesPrivate, Q_GUI_EXPORT) +/
25 /// Binding for C++ class [QPageRanges](https://doc.qt.io/qt-6/qpageranges.html).
26 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QPageRanges
27 {
28 public:
29     @disable this();
30     pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this))))
31     ref typeof(this) rawConstructor();
32     static typeof(this) create()
33     {
34         typeof(this) r = typeof(this).init;
35         r.rawConstructor();
36         return r;
37     }
38 
39     ~this();
40 
41     @disable this(this);
42     this(ref const(QPageRanges) other)/+ noexcept+/;
43     /+ref QPageRanges operator =(ref const(QPageRanges) other)/+ noexcept+/;+/
44 
45     /+ QPageRanges(QPageRanges &&other) noexcept = default; +/
46     /+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageRanges) +/
47     /+ void swap(QPageRanges &other) noexcept
48     { qSwap(d, other.d); } +/
49 
50     /+ friend bool operator==(const QPageRanges &lhs, const QPageRanges &rhs) noexcept
51     { return lhs.isEqual(rhs); } +/
52     /+ friend bool operator!=(const QPageRanges &lhs, const QPageRanges &rhs) noexcept
53     { return !lhs.isEqual(rhs); } +/
54 
55     struct Range {
56         int from = -1;
57         int to = -1;
58         bool contains(int pageNumber) const/+ noexcept+/
59         { return from <= pageNumber && to >= pageNumber; }
60         /+ friend bool operator==(Range lhs, Range rhs) noexcept
61         { return lhs.from == rhs.from && lhs.to == rhs.to; } +/
62         /+ friend bool operator!=(Range lhs, Range rhs) noexcept
63         { return !(lhs == rhs); } +/
64         /+ friend bool operator<(Range lhs, Range rhs) noexcept
65         { return lhs.from < rhs.from || (!(rhs.from < lhs.from) && lhs.to < rhs.to); } +/
66     }
67 
68     void addPage(int pageNumber);
69     void addRange(int from, int to);
70     //QList!(Range) toRangeList() const;
71     void clear();
72 
73     QString toString() const;
74     static QPageRanges fromString(ref const(QString) ranges);
75 
76     bool contains(int pageNumber) const;
77     bool isEmpty() const;
78     int firstPage() const;
79     int lastPage() const;
80 
81     void detach();
82 
83 private:
84     bool isEqual(ref const(QPageRanges) other) const/+ noexcept+/;
85 
86     QExplicitlySharedDataPointer!(QPageRangesPrivate) d;
87     mixin(CREATE_CONVENIENCE_WRAPPERS);
88 }
89 
90 /+ #ifndef QT_NO_DATASTREAM
91 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPageRanges &);
92 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPageRanges &);
93 #endif
94 
95 #ifndef QT_NO_DEBUG_STREAM
96 Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageRanges &pageRanges);
97 #endif
98 
99 Q_DECLARE_SHARED(QPageRanges)
100 Q_DECLARE_TYPEINFO(QPageRanges::Range, Q_RELOCATABLE_TYPE);
101 
102 
103 Q_DECLARE_METATYPE(QPageRanges) +/
104