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:
|
||||
explicit DebugProxyStyle(QStyle *style);
|
||||
|
||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const;
|
||||
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
||||
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
|
||||
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const;
|
||||
QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const;
|
||||
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
|
||||
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
|
||||
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
|
||||
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
|
||||
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) 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 = nullptr) const override;
|
||||
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 override;
|
||||
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 override;
|
||||
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 override;
|
||||
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override;
|
||||
int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override;
|
||||
int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
|
||||
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 override;
|
||||
};
|
||||
|
||||
} // namespace QtDiag
|
||||
|
@ -197,7 +197,7 @@ static void formatApplicationState(QDebug debug)
|
||||
static void formatMouseState(QObject *o, QDebug debug)
|
||||
{
|
||||
if (o->isWidgetType()) {
|
||||
const QWidget *w = static_cast<const QWidget *>(o);
|
||||
auto w = static_cast<const QWidget *>(o);
|
||||
if (QWidget::mouseGrabber() == w)
|
||||
debug << " [grabbed]";
|
||||
if (w->hasMouseTracking())
|
||||
|
@ -68,10 +68,10 @@ public:
|
||||
};
|
||||
Q_DECLARE_FLAGS(ObjectTypes, ObjectType)
|
||||
|
||||
explicit EventFilter(EventCategories eventCategories, QObject *p = 0);
|
||||
explicit EventFilter(QObject *p = 0);
|
||||
explicit EventFilter(EventCategories eventCategories, QObject *p = nullptr);
|
||||
explicit EventFilter(QObject *p = nullptr);
|
||||
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
bool eventFilter(QObject *, QEvent *) override;
|
||||
|
||||
ObjectTypes objectTypes() const { return m_objectTypes; }
|
||||
void setObjectTypes(ObjectTypes objectTypes) { m_objectTypes = objectTypes; }
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
LogWidget *LogWidget::m_instance = 0;
|
||||
LogWidget *LogWidget::m_instance = nullptr;
|
||||
bool LogWidget::m_lineNumberingEnabled = true;
|
||||
bool LogWidget::m_showMessageType = true;
|
||||
int LogWidget::m_indent = 0;
|
||||
@ -54,7 +54,7 @@ LogWidget::LogWidget(QWidget *parent)
|
||||
|
||||
LogWidget::~LogWidget()
|
||||
{
|
||||
LogWidget::m_instance = 0;
|
||||
LogWidget::m_instance = nullptr;
|
||||
}
|
||||
|
||||
QString LogWidget::startupMessage()
|
||||
|
@ -46,7 +46,7 @@ class LogWidget : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LogWidget(QWidget *parent = 0);
|
||||
explicit LogWidget(QWidget *parent = nullptr);
|
||||
~LogWidget();
|
||||
|
||||
static LogWidget *instance() { return m_instance; }
|
||||
|
@ -59,8 +59,8 @@ static const char *qtWidgetClasses[] = {
|
||||
|
||||
static bool isQtWidget(const char *className)
|
||||
{
|
||||
for (size_t i = 0, count = sizeof(qtWidgetClasses) / sizeof(qtWidgetClasses[0]); i < count; ++i) {
|
||||
if (!qstrcmp(className, qtWidgetClasses[i]))
|
||||
for (auto qtWidgetClass : qtWidgetClasses) {
|
||||
if (qstrcmp(className, qtWidgetClass) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -35,7 +35,7 @@ QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||
|
||||
namespace QtDiag {
|
||||
|
||||
void dumpAllWidgets(FormatWindowOptions options = 0, const QWidget *root = 0);
|
||||
void dumpAllWidgets(FormatWindowOptions options = {}, const QWidget *root = nullptr);
|
||||
|
||||
} // namespace QtDiag
|
||||
|
||||
|
@ -73,7 +73,7 @@ if ((type & typeConstant) == typeConstant) \
|
||||
if (flags & 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;
|
||||
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,
|
||||
FormatWindowOptions options = 0, int depth = 0)
|
||||
FormatWindowOptions options = {}, int depth = 0)
|
||||
{
|
||||
indentStream(str, 2 * depth);
|
||||
formatWindow(str, w, options);
|
||||
|
@ -49,10 +49,10 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(FormatWindowOptions)
|
||||
void indentStream(QTextStream &s, int indent);
|
||||
void formatObject(QTextStream &str, const QObject *o);
|
||||
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 dumpAllWindows(FormatWindowOptions options = 0);
|
||||
void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = {});
|
||||
void dumpAllWindows(FormatWindowOptions options = {});
|
||||
|
||||
} // namespace QtDiag
|
||||
|
||||
|
@ -381,7 +381,7 @@ static const EnumLookup *enumLookup(int v, const EnumLookup *array, size_t size)
|
||||
if (p->value == v)
|
||||
return p;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
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.
|
||||
struct FormattingContext
|
||||
{
|
||||
FormattingContext() : category(-1), direction(-1), joiningType(-1)
|
||||
, decompositionTag(-1), script(-1), unicodeVersion(-1) {}
|
||||
|
||||
int category;
|
||||
int direction;
|
||||
int joiningType;
|
||||
int decompositionTag;
|
||||
int script;
|
||||
int unicodeVersion;
|
||||
int category = -1;
|
||||
int direction = -1;
|
||||
int joiningType = -1;
|
||||
int decompositionTag = -1;
|
||||
int script = -1;
|
||||
int unicodeVersion = -1;
|
||||
};
|
||||
|
||||
static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context)
|
||||
@ -478,8 +475,8 @@ QString dumpTextAsCode(const QString &text)
|
||||
QString result;
|
||||
QTextStream str(&result);
|
||||
str << " QString result;\n" << hex << showbase;
|
||||
for (int i = 0; i < text.size(); ++i)
|
||||
str << " result += QChar(" << text.at(i).unicode() << ");\n";
|
||||
for (QChar c : text)
|
||||
str << " result += QChar(" << c.unicode() << ");\n";
|
||||
str << '\n';
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user