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.

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>
(cherry picked from commit 5d2f40a14bb584550305b96cfcdbeae3ca66de56)
bb10
Kai Köhne 2024-12-05 15:46:10 +01:00 committed by Qt Cherry-pick Bot
parent af6b7113f7
commit 98ba334cdc
1 changed files with 15 additions and 10 deletions

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.
However, pos() is set to 0. Use QIODevice::Append or QIODevice::Truncate to
change either behavior.
The flags for \a mode must include \l QIODeviceBase::ReadOnly,
\l WriteOnly, or \l ReadWrite. If not, an error is printed and
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);
if ((flags & (Append | Truncate)) != 0)
flags |= WriteOnly;
if ((flags & (ReadOnly | WriteOnly)) == 0) {
if ((mode & (Append | Truncate)) != 0)
mode |= WriteOnly;
if ((mode & (ReadOnly | WriteOnly)) == 0) {
qWarning("QBuffer::open: Buffer access not specified");
return false;
}
if ((flags & Truncate) == Truncate)
if ((mode & Truncate) == Truncate)
d->buf->resize(0);
return QIODevice::open(flags | QIODevice::Unbuffered);
return QIODevice::open(mode | QIODevice::Unbuffered);
}
/*!