Brush up Diaglib
Fix most clang warnings about override, nullptr, range-based for loops. Change-Id: Id47e57adb63a38e2f397a31511b788a2432c97cf Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
9be66cb282
commit
530c6903a4
@ -39,19 +39,19 @@ class DebugProxyStyle : public QProxyStyle {
|
|||||||
public:
|
public:
|
||||||
explicit DebugProxyStyle(QStyle *style);
|
explicit DebugProxyStyle(QStyle *style);
|
||||||
|
|
||||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
|
||||||
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
|
||||||
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
|
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const override;
|
||||||
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const;
|
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override;
|
||||||
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override;
|
||||||
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
|
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override;
|
||||||
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const;
|
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override;
|
||||||
QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const;
|
QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override;
|
||||||
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
|
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override;
|
||||||
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
|
int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override;
|
||||||
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
|
int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
|
||||||
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
|
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = nullptr) const override;
|
||||||
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
|
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QtDiag
|
} // namespace QtDiag
|
||||||
|
@ -197,7 +197,7 @@ static void formatApplicationState(QDebug debug)
|
|||||||
static void formatMouseState(QObject *o, QDebug debug)
|
static void formatMouseState(QObject *o, QDebug debug)
|
||||||
{
|
{
|
||||||
if (o->isWidgetType()) {
|
if (o->isWidgetType()) {
|
||||||
const QWidget *w = static_cast<const QWidget *>(o);
|
auto w = static_cast<const QWidget *>(o);
|
||||||
if (QWidget::mouseGrabber() == w)
|
if (QWidget::mouseGrabber() == w)
|
||||||
debug << " [grabbed]";
|
debug << " [grabbed]";
|
||||||
if (w->hasMouseTracking())
|
if (w->hasMouseTracking())
|
||||||
|
@ -68,10 +68,10 @@ public:
|
|||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(ObjectTypes, ObjectType)
|
Q_DECLARE_FLAGS(ObjectTypes, ObjectType)
|
||||||
|
|
||||||
explicit EventFilter(EventCategories eventCategories, QObject *p = 0);
|
explicit EventFilter(EventCategories eventCategories, QObject *p = nullptr);
|
||||||
explicit EventFilter(QObject *p = 0);
|
explicit EventFilter(QObject *p = nullptr);
|
||||||
|
|
||||||
bool eventFilter(QObject *, QEvent *);
|
bool eventFilter(QObject *, QEvent *) override;
|
||||||
|
|
||||||
ObjectTypes objectTypes() const { return m_objectTypes; }
|
ObjectTypes objectTypes() const { return m_objectTypes; }
|
||||||
void setObjectTypes(ObjectTypes objectTypes) { m_objectTypes = objectTypes; }
|
void setObjectTypes(ObjectTypes objectTypes) { m_objectTypes = objectTypes; }
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
LogWidget *LogWidget::m_instance = 0;
|
LogWidget *LogWidget::m_instance = nullptr;
|
||||||
bool LogWidget::m_lineNumberingEnabled = true;
|
bool LogWidget::m_lineNumberingEnabled = true;
|
||||||
bool LogWidget::m_showMessageType = true;
|
bool LogWidget::m_showMessageType = true;
|
||||||
int LogWidget::m_indent = 0;
|
int LogWidget::m_indent = 0;
|
||||||
@ -54,7 +54,7 @@ LogWidget::LogWidget(QWidget *parent)
|
|||||||
|
|
||||||
LogWidget::~LogWidget()
|
LogWidget::~LogWidget()
|
||||||
{
|
{
|
||||||
LogWidget::m_instance = 0;
|
LogWidget::m_instance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LogWidget::startupMessage()
|
QString LogWidget::startupMessage()
|
||||||
|
@ -46,7 +46,7 @@ class LogWidget : public QPlainTextEdit
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LogWidget(QWidget *parent = 0);
|
explicit LogWidget(QWidget *parent = nullptr);
|
||||||
~LogWidget();
|
~LogWidget();
|
||||||
|
|
||||||
static LogWidget *instance() { return m_instance; }
|
static LogWidget *instance() { return m_instance; }
|
||||||
|
@ -59,8 +59,8 @@ static const char *qtWidgetClasses[] = {
|
|||||||
|
|
||||||
static bool isQtWidget(const char *className)
|
static bool isQtWidget(const char *className)
|
||||||
{
|
{
|
||||||
for (size_t i = 0, count = sizeof(qtWidgetClasses) / sizeof(qtWidgetClasses[0]); i < count; ++i) {
|
for (auto qtWidgetClass : qtWidgetClasses) {
|
||||||
if (!qstrcmp(className, qtWidgetClasses[i]))
|
if (qstrcmp(className, qtWidgetClass) == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -35,7 +35,7 @@ QT_FORWARD_DECLARE_CLASS(QWidget)
|
|||||||
|
|
||||||
namespace QtDiag {
|
namespace QtDiag {
|
||||||
|
|
||||||
void dumpAllWidgets(FormatWindowOptions options = 0, const QWidget *root = 0);
|
void dumpAllWidgets(FormatWindowOptions options = {}, const QWidget *root = nullptr);
|
||||||
|
|
||||||
} // namespace QtDiag
|
} // namespace QtDiag
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ if ((type & typeConstant) == typeConstant) \
|
|||||||
if (flags & flagConstant) \
|
if (flags & flagConstant) \
|
||||||
s << ' ' << #flagConstant;
|
s << ' ' << #flagConstant;
|
||||||
|
|
||||||
void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags)
|
void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags)
|
||||||
{
|
{
|
||||||
str << showbase << hex << unsigned(flags) << dec << noshowbase;
|
str << showbase << hex << unsigned(flags) << dec << noshowbase;
|
||||||
const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask;
|
const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask;
|
||||||
@ -158,7 +158,7 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void dumpWindowRecursion(QTextStream &str, const QWindow *w,
|
static void dumpWindowRecursion(QTextStream &str, const QWindow *w,
|
||||||
FormatWindowOptions options = 0, int depth = 0)
|
FormatWindowOptions options = {}, int depth = 0)
|
||||||
{
|
{
|
||||||
indentStream(str, 2 * depth);
|
indentStream(str, 2 * depth);
|
||||||
formatWindow(str, w, options);
|
formatWindow(str, w, options);
|
||||||
|
@ -49,10 +49,10 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(FormatWindowOptions)
|
|||||||
void indentStream(QTextStream &s, int indent);
|
void indentStream(QTextStream &s, int indent);
|
||||||
void formatObject(QTextStream &str, const QObject *o);
|
void formatObject(QTextStream &str, const QObject *o);
|
||||||
void formatRect(QTextStream &str, const QRect &geom);
|
void formatRect(QTextStream &str, const QRect &geom);
|
||||||
void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags);
|
void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags);
|
||||||
|
|
||||||
void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = 0);
|
void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = {});
|
||||||
void dumpAllWindows(FormatWindowOptions options = 0);
|
void dumpAllWindows(FormatWindowOptions options = {});
|
||||||
|
|
||||||
} // namespace QtDiag
|
} // namespace QtDiag
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ static const EnumLookup *enumLookup(int v, const EnumLookup *array, size_t size)
|
|||||||
if (p->value == v)
|
if (p->value == v)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *enumName(int v, const EnumLookup *array, size_t size)
|
static const char *enumName(int v, const EnumLookup *array, size_t size)
|
||||||
@ -394,15 +394,12 @@ static const char *enumName(int v, const EnumLookup *array, size_t size)
|
|||||||
// that change will be output.
|
// that change will be output.
|
||||||
struct FormattingContext
|
struct FormattingContext
|
||||||
{
|
{
|
||||||
FormattingContext() : category(-1), direction(-1), joiningType(-1)
|
int category = -1;
|
||||||
, decompositionTag(-1), script(-1), unicodeVersion(-1) {}
|
int direction = -1;
|
||||||
|
int joiningType = -1;
|
||||||
int category;
|
int decompositionTag = -1;
|
||||||
int direction;
|
int script = -1;
|
||||||
int joiningType;
|
int unicodeVersion = -1;
|
||||||
int decompositionTag;
|
|
||||||
int script;
|
|
||||||
int unicodeVersion;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context)
|
static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context)
|
||||||
@ -478,8 +475,8 @@ 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" << hex << showbase;
|
||||||
for (int i = 0; i < text.size(); ++i)
|
for (QChar c : text)
|
||||||
str << " result += QChar(" << text.at(i).unicode() << ");\n";
|
str << " result += QChar(" << c.unicode() << ");\n";
|
||||||
str << '\n';
|
str << '\n';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user