Add QDebug operator for QMimeType.
Task-number: QTBUG-35686 Change-Id: I72be7cf9374f86e8cb3e6946129bbfec8fec9616 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
91c9cae720
commit
14bd7a5881
@ -443,4 +443,17 @@ bool QMimeType::inherits(const QString &mimeTypeName) const
|
||||
return QMimeDatabasePrivate::instance()->inherits(d->name, mimeTypeName);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug debug, const QMimeType &mime)
|
||||
{
|
||||
QDebugStateSaver saver(debug);
|
||||
if (!mime.isValid()) {
|
||||
debug.nospace() << "QMimeType(invalid)";
|
||||
} else {
|
||||
debug.nospace() << "QMimeType(" << mime.name() << ")";
|
||||
}
|
||||
return debug;
|
||||
}
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -110,5 +110,10 @@ protected:
|
||||
|
||||
Q_DECLARE_SHARED(QMimeType)
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
class QDebug;
|
||||
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QMimeType &mime);
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif // QMIMETYPE_H
|
||||
|
@ -211,6 +211,8 @@ void tst_QDebug::debugSpaceHandling() const
|
||||
QCOMPARE(s_msg, QString::fromLatin1("QPoint(21,22) QRect(23,24 25x26) QLine(QPoint(27,28),QPoint(29,30))"));
|
||||
qDebug() << QPointF(21, 22) << QRectF(23, 24, 25, 26) << QLineF(27, 28, 29, 30);
|
||||
QCOMPARE(s_msg, QString::fromLatin1("QPointF(21,22) QRectF(23,24 25x26) QLineF(QPointF(27,28),QPointF(29,30))"));
|
||||
qDebug() << QMimeType() << QMimeDatabase().mimeTypeForName("application/pdf") << "foo";
|
||||
QCOMPARE(s_msg, QString::fromLatin1("QMimeType(invalid) QMimeType(\"application/pdf\") foo"));
|
||||
}
|
||||
|
||||
void tst_QDebug::stateSaver() const
|
||||
|
Loading…
Reference in New Issue
Block a user