Disable copying and assigning of QEvent
Polymorphic classes should not be copied. However, we do rely on event copying in our propagation logic. So, make the members protected, don't delete them, using a dedicated macro. This way, QMutable*Event classes can be used to make copies. Remove some last usage of copying of QInputMethod(Query)Events. Change-Id: Ia0a8ae4ca9de97dcd7788ca3c6ed930b6460c43a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
c149fd232d
commit
19f9b0d5f5
@ -302,10 +302,10 @@ QEvent::QEvent(Type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\fn QEvent::QEvent(const QEvent &other)
|
||||||
\internal
|
\internal
|
||||||
Copies the \a other event.
|
Copies the \a other event.
|
||||||
*/
|
*/
|
||||||
QEvent::QEvent(const QEvent &other) = default;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
@ -334,13 +334,13 @@ QEvent::QEvent(const QEvent &other) = default;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\fn QEvent &QEvent::operator=(const QEvent &other)
|
||||||
\internal
|
\internal
|
||||||
Attempts to copy the \a other event.
|
Attempts to copy the \a other event.
|
||||||
|
|
||||||
Copying events is a bad idea, yet some Qt 4 code does it (notably,
|
Copying events is a bad idea, yet some Qt 4 code does it (notably,
|
||||||
QApplication and the state machine).
|
QApplication and the state machine).
|
||||||
*/
|
*/
|
||||||
QEvent &QEvent::operator=(const QEvent &other) = default;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Destroys the event. If it was \l{QCoreApplication::postEvent()}{posted},
|
Destroys the event. If it was \l{QCoreApplication::postEvent()}{posted},
|
||||||
|
@ -46,12 +46,18 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#define Q_EVENT_DISABLE_COPY(Class) \
|
||||||
|
protected: \
|
||||||
|
Class(const Class &) = default; \
|
||||||
|
Class &operator=(const Class &other) = default
|
||||||
|
|
||||||
class QEventPrivate;
|
class QEventPrivate;
|
||||||
class Q_CORE_EXPORT QEvent // event base class
|
class Q_CORE_EXPORT QEvent // event base class
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
|
QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
|
||||||
|
|
||||||
|
Q_EVENT_DISABLE_COPY(QEvent);
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
/*
|
/*
|
||||||
@ -295,9 +301,7 @@ public:
|
|||||||
Q_ENUM(Type)
|
Q_ENUM(Type)
|
||||||
|
|
||||||
explicit QEvent(Type type);
|
explicit QEvent(Type type);
|
||||||
QEvent(const QEvent &other);
|
|
||||||
virtual ~QEvent();
|
virtual ~QEvent();
|
||||||
QEvent &operator=(const QEvent &other);
|
|
||||||
inline Type type() const { return static_cast<Type>(t); }
|
inline Type type() const { return static_cast<Type>(t); }
|
||||||
inline bool spontaneous() const { return m_spont; }
|
inline bool spontaneous() const { return m_spont; }
|
||||||
|
|
||||||
@ -359,6 +363,7 @@ private:
|
|||||||
|
|
||||||
class Q_CORE_EXPORT QTimerEvent : public QEvent
|
class Q_CORE_EXPORT QTimerEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QTimerEvent);
|
||||||
public:
|
public:
|
||||||
explicit QTimerEvent(int timerId);
|
explicit QTimerEvent(int timerId);
|
||||||
~QTimerEvent();
|
~QTimerEvent();
|
||||||
@ -374,6 +379,7 @@ class QObject;
|
|||||||
|
|
||||||
class Q_CORE_EXPORT QChildEvent : public QEvent
|
class Q_CORE_EXPORT QChildEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QChildEvent);
|
||||||
public:
|
public:
|
||||||
QChildEvent(Type type, QObject *child);
|
QChildEvent(Type type, QObject *child);
|
||||||
~QChildEvent();
|
~QChildEvent();
|
||||||
@ -390,6 +396,7 @@ protected:
|
|||||||
|
|
||||||
class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent
|
class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QDynamicPropertyChangeEvent);
|
||||||
public:
|
public:
|
||||||
explicit QDynamicPropertyChangeEvent(const QByteArray &name);
|
explicit QDynamicPropertyChangeEvent(const QByteArray &name);
|
||||||
~QDynamicPropertyChangeEvent();
|
~QDynamicPropertyChangeEvent();
|
||||||
@ -404,6 +411,7 @@ private:
|
|||||||
|
|
||||||
class Q_CORE_EXPORT QDeferredDeleteEvent : public QEvent
|
class Q_CORE_EXPORT QDeferredDeleteEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QDeferredDeleteEvent);
|
||||||
public:
|
public:
|
||||||
explicit QDeferredDeleteEvent();
|
explicit QDeferredDeleteEvent();
|
||||||
~QDeferredDeleteEvent();
|
~QDeferredDeleteEvent();
|
||||||
|
@ -65,6 +65,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
class QFutureCallOutEvent : public QEvent
|
class QFutureCallOutEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QFutureCallOutEvent);
|
||||||
public:
|
public:
|
||||||
enum CallOutType {
|
enum CallOutType {
|
||||||
Started,
|
Started,
|
||||||
|
@ -2267,16 +2267,6 @@ QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Att
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Constructs a copy of \a other.
|
|
||||||
*/
|
|
||||||
QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
|
|
||||||
: QEvent(QEvent::InputMethod), m_preedit(other.m_preedit), m_commit(other.m_commit),
|
|
||||||
m_attributes(other.m_attributes), m_replacementStart(other.m_replacementStart),
|
|
||||||
m_replacementLength(other.m_replacementLength)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QInputMethodEvent::~QInputMethodEvent()
|
QInputMethodEvent::~QInputMethodEvent()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ class QGesture;
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QInputEvent : public QEvent
|
class Q_GUI_EXPORT QInputEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QInputEvent);
|
||||||
public:
|
public:
|
||||||
explicit QInputEvent(Type type, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
explicit QInputEvent(Type type, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||||
~QInputEvent();
|
~QInputEvent();
|
||||||
@ -99,6 +100,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QPointerEvent : public QInputEvent
|
class Q_GUI_EXPORT QPointerEvent : public QInputEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QPointerEvent);
|
||||||
public:
|
public:
|
||||||
explicit QPointerEvent(Type type, const QPointingDevice *dev,
|
explicit QPointerEvent(Type type, const QPointingDevice *dev,
|
||||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier, const QList<QEventPoint> &points = {});
|
Qt::KeyboardModifiers modifiers = Qt::NoModifier, const QList<QEventPoint> &points = {});
|
||||||
@ -139,6 +141,7 @@ class Q_GUI_EXPORT QSinglePointEvent : public QPointerEvent
|
|||||||
Q_GADGET
|
Q_GADGET
|
||||||
Q_PROPERTY(QObject *exclusivePointGrabber READ exclusivePointGrabber WRITE setExclusivePointGrabber)
|
Q_PROPERTY(QObject *exclusivePointGrabber READ exclusivePointGrabber WRITE setExclusivePointGrabber)
|
||||||
|
|
||||||
|
Q_EVENT_DISABLE_COPY(QSinglePointEvent);
|
||||||
public:
|
public:
|
||||||
inline Qt::MouseButton button() const { return m_button; }
|
inline Qt::MouseButton button() const { return m_button; }
|
||||||
inline Qt::MouseButtons buttons() const { return m_mouseState; }
|
inline Qt::MouseButtons buttons() const { return m_mouseState; }
|
||||||
@ -191,6 +194,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QEnterEvent : public QSinglePointEvent
|
class Q_GUI_EXPORT QEnterEvent : public QSinglePointEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QEnterEvent);
|
||||||
public:
|
public:
|
||||||
QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
|
QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
|
||||||
const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
|
const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
|
||||||
@ -224,6 +228,7 @@ public:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QMouseEvent : public QSinglePointEvent
|
class Q_GUI_EXPORT QMouseEvent : public QSinglePointEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QMouseEvent);
|
||||||
public:
|
public:
|
||||||
QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
|
QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||||
@ -273,6 +278,7 @@ public:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QHoverEvent : public QSinglePointEvent
|
class Q_GUI_EXPORT QHoverEvent : public QSinglePointEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QHoverEvent);
|
||||||
public:
|
public:
|
||||||
QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
|
QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
|
||||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier,
|
Qt::KeyboardModifiers modifiers = Qt::NoModifier,
|
||||||
@ -310,6 +316,8 @@ class Q_GUI_EXPORT QWheelEvent : public QSinglePointEvent
|
|||||||
Q_PROPERTY(QPoint angleDelta READ angleDelta)
|
Q_PROPERTY(QPoint angleDelta READ angleDelta)
|
||||||
Q_PROPERTY(Qt::ScrollPhase phase READ phase)
|
Q_PROPERTY(Qt::ScrollPhase phase READ phase)
|
||||||
Q_PROPERTY(bool inverted READ inverted)
|
Q_PROPERTY(bool inverted READ inverted)
|
||||||
|
|
||||||
|
Q_EVENT_DISABLE_COPY(QWheelEvent);
|
||||||
public:
|
public:
|
||||||
enum { DefaultDeltasPerStep = 120 };
|
enum { DefaultDeltasPerStep = 120 };
|
||||||
|
|
||||||
@ -343,6 +351,7 @@ protected:
|
|||||||
#if QT_CONFIG(tabletevent)
|
#if QT_CONFIG(tabletevent)
|
||||||
class Q_GUI_EXPORT QTabletEvent : public QSinglePointEvent
|
class Q_GUI_EXPORT QTabletEvent : public QSinglePointEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QTabletEvent);
|
||||||
public:
|
public:
|
||||||
QTabletEvent(Type t, const QPointingDevice *device,
|
QTabletEvent(Type t, const QPointingDevice *device,
|
||||||
const QPointF &pos, const QPointF &globalPos,
|
const QPointF &pos, const QPointF &globalPos,
|
||||||
@ -397,6 +406,7 @@ protected:
|
|||||||
#if QT_CONFIG(gestures)
|
#if QT_CONFIG(gestures)
|
||||||
class Q_GUI_EXPORT QNativeGestureEvent : public QSinglePointEvent
|
class Q_GUI_EXPORT QNativeGestureEvent : public QSinglePointEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QNativeGestureEvent);
|
||||||
public:
|
public:
|
||||||
QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, const QPointF &localPos, const QPointF &scenePos,
|
QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, const QPointF &localPos, const QPointF &scenePos,
|
||||||
const QPointF &globalPos, qreal value, quint64 sequenceId, quint64 intArgument);
|
const QPointF &globalPos, qreal value, quint64 sequenceId, quint64 intArgument);
|
||||||
@ -433,6 +443,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QKeyEvent : public QInputEvent
|
class Q_GUI_EXPORT QKeyEvent : public QInputEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QKeyEvent);
|
||||||
public:
|
public:
|
||||||
QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
|
QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
|
||||||
bool autorep = false, quint16 count = 1);
|
bool autorep = false, quint16 count = 1);
|
||||||
@ -481,6 +492,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QFocusEvent : public QEvent
|
class Q_GUI_EXPORT QFocusEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QFocusEvent);
|
||||||
public:
|
public:
|
||||||
explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
|
explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
|
||||||
~QFocusEvent();
|
~QFocusEvent();
|
||||||
@ -499,6 +511,7 @@ private:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QPaintEvent : public QEvent
|
class Q_GUI_EXPORT QPaintEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QPaintEvent);
|
||||||
public:
|
public:
|
||||||
explicit QPaintEvent(const QRegion& paintRegion);
|
explicit QPaintEvent(const QRegion& paintRegion);
|
||||||
explicit QPaintEvent(const QRect &paintRect);
|
explicit QPaintEvent(const QRect &paintRect);
|
||||||
@ -517,6 +530,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QMoveEvent : public QEvent
|
class Q_GUI_EXPORT QMoveEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QMoveEvent);
|
||||||
public:
|
public:
|
||||||
QMoveEvent(const QPoint &pos, const QPoint &oldPos);
|
QMoveEvent(const QPoint &pos, const QPoint &oldPos);
|
||||||
~QMoveEvent();
|
~QMoveEvent();
|
||||||
@ -532,6 +546,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QExposeEvent : public QEvent
|
class Q_GUI_EXPORT QExposeEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QExposeEvent);
|
||||||
public:
|
public:
|
||||||
explicit QExposeEvent(const QRegion &m_region);
|
explicit QExposeEvent(const QRegion &m_region);
|
||||||
~QExposeEvent();
|
~QExposeEvent();
|
||||||
@ -549,6 +564,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QPlatformSurfaceEvent : public QEvent
|
class Q_GUI_EXPORT QPlatformSurfaceEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QPlatformSurfaceEvent);
|
||||||
public:
|
public:
|
||||||
enum SurfaceEventType {
|
enum SurfaceEventType {
|
||||||
SurfaceCreated,
|
SurfaceCreated,
|
||||||
@ -568,6 +584,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QResizeEvent : public QEvent
|
class Q_GUI_EXPORT QResizeEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QResizeEvent);
|
||||||
public:
|
public:
|
||||||
QResizeEvent(const QSize &size, const QSize &oldSize);
|
QResizeEvent(const QSize &size, const QSize &oldSize);
|
||||||
~QResizeEvent();
|
~QResizeEvent();
|
||||||
@ -584,6 +601,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QCloseEvent : public QEvent
|
class Q_GUI_EXPORT QCloseEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QCloseEvent);
|
||||||
public:
|
public:
|
||||||
QCloseEvent();
|
QCloseEvent();
|
||||||
~QCloseEvent();
|
~QCloseEvent();
|
||||||
@ -592,6 +610,7 @@ public:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QIconDragEvent : public QEvent
|
class Q_GUI_EXPORT QIconDragEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QIconDragEvent);
|
||||||
public:
|
public:
|
||||||
QIconDragEvent();
|
QIconDragEvent();
|
||||||
~QIconDragEvent();
|
~QIconDragEvent();
|
||||||
@ -600,6 +619,7 @@ public:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QShowEvent : public QEvent
|
class Q_GUI_EXPORT QShowEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QShowEvent);
|
||||||
public:
|
public:
|
||||||
QShowEvent();
|
QShowEvent();
|
||||||
~QShowEvent();
|
~QShowEvent();
|
||||||
@ -608,6 +628,7 @@ public:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QHideEvent : public QEvent
|
class Q_GUI_EXPORT QHideEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QHideEvent);
|
||||||
public:
|
public:
|
||||||
QHideEvent();
|
QHideEvent();
|
||||||
~QHideEvent();
|
~QHideEvent();
|
||||||
@ -616,6 +637,7 @@ public:
|
|||||||
#ifndef QT_NO_CONTEXTMENU
|
#ifndef QT_NO_CONTEXTMENU
|
||||||
class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
|
class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QContextMenuEvent);
|
||||||
public:
|
public:
|
||||||
enum Reason { Mouse, Keyboard, Other };
|
enum Reason { Mouse, Keyboard, Other };
|
||||||
|
|
||||||
@ -646,6 +668,7 @@ protected:
|
|||||||
#ifndef QT_NO_INPUTMETHOD
|
#ifndef QT_NO_INPUTMETHOD
|
||||||
class Q_GUI_EXPORT QInputMethodEvent : public QEvent
|
class Q_GUI_EXPORT QInputMethodEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QInputMethodEvent);
|
||||||
public:
|
public:
|
||||||
enum AttributeType {
|
enum AttributeType {
|
||||||
TextFormat,
|
TextFormat,
|
||||||
@ -678,8 +701,6 @@ public:
|
|||||||
inline int replacementStart() const { return m_replacementStart; }
|
inline int replacementStart() const { return m_replacementStart; }
|
||||||
inline int replacementLength() const { return m_replacementLength; }
|
inline int replacementLength() const { return m_replacementLength; }
|
||||||
|
|
||||||
QInputMethodEvent(const QInputMethodEvent &other);
|
|
||||||
|
|
||||||
inline friend bool operator==(const QInputMethodEvent::Attribute &lhs,
|
inline friend bool operator==(const QInputMethodEvent::Attribute &lhs,
|
||||||
const QInputMethodEvent::Attribute &rhs)
|
const QInputMethodEvent::Attribute &rhs)
|
||||||
{
|
{
|
||||||
@ -704,6 +725,7 @@ Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_MOVABLE_TYPE);
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent
|
class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QInputMethodQueryEvent);
|
||||||
public:
|
public:
|
||||||
explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries);
|
explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries);
|
||||||
~QInputMethodQueryEvent();
|
~QInputMethodQueryEvent();
|
||||||
@ -733,6 +755,7 @@ class QMimeData;
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QDropEvent : public QEvent
|
class Q_GUI_EXPORT QDropEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QDropEvent);
|
||||||
public:
|
public:
|
||||||
QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
|
QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
|
||||||
@ -779,6 +802,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
|
class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QDragMoveEvent);
|
||||||
public:
|
public:
|
||||||
QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
|
QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
|
||||||
@ -801,6 +825,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
|
class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QDragEnterEvent);
|
||||||
public:
|
public:
|
||||||
QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
|
QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
|
||||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
|
||||||
@ -810,6 +835,7 @@ public:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
|
class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QDragLeaveEvent);
|
||||||
public:
|
public:
|
||||||
QDragLeaveEvent();
|
QDragLeaveEvent();
|
||||||
~QDragLeaveEvent();
|
~QDragLeaveEvent();
|
||||||
@ -819,6 +845,7 @@ public:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QHelpEvent : public QEvent
|
class Q_GUI_EXPORT QHelpEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QHelpEvent);
|
||||||
public:
|
public:
|
||||||
QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
|
QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
|
||||||
~QHelpEvent();
|
~QHelpEvent();
|
||||||
@ -841,6 +868,7 @@ private:
|
|||||||
#ifndef QT_NO_STATUSTIP
|
#ifndef QT_NO_STATUSTIP
|
||||||
class Q_GUI_EXPORT QStatusTipEvent : public QEvent
|
class Q_GUI_EXPORT QStatusTipEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QStatusTipEvent);
|
||||||
public:
|
public:
|
||||||
explicit QStatusTipEvent(const QString &tip);
|
explicit QStatusTipEvent(const QString &tip);
|
||||||
~QStatusTipEvent();
|
~QStatusTipEvent();
|
||||||
@ -856,6 +884,7 @@ private:
|
|||||||
#if QT_CONFIG(whatsthis)
|
#if QT_CONFIG(whatsthis)
|
||||||
class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
|
class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QWhatsThisClickedEvent);
|
||||||
public:
|
public:
|
||||||
explicit QWhatsThisClickedEvent(const QString &href);
|
explicit QWhatsThisClickedEvent(const QString &href);
|
||||||
~QWhatsThisClickedEvent();
|
~QWhatsThisClickedEvent();
|
||||||
@ -871,6 +900,7 @@ private:
|
|||||||
#if QT_CONFIG(action)
|
#if QT_CONFIG(action)
|
||||||
class Q_GUI_EXPORT QActionEvent : public QEvent
|
class Q_GUI_EXPORT QActionEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QActionEvent);
|
||||||
public:
|
public:
|
||||||
QActionEvent(int type, QAction *action, QAction *before = nullptr);
|
QActionEvent(int type, QAction *action, QAction *before = nullptr);
|
||||||
~QActionEvent();
|
~QActionEvent();
|
||||||
@ -887,6 +917,7 @@ private:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QFileOpenEvent : public QEvent
|
class Q_GUI_EXPORT QFileOpenEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QFileOpenEvent);
|
||||||
public:
|
public:
|
||||||
explicit QFileOpenEvent(const QString &file);
|
explicit QFileOpenEvent(const QString &file);
|
||||||
explicit QFileOpenEvent(const QUrl &url);
|
explicit QFileOpenEvent(const QUrl &url);
|
||||||
@ -905,6 +936,7 @@ private:
|
|||||||
#ifndef QT_NO_TOOLBAR
|
#ifndef QT_NO_TOOLBAR
|
||||||
class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
|
class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QToolBarChangeEvent);
|
||||||
public:
|
public:
|
||||||
explicit QToolBarChangeEvent(bool t);
|
explicit QToolBarChangeEvent(bool t);
|
||||||
~QToolBarChangeEvent();
|
~QToolBarChangeEvent();
|
||||||
@ -920,6 +952,7 @@ private:
|
|||||||
#if QT_CONFIG(shortcut)
|
#if QT_CONFIG(shortcut)
|
||||||
class Q_GUI_EXPORT QShortcutEvent : public QEvent
|
class Q_GUI_EXPORT QShortcutEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QShortcutEvent);
|
||||||
public:
|
public:
|
||||||
QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
|
QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
|
||||||
~QShortcutEvent();
|
~QShortcutEvent();
|
||||||
@ -938,6 +971,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
|
class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QWindowStateChangeEvent);
|
||||||
public:
|
public:
|
||||||
explicit QWindowStateChangeEvent(Qt::WindowStates oldState, bool isOverride = false);
|
explicit QWindowStateChangeEvent(Qt::WindowStates oldState, bool isOverride = false);
|
||||||
~QWindowStateChangeEvent();
|
~QWindowStateChangeEvent();
|
||||||
@ -958,6 +992,7 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QTouchEvent : public QPointerEvent
|
class Q_GUI_EXPORT QTouchEvent : public QPointerEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QTouchEvent);
|
||||||
public:
|
public:
|
||||||
using TouchPoint = QEventPoint; // source compat
|
using TouchPoint = QEventPoint; // source compat
|
||||||
|
|
||||||
@ -995,6 +1030,7 @@ protected:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
|
class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QScrollPrepareEvent);
|
||||||
public:
|
public:
|
||||||
explicit QScrollPrepareEvent(const QPointF &startPos);
|
explicit QScrollPrepareEvent(const QPointF &startPos);
|
||||||
~QScrollPrepareEvent();
|
~QScrollPrepareEvent();
|
||||||
@ -1021,6 +1057,7 @@ private:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QScrollEvent : public QEvent
|
class Q_GUI_EXPORT QScrollEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QScrollEvent);
|
||||||
public:
|
public:
|
||||||
enum ScrollState
|
enum ScrollState
|
||||||
{
|
{
|
||||||
@ -1046,6 +1083,7 @@ private:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent
|
class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QScreenOrientationChangeEvent);
|
||||||
public:
|
public:
|
||||||
QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation);
|
QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation);
|
||||||
~QScreenOrientationChangeEvent();
|
~QScreenOrientationChangeEvent();
|
||||||
@ -1062,6 +1100,7 @@ private:
|
|||||||
|
|
||||||
class Q_GUI_EXPORT QApplicationStateChangeEvent : public QEvent
|
class Q_GUI_EXPORT QApplicationStateChangeEvent : public QEvent
|
||||||
{
|
{
|
||||||
|
Q_EVENT_DISABLE_COPY(QApplicationStateChangeEvent);
|
||||||
public:
|
public:
|
||||||
explicit QApplicationStateChangeEvent(Qt::ApplicationState state);
|
explicit QApplicationStateChangeEvent(Qt::ApplicationState state);
|
||||||
|
|
||||||
|
@ -1453,12 +1453,11 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur
|
|||||||
else
|
else
|
||||||
m_composingCursor = -1;
|
m_composingCursor = -1;
|
||||||
|
|
||||||
QInputMethodEvent event;
|
|
||||||
if (focusObjectIsComposing()) {
|
if (focusObjectIsComposing()) {
|
||||||
QTextCharFormat underlined;
|
QTextCharFormat underlined;
|
||||||
underlined.setFontUnderline(true);
|
underlined.setFontUnderline(true);
|
||||||
|
|
||||||
event = QInputMethodEvent(m_composingText, {
|
QInputMethodEvent event(m_composingText, {
|
||||||
{ QInputMethodEvent::TextFormat, 0, int(m_composingText.length()), underlined },
|
{ QInputMethodEvent::TextFormat, 0, int(m_composingText.length()), underlined },
|
||||||
{ QInputMethodEvent::Cursor, m_composingCursor - m_composingTextStart, 1 }
|
{ QInputMethodEvent::Cursor, m_composingCursor - m_composingTextStart, 1 }
|
||||||
});
|
});
|
||||||
@ -1467,8 +1466,12 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur
|
|||||||
event.setCommitString({}, m_composingTextStart - effectiveAbsoluteCursorPos,
|
event.setCommitString({}, m_composingTextStart - effectiveAbsoluteCursorPos,
|
||||||
oldComposingTextLen);
|
oldComposingTextLen);
|
||||||
}
|
}
|
||||||
|
if (m_composingText.isEmpty())
|
||||||
|
clear();
|
||||||
|
|
||||||
|
QGuiApplication::sendEvent(m_focusObject, &event);
|
||||||
} else {
|
} else {
|
||||||
event = QInputMethodEvent({}, {});
|
QInputMethodEvent event({}, {});
|
||||||
|
|
||||||
if (focusObjectWasComposing) {
|
if (focusObjectWasComposing) {
|
||||||
event.setCommitString(m_composingText);
|
event.setCommitString(m_composingText);
|
||||||
@ -1477,13 +1480,12 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur
|
|||||||
m_composingTextStart - effectiveAbsoluteCursorPos,
|
m_composingTextStart - effectiveAbsoluteCursorPos,
|
||||||
oldComposingTextLen);
|
oldComposingTextLen);
|
||||||
}
|
}
|
||||||
|
if (m_composingText.isEmpty())
|
||||||
|
clear();
|
||||||
|
|
||||||
|
QGuiApplication::sendEvent(m_focusObject, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_composingText.isEmpty())
|
|
||||||
clear();
|
|
||||||
|
|
||||||
QGuiApplication::sendEvent(m_focusObject, &event);
|
|
||||||
|
|
||||||
if (!focusObjectIsComposing() && newCursorPosition != 1) {
|
if (!focusObjectIsComposing() && newCursorPosition != 1) {
|
||||||
// Move cursor using a separate event because if we have inserted or deleted a newline
|
// Move cursor using a separate event because if we have inserted or deleted a newline
|
||||||
// character, then we are now inside an another block
|
// character, then we are now inside an another block
|
||||||
@ -1491,7 +1493,7 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur
|
|||||||
const int newBlockPos = getBlockPosition(
|
const int newBlockPos = getBlockPosition(
|
||||||
focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImAbsolutePosition));
|
focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImAbsolutePosition));
|
||||||
|
|
||||||
event = QInputMethodEvent({}, {
|
QInputMethodEvent event({}, {
|
||||||
{ QInputMethodEvent::Selection, newAbsoluteCursorPos - newBlockPos, 0 }
|
{ QInputMethodEvent::Selection, newAbsoluteCursorPos - newBlockPos, 0 }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@
|
|||||||
m_inSelectionChange = NO;
|
m_inSelectionChange = NO;
|
||||||
m_inputContext = inputContext;
|
m_inputContext = inputContext;
|
||||||
|
|
||||||
m_configuredImeState = new QInputMethodQueryEvent(m_inputContext->imeState().currentState);
|
m_configuredImeState = static_cast<QInputMethodQueryEvent*>(m_inputContext->imeState().currentState.clone());
|
||||||
QVariantMap platformData = m_configuredImeState->value(Qt::ImPlatformData).toMap();
|
QVariantMap platformData = m_configuredImeState->value(Qt::ImPlatformData).toMap();
|
||||||
Qt::InputMethodHints hints = Qt::InputMethodHints(m_configuredImeState->value(Qt::ImHints).toUInt());
|
Qt::InputMethodHints hints = Qt::InputMethodHints(m_configuredImeState->value(Qt::ImHints).toUInt());
|
||||||
|
|
||||||
@ -828,20 +828,24 @@
|
|||||||
NSRange r = static_cast<QUITextRange*>(range).range;
|
NSRange r = static_cast<QUITextRange*>(range).range;
|
||||||
QList<QInputMethodEvent::Attribute> attrs;
|
QList<QInputMethodEvent::Attribute> attrs;
|
||||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.location, 0, 0);
|
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.location, 0, 0);
|
||||||
QInputMethodEvent e(m_markedText, attrs);
|
{
|
||||||
[self sendEventToFocusObject:e];
|
QInputMethodEvent e(m_markedText, attrs);
|
||||||
|
[self sendEventToFocusObject:e];
|
||||||
|
}
|
||||||
QRectF startRect = qApp->inputMethod()->cursorRectangle();
|
QRectF startRect = qApp->inputMethod()->cursorRectangle();
|
||||||
|
|
||||||
attrs = QList<QInputMethodEvent::Attribute>();
|
attrs = QList<QInputMethodEvent::Attribute>();
|
||||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.location + r.length, 0, 0);
|
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.location + r.length, 0, 0);
|
||||||
e = QInputMethodEvent(m_markedText, attrs);
|
{
|
||||||
[self sendEventToFocusObject:e];
|
QInputMethodEvent e(m_markedText, attrs);
|
||||||
|
[self sendEventToFocusObject:e];
|
||||||
|
}
|
||||||
QRectF endRect = qApp->inputMethod()->cursorRectangle();
|
QRectF endRect = qApp->inputMethod()->cursorRectangle();
|
||||||
|
|
||||||
if (cursorPos != int(r.location + r.length) || cursorPos != anchorPos) {
|
if (cursorPos != int(r.location + r.length) || cursorPos != anchorPos) {
|
||||||
attrs = QList<QInputMethodEvent::Attribute>();
|
attrs = QList<QInputMethodEvent::Attribute>();
|
||||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, qMin(cursorPos, anchorPos), qAbs(cursorPos - anchorPos), 0);
|
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, qMin(cursorPos, anchorPos), qAbs(cursorPos - anchorPos), 0);
|
||||||
e = QInputMethodEvent(m_markedText, attrs);
|
QInputMethodEvent e(m_markedText, attrs);
|
||||||
[self sendEventToFocusObject:e];
|
[self sendEventToFocusObject:e];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user