Qt 4.8
qcoreevent.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qcoreevent.h"
43 #include "qcoreapplication.h"
44 #include "qcoreapplication_p.h"
45 
46 #include "qmutex.h"
47 #include "qset.h"
48 
50 
290  : d(0), t(type), posted(false), spont(false), m_accept(true)
291 {}
292 
300 {
303 }
304 
305 
378 {
379 public:
382 };
383 Q_GLOBAL_STATIC(QEventUserEventRegistration, userEventRegistrationHelper)
384 
385 
398 int QEvent::registerEventType(int hint)
399 {
400  QEventUserEventRegistration *userEventRegistration
401  = userEventRegistrationHelper();
402  if (!userEventRegistration)
403  return -1;
404 
405  QMutexLocker locker(&userEventRegistration->mutex);
406 
407  // if the type hint hasn't been registered yet, take it
408  if (hint >= QEvent::User && hint <= QEvent::MaxUser && !userEventRegistration->set.contains(hint)) {
409  userEventRegistration->set.insert(hint);
410  return hint;
411  }
412 
413  // find a free event type, starting at MaxUser and decreasing
414  int id = QEvent::MaxUser;
415  while (userEventRegistration->set.contains(id) && id >= QEvent::User)
416  --id;
417  if (id >= QEvent::User) {
418  userEventRegistration->set.insert(id);
419  return id;
420  }
421  return -1;
422 }
423 
452  : QEvent(Timer), id(timerId)
453 {}
454 
458 {
459 }
460 
503  : QEvent(type), c(child)
504 {}
505 
509 {
510 }
511 
578 #ifdef QT3_SUPPORT
579 QCustomEvent::QCustomEvent(int type, void *data)
580  : QEvent(static_cast<Type>(type))
581 {
582  d = reinterpret_cast<QEventPrivate *>(data);
583 }
584 
587 QCustomEvent::~QCustomEvent()
588 {
589 }
590 #endif
591 
642  : QEvent(QEvent::DynamicPropertyChange), n(name)
643 {
644 }
645 
650 {
651 }
652 
double d
Definition: qnumeric_p.h:62
int type
Definition: qmetatype.cpp:239
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
QChildEvent(Type type, QObject *child)
Constructs a child event object of a particular type for the child.
Definition: qcoreevent.cpp:502
QDynamicPropertyChangeEvent(const QByteArray &name)
Constructs a dynamic property change event object with the property name set to name.
Definition: qcoreevent.cpp:641
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool contains(const T &value) const
Definition: qset.h:91
const char * name
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
const_iterator insert(const T &value)
Definition: qset.h:179
static const char * data(const QByteArray &arr)
QEvent(Type type)
Contructs an event object of type type.
Definition: qcoreevent.cpp:289
ushort posted
Definition: qcoreevent.h:319
QEventPrivate * d
Definition: qcoreevent.h:315
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
static int registerEventType(int hint=-1)
Registers and returns a custom event type.
Definition: qcoreevent.cpp:398
The Timer item triggers a handler at a specified interval.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
virtual ~QEvent()
Destroys the event.
Definition: qcoreevent.cpp:299
static void removePostedEvent(QEvent *)
Removes event from the queue of posted events, and emits a warning message if appropriate.
QTimerEvent(int timerId)
Constructs a timer event object with the timer identifier set to timerId.
Definition: qcoreevent.cpp:451