Add debug operator for QPrinterInfo.
Add formatting helper to private class QPrintDevice and use that to implement debug operators for QPrintDevice and QPrinterInfo. Sample output: (QPrinterInfo(id="HP_Color_LaserJet_CM6030_MFP", state=0, name="HP Color LaserJet CM6030 MFP", makeAndModel="HP Color LaserJet CM6030 MFP Postscript (recommended)", default, defaultPageSize=QPageSize("Letter", "Letter", 612x792pt, 2), supportsCustomPageSizes, physicalPageSize=(278, 396)..(907, 1296), defaultResolution=600, defaultDuplexMode=0, defaultColorMode=1, supportedMimeTypes=( "application/pdf" "application/postscript" "image/gif" "image/png" "image/jpeg" "image/tiff" "text/html" "text/plain"))) Task-number: QTBUG-44991 Change-Id: I187414d2f68871e38ace0bd66661d2e37712f662 Reviewed-by: Andy Shaw <andy.shaw@digia.com>
This commit is contained in:
parent
e8dc128d1d
commit
319f3c89b1
@ -34,6 +34,8 @@
|
|||||||
#include "qprintdevice_p.h"
|
#include "qprintdevice_p.h"
|
||||||
#include "qplatformprintdevice.h"
|
#include "qplatformprintdevice.h"
|
||||||
|
|
||||||
|
#include <private/qdebug_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
#ifndef QT_NO_PRINTER
|
#ifndef QT_NO_PRINTER
|
||||||
@ -244,6 +246,59 @@ QList<QMimeType> QPrintDevice::supportedMimeTypes() const
|
|||||||
}
|
}
|
||||||
#endif // QT_NO_MIMETYPE
|
#endif // QT_NO_MIMETYPE
|
||||||
|
|
||||||
|
# ifndef QT_NO_DEBUG_STREAM
|
||||||
|
void QPrintDevice::format(QDebug debug) const
|
||||||
|
{
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
debug.noquote();
|
||||||
|
debug.nospace();
|
||||||
|
if (isValid()) {
|
||||||
|
const QString deviceId = id();
|
||||||
|
const QString deviceName = name();
|
||||||
|
debug << "id=\"" << deviceId << "\", state=" << state();
|
||||||
|
if (!deviceName.isEmpty() && deviceName != deviceId)
|
||||||
|
debug << ", name=\"" << deviceName << '"';
|
||||||
|
if (!location().isEmpty())
|
||||||
|
debug << ", location=\"" << location() << '"';
|
||||||
|
debug << ", makeAndModel=\"" << makeAndModel() << '"';
|
||||||
|
if (isDefault())
|
||||||
|
debug << ", default";
|
||||||
|
if (isRemote())
|
||||||
|
debug << ", remote";
|
||||||
|
debug << ", defaultPageSize=" << defaultPageSize();
|
||||||
|
if (supportsCustomPageSizes())
|
||||||
|
debug << ", supportsCustomPageSizes";
|
||||||
|
debug << ", physicalPageSize=(";
|
||||||
|
QtDebugUtils::formatQSize(debug, minimumPhysicalPageSize());
|
||||||
|
debug << ")..(";
|
||||||
|
QtDebugUtils::formatQSize(debug, maximumPhysicalPageSize());
|
||||||
|
debug << "), defaultResolution=" << defaultResolution()
|
||||||
|
<< ", defaultDuplexMode=" << defaultDuplexMode()
|
||||||
|
<< ", defaultColorMode="<< defaultColorMode();
|
||||||
|
# ifndef QT_NO_MIMETYPE
|
||||||
|
const QList<QMimeType> mimeTypes = supportedMimeTypes();
|
||||||
|
if (const int mimeTypeCount = mimeTypes.size()) {
|
||||||
|
debug << ", supportedMimeTypes=(";
|
||||||
|
for (int i = 0; i < mimeTypeCount; ++i)
|
||||||
|
debug << " \"" << mimeTypes.at(i).name() << '"';
|
||||||
|
debug << ')';
|
||||||
|
}
|
||||||
|
# endif // !QT_NO_MIMETYPE
|
||||||
|
} else {
|
||||||
|
debug << "null";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, const QPrintDevice &p)
|
||||||
|
{
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
debug.nospace();
|
||||||
|
debug << "QPrintDevice(";
|
||||||
|
p.format(debug);
|
||||||
|
debug << ')';
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
# endif // QT_NO_DEBUG_STREAM
|
||||||
#endif // QT_NO_PRINTER
|
#endif // QT_NO_PRINTER
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QPlatformPrintDevice;
|
class QPlatformPrintDevice;
|
||||||
class QMarginsF;
|
class QMarginsF;
|
||||||
class QMimeType;
|
class QMimeType;
|
||||||
|
class QDebug;
|
||||||
|
|
||||||
class Q_PRINTSUPPORT_EXPORT QPrintDevice
|
class Q_PRINTSUPPORT_EXPORT QPrintDevice
|
||||||
{
|
{
|
||||||
@ -127,6 +128,10 @@ public:
|
|||||||
QList<QMimeType> supportedMimeTypes() const;
|
QList<QMimeType> supportedMimeTypes() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
# ifndef QT_NO_DEBUG_STREAM
|
||||||
|
void format(QDebug debug) const;
|
||||||
|
# endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QPlatformPrinterSupport;
|
friend class QPlatformPrinterSupport;
|
||||||
friend class QPlatformPrintDevice;
|
friend class QPlatformPrintDevice;
|
||||||
@ -136,6 +141,9 @@ private:
|
|||||||
|
|
||||||
Q_DECLARE_SHARED(QPrintDevice)
|
Q_DECLARE_SHARED(QPrintDevice)
|
||||||
|
|
||||||
|
# ifndef QT_NO_DEBUG_STREAM
|
||||||
|
Q_PRINTSUPPORT_EXPORT QDebug operator<<(QDebug debug, const QPrintDevice &);
|
||||||
|
# endif
|
||||||
#endif // QT_NO_PRINTER
|
#endif // QT_NO_PRINTER
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#ifndef QT_NO_PRINTER
|
#ifndef QT_NO_PRINTER
|
||||||
|
|
||||||
|
#include <QtCore/qdebug.h>
|
||||||
|
|
||||||
#include <qpa/qplatformprintplugin.h>
|
#include <qpa/qplatformprintplugin.h>
|
||||||
#include <qpa/qplatformprintersupport.h>
|
#include <qpa/qplatformprintersupport.h>
|
||||||
|
|
||||||
@ -469,6 +471,21 @@ QPrinterInfo QPrinterInfo::printerInfo(const QString &printerName)
|
|||||||
return QPrinterInfo(printerName);
|
return QPrinterInfo(printerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifndef QT_NO_DEBUG_STREAM
|
||||||
|
QDebug operator<<(QDebug debug, const QPrinterInfo &p)
|
||||||
|
{
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
debug.nospace();
|
||||||
|
debug << "QPrinterInfo(";
|
||||||
|
if (p.isNull())
|
||||||
|
debug << "null";
|
||||||
|
else
|
||||||
|
p.d_ptr->m_printDevice.format(debug);
|
||||||
|
debug << ')';
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
# endif // !QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QT_NO_PRINTER
|
#endif // QT_NO_PRINTER
|
||||||
|
@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
#ifndef QT_NO_PRINTER
|
#ifndef QT_NO_PRINTER
|
||||||
class QPrinterInfoPrivate;
|
class QPrinterInfoPrivate;
|
||||||
class QPrinterInfoPrivateDeleter;
|
class QPrinterInfoPrivateDeleter;
|
||||||
|
class QDebug;
|
||||||
class Q_PRINTSUPPORT_EXPORT QPrinterInfo
|
class Q_PRINTSUPPORT_EXPORT QPrinterInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -98,6 +99,9 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QPlatformPrinterSupport;
|
friend class QPlatformPrinterSupport;
|
||||||
|
# ifndef QT_NO_DEBUG_STREAM
|
||||||
|
friend Q_PRINTSUPPORT_EXPORT QDebug operator<<(QDebug debug, const QPrinterInfo &);
|
||||||
|
# endif
|
||||||
Q_DECLARE_PRIVATE(QPrinterInfo)
|
Q_DECLARE_PRIVATE(QPrinterInfo)
|
||||||
QScopedPointer<QPrinterInfoPrivate, QPrinterInfoPrivateDeleter> d_ptr;
|
QScopedPointer<QPrinterInfoPrivate, QPrinterInfoPrivateDeleter> d_ptr;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user