diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index f04cfe45d9..608769cd36 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -934,11 +934,24 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) */ /*! + \if defined(qt7) + + \fn Qt::Alignment QListWidgetItem::textAlignment() const + + Returns the text alignment for the list item. + + \else + \fn int QListWidgetItem::textAlignment() const Returns the text alignment for the list item. - \sa Qt::AlignmentFlag + \note This function returns an int for historical reasons. It will + be corrected to return Qt::Alignment in Qt 7. + + \sa Qt::Alignment + + \endif */ /*! @@ -1092,11 +1105,21 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) */ /*! + \obsolete [6.4] Use the overload that takes a Qt::Alignment argument. + \fn void QListWidgetItem::setTextAlignment(int alignment) Sets the list item's text alignment to \a alignment. - \sa Qt::AlignmentFlag + \sa Qt::Alignment +*/ + +/*! + \since 6.4 + + \fn void QListWidgetItem::setTextAlignment(Qt::Alignment alignment) + + Sets the list item's text alignment to \a alignment. */ /*! diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h index 594266d71b..2005c27c48 100644 --- a/src/widgets/itemviews/qlistwidget.h +++ b/src/widgets/itemviews/qlistwidget.h @@ -109,10 +109,20 @@ public: { return qvariant_cast(data(Qt::FontRole)); } inline void setFont(const QFont &font); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) inline int textAlignment() const { return data(Qt::TextAlignmentRole).toInt(); } +#else + inline Qt::Alignment textAlignment() const + { return qvariant_cast(data(Qt::TextAlignmentRole)); } +#endif +#if QT_DEPRECATED_SINCE(6, 4) + QT_DEPRECATED_VERSION_X_6_4("Use the overload taking Qt::Alignment") inline void setTextAlignment(int alignment) { setData(Qt::TextAlignmentRole, alignment); } +#endif + inline void setTextAlignment(Qt::Alignment alignment) + { setData(Qt::TextAlignmentRole, QVariant::fromValue(alignment)); } inline QBrush background() const { return qvariant_cast(data(Qt::BackgroundRole)); } @@ -125,7 +135,7 @@ public: { setData(Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } inline Qt::CheckState checkState() const - { return static_cast(data(Qt::CheckStateRole).toInt()); } + { return qvariant_cast(data(Qt::CheckStateRole)); } inline void setCheckState(Qt::CheckState state) { setData(Qt::CheckStateRole, static_cast(state)); } diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 5c3d3385da..360d3c1df5 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -1289,14 +1289,29 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) */ /*! + \if defined(qt7) + + \fn Qt::Alignment QTableWidgetItem::textAlignment() const + + Returns the text alignment for the list item. + + \else + \fn int QTableWidgetItem::textAlignment() const Returns the text alignment for the item's text. + \note This function returns an int for historical reasons. It will + be corrected to return Qt::Alignment in Qt 7. + \sa Qt::Alignment + + \endif */ /*! + \obsolete [6.4] Use the overload that takes a Qt::Alignment argument. + \fn void QTableWidgetItem::setTextAlignment(int alignment) Sets the text alignment for the item's text to the \a alignment @@ -1305,6 +1320,15 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) \sa Qt::Alignment */ +/*! + \since 6.4 + + \fn void QTableWidgetItem::setTextAlignment(Qt::Alignment alignment) + + Sets the text alignment for the item's text to the \a alignment + specified. +*/ + /*! Constructs a table item of the specified \a type that does not belong to any table. diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h index 46711c8fa0..241ad4a588 100644 --- a/src/widgets/itemviews/qtablewidget.h +++ b/src/widgets/itemviews/qtablewidget.h @@ -133,10 +133,20 @@ public: { return qvariant_cast(data(Qt::FontRole)); } inline void setFont(const QFont &font); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) inline int textAlignment() const { return data(Qt::TextAlignmentRole).toInt(); } +#else + inline Qt::Alignment textAlignment() const + { return qvariant_cast(data(Qt::TextAlignmentRole)); } +#endif +#if QT_DEPRECATED_SINCE(6, 4) + QT_DEPRECATED_VERSION_X_6_4("Use the overload taking Qt::Alignment") inline void setTextAlignment(int alignment) { setData(Qt::TextAlignmentRole, alignment); } +#endif + inline void setTextAlignment(Qt::Alignment alignment) + { setData(Qt::TextAlignmentRole, QVariant::fromValue(alignment)); } inline QBrush background() const { return qvariant_cast(data(Qt::BackgroundRole)); } @@ -149,7 +159,7 @@ public: { setData(Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } inline Qt::CheckState checkState() const - { return static_cast(data(Qt::CheckStateRole).toInt()); } + { return qvariant_cast(data(Qt::CheckStateRole)); } inline void setCheckState(Qt::CheckState state) { setData(Qt::CheckStateRole, state); } diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 31e075a788..5ce5c29e82 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1362,17 +1362,44 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const */ /*! + \if defined(qt7) + + \fn Qt::Alignment QTreeWidgetItem::textAlignment(int column) const + + Returns the text alignment for the label in the given \a column. + + \else + \fn int QTreeWidgetItem::textAlignment(int column) const - Returns the text alignment for the label in the given \a column - (see \l{Qt::AlignmentFlag}). + Returns the text alignment for the label in the given \a column. + + \note This function returns an int for historical reasons. It will + be corrected to return Qt::Alignment in Qt 7. + + \sa Qt::Alignment + + \endif */ /*! + \obsolete [6.4] Use the overload that takes a Qt::Alignment argument. + \fn void QTreeWidgetItem::setTextAlignment(int column, int alignment) Sets the text alignment for the label in the given \a column to - the \a alignment specified (see \l{Qt::AlignmentFlag}). + the \a alignment specified. + + \sa Qt::Alignment +*/ + +/*! + \since 6.4 + + \fn void QTreeWidgetItem::setTextAlignment(int column, Qt::Alignment alignment) + + Sets the text alignment for the label in the given \a column to + the \a alignment specified. */ /*! diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h index 21f6883cae..5281d621cd 100644 --- a/src/widgets/itemviews/qtreewidget.h +++ b/src/widgets/itemviews/qtreewidget.h @@ -129,10 +129,20 @@ public: { return qvariant_cast(data(column, Qt::FontRole)); } inline void setFont(int column, const QFont &font); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) inline int textAlignment(int column) const { return data(column, Qt::TextAlignmentRole).toInt(); } +#else + inline Qt::Alignment textAlignment(int column) const + { return qvariant_cast(data(column, Qt::TextAlignmentRole)); } +#endif +#if QT_DEPRECATED_SINCE(6, 4) + QT_DEPRECATED_VERSION_X_6_4("Use the overload taking Qt::Alignment") inline void setTextAlignment(int column, int alignment) { setData(column, Qt::TextAlignmentRole, alignment); } +#endif + inline void setTextAlignment(int column, Qt::Alignment alignment) + { setData(column, Qt::TextAlignmentRole, QVariant::fromValue(alignment)); } inline QBrush background(int column) const { return qvariant_cast(data(column, Qt::BackgroundRole)); } @@ -145,7 +155,7 @@ public: { setData(column, Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } inline Qt::CheckState checkState(int column) const - { return static_cast(data(column, Qt::CheckStateRole).toInt()); } + { return qvariant_cast(data(column, Qt::CheckStateRole)); } inline void setCheckState(int column, Qt::CheckState state) { setData(column, Qt::CheckStateRole, state); }