summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qflags.h9
-rw-r--r--src/corelib/global/qtypetraits.h55
-rw-r--r--src/corelib/io/qurl.h4
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp2
-rw-r--r--src/corelib/kernel/qmetatype.cpp2
-rw-r--r--src/corelib/kernel/qmetatype_p.h2
-rw-r--r--src/gui/opengl/qopengltexturecache.cpp2
-rw-r--r--src/gui/opengl/qopengltexturecache_p.h28
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp4
-rw-r--r--src/widgets/styles/qfusionstyle.cpp4
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm4
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp8
-rw-r--r--tests/auto/other/modeltest/modeltest.cpp2
13 files changed, 44 insertions, 82 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index b871c90c9d..89a0ae9083 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -42,13 +42,12 @@
#ifndef QFLAGS_H
#define QFLAGS_H
-#include <QtCore/qtypeinfo.h>
-#include <QtCore/qtypetraits.h>
-
#ifdef Q_COMPILER_INITIALIZER_LISTS
#include <initializer_list>
#endif
+#include <type_traits>
+
QT_BEGIN_NAMESPACE
class QFlag
@@ -94,6 +93,8 @@ class QFlags
Q_STATIC_ASSERT_X((sizeof(Enum) <= sizeof(int)),
"QFlags uses an int as storage, so an enum with underlying "
"long long will overflow.");
+ Q_STATIC_ASSERT_X((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
+
struct Private;
typedef int (Private::*Zero);
public:
@@ -103,7 +104,7 @@ public:
typedef int Int;
#else
typedef typename std::conditional<
- QtPrivate::QIsUnsignedEnum<Enum>::value,
+ std::is_unsigned<typename std::underlying_type<Enum>::type>::value,
unsigned int,
signed int
>::type Int;
diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h
index 9773db919b..35e407e2de 100644
--- a/src/corelib/global/qtypetraits.h
+++ b/src/corelib/global/qtypetraits.h
@@ -37,6 +37,12 @@
**
****************************************************************************/
+// ### Qt 6: remove this header
+//
+// This header is deliberately empty. Although it did not contain any public API,
+// it was accidentally made public in Qt 5. So: do not remove it for the moment
+// being, to prevent #include breaks in downstreams.
+
#include "QtCore/qglobal.h"
#ifndef QTYPETRAITS_H
@@ -44,53 +50,6 @@
QT_BEGIN_NAMESPACE
-namespace QtPrivate {
-
-//
-// Define QIsUnsignedEnum, QIsSignedEnum -
-// std::is_signed, std::is_unsigned does not work for enum's
-//
-
-// a metafunction to invert an integral_constant:
-template <typename T>
-struct not_
- : std::integral_constant<bool, !T::value> {};
-
-// Checks whether a type is unsigned (T must be convertible to unsigned int):
-template <typename T>
-struct QIsUnsignedEnum
- : std::integral_constant<bool, (T(0) < T(-1))> {};
-
-// Checks whether a type is signed (T must be convertible to int):
-template <typename T>
-struct QIsSignedEnum
- : not_< QIsUnsignedEnum<T> > {};
-
-Q_STATIC_ASSERT(( QIsUnsignedEnum<quint8>::value));
-Q_STATIC_ASSERT((!QIsUnsignedEnum<qint8>::value));
-
-Q_STATIC_ASSERT((!QIsSignedEnum<quint8>::value));
-Q_STATIC_ASSERT(( QIsSignedEnum<qint8>::value));
-
-Q_STATIC_ASSERT(( QIsUnsignedEnum<quint16>::value));
-Q_STATIC_ASSERT((!QIsUnsignedEnum<qint16>::value));
-
-Q_STATIC_ASSERT((!QIsSignedEnum<quint16>::value));
-Q_STATIC_ASSERT(( QIsSignedEnum<qint16>::value));
-
-Q_STATIC_ASSERT(( QIsUnsignedEnum<quint32>::value));
-Q_STATIC_ASSERT((!QIsUnsignedEnum<qint32>::value));
-
-Q_STATIC_ASSERT((!QIsSignedEnum<quint32>::value));
-Q_STATIC_ASSERT(( QIsSignedEnum<qint32>::value));
-
-Q_STATIC_ASSERT(( QIsUnsignedEnum<quint64>::value));
-Q_STATIC_ASSERT((!QIsUnsignedEnum<qint64>::value));
-
-Q_STATIC_ASSERT((!QIsSignedEnum<quint64>::value));
-Q_STATIC_ASSERT(( QIsSignedEnum<qint64>::value));
-
-} // namespace QtPrivate
-
QT_END_NAMESPACE
+
#endif // QTYPETRAITS_H
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index a554a3b07e..c16825a033 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -69,8 +69,8 @@ public:
Q_DECL_CONSTEXPR inline QUrlTwoFlags(E1 f) : i(f) {}
Q_DECL_CONSTEXPR inline QUrlTwoFlags(E2 f) : i(f) {}
Q_DECL_CONSTEXPR inline QUrlTwoFlags(QFlag f) : i(f) {}
- Q_DECL_CONSTEXPR inline QUrlTwoFlags(QFlags<E1> f) : i(f.operator int()) {}
- Q_DECL_CONSTEXPR inline QUrlTwoFlags(QFlags<E2> f) : i(f.operator int()) {}
+ Q_DECL_CONSTEXPR inline QUrlTwoFlags(QFlags<E1> f) : i(f.operator typename QFlags<E1>::Int()) {}
+ Q_DECL_CONSTEXPR inline QUrlTwoFlags(QFlags<E2> f) : i(f.operator typename QFlags<E2>::Int()) {}
Q_DECL_CONSTEXPR inline QUrlTwoFlags(Zero = 0) : i(0) {}
inline QUrlTwoFlags &operator&=(int mask) { i &= mask; return *this; }
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 7fdf107383..3faa8e1441 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -2044,7 +2044,7 @@ Qt::DropActions QAbstractItemModel::supportedDropActions() const
Qt::DropActions QAbstractItemModel::supportedDragActions() const
{
Q_D(const QAbstractItemModel);
- if (d->supportedDragActions != -1)
+ if (d->supportedDragActions != Qt::IgnoreAction)
return d->supportedDragActions;
return supportedDropActions();
}
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index f27fde6b8d..fb86d0222e 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1027,7 +1027,7 @@ int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName,
normalizedTypeName.size());
int previousSize = 0;
- int previousFlags = 0;
+ QMetaType::TypeFlags::Int previousFlags = 0;
if (idx == UnknownType) {
QWriteLocker locker(customTypesLock());
int posInVector = -1;
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index dd0bce2645..6f1334d082 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -129,7 +129,7 @@ public:
QMetaType::Constructor constructor;
QMetaType::Destructor destructor;
int size;
- quint32 flags; // same as QMetaType::TypeFlags
+ QMetaType::TypeFlags::Int flags;
const QMetaObject *metaObject;
};
diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp
index 688226551d..27aa8db33a 100644
--- a/src/gui/opengl/qopengltexturecache.cpp
+++ b/src/gui/opengl/qopengltexturecache.cpp
@@ -371,7 +371,7 @@ static void freeTexture(QOpenGLFunctions *funcs, GLuint id)
funcs->glDeleteTextures(1, &id);
}
-QOpenGLCachedTexture::QOpenGLCachedTexture(GLuint id, int options, QOpenGLContext *context) : m_options(options)
+QOpenGLCachedTexture::QOpenGLCachedTexture(GLuint id, QOpenGLTextureCache::BindOptions options, QOpenGLContext *context) : m_options(options)
{
m_resource = new QOpenGLSharedResourceGuard(context, id, freeTexture);
}
diff --git a/src/gui/opengl/qopengltexturecache_p.h b/src/gui/opengl/qopengltexturecache_p.h
index c68b068739..4a438c8d95 100644
--- a/src/gui/opengl/qopengltexturecache_p.h
+++ b/src/gui/opengl/qopengltexturecache_p.h
@@ -60,19 +60,7 @@
QT_BEGIN_NAMESPACE
-class QOpenGLCachedTexture
-{
-public:
- QOpenGLCachedTexture(GLuint id, int options, QOpenGLContext *context);
- ~QOpenGLCachedTexture() { m_resource->free(); }
-
- GLuint id() const { return m_resource->id(); }
- int options() const { return m_options; }
-
-private:
- QOpenGLSharedResourceGuard *m_resource;
- int m_options;
-};
+class QOpenGLCachedTexture;
class Q_GUI_EXPORT QOpenGLTextureCache : public QOpenGLSharedResource
{
@@ -106,6 +94,20 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLTextureCache::BindOptions)
+class QOpenGLCachedTexture
+{
+public:
+ QOpenGLCachedTexture(GLuint id, QOpenGLTextureCache::BindOptions options, QOpenGLContext *context);
+ ~QOpenGLCachedTexture() { m_resource->free(); }
+
+ GLuint id() const { return m_resource->id(); }
+ QOpenGLTextureCache::BindOptions options() const { return m_options; }
+
+private:
+ QOpenGLSharedResourceGuard *m_resource;
+ QOpenGLTextureCache::BindOptions m_options;
+};
+
QT_END_NAMESPACE
#endif
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 3e15b6977a..7295cc36f6 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -957,8 +957,8 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event
// Sent event if the state changed (that is, it is not triggered by
// QWidget::setWindowState(), which also sends an event to the widget).
- if (widgetState != int(m_widget->data->window_state)) {
- m_widget->data->window_state = widgetState;
+ if (widgetState != Qt::WindowStates::Int(m_widget->data->window_state)) {
+ m_widget->data->window_state = uint(widgetState);
QWindowStateChangeEvent widgetEvent(eventState);
QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);
}
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 74e4d53dca..70af751fd3 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -2417,7 +2417,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
int oldMin = styleObject->property("_q_stylemin").toInt();
int oldMax = styleObject->property("_q_stylemax").toInt();
QRect oldRect = styleObject->property("_q_stylerect").toRect();
- int oldState = styleObject->property("_q_stylestate").toInt();
+ QStyle::State oldState = static_cast<QStyle::State>(styleObject->property("_q_stylestate").value<QStyle::State::Int>());
uint oldActiveControls = styleObject->property("_q_stylecontrols").toUInt();
// a scrollbar is transient when the the scrollbar itself and
@@ -2440,7 +2440,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
styleObject->setProperty("_q_stylemin", scrollBar->minimum);
styleObject->setProperty("_q_stylemax", scrollBar->maximum);
styleObject->setProperty("_q_stylerect", scrollBar->rect);
- styleObject->setProperty("_q_stylestate", static_cast<int>(scrollBar->state));
+ styleObject->setProperty("_q_stylestate", static_cast<QStyle::State::Int>(scrollBar->state));
styleObject->setProperty("_q_stylecontrols", static_cast<uint>(scrollBar->activeSubControls));
#ifndef QT_NO_ANIMATION
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 272877130b..ee257c7310 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -5284,7 +5284,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
int oldMin = styleObject->property("_q_stylemin").toInt();
int oldMax = styleObject->property("_q_stylemax").toInt();
QRect oldRect = styleObject->property("_q_stylerect").toRect();
- int oldState = styleObject->property("_q_stylestate").toInt();
+ QStyle::State oldState = static_cast<QStyle::State>(styleObject->property("_q_stylestate").value<QStyle::State::Int>());
uint oldActiveControls = styleObject->property("_q_stylecontrols").toUInt();
// a scrollbar is transient when the scrollbar itself and
@@ -5307,7 +5307,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
styleObject->setProperty("_q_stylemin", slider->minimum);
styleObject->setProperty("_q_stylemax", slider->maximum);
styleObject->setProperty("_q_stylerect", slider->rect);
- styleObject->setProperty("_q_stylestate", static_cast<int>(slider->state));
+ styleObject->setProperty("_q_stylestate", static_cast<QStyle::State::Int>(slider->state));
styleObject->setProperty("_q_stylecontrols", static_cast<uint>(slider->activeSubControls));
QScrollbarStyleAnimation *anim = qobject_cast<QScrollbarStyleAnimation *>(d->animation(styleObject));
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp
index 634d9a2df3..d70b099fe3 100644
--- a/tests/auto/corelib/global/qflags/tst_qflags.cpp
+++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp
@@ -134,11 +134,11 @@ void tst_QFlags::signedness()
// underlying type is implementation-defined, we need to allow for
// a different signedness, so we only check that the relative
// signedness of the types matches:
- Q_STATIC_ASSERT((QtPrivate::QIsUnsignedEnum<Qt::MouseButton>::value ==
- QtPrivate::QIsUnsignedEnum<Qt::MouseButtons::Int>::value));
+ Q_STATIC_ASSERT((std::is_unsigned<typename std::underlying_type<Qt::MouseButton>::type>::value ==
+ std::is_unsigned<Qt::MouseButtons::Int>::value));
- Q_STATIC_ASSERT((QtPrivate::QIsSignedEnum<Qt::AlignmentFlag>::value ==
- QtPrivate::QIsSignedEnum<Qt::Alignment::Int>::value));
+ Q_STATIC_ASSERT((std::is_signed<typename std::underlying_type<Qt::AlignmentFlag>::type>::value ==
+ std::is_signed<Qt::Alignment::Int>::value));
}
#if defined(Q_COMPILER_CLASS_ENUM)
diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp
index 3c74592528..4da00bda4d 100644
--- a/tests/auto/other/modeltest/modeltest.cpp
+++ b/tests/auto/other/modeltest/modeltest.cpp
@@ -438,7 +438,7 @@ void ModelTest::data()
// Check that the alignment is one we know about
QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole );
if ( textAlignmentVariant.isValid() ) {
- int alignment = textAlignmentVariant.toInt();
+ Qt::Alignment alignment = textAlignmentVariant.value<Qt::Alignment>();
QCOMPARE( alignment, ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );
}