Miscellanea fixes for QT_TYPESAFE_FLAGS in our headers
In preparation for adding it to headersclean. Some remarks: * QStandardItemModel builds just fine (QFlags has comparison operators against literal zero); the warning we however get is about 0 converted to a null pointer constant. There's nothing we can do about that one (even <compare> gives such a warning). * Several code was depending on flags->int conversions. Add toInt(), but also cast again to the expected type to avoid warnings in case toInt() returns unsigned int. * Ported to explicit casts to bool rather than test(Any)Flag to minimize confusion for people unfamiliar with the test*Flag methods. Change-Id: I5be280ac33a0b38e2680096f0e79129fd55ba241 Reviewed-by: Marc Mutz <marc.mutz@qt.io>bb10
parent
9e01827193
commit
5e91f142aa
|
|
@ -143,43 +143,43 @@ public:
|
|||
void setFlags(Qt::ItemFlags flags);
|
||||
|
||||
inline bool isEnabled() const {
|
||||
return (flags() & Qt::ItemIsEnabled) != 0;
|
||||
return bool(flags() & Qt::ItemIsEnabled);
|
||||
}
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
inline bool isEditable() const {
|
||||
return (flags() & Qt::ItemIsEditable) != 0;
|
||||
return bool(flags() & Qt::ItemIsEditable);
|
||||
}
|
||||
void setEditable(bool editable);
|
||||
|
||||
inline bool isSelectable() const {
|
||||
return (flags() & Qt::ItemIsSelectable) != 0;
|
||||
return bool(flags() & Qt::ItemIsSelectable);
|
||||
}
|
||||
void setSelectable(bool selectable);
|
||||
|
||||
inline bool isCheckable() const {
|
||||
return (flags() & Qt::ItemIsUserCheckable) != 0;
|
||||
return bool(flags() & Qt::ItemIsUserCheckable);
|
||||
}
|
||||
void setCheckable(bool checkable);
|
||||
|
||||
inline bool isAutoTristate() const {
|
||||
return (flags() & Qt::ItemIsAutoTristate) != 0;
|
||||
return bool(flags() & Qt::ItemIsAutoTristate);
|
||||
}
|
||||
void setAutoTristate(bool tristate);
|
||||
|
||||
inline bool isUserTristate() const {
|
||||
return (flags() & Qt::ItemIsUserTristate) != 0;
|
||||
return bool(flags() & Qt::ItemIsUserTristate);
|
||||
}
|
||||
void setUserTristate(bool tristate);
|
||||
|
||||
#if QT_CONFIG(draganddrop)
|
||||
inline bool isDragEnabled() const {
|
||||
return (flags() & Qt::ItemIsDragEnabled) != 0;
|
||||
return bool(flags() & Qt::ItemIsDragEnabled);
|
||||
}
|
||||
void setDragEnabled(bool dragEnabled);
|
||||
|
||||
inline bool isDropEnabled() const {
|
||||
return (flags() & Qt::ItemIsDropEnabled) != 0;
|
||||
return bool(flags() & Qt::ItemIsDropEnabled);
|
||||
}
|
||||
void setDropEnabled(bool dropEnabled);
|
||||
#endif // QT_CONFIG(draganddrop)
|
||||
|
|
@ -274,7 +274,7 @@ inline void QStandardItem::setFont(const QFont &afont)
|
|||
{ setData(afont, Qt::FontRole); }
|
||||
|
||||
inline void QStandardItem::setTextAlignment(Qt::Alignment atextAlignment)
|
||||
{ setData(int(atextAlignment), Qt::TextAlignmentRole); }
|
||||
{ setData(int(atextAlignment.toInt()), Qt::TextAlignmentRole); }
|
||||
|
||||
inline void QStandardItem::setBackground(const QBrush &abrush)
|
||||
{ setData(abrush, Qt::BackgroundRole); }
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ inline QMatrix4x4& QMatrix4x4::operator*=(const QMatrix4x4& o)
|
|||
const QMatrix4x4 other = o; // prevent aliasing when &o == this ### Qt 6: take o by value
|
||||
flagBits |= other.flagBits;
|
||||
|
||||
if (flagBits < Rotation2D) {
|
||||
if (flagBits.toInt() < Rotation2D) {
|
||||
m[3][0] += m[0][0] * other.m[3][0];
|
||||
m[3][1] += m[1][1] * other.m[3][1];
|
||||
m[3][2] += m[2][2] * other.m[3][2];
|
||||
|
|
@ -637,7 +637,7 @@ inline QMatrix4x4 operator-(const QMatrix4x4& m1, const QMatrix4x4& m2)
|
|||
inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2)
|
||||
{
|
||||
QMatrix4x4::Flags flagBits = m1.flagBits | m2.flagBits;
|
||||
if (flagBits < QMatrix4x4::Rotation2D) {
|
||||
if (flagBits.toInt() < QMatrix4x4::Rotation2D) {
|
||||
QMatrix4x4 m = m1;
|
||||
m.m[3][0] += m.m[0][0] * m2.m[3][0];
|
||||
m.m[3][1] += m.m[1][1] * m2.m[3][1];
|
||||
|
|
@ -943,11 +943,11 @@ inline QPoint QMatrix4x4::map(const QPoint& point) const
|
|||
yin = point.y();
|
||||
if (flagBits == QMatrix4x4::Identity) {
|
||||
return point;
|
||||
} else if (flagBits < QMatrix4x4::Rotation2D) {
|
||||
} else if (flagBits.toInt() < QMatrix4x4::Rotation2D) {
|
||||
// Translation | Scale
|
||||
return QPoint(qRound(xin * m[0][0] + m[3][0]),
|
||||
qRound(yin * m[1][1] + m[3][1]));
|
||||
} else if (flagBits < QMatrix4x4::Perspective) {
|
||||
} else if (flagBits.toInt() < QMatrix4x4::Perspective) {
|
||||
return QPoint(qRound(xin * m[0][0] + yin * m[1][0] + m[3][0]),
|
||||
qRound(xin * m[0][1] + yin * m[1][1] + m[3][1]));
|
||||
} else {
|
||||
|
|
@ -975,11 +975,11 @@ inline QPointF QMatrix4x4::map(const QPointF& point) const
|
|||
yin = point.y();
|
||||
if (flagBits == QMatrix4x4::Identity) {
|
||||
return point;
|
||||
} else if (flagBits < QMatrix4x4::Rotation2D) {
|
||||
} else if (flagBits.toInt() < QMatrix4x4::Rotation2D) {
|
||||
// Translation | Scale
|
||||
return QPointF(xin * qreal(m[0][0]) + qreal(m[3][0]),
|
||||
yin * qreal(m[1][1]) + qreal(m[3][1]));
|
||||
} else if (flagBits < QMatrix4x4::Perspective) {
|
||||
} else if (flagBits.toInt() < QMatrix4x4::Perspective) {
|
||||
return QPointF(xin * qreal(m[0][0]) + yin * qreal(m[1][0]) +
|
||||
qreal(m[3][0]),
|
||||
xin * qreal(m[0][1]) + yin * qreal(m[1][1]) +
|
||||
|
|
@ -1009,12 +1009,12 @@ inline QVector3D QMatrix4x4::map(const QVector3D& point) const
|
|||
float x, y, z, w;
|
||||
if (flagBits == QMatrix4x4::Identity) {
|
||||
return point;
|
||||
} else if (flagBits < QMatrix4x4::Rotation2D) {
|
||||
} else if (flagBits.toInt() < QMatrix4x4::Rotation2D) {
|
||||
// Translation | Scale
|
||||
return QVector3D(point.x() * m[0][0] + m[3][0],
|
||||
point.y() * m[1][1] + m[3][1],
|
||||
point.z() * m[2][2] + m[3][2]);
|
||||
} else if (flagBits < QMatrix4x4::Rotation) {
|
||||
} else if (flagBits.toInt() < QMatrix4x4::Rotation) {
|
||||
// Translation | Scale | Rotation2D
|
||||
return QVector3D(point.x() * m[0][0] + point.y() * m[1][0] + m[3][0],
|
||||
point.x() * m[0][1] + point.y() * m[1][1] + m[3][1],
|
||||
|
|
@ -1045,10 +1045,10 @@ inline QVector3D QMatrix4x4::map(const QVector3D& point) const
|
|||
|
||||
inline QVector3D QMatrix4x4::mapVector(const QVector3D& vector) const
|
||||
{
|
||||
if (flagBits < Scale) {
|
||||
if (flagBits.toInt() < Scale) {
|
||||
// Translation
|
||||
return vector;
|
||||
} else if (flagBits < Rotation2D) {
|
||||
} else if (flagBits.toInt() < Rotation2D) {
|
||||
// Translation | Scale
|
||||
return QVector3D(vector.x() * m[0][0],
|
||||
vector.y() * m[1][1],
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ public:
|
|||
inline void setDirty(DirtyFlags df);
|
||||
inline void clearDirty(DirtyFlags df);
|
||||
|
||||
bool hasFeature(PaintEngineFeatures feature) const { return gccaps & feature; }
|
||||
bool hasFeature(PaintEngineFeatures feature) const { return bool(gccaps & feature); }
|
||||
|
||||
QPainter *painter() const;
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ inline void QPaintEngine::fix_neg_rect(int *x, int *y, int *w, int *h)
|
|||
|
||||
inline bool QPaintEngine::testDirty(DirtyFlags df) {
|
||||
Q_ASSERT(state);
|
||||
return state->dirtyFlags & df;
|
||||
return bool(state->dirtyFlags & df);
|
||||
}
|
||||
|
||||
inline void QPaintEngine::setDirty(DirtyFlags df) {
|
||||
|
|
@ -331,7 +331,7 @@ inline void QPaintEngine::setDirty(DirtyFlags df) {
|
|||
inline void QPaintEngine::clearDirty(DirtyFlags df)
|
||||
{
|
||||
Q_ASSERT(state);
|
||||
state->dirtyFlags &= ~static_cast<uint>(df);
|
||||
state->dirtyFlags &= ~df;
|
||||
}
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextItem::RenderFlags)
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ public:
|
|||
void setRenderHint(RenderHint hint, bool on = true);
|
||||
void setRenderHints(RenderHints hints, bool on = true);
|
||||
RenderHints renderHints() const;
|
||||
inline bool testRenderHint(RenderHint hint) const { return renderHints() & hint; }
|
||||
inline bool testRenderHint(RenderHint hint) const { return bool(renderHints() & hint); }
|
||||
|
||||
QPaintEngine *paintEngine() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -707,7 +707,7 @@ public:
|
|||
{ return boolProperty(BlockNonBreakableLines); }
|
||||
|
||||
inline void setPageBreakPolicy(PageBreakFlags flags)
|
||||
{ setProperty(PageBreakPolicy, int(flags)); }
|
||||
{ setProperty(PageBreakPolicy, int(flags.toInt())); }
|
||||
inline PageBreakFlags pageBreakPolicy() const
|
||||
{ return PageBreakFlags(intProperty(PageBreakPolicy)); }
|
||||
|
||||
|
|
@ -727,7 +727,7 @@ protected:
|
|||
Q_DECLARE_SHARED(QTextBlockFormat)
|
||||
|
||||
inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment)
|
||||
{ setProperty(BlockAlignment, int(aalignment)); }
|
||||
{ setProperty(BlockAlignment, int(aalignment.toInt())); }
|
||||
|
||||
inline void QTextBlockFormat::setIndent(int aindent)
|
||||
{ setProperty(BlockIndent, aindent); }
|
||||
|
|
@ -929,7 +929,7 @@ public:
|
|||
{ return lengthProperty(FrameHeight); }
|
||||
|
||||
inline void setPageBreakPolicy(PageBreakFlags flags)
|
||||
{ setProperty(PageBreakPolicy, int(flags)); }
|
||||
{ setProperty(PageBreakPolicy, int(flags.toInt())); }
|
||||
inline PageBreakFlags pageBreakPolicy() const
|
||||
{ return PageBreakFlags(intProperty(PageBreakPolicy)); }
|
||||
|
||||
|
|
@ -1027,7 +1027,7 @@ inline void QTextTableFormat::setCellPadding(qreal apadding)
|
|||
{ setProperty(TableCellPadding, apadding); }
|
||||
|
||||
inline void QTextTableFormat::setAlignment(Qt::Alignment aalignment)
|
||||
{ setProperty(BlockAlignment, int(aalignment)); }
|
||||
{ setProperty(BlockAlignment, int(aalignment.toInt())); }
|
||||
|
||||
class Q_GUI_EXPORT QTextTableCellFormat : public QTextCharFormat
|
||||
{
|
||||
|
|
|
|||
|
|
@ -141,10 +141,10 @@ private:
|
|||
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags)
|
||||
|
||||
inline void QTextOption::setAlignment(Qt::Alignment aalignment)
|
||||
{ align = aalignment; }
|
||||
{ align = uint(aalignment.toInt()); }
|
||||
|
||||
inline void QTextOption::setFlags(Flags aflags)
|
||||
{ f = aflags; }
|
||||
{ f = uint(aflags.toInt()); }
|
||||
|
||||
inline void QTextOption::setTabStopDistance(qreal atabStop)
|
||||
{ tab = atabStop; }
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ inline const char *toString(QSizePolicy::Policy p)
|
|||
inline QByteArray toString(QSizePolicy::ControlTypes ct)
|
||||
{
|
||||
static const QMetaEnum me = QSizePolicy::staticMetaObject.enumerator(QSizePolicy::staticMetaObject.indexOfEnumerator("ControlTypes"));
|
||||
return me.valueToKeys(int(ct));
|
||||
return me.valueToKeys(int(ct.toInt()));
|
||||
}
|
||||
|
||||
inline QByteArray toString(QSizePolicy sp)
|
||||
|
|
|
|||
|
|
@ -832,17 +832,17 @@ inline QWidget *QWidget::childAt(int ax, int ay) const
|
|||
{ return childAt(QPoint(ax, ay)); }
|
||||
|
||||
inline Qt::WindowType QWidget::windowType() const
|
||||
{ return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); }
|
||||
{ return static_cast<Qt::WindowType>((data->window_flags & Qt::WindowType_Mask).toInt()); }
|
||||
inline Qt::WindowFlags QWidget::windowFlags() const
|
||||
{ return data->window_flags; }
|
||||
|
||||
#if QT_DEPRECATED_SINCE(6, 1)
|
||||
inline bool QWidget::isTopLevel() const
|
||||
{ return (windowType() & Qt::Window); }
|
||||
{ return bool(windowType() & Qt::Window); }
|
||||
#endif
|
||||
|
||||
inline bool QWidget::isWindow() const
|
||||
{ return (windowType() & Qt::Window); }
|
||||
{ return bool(windowType() & Qt::Window); }
|
||||
|
||||
inline bool QWidget::isEnabled() const
|
||||
{ return !testAttribute(Qt::WA_Disabled); }
|
||||
|
|
|
|||
Loading…
Reference in New Issue