Diaglib: Fix build

Use range-based for and fix deprecation warnings.

Change-Id: I54152b2598e9e4a7a3cc9db9b7072bbabcef7fcf
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Friedemann Kleint 2020-01-28 11:46:16 +01:00
parent 46ebd11e66
commit cc333f5faf
5 changed files with 19 additions and 19 deletions

View File

@ -69,7 +69,7 @@ QDebug operator<<(QDebug debug, const QStyleOption *option)
debug << "QStyleOption("; debug << "QStyleOption(";
} }
debug << "rect=" << option->rect.width() << 'x' << option->rect.height() debug << "rect=" << option->rect.width() << 'x' << option->rect.height()
<< forcesign << option->rect.x() << option->rect.y() << noforcesign; << Qt::forcesign << option->rect.x() << option->rect.y() << Qt::noforcesign;
if (option->state != QStyle::State_None) if (option->state != QStyle::State_None)
debug << ", state=" << option->state; debug << ", state=" << option->state;
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000

View File

@ -69,7 +69,7 @@ static QTextStream &operator<<(QTextStream &str, const QSize &s)
static QTextStream &operator<<(QTextStream &str, const QRect &rect) static QTextStream &operator<<(QTextStream &str, const QRect &rect)
{ {
str << rect.size() << forcesign << rect.x() << rect.y() << noforcesign; str << rect.size() << Qt::forcesign << rect.x() << rect.y() << Qt::noforcesign;
return str; return str;
} }
@ -110,7 +110,7 @@ static bool isTopLevel(HWND hwnd)
static void formatNativeWindow(HWND hwnd, QTextStream &str) static void formatNativeWindow(HWND hwnd, QTextStream &str)
{ {
str << hex << showbase << quintptr(hwnd) << noshowbase << dec; str << Qt::hex << Qt::showbase << quintptr(hwnd) << Qt::noshowbase << Qt::dec;
const bool topLevel = isTopLevel(hwnd); const bool topLevel = isTopLevel(hwnd);
if (topLevel) if (topLevel)
@ -136,7 +136,7 @@ static void formatNativeWindow(HWND hwnd, QTextStream &str)
if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0]))) if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
str << '"' << QString::fromWCharArray(buf) << '"'; str << '"' << QString::fromWCharArray(buf) << '"';
str << hex << showbase; str << Qt::hex << Qt::showbase;
if (const LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE)) { if (const LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE)) {
str << " style=" << style; str << " style=" << style;
debugWinStyle(str, style, WS_OVERLAPPED) debugWinStyle(str, style, WS_OVERLAPPED)
@ -208,7 +208,7 @@ static void formatNativeWindow(HWND hwnd, QTextStream &str)
if (const ULONG_PTR wndProc = GetClassLongPtr(hwnd, GCLP_WNDPROC)) if (const ULONG_PTR wndProc = GetClassLongPtr(hwnd, GCLP_WNDPROC))
str << " wndProc=" << wndProc; str << " wndProc=" << wndProc;
str << noshowbase << dec; str << Qt::noshowbase << Qt::dec;
if (GetWindowModuleFileName(hwnd, buf, sizeof(buf)/sizeof(buf[0]))) if (GetWindowModuleFileName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
str << " module=\"" << QString::fromWCharArray(buf) << '"'; str << " module=\"" << QString::fromWCharArray(buf) << '"';
@ -258,7 +258,7 @@ static void dumpNativeWindows(const WIdVector& wins)
DumpContext dc; DumpContext dc;
QString s; QString s;
dc.stream = QSharedPointer<QTextStream>(new QTextStream(&s)); dc.stream = QSharedPointer<QTextStream>(new QTextStream(&s));
foreach (WId win, wins) for (WId win : wins)
dumpNativeWindowRecursion(reinterpret_cast<HWND>(win), &dc); dumpNativeWindowRecursion(reinterpret_cast<HWND>(win), &dc);
#if QT_VERSION >= 0x050400 #if QT_VERSION >= 0x050400
qDebug().noquote() << s; qDebug().noquote() << s;

View File

@ -86,14 +86,14 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w,
formatWidgetClass(str, w); formatWidgetClass(str, w);
str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] "); str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] ");
if (const WId nativeWinId = w->internalWinId()) if (const WId nativeWinId = w->internalWinId())
str << "[native: " << hex << showbase << nativeWinId << dec << noshowbase << "] "; str << "[native: " << Qt::hex << Qt::showbase << nativeWinId << Qt::dec << Qt::noshowbase << "] ";
if (w->isWindow()) if (w->isWindow())
str << "[top] "; str << "[top] ";
str << (w->testAttribute(Qt::WA_Mapped) ? "[mapped] " : "[not mapped] "); str << (w->testAttribute(Qt::WA_Mapped) ? "[mapped] " : "[not mapped] ");
if (w->testAttribute(Qt::WA_DontCreateNativeAncestors)) if (w->testAttribute(Qt::WA_DontCreateNativeAncestors))
str << "[NoNativeAncestors] "; str << "[NoNativeAncestors] ";
if (const int states = w->windowState()) if (const int states = w->windowState())
str << "windowState=" << hex << showbase << states << dec << noshowbase << ' '; str << "windowState=" << Qt::hex << Qt::showbase << states << Qt::dec << Qt::noshowbase << ' ';
formatRect(str, w->geometry()); formatRect(str, w->geometry());
if (w->isWindow()) { if (w->isWindow()) {
str << ' ' << w->logicalDpiX() << "DPI"; str << ' ' << w->logicalDpiX() << "DPI";
@ -135,7 +135,7 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w,
str << '\n'; str << '\n';
} }
#endif // Qt 5 #endif // Qt 5
foreach (const QObject *co, w->children()) { for (const QObject *co : w->children()) {
if (co->isWidgetType()) if (co->isWidgetType())
dumpWidgetRecursion(str, static_cast<const QWidget *>(co), options, depth + 1); dumpWidgetRecursion(str, static_cast<const QWidget *>(co), options, depth + 1);
} }
@ -151,11 +151,11 @@ void dumpAllWidgets(FormatWindowOptions options, const QWidget *root)
topLevels.append(const_cast<QWidget *>(root)); topLevels.append(const_cast<QWidget *>(root));
else else
topLevels = QApplication::topLevelWidgets(); topLevels = QApplication::topLevelWidgets();
foreach (QWidget *tw, topLevels) for (QWidget *tw : qAsConst(topLevels))
dumpWidgetRecursion(str, tw, options); dumpWidgetRecursion(str, tw, options);
#if QT_VERSION >= 0x050400 #if QT_VERSION >= 0x050400
{ {
foreach (const QString &line, d.split(QLatin1Char('\n'))) for (const QString &line : d.split(QLatin1Char('\n')))
qDebug().noquote() << line; qDebug().noquote() << line;
} }
#else #else

View File

@ -62,7 +62,7 @@ void formatObject(QTextStream &str, const QObject *o)
void formatRect(QTextStream &str, const QRect &geom) void formatRect(QTextStream &str, const QRect &geom)
{ {
str << geom.width() << 'x' << geom.height() str << geom.width() << 'x' << geom.height()
<< forcesign << geom.x() << geom.y() << noforcesign; << Qt::forcesign << geom.x() << geom.y() << Qt::noforcesign;
} }
#define debugType(s, type, typeConstant) \ #define debugType(s, type, typeConstant) \
@ -75,7 +75,7 @@ if (flags & flagConstant) \
void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags) void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags)
{ {
str << showbase << hex << unsigned(flags) << dec << noshowbase; str << Qt::showbase << Qt::hex << unsigned(flags) << Qt::dec << Qt::noshowbase;
const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask; const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask;
debugFlag(str, flags, Qt::Window) debugFlag(str, flags, Qt::Window)
debugType(str, windowType, Qt::Dialog) debugType(str, windowType, Qt::Dialog)
@ -123,7 +123,7 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option
formatObject(str, w); formatObject(str, w);
str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] "); str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] ");
if (const WId nativeWinId = pw ? pw->winId() : WId(0)) if (const WId nativeWinId = pw ? pw->winId() : WId(0))
str << "[native: " << hex << showbase << nativeWinId << dec << noshowbase << "] "; str << "[native: " << Qt::hex << Qt::showbase << nativeWinId << Qt::dec << Qt::noshowbase << "] ";
if (w->isTopLevel()) if (w->isTopLevel())
str << "[top] "; str << "[top] ";
if (w->isExposed()) if (w->isExposed())
@ -162,7 +162,7 @@ static void dumpWindowRecursion(QTextStream &str, const QWindow *w,
{ {
indentStream(str, 2 * depth); indentStream(str, 2 * depth);
formatWindow(str, w, options); formatWindow(str, w, options);
foreach (const QObject *co, w->children()) { for (const QObject *co : w->children()) {
if (co->isWindowType()) if (co->isWindowType())
dumpWindowRecursion(str, static_cast<const QWindow *>(co), options, depth + 1); dumpWindowRecursion(str, static_cast<const QWindow *>(co), options, depth + 1);
} }
@ -173,7 +173,7 @@ void dumpAllWindows(FormatWindowOptions options)
QString d; QString d;
QTextStream str(&d); QTextStream str(&d);
str << "### QWindows:\n"; str << "### QWindows:\n";
foreach (QWindow *w, QGuiApplication::topLevelWindows()) for (QWindow *w : QGuiApplication::topLevelWindows())
dumpWindowRecursion(str, w, options); dumpWindowRecursion(str, w, options);
#if QT_VERSION >= 0x050400 #if QT_VERSION >= 0x050400
qDebug().noquote() << d; qDebug().noquote() << d;

View File

@ -408,8 +408,8 @@ struct FormattingContext
static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context) static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context)
{ {
const ushort unicode = qc.unicode(); const ushort unicode = qc.unicode();
str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << uppercasedigits << hex << unicode str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << Qt::uppercasedigits
<< dec << qSetFieldWidth(0) << ' '; << Qt::hex << unicode << Qt::dec << qSetFieldWidth(0) << ' ';
const EnumLookup *specialChar = enumLookup(unicode, specialCharactersEnumLookup, sizeof(specialCharactersEnumLookup) / sizeof(EnumLookup)); const EnumLookup *specialChar = enumLookup(unicode, specialCharactersEnumLookup, sizeof(specialCharactersEnumLookup) / sizeof(EnumLookup));
if (specialChar) if (specialChar)
@ -477,7 +477,7 @@ QString dumpTextAsCode(const QString &text)
{ {
QString result; QString result;
QTextStream str(&result); QTextStream str(&result);
str << " QString result;\n" << hex << showbase; str << " QString result;\n" << Qt::hex << Qt::showbase;
for (QChar c : text) for (QChar c : text)
str << " result += QChar(" << c.unicode() << ");\n"; str << " result += QChar(" << c.unicode() << ");\n";
str << '\n'; str << '\n';