Doc: Improve QBuffer::open description

Explain the method, instead of just linking to the base method.

Call the argument 'mode' instead of 'flags', like it is done in
the base class.

Force the mentioned QIODeviceBase flags to be links. Use fully
qualified name for the first flag mentioned, but use the short form
for the rest to improve readability.

Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: I8e9668ffc095ec261e2be54a2dcf16a32e4cb441
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 334460407b7cde1cdab5cfe5abe00175893749c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Kai Köhne 2024-12-05 15:46:10 +01:00 committed by Qt Cherry-pick Bot
parent eb44663eaa
commit 5d2f40a14b

View File

@ -286,27 +286,32 @@ void QBuffer::setData(const char *data, qsizetype size)
} }
/*! /*!
\reimp Opens the buffer using \a mode flags, returning \c true if successful;
otherwise returns \c false.
Unlike QFile, opening a QBuffer QIODevice::WriteOnly does not truncate it. The flags for \a mode must include \l QIODeviceBase::ReadOnly,
However, pos() is set to 0. Use QIODevice::Append or QIODevice::Truncate to \l WriteOnly, or \l ReadWrite. If not, an error is printed and
change either behavior. the method fails. In any other case, it succeeds.
Unlike \l QFile::open(), opening a QBuffer with \l WriteOnly
does not truncate it. However, \l pos() is set to \c{0}.
Use \l Append or \l Truncate to change either behavior.
*/ */
bool QBuffer::open(OpenMode flags) bool QBuffer::open(OpenMode mode)
{ {
Q_D(QBuffer); Q_D(QBuffer);
if ((flags & (Append | Truncate)) != 0) if ((mode & (Append | Truncate)) != 0)
flags |= WriteOnly; mode |= WriteOnly;
if ((flags & (ReadOnly | WriteOnly)) == 0) { if ((mode & (ReadOnly | WriteOnly)) == 0) {
qWarning("QBuffer::open: Buffer access not specified"); qWarning("QBuffer::open: Buffer access not specified");
return false; return false;
} }
if ((flags & Truncate) == Truncate) if ((mode & Truncate) == Truncate)
d->buf->resize(0); d->buf->resize(0);
return QIODevice::open(flags | QIODevice::Unbuffered); return QIODevice::open(mode | QIODevice::Unbuffered);
} }
/*! /*!