From 118b3d3f8415037a1afddc6b962bd809905527d5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 28 Jun 2011 12:17:34 +0200 Subject: Remove Qt3 support functionality from parts of QtCore Change-Id: I90f391e9bfc412087bd0401e28d2497571f81aa1 Reviewed-on: http://codereview.qt.nokia.com/825 Reviewed-by: Qt Sanity Bot Reviewed-by: Liang Qi --- src/corelib/kernel/qcoreapplication.cpp | 132 --------------------- src/corelib/kernel/qcoreapplication.h | 20 ---- src/corelib/kernel/qcoreevent.cpp | 59 --------- src/corelib/kernel/qcoreevent.h | 22 ---- src/corelib/kernel/qobject.cpp | 204 -------------------------------- src/corelib/kernel/qobject.h | 67 +---------- src/corelib/kernel/qobject_p.h | 12 -- 7 files changed, 3 insertions(+), 513 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index cc1b1812e5..5f11b10ec5 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -176,9 +176,6 @@ extern QString qAppFileName(); #endif int QCoreApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0 -#if defined(QT3_SUPPORT) -bool QCoreApplicationPrivate::useQt3Support = true; -#endif #if !defined(Q_OS_WIN) #ifdef Q_OS_MAC @@ -337,9 +334,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint in_exec(false), aboutToQuitEmitted(false) { app_compile_version = flags & 0xffffff; -#if defined(QT3_SUPPORT) - useQt3Support = !(flags & 0x01000000); -#endif static const char *const empty = ""; if (argc == 0 || argv == 0) { argc = 0; @@ -1370,20 +1364,6 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type ++data->postEventList.recursion; -#ifdef QT3_SUPPORT - if (event_type == QEvent::ChildInserted) { - if (receiver) { - // optimize sendPostedEvents(w, QEvent::ChildInserted) calls away - receiver->d_func()->sendPendingChildInsertedEvents(); - --data->postEventList.recursion; - return; - } - - // ChildInserted events are sent in response to *Request - event_type = QEvent::ChildInsertedRequest; - } -#endif - QMutexLocker locker(&data->postEventList.mutex); // by default, we assume that the event dispatcher can go to sleep after @@ -1534,11 +1514,6 @@ void QCoreApplication::removePostedEvents(QObject *receiver) void QCoreApplication::removePostedEvents(QObject *receiver, int eventType) { -#ifdef QT3_SUPPORT - if (eventType == QEvent::ChildInserted) - eventType = QEvent::ChildInsertedRequest; -#endif - QThreadData *data = receiver ? receiver->d_func()->threadData : QThreadData::current(); QMutexLocker locker(&data->postEventList.mutex); @@ -1561,10 +1536,6 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType) if ((!receiver || pe.receiver == receiver) && (pe.event && (eventType == 0 || pe.event->type() == eventType))) { --pe.receiver->d_func()->postedEvents; -#ifdef QT3_SUPPORT - if (pe.event->type() == QEvent::ChildInsertedRequest) - pe.receiver->d_func()->pendingChildInsertedEvents.clear(); -#endif pe.event->posted = false; events.append(pe.event); const_cast(pe).event = 0; @@ -2557,109 +2528,6 @@ bool QCoreApplication::hasPendingEvents() return false; } -#ifdef QT3_SUPPORT -/*! \fn void QCoreApplication::lock() - - In Qt 3, this function locked the Qt library mutex, allowing - non-GUI threads to perform basic printing operations using - QPainter. - - In Qt 4, this is no longer supported, since painting is only - supported from within a paint event handler. This function does - nothing. - - \sa QWidget::paintEvent() -*/ - -/*! \fn void QCoreApplication::unlock(bool wakeUpGui) - - In Qt 3, this function unlocked the Qt library mutex. The mutex - allowed non-GUI threads to perform basic printing operations - using QPainter. - - In Qt 4, this is no longer supported, since painting is only - supported from within a paint event handler. This function does - nothing. -*/ - -/*! \fn bool QCoreApplication::locked() - - This function does nothing. It is there to keep old code working. - It always returns false. - - See lock() for details. -*/ - -/*! \fn bool QCoreApplication::tryLock() - - This function does nothing. It is there to keep old code working. - It always returns false. - - See lock() for details. -*/ - -/*! \fn void QCoreApplication::processOneEvent() - \obsolete - - Waits for an event to occur, processes it, then returns. - - This function is useful for adapting Qt to situations where the - event processing must be grafted onto existing program loops. - - Using this function in new applications may be an indication of design - problems. - - \sa processEvents(), exec(), QTimer -*/ - -/*! \obsolete - - This function enters the main event loop (recursively). Do not call - it unless you really know what you are doing. -*/ -int QCoreApplication::enter_loop() -{ - if (!QCoreApplicationPrivate::checkInstance("enter_loop")) - return -1; - if (QThreadData::current() != self->d_func()->threadData) { - qWarning("QCoreApplication::enter_loop: Must be called from the main thread"); - return -1; - } - QEventLoop eventLoop; - int returnCode = eventLoop.exec(); - return returnCode; -} - -/*! \obsolete - - This function exits from a recursive call to the main event loop. - Do not call it unless you are an expert. -*/ -void QCoreApplication::exit_loop() -{ - if (!QCoreApplicationPrivate::checkInstance("exit_loop")) - return; - QThreadData *data = QThreadData::current(); - if (data != self->d_func()->threadData) { - qWarning("QCoreApplication::exit_loop: Must be called from the main thread"); - return; - } - if (!data->eventLoops.isEmpty()) - data->eventLoops.top()->exit(); -} - -/*! \obsolete - - Returns the current loop level. -*/ -int QCoreApplication::loopLevel() -{ - if (!QCoreApplicationPrivate::checkInstance("loopLevel")) - return -1; - return self->d_func()->threadData->eventLoops.size(); -} -#endif - /* \fn void QCoreApplication::watchUnixSignal(int signal, bool watch) \internal diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index d4356e3e36..adc70387cc 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -46,10 +46,6 @@ #include #include -#ifdef QT_INCLUDE_COMPAT -#include -#endif - #if defined(Q_WS_WIN) && !defined(tagMSG) typedef struct tagMSG MSG; #endif @@ -79,9 +75,6 @@ class Q_CORE_EXPORT QCoreApplication : public QObject Q_DECLARE_PRIVATE(QCoreApplication) public: enum { ApplicationFlags = QT_VERSION -#if !defined(QT3_SUPPORT) - | 0x01000000 -#endif }; #if defined(QT_BUILD_CORE_LIB) || defined(qdoc) @@ -164,19 +157,6 @@ public: static void flush(); -#if defined(QT3_SUPPORT) - inline QT3_SUPPORT void lock() {} - inline QT3_SUPPORT void unlock(bool = true) {} - inline QT3_SUPPORT bool locked() { return false; } - inline QT3_SUPPORT bool tryLock() { return false; } - - static inline QT3_SUPPORT void processOneEvent() - { processEvents(QEventLoop::WaitForMoreEvents); } - static QT3_SUPPORT int enter_loop(); - static QT3_SUPPORT void exit_loop(); - static QT3_SUPPORT int loopLevel(); -#endif - #if defined(Q_WS_WIN) virtual bool winEventFilter(MSG *message, long *result); #endif diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index fbc935ddde..a355b0ad1a 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -504,65 +504,6 @@ QChildEvent::~QChildEvent() false. */ -/*! - \class QCustomEvent - \brief The QCustomEvent class provides support for custom events. - - \compat - - QCustomEvent has a \c{void *} that can be used to store custom - data. - - In Qt 3, QObject::customEvent() took a QCustomEvent pointer. We - found out that this approach was unsatisfactory, because - there was often no safe way of deleting the data held in the - \c{void *}. - - In Qt 4, QObject::customEvent() takes a plain QEvent pointer. - You can add custom data by subclassing. - - \sa QObject::customEvent(), QCoreApplication::notify() -*/ - -/*! - \fn QCustomEvent::QCustomEvent(int type, void *data) - - Constructs a custom event object with the event \a type and a - pointer to \a data. The value of \a type must be at least as - large as QEvent::User. By default, the data pointer is set to 0. -*/ -#ifdef QT3_SUPPORT -QCustomEvent::QCustomEvent(int type, void *data) - : QEvent(static_cast(type)) -{ - d = reinterpret_cast(data); -} - -/*! \internal -*/ -QCustomEvent::~QCustomEvent() -{ -} -#endif -/*! - \fn void QCustomEvent::setData(void *data) - - \compat - - Sets the generic data pointer to \a data. - - \sa data() -*/ - -/*! - \fn void *QCustomEvent::data() const - - \compat - - Returns a pointer to the generic event data. - - \sa setData() -*/ /*! \fn bool QChildEvent::inserted() const diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 98a08e9628..d2b2d97839 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -89,9 +89,6 @@ public: Quit = 20, // request to quit application ParentChange = 21, // widget has been reparented ParentAboutToChange = 131, // sent just before the parent change is done -#ifdef QT3_SUPPORT - Reparent = ParentChange, -#endif ThreadChange = 22, // object has changed threads WindowActivate = 24, // window was activated WindowDeactivate = 25, // window was deactivated @@ -118,11 +115,6 @@ public: DragResponse = 64, // drag accepted/rejected ChildAdded = 68, // new child widget ChildPolished = 69, // polished child widget -#ifdef QT3_SUPPORT - ChildInsertedRequest = 67, // send ChildInserted compatibility events to receiver - ChildInserted = 70, // compatibility child inserted - LayoutHint = 72, // compatibility relayout request -#endif ChildRemoved = 71, // deleted child widget ShowWindowRequest = 73, // widget's window should be mapped PolishRequest = 74, // widget should be polished @@ -357,26 +349,12 @@ public: ~QChildEvent(); QObject *child() const { return c; } bool added() const { return type() == ChildAdded; } -#ifdef QT3_SUPPORT - QT3_SUPPORT bool inserted() const { return type() == ChildInserted; } -#endif bool polished() const { return type() == ChildPolished; } bool removed() const { return type() == ChildRemoved; } protected: QObject *c; }; -#ifdef QT3_SUPPORT -class Q_CORE_EXPORT QCustomEvent : public QEvent -{ -public: - QT3_SUPPORT_CONSTRUCTOR QCustomEvent(int type, void *data = 0); - ~QCustomEvent(); - QT3_SUPPORT void *data() const { return d; } - QT3_SUPPORT void setData(void* aData) { d = reinterpret_cast(aData); } -}; -#endif - class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent { public: diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 88618c3c87..cce458e0f8 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -202,22 +202,6 @@ void QObjectPrivate::resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int dele } #endif -#ifdef QT3_SUPPORT -void QObjectPrivate::sendPendingChildInsertedEvents() -{ - Q_Q(QObject); - for (int i = 0; i < pendingChildInsertedEvents.size(); ++i) { - QObject *c = pendingChildInsertedEvents.at(i).data(); - if (!c || c->parent() != q) - continue; - QChildEvent childEvent(QEvent::ChildInserted, c); - QCoreApplication::sendEvent(q, &childEvent); - } - pendingChildInsertedEvents.clear(); -} - -#endif - /*!\internal For a given metaobject, compute the signal offset, and the method offset (including signals) @@ -736,29 +720,6 @@ QObject::QObject(QObject *parent) qt_addObject(this); } -#ifdef QT3_SUPPORT -/*! - \overload QObject() - \obsolete - - Creates a new QObject with the given \a parent and object \a name. - */ -QObject::QObject(QObject *parent, const char *name) - : d_ptr(new QObjectPrivate) -{ - Q_D(QObject); - qt_addObject(d_ptr->q_ptr = this); - d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current(); - d->threadData->ref(); - if (parent) { - if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) - parent = 0; - setParent(parent); - } - setObjectName(QString::fromAscii(name)); -} -#endif - /*! \internal */ QObject::QObject(QObjectPrivate &dd, QObject *parent) @@ -1078,56 +1039,6 @@ void QObject::setObjectName(const QString &name) d->declarativeData->objectNameChanged(d->declarativeData, this); } - -#ifdef QT3_SUPPORT -/*! \internal - QObject::child is compat but needs to call itself recursively, - that's why we need this helper. -*/ -static QObject *qChildHelper(const char *objName, const char *inheritsClass, - bool recursiveSearch, const QObjectList &children) -{ - if (children.isEmpty()) - return 0; - - bool onlyWidgets = (inheritsClass && qstrcmp(inheritsClass, "QWidget") == 0); - const QLatin1String oName(objName); - for (int i = 0; i < children.size(); ++i) { - QObject *obj = children.at(i); - if (onlyWidgets) { - if (obj->isWidgetType() && (!objName || obj->objectName() == oName)) - return obj; - } else if ((!inheritsClass || obj->inherits(inheritsClass)) - && (!objName || obj->objectName() == oName)) - return obj; - if (recursiveSearch && (obj = qChildHelper(objName, inheritsClass, - recursiveSearch, obj->children()))) - return obj; - } - return 0; -} - - -/*! - Searches the children and optionally grandchildren of this object, - and returns a child that is called \a objName that inherits \a - inheritsClass. If \a inheritsClass is 0 (the default), any class - matches. - - If \a recursiveSearch is true (the default), child() performs a - depth-first search of the object's children. - - If there is no such object, this function returns 0. If there are - more than one, the first one found is returned. -*/ -QObject* QObject::child(const char *objName, const char *inheritsClass, - bool recursiveSearch) const -{ - Q_D(const QObject); - return qChildHelper(objName, inheritsClass, recursiveSearch, d->children); -} -#endif - /*! \fn bool QObject::isWidgetType() const @@ -1156,17 +1067,8 @@ bool QObject::event(QEvent *e) timerEvent((QTimerEvent*)e); break; -#ifdef QT3_SUPPORT - case QEvent::ChildInsertedRequest: - d_func()->sendPendingChildInsertedEvents(); - break; -#endif - case QEvent::ChildAdded: case QEvent::ChildPolished: -#ifdef QT3_SUPPORT - case QEvent::ChildInserted: -#endif case QEvent::ChildRemoved: childEvent((QChildEvent*)e); break; @@ -1635,102 +1537,6 @@ void QObject::killTimer(int id) \sa findChild(), findChildren(), parent(), setParent() */ -#ifdef QT3_SUPPORT -static void objSearch(QObjectList &result, - const QObjectList &list, - const char *inheritsClass, - bool onlyWidgets, - const char *objName, - QRegExp *rx, - bool recurse) -{ - for (int i = 0; i < list.size(); ++i) { - QObject *obj = list.at(i); - if (!obj) - continue; - bool ok = true; - if (onlyWidgets) - ok = obj->isWidgetType(); - else if (inheritsClass && !obj->inherits(inheritsClass)) - ok = false; - if (ok) { - if (objName) - ok = (obj->objectName() == QLatin1String(objName)); -#ifndef QT_NO_REGEXP - else if (rx) - ok = (rx->indexIn(obj->objectName()) != -1); -#endif - } - if (ok) // match! - result.append(obj); - if (recurse) { - QObjectList clist = obj->children(); - if (!clist.isEmpty()) - objSearch(result, clist, inheritsClass, - onlyWidgets, objName, rx, recurse); - } - } -} - -/*! - \internal - - Searches the children and optionally grandchildren of this object, - and returns a list of those objects that are named or that match - \a objName and inherit \a inheritsClass. If \a inheritsClass is 0 - (the default), all classes match. If \a objName is 0 (the - default), all object names match. - - If \a regexpMatch is true (the default), \a objName is a regular - expression that the objects's names must match. The syntax is that - of a QRegExp. If \a regexpMatch is false, \a objName is a string - and object names must match it exactly. - - Note that \a inheritsClass uses single inheritance from QObject, - the way inherits() does. According to inherits(), QWidget - inherits QObject but not QPaintDevice. This does not quite match - reality, but is the best that can be done on the wide variety of - compilers Qt supports. - - Finally, if \a recursiveSearch is true (the default), queryList() - searches \e{n}th-generation as well as first-generation children. - - If all this seems a bit complex for your needs, the simpler - child() function may be what you want. - - This somewhat contrived example disables all the buttons in this - window: - - \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 9 - - \warning Delete the list as soon you have finished using it. The - list contains pointers that may become invalid at almost any time - without notice (as soon as the user closes a window you may have - dangling pointers, for example). - - \sa child() children(), parent(), inherits(), objectName(), QRegExp -*/ - -QObjectList QObject::queryList(const char *inheritsClass, - const char *objName, - bool regexpMatch, - bool recursiveSearch) const -{ - Q_D(const QObject); - QObjectList list; - bool onlyWidgets = (inheritsClass && qstrcmp(inheritsClass, "QWidget") == 0); -#ifndef QT_NO_REGEXP - if (regexpMatch && objName) { // regexp matching - QRegExp rx(QString::fromLatin1(objName)); - objSearch(list, d->children, inheritsClass, onlyWidgets, 0, &rx, recursiveSearch); - } else -#endif - { - objSearch(list, d->children, inheritsClass, onlyWidgets, objName, 0, recursiveSearch); - } - return list; -} -#endif /*! \fn T *QObject::findChild(const QString &name) const @@ -1948,16 +1754,6 @@ void QObjectPrivate::setParent_helper(QObject *o) if (!isWidget) { QChildEvent e(QEvent::ChildAdded, q); QCoreApplication::sendEvent(parent, &e); -#ifdef QT3_SUPPORT - if (QCoreApplicationPrivate::useQt3Support) { - if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) { - QCoreApplication::postEvent(parent, - new QEvent(QEvent::ChildInsertedRequest), - Qt::HighEventPriority); - } - parent->d_func()->pendingChildInsertedEvents.append(q); - } -#endif } } } diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 15d81b949a..0e28fa7e26 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -186,14 +186,6 @@ public: } #endif -#ifdef QT3_SUPPORT - QT3_SUPPORT QObject *child(const char *objName, const char *inheritsClass = 0, - bool recursiveSearch = true) const; - QT3_SUPPORT QObjectList queryList(const char *inheritsClass = 0, - const char *objName = 0, - bool regexpMatch = true, - bool recursiveSearch = true) const; -#endif inline const QObjectList &children() const { return d_ptr->children; } void setParent(QObject *); @@ -202,44 +194,14 @@ public: static bool connect(const QObject *sender, const char *signal, - const QObject *receiver, const char *member, Qt::ConnectionType = -#ifdef qdoc - Qt::AutoConnection -#else -#ifdef QT3_SUPPORT - Qt::AutoCompatConnection -#else - Qt::AutoConnection -#endif -#endif - ); + const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection); static bool connect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, - Qt::ConnectionType type = -#ifdef qdoc - Qt::AutoConnection -#else -#ifdef QT3_SUPPORT - Qt::AutoCompatConnection -#else - Qt::AutoConnection -#endif -#endif - ); + Qt::ConnectionType type = Qt::AutoConnection); inline bool connect(const QObject *sender, const char *signal, - const char *member, Qt::ConnectionType type = -#ifdef qdoc - Qt::AutoConnection -#else -#ifdef QT3_SUPPORT - Qt::AutoCompatConnection -#else - Qt::AutoConnection -#endif -#endif - ) const; + const char *member, Qt::ConnectionType type = Qt::AutoConnection) const; static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member); @@ -290,29 +252,6 @@ protected: virtual void connectNotify(const char *signal); virtual void disconnectNotify(const char *signal); -#ifdef QT3_SUPPORT -public: - QT3_SUPPORT_CONSTRUCTOR QObject(QObject *parent, const char *name); - inline QT3_SUPPORT void insertChild(QObject *o) - { if (o) o->setParent(this); } - inline QT3_SUPPORT void removeChild(QObject *o) - { if (o) o->setParent(0); } - inline QT3_SUPPORT bool isA(const char *classname) const - { return qstrcmp(classname, metaObject()->className()) == 0; } - inline QT3_SUPPORT const char *className() const { return metaObject()->className(); } - inline QT3_SUPPORT const char *name() const { return objectName().latin1_helper(); } - inline QT3_SUPPORT const char *name(const char *defaultName) const - { QString s = objectName(); return s.isEmpty()?defaultName:s.latin1_helper(); } - inline QT3_SUPPORT void setName(const char *aName) { setObjectName(QLatin1String(aName)); } -protected: - inline QT3_SUPPORT bool checkConnectArgs(const char *signal, - const QObject *, - const char *member) - { return QMetaObject::checkConnectArgs(signal, member); } - static inline QT3_SUPPORT QByteArray normalizeSignalSlot(const char *signalSlot) - { return QMetaObject::normalizedSignature(signalSlot); } -#endif - protected: QObject(QObjectPrivate &dd, QObject *parent = 0); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 3968a31bb8..9151e8eb7b 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -157,10 +157,6 @@ public: void addConnection(int signal, Connection *c); void cleanConnectionLists(); -#ifdef QT3_SUPPORT - void sendPendingChildInsertedEvents(); -#endif - static inline Sender *setCurrentSender(QObject *receiver, Sender *sender); static inline void resetCurrentSender(QObject *receiver, @@ -190,14 +186,6 @@ public: Sender *currentSender; // object currently activating the object mutable quint32 connectedSignals[2]; -#ifdef QT3_SUPPORT - QVector< QWeakPointer > pendingChildInsertedEvents; -#else - // preserve binary compatibility with code compiled without Qt 3 support - // keeping the binary layout stable helps the Qt Creator debugger - void *unused; -#endif - QList > eventFilters; union { QObject *currentChildBeingDeleted; -- cgit v1.2.3