drop unused feature to register custom events

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-05 03:51:25 +03:00
parent e297f68e33
commit 6770624ef9
4 changed files with 2 additions and 125 deletions

View file

@ -22,8 +22,6 @@
#include "qcoreevent.h"
#include "qcoreapplication.h"
#include "qcoreapplication_p.h"
#include "qmutex.h"
#include "qstdcontainers_p.h"
QT_BEGIN_NAMESPACE
@ -185,12 +183,6 @@ QT_BEGIN_NAMESPACE
\value User User-defined event.
\value MaxUser Last user event ID.
For convenience, you can use the registerEventType() function to
register and reserve a custom event type for your
application. Doing so will allow you to avoid accidentally
re-using a custom event type already in use elsewhere in your
application.
\omitvalue GraphicsSceneLeave
\omitvalue AcceptDropsChange
\omitvalue Create
@ -206,7 +198,8 @@ QT_BEGIN_NAMESPACE
*/
QEvent::QEvent(Type type)
: t(type), posted(false), spont(false), m_accept(true), looplevel(0)
{}
{
}
/*!
Destroys the event. If it was \link
@ -277,44 +270,6 @@ QEvent::~QEvent()
The return value of this function is not defined for paint events.
*/
typedef QStdVector<int> QEventUserEventList;
Q_GLOBAL_STATIC(QMutex, qGlobalUserEventsMutex)
Q_GLOBAL_STATIC(QEventUserEventList, qGlobalUserEvents)
/*!
\since 4.4
\threadsafe
Registers and returns a custom event type. The \a hint provided
will be used if it is available, otherwise it will return a value
between QEvent::User and QEvent::MaxUser that has not yet been
registered. The \a hint is ignored if its value is not between
QEvent::User and QEvent::MaxUser.
*/
int QEvent::registerEventType(int hint)
{
QMutexLocker locker(qGlobalUserEventsMutex());
QEventUserEventList *userEventRegistration = qGlobalUserEvents();
if (!userEventRegistration)
return -1;
// if the type hint hasn't been registered yet, take it
if (hint >= QEvent::User && hint <= QEvent::MaxUser && !userEventRegistration->contains(hint)) {
userEventRegistration->append(hint);
return hint;
}
// find a free event type, starting at MaxUser and decreasing
int id = QEvent::MaxUser;
while (userEventRegistration->contains(id) && id >= QEvent::User)
--id;
if (id >= QEvent::User) {
userEventRegistration->append(id);
return id;
}
return -1;
}
/*!
\class QTimerEvent
\brief The QTimerEvent class contains parameters that describe a

View file

@ -194,8 +194,6 @@ public:
inline void accept() { m_accept = true; }
inline void ignore() { m_accept = false; }
static int registerEventType(int hint = -1);
protected:
Type t;

View file

@ -1,3 +0,0 @@
katie_test(tst_qevent
${CMAKE_CURRENT_SOURCE_DIR}/tst_qevent.cpp
)

View file

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the test suite of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtTest/QtTest>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qcoreevent.h>
//TESTED_CLASS=
//TESTED_FILES=
class tst_QEvent : public QObject
{
Q_OBJECT
public:
tst_QEvent();
~tst_QEvent();
private slots:
void registerEventType_data();
void registerEventType();
};
tst_QEvent::tst_QEvent()
{ }
tst_QEvent::~tst_QEvent()
{ }
void tst_QEvent::registerEventType_data()
{
QTest::addColumn<int>("hint");
QTest::addColumn<int>("expected");
// default argument
QTest::newRow("default") << -1 << int(QEvent::MaxUser);
// hint not valid
QTest::newRow("User-1") << int(QEvent::User - 1) << int(QEvent::MaxUser - 1);
// hint valid, but already taken
QTest::newRow("MaxUser-1") << int(QEvent::MaxUser - 1) << int(QEvent::MaxUser - 2);
// hint valid, but not taken
QTest::newRow("User + 1000") << int(QEvent::User + 1000) << int(QEvent::User + 1000);
}
void tst_QEvent::registerEventType()
{
QFETCH(int, hint);
QFETCH(int, expected);
QCOMPARE(QEvent::registerEventType(hint), expected);
}
QTEST_MAIN(tst_QEvent)
#include "moc_tst_qevent.cpp"