Fix debug operator for QRegion.
Use QDebugStateSaver, drop the multiline format, check for null, empty and output rectangular regions as: QRegion(0,0 252x188) and complicated regions as: QRegion(size=4, bounds=(0,0 278x262) - [(0,0 278x13), (0,13 13x188), (265,13 13x188), (0,201 278x61)]) Change-Id: I82b8f58af08f7128e6cf2c2c8b06c4684fc6a9c8 Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
parent
5ac2b39133
commit
893f2ade85
@ -41,7 +41,7 @@
|
||||
#include "qimage.h"
|
||||
#include "qbitmap.h"
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <private/qdebug_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -422,11 +422,32 @@ QDataStream &operator>>(QDataStream &s, QRegion &r)
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug s, const QRegion &r)
|
||||
{
|
||||
QVector<QRect> rects = r.rects();
|
||||
s.nospace() << "QRegion(size=" << rects.size() << "), "
|
||||
<< "bounds = " << r.boundingRect() << '\n';
|
||||
for (int i=0; i<rects.size(); ++i)
|
||||
s << "- " << i << rects.at(i) << '\n';
|
||||
QDebugStateSaver saver(s);
|
||||
s.nospace();
|
||||
s << "QRegion(";
|
||||
if (r.isNull()) {
|
||||
s << "null";
|
||||
} else if (r.isEmpty()) {
|
||||
s << "empty";
|
||||
} else {
|
||||
const QVector<QRect> rects = r.rects();
|
||||
const int count = rects.size();
|
||||
if (count > 1)
|
||||
s << "size=" << count << ", bounds=(";
|
||||
QtDebugUtils::formatQRect(s, r.boundingRect());
|
||||
if (count > 1) {
|
||||
s << ") - [";
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (i)
|
||||
s << ", ";
|
||||
s << '(';
|
||||
QtDebugUtils::formatQRect(s, rects.at(i));
|
||||
s << ')';
|
||||
}
|
||||
s << ']';
|
||||
}
|
||||
}
|
||||
s << ')';
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user