diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-03-03 15:09:12 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-03-07 02:13:14 +0100 |
commit | 5e91f142aa0342e177d65037224ab983c878a679 (patch) | |
tree | 65aad80a3d3980f9f112f7b5e9471c6b23a3d044 /src/gui/itemmodels/qstandarditemmodel.h | |
parent | 9e01827193a4aaafc7bb1a92c15c4edcee3bee00 (diff) |
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>
Diffstat (limited to 'src/gui/itemmodels/qstandarditemmodel.h')
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index 66ae3a27cd..14fa23e447 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -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); } |