Make QPageRanges::detach public, add data stream operators
As per QUIP-19 discussion, value types should have streaming operators, and detach should be public. detach() is still documented as \internal, like other public detach methods in value types. Change-Id: I30451909ad5226088fb05206f83983dda5b0c6b5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>bb10
parent
f5010c49a3
commit
63f03f5e2d
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include <QtCore/qstack.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qdatastream.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -325,6 +326,40 @@ void QPageRanges::detach()
|
|||
d.reset(new QPageRangesPrivate);
|
||||
}
|
||||
|
||||
#if !defined(QT_NO_DATASTREAM)
|
||||
/*!
|
||||
\fn QDataStream &operator<<(QDataStream &stream, const QPageRanges &pageRanges)
|
||||
\relates QPageRanges
|
||||
|
||||
Writes \a pageRanges to \a stream as a range string.
|
||||
|
||||
\sa QPageRanges::toString
|
||||
*/
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const QPageRanges &pageRanges)
|
||||
{
|
||||
s << pageRanges.toString();
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QDataStream &operator>>(QDataStream &stream, QPageRanges &pageRanges)
|
||||
\relates QPageRanges
|
||||
|
||||
Reads a page ranges string from \a stream and stores it in \a pageRanges.
|
||||
|
||||
\sa QPageRanges::fromString
|
||||
*/
|
||||
|
||||
QDataStream &operator>>(QDataStream &s, QPageRanges &pageRanges)
|
||||
{
|
||||
QString rangesString;
|
||||
s >> rangesString;
|
||||
pageRanges = QPageRanges::fromString(rangesString);
|
||||
return s;
|
||||
}
|
||||
#endif // QT_NO_DATASTREAM
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QPageRanges &pageRanges)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDebug;
|
||||
class QDataStream;
|
||||
class QPageRangesPrivate;
|
||||
QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPageRangesPrivate, Q_GUI_EXPORT)
|
||||
|
||||
|
|
@ -97,13 +98,19 @@ public:
|
|||
int firstPage() const;
|
||||
int lastPage() const;
|
||||
|
||||
void detach();
|
||||
|
||||
private:
|
||||
bool isEqual(const QPageRanges &other) const noexcept;
|
||||
void detach();
|
||||
|
||||
QExplicitlySharedDataPointer<QPageRangesPrivate> d;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPageRanges &);
|
||||
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPageRanges &);
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageRanges &pageRanges);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue