Add QDebug operator for QFileInfo

So far it only shows the path.

Change-Id: Ibfecc20ddacce12a178e1ddb297b0e7b91f29f05
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Shawn Rutledge 2017-05-08 09:01:43 +02:00
parent 5f2eee18c9
commit 3d77e1396c
2 changed files with 16 additions and 0 deletions

View File

@ -42,6 +42,7 @@
#include "qglobal.h"
#include "qdir.h"
#include "qfileinfo_p.h"
#include "qdebug.h"
QT_BEGIN_NAMESPACE
@ -1445,4 +1446,15 @@ void QFileInfo::setCaching(bool enable)
Synonym for QList<QFileInfo>.
*/
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
{
QDebugStateSaver saver(dbg);
dbg.nospace();
dbg.noquote();
dbg << "QFileInfo(" << QDir::toNativeSeparators(fi.filePath()) << ')';
return dbg;
}
#endif
QT_END_NAMESPACE

View File

@ -158,6 +158,10 @@ Q_DECLARE_SHARED(QFileInfo)
typedef QList<QFileInfo> QFileInfoList;
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT QDebug operator<<(QDebug, const QFileInfo &);
#endif
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QFileInfo)