diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-12-20 14:22:11 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-01-23 16:12:44 +0000 |
commit | a1ad9b590b8815feb35ecd860b659c188155df6d (patch) | |
tree | f5fc843fca117e4e75c093793d421571c1d96d8f | |
parent | 0d65c71a193c3c14860bf3f2aa80240032d77ab8 (diff) |
Add convenience enum for QDebug's verbosity levels
Change-Id: I9b7ad39c64d4b5787ce59db91b9ddadb82646e31
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/io/qdebug.cpp | 19 | ||||
-rw-r--r-- | src/corelib/io/qdebug.h | 5 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index ce549eda6b..e2487b927e 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -356,7 +356,7 @@ QDebug &QDebug::resetFormat() stream->space = true; if (stream->context.version > 1) stream->flags = 0; - stream->setVerbosity(Stream::DefaultVerbosity); + stream->setVerbosity(DefaultVerbosity); return *this; } @@ -461,7 +461,7 @@ QDebug &QDebug::resetFormat() The allowed range is from 0 to 7. The default value is 2. - \sa setVerbosity() + \sa setVerbosity(), VerbosityLevel */ /*! @@ -472,7 +472,7 @@ QDebug &QDebug::resetFormat() The allowed range is from 0 to 7. The default value is 2. - \sa verbosity() + \sa verbosity(), VerbosityLevel */ /*! @@ -483,6 +483,19 @@ QDebug &QDebug::resetFormat() The allowed range is from 0 to 7. The default value is 2. + \sa verbosity(), setVerbosity(), VerbosityLevel +*/ + +/*! + \enum QDebug::VerbosityLevel + \since 5.13 + + This enum describes the range of verbosity levels. + + \value MinimumVerbosity + \value DefaultVerbosity + \value MaximumVerbosity + \sa verbosity(), setVerbosity() */ diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 07a0228168..91fde75fa5 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -67,7 +67,7 @@ class Q_CORE_EXPORT QDebug friend class QMessageLogger; friend class QDebugStateSaverPrivate; struct Stream { - enum { DefaultVerbosity = 2, VerbosityShift = 29, VerbosityMask = 0x7 }; + enum { VerbosityShift = 29, VerbosityMask = 0x7 }; Stream(QIODevice *device) : ts(device), ref(1), type(QtDebugMsg), space(true), message_output(false), flags(DefaultVerbosity << VerbosityShift) {} @@ -92,7 +92,7 @@ class Q_CORE_EXPORT QDebug void setFlag(FormatFlag flag) { if (context.version > 1) { flags |= flag; } } void unsetFlag(FormatFlag flag) { if (context.version > 1) { flags &= ~flag; } } int verbosity() const - { return context.version > 1 ? (flags >> VerbosityShift) & VerbosityMask : int(Stream::DefaultVerbosity); } + { return context.version > 1 ? (flags >> VerbosityShift) & VerbosityMask : int(DefaultVerbosity); } void setVerbosity(int v) { if (context.version > 1) { @@ -126,6 +126,7 @@ public: inline QDebug &verbosity(int verbosityLevel) { setVerbosity(verbosityLevel); return *this; } int verbosity() const { return stream->verbosity(); } void setVerbosity(int verbosityLevel) { stream->setVerbosity(verbosityLevel); } + enum VerbosityLevel { MinimumVerbosity = 0, DefaultVerbosity = 2, MaximumVerbosity = 7 }; bool autoInsertSpaces() const { return stream->space; } void setAutoInsertSpaces(bool b) { stream->space = b; } |