From 04913ce7a46fd027856e83a96205fdc388742a19 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 23 May 2024 14:04:45 +0900 Subject: Rename ntqobject*.h and qobject*.cpp to tqobject* Signed-off-by: Michele Calgaro --- src/dialogs/qdialog.cpp | 2 +- src/dialogs/qfiledialog.cpp | 2 +- src/dialogs/qmessagebox.cpp | 2 +- src/dialogs/qtabdialog.cpp | 2 +- src/kernel/ntqaccel.h | 2 +- src/kernel/ntqaccessible.h | 2 +- src/kernel/ntqasyncio.h | 2 +- src/kernel/ntqclipboard.h | 2 +- src/kernel/ntqconnection.h | 2 +- src/kernel/ntqdragobject.h | 2 +- src/kernel/ntqeventloop.h | 2 +- src/kernel/ntqgplugin.h | 2 +- src/kernel/ntqguardedptr.h | 2 +- src/kernel/ntqiconset.h | 2 +- src/kernel/ntqinputcontext.h | 2 +- src/kernel/ntqlayout.h | 2 +- src/kernel/ntqnamespace.h | 2 +- src/kernel/ntqnetworkprotocol.h | 2 +- src/kernel/ntqobject.h | 290 --- src/kernel/ntqobjectcleanuphandler.h | 68 - src/kernel/ntqobjectdefs.h | 174 -- src/kernel/ntqobjectdict.h | 66 - src/kernel/ntqobjectlist.h | 84 - src/kernel/ntqprocess.h | 2 +- src/kernel/ntqsessionmanager.h | 2 +- src/kernel/ntqsignal.h | 2 +- src/kernel/ntqsignalmapper.h | 2 +- src/kernel/ntqsocketnotifier.h | 2 +- src/kernel/ntqsound.h | 2 +- src/kernel/ntqstyle.h | 2 +- src/kernel/ntqstylesheet.h | 2 +- src/kernel/ntqt.h | 10 +- src/kernel/ntqtimer.h | 2 +- src/kernel/ntqtranslator.h | 2 +- src/kernel/ntqurloperator.h | 2 +- src/kernel/ntqwidget.h | 2 +- src/kernel/ntqwindowdefs.h | 2 +- src/kernel/qapplication.cpp | 2 +- src/kernel/qapplication_x11.cpp | 2 +- src/kernel/qdesktopwidget_x11.cpp | 2 +- src/kernel/qdnd_x11.cpp | 2 +- src/kernel/qfontdata_p.h | 2 +- src/kernel/qmovie.cpp | 2 +- src/kernel/qobject.cpp | 3249 --------------------------------- src/kernel/qobjectcleanuphandler.cpp | 172 -- src/kernel/qpixmap.cpp | 2 +- src/kernel/qpixmapcache.cpp | 2 +- src/kernel/qrichtext_p.h | 4 +- src/kernel/qsizegrip.cpp | 2 +- src/kernel/qstyle.cpp | 2 +- src/kernel/qt_kernel.pri | 14 +- src/kernel/qt_pch.h | 2 +- src/kernel/qtimer.cpp | 2 +- src/kernel/qwidget.cpp | 2 +- src/kernel/qwidget_x11.cpp | 2 +- src/kernel/tqobject.cpp | 3249 +++++++++++++++++++++++++++++++++ src/kernel/tqobject.h | 292 +++ src/kernel/tqobjectcleanuphandler.cpp | 172 ++ src/kernel/tqobjectcleanuphandler.h | 68 + src/kernel/tqobjectdefs.h | 174 ++ src/kernel/tqobjectdict.h | 66 + src/kernel/tqobjectlist.h | 84 + src/moc/moc.y | 4 +- src/moc/moc_yacc.cpp | 4 +- src/network/ntqdns.h | 2 +- src/network/ntqhttp.h | 2 +- src/network/ntqserversocket.h | 2 +- src/network/ntqsocket.h | 2 +- src/sql/ntqeditorfactory.h | 2 +- src/sql/ntqsqldatabase.h | 2 +- src/sql/ntqsqldriver.h | 2 +- src/sql/ntqsqlform.h | 2 +- src/sql/ntqsqlquery.h | 2 +- src/sql/qsqldatabase.cpp | 2 +- src/styles/qcommonstyle.cpp | 2 +- src/styles/qstyleplugin.cpp | 2 +- src/styles/qwindowsstyle.cpp | 2 +- src/table/qtable.cpp | 2 +- src/tools/qfile.cpp | 2 +- src/tools/qwinexport.cpp | 2 +- src/widgets/ntqaction.h | 2 +- src/widgets/ntqvalidator.h | 2 +- src/widgets/ntqwhatsthis.h | 2 +- src/widgets/qaction.cpp | 2 +- src/widgets/qgroupbox.cpp | 2 +- src/widgets/qhbox.cpp | 2 +- src/widgets/qmainwindow.cpp | 2 +- src/widgets/qpopupmenu.cpp | 2 +- src/widgets/qscrollview.cpp | 2 +- src/widgets/qsplitter.cpp | 2 +- src/widgets/qtabwidget.cpp | 2 +- src/widgets/qtoolbar.cpp | 2 +- src/widgets/qtoolbox.cpp | 2 +- src/widgets/qwidgetplugin.cpp | 2 +- src/widgets/qwidgetresizehandler_p.h | 2 +- src/widgets/qwidgetstack.cpp | 2 +- src/workspace/qworkspace.cpp | 2 +- src/xml/qxml.cpp | 2 +- 98 files changed, 4202 insertions(+), 4200 deletions(-) delete mode 100644 src/kernel/ntqobject.h delete mode 100644 src/kernel/ntqobjectcleanuphandler.h delete mode 100644 src/kernel/ntqobjectdefs.h delete mode 100644 src/kernel/ntqobjectdict.h delete mode 100644 src/kernel/ntqobjectlist.h delete mode 100644 src/kernel/qobject.cpp delete mode 100644 src/kernel/qobjectcleanuphandler.cpp create mode 100644 src/kernel/tqobject.cpp create mode 100644 src/kernel/tqobject.h create mode 100644 src/kernel/tqobjectcleanuphandler.cpp create mode 100644 src/kernel/tqobjectcleanuphandler.h create mode 100644 src/kernel/tqobjectdefs.h create mode 100644 src/kernel/tqobjectdict.h create mode 100644 src/kernel/tqobjectlist.h (limited to 'src') diff --git a/src/dialogs/qdialog.cpp b/src/dialogs/qdialog.cpp index f8067b545..eb9526387 100644 --- a/src/dialogs/qdialog.cpp +++ b/src/dialogs/qdialog.cpp @@ -45,7 +45,7 @@ #include "ntqpushbutton.h" #include "ntqfocusdata.h" #include "ntqapplication.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqwidgetlist.h" #include "ntqlayout.h" #include "ntqsizegrip.h" diff --git a/src/dialogs/qfiledialog.cpp b/src/dialogs/qfiledialog.cpp index 864139e12..bb02ad2bd 100644 --- a/src/dialogs/qfiledialog.cpp +++ b/src/dialogs/qfiledialog.cpp @@ -78,7 +78,7 @@ #include "ntqmessagebox.h" #include "ntqmime.h" #include "ntqnetworkprotocol.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqpainter.h" #include "ntqpopupmenu.h" #include "ntqprogressbar.h" diff --git a/src/dialogs/qmessagebox.cpp b/src/dialogs/qmessagebox.cpp index 929be411a..29005500c 100644 --- a/src/dialogs/qmessagebox.cpp +++ b/src/dialogs/qmessagebox.cpp @@ -48,7 +48,7 @@ #include "ntqimage.h" #include "ntqapplication.h" #include "ntqstyle.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #if defined(QT_ACCESSIBILITY_SUPPORT) #include "ntqaccessible.h" #endif diff --git a/src/dialogs/qtabdialog.cpp b/src/dialogs/qtabdialog.cpp index e6641dbc6..a9ad79d7d 100644 --- a/src/dialogs/qtabdialog.cpp +++ b/src/dialogs/qtabdialog.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_TABDIALOG -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqtabbar.h" #include "ntqtabwidget.h" #include "ntqpushbutton.h" diff --git a/src/kernel/ntqaccel.h b/src/kernel/ntqaccel.h index ef578242a..22c2f80e1 100644 --- a/src/kernel/ntqaccel.h +++ b/src/kernel/ntqaccel.h @@ -42,7 +42,7 @@ #define TQACCEL_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqkeysequence.h" #endif // QT_H diff --git a/src/kernel/ntqaccessible.h b/src/kernel/ntqaccessible.h index 61baf31b0..39f68ee3f 100644 --- a/src/kernel/ntqaccessible.h +++ b/src/kernel/ntqaccessible.h @@ -40,7 +40,7 @@ #define TQACCESSIBLE_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include #include "ntqrect.h" #include "ntqguardedptr.h" diff --git a/src/kernel/ntqasyncio.h b/src/kernel/ntqasyncio.h index 1fea830be..19fe284b0 100644 --- a/src/kernel/ntqasyncio.h +++ b/src/kernel/ntqasyncio.h @@ -42,7 +42,7 @@ #define TQASYNCIO_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqsignal.h" #include "ntqtimer.h" #endif // QT_H diff --git a/src/kernel/ntqclipboard.h b/src/kernel/ntqclipboard.h index 706115f33..0202f78de 100644 --- a/src/kernel/ntqclipboard.h +++ b/src/kernel/ntqclipboard.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "ntqwindowdefs.h" -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H #ifndef TQT_NO_CLIPBOARD diff --git a/src/kernel/ntqconnection.h b/src/kernel/ntqconnection.h index b259d9866..6906184b7 100644 --- a/src/kernel/ntqconnection.h +++ b/src/kernel/ntqconnection.h @@ -42,7 +42,7 @@ #define TQCONNECTION_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H class TQ_EXPORT TQConnection diff --git a/src/kernel/ntqdragobject.h b/src/kernel/ntqdragobject.h index 069e82973..60a43ca34 100644 --- a/src/kernel/ntqdragobject.h +++ b/src/kernel/ntqdragobject.h @@ -46,7 +46,7 @@ class TQStoredDragData; class TQImageDragData; #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqimage.h" #include "ntqstrlist.h" #include "ntqcolor.h" diff --git a/src/kernel/ntqeventloop.h b/src/kernel/ntqeventloop.h index deca8d061..1c66e5950 100644 --- a/src/kernel/ntqeventloop.h +++ b/src/kernel/ntqeventloop.h @@ -40,7 +40,7 @@ #define TQEVENTLOOP_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqsocketnotifier.h" #endif // QT_H diff --git a/src/kernel/ntqgplugin.h b/src/kernel/ntqgplugin.h index 1b7431458..88212515b 100644 --- a/src/kernel/ntqgplugin.h +++ b/src/kernel/ntqgplugin.h @@ -52,7 +52,7 @@ // #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H #ifndef TQT_NO_COMPONENT diff --git a/src/kernel/ntqguardedptr.h b/src/kernel/ntqguardedptr.h index c0b7084a3..29ef8b8c7 100644 --- a/src/kernel/ntqguardedptr.h +++ b/src/kernel/ntqguardedptr.h @@ -42,7 +42,7 @@ #define TQGUARDEDPTR_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H // ### 4.0: rename to something without Private in it. Not really internal. diff --git a/src/kernel/ntqiconset.h b/src/kernel/ntqiconset.h index d9a90460e..66fc71146 100644 --- a/src/kernel/ntqiconset.h +++ b/src/kernel/ntqiconset.h @@ -42,7 +42,7 @@ #define TQICONSET_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqpixmap.h" #endif // QT_H diff --git a/src/kernel/ntqinputcontext.h b/src/kernel/ntqinputcontext.h index 24bbca763..a37c01670 100644 --- a/src/kernel/ntqinputcontext.h +++ b/src/kernel/ntqinputcontext.h @@ -39,7 +39,7 @@ #ifndef TQT_NO_IM #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqglobal.h" #include "ntqevent.h" #include "ntqstring.h" diff --git a/src/kernel/ntqlayout.h b/src/kernel/ntqlayout.h index 6e0749098..9ff6615a9 100644 --- a/src/kernel/ntqlayout.h +++ b/src/kernel/ntqlayout.h @@ -42,7 +42,7 @@ #define TQLAYOUT_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqsizepolicy.h" #include "ntqwidget.h" #endif // QT_H diff --git a/src/kernel/ntqnamespace.h b/src/kernel/ntqnamespace.h index 14b4a67e1..5ce38f835 100644 --- a/src/kernel/ntqnamespace.h +++ b/src/kernel/ntqnamespace.h @@ -89,7 +89,7 @@ public: Keypad = 0x4000 }; - // documented in qobject.cpp + // documented in tqobject.cpp // ideally would start at 1, as in TQSizePolicy, but that breaks other things enum Orientation { Horizontal = 0, diff --git a/src/kernel/ntqnetworkprotocol.h b/src/kernel/ntqnetworkprotocol.h index fa245f9c2..3872ffb3c 100644 --- a/src/kernel/ntqnetworkprotocol.h +++ b/src/kernel/ntqnetworkprotocol.h @@ -45,7 +45,7 @@ #include "ntqurlinfo.h" #include "ntqstring.h" #include "ntqdict.h" -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H #ifndef TQT_NO_NETWORKPROTOCOL diff --git a/src/kernel/ntqobject.h b/src/kernel/ntqobject.h deleted file mode 100644 index 19df54726..000000000 --- a/src/kernel/ntqobject.h +++ /dev/null @@ -1,290 +0,0 @@ -/**************************************************************************** -** -** Definition of TQObject class -** -** Created : 930418 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECT_H -#define TQOBJECT_H - -#ifndef QT_H -#include "ntqobjectdefs.h" -#include "ntqwindowdefs.h" -#include "ntqstring.h" -#include "ntqevent.h" -#include "ntqmutex.h" -#include "ntqnamespace.h" -#endif // QT_H - -#define TQT_TR_NOOP(x) (x) -#define TQT_TRANSLATE_NOOP(scope,x) (x) - -class TQMetaObject; -class TQVariant; -class TQMetaProperty; -class TQPostEventList; -class TQSenderObjectList; -class TQObjectPrivate; -#ifndef TQT_NO_USERDATA -class TQObjectUserData; -#endif -struct TQUObject; - -#ifdef TQT_THREAD_SUPPORT -class TQThread; -#endif - -class TQStyleControlElementData; -class TQStyleControlElementDataPrivate; - -class TQ_EXPORT TQObject: public TQt -{ - TQ_OBJECT - TQ_PROPERTY( TQCString name READ name WRITE setName ) - -public: - TQObject( TQObject *parent=0, const char *name=0 ); - virtual ~TQObject(); - -#ifdef Q_QDOC - virtual const char *className() const; - static TQString tr( const char *, const char * ); - static TQString trUtf8( const char *, const char * ); - virtual TQMetaObject *metaObject() const; -#endif - - virtual bool event( TQEvent * ); - virtual bool eventFilter( TQObject *, TQEvent * ); - - bool isA( const char * ) const; - bool inherits( const char * ) const; - - const char *name() const; - const char *name( const char * defaultName ) const; - - virtual void setName( const char *name ); - bool isWidgetType() const { return isWidget; } - bool highPriority() const { return FALSE; } - - bool signalsBlocked() const { return blockSig; } - void blockSignals( bool b ); - - int startTimer( int interval ); - void killTimer( int id ); - void killTimers(); - - TQObject *child( const char *objName, const char *inheritsClass = 0, bool recursiveSearch = TRUE ); //### const in 4.0 - const TQObjectList *children() const { return childObjects; } - TQObjectList childrenListObject(); - const TQObjectList childrenListObject() const; - - static const TQObjectList *objectTrees(); - static const TQObjectList objectTreesListObject(); - - TQObjectList *queryList( const char *inheritsClass = 0, - const char *objName = 0, - bool regexpMatch = TRUE, - bool recursiveSearch = TRUE ) const; - - virtual void insertChild( TQObject * ); - virtual void removeChild( TQObject * ); - - void installEventFilter( const TQObject * ); - void removeEventFilter( const TQObject * ); - - static bool connect( const TQObject *sender, const char *signal, - const TQObject *receiver, const char *member ); - bool connect( const TQObject *sender, const char *signal, - const char *member ) const; - static bool disconnect( const TQObject *sender, const char *signal, - const TQObject *receiver, const char *member ); - bool disconnect( const char *signal=0, - const TQObject *receiver=0, const char *member=0 ); - bool disconnect( const TQObject *receiver, const char *member=0 ); - static void connectInternal( const TQObject *sender, int signal_index, - const TQObject *receiver, int membcode, int member_index ); - static bool disconnectInternal( const TQObject *sender, int signal_index, - const TQObject *receiver, int membcode, int member_index ); - - void dumpObjectTree(); - void dumpObjectInfo(); - - TQStyleControlElementData* controlElementDataObject(); - TQStyleControlElementDataPrivate* controlElementDataPrivateObject(); - -#ifndef TQT_NO_PROPERTIES - virtual bool setProperty( const char *name, const TQVariant& value ); - virtual TQVariant property( const char *name ) const; -#endif // TQT_NO_PROPERTIES -#ifdef TQT_NO_TRANSLATION - static TQString tr( const char *sourceText, const char * = 0); -#ifndef TQT_NO_TEXTCODEC - static TQString trUtf8( const char *sourceText, const char * = 0); -#endif -#endif //TQT_NO_TRANSLATION - -#ifndef TQT_NO_USERDATA - static uint registerUserData(); - void setUserData( uint id, TQObjectUserData* data); - TQObjectUserData* userData( uint id ) const; -#endif // TQT_NO_USERDATA - -signals: - void destroyed(); - void destroyed( TQObject* obj ); - -public: - TQObject *parent() const { return parentObj; } - -public slots: - void deleteLater(); - -private slots: - void cleanupEventFilter( TQObject* ); - -protected: - bool activate_filters( TQEvent * ); - TQConnectionList *receivers( const char* signal ) const; - TQConnectionList *receivers( int signal ) const; - void activate_signal( int signal ); - void activate_signal( int signal, int ); - void activate_signal( int signal, double ); - void activate_signal( int signal, TQString ); - void activate_signal_bool( int signal, bool ); - void activate_signal( TQConnectionList *clist, TQUObject *o ); - - const TQObject *sender(); - - virtual void timerEvent( TQTimerEvent * ); - virtual void childEvent( TQChildEvent * ); - virtual void customEvent( TQCustomEvent * ); - - virtual void connectNotify( const char *signal ); - virtual void disconnectNotify( const char *signal ); - virtual bool checkConnectArgs( const char *signal, const TQObject *receiver, - const char *member ); - static TQCString normalizeSignalSlot( const char *signalSlot ); - -private: - uint isSignal : 1; - uint isWidget : 1; - uint pendTimer : 1; - uint blockSig : 1; - uint wasDeleted : 1; - uint isTree : 1; - - const char *objname; - TQObject *parentObj; - TQObjectList *childObjects; - TQSignalVec *connections; - TQSenderObjectList *senderObjects; - TQObjectList *eventFilters; - TQPostEventList *postedEvents; - TQObjectPrivate* d; - - static TQMetaObject* staticTQtMetaObject(); - - friend class TQApplication; - friend class TQBaseApplication; - friend class TQWidget; - friend class TQSignal; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQObject( const TQObject & ); - TQObject &operator=( const TQObject & ); -#endif - -public: -#ifdef TQT_THREAD_SUPPORT - TQThread* contextThreadObject() const; - void moveToThread(TQThread *targetThread); - void disableThreadPostedEvents(bool disable); -#endif - -private: - void cleanupControlElementData(); -#ifdef TQT_THREAD_SUPPORT - void moveToThread_helper(TQThread *targetThread); - void setThreadObject_helper(TQThread *targetThread); -#endif -}; - - -#ifndef TQT_NO_USERDATA -class TQ_EXPORT TQObjectUserData { -public: - virtual ~TQObjectUserData(); -}; -#endif - - -inline bool TQObject::connect( const TQObject *sender, const char *signal, - const char *member ) const -{ - return connect( sender, signal, this, member ); -} - - -inline bool TQObject::disconnect( const char *signal, - const TQObject *receiver, const char *member ) -{ - return disconnect( this, signal, receiver, member ); -} - - -inline bool TQObject::disconnect( const TQObject *receiver, const char *member ) -{ - return disconnect( this, 0, receiver, member ); -} - - -#ifdef TQT_NO_TRANSLATION -inline TQString TQObject::tr( const char *sourceText, const char * ) { - return TQString::fromLatin1( sourceText ); -} -#ifndef TQT_NO_TEXTCODEC -inline TQString TQObject::trUtf8( const char *sourceText, const char * ) { - return TQString::fromUtf8( sourceText ); -} -#endif -#endif //TQT_NO_TRANSLATION - - -#define Q_DEFINED_QOBJECT -#include "ntqwinexport.h" -#endif // TQOBJECT_H diff --git a/src/kernel/ntqobjectcleanuphandler.h b/src/kernel/ntqobjectcleanuphandler.h deleted file mode 100644 index 82fe6d9b2..000000000 --- a/src/kernel/ntqobjectcleanuphandler.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Definition of ??? -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECTCLEANUPHANDLER_H -#define TQOBJECTCLEANUPHANDLER_H - -#ifndef QT_H -#include "ntqobject.h" -#endif // QT_H - -class TQObjectList; - -class TQ_EXPORT TQObjectCleanupHandler : public TQObject -{ - TQ_OBJECT - -public: - TQObjectCleanupHandler(); - ~TQObjectCleanupHandler(); - - TQObject* add( TQObject* object ); - void remove( TQObject *object ); - bool isEmpty() const; - void clear(); - -private: - TQObjectList *cleanupObjects; - -private slots: - void objectDestroyed( TQObject * ); -}; - -#endif // TQOBJECTCLEANUPHANDLER_H diff --git a/src/kernel/ntqobjectdefs.h b/src/kernel/ntqobjectdefs.h deleted file mode 100644 index ba5e12b88..000000000 --- a/src/kernel/ntqobjectdefs.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Macros and definitions related to TQObject -** -** Created : 930419 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECTDEFS_H -#define TQOBJECTDEFS_H - -#ifndef QT_H -#include "ntqglobal.h" -#endif // QT_H - - -#ifndef TQT_NO_TRANSLATION -# ifndef TQT_NO_TEXTCODEC -// full set of tr functions -# define TQT_TR_FUNCTIONS \ - static TQString tr( const char *, const char * = 0 ); \ - static TQString trUtf8( const char *, const char * = 0 ); -# else -// no TQTextCodec, no utf8 -# define TQT_TR_FUNCTIONS \ - static TQString tr( const char *, const char * = 0 ); -# endif -#else -// inherit the ones from TQObject -# define TQT_TR_FUNCTIONS -#endif - -#ifndef TQT_NO_PROPERTIES -# define QT_PROP_FUNCTIONS \ - virtual bool tqt_property( int id, int f, TQVariant* v); \ - static bool tqt_static_property( TQObject* , int, int, TQVariant* ); -#else -# define QT_PROP_FUNCTIONS -#endif - -// The following macros are our "extensions" to C++ -// They are used, strictly speaking, only by the moc. -struct TQUObject; - -#ifdef QT_MOC_CPP -#define slots slots -#define signals signals -#define TQ_CLASSINFO( name, value ) TQ_CLASSINFO( name, value ) -#define TQ_PROPERTY( text ) TQ_PROPERTY( text ) -#define TQ_OVERRIDE( text ) TQ_OVERRIDE( text ) -#define TQ_ENUMS( x ) TQ_ENUMS( x ) -#define TQ_SETS( x ) TQ_SETS( x ) - /* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT TQ_OBJECT - /* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT_FAKE TQ_OBJECT_FAKE - -#else -#define slots // slots: in class -#define signals protected // signals: in class -#ifndef TQT_NO_EMIT -#define emit // emit signal -#endif -#define TQ_CLASSINFO( name, value ) // class info -#define TQ_PROPERTY( text ) // property -#define TQ_OVERRIDE( text ) // override property -#define TQ_ENUMS( x ) -#define TQ_SETS( x ) - -/* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT \ -public: \ - virtual TQMetaObject *metaObject() const { \ - return staticMetaObject(); \ - } \ - virtual const char *className() const; \ - virtual void* tqt_cast( const char* ); \ - virtual bool tqt_invoke( int, TQUObject* ); \ - virtual bool tqt_emit( int, TQUObject* ); \ - QT_PROP_FUNCTIONS \ - static TQMetaObject* staticMetaObject(); \ - TQObject* qObject() { return (TQObject*)this; } \ - TQT_TR_FUNCTIONS \ -private: \ - static TQMetaObject *metaObj; - -/* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT_FAKE TQ_OBJECT - -#endif - -// macro for naming members -#ifdef TQ_METHOD -#undef TQ_METHOD -#endif -#ifdef TQ_SLOT -#undef TQ_SLOT -#endif -#ifdef TQ_SIGNAL -#undef TQ_SIGNAL -#endif - -#if defined(_OLD_CPP_) -#define TQ_METHOD(a) "0""a" -#define TQ_SLOT(a) "1""a" -#define TQ_SIGNAL(a) "2""a" -#else -#define TQ_METHOD(a) "0"#a -#define TQ_SLOT(a) "1"#a -#define TQ_SIGNAL(a) "2"#a -#endif - -#define TQ_METHOD_CODE 0 // member type codes -#define TQ_SLOT_CODE 1 -#define TQ_SIGNAL_CODE 2 - -class TQObject; -class TQMetaObject; -class TQSignal; -class TQConnection; -class TQEvent; -class TQMutex; -struct TQMetaData; -class TQConnectionList; -class TQConnectionListIt; -class TQSignalVec; -class TQObjectList; -class TQObjectListIt; -class TQMemberDict; - -extern TQMutex *tqt_sharedMetaObjectMutex; - -TQ_EXPORT void *tqt_find_obj_child( TQObject *, const char *, const char * ); -#define Q_CHILD(parent,type,name) \ - ((type*)tqt_find_obj_child(parent,#type,name)) - -TQ_EXPORT void *tqt_inheritedBy( TQMetaObject *super, const TQObject *cls ); - -template -TQ_INLINE_TEMPLATES T tqt_cast(const TQObject *object) -{ return (T)tqt_inheritedBy( ((T)0)->staticMetaObject(), object ); } -#endif // TQOBJECTDEFS_H diff --git a/src/kernel/ntqobjectdict.h b/src/kernel/ntqobjectdict.h deleted file mode 100644 index 4ee49faf2..000000000 --- a/src/kernel/ntqobjectdict.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Definition of TQObjectDictionary -** -** Created : 940807 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECTDICT_H -#define TQOBJECTDICT_H - -#ifndef QT_H -#include "ntqmetaobject.h" -#include "ntqasciidict.h" -#endif // QT_H - - -// -// The object dictionary is a collection of TQMetaObjects -// - -class TQ_EXPORT TQObjectDictionary : public TQAsciiDict -{ -public: - TQObjectDictionary(int size=17,bool cs=TRUE,bool ck=TRUE) - : TQAsciiDict(size,cs,ck) {} - TQObjectDictionary( const TQObjectDictionary &dict ) - : TQAsciiDict(dict) {} - ~TQObjectDictionary() { clear(); } - TQObjectDictionary &operator=(const TQObjectDictionary &dict) - { return (TQObjectDictionary&)TQAsciiDict::operator=(dict);} -}; - -#endif // TQOBJECTDICT_H diff --git a/src/kernel/ntqobjectlist.h b/src/kernel/ntqobjectlist.h deleted file mode 100644 index 80c353f0d..000000000 --- a/src/kernel/ntqobjectlist.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Definition of TQObjectList -** -** Created : 940807 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECTLIST_H -#define TQOBJECTLIST_H - -#ifndef QT_H -#include "ntqobject.h" -#include "ntqptrlist.h" -#endif // QT_H - - -#if defined(Q_TEMPLATEDLL) -//Q_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrList; -//Q_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrListIterator; -#endif - - -class TQ_EXPORT TQObjectList : public TQPtrList -{ -public: - TQObjectList() : TQPtrList() {} - TQObjectList( const TQObjectList &list ) : TQPtrList(list) {} - ~TQObjectList() { clear(); } - TQObjectList &operator=(const TQObjectList &list) - { return (TQObjectList&)TQPtrList::operator=(list); } -}; - -class TQ_EXPORT TQObjectListIterator : public TQPtrListIterator -{ -public: - TQObjectListIterator( const TQObjectList &l ) - : TQPtrListIterator( l ) { } - TQObjectListIterator &operator=( const TQObjectListIterator &i ) - { return (TQObjectListIterator&) - TQPtrListIterator::operator=( i ); } -}; - -class TQ_EXPORT TQObjectListIt : public TQPtrListIterator -{ -public: - TQObjectListIt( const TQObjectList &l ) : TQPtrListIterator(l) {} - TQObjectListIt &operator=(const TQObjectListIt &i) - { return (TQObjectListIt&)TQPtrListIterator::operator=(i); } -}; - -#endif // TQOBJECTLIST_H diff --git a/src/kernel/ntqprocess.h b/src/kernel/ntqprocess.h index b03ffe647..e3e189af0 100644 --- a/src/kernel/ntqprocess.h +++ b/src/kernel/ntqprocess.h @@ -42,7 +42,7 @@ #define TQPROCESS_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqstringlist.h" #include "ntqdir.h" #endif // QT_H diff --git a/src/kernel/ntqsessionmanager.h b/src/kernel/ntqsessionmanager.h index f87fb3b11..600b2950e 100644 --- a/src/kernel/ntqsessionmanager.h +++ b/src/kernel/ntqsessionmanager.h @@ -42,7 +42,7 @@ #define TQSESSIONMANAGER_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqwindowdefs.h" #include "ntqstring.h" #include "ntqstringlist.h" diff --git a/src/kernel/ntqsignal.h b/src/kernel/ntqsignal.h index 942eaaeb9..bb3875a09 100644 --- a/src/kernel/ntqsignal.h +++ b/src/kernel/ntqsignal.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "ntqvariant.h" -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H diff --git a/src/kernel/ntqsignalmapper.h b/src/kernel/ntqsignalmapper.h index b8125e57b..aed7e72d4 100644 --- a/src/kernel/ntqsignalmapper.h +++ b/src/kernel/ntqsignalmapper.h @@ -42,7 +42,7 @@ #define TQSIGNALMAPPER_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H #ifndef TQT_NO_SIGNALMAPPER class TQSignalMapperData; diff --git a/src/kernel/ntqsocketnotifier.h b/src/kernel/ntqsocketnotifier.h index 7a9c56fb3..717be3898 100644 --- a/src/kernel/ntqsocketnotifier.h +++ b/src/kernel/ntqsocketnotifier.h @@ -42,7 +42,7 @@ #define TQSOCKETNOTIFIER_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H diff --git a/src/kernel/ntqsound.h b/src/kernel/ntqsound.h index 19f1ba4ec..d3ba92ed3 100644 --- a/src/kernel/ntqsound.h +++ b/src/kernel/ntqsound.h @@ -41,7 +41,7 @@ #define TQSOUND_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H #ifndef TQT_NO_SOUND diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h index 5ebbb2c5e..d4288aa33 100644 --- a/src/kernel/ntqstyle.h +++ b/src/kernel/ntqstyle.h @@ -41,7 +41,7 @@ #define TQSTYLE_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqpixmap.h" #include "ntqcolor.h" #include "ntqiconset.h" diff --git a/src/kernel/ntqstylesheet.h b/src/kernel/ntqstylesheet.h index 17f13a25b..2b397f946 100644 --- a/src/kernel/ntqstylesheet.h +++ b/src/kernel/ntqstylesheet.h @@ -46,7 +46,7 @@ #include "ntqvaluelist.h" #include "ntqptrvector.h" #include "ntqdict.h" -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H #ifndef TQT_NO_RICHTEXT diff --git a/src/kernel/ntqt.h b/src/kernel/ntqt.h index 1d2147fae..2e4c2caaa 100644 --- a/src/kernel/ntqt.h +++ b/src/kernel/ntqt.h @@ -20,7 +20,7 @@ #include "ntqshared.h" #include "ntqptrcollection.h" #include "ntqglist.h" -#include "ntqobjectdefs.h" +#include "tqobjectdefs.h" #include "ntqnamespace.h" #include "ntqgarray.h" #include "ntqmemarray.h" @@ -59,7 +59,7 @@ #include "ntqstringlist.h" #include "ntqcolor.h" #include -#include "ntqobject.h" +#include "tqobject.h" #include #include "ntqbrush.h" #include "ntqpalette.h" @@ -140,10 +140,10 @@ #include #include #include "ntqguardedptr.h" -#include +#include #include "ntqsqlfield.h" -#include -#include +#include +#include #include #include #include "ntqpointarray.h" diff --git a/src/kernel/ntqtimer.h b/src/kernel/ntqtimer.h index 1b3045caa..40aae8724 100644 --- a/src/kernel/ntqtimer.h +++ b/src/kernel/ntqtimer.h @@ -42,7 +42,7 @@ #define TQTIMER_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H diff --git a/src/kernel/ntqtranslator.h b/src/kernel/ntqtranslator.h index beb6f5528..e255b81e1 100644 --- a/src/kernel/ntqtranslator.h +++ b/src/kernel/ntqtranslator.h @@ -43,7 +43,7 @@ #define TQTRANSLATOR_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqvaluelist.h" #endif // QT_H diff --git a/src/kernel/ntqurloperator.h b/src/kernel/ntqurloperator.h index 1644922aa..986fb25aa 100644 --- a/src/kernel/ntqurloperator.h +++ b/src/kernel/ntqurloperator.h @@ -42,7 +42,7 @@ #define TQURLOPERATOR_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqurl.h" #include "ntqptrlist.h" #include "ntqnetworkprotocol.h" diff --git a/src/kernel/ntqwidget.h b/src/kernel/ntqwidget.h index 7e589c1a8..d328dd95d 100644 --- a/src/kernel/ntqwidget.h +++ b/src/kernel/ntqwidget.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "ntqwindowdefs.h" -#include "ntqobject.h" +#include "tqobject.h" #include "ntqpaintdevice.h" #include "ntqpalette.h" #include "ntqfont.h" diff --git a/src/kernel/ntqwindowdefs.h b/src/kernel/ntqwindowdefs.h index 4af074cc9..ae28caace 100644 --- a/src/kernel/ntqwindowdefs.h +++ b/src/kernel/ntqwindowdefs.h @@ -43,7 +43,7 @@ #define TQWINDOWDEFS_H #ifndef QT_H -#include "ntqobjectdefs.h" +#include "tqobjectdefs.h" #include "ntqstring.h" #include "ntqnamespace.h" #endif // QT_H diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 45016b04c..31bd5ecc4 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -38,7 +38,7 @@ ** **********************************************************************/ -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqapplication.h" #include "ntqeventloop.h" #include "qeventloop_p.h" diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 0148f8760..125f1fa21 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -67,7 +67,7 @@ #include "ntqcursor.h" #include "ntqwidget.h" #include "qwidget_p.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqwidgetlist.h" #include "ntqwidgetintdict.h" #include "ntqbitarray.h" diff --git a/src/kernel/qdesktopwidget_x11.cpp b/src/kernel/qdesktopwidget_x11.cpp index 449af4ffc..bb301e522 100644 --- a/src/kernel/qdesktopwidget_x11.cpp +++ b/src/kernel/qdesktopwidget_x11.cpp @@ -38,7 +38,7 @@ #include "ntqdesktopwidget.h" #include "ntqapplication.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "qt_x11_p.h" #include diff --git a/src/kernel/qdnd_x11.cpp b/src/kernel/qdnd_x11.cpp index bad09d3cd..a50f23319 100644 --- a/src/kernel/qdnd_x11.cpp +++ b/src/kernel/qdnd_x11.cpp @@ -50,7 +50,7 @@ #include "ntqdict.h" #include "ntqguardedptr.h" #include "ntqdragobject.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqcursor.h" #include "ntqbitmap.h" #include "ntqpainter.h" diff --git a/src/kernel/qfontdata_p.h b/src/kernel/qfontdata_p.h index 9c21dfe60..991b61773 100644 --- a/src/kernel/qfontdata_p.h +++ b/src/kernel/qfontdata_p.h @@ -53,7 +53,7 @@ // // -#include "ntqobject.h" +#include "tqobject.h" #include "ntqfont.h" #include "ntqpaintdevicemetrics.h" diff --git a/src/kernel/qmovie.cpp b/src/kernel/qmovie.cpp index 6833762e8..2f83cabff 100644 --- a/src/kernel/qmovie.cpp +++ b/src/kernel/qmovie.cpp @@ -47,7 +47,7 @@ #include "ntqmovie.h" #include "ntqfile.h" #include "ntqbuffer.h" -#include "ntqobject.h" +#include "tqobject.h" #include "ntqpixmapcache.h" #ifndef TQT_NO_MOVIE diff --git a/src/kernel/qobject.cpp b/src/kernel/qobject.cpp deleted file mode 100644 index bb4c848b8..000000000 --- a/src/kernel/qobject.cpp +++ /dev/null @@ -1,3249 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQObject class -** -** Created : 930418 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqvariant.h" -#include "ntqapplication.h" -#include "ntqobject.h" -#include "ntqobjectlist.h" -#include "ntqsignalslotimp.h" -#include "ntqregexp.h" -#include "ntqmetaobject.h" -#include -#include "qucomextra_p.h" -#include "ntqptrvector.h" - -// TQStyleControlElementData -#include "ntqstyle.h" - -#ifdef TQT_THREAD_SUPPORT -#include "ntqmutex.h" -#include -#include "ntqthread.h" -#endif - -#include -#include - -// Keep in sync with duplicate definition in qcommonstyle.cpp -class TQStyleControlElementDataPrivate { - public: - bool isTQPushButton; - bool isTQToolButton; - bool isTQButton; - bool isTQTabBar; - bool isTQTitleBar; - bool isTQToolBox; - bool isTQToolBar; - bool isTQProgressBar; - bool isTQPopupMenu; - bool isTQComboBox; - bool isTQCheckBox; - bool isTQRadioButton; - bool isTQHeader; - bool isTQScrollBar; - bool isTQSlider; - bool isTQDialogButtons; - bool isTQSpinWidget; - bool isTQListView; - bool isTQDockWindow; - bool isTQTabWidget; - bool isTQFrame; - bool isTQWidget; -}; - -#ifndef TQT_NO_USERDATA -class TQObjectPrivate : public TQPtrVector -#else -class TQObjectPrivate { -#endif -{ -public: -#ifndef TQT_NO_USERDATA - TQObjectPrivate( uint s ) : TQPtrVector(s) { -#ifdef TQT_THREAD_SUPPORT - ownThread = NULL; - disableThreadPostedEvents = false; -#endif - setAutoDelete( TRUE ); - controlElementData = NULL; - controlElementDataPrivate = NULL; - } - ~TQObjectPrivate() { - delete controlElementData; - delete controlElementDataPrivate; - } -#endif -#ifdef TQT_THREAD_SUPPORT - TQThread* ownThread; - TQMutex* senderObjectListMutex; - TQMutex* childObjectListMutex; - bool disableThreadPostedEvents; -#endif - TQStyleControlElementData* controlElementData; - TQStyleControlElementDataPrivate* controlElementDataPrivate; -}; - -TQStyleControlElementData* TQObject::controlElementDataObject() { - if (!d->controlElementData) { - d->controlElementData = new TQStyleControlElementData(); - } - return d->controlElementData; -} - -TQStyleControlElementDataPrivate* TQObject::controlElementDataPrivateObject() { - if (!d->controlElementDataPrivate) { - d->controlElementDataPrivate = new TQStyleControlElementDataPrivate(); - } - return d->controlElementDataPrivate; -} - -void TQObject::cleanupControlElementData() { - delete d->controlElementData; - d->controlElementData = 0; - delete d->controlElementDataPrivate; - d->controlElementDataPrivate = 0; -} - -#if defined(TQT_THREAD_SUPPORT) - -void TQObject::moveToThread_helper(TQThread *targetThread) -{ - TQEvent e(TQEvent::ThreadChange); - TQApplication::sendEvent(this, &e); - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( d->childObjectListMutex ); -#endif // TQT_THREAD_SUPPORT - - if (childObjects) { - TQObject *child; - TQObjectListIt it(*childObjects); - while ( (child=it.current()) ) { - ++it; - child->moveToThread_helper(targetThread); - } - } -} - -void TQObject::setThreadObject_helper(TQThread *targetThread) -{ - d->ownThread = targetThread; - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( d->childObjectListMutex ); -#endif // TQT_THREAD_SUPPORT - - if (childObjects) { - TQObject *child; - TQObjectListIt it(*childObjects); - while ( (child=it.current()) ) { - ++it; - child->setThreadObject_helper(targetThread); - } - } -} - -/*! - Changes the thread affinity for this object and its children. The - object cannot be moved if it has a parent. Event processing will - continue in the \a targetThread. To move an object to the main - thread, pass TQApplication::guiThread() as the \a targetThread. - - Note that all active timers for the object will be reset. The - timers are first stopped in the current thread and restarted (with - the same interval) in the \a targetThread. As a result, constantly - moving an object between threads can postpone timer events - indefinitely. - - \sa contextThreadObject() - */ -void TQObject::moveToThread(TQThread *targetThread) -{ -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( TQApplication::tqt_mutex ); -#endif // TQT_THREAD_SUPPORT - - if (parentObj) { -#if defined(QT_DEBUG) - tqWarning( "TQObject::moveToThread: Cannot move objects with a parent" ); -#endif - return; - } - if (isWidget) { -#if defined(QT_DEBUG) - tqWarning( "TQObject::moveToThread: Widgets cannot be moved to a new thread" ); -#endif - return; - } - - TQThread *objectThread = contextThreadObject(); - // NOTE currentThread could be NULL if the current thread was not started using the TQThread API - TQThread *currentThread = TQThread::currentThreadObject(); - - if (currentThread && objectThread != currentThread) { -#if defined(QT_DEBUG) - tqWarning( "TQObject::moveToThread: Current thread is not the object's thread" ); -#endif - return; - } - - if (objectThread == targetThread) { - return; - } - - moveToThread_helper(targetThread); - setThreadObject_helper(targetThread); -} - -/*! - Changes the way cross thread signals are handled - If disable is FALSE, signals emitted from one thread will be - posted to any other connected threads' event loops (default). - - If disable is TRUE, calls to emit from one thread - will immediately execute slots in another thread. - This mode of operation is inherently unsafe and is provided - solely to support thread management by a third party application. - */ -void TQObject::disableThreadPostedEvents(bool disable) { - if ( !d ) { - d = new TQObjectPrivate(0); - } - - d->ownThread = TQThread::currentThreadObject(); - d->disableThreadPostedEvents = disable; -} - -#endif // defined(TQT_THREAD_SUPPORT) - -class TQSenderObjectList : public TQObjectList, public TQShared -{ - public: - TQSenderObjectList(); - ~TQSenderObjectList(); - - public: - TQObject *currentSender; -#ifdef TQT_THREAD_SUPPORT - TQMutex *listMutex; -#endif -}; - -TQSenderObjectList::TQSenderObjectList() : currentSender( 0 ) { -#ifdef TQT_THREAD_SUPPORT - listMutex = new TQMutex( TRUE ); -#endif -} - -TQSenderObjectList::~TQSenderObjectList() { -#ifdef TQT_THREAD_SUPPORT - delete listMutex; -#endif -} - -class TQ_EXPORT TQMetaCallEvent : public TQEvent -{ -public: - enum MetaCallType { - MetaCallEmit = 0, - MetaCallInvoke = 1 - }; - -public: - TQMetaCallEvent(int id, TQObject *sender, TQUObject *data, MetaCallType type); - ~TQMetaCallEvent(); - - inline int id() const { return id_; } - inline TQObject *sender() const { return sender_; } - inline TQUObject *data() const { return data_; } - inline MetaCallType type() const { return type_; } - -private: - const int id_; - TQObject *sender_; - TQUObject *data_; - const MetaCallType type_; -}; - -/*! \internal - */ -TQMetaCallEvent::TQMetaCallEvent(int id, TQObject *sender, TQUObject *data, MetaCallType type) - :TQEvent(MetaCall), id_(id), sender_(sender), data_(data), type_(type) -{ } - -/*! \internal - */ -TQMetaCallEvent::~TQMetaCallEvent() -{ } - -/*! - \class TQt ntqnamespace.h - - \brief The TQt class is a namespace for miscellaneous identifiers - that need to be global-like. - - \ingroup misc - - Normally, you can ignore this class. TQObject and a few other - classes inherit it, so all the identifiers in the TQt namespace are - normally usable without qualification. - - However, you may occasionally need to say \c TQt::black instead of - just \c black, particularly in static utility functions (such as - many class factories). - -*/ - -/*! - \enum TQt::Orientation - - This type is used to signify an object's orientation. - - \value Horizontal - \value Vertical - - Orientation is used with TQScrollBar for example. -*/ - - -/*! - \class TQObject ntqobject.h - \brief The TQObject class is the base class of all TQt objects. - - \ingroup objectmodel - \mainclass - \reentrant - - TQObject is the heart of the \link object.html TQt object model. - \endlink The central feature in this model is a very powerful - mechanism for seamless object communication called \link - signalsandslots.html signals and slots \endlink. You can - connect a signal to a slot with connect() and destroy the - connection with disconnect(). To avoid never ending notification - loops you can temporarily block signals with blockSignals(). The - protected functions connectNotify() and disconnectNotify() make it - possible to track connections. - - TQObjects organize themselves in object trees. When you create a - TQObject with another object as parent, the object will - automatically do an insertChild() on the parent and thus show up - in the parent's children() list. The parent takes ownership of the - object i.e. it will automatically delete its children in its - destructor. You can look for an object by name and optionally type - using child() or queryList(), and get the list of tree roots using - objectTrees(). - - Every object has an object name() and can report its className() - and whether it inherits() another class in the TQObject inheritance - hierarchy. - - When an object is deleted, it emits a destroyed() signal. You can - catch this signal to avoid dangling references to TQObjects. The - TQGuardedPtr class provides an elegant way to use this feature. - - TQObjects can receive events through event() and filter the events - of other objects. See installEventFilter() and eventFilter() for - details. A convenience handler, childEvent(), can be reimplemented - to catch child events. - - Last but not least, TQObject provides the basic timer support in - TQt; see TQTimer for high-level support for timers. - - Notice that the TQ_OBJECT macro is mandatory for any object that - implements signals, slots or properties. You also need to run the - \link moc.html moc program (Meta Object Compiler) \endlink on the - source file. We strongly recommend the use of this macro in \e all - subclasses of TQObject regardless of whether or not they actually - use signals, slots and properties, since failure to do so may lead - certain functions to exhibit undefined behaviour. - - All TQt widgets inherit TQObject. The convenience function - isWidgetType() returns whether an object is actually a widget. It - is much faster than inherits( "TQWidget" ). - - Some TQObject functions, e.g. children(), objectTrees() and - queryList() return a TQObjectList. A TQObjectList is a TQPtrList of - TQObjects. TQObjectLists support the same operations as TQPtrLists - and have an iterator class, TQObjectListIt. -*/ - - -// -// Remove white space from TQ_SIGNAL and TQ_SLOT names. -// Internal for TQObject::connect() and TQObject::disconnect() -// - -static inline bool isIdentChar( char x ) -{ // Avoid bug in isalnum - return x == '_' || (x >= '0' && x <= '9') || - (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z'); -} - -static inline bool isSpace( char x ) -{ -#if defined(Q_CC_BOR) - /* - Borland C++ 4.5 has a weird isspace() bug. - isspace() usually works, but not here. - This implementation is sufficient for our internal use: rmWS() - */ - return (uchar) x <= 32; -#else - return isspace( (uchar) x ); -#endif -} - -static TQCString qt_rmWS( const char *s ) -{ - TQCString result( tqstrlen(s)+1 ); - char *d = result.data(); - char last = 0; - while( *s && isSpace(*s) ) // skip leading space - s++; - while ( *s ) { - while ( *s && !isSpace(*s) ) - last = *d++ = *s++; - while ( *s && isSpace(*s) ) - s++; - if ( *s && isIdentChar(*s) && isIdentChar(last) ) - last = *d++ = ' '; - } - *d = '\0'; - result.truncate( (int)(d - result.data()) ); - int void_pos = result.find("(void)"); - if ( void_pos >= 0 ) - result.remove( void_pos+1, (uint)strlen("void") ); - return result; -} - - -// Event functions, implemented in qapplication_xxx.cpp - -int qStartTimer( int interval, TQObject *obj ); -bool qKillTimer( int id ); -bool qKillTimer( TQObject *obj ); - -static void removeObjFromList( TQObjectList *objList, const TQObject *obj, - bool single=FALSE ) -{ - if ( !objList ) { - return; - } - int index = objList->findRef( obj ); - while ( index >= 0 ) { - objList->remove(); - if ( single ) - return; - index = objList->findNextRef( obj ); - } -} - - -/*! - \relates TQObject - - Returns a pointer to the object named \a name that inherits \a - type and with a given \a parent. - - Returns 0 if there is no such child. - - \code - TQListBox *c = (TQListBox *) tqt_find_obj_child( myWidget, "TQListBox", - "my list box" ); - if ( c ) - c->insertItem( "another string" ); - \endcode -*/ - -void *tqt_find_obj_child( TQObject *parent, const char *type, const char *name ) -{ - const TQObjectList *list = parent->children(); - if ( list ) { - TQObjectListIt it( *list ); - TQObject *obj; - while ( (obj = it.current()) ) { - ++it; - if ( qstrcmp(name,obj->name()) == 0 && - obj->inherits(type) ) - return obj; - } - } - return 0; -} - -#ifdef TQT_THREAD_SUPPORT - -/*! - Returns a pointer to the TQThread* associated with - the current thread affinity of this object. - - \sa moveToThread() - */ - -TQThread* TQObject::contextThreadObject() const -{ - return d->ownThread; -} - -#endif - -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY -/* - Preliminary signal spy - */ -TQ_EXPORT TQObject* tqt_preliminary_signal_spy = 0; -static TQObject* qt_spy_signal_sender = 0; - -static void qt_spy_signal( TQObject* sender, int signal, TQUObject* o ) -{ - TQMetaObject* mo = sender->metaObject(); - while ( mo && signal - mo->signalOffset() < 0 ) - mo = mo->superClass(); - if ( !mo ) - return; - const TQMetaData* sigData = mo->signal( signal - mo->signalOffset() ); - if ( !sigData ) - return; - TQCString s; - mo = sender->metaObject(); - while ( mo ) { - s.sprintf( "%s_%s", mo->className(), sigData->name ); - int slot = tqt_preliminary_signal_spy->metaObject()->findSlot( s, TRUE ); - if ( slot >= 0 ) { -#ifdef TQT_THREAD_SUPPORT - // protect access to qt_spy_signal_sender - void * const address = &qt_spy_signal_sender; - TQMutexLocker locker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( address ) : 0 ); -#endif // TQT_THREAD_SUPPORT - - TQObject* old_sender = qt_spy_signal_sender; - qt_spy_signal_sender = sender; - tqt_preliminary_signal_spy->tqt_invoke( slot, o ); - qt_spy_signal_sender = old_sender; - break; - } - mo = mo->superClass(); - } -} - -/* - End Preliminary signal spy - */ -#endif // TQT_NO_PRELIMINARY_SIGNAL_SPY - -static TQObjectList* object_trees = 0; - -#ifdef TQT_THREAD_SUPPORT -static TQMutex *obj_trees_mutex = 0; -#endif - -static void cleanup_object_trees() -{ - delete object_trees; - object_trees = 0; -#ifdef TQT_THREAD_SUPPORT - delete obj_trees_mutex; - obj_trees_mutex = 0; -#endif -} - -static void ensure_object_trees() -{ - object_trees = new TQObjectList; - tqAddPostRoutine( cleanup_object_trees ); -} - -static void insert_tree( TQObject* obj ) -{ -#ifdef TQT_THREAD_SUPPORT - if ( !obj_trees_mutex ) - obj_trees_mutex = new TQMutex(); - TQMutexLocker locker( obj_trees_mutex ); -#endif - if ( !object_trees ) - ensure_object_trees(); - object_trees->insert(0, obj ); -} - -static void remove_tree( TQObject* obj ) -{ - if ( object_trees ) { -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( obj_trees_mutex ); -#endif - object_trees->removeRef( obj ); - } -} - -/*! \internal - TQt compatibility function -*/ -TQObjectList TQObject::childrenListObject() { - if (children()) return *(children()); - else return TQObjectList(); -} - -/*! \internal - TQt compatibility function -*/ -const TQObjectList TQObject::childrenListObject() const { - if (children()) return *(children()); - else return TQObjectList(); -} - -/*! \internal - TQt compatibility function -*/ -const TQObjectList TQObject::objectTreesListObject() { - if (objectTrees()) return *(objectTrees()); - else return TQObjectList(); -} - - -/***************************************************************************** - TQObject member functions - *****************************************************************************/ - -/*! - Constructs an object called \a name with parent object, \a parent. - - The parent of an object may be viewed as the object's owner. For - instance, a \link TQDialog dialog box\endlink is the parent of the - "OK" and "Cancel" buttons it contains. - - The destructor of a parent object destroys all child objects. - - Setting \a parent to 0 constructs an object with no parent. If the - object is a widget, it will become a top-level window. - - The object name is some text that can be used to identify a - TQObject. It's particularly useful in conjunction with \link - designer-manual.book TQt Designer\endlink. You can find an - object by name (and type) using child(). To find several objects - use queryList(). - - \sa parent(), name(), child(), queryList() -*/ - -TQObject::TQObject( TQObject *parent, const char *name ) - : - isSignal( FALSE ), // assume not a signal object - isWidget( FALSE ), // assume not a widget object - pendTimer( FALSE ), // no timers yet - blockSig( FALSE ), // not blocking signals - wasDeleted( FALSE ), // double-delete catcher - isTree( FALSE ), // no tree yet - objname( name ? tqstrdup(name) : 0 ), // set object name - parentObj( 0 ), // no parent yet. It is set by insertChild() - childObjects( 0 ), // no children yet - connections( 0 ), // no connections yet - senderObjects( 0 ), // no signals connected yet - eventFilters( 0 ), // no filters installed - postedEvents( 0 ), // no events posted - d( 0 ) -{ - if ( !d ) { - d = new TQObjectPrivate(0); - } - -#ifdef TQT_THREAD_SUPPORT - d->ownThread = TQThread::currentThreadObject(); - d->senderObjectListMutex = new TQMutex( TRUE ); - d->childObjectListMutex = new TQMutex( TRUE ); -#endif - if ( !metaObj ) { // will create object dict - (void) staticMetaObject(); - } - - if ( parent ) { // add object to parent - parent->insertChild( this ); - } - else { - insert_tree( this ); - isTree = TRUE; - } -} - - -/*! - Destroys the object, deleting all its child objects. - - All signals to and from the object are automatically disconnected. - - \warning All child objects are deleted. If any of these objects - are on the stack or global, sooner or later your program will - crash. We do not recommend holding pointers to child objects from - outside the parent. If you still do, the TQObject::destroyed() - signal gives you an opportunity to detect when an object is - destroyed. - - \warning Deleting a TQObject while pending events are waiting to be - delivered can cause a crash. You must not delete the TQObject - directly from a thread that is not the GUI thread. Use the - TQObject::deleteLater() method instead, which will cause the event - loop to delete the object after all pending events have been - delivered to the object. -*/ - -TQObject::~TQObject() -{ - if ( wasDeleted ) { -#if defined(QT_DEBUG) - tqWarning( "Double TQObject deletion detected." ); -#endif - return; - } - if (tqApp) { - TQEvent destroyEvent(TQEvent::Destroy); - tqApp->notify(this, &destroyEvent); - } - wasDeleted = 1; - blockSig = 0; // unblock signals to keep TQGuardedPtr happy - emit destroyed( this ); - emit destroyed(); - - if ( objname ) { - delete [] (char*)objname; - } - objname = 0; - if ( pendTimer ) { // might be pending timers - qKillTimer( this ); - } - TQApplication::removePostedEvents( this ); - if ( isTree ) { - remove_tree( this ); // remove from global root list - isTree = FALSE; - } - if ( parentObj ) // remove it from parent object - parentObj->removeChild( this ); - TQObject *obj; - if ( senderObjects ) { // disconnect from senders - TQSenderObjectList *tmp = senderObjects; - senderObjects = 0; - obj = tmp->first(); - while ( obj ) { // for all senders... - obj->disconnect( this ); - obj = tmp->next(); - } - if ( tmp->deref() ) - delete tmp; - } - if ( connections ) { // disconnect receivers - for ( int i = 0; i < (int) connections->size(); i++ ) { - TQConnectionList* clist = (*connections)[i]; // for each signal... - if ( !clist ) - continue; - TQConnection *c; - TQConnectionListIt cit(*clist); - while( (c=cit.current()) ) { // for each connected slot... - ++cit; - if ( (obj=c->object()) ) { - removeObjFromList( obj->senderObjects, this ); - } - } - } - delete connections; - connections = 0; - } - if ( eventFilters ) { - delete eventFilters; - eventFilters = 0; - } - if ( childObjects ) { // delete children objects - TQObjectListIt it(*childObjects); - while ( (obj=it.current()) ) { - ++it; - obj->parentObj = 0; - childObjects->removeRef( obj ); - delete obj; - } - delete childObjects; - } - -#ifdef TQT_THREAD_SUPPORT - delete d->childObjectListMutex; - delete d->senderObjectListMutex; -#endif // TQT_THREAD_SUPPORT - - delete d; -} - - -/*! - \fn TQMetaObject *TQObject::metaObject() const - - Returns a pointer to the meta object of this object. - - A meta object contains information about a class that inherits - TQObject, e.g. class name, superclass name, properties, signals and - slots. Every class that contains the TQ_OBJECT macro will also have - a meta object. - - The meta object information is required by the signal/slot - connection mechanism and the property system. The functions isA() - and inherits() also make use of the meta object. -*/ - -/*! - \fn const char *TQObject::className() const - - Returns the class name of this object. - - This function is generated by the \link metaobjects.html Meta - Object Compiler. \endlink - - \warning This function will return the wrong name if the class - definition lacks the TQ_OBJECT macro. - - \sa name(), inherits(), isA(), isWidgetType() -*/ - -/*! - Returns TRUE if this object is an instance of the class \a clname; - otherwise returns FALSE. - - Example: - \code - TQTimer *t = new TQTimer; // TQTimer inherits TQObject - t->isA( "TQTimer" ); // returns TRUE - t->isA( "TQObject" ); // returns FALSE - \endcode - - \sa inherits() metaObject() -*/ - -bool TQObject::isA( const char *clname ) const -{ - return qstrcmp( clname, className() ) == 0; -} - -/*! - Returns TRUE if this object is an instance of a class that - inherits \a clname, and \a clname inherits TQObject; otherwise - returns FALSE. - - A class is considered to inherit itself. - - Example: - \code - TQTimer *t = new TQTimer; // TQTimer inherits TQObject - t->inherits( "TQTimer" ); // returns TRUE - t->inherits( "TQObject" ); // returns TRUE - t->inherits( "TQButton" ); // returns FALSE - - // TQScrollBar inherits TQWidget and TQRangeControl - TQScrollBar *s = new TQScrollBar( 0 ); - s->inherits( "TQWidget" ); // returns TRUE - s->inherits( "TQRangeControl" ); // returns FALSE - \endcode - - (\l TQRangeControl is not a TQObject.) - - \sa isA(), metaObject() -*/ - -bool TQObject::inherits( const char *clname ) const -{ - return metaObject()->inherits( clname ); -} - -/*! - \internal - - Returns TRUE if \a object inherits \a superClass within - the meta object inheritance chain; otherwise returns FALSE. - - \sa inherits() -*/ -void *tqt_inheritedBy( TQMetaObject *superClass, const TQObject *object ) -{ - if (!object) - return 0; - TQMetaObject *mo = object->metaObject(); - while (mo) { - if (mo == superClass) - return (void*)object; - mo = mo->superClass(); - } - return 0; -} - -/*! - \property TQObject::name - - \brief the name of this object - - You can find an object by name (and type) using child(). You can - find a set of objects with queryList(). - - The object name is set by the constructor or by the setName() - function. The object name is not very useful in the current - version of TQt, but will become increasingly important in the - future. - - If the object does not have a name, the name() function returns - "unnamed", so printf() (used in tqDebug()) will not be asked to - output a null pointer. If you want a null pointer to be returned - for unnamed objects, you can call name( 0 ). - - \code - tqDebug( "MyClass::setPrecision(): (%s) invalid precision %f", - name(), newPrecision ); - \endcode - - \sa className(), child(), queryList() -*/ - -const char * TQObject::name() const -{ - // If you change the name here, the builder will be broken - return objname ? objname : "unnamed"; -} - -/*! - Sets the object's name to \a name. -*/ -void TQObject::setName( const char *name ) -{ - if ( objname ) - delete [] (char*) objname; - objname = name ? tqstrdup(name) : 0; -} - -/*! - \overload - - Returns the name of this object, or \a defaultName if the object - does not have a name. -*/ - -const char * TQObject::name( const char * defaultName ) const -{ - return objname ? objname : defaultName; -} - - -/*! - 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 retured; if you need all of - them, use queryList(). -*/ -TQObject* TQObject::child( const char *objName, const char *inheritsClass, - bool recursiveSearch ) -{ - const TQObjectList *list = children(); - if ( !list ) - return 0; - - bool onlyWidgets = ( inheritsClass && qstrcmp( inheritsClass, "TQWidget" ) == 0 ); - TQObjectListIt it( *list ); - TQObject *obj; - while ( ( obj = it.current() ) ) { - ++it; - if ( onlyWidgets ) { - if ( obj->isWidgetType() && ( !objName || qstrcmp( objName, obj->name() ) == 0 ) ) - break; - } else if ( ( !inheritsClass || obj->inherits(inheritsClass) ) && ( !objName || qstrcmp( objName, obj->name() ) == 0 ) ) - break; - if ( recursiveSearch && (obj = obj->child( objName, inheritsClass, recursiveSearch ) ) ) - break; - } - return obj; -} - -/*! \internal */ -TQUObject* deepCopyTQUObjectArray(TQUObject* origArray) -{ - TQUObject* newArray; - int count = 0; - while (!((origArray+count)->isLastObject)) { - count++; - } - count++; - newArray = (TQUObject*)malloc(sizeof(TQUObject)*count); - for (int i=0; ideepCopy(newArray+i); - } - return newArray; -} - -/*! \internal */ -void destroyDeepCopiedTQUObjectArray(TQUObject* uArray) -{ - int count = 0; - while (!((uArray+count)->isLastObject)) { - count++; - } - count++; - for (int i=0; i~TQUObject(); - } - free(uArray); -} - -/*! - \fn bool TQObject::isWidgetType() const - - Returns TRUE if the object is a widget; otherwise returns FALSE. - - Calling this function is equivalent to calling - inherits("TQWidget"), except that it is much faster. -*/ - -/*! - \fn bool TQObject::highPriority() const - - Returns TRUE if the object is a high-priority object, or FALSE if - it is a standard-priority object. - - High-priority objects are placed first in TQObject's list of - children on the assumption that they will be referenced very - often. -*/ - - -/*! - This virtual function receives events to an object and should - return TRUE if the event \a e was recognized and processed. - - The event() function can be reimplemented to customize the - behavior of an object. - - \sa installEventFilter(), timerEvent(), TQApplication::sendEvent(), - TQApplication::postEvent(), TQWidget::event() -*/ - -bool TQObject::event( TQEvent *e ) -{ -#if defined(QT_CHECK_NULL) - if ( e == 0 ) { - tqWarning( "TQObject::event: Null events are not permitted" ); - } -#endif - if ( wasDeleted ) { - return TRUE; - } - if ( eventFilters ) { // try filters - if ( activate_filters(e) ) { // stopped by a filter - return TRUE; - } - } - - switch ( e->type() ) { - case TQEvent::Timer: - timerEvent( (TQTimerEvent*)e ); - return TRUE; - - case TQEvent::ChildInserted: - case TQEvent::ChildRemoved: - childEvent( (TQChildEvent*)e ); - return TRUE; - - case TQEvent::DeferredDelete: - delete this; - return TRUE; - - case TQEvent::MetaCall: - { - TQMetaCallEvent* metaEvent = dynamic_cast(e); - if (metaEvent) { -#ifdef TQT_THREAD_SUPPORT - if ((d->disableThreadPostedEvents) - || (d->ownThread == TQThread::currentThreadObject())) -#endif // TQT_THREAD_SUPPORT - { - TQSenderObjectList* sol; - TQObject* oldSender = 0; - sol = senderObjects; -#ifdef TQT_THREAD_SUPPORT - sol->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - if ( sol ) { - oldSender = sol->currentSender; - sol->ref(); - sol->currentSender = metaEvent->sender(); - } -#ifdef TQT_THREAD_SUPPORT - sol->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - TQUObject *o = metaEvent->data(); - if (metaEvent->type() == TQMetaCallEvent::MetaCallEmit) { - tqt_emit( metaEvent->id(), o ); - } - if (metaEvent->type() == TQMetaCallEvent::MetaCallInvoke) { - tqt_invoke( metaEvent->id(), o ); - } -#ifdef TQT_THREAD_SUPPORT - sol->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - if (sol ) { - sol->currentSender = oldSender; - if ( sol->deref() ) { -#ifdef TQT_THREAD_SUPPORT - sol->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - delete sol; - sol = NULL; - } - } -#ifdef TQT_THREAD_SUPPORT - if (sol) sol->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - } -#ifdef TQT_THREAD_SUPPORT - else { - tqWarning("TQObject: Ignoring metacall event from non-owning thread"); - } -#endif // TQT_THREAD_SUPPORT - destroyDeepCopiedTQUObjectArray(metaEvent->data()); - } - } - - default: - if ( e->type() >= TQEvent::User ) { - customEvent( (TQCustomEvent*) e ); - return TRUE; - } - break; - } - return FALSE; -} - -/*! - This event handler can be reimplemented in a subclass to receive - timer events for the object. - - TQTimer provides a higher-level interface to the timer - functionality, and also more general information about timers. - - \sa startTimer(), killTimer(), killTimers(), event() -*/ - -void TQObject::timerEvent( TQTimerEvent * ) -{ -} - - -/*! - This event handler can be reimplemented in a subclass to receive - child events. - - Child events are sent to objects when children are inserted or - removed. - - Note that events with TQEvent::type() \c TQEvent::ChildInserted are - posted (with \l{TQApplication::postEvent()}) to make sure that the - child's construction is completed before this function is called. - - If a child is removed immediately after it is inserted, the \c - ChildInserted event may be suppressed, but the \c ChildRemoved - event will always be sent. In such cases it is possible that there - will be a \c ChildRemoved event without a corresponding \c - ChildInserted event. - - If you change state based on \c ChildInserted events, call - TQWidget::constPolish(), or do - \code - TQApplication::sendPostedEvents( this, TQEvent::ChildInserted ); - \endcode - in functions that depend on the state. One notable example is - TQWidget::sizeHint(). - - \sa event(), TQChildEvent -*/ - -void TQObject::childEvent( TQChildEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - custom events. Custom events are user-defined events with a type - value at least as large as the "User" item of the \l TQEvent::Type - enum, and is typically a TQCustomEvent or TQCustomEvent subclass. - - \sa event(), TQCustomEvent -*/ -void TQObject::customEvent( TQCustomEvent * ) -{ -} - - - -/*! - Filters events if this object has been installed as an event - filter for the \a watched object. - - In your reimplementation of this function, if you want to filter - the event \a e, out, i.e. stop it being handled further, return - TRUE; otherwise return FALSE. - - Example: - \code - class MyMainWindow : public TQMainWindow - { - public: - MyMainWindow( TQWidget *parent = 0, const char *name = 0 ); - - protected: - bool eventFilter( TQObject *obj, TQEvent *ev ); - - private: - TQTextEdit *textEdit; - }; - - MyMainWindow::MyMainWindow( TQWidget *parent, const char *name ) - : TQMainWindow( parent, name ) - { - textEdit = new TQTextEdit( this ); - setCentralWidget( textEdit ); - textEdit->installEventFilter( this ); - } - - bool MyMainWindow::eventFilter( TQObject *obj, TQEvent *ev ) - { - if ( obj == textEdit ) { - if ( e->type() == TQEvent::KeyPress ) { - TQKeyEvent *k = (TQKeyEvent*)ev; - tqDebug( "Ate key press %d", k->key() ); - return TRUE; - } else { - return FALSE; - } - } else { - // pass the event on to the parent class - return TQMainWindow::eventFilter( obj, ev ); - } - } - \endcode - - Notice in the example above that unhandled events are passed to - the base class's eventFilter() function, since the base class - might have reimplemented eventFilter() for its own internal - purposes. - - \warning If you delete the receiver object in this function, be - sure to return TRUE. Otherwise, TQt will forward the event to the - deleted object and the program might crash. - - \sa installEventFilter() -*/ - -bool TQObject::eventFilter( TQObject * /* watched */, TQEvent * /* e */ ) -{ - return FALSE; -} - - -/*! - \internal - Activates all event filters for this object. - This function is normally called from TQObject::event() or TQWidget::event(). -*/ - -bool TQObject::activate_filters( TQEvent *e ) -{ - if ( !eventFilters ) // no event filter - return FALSE; - TQObjectListIt it( *eventFilters ); - TQObject *obj = it.current(); - while ( obj ) { // send to all filters - ++it; // until one returns TRUE - if ( obj->eventFilter(this,e) ) { - return TRUE; - } - obj = it.current(); - } - return FALSE; // don't do anything with it -} - - -/*! - \fn bool TQObject::signalsBlocked() const - - Returns TRUE if signals are blocked; otherwise returns FALSE. - - Signals are not blocked by default. - - \sa blockSignals() -*/ - -/*! - Blocks signals if \a block is TRUE, or unblocks signals if \a - block is FALSE. - - Emitted signals disappear into hyperspace if signals are blocked. - Note that the destroyed() signals will be emitted even if the signals - for this object have been blocked. -*/ - -void TQObject::blockSignals( bool block ) -{ - blockSig = block; -} - - -// -// The timer flag hasTimer is set when startTimer is called. -// It is not reset when killing the timer because more than -// one timer might be active. -// - -/*! - Starts a timer and returns a timer identifier, or returns zero if - it could not start a timer. - - A timer event will occur every \a interval milliseconds until - killTimer() or killTimers() is called. If \a interval is 0, then - the timer event occurs once every time there are no more window - system events to process. - - The virtual timerEvent() function is called with the TQTimerEvent - event parameter class when a timer event occurs. Reimplement this - function to get timer events. - - If multiple timers are running, the TQTimerEvent::timerId() can be - used to find out which timer was activated. - - Example: - \code - class MyObject : public TQObject - { - TQ_OBJECT - public: - MyObject( TQObject *parent = 0, const char *name = 0 ); - - protected: - void timerEvent( TQTimerEvent * ); - }; - - MyObject::MyObject( TQObject *parent, const char *name ) - : TQObject( parent, name ) - { - startTimer( 50 ); // 50-millisecond timer - startTimer( 1000 ); // 1-second timer - startTimer( 60000 ); // 1-minute timer - } - - void MyObject::timerEvent( TQTimerEvent *e ) - { - tqDebug( "timer event, id %d", e->timerId() ); - } - \endcode - - Note that TQTimer's accuracy depends on the underlying operating - system and hardware. Most platforms support an accuracy of 20 ms; - some provide more. If TQt is unable to deliver the requested - number of timer clicks, it will silently discard some. - - The TQTimer class provides a high-level programming interface with - one-shot timers and timer signals instead of events. - - \sa timerEvent(), killTimer(), killTimers(), TQEventLoop::awake(), - TQEventLoop::aboutToBlock() -*/ - -int TQObject::startTimer( int interval ) -{ - pendTimer = TRUE; // set timer flag - return qStartTimer( interval, (TQObject *)this ); -} - -/*! - Kills the timer with timer identifier, \a id. - - The timer identifier is returned by startTimer() when a timer - event is started. - - \sa timerEvent(), startTimer(), killTimers() -*/ - -void TQObject::killTimer( int id ) -{ - qKillTimer( id ); -} - -/*! - Kills all timers that this object has started. - - \warning Using this function can cause hard-to-find bugs: it kills - timers started by sub- and superclasses as well as those started - by you, which is often not what you want. We recommend using a - TQTimer or perhaps killTimer(). - - \sa timerEvent(), startTimer(), killTimer() -*/ - -void TQObject::killTimers() -{ - qKillTimer( this ); -} - -static void objSearch( TQObjectList *result, - TQObjectList *list, - const char *inheritsClass, - bool onlyWidgets, - const char *objName, - TQRegExp *rx, - bool recurse ) -{ - if ( !list || list->isEmpty() ) // nothing to search - return; - TQObject *obj = list->first(); - while ( obj ) { - bool ok = TRUE; - if ( onlyWidgets ) - ok = obj->isWidgetType(); - else if ( inheritsClass && !obj->inherits(inheritsClass) ) - ok = FALSE; - if ( ok ) { - if ( objName ) - ok = ( qstrcmp(objName,obj->name()) == 0 ); -#ifndef TQT_NO_REGEXP - else if ( rx ) - ok = ( rx->search(TQString::fromLatin1(obj->name())) != -1 ); -#endif - } - if ( ok ) // match! - result->append( obj ); - if ( recurse && obj->children() ) - objSearch( result, (TQObjectList *)obj->children(), inheritsClass, - onlyWidgets, objName, rx, recurse ); - obj = list->next(); - } -} - -/*! - \fn TQObject *TQObject::parent() const - - Returns a pointer to the parent object. - - \sa children() -*/ - -/*! - \fn const TQObjectList *TQObject::children() const - - Returns a list of child objects, or 0 if this object has no - children. - - The TQObjectList class is defined in the \c ntqobjectlist.h header - file. - - The first child added is the \link TQPtrList::first() first\endlink - object in the list and the last child added is the \link - TQPtrList::last() last\endlink object in the list, i.e. new - children are appended at the end. - - Note that the list order changes when TQWidget children are \link - TQWidget::raise() raised\endlink or \link TQWidget::lower() - lowered.\endlink A widget that is raised becomes the last object - in the list, and a widget that is lowered becomes the first object - in the list. - - \sa child(), queryList(), parent(), insertChild(), removeChild() -*/ - - -/*! - Returns a pointer to the list of all object trees (their root - objects), or 0 if there are no objects. - - The TQObjectList class is defined in the \c ntqobjectlist.h header - file. - - The most recent root object created is the \link TQPtrList::first() - first\endlink object in the list and the first root object added - is the \link TQPtrList::last() last\endlink object in the list. - - \sa children(), parent(), insertChild(), removeChild() -*/ -const TQObjectList *TQObject::objectTrees() -{ - return object_trees; -} - - -/*! - 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 TQRegExp. 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 TQObject, - the way inherits() does. According to inherits(), TQMenuBar - inherits TQWidget but not TQMenuData. This does not quite match - reality, but is the best that can be done on the wide variety of - compilers TQt 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: - \code - TQObjectList *l = topLevelWidget()->queryList( "TQButton" ); - TQObjectListIt it( *l ); // iterate over the buttons - TQObject *obj; - - while ( (obj = it.current()) != 0 ) { - // for each found object... - ++it; - ((TQButton*)obj)->setEnabled( FALSE ); - } - delete l; // delete the list, not the objects - \endcode - - The TQObjectList class is defined in the \c ntqobjectlist.h header - file. - - \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(), name(), TQRegExp -*/ - -TQObjectList *TQObject::queryList( const char *inheritsClass, - const char *objName, - bool regexpMatch, - bool recursiveSearch ) const -{ - TQObjectList *list = new TQObjectList; - TQ_CHECK_PTR( list ); - bool onlyWidgets = ( inheritsClass && qstrcmp(inheritsClass, "TQWidget") == 0 ); -#ifndef TQT_NO_REGEXP - if ( regexpMatch && objName ) { // regexp matching - TQRegExp rx(TQString::fromLatin1(objName)); - objSearch( list, (TQObjectList *)children(), inheritsClass, onlyWidgets, - 0, &rx, recursiveSearch ); - } else -#endif - { - objSearch( list, (TQObjectList *)children(), inheritsClass, onlyWidgets, - objName, 0, recursiveSearch ); - } - return list; -} - -/*! \internal - - Returns a list of objects/slot pairs that are connected to the - \a signal, or 0 if nothing is connected to it. -*/ - -TQConnectionList *TQObject::receivers( const char* signal ) const -{ - if ( connections && signal ) { - if ( *signal == '2' ) { // tag == 2, i.e. signal - TQCString s = qt_rmWS( signal+1 ); - return receivers( metaObject()->findSignal( (const char*)s, TRUE ) ); - } else { - return receivers( metaObject()->findSignal(signal, TRUE ) ); - } - } - return 0; -} - -/*! \internal - - Returns a list of objects/slot pairs that are connected to the - signal, or 0 if nothing is connected to it. -*/ - -TQConnectionList *TQObject::receivers( int signal ) const -{ -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( tqt_preliminary_signal_spy && signal >= 0 ) { - if ( !connections ) { - TQObject* that = (TQObject*) this; - that->connections = new TQSignalVec( signal+1 ); - that->connections->setAutoDelete( TRUE ); - } - if ( !connections->at( signal ) ) { - TQConnectionList* clist = new TQConnectionList; - clist->setAutoDelete( TRUE ); - connections->insert( signal, clist ); - return clist; - } - } -#endif - if ( connections && signal >= 0 ) - return connections->at( signal ); - return 0; -} - - -/*! - Inserts an object \a obj into the list of child objects. - - \warning This function cannot be used to make one widget the child - widget of another widget. Child widgets can only be created by - setting the parent widget in the constructor or by calling - TQWidget::reparent(). - - \sa removeChild(), TQWidget::reparent() -*/ - -void TQObject::insertChild( TQObject *obj ) -{ -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( d->childObjectListMutex ); -#endif // TQT_THREAD_SUPPORT - - if ( obj->isTree ) { - remove_tree( obj ); - obj->isTree = FALSE; - } - if ( obj->parentObj && obj->parentObj != this ) { -#if defined(QT_CHECK_STATE) - if ( obj->parentObj != this && obj->isWidgetType() ) - tqWarning( "TQObject::insertChild: Cannot reparent a widget, " - "use TQWidget::reparent() instead" ); -#endif - obj->parentObj->removeChild( obj ); - } - - if ( !childObjects ) { - childObjects = new TQObjectList; - TQ_CHECK_PTR( childObjects ); - } else if ( obj->parentObj == this ) { -#if defined(QT_CHECK_STATE) - tqWarning( "TQObject::insertChild: Object %s::%s already in list", - obj->className(), obj->name( "unnamed" ) ); -#endif - return; - } - obj->parentObj = this; - childObjects->append( obj ); - - TQChildEvent *e = new TQChildEvent( TQEvent::ChildInserted, obj ); - TQApplication::postEvent( this, e ); -} - -/*! - Removes the child object \a obj from the list of children. - - \warning This function will not remove a child widget from the - screen. It will only remove it from the parent widget's list of - children. - - \sa insertChild(), TQWidget::reparent() -*/ - -void TQObject::removeChild( TQObject *obj ) -{ -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( d->childObjectListMutex ); -#endif // TQT_THREAD_SUPPORT - - if ( childObjects && childObjects->removeRef(obj) ) { - obj->parentObj = 0; - if ( !obj->wasDeleted ) { - insert_tree( obj ); // it's a root object now - obj->isTree = TRUE; - } - if ( childObjects->isEmpty() ) { - delete childObjects; // last child removed - childObjects = 0; // reset children list - } - - // remove events must be sent, not posted!!! - TQChildEvent ce( TQEvent::ChildRemoved, obj ); - TQApplication::sendEvent( this, &ce ); - } -} - - -/*! - \fn void TQObject::installEventFilter( const TQObject *filterObj ) - - Installs an event filter \a filterObj on this object. For example: - \code - monitoredObj->installEventFilter( filterObj ); - \endcode - - An event filter is an object that receives all events that are - sent to this object. The filter can either stop the event or - forward it to this object. The event filter \a filterObj receives - events via its eventFilter() function. The eventFilter() function - must return TRUE if the event should be filtered, (i.e. stopped); - otherwise it must return FALSE. - - If multiple event filters are installed on a single object, the - filter that was installed last is activated first. - - Here's a \c KeyPressEater class that eats the key presses of its - monitored objects: - \code - class KeyPressEater : public TQObject - { - ... - protected: - bool eventFilter( TQObject *o, TQEvent *e ); - }; - - bool KeyPressEater::eventFilter( TQObject *o, TQEvent *e ) - { - if ( e->type() == TQEvent::KeyPress ) { - // special processing for key press - TQKeyEvent *k = (TQKeyEvent *)e; - tqDebug( "Ate key press %d", k->key() ); - return TRUE; // eat event - } else { - // standard event processing - return FALSE; - } - } - \endcode - - And here's how to install it on two widgets: - \code - KeyPressEater *keyPressEater = new KeyPressEater( this ); - TQPushButton *pushButton = new TQPushButton( this ); - TQListView *listView = new TQListView( this ); - - pushButton->installEventFilter( keyPressEater ); - listView->installEventFilter( keyPressEater ); - \endcode - - The TQAccel class, for example, uses this technique to intercept - accelerator key presses. - - \warning If you delete the receiver object in your eventFilter() - function, be sure to return TRUE. If you return FALSE, TQt sends - the event to the deleted object and the program will crash. - - \sa removeEventFilter(), eventFilter(), event() -*/ - -void TQObject::installEventFilter( const TQObject *obj ) -{ - if ( !obj ) - return; - if ( eventFilters ) { - int c = eventFilters->findRef( obj ); - if ( c >= 0 ) - eventFilters->take( c ); - disconnect( obj, TQ_SIGNAL(destroyed(TQObject*)), - this, TQ_SLOT(cleanupEventFilter(TQObject*)) ); - } else { - eventFilters = new TQObjectList; - TQ_CHECK_PTR( eventFilters ); - } - eventFilters->insert( 0, obj ); - connect( obj, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(cleanupEventFilter(TQObject*)) ); -} - -/*! - Removes an event filter object \a obj from this object. The - request is ignored if such an event filter has not been installed. - - All event filters for this object are automatically removed when - this object is destroyed. - - It is always safe to remove an event filter, even during event - filter activation (i.e. from the eventFilter() function). - - \sa installEventFilter(), eventFilter(), event() -*/ - -void TQObject::removeEventFilter( const TQObject *obj ) -{ - if ( eventFilters && eventFilters->removeRef(obj) ) { - if ( eventFilters->isEmpty() ) { // last event filter removed - delete eventFilters; - eventFilters = 0; // reset event filter list - } - disconnect( obj, TQ_SIGNAL(destroyed(TQObject*)), - this, TQ_SLOT(cleanupEventFilter(TQObject*)) ); - } -} - - -/***************************************************************************** - Signal connection management - *****************************************************************************/ - -#if defined(QT_CHECK_RANGE) - -static bool check_signal_macro( const TQObject *sender, const char *signal, - const char *func, const char *op ) -{ - int sigcode = (int)(*signal) - '0'; - if ( sigcode != TQ_SIGNAL_CODE ) { - if ( sigcode == TQ_SLOT_CODE ) - tqWarning( "TQObject::%s: Attempt to %s non-signal %s::%s", - func, op, sender->className(), signal+1 ); - else - tqWarning( "TQObject::%s: Use the TQ_SIGNAL macro to %s %s::%s", - func, op, sender->className(), signal ); - return FALSE; - } - return TRUE; -} - -static bool check_member_code( int code, const TQObject *object, - const char *member, const char *func ) -{ - if ( code != TQ_SLOT_CODE && code != TQ_SIGNAL_CODE ) { - tqWarning( "TQObject::%s: Use the TQ_SLOT or TQ_SIGNAL macro to " - "%s %s::%s", func, func, object->className(), member ); - return FALSE; - } - return TRUE; -} - -static void err_member_notfound( int code, const TQObject *object, - const char *member, const char *func ) -{ - const char *type = 0; - switch ( code ) { - case TQ_SLOT_CODE: type = "slot"; break; - case TQ_SIGNAL_CODE: type = "signal"; break; - } - if ( strchr(member,')') == 0 ) // common typing mistake - tqWarning( "TQObject::%s: Parentheses expected, %s %s::%s", - func, type, object->className(), member ); - else - tqWarning( "TQObject::%s: No such %s %s::%s", - func, type, object->className(), member ); -} - - -static void err_info_about_objects( const char * func, - const TQObject * sender, - const TQObject * receiver ) -{ - const char * a = sender->name(), * b = receiver->name(); - if ( a ) - tqWarning( "TQObject::%s: (sender name: '%s')", func, a ); - if ( b ) - tqWarning( "TQObject::%s: (receiver name: '%s')", func, b ); -} - -static void err_info_about_candidates( int code, - const TQMetaObject* mo, - const char* member, - const char *func ) -{ - if ( strstr(member,"const char*") ) { - // porting help - TQCString newname = member; - int p; - while ( (p=newname.find("const char*")) >= 0 ) { - newname.replace(p, 11, "const TQString&"); - } - const TQMetaData *rm = 0; - switch ( code ) { - case TQ_SLOT_CODE: - rm = mo->slot( mo->findSlot( newname, TRUE ), TRUE ); - break; - case TQ_SIGNAL_CODE: - rm = mo->signal( mo->findSignal( newname, TRUE ), TRUE ); - break; - } - if ( rm ) { - tqWarning("TQObject::%s: Candidate: %s", func, newname.data()); - } - } -} - - -#endif // QT_CHECK_RANGE - - -/*! - Returns a pointer to the object that sent the signal, if called in - a slot activated by a signal; otherwise it returns 0. The pointer - is valid only during the execution of the slot that calls this - function. - - The pointer returned by this function becomes invalid if the - sender is destroyed, or if the slot is disconnected from the - sender's signal. - - \warning This function violates the object-oriented principle of - modularity. However, getting access to the sender might be useful - when many signals are connected to a single slot. The sender is - undefined if the slot is called as a normal C++ function. -*/ - -const TQObject *TQObject::sender() -{ -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( this == tqt_preliminary_signal_spy ) { -# ifdef TQT_THREAD_SUPPORT - // protect access to qt_spy_signal_sender - void * const address = &qt_spy_signal_sender; - TQMutexLocker locker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( address ) : 0 ); -# endif // TQT_THREAD_SUPPORT - return qt_spy_signal_sender; - } -#endif - if ( senderObjects && - senderObjects->currentSender && - /* - * currentSender may be a dangling pointer in case the object - * it was pointing to was destructed from inside a slot. Thus - * verify it still is contained inside the senderObjects list - * which gets cleaned on both destruction and disconnect. - */ - - senderObjects->findRef( senderObjects->currentSender ) != -1 ) - return senderObjects->currentSender; - return 0; -} - - -/*! - \fn void TQObject::connectNotify( const char *signal ) - - This virtual function is called when something has been connected - to \a signal in this object. - - \warning This function violates the object-oriented principle of - modularity. However, it might be useful when you need to perform - expensive initialization only if something is connected to a - signal. - - \sa connect(), disconnectNotify() -*/ - -void TQObject::connectNotify( const char * ) -{ -} - -/*! - \fn void TQObject::disconnectNotify( const char *signal ) - - This virtual function is called when something has been - disconnected from \a signal in this object. - - \warning This function violates the object-oriented principle of - modularity. However, it might be useful for optimizing access to - expensive resources. - - \sa disconnect(), connectNotify() -*/ - -void TQObject::disconnectNotify( const char * ) -{ -} - - -/*! - \fn bool TQObject::checkConnectArgs( const char *signal, const TQObject *receiver, const char *member ) - - Returns TRUE if the \a signal and the \a member arguments are - compatible; otherwise returns FALSE. (The \a receiver argument is - currently ignored.) - - \warning We recommend that you use the default implementation and - do not reimplement this function. - - \omit - TRUE: "signal()", "member()" - TRUE: "signal(a,b,c)", "member(a,b,c)" - TRUE: "signal(a,b,c)", "member(a,b)", "member(a)" etc. - FALSE: "signal(const a)", "member(a)" - FALSE: "signal(a)", "member(const a)" - FALSE: "signal(a)", "member(b)" - FALSE: "signal(a)", "member(a,b)" - \endomit -*/ - -bool TQObject::checkConnectArgs( const char *signal, - const TQObject *, - const char *member ) -{ - const char *s1 = signal; - const char *s2 = member; - while ( *s1++ != '(' ) { } // scan to first '(' - while ( *s2++ != '(' ) { } - if ( *s2 == ')' || qstrcmp(s1,s2) == 0 ) // member has no args or - return TRUE; // exact match - int s1len = tqstrlen(s1); - int s2len = tqstrlen(s2); - if ( s2len < s1len && tqstrncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==',' ) - return TRUE; // member has less args - return FALSE; -} - -/*! - Normlizes the signal or slot definition \a signalSlot by removing - unnecessary whitespace. -*/ - -TQCString TQObject::normalizeSignalSlot( const char *signalSlot ) -{ - if ( !signalSlot ) - return TQCString(); - return qt_rmWS( signalSlot ); -} - - - -/*! - \overload bool TQObject::connect( const TQObject *sender, const char *signal, const char *member ) const - - Connects \a signal from the \a sender object to this object's \a - member. - - Equivalent to: \c{TQObject::connect(sender, signal, this, member)}. - - \sa disconnect() -*/ - -/*! - Connects \a signal from the \a sender object to \a member in object - \a receiver, and returns TRUE if the connection succeeds; otherwise - returns FALSE. - - You must use the TQ_SIGNAL() and TQ_SLOT() macros when specifying the \a signal - and the \a member, for example: - \code - TQLabel *label = new TQLabel; - TQScrollBar *scroll = new TQScrollBar; - TQObject::connect( scroll, TQ_SIGNAL(valueChanged(int)), - label, TQ_SLOT(setNum(int)) ); - \endcode - - This example ensures that the label always displays the current - scroll bar value. Note that the signal and slots parameters must not - contain any variable names, only the type. E.g. the following would - not work and return FALSE: - TQObject::connect( scroll, TQ_SIGNAL(valueChanged(int v)), - label, TQ_SLOT(setNum(int v)) ); - - A signal can also be connected to another signal: - - \code - class MyWidget : public TQWidget - { - TQ_OBJECT - public: - MyWidget(); - - signals: - void myUsefulSignal(); - - private: - TQPushButton *aButton; - }; - - MyWidget::MyWidget() - { - aButton = new TQPushButton( this ); - connect( aButton, TQ_SIGNAL(clicked()), TQ_SIGNAL(myUsefulSignal()) ); - } - \endcode - - In this example, the MyWidget constructor relays a signal from a - private member variable, and makes it available under a name that - relates to MyWidget. - - A signal can be connected to many slots and signals. Many signals - can be connected to one slot. - - If a signal is connected to several slots, the slots are activated - in an arbitrary order when the signal is emitted. - - The function returns TRUE if it successfully connects the signal - to the slot. It will return FALSE if it cannot create the - connection, for example, if TQObject is unable to verify the - existence of either \a signal or \a member, or if their signatures - aren't compatible. - - A signal is emitted for \e{every} connection you make, so if you - duplicate a connection, two signals will be emitted. You can - always break a connection using \c{disconnect()}. - - \sa disconnect() -*/ - -bool TQObject::connect( const TQObject *sender, const char *signal, - const TQObject *receiver, const char *member ) -{ -#if defined(QT_CHECK_NULL) - if ( sender == 0 || receiver == 0 || signal == 0 || member == 0 ) { - tqWarning( "TQObject::connect: Cannot connect %s::%s to %s::%s", - sender ? sender->className() : "(null)", - signal ? signal+1 : "(null)", - receiver ? receiver->className() : "(null)", - member ? member+1 : "(null)" ); - return FALSE; - } -#endif - TQMetaObject *smeta = sender->metaObject(); - -#if defined(QT_CHECK_RANGE) - if ( !check_signal_macro( sender, signal, "connect", "bind" ) ) - return FALSE; -#endif - TQCString nw_signal(signal); // Assume already normalized - ++signal; // skip member type code - - int signal_index = smeta->findSignal( signal, TRUE ); - if ( signal_index < 0 ) { // normalize and retry - nw_signal = qt_rmWS( signal-1 ); // remove whitespace - signal = nw_signal.data()+1; // skip member type code - signal_index = smeta->findSignal( signal, TRUE ); - } - - if ( signal_index < 0 ) { // no such signal -#if defined(QT_CHECK_RANGE) - err_member_notfound( TQ_SIGNAL_CODE, sender, signal, "connect" ); - err_info_about_candidates( TQ_SIGNAL_CODE, smeta, signal, "connect" ); - err_info_about_objects( "connect", sender, receiver ); -#endif - return FALSE; - } - const TQMetaData *sm = smeta->signal( signal_index, TRUE ); - signal = sm->name; // use name from meta object - - int membcode = member[0] - '0'; // get member code - - TQObject *s = (TQObject *)sender; // we need to change them - TQObject *r = (TQObject *)receiver; // internally - -#if defined(QT_CHECK_RANGE) - if ( !check_member_code( membcode, r, member, "connect" ) ) - return FALSE; -#endif - member++; // skip code - - TQCString nw_member ; - TQMetaObject *rmeta = r->metaObject(); - int member_index = -1; - switch ( membcode ) { // get receiver member - case TQ_SLOT_CODE: - member_index = rmeta->findSlot( member, TRUE ); - if ( member_index < 0 ) { // normalize and retry - nw_member = qt_rmWS(member); // remove whitespace - member = nw_member; - member_index = rmeta->findSlot( member, TRUE ); - } - break; - case TQ_SIGNAL_CODE: - member_index = rmeta->findSignal( member, TRUE ); - if ( member_index < 0 ) { // normalize and retry - nw_member = qt_rmWS(member); // remove whitespace - member = nw_member; - member_index = rmeta->findSignal( member, TRUE ); - } - break; - } - if ( member_index < 0 ) { -#if defined(QT_CHECK_RANGE) - err_member_notfound( membcode, r, member, "connect" ); - err_info_about_candidates( membcode, rmeta, member, "connect" ); - err_info_about_objects( "connect", sender, receiver ); -#endif - return FALSE; - } -#if defined(QT_CHECK_RANGE) - if ( !s->checkConnectArgs(signal,receiver,member) ) { - tqWarning( "TQObject::connect: Incompatible sender/receiver arguments" - "\n\t%s::%s --> %s::%s", - s->className(), signal, - r->className(), member ); - return FALSE; - } else { - const TQMetaData *rm = membcode == TQ_SLOT_CODE ? - rmeta->slot( member_index, TRUE ) : - rmeta->signal( member_index, TRUE ); - if ( rm ) { - int si = 0; - int ri = 0; - while ( si < sm->method->count && ri < rm->method->count ) { - if ( sm->method->parameters[si].inOut == TQUParameter::Out ) - si++; - else if ( rm->method->parameters[ri].inOut == TQUParameter::Out ) - ri++; - else if ( !TQUType::isEqual( sm->method->parameters[si++].type, - rm->method->parameters[ri++].type ) ) { - if ( ( TQUType::isEqual( sm->method->parameters[si-1].type, &static_QUType_ptr ) - && TQUType::isEqual( rm->method->parameters[ri-1].type, &static_QUType_varptr ) ) - || ( TQUType::isEqual( sm->method->parameters[si-1].type, &static_QUType_varptr ) - && TQUType::isEqual( rm->method->parameters[ri-1].type, &static_QUType_ptr ) ) ) - continue; // varptr got introduced in 3.1 and is binary compatible with ptr - tqWarning( "TQObject::connect: Incompatible sender/receiver marshalling" - "\n\t%s::%s --> %s::%s", - s->className(), signal, - r->className(), member ); - return FALSE; - } - } - } - } -#endif - connectInternal( sender, signal_index, receiver, membcode, member_index ); - s->connectNotify( nw_signal ); - return TRUE; -} - -/*! \internal */ - -void TQObject::connectInternal( const TQObject *sender, int signal_index, const TQObject *receiver, - int membcode, int member_index ) -{ - TQObject *s = (TQObject*)sender; - TQObject *r = (TQObject*)receiver; - - if ( !s->connections ) { // create connections lookup table - s->connections = new TQSignalVec( signal_index+1 ); - TQ_CHECK_PTR( s->connections ); - s->connections->setAutoDelete( TRUE ); - } - - TQConnectionList *clist = s->connections->at( signal_index ); - if ( !clist ) { // create receiver list - clist = new TQConnectionList; - TQ_CHECK_PTR( clist ); - clist->setAutoDelete( TRUE ); - s->connections->insert( signal_index, clist ); - } - - TQMetaObject *rmeta = r->metaObject(); - const TQMetaData *rm = 0; - - switch ( membcode ) { // get receiver member - case TQ_SLOT_CODE: - rm = rmeta->slot( member_index, TRUE ); - break; - case TQ_SIGNAL_CODE: - rm = rmeta->signal( member_index, TRUE ); - break; - } - - TQConnection *c = new TQConnection( r, member_index, rm ? rm->name : "qt_invoke", membcode ); - TQ_CHECK_PTR( c ); - clist->append( c ); - if ( !r->senderObjects ) { // create list of senders -#ifdef TQT_THREAD_SUPPORT - r->d->senderObjectListMutex->lock(); -#endif // TQT_THREAD_SUPPORT - r->senderObjects = new TQSenderObjectList; -#ifdef TQT_THREAD_SUPPORT - r->senderObjects->listMutex->lock(); - r->d->senderObjectListMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - } - else { -#ifdef TQT_THREAD_SUPPORT - r->senderObjects->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - } - r->senderObjects->append( s ); // add sender to list -#ifdef TQT_THREAD_SUPPORT - r->senderObjects->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT -} - - -/*! - \overload bool TQObject::disconnect( const char *signal, const TQObject *receiver, const char *member ) - - Disconnects \a signal from \a member of \a receiver. - - A signal-slot connection is removed when either of the objects - involved are destroyed. -*/ - -/*! - \overload bool TQObject::disconnect( const TQObject *receiver, const char *member ) - - Disconnects all signals in this object from \a receiver's \a - member. - - A signal-slot connection is removed when either of the objects - involved are destroyed. -*/ - -/*! - Disconnects \a signal in object \a sender from \a member in object - \a receiver. - - A signal-slot connection is removed when either of the objects - involved are destroyed. - - disconnect() is typically used in three ways, as the following - examples demonstrate. - \list 1 - \i Disconnect everything connected to an object's signals: - \code - disconnect( myObject, 0, 0, 0 ); - \endcode - equivalent to the non-static overloaded function - \code - myObject->disconnect(); - \endcode - \i Disconnect everything connected to a specific signal: - \code - disconnect( myObject, TQ_SIGNAL(mySignal()), 0, 0 ); - \endcode - equivalent to the non-static overloaded function - \code - myObject->disconnect( TQ_SIGNAL(mySignal()) ); - \endcode - \i Disconnect a specific receiver: - \code - disconnect( myObject, 0, myReceiver, 0 ); - \endcode - equivalent to the non-static overloaded function - \code - myObject->disconnect( myReceiver ); - \endcode - \endlist - - 0 may be used as a wildcard, meaning "any signal", "any receiving - object", or "any slot in the receiving object", respectively. - - The \a sender may never be 0. (You cannot disconnect signals from - more than one object in a single call.) - - If \a signal is 0, it disconnects \a receiver and \a member from - any signal. If not, only the specified signal is disconnected. - - If \a receiver is 0, it disconnects anything connected to \a - signal. If not, slots in objects other than \a receiver are not - disconnected. - - If \a member is 0, it disconnects anything that is connected to \a - receiver. If not, only slots named \a member will be disconnected, - and all other slots are left alone. The \a member must be 0 if \a - receiver is left out, so you cannot disconnect a - specifically-named slot on all objects. - - \sa connect() -*/ - -bool TQObject::disconnect( const TQObject *sender, const char *signal, - const TQObject *receiver, const char *member ) -{ -#if defined(QT_CHECK_NULL) - if ( sender == 0 || (receiver == 0 && member != 0) ) { - tqWarning( "TQObject::disconnect: Unexpected null parameter" ); - return FALSE; - } -#endif - if ( !sender->connections ) // no connected signals - return FALSE; - TQObject *s = (TQObject *)sender; - TQObject *r = (TQObject *)receiver; - int member_index = -1; - int membcode = -1; - TQCString nw_member; - if ( member ) { - membcode = member[0] - '0'; -#if defined(QT_CHECK_RANGE) - if ( !check_member_code( membcode, r, member, "disconnect" ) ) - return FALSE; -#endif - ++member; - TQMetaObject *rmeta = r->metaObject(); - - switch ( membcode ) { // get receiver member - case TQ_SLOT_CODE: - member_index = rmeta->findSlot( member, TRUE ); - if ( member_index < 0 ) { // normalize and retry - nw_member = qt_rmWS(member); // remove whitespace - member = nw_member; - member_index = rmeta->findSlot( member, TRUE ); - } - break; - case TQ_SIGNAL_CODE: - member_index = rmeta->findSignal( member, TRUE ); - if ( member_index < 0 ) { // normalize and retry - nw_member = qt_rmWS(member); // remove whitespace - member = nw_member; - member_index = rmeta->findSignal( member, TRUE ); - } - break; - } - if ( member_index < 0 ) { // no such member -#if defined(QT_CHECK_RANGE) - err_member_notfound( membcode, r, member, "disconnect" ); - err_info_about_candidates( membcode, rmeta, member, "connect" ); - err_info_about_objects( "disconnect", sender, receiver ); -#endif - return FALSE; - } - } - - if ( signal == 0 ) { // any/all signals - if ( disconnectInternal( s, -1, r, membcode, member_index ) ) - s->disconnectNotify( 0 ); - else - return FALSE; - } else { // specific signal -#if defined(QT_CHECK_RANGE) - if ( !check_signal_macro( s, signal, "disconnect", "unbind" ) ) - return FALSE; -#endif - TQCString nw_signal(signal); // Assume already normalized - ++signal; // skip member type code - - TQMetaObject *smeta = s->metaObject(); - if ( !smeta ) // no meta object - return FALSE; - int signal_index = smeta->findSignal( signal, TRUE ); - if ( signal_index < 0 ) { // normalize and retry - nw_signal = qt_rmWS( signal-1 ); // remove whitespace - signal = nw_signal.data()+1; // skip member type code - signal_index = smeta->findSignal( signal, TRUE ); - } - if ( signal_index < 0 ) { -#if defined(QT_CHECK_RANGE) - tqWarning( "TQObject::disconnect: No such signal %s::%s", - s->className(), signal ); -#endif - return FALSE; - } - - /* compatibility and safety: If a receiver has several slots - * with the same name, disconnect them all*/ - bool res = FALSE; - if ( membcode == TQ_SLOT_CODE && r ) { - TQMetaObject * rmeta = r->metaObject(); - do { - int mi = rmeta->findSlot( member ); - if ( mi != -1 ) - res |= disconnectInternal( s, signal_index, r, membcode, mi ); - } while ( (rmeta = rmeta->superClass()) ); - } else { - res = disconnectInternal( s, signal_index, r, membcode, member_index ); - } - if ( res ) - s->disconnectNotify( nw_signal ); - return res; - } - return TRUE; -} - -/*! \internal */ - -bool TQObject::disconnectInternal( const TQObject *sender, int signal_index, - const TQObject *receiver, int membcode, int member_index ) -{ - TQObject *s = (TQObject*)sender; - TQObject *r = (TQObject*)receiver; - - if ( !s->connections ) - return FALSE; - - bool success = FALSE; - TQConnectionList *clist; - TQConnection *c; - if ( signal_index == -1 ) { - for ( int i = 0; i < (int) s->connections->size(); i++ ) { - clist = (*s->connections)[i]; // for all signals... - if ( !clist ) - continue; - c = clist->first(); - while ( c ) { // for all receivers... - if ( r == 0 ) { // remove all receivers -#ifdef TQT_THREAD_SUPPORT - if (c->object()->senderObjects) c->object()->senderObjects->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - removeObjFromList( c->object()->senderObjects, s ); -#ifdef TQT_THREAD_SUPPORT - if (c->object()->senderObjects) c->object()->senderObjects->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - success = TRUE; - c = clist->next(); - } else if ( r == c->object() && - ( (member_index == -1) || - ((member_index == c->member()) && (c->memberType() == membcode)) ) ) { -#ifdef TQT_THREAD_SUPPORT - if (c->object()->senderObjects) c->object()->senderObjects->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - removeObjFromList( c->object()->senderObjects, s, TRUE ); -#ifdef TQT_THREAD_SUPPORT - if (c->object()->senderObjects) c->object()->senderObjects->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - success = TRUE; - clist->remove(); - c = clist->current(); - } else { - c = clist->next(); - } - } - if ( r == 0 ) // disconnect all receivers - s->connections->insert( i, 0 ); - } - } else { - clist = s->connections->at( signal_index ); - if ( !clist ) - return FALSE; - - c = clist->first(); - while ( c ) { // for all receivers... - if ( r == 0 ) { // remove all receivers -#ifdef TQT_THREAD_SUPPORT - if (c->object()->senderObjects) c->object()->senderObjects->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - removeObjFromList( c->object()->senderObjects, s, TRUE ); -#ifdef TQT_THREAD_SUPPORT - if (c->object()->senderObjects) c->object()->senderObjects->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - success = TRUE; - c = clist->next(); - } else if ( r == c->object() && - ( (member_index == -1) || - ((member_index == c->member()) && (c->memberType() == membcode)) ) ) { -#ifdef TQT_THREAD_SUPPORT - if (c->object()->senderObjects) c->object()->senderObjects->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - removeObjFromList( c->object()->senderObjects, s, TRUE ); -#ifdef TQT_THREAD_SUPPORT - if (c->object()->senderObjects) c->object()->senderObjects->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - success = TRUE; - clist->remove(); - c = clist->current(); - } else { - c = clist->next(); - } - } - if ( r == 0 ) { // disconnect all receivers - s->connections->insert( signal_index, 0 ); - } - } - return success; -} - -/*! - \fn TQObject::destroyed() - - This signal is emitted when the object is being destroyed. - - Note that the signal is emitted by the TQObject destructor, so - the object's virtual table is already degenerated at this point, - and it is not safe to call any functions on the object emitting - the signal. This signal can not be blocked. - - All the objects's children are destroyed immediately after this - signal is emitted. -*/ - -/*! - \overload TQObject::destroyed( TQObject* obj) - - This signal is emitted immediately before the object \a obj is - destroyed, and can not be blocked. - - All the objects's children are destroyed immediately after this - signal is emitted. -*/ - -/*! - Performs a deferred deletion of this object. - - Instead of an immediate deletion this function schedules a - deferred delete event for processing when TQt returns to the main - event loop. -*/ -void TQObject::deleteLater() -{ - TQApplication::postEvent( this, new TQEvent( TQEvent::DeferredDelete) ); -} - -/*! - This slot is connected to the destroyed() signal of other objects - that have installed event filters on this object. When the other - object, \a obj, is destroyed, we want to remove its event filter. -*/ - -void TQObject::cleanupEventFilter(TQObject* obj) -{ - removeEventFilter( obj ); -} - - -/*! - \fn TQString TQObject::tr( const char *sourceText, const char * comment ) - \reentrant - - Returns a translated version of \a sourceText, or \a sourceText - itself if there is no appropriate translated version. The - translation context is TQObject with \a comment (0 by default). - All TQObject subclasses using the TQ_OBJECT macro automatically have - a reimplementation of this function with the subclass name as - context. - - \warning This method is reentrant only if all translators are - installed \e before calling this method. Installing or removing - translators while performing translations is not supported. Doing - so will probably result in crashes or other undesirable behavior. - - \sa trUtf8() TQApplication::translate() - \link i18n.html Internationalization with TQt\endlink -*/ - -/*! - \fn TQString TQObject::trUtf8( const char *sourceText, - const char *comment ) - \reentrant - - Returns a translated version of \a sourceText, or - TQString::fromUtf8(\a sourceText) if there is no appropriate - version. It is otherwise identical to tr(\a sourceText, \a - comment). - - \warning This method is reentrant only if all translators are - installed \e before calling this method. Installing or removing - translators while performing translations is not supported. Doing - so will probably result in crashes or other undesirable behavior. - - \sa tr() TQApplication::translate() -*/ - -static TQMetaObjectCleanUp cleanUp_TQt = TQMetaObjectCleanUp( "TQObject", &TQObject::staticMetaObject ); - -TQMetaObject* TQObject::staticTQtMetaObject() -{ - static TQMetaObject* qtMetaObject = 0; - if ( qtMetaObject ) - return qtMetaObject; - -#ifndef TQT_NO_PROPERTIES - static const TQMetaEnum::Item enum_0[] = { - { "AlignLeft", (int) TQt::AlignLeft }, - { "AlignRight", (int) TQt::AlignRight }, - { "AlignHCenter", (int) TQt::AlignHCenter }, - { "AlignTop", (int) TQt::AlignTop }, - { "AlignBottom", (int) TQt::AlignBottom }, - { "AlignVCenter", (int) TQt::AlignVCenter }, - { "AlignCenter", (int) TQt::AlignCenter }, - { "AlignAuto", (int) TQt::AlignAuto }, - { "AlignJustify", (int) TQt::AlignJustify }, - { "WordBreak", (int) TQt::WordBreak } - }; - - static const TQMetaEnum::Item enum_1[] = { - { "Horizontal", (int) TQt::Horizontal }, - { "Vertical", (int) TQt::Vertical } - }; - - static const TQMetaEnum::Item enum_2[] = { - { "PlainText", (int) TQt::PlainText }, - { "RichText", (int) TQt::RichText }, - { "AutoText", (int) TQt::AutoText }, - { "LogText", (int) TQt::LogText } - }; - - static const TQMetaEnum::Item enum_3[] = { - { "NoBackground", (int) TQt::NoBackground }, - { "PaletteForeground", (int) TQt::PaletteForeground }, - { "PaletteButton", (int) TQt::PaletteButton }, - { "PaletteLight", (int) TQt::PaletteLight }, - { "PaletteMidlight", (int) TQt::PaletteMidlight }, - { "PaletteDark", (int) TQt::PaletteDark }, - { "PaletteMid", (int) TQt::PaletteMid }, - { "PaletteText", (int) TQt::PaletteText }, - { "PaletteBrightText", (int) TQt::PaletteBrightText }, - { "PaletteBase", (int) TQt::PaletteBase }, - { "PaletteBackground", (int) TQt::PaletteBackground }, - { "PaletteShadow", (int) TQt::PaletteShadow }, - { "PaletteHighlight", (int) TQt::PaletteHighlight }, - { "PaletteHighlightedText", (int) TQt::PaletteHighlightedText }, - { "PaletteButtonText", (int) TQt::PaletteButtonText }, - { "PaletteLink", (int) TQt::PaletteLink }, - { "PaletteLinkVisited", (int) TQt::PaletteLinkVisited } - }; - - static const TQMetaEnum::Item enum_4[] = { - { "TextDate", (int) TQt::TextDate }, - { "ISODate", (int) TQt::ISODate }, - { "LocalDate", (int) TQt::LocalDate } - }; - - - static const TQMetaEnum enum_tbl[] = { - { "Alignment", 10, enum_0, TRUE }, - { "Orientation", 2, enum_1, FALSE }, - { "TextFormat", 4, enum_2, FALSE }, - { "BackgroundMode", 17, enum_3, FALSE }, - { "DateFormat", 3, enum_4, FALSE } - }; -#endif - - qtMetaObject = new TQMetaObject( "TQt", 0, - 0, 0, - 0, 0, -#ifndef TQT_NO_PROPERTIES - 0, 0, - enum_tbl, 5, -#endif - 0, 0 ); - cleanUp_TQt.setMetaObject( qtMetaObject ); - - return qtMetaObject; -} - -/*! - \internal - - Signal activation with the most frequently used parameter/argument - types. All other combinations are generated by the meta object - compiler. - */ -void TQObject::activate_signal( int signal ) -{ -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( tqt_preliminary_signal_spy ) { - if ( !signalsBlocked() && signal >= 0 && - ( !connections || !connections->at( signal ) ) ) { - TQUObject o[1]; - o[0].isLastObject = true; - qt_spy_signal( this, signal, o ); - return; - } - } -#endif - - if ( !connections || signalsBlocked() || signal < 0 ) { - return; - } - TQConnectionList *clist = connections->at( signal ); - if ( !clist ) { - return; - } - TQUObject o[1]; - o[0].isLastObject = true; - activate_signal( clist, o ); -} - -/*! \internal */ - -void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o ) -{ - if ( !clist ) { - return; - } - -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( tqt_preliminary_signal_spy ) { - qt_spy_signal( this, connections->findRef( clist), o ); - } -#endif - -#ifdef TQT_THREAD_SUPPORT - // NOTE currentThread could be NULL if the current thread was not started using the TQThread API - const TQThread *currentThread = TQThread::currentThreadObject(); -#endif // TQT_THREAD_SUPPORT - - TQObject *object; - TQSenderObjectList* sol; - TQObject* oldSender = 0; - TQConnection *c; - if ( clist->count() == 1 ) { // save iterator - c = clist->first(); - object = c->object(); - sol = object->senderObjects; -#ifdef TQT_THREAD_SUPPORT - sol->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - if ( sol ) { - oldSender = sol->currentSender; - sol->ref(); - sol->currentSender = this; - } - if ( c->memberType() == TQ_SIGNAL_CODE ) { -#if !defined(TQT_THREAD_SUPPORT) - object->tqt_emit( c->member(), o ); -#else // defined(TQT_THREAD_SUPPORT) - if ((d->disableThreadPostedEvents) || - (object->d->disableThreadPostedEvents) || - (currentThread && currentThread->threadPostedEventsDisabled()) || - (currentThread && object->d->ownThread == currentThread)) { - sol->listMutex->unlock(); - object->tqt_emit( c->member(), o ); - sol->listMutex->lock(); - } - else { - if (object->d->ownThread && !object->d->ownThread->finished()) { -#ifdef QT_DEBUG - tqDebug("TQObject::activate_signal: Emitting cross-thread signal from object %p (member %d receiver %p) (1)\n", this, c->member(), object); -#endif // QT_DEBUG - TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit)); - } - } -#endif // !defined(TQT_THREAD_SUPPORT) - } - else { -#if !defined(TQT_THREAD_SUPPORT) - object->tqt_invoke( c->member(), o ); -#else // defined(TQT_THREAD_SUPPORT) - if ((d->disableThreadPostedEvents) || - (object->d->disableThreadPostedEvents) || - (currentThread && currentThread->threadPostedEventsDisabled()) || - (currentThread && object->d->ownThread == currentThread)) { - sol->listMutex->unlock(); - object->tqt_invoke( c->member(), o ); - sol->listMutex->lock(); - } - else { - if (object->d->ownThread && !object->d->ownThread->finished()) { -#ifdef QT_DEBUG - tqDebug("TQObject::activate_signal: Invoking cross-thread method from object %p (member %d receiver %p) (1)\n", this, c->member(), object); -#endif // QT_DEBUG - TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke)); - } - } -#endif // !defined(TQT_THREAD_SUPPORT) - } - if ( sol ) { - sol->currentSender = oldSender; - if ( sol->deref() ) { -#ifdef TQT_THREAD_SUPPORT - sol->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - delete sol; - sol = NULL; - } - } -#ifdef TQT_THREAD_SUPPORT - if (sol) sol->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - } else { - TQConnection *cd = 0; - TQConnectionListIt it(*clist); - while ( (c=it.current()) ) { - ++it; - if ( c == cd ) - continue; - cd = c; - object = c->object(); - sol = object->senderObjects; -#ifdef TQT_THREAD_SUPPORT - sol->listMutex->lock(); -#endif // TQT_THREAD_SUPPORT - if ( sol ) { - oldSender = sol->currentSender; - sol->ref(); - sol->currentSender = this; - } - if ( c->memberType() == TQ_SIGNAL_CODE ) { -#if !defined(TQT_THREAD_SUPPORT) - object->tqt_emit( c->member(), o ); -#else // defined(TQT_THREAD_SUPPORT) - if ((d->disableThreadPostedEvents) || - (object->d->disableThreadPostedEvents) || - (currentThread && currentThread->threadPostedEventsDisabled()) || - (currentThread && object->d->ownThread == currentThread)) { - sol->listMutex->unlock(); - object->tqt_emit( c->member(), o ); - sol->listMutex->lock(); - } - else { - if (object->d->ownThread && !object->d->ownThread->finished()) { -#ifdef QT_DEBUG - tqDebug("TQObject::activate_signal: Emitting cross-thread signal from object %p (member %d receiver %p) (2)\n", this, c->member(), object); -#endif // QT_DEBUG - TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit)); - } - } -#endif // !defined(TQT_THREAD_SUPPORT) - } - else { -#if !defined(TQT_THREAD_SUPPORT) - object->tqt_invoke( c->member(), o ); -#else // defined(TQT_THREAD_SUPPORT) - if ((d->disableThreadPostedEvents) || - (object->d->disableThreadPostedEvents) || - (currentThread && currentThread->threadPostedEventsDisabled()) || - (currentThread && object->d->ownThread == currentThread)) { - sol->listMutex->unlock(); - object->tqt_invoke( c->member(), o ); - sol->listMutex->lock(); - } - else { - if (object->d->ownThread && !object->d->ownThread->finished()) { -#ifdef QT_DEBUG - tqDebug("TQObject::activate_signal: Invoking cross-thread method from object %p (member %d receiver %p) (2)\n", this, c->member(), object); -#endif // QT_DEBUG - TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke)); - } - } -#endif // !defined(TQT_THREAD_SUPPORT) - } - if (sol ) { - sol->currentSender = oldSender; - if ( sol->deref() ) { -#ifdef TQT_THREAD_SUPPORT - sol->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - delete sol; - sol = NULL; - } - } -#ifdef TQT_THREAD_SUPPORT - if (sol) sol->listMutex->unlock(); -#endif // TQT_THREAD_SUPPORT - } - } -} - -/*! - \overload void TQObject::activate_signal( int signal, int ) -*/ - -/*! - \overload void TQObject::activate_signal( int signal, double ) -*/ - -/*! - \overload void TQObject::activate_signal( int signal, TQString ) -*/ - -/*! - \fn void TQObject::activate_signal_bool( int signal, bool ) - \internal - - Like the above functions, but since bool is sometimes - only a typedef it cannot be a simple overload. -*/ - -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY -#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \ -void TQObject::FNAME( int signal, TYPE param ) \ -{ \ - if ( tqt_preliminary_signal_spy ) { \ - if ( !signalsBlocked() && signal >= 0 && \ - ( !connections || !connections->at( signal ) ) ) { \ - TQUObject o[2]; \ - o[1].isLastObject = true; \ - static_QUType_##TYPE.set( o+1, param ); \ - qt_spy_signal( this, signal, o ); \ - return; \ - } \ - } \ - if ( !connections || signalsBlocked() || signal < 0 ) \ - return; \ - TQConnectionList *clist = connections->at( signal ); \ - if ( !clist ) \ - return; \ - TQUObject o[2]; \ - o[1].isLastObject = true; \ - static_QUType_##TYPE.set( o+1, param ); \ - activate_signal( clist, o ); \ -} -#else -#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \ -void TQObject::FNAME( int signal, TYPE param ) \ -{ \ - if ( !connections || signalsBlocked() || signal < 0 ) \ - return; \ - TQConnectionList *clist = connections->at( signal ); \ - if ( !clist ) \ - return; \ - TQUObject o[2]; \ - o[1].isLastObject = true; \ - static_QUType_##TYPE.set( o+1, param ); \ - activate_signal( clist, o ); \ -} - -#endif -// We don't want to duplicate too much text so... - -ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, int ) -ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, double ) -ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, TQString ) -ACTIVATE_SIGNAL_WITH_PARAM( activate_signal_bool, bool ) - - -/***************************************************************************** - TQObject debugging output routines. - *****************************************************************************/ - -static void dumpRecursive( int level, TQObject *object ) -{ -#if defined(QT_DEBUG) - if ( object ) { - TQString buf; - buf.fill( '\t', level/2 ); - if ( level % 2 ) - buf += " "; - const char *name = object->name(); - TQString flags=""; - if ( tqApp->focusWidget() == object ) - flags += 'F'; - if ( object->isWidgetType() ) { - TQWidget * w = (TQWidget *)object; - if ( w->isVisible() ) { - TQString t( "<%1,%2,%3,%4>" ); - flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height()); - } else { - flags += 'I'; - } - } - tqDebug( "%s%s::%s %s", (const char*)buf, object->className(), name, - flags.latin1() ); - if ( object->children() ) { - TQObjectListIt it(*object->children()); - TQObject * c; - while ( (c=it.current()) != 0 ) { - ++it; - dumpRecursive( level+1, c ); - } - } - } -#else - Q_UNUSED( level ) - Q_UNUSED( object ) -#endif -} - -/*! - Dumps a tree of children to the debug output. - - This function is useful for debugging, but does nothing if the - library has been compiled in release mode (i.e. without debugging - information). -*/ - -void TQObject::dumpObjectTree() -{ - dumpRecursive( 0, this ); -} - -/*! - Dumps information about signal connections, etc. for this object - to the debug output. - - This function is useful for debugging, but does nothing if the - library has been compiled in release mode (i.e. without debugging - information). -*/ - -void TQObject::dumpObjectInfo() -{ -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( d->senderObjectListMutex ); -#endif // TQT_THREAD_SUPPORT - -#if defined(QT_DEBUG) - tqDebug( "OBJECT %s::%s", className(), name( "unnamed" ) ); - int n = 0; - tqDebug( " SIGNALS OUT" ); - if ( connections ) { - TQConnectionList *clist; - for ( uint i = 0; i < connections->size(); i++ ) { - if ( ( clist = connections->at( i ) ) ) { - tqDebug( "\t%s", metaObject()->signal( i, TRUE )->name ); - n++; - TQConnection *c; - TQConnectionListIt cit(*clist); - while ( (c=cit.current()) ) { - ++cit; - tqDebug( "\t --> %s::%s %s", c->object()->className(), - c->object()->name( "unnamed" ), c->memberName() ); - } - } - } - } - if ( n == 0 ) - tqDebug( "\t" ); - - tqDebug( " SIGNALS IN" ); - n = 0; - if ( senderObjects ) { - TQObject *sender = senderObjects->first(); - while ( sender ) { - tqDebug( "\t%s::%s", - sender->className(), sender->name( "unnamed" ) ); - n++; - sender = senderObjects->next(); - } - } - if ( n == 0 ) { - tqDebug( "\t" ); - } -#endif -} - -#ifndef TQT_NO_PROPERTIES - -/*! - Sets the value of the object's \a name property to \a value. - - Returns TRUE if the operation was successful; otherwise returns - FALSE. - - Information about all available properties is provided through the - metaObject(). - - \sa property(), metaObject(), TQMetaObject::propertyNames(), TQMetaObject::property() -*/ -bool TQObject::setProperty( const char *name, const TQVariant& value ) -{ - if ( !value.isValid() ) - return FALSE; - - TQVariant v = value; - - TQMetaObject* meta = metaObject(); - if ( !meta ) - return FALSE; - int id = meta->findProperty( name, TRUE ); - const TQMetaProperty* p = meta->property( id, TRUE ); - if ( !p || !p->isValid() || !p->writable() ) { - tqWarning( "%s::setProperty( \"%s\", value ) failed: property invalid, read-only or does not exist", - className(), name ); - return FALSE; - } - - if ( p->isEnumType() ) { - if ( v.type() == TQVariant::String || v.type() == TQVariant::CString ) { - if ( p->isSetType() ) { - TQString s = value.toString(); - // TQStrList does not support split, use TQStringList for that. - TQStringList l = TQStringList::split( '|', s ); - TQStrList keys; - for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it ) - keys.append( (*it).stripWhiteSpace().latin1() ); - v = TQVariant( p->keysToValue( keys ) ); - } else { - v = TQVariant( p->keyToValue( value.toCString().data() ) ); - } - } else if ( v.type() != TQVariant::Int && v.type() != TQVariant::UInt ) { - return FALSE; - } - return tqt_property( id, 0, &v ); - } - - TQVariant::Type type = (TQVariant::Type)(p->flags >> 24); - if ( type == TQVariant::Invalid ) - type = TQVariant::nameToType( p->type() ); - if ( type != TQVariant::Invalid && !v.canCast( type ) ) - return FALSE; - return tqt_property( id, 0, &v ); -} - -/*! - Returns the value of the object's \a name property. - - If no such property exists, the returned variant is invalid. - - Information about all available properties are provided through - the metaObject(). - - \sa setProperty(), TQVariant::isValid(), metaObject(), - TQMetaObject::propertyNames(), TQMetaObject::property() -*/ -TQVariant TQObject::property( const char *name ) const -{ - TQVariant v; - TQMetaObject* meta = metaObject(); - if ( !meta ) - return v; - int id = meta->findProperty( name, TRUE ); - const TQMetaProperty* p = meta->property( id, TRUE ); - if ( !p || !p->isValid() ) { - tqWarning( "%s::property( \"%s\" ) failed: property invalid or does not exist", - className(), name ); - return v; - } - TQObject* that = (TQObject*) this; // moc ensures constness for the tqt_property call - that->tqt_property( id, 1, &v ); - return v; -} - -#endif // TQT_NO_PROPERTIES - -#ifndef TQT_NO_USERDATA -/*!\internal - */ -uint TQObject::registerUserData() -{ - static int user_data_registration = 0; - return user_data_registration++; -} - -/*!\internal - */ -TQObjectUserData::~TQObjectUserData() -{ -} - -/*!\internal - */ -void TQObject::setUserData( uint id, TQObjectUserData* data) -{ - if ( !d ) - d = new TQObjectPrivate( id+1 ); - if ( id >= d->size() ) - d->resize( id+1 ); - d->insert( id, data ); -} - -/*!\internal - */ -TQObjectUserData* TQObject::userData( uint id ) const -{ - if ( d && id < d->size() ) - return d->at( id ); - return 0; -} - -#endif // TQT_NO_USERDATA diff --git a/src/kernel/qobjectcleanuphandler.cpp b/src/kernel/qobjectcleanuphandler.cpp deleted file mode 100644 index 8523e4add..000000000 --- a/src/kernel/qobjectcleanuphandler.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQObjectCleanupHandler class -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqobjectcleanuphandler.h" -#include "ntqobjectlist.h" - -/*! - \class TQObjectCleanupHandler ntqobjectcleanuphandler.h - \brief The TQObjectCleanupHandler class watches the lifetime of multiple TQObjects. - - \ingroup objectmodel - - A TQObjectCleanupHandler is useful whenever you need to know when a - number of \l{TQObject}s that are owned by someone else have been - deleted. This is important, for example, when referencing memory - in an application that has been allocated in a shared library. - - Example: - - \code - class FactoryComponent : public FactoryInterface, public TQLibraryInterface - { - public: - ... - - TQObject *createObject(); - - bool init(); - void cleanup(); - bool canUnload() const; - - private: - TQObjectCleanupHandler objects; - }; - - // allocate a new object, and add it to the cleanup handler - TQObject *FactoryComponent::createObject() - { - return objects.add( new TQObject() ); - } - - // TQLibraryInterface implementation - bool FactoryComponent::init() - { - return TRUE; - } - - void FactoryComponent::cleanup() - { - } - - // it is only safe to unload the library when all TQObject's have been destroyed - bool FactoryComponent::canUnload() const - { - return objects.isEmpty(); - } - \endcode -*/ - -/*! - Constructs an empty TQObjectCleanupHandler. -*/ -TQObjectCleanupHandler::TQObjectCleanupHandler() -: TQObject(), cleanupObjects( 0 ) -{ -} - -/*! - Destroys the cleanup handler. All objects in this cleanup handler - will be deleted. -*/ -TQObjectCleanupHandler::~TQObjectCleanupHandler() -{ - clear(); -} - -/*! - Adds \a object to this cleanup handler and returns the pointer to - the object. -*/ -TQObject* TQObjectCleanupHandler::add( TQObject* object ) -{ - if ( !object ) - return 0; - - if ( !cleanupObjects ) { - cleanupObjects = new TQObjectList; - cleanupObjects->setAutoDelete( TRUE ); - } - connect( object, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(objectDestroyed(TQObject*)) ); - cleanupObjects->insert( 0, object ); - return object; -} - -/*! - Removes the \a object from this cleanup handler. The object will - not be destroyed. -*/ -void TQObjectCleanupHandler::remove( TQObject *object ) -{ - if ( !cleanupObjects ) - return; - if ( cleanupObjects->findRef( object ) >= 0 ) { - (void) cleanupObjects->take(); - disconnect( object, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(objectDestroyed(TQObject*)) ); - } -} - -/*! - Returns TRUE if this cleanup handler is empty or if all objects in - this cleanup handler have been destroyed; otherwise return FALSE. -*/ -bool TQObjectCleanupHandler::isEmpty() const -{ - return cleanupObjects ? cleanupObjects->isEmpty() : TRUE; -} - -/*! - Deletes all objects in this cleanup handler. The cleanup handler - becomes empty. -*/ -void TQObjectCleanupHandler::clear() -{ - delete cleanupObjects; - cleanupObjects = 0; -} - -void TQObjectCleanupHandler::objectDestroyed( TQObject*object ) -{ - if ( cleanupObjects ) - cleanupObjects->setAutoDelete( FALSE ); - - remove( object ); - - if ( cleanupObjects ) - cleanupObjects->setAutoDelete( TRUE ); -} diff --git a/src/kernel/qpixmap.cpp b/src/kernel/qpixmap.cpp index b11530f6c..4f05adc02 100644 --- a/src/kernel/qpixmap.cpp +++ b/src/kernel/qpixmap.cpp @@ -46,7 +46,7 @@ #include "ntqpainter.h" #include "ntqdatastream.h" #include "ntqbuffer.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqapplication.h" #include #include "ntqmime.h" diff --git a/src/kernel/qpixmapcache.cpp b/src/kernel/qpixmapcache.cpp index c30e5b9d0..16a7c5ed2 100644 --- a/src/kernel/qpixmapcache.cpp +++ b/src/kernel/qpixmapcache.cpp @@ -40,7 +40,7 @@ #include "ntqpixmapcache.h" #include "ntqcache.h" -#include "ntqobject.h" +#include "tqobject.h" #include "ntqcleanuphandler.h" diff --git a/src/kernel/qrichtext_p.h b/src/kernel/qrichtext_p.h index 428b0ec5d..1915820fa 100644 --- a/src/kernel/qrichtext_p.h +++ b/src/kernel/qrichtext_p.h @@ -66,14 +66,14 @@ #include "ntqsize.h" #include "ntqvaluelist.h" #include "ntqvaluestack.h" -#include "ntqobject.h" +#include "tqobject.h" #include "ntqdict.h" #include "ntqpixmap.h" #include "ntqstylesheet.h" #include "ntqptrvector.h" #include "ntqpainter.h" #include "ntqlayout.h" -#include "ntqobject.h" +#include "tqobject.h" #include "ntqapplication.h" #endif // QT_H diff --git a/src/kernel/qsizegrip.cpp b/src/kernel/qsizegrip.cpp index 7b8140c62..d27e0b534 100644 --- a/src/kernel/qsizegrip.cpp +++ b/src/kernel/qsizegrip.cpp @@ -50,7 +50,7 @@ #include "qt_x11_p.h" extern Atom qt_sizegrip; // defined in qapplication_x11.cpp #elif defined (TQ_WS_WIN ) -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "qt_windows.h" #elif defined(TQ_WS_MAC) bool qt_mac_update_sizer(TQWidget *, int); //qwidget_mac.cpp diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 7d143270b..67b42e70f 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -49,7 +49,7 @@ #include "ntqlistview.h" #include "ntqpopupmenu.h" #include "ntqpushbutton.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqwidgetlist.h" #include diff --git a/src/kernel/qt_kernel.pri b/src/kernel/qt_kernel.pri index 684866e7d..6baa0c732 100644 --- a/src/kernel/qt_kernel.pri +++ b/src/kernel/qt_kernel.pri @@ -45,11 +45,11 @@ kernel { $$KERNEL_H/ntqmovie.h \ $$KERNEL_H/ntqnamespace.h \ $$KERNEL_H/ntqnetworkprotocol.h \ - $$KERNEL_H/ntqobject.h \ - $$KERNEL_H/ntqobjectcleanuphandler.h \ - $$KERNEL_H/ntqobjectdefs.h \ - $$KERNEL_H/ntqobjectdict.h \ - $$KERNEL_H/ntqobjectlist.h \ + $$KERNEL_H/tqobject.h \ + $$KERNEL_H/tqobjectcleanuphandler.h \ + $$KERNEL_H/tqobjectdefs.h \ + $$KERNEL_H/tqobjectdict.h \ + $$KERNEL_H/tqobjectlist.h \ $$KERNEL_H/ntqpaintdevice.h \ $$KERNEL_H/ntqpainter.h \ $$KERNEL_P/qpainter_p.h \ @@ -226,8 +226,8 @@ kernel { $$KERNEL_CPP/qmime.cpp \ $$KERNEL_CPP/qmovie.cpp \ $$KERNEL_CPP/qnetworkprotocol.cpp \ - $$KERNEL_CPP/qobject.cpp \ - $$KERNEL_CPP/qobjectcleanuphandler.cpp \ + $$KERNEL_CPP/tqobject.cpp \ + $$KERNEL_CPP/tqobjectcleanuphandler.cpp \ $$KERNEL_CPP/qpainter.cpp \ $$KERNEL_CPP/qpalette.cpp \ $$KERNEL_CPP/qpaintdevicemetrics.cpp \ diff --git a/src/kernel/qt_pch.h b/src/kernel/qt_pch.h index cdde3e790..1aef6f4a8 100644 --- a/src/kernel/qt_pch.h +++ b/src/kernel/qt_pch.h @@ -30,7 +30,7 @@ #include #include #include // All moc genereated code has this include -#include +#include #include #include #include diff --git a/src/kernel/qtimer.cpp b/src/kernel/qtimer.cpp index f7736c028..ca2dddb9e 100644 --- a/src/kernel/qtimer.cpp +++ b/src/kernel/qtimer.cpp @@ -40,7 +40,7 @@ #include "ntqtimer.h" #include "ntqsignal.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" /*! \class TQTimer ntqtimer.h diff --git a/src/kernel/qwidget.cpp b/src/kernel/qwidget.cpp index 1af274c6e..e855e7448 100644 --- a/src/kernel/qwidget.cpp +++ b/src/kernel/qwidget.cpp @@ -39,7 +39,7 @@ **********************************************************************/ -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqwidget.h" #include "ntqwidgetlist.h" #include "ntqwidgetintdict.h" diff --git a/src/kernel/qwidget_x11.cpp b/src/kernel/qwidget_x11.cpp index 0591ca4cf..db3500cfe 100644 --- a/src/kernel/qwidget_x11.cpp +++ b/src/kernel/qwidget_x11.cpp @@ -45,7 +45,7 @@ #include "ntqpainter.h" #include "ntqbitmap.h" #include "ntqimage.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqlayout.h" #include "ntqtextcodec.h" #include "ntqdatetime.h" diff --git a/src/kernel/tqobject.cpp b/src/kernel/tqobject.cpp new file mode 100644 index 000000000..d66f8cf16 --- /dev/null +++ b/src/kernel/tqobject.cpp @@ -0,0 +1,3249 @@ +/**************************************************************************** +** +** Implementation of TQObject class +** +** Created : 930418 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "ntqvariant.h" +#include "ntqapplication.h" +#include "tqobject.h" +#include "tqobjectlist.h" +#include "ntqsignalslotimp.h" +#include "ntqregexp.h" +#include "ntqmetaobject.h" +#include +#include "qucomextra_p.h" +#include "ntqptrvector.h" + +// TQStyleControlElementData +#include "ntqstyle.h" + +#ifdef TQT_THREAD_SUPPORT +#include "ntqmutex.h" +#include +#include "ntqthread.h" +#endif + +#include +#include + +// Keep in sync with duplicate definition in qcommonstyle.cpp +class TQStyleControlElementDataPrivate { + public: + bool isTQPushButton; + bool isTQToolButton; + bool isTQButton; + bool isTQTabBar; + bool isTQTitleBar; + bool isTQToolBox; + bool isTQToolBar; + bool isTQProgressBar; + bool isTQPopupMenu; + bool isTQComboBox; + bool isTQCheckBox; + bool isTQRadioButton; + bool isTQHeader; + bool isTQScrollBar; + bool isTQSlider; + bool isTQDialogButtons; + bool isTQSpinWidget; + bool isTQListView; + bool isTQDockWindow; + bool isTQTabWidget; + bool isTQFrame; + bool isTQWidget; +}; + +#ifndef TQT_NO_USERDATA +class TQObjectPrivate : public TQPtrVector +#else +class TQObjectPrivate { +#endif +{ +public: +#ifndef TQT_NO_USERDATA + TQObjectPrivate( uint s ) : TQPtrVector(s) { +#ifdef TQT_THREAD_SUPPORT + ownThread = NULL; + disableThreadPostedEvents = false; +#endif + setAutoDelete( TRUE ); + controlElementData = NULL; + controlElementDataPrivate = NULL; + } + ~TQObjectPrivate() { + delete controlElementData; + delete controlElementDataPrivate; + } +#endif +#ifdef TQT_THREAD_SUPPORT + TQThread* ownThread; + TQMutex* senderObjectListMutex; + TQMutex* childObjectListMutex; + bool disableThreadPostedEvents; +#endif + TQStyleControlElementData* controlElementData; + TQStyleControlElementDataPrivate* controlElementDataPrivate; +}; + +TQStyleControlElementData* TQObject::controlElementDataObject() { + if (!d->controlElementData) { + d->controlElementData = new TQStyleControlElementData(); + } + return d->controlElementData; +} + +TQStyleControlElementDataPrivate* TQObject::controlElementDataPrivateObject() { + if (!d->controlElementDataPrivate) { + d->controlElementDataPrivate = new TQStyleControlElementDataPrivate(); + } + return d->controlElementDataPrivate; +} + +void TQObject::cleanupControlElementData() { + delete d->controlElementData; + d->controlElementData = 0; + delete d->controlElementDataPrivate; + d->controlElementDataPrivate = 0; +} + +#if defined(TQT_THREAD_SUPPORT) + +void TQObject::moveToThread_helper(TQThread *targetThread) +{ + TQEvent e(TQEvent::ThreadChange); + TQApplication::sendEvent(this, &e); + +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker locker( d->childObjectListMutex ); +#endif // TQT_THREAD_SUPPORT + + if (childObjects) { + TQObject *child; + TQObjectListIt it(*childObjects); + while ( (child=it.current()) ) { + ++it; + child->moveToThread_helper(targetThread); + } + } +} + +void TQObject::setThreadObject_helper(TQThread *targetThread) +{ + d->ownThread = targetThread; + +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker locker( d->childObjectListMutex ); +#endif // TQT_THREAD_SUPPORT + + if (childObjects) { + TQObject *child; + TQObjectListIt it(*childObjects); + while ( (child=it.current()) ) { + ++it; + child->setThreadObject_helper(targetThread); + } + } +} + +/*! + Changes the thread affinity for this object and its children. The + object cannot be moved if it has a parent. Event processing will + continue in the \a targetThread. To move an object to the main + thread, pass TQApplication::guiThread() as the \a targetThread. + + Note that all active timers for the object will be reset. The + timers are first stopped in the current thread and restarted (with + the same interval) in the \a targetThread. As a result, constantly + moving an object between threads can postpone timer events + indefinitely. + + \sa contextThreadObject() + */ +void TQObject::moveToThread(TQThread *targetThread) +{ +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker locker( TQApplication::tqt_mutex ); +#endif // TQT_THREAD_SUPPORT + + if (parentObj) { +#if defined(QT_DEBUG) + tqWarning( "TQObject::moveToThread: Cannot move objects with a parent" ); +#endif + return; + } + if (isWidget) { +#if defined(QT_DEBUG) + tqWarning( "TQObject::moveToThread: Widgets cannot be moved to a new thread" ); +#endif + return; + } + + TQThread *objectThread = contextThreadObject(); + // NOTE currentThread could be NULL if the current thread was not started using the TQThread API + TQThread *currentThread = TQThread::currentThreadObject(); + + if (currentThread && objectThread != currentThread) { +#if defined(QT_DEBUG) + tqWarning( "TQObject::moveToThread: Current thread is not the object's thread" ); +#endif + return; + } + + if (objectThread == targetThread) { + return; + } + + moveToThread_helper(targetThread); + setThreadObject_helper(targetThread); +} + +/*! + Changes the way cross thread signals are handled + If disable is FALSE, signals emitted from one thread will be + posted to any other connected threads' event loops (default). + + If disable is TRUE, calls to emit from one thread + will immediately execute slots in another thread. + This mode of operation is inherently unsafe and is provided + solely to support thread management by a third party application. + */ +void TQObject::disableThreadPostedEvents(bool disable) { + if ( !d ) { + d = new TQObjectPrivate(0); + } + + d->ownThread = TQThread::currentThreadObject(); + d->disableThreadPostedEvents = disable; +} + +#endif // defined(TQT_THREAD_SUPPORT) + +class TQSenderObjectList : public TQObjectList, public TQShared +{ + public: + TQSenderObjectList(); + ~TQSenderObjectList(); + + public: + TQObject *currentSender; +#ifdef TQT_THREAD_SUPPORT + TQMutex *listMutex; +#endif +}; + +TQSenderObjectList::TQSenderObjectList() : currentSender( 0 ) { +#ifdef TQT_THREAD_SUPPORT + listMutex = new TQMutex( TRUE ); +#endif +} + +TQSenderObjectList::~TQSenderObjectList() { +#ifdef TQT_THREAD_SUPPORT + delete listMutex; +#endif +} + +class TQ_EXPORT TQMetaCallEvent : public TQEvent +{ +public: + enum MetaCallType { + MetaCallEmit = 0, + MetaCallInvoke = 1 + }; + +public: + TQMetaCallEvent(int id, TQObject *sender, TQUObject *data, MetaCallType type); + ~TQMetaCallEvent(); + + inline int id() const { return id_; } + inline TQObject *sender() const { return sender_; } + inline TQUObject *data() const { return data_; } + inline MetaCallType type() const { return type_; } + +private: + const int id_; + TQObject *sender_; + TQUObject *data_; + const MetaCallType type_; +}; + +/*! \internal + */ +TQMetaCallEvent::TQMetaCallEvent(int id, TQObject *sender, TQUObject *data, MetaCallType type) + :TQEvent(MetaCall), id_(id), sender_(sender), data_(data), type_(type) +{ } + +/*! \internal + */ +TQMetaCallEvent::~TQMetaCallEvent() +{ } + +/*! + \class TQt ntqnamespace.h + + \brief The TQt class is a namespace for miscellaneous identifiers + that need to be global-like. + + \ingroup misc + + Normally, you can ignore this class. TQObject and a few other + classes inherit it, so all the identifiers in the TQt namespace are + normally usable without qualification. + + However, you may occasionally need to say \c TQt::black instead of + just \c black, particularly in static utility functions (such as + many class factories). + +*/ + +/*! + \enum TQt::Orientation + + This type is used to signify an object's orientation. + + \value Horizontal + \value Vertical + + Orientation is used with TQScrollBar for example. +*/ + + +/*! + \class TQObject tqobject.h + \brief The TQObject class is the base class of all TQt objects. + + \ingroup objectmodel + \mainclass + \reentrant + + TQObject is the heart of the \link object.html TQt object model. + \endlink The central feature in this model is a very powerful + mechanism for seamless object communication called \link + signalsandslots.html signals and slots \endlink. You can + connect a signal to a slot with connect() and destroy the + connection with disconnect(). To avoid never ending notification + loops you can temporarily block signals with blockSignals(). The + protected functions connectNotify() and disconnectNotify() make it + possible to track connections. + + TQObjects organize themselves in object trees. When you create a + TQObject with another object as parent, the object will + automatically do an insertChild() on the parent and thus show up + in the parent's children() list. The parent takes ownership of the + object i.e. it will automatically delete its children in its + destructor. You can look for an object by name and optionally type + using child() or queryList(), and get the list of tree roots using + objectTrees(). + + Every object has an object name() and can report its className() + and whether it inherits() another class in the TQObject inheritance + hierarchy. + + When an object is deleted, it emits a destroyed() signal. You can + catch this signal to avoid dangling references to TQObjects. The + TQGuardedPtr class provides an elegant way to use this feature. + + TQObjects can receive events through event() and filter the events + of other objects. See installEventFilter() and eventFilter() for + details. A convenience handler, childEvent(), can be reimplemented + to catch child events. + + Last but not least, TQObject provides the basic timer support in + TQt; see TQTimer for high-level support for timers. + + Notice that the TQ_OBJECT macro is mandatory for any object that + implements signals, slots or properties. You also need to run the + \link moc.html moc program (Meta Object Compiler) \endlink on the + source file. We strongly recommend the use of this macro in \e all + subclasses of TQObject regardless of whether or not they actually + use signals, slots and properties, since failure to do so may lead + certain functions to exhibit undefined behaviour. + + All TQt widgets inherit TQObject. The convenience function + isWidgetType() returns whether an object is actually a widget. It + is much faster than inherits( "TQWidget" ). + + Some TQObject functions, e.g. children(), objectTrees() and + queryList() return a TQObjectList. A TQObjectList is a TQPtrList of + TQObjects. TQObjectLists support the same operations as TQPtrLists + and have an iterator class, TQObjectListIt. +*/ + + +// +// Remove white space from TQ_SIGNAL and TQ_SLOT names. +// Internal for TQObject::connect() and TQObject::disconnect() +// + +static inline bool isIdentChar( char x ) +{ // Avoid bug in isalnum + return x == '_' || (x >= '0' && x <= '9') || + (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z'); +} + +static inline bool isSpace( char x ) +{ +#if defined(Q_CC_BOR) + /* + Borland C++ 4.5 has a weird isspace() bug. + isspace() usually works, but not here. + This implementation is sufficient for our internal use: rmWS() + */ + return (uchar) x <= 32; +#else + return isspace( (uchar) x ); +#endif +} + +static TQCString qt_rmWS( const char *s ) +{ + TQCString result( tqstrlen(s)+1 ); + char *d = result.data(); + char last = 0; + while( *s && isSpace(*s) ) // skip leading space + s++; + while ( *s ) { + while ( *s && !isSpace(*s) ) + last = *d++ = *s++; + while ( *s && isSpace(*s) ) + s++; + if ( *s && isIdentChar(*s) && isIdentChar(last) ) + last = *d++ = ' '; + } + *d = '\0'; + result.truncate( (int)(d - result.data()) ); + int void_pos = result.find("(void)"); + if ( void_pos >= 0 ) + result.remove( void_pos+1, (uint)strlen("void") ); + return result; +} + + +// Event functions, implemented in qapplication_xxx.cpp + +int qStartTimer( int interval, TQObject *obj ); +bool qKillTimer( int id ); +bool qKillTimer( TQObject *obj ); + +static void removeObjFromList( TQObjectList *objList, const TQObject *obj, + bool single=FALSE ) +{ + if ( !objList ) { + return; + } + int index = objList->findRef( obj ); + while ( index >= 0 ) { + objList->remove(); + if ( single ) + return; + index = objList->findNextRef( obj ); + } +} + + +/*! + \relates TQObject + + Returns a pointer to the object named \a name that inherits \a + type and with a given \a parent. + + Returns 0 if there is no such child. + + \code + TQListBox *c = (TQListBox *) tqt_find_obj_child( myWidget, "TQListBox", + "my list box" ); + if ( c ) + c->insertItem( "another string" ); + \endcode +*/ + +void *tqt_find_obj_child( TQObject *parent, const char *type, const char *name ) +{ + const TQObjectList *list = parent->children(); + if ( list ) { + TQObjectListIt it( *list ); + TQObject *obj; + while ( (obj = it.current()) ) { + ++it; + if ( qstrcmp(name,obj->name()) == 0 && + obj->inherits(type) ) + return obj; + } + } + return 0; +} + +#ifdef TQT_THREAD_SUPPORT + +/*! + Returns a pointer to the TQThread* associated with + the current thread affinity of this object. + + \sa moveToThread() + */ + +TQThread* TQObject::contextThreadObject() const +{ + return d->ownThread; +} + +#endif + +#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY +/* + Preliminary signal spy + */ +TQ_EXPORT TQObject* tqt_preliminary_signal_spy = 0; +static TQObject* qt_spy_signal_sender = 0; + +static void qt_spy_signal( TQObject* sender, int signal, TQUObject* o ) +{ + TQMetaObject* mo = sender->metaObject(); + while ( mo && signal - mo->signalOffset() < 0 ) + mo = mo->superClass(); + if ( !mo ) + return; + const TQMetaData* sigData = mo->signal( signal - mo->signalOffset() ); + if ( !sigData ) + return; + TQCString s; + mo = sender->metaObject(); + while ( mo ) { + s.sprintf( "%s_%s", mo->className(), sigData->name ); + int slot = tqt_preliminary_signal_spy->metaObject()->findSlot( s, TRUE ); + if ( slot >= 0 ) { +#ifdef TQT_THREAD_SUPPORT + // protect access to qt_spy_signal_sender + void * const address = &qt_spy_signal_sender; + TQMutexLocker locker( tqt_global_mutexpool ? + tqt_global_mutexpool->get( address ) : 0 ); +#endif // TQT_THREAD_SUPPORT + + TQObject* old_sender = qt_spy_signal_sender; + qt_spy_signal_sender = sender; + tqt_preliminary_signal_spy->tqt_invoke( slot, o ); + qt_spy_signal_sender = old_sender; + break; + } + mo = mo->superClass(); + } +} + +/* + End Preliminary signal spy + */ +#endif // TQT_NO_PRELIMINARY_SIGNAL_SPY + +static TQObjectList* object_trees = 0; + +#ifdef TQT_THREAD_SUPPORT +static TQMutex *obj_trees_mutex = 0; +#endif + +static void cleanup_object_trees() +{ + delete object_trees; + object_trees = 0; +#ifdef TQT_THREAD_SUPPORT + delete obj_trees_mutex; + obj_trees_mutex = 0; +#endif +} + +static void ensure_object_trees() +{ + object_trees = new TQObjectList; + tqAddPostRoutine( cleanup_object_trees ); +} + +static void insert_tree( TQObject* obj ) +{ +#ifdef TQT_THREAD_SUPPORT + if ( !obj_trees_mutex ) + obj_trees_mutex = new TQMutex(); + TQMutexLocker locker( obj_trees_mutex ); +#endif + if ( !object_trees ) + ensure_object_trees(); + object_trees->insert(0, obj ); +} + +static void remove_tree( TQObject* obj ) +{ + if ( object_trees ) { +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker locker( obj_trees_mutex ); +#endif + object_trees->removeRef( obj ); + } +} + +/*! \internal + TQt compatibility function +*/ +TQObjectList TQObject::childrenListObject() { + if (children()) return *(children()); + else return TQObjectList(); +} + +/*! \internal + TQt compatibility function +*/ +const TQObjectList TQObject::childrenListObject() const { + if (children()) return *(children()); + else return TQObjectList(); +} + +/*! \internal + TQt compatibility function +*/ +const TQObjectList TQObject::objectTreesListObject() { + if (objectTrees()) return *(objectTrees()); + else return TQObjectList(); +} + + +/***************************************************************************** + TQObject member functions + *****************************************************************************/ + +/*! + Constructs an object called \a name with parent object, \a parent. + + The parent of an object may be viewed as the object's owner. For + instance, a \link TQDialog dialog box\endlink is the parent of the + "OK" and "Cancel" buttons it contains. + + The destructor of a parent object destroys all child objects. + + Setting \a parent to 0 constructs an object with no parent. If the + object is a widget, it will become a top-level window. + + The object name is some text that can be used to identify a + TQObject. It's particularly useful in conjunction with \link + designer-manual.book TQt Designer\endlink. You can find an + object by name (and type) using child(). To find several objects + use queryList(). + + \sa parent(), name(), child(), queryList() +*/ + +TQObject::TQObject( TQObject *parent, const char *name ) + : + isSignal( FALSE ), // assume not a signal object + isWidget( FALSE ), // assume not a widget object + pendTimer( FALSE ), // no timers yet + blockSig( FALSE ), // not blocking signals + wasDeleted( FALSE ), // double-delete catcher + isTree( FALSE ), // no tree yet + objname( name ? tqstrdup(name) : 0 ), // set object name + parentObj( 0 ), // no parent yet. It is set by insertChild() + childObjects( 0 ), // no children yet + connections( 0 ), // no connections yet + senderObjects( 0 ), // no signals connected yet + eventFilters( 0 ), // no filters installed + postedEvents( 0 ), // no events posted + d( 0 ) +{ + if ( !d ) { + d = new TQObjectPrivate(0); + } + +#ifdef TQT_THREAD_SUPPORT + d->ownThread = TQThread::currentThreadObject(); + d->senderObjectListMutex = new TQMutex( TRUE ); + d->childObjectListMutex = new TQMutex( TRUE ); +#endif + if ( !metaObj ) { // will create object dict + (void) staticMetaObject(); + } + + if ( parent ) { // add object to parent + parent->insertChild( this ); + } + else { + insert_tree( this ); + isTree = TRUE; + } +} + + +/*! + Destroys the object, deleting all its child objects. + + All signals to and from the object are automatically disconnected. + + \warning All child objects are deleted. If any of these objects + are on the stack or global, sooner or later your program will + crash. We do not recommend holding pointers to child objects from + outside the parent. If you still do, the TQObject::destroyed() + signal gives you an opportunity to detect when an object is + destroyed. + + \warning Deleting a TQObject while pending events are waiting to be + delivered can cause a crash. You must not delete the TQObject + directly from a thread that is not the GUI thread. Use the + TQObject::deleteLater() method instead, which will cause the event + loop to delete the object after all pending events have been + delivered to the object. +*/ + +TQObject::~TQObject() +{ + if ( wasDeleted ) { +#if defined(QT_DEBUG) + tqWarning( "Double TQObject deletion detected." ); +#endif + return; + } + if (tqApp) { + TQEvent destroyEvent(TQEvent::Destroy); + tqApp->notify(this, &destroyEvent); + } + wasDeleted = 1; + blockSig = 0; // unblock signals to keep TQGuardedPtr happy + emit destroyed( this ); + emit destroyed(); + + if ( objname ) { + delete [] (char*)objname; + } + objname = 0; + if ( pendTimer ) { // might be pending timers + qKillTimer( this ); + } + TQApplication::removePostedEvents( this ); + if ( isTree ) { + remove_tree( this ); // remove from global root list + isTree = FALSE; + } + if ( parentObj ) // remove it from parent object + parentObj->removeChild( this ); + TQObject *obj; + if ( senderObjects ) { // disconnect from senders + TQSenderObjectList *tmp = senderObjects; + senderObjects = 0; + obj = tmp->first(); + while ( obj ) { // for all senders... + obj->disconnect( this ); + obj = tmp->next(); + } + if ( tmp->deref() ) + delete tmp; + } + if ( connections ) { // disconnect receivers + for ( int i = 0; i < (int) connections->size(); i++ ) { + TQConnectionList* clist = (*connections)[i]; // for each signal... + if ( !clist ) + continue; + TQConnection *c; + TQConnectionListIt cit(*clist); + while( (c=cit.current()) ) { // for each connected slot... + ++cit; + if ( (obj=c->object()) ) { + removeObjFromList( obj->senderObjects, this ); + } + } + } + delete connections; + connections = 0; + } + if ( eventFilters ) { + delete eventFilters; + eventFilters = 0; + } + if ( childObjects ) { // delete children objects + TQObjectListIt it(*childObjects); + while ( (obj=it.current()) ) { + ++it; + obj->parentObj = 0; + childObjects->removeRef( obj ); + delete obj; + } + delete childObjects; + } + +#ifdef TQT_THREAD_SUPPORT + delete d->childObjectListMutex; + delete d->senderObjectListMutex; +#endif // TQT_THREAD_SUPPORT + + delete d; +} + + +/*! + \fn TQMetaObject *TQObject::metaObject() const + + Returns a pointer to the meta object of this object. + + A meta object contains information about a class that inherits + TQObject, e.g. class name, superclass name, properties, signals and + slots. Every class that contains the TQ_OBJECT macro will also have + a meta object. + + The meta object information is required by the signal/slot + connection mechanism and the property system. The functions isA() + and inherits() also make use of the meta object. +*/ + +/*! + \fn const char *TQObject::className() const + + Returns the class name of this object. + + This function is generated by the \link metaobjects.html Meta + Object Compiler. \endlink + + \warning This function will return the wrong name if the class + definition lacks the TQ_OBJECT macro. + + \sa name(), inherits(), isA(), isWidgetType() +*/ + +/*! + Returns TRUE if this object is an instance of the class \a clname; + otherwise returns FALSE. + + Example: + \code + TQTimer *t = new TQTimer; // TQTimer inherits TQObject + t->isA( "TQTimer" ); // returns TRUE + t->isA( "TQObject" ); // returns FALSE + \endcode + + \sa inherits() metaObject() +*/ + +bool TQObject::isA( const char *clname ) const +{ + return qstrcmp( clname, className() ) == 0; +} + +/*! + Returns TRUE if this object is an instance of a class that + inherits \a clname, and \a clname inherits TQObject; otherwise + returns FALSE. + + A class is considered to inherit itself. + + Example: + \code + TQTimer *t = new TQTimer; // TQTimer inherits TQObject + t->inherits( "TQTimer" ); // returns TRUE + t->inherits( "TQObject" ); // returns TRUE + t->inherits( "TQButton" ); // returns FALSE + + // TQScrollBar inherits TQWidget and TQRangeControl + TQScrollBar *s = new TQScrollBar( 0 ); + s->inherits( "TQWidget" ); // returns TRUE + s->inherits( "TQRangeControl" ); // returns FALSE + \endcode + + (\l TQRangeControl is not a TQObject.) + + \sa isA(), metaObject() +*/ + +bool TQObject::inherits( const char *clname ) const +{ + return metaObject()->inherits( clname ); +} + +/*! + \internal + + Returns TRUE if \a object inherits \a superClass within + the meta object inheritance chain; otherwise returns FALSE. + + \sa inherits() +*/ +void *tqt_inheritedBy( TQMetaObject *superClass, const TQObject *object ) +{ + if (!object) + return 0; + TQMetaObject *mo = object->metaObject(); + while (mo) { + if (mo == superClass) + return (void*)object; + mo = mo->superClass(); + } + return 0; +} + +/*! + \property TQObject::name + + \brief the name of this object + + You can find an object by name (and type) using child(). You can + find a set of objects with queryList(). + + The object name is set by the constructor or by the setName() + function. The object name is not very useful in the current + version of TQt, but will become increasingly important in the + future. + + If the object does not have a name, the name() function returns + "unnamed", so printf() (used in tqDebug()) will not be asked to + output a null pointer. If you want a null pointer to be returned + for unnamed objects, you can call name( 0 ). + + \code + tqDebug( "MyClass::setPrecision(): (%s) invalid precision %f", + name(), newPrecision ); + \endcode + + \sa className(), child(), queryList() +*/ + +const char * TQObject::name() const +{ + // If you change the name here, the builder will be broken + return objname ? objname : "unnamed"; +} + +/*! + Sets the object's name to \a name. +*/ +void TQObject::setName( const char *name ) +{ + if ( objname ) + delete [] (char*) objname; + objname = name ? tqstrdup(name) : 0; +} + +/*! + \overload + + Returns the name of this object, or \a defaultName if the object + does not have a name. +*/ + +const char * TQObject::name( const char * defaultName ) const +{ + return objname ? objname : defaultName; +} + + +/*! + 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 retured; if you need all of + them, use queryList(). +*/ +TQObject* TQObject::child( const char *objName, const char *inheritsClass, + bool recursiveSearch ) +{ + const TQObjectList *list = children(); + if ( !list ) + return 0; + + bool onlyWidgets = ( inheritsClass && qstrcmp( inheritsClass, "TQWidget" ) == 0 ); + TQObjectListIt it( *list ); + TQObject *obj; + while ( ( obj = it.current() ) ) { + ++it; + if ( onlyWidgets ) { + if ( obj->isWidgetType() && ( !objName || qstrcmp( objName, obj->name() ) == 0 ) ) + break; + } else if ( ( !inheritsClass || obj->inherits(inheritsClass) ) && ( !objName || qstrcmp( objName, obj->name() ) == 0 ) ) + break; + if ( recursiveSearch && (obj = obj->child( objName, inheritsClass, recursiveSearch ) ) ) + break; + } + return obj; +} + +/*! \internal */ +TQUObject* deepCopyTQUObjectArray(TQUObject* origArray) +{ + TQUObject* newArray; + int count = 0; + while (!((origArray+count)->isLastObject)) { + count++; + } + count++; + newArray = (TQUObject*)malloc(sizeof(TQUObject)*count); + for (int i=0; ideepCopy(newArray+i); + } + return newArray; +} + +/*! \internal */ +void destroyDeepCopiedTQUObjectArray(TQUObject* uArray) +{ + int count = 0; + while (!((uArray+count)->isLastObject)) { + count++; + } + count++; + for (int i=0; i~TQUObject(); + } + free(uArray); +} + +/*! + \fn bool TQObject::isWidgetType() const + + Returns TRUE if the object is a widget; otherwise returns FALSE. + + Calling this function is equivalent to calling + inherits("TQWidget"), except that it is much faster. +*/ + +/*! + \fn bool TQObject::highPriority() const + + Returns TRUE if the object is a high-priority object, or FALSE if + it is a standard-priority object. + + High-priority objects are placed first in TQObject's list of + children on the assumption that they will be referenced very + often. +*/ + + +/*! + This virtual function receives events to an object and should + return TRUE if the event \a e was recognized and processed. + + The event() function can be reimplemented to customize the + behavior of an object. + + \sa installEventFilter(), timerEvent(), TQApplication::sendEvent(), + TQApplication::postEvent(), TQWidget::event() +*/ + +bool TQObject::event( TQEvent *e ) +{ +#if defined(QT_CHECK_NULL) + if ( e == 0 ) { + tqWarning( "TQObject::event: Null events are not permitted" ); + } +#endif + if ( wasDeleted ) { + return TRUE; + } + if ( eventFilters ) { // try filters + if ( activate_filters(e) ) { // stopped by a filter + return TRUE; + } + } + + switch ( e->type() ) { + case TQEvent::Timer: + timerEvent( (TQTimerEvent*)e ); + return TRUE; + + case TQEvent::ChildInserted: + case TQEvent::ChildRemoved: + childEvent( (TQChildEvent*)e ); + return TRUE; + + case TQEvent::DeferredDelete: + delete this; + return TRUE; + + case TQEvent::MetaCall: + { + TQMetaCallEvent* metaEvent = dynamic_cast(e); + if (metaEvent) { +#ifdef TQT_THREAD_SUPPORT + if ((d->disableThreadPostedEvents) + || (d->ownThread == TQThread::currentThreadObject())) +#endif // TQT_THREAD_SUPPORT + { + TQSenderObjectList* sol; + TQObject* oldSender = 0; + sol = senderObjects; +#ifdef TQT_THREAD_SUPPORT + sol->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + if ( sol ) { + oldSender = sol->currentSender; + sol->ref(); + sol->currentSender = metaEvent->sender(); + } +#ifdef TQT_THREAD_SUPPORT + sol->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + TQUObject *o = metaEvent->data(); + if (metaEvent->type() == TQMetaCallEvent::MetaCallEmit) { + tqt_emit( metaEvent->id(), o ); + } + if (metaEvent->type() == TQMetaCallEvent::MetaCallInvoke) { + tqt_invoke( metaEvent->id(), o ); + } +#ifdef TQT_THREAD_SUPPORT + sol->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + if (sol ) { + sol->currentSender = oldSender; + if ( sol->deref() ) { +#ifdef TQT_THREAD_SUPPORT + sol->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + delete sol; + sol = NULL; + } + } +#ifdef TQT_THREAD_SUPPORT + if (sol) sol->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + } +#ifdef TQT_THREAD_SUPPORT + else { + tqWarning("TQObject: Ignoring metacall event from non-owning thread"); + } +#endif // TQT_THREAD_SUPPORT + destroyDeepCopiedTQUObjectArray(metaEvent->data()); + } + } + + default: + if ( e->type() >= TQEvent::User ) { + customEvent( (TQCustomEvent*) e ); + return TRUE; + } + break; + } + return FALSE; +} + +/*! + This event handler can be reimplemented in a subclass to receive + timer events for the object. + + TQTimer provides a higher-level interface to the timer + functionality, and also more general information about timers. + + \sa startTimer(), killTimer(), killTimers(), event() +*/ + +void TQObject::timerEvent( TQTimerEvent * ) +{ +} + + +/*! + This event handler can be reimplemented in a subclass to receive + child events. + + Child events are sent to objects when children are inserted or + removed. + + Note that events with TQEvent::type() \c TQEvent::ChildInserted are + posted (with \l{TQApplication::postEvent()}) to make sure that the + child's construction is completed before this function is called. + + If a child is removed immediately after it is inserted, the \c + ChildInserted event may be suppressed, but the \c ChildRemoved + event will always be sent. In such cases it is possible that there + will be a \c ChildRemoved event without a corresponding \c + ChildInserted event. + + If you change state based on \c ChildInserted events, call + TQWidget::constPolish(), or do + \code + TQApplication::sendPostedEvents( this, TQEvent::ChildInserted ); + \endcode + in functions that depend on the state. One notable example is + TQWidget::sizeHint(). + + \sa event(), TQChildEvent +*/ + +void TQObject::childEvent( TQChildEvent * ) +{ +} + +/*! + This event handler can be reimplemented in a subclass to receive + custom events. Custom events are user-defined events with a type + value at least as large as the "User" item of the \l TQEvent::Type + enum, and is typically a TQCustomEvent or TQCustomEvent subclass. + + \sa event(), TQCustomEvent +*/ +void TQObject::customEvent( TQCustomEvent * ) +{ +} + + + +/*! + Filters events if this object has been installed as an event + filter for the \a watched object. + + In your reimplementation of this function, if you want to filter + the event \a e, out, i.e. stop it being handled further, return + TRUE; otherwise return FALSE. + + Example: + \code + class MyMainWindow : public TQMainWindow + { + public: + MyMainWindow( TQWidget *parent = 0, const char *name = 0 ); + + protected: + bool eventFilter( TQObject *obj, TQEvent *ev ); + + private: + TQTextEdit *textEdit; + }; + + MyMainWindow::MyMainWindow( TQWidget *parent, const char *name ) + : TQMainWindow( parent, name ) + { + textEdit = new TQTextEdit( this ); + setCentralWidget( textEdit ); + textEdit->installEventFilter( this ); + } + + bool MyMainWindow::eventFilter( TQObject *obj, TQEvent *ev ) + { + if ( obj == textEdit ) { + if ( e->type() == TQEvent::KeyPress ) { + TQKeyEvent *k = (TQKeyEvent*)ev; + tqDebug( "Ate key press %d", k->key() ); + return TRUE; + } else { + return FALSE; + } + } else { + // pass the event on to the parent class + return TQMainWindow::eventFilter( obj, ev ); + } + } + \endcode + + Notice in the example above that unhandled events are passed to + the base class's eventFilter() function, since the base class + might have reimplemented eventFilter() for its own internal + purposes. + + \warning If you delete the receiver object in this function, be + sure to return TRUE. Otherwise, TQt will forward the event to the + deleted object and the program might crash. + + \sa installEventFilter() +*/ + +bool TQObject::eventFilter( TQObject * /* watched */, TQEvent * /* e */ ) +{ + return FALSE; +} + + +/*! + \internal + Activates all event filters for this object. + This function is normally called from TQObject::event() or TQWidget::event(). +*/ + +bool TQObject::activate_filters( TQEvent *e ) +{ + if ( !eventFilters ) // no event filter + return FALSE; + TQObjectListIt it( *eventFilters ); + TQObject *obj = it.current(); + while ( obj ) { // send to all filters + ++it; // until one returns TRUE + if ( obj->eventFilter(this,e) ) { + return TRUE; + } + obj = it.current(); + } + return FALSE; // don't do anything with it +} + + +/*! + \fn bool TQObject::signalsBlocked() const + + Returns TRUE if signals are blocked; otherwise returns FALSE. + + Signals are not blocked by default. + + \sa blockSignals() +*/ + +/*! + Blocks signals if \a block is TRUE, or unblocks signals if \a + block is FALSE. + + Emitted signals disappear into hyperspace if signals are blocked. + Note that the destroyed() signals will be emitted even if the signals + for this object have been blocked. +*/ + +void TQObject::blockSignals( bool block ) +{ + blockSig = block; +} + + +// +// The timer flag hasTimer is set when startTimer is called. +// It is not reset when killing the timer because more than +// one timer might be active. +// + +/*! + Starts a timer and returns a timer identifier, or returns zero if + it could not start a timer. + + A timer event will occur every \a interval milliseconds until + killTimer() or killTimers() is called. If \a interval is 0, then + the timer event occurs once every time there are no more window + system events to process. + + The virtual timerEvent() function is called with the TQTimerEvent + event parameter class when a timer event occurs. Reimplement this + function to get timer events. + + If multiple timers are running, the TQTimerEvent::timerId() can be + used to find out which timer was activated. + + Example: + \code + class MyObject : public TQObject + { + TQ_OBJECT + public: + MyObject( TQObject *parent = 0, const char *name = 0 ); + + protected: + void timerEvent( TQTimerEvent * ); + }; + + MyObject::MyObject( TQObject *parent, const char *name ) + : TQObject( parent, name ) + { + startTimer( 50 ); // 50-millisecond timer + startTimer( 1000 ); // 1-second timer + startTimer( 60000 ); // 1-minute timer + } + + void MyObject::timerEvent( TQTimerEvent *e ) + { + tqDebug( "timer event, id %d", e->timerId() ); + } + \endcode + + Note that TQTimer's accuracy depends on the underlying operating + system and hardware. Most platforms support an accuracy of 20 ms; + some provide more. If TQt is unable to deliver the requested + number of timer clicks, it will silently discard some. + + The TQTimer class provides a high-level programming interface with + one-shot timers and timer signals instead of events. + + \sa timerEvent(), killTimer(), killTimers(), TQEventLoop::awake(), + TQEventLoop::aboutToBlock() +*/ + +int TQObject::startTimer( int interval ) +{ + pendTimer = TRUE; // set timer flag + return qStartTimer( interval, (TQObject *)this ); +} + +/*! + Kills the timer with timer identifier, \a id. + + The timer identifier is returned by startTimer() when a timer + event is started. + + \sa timerEvent(), startTimer(), killTimers() +*/ + +void TQObject::killTimer( int id ) +{ + qKillTimer( id ); +} + +/*! + Kills all timers that this object has started. + + \warning Using this function can cause hard-to-find bugs: it kills + timers started by sub- and superclasses as well as those started + by you, which is often not what you want. We recommend using a + TQTimer or perhaps killTimer(). + + \sa timerEvent(), startTimer(), killTimer() +*/ + +void TQObject::killTimers() +{ + qKillTimer( this ); +} + +static void objSearch( TQObjectList *result, + TQObjectList *list, + const char *inheritsClass, + bool onlyWidgets, + const char *objName, + TQRegExp *rx, + bool recurse ) +{ + if ( !list || list->isEmpty() ) // nothing to search + return; + TQObject *obj = list->first(); + while ( obj ) { + bool ok = TRUE; + if ( onlyWidgets ) + ok = obj->isWidgetType(); + else if ( inheritsClass && !obj->inherits(inheritsClass) ) + ok = FALSE; + if ( ok ) { + if ( objName ) + ok = ( qstrcmp(objName,obj->name()) == 0 ); +#ifndef TQT_NO_REGEXP + else if ( rx ) + ok = ( rx->search(TQString::fromLatin1(obj->name())) != -1 ); +#endif + } + if ( ok ) // match! + result->append( obj ); + if ( recurse && obj->children() ) + objSearch( result, (TQObjectList *)obj->children(), inheritsClass, + onlyWidgets, objName, rx, recurse ); + obj = list->next(); + } +} + +/*! + \fn TQObject *TQObject::parent() const + + Returns a pointer to the parent object. + + \sa children() +*/ + +/*! + \fn const TQObjectList *TQObject::children() const + + Returns a list of child objects, or 0 if this object has no + children. + + The TQObjectList class is defined in the \c tqobjectlist.h header + file. + + The first child added is the \link TQPtrList::first() first\endlink + object in the list and the last child added is the \link + TQPtrList::last() last\endlink object in the list, i.e. new + children are appended at the end. + + Note that the list order changes when TQWidget children are \link + TQWidget::raise() raised\endlink or \link TQWidget::lower() + lowered.\endlink A widget that is raised becomes the last object + in the list, and a widget that is lowered becomes the first object + in the list. + + \sa child(), queryList(), parent(), insertChild(), removeChild() +*/ + + +/*! + Returns a pointer to the list of all object trees (their root + objects), or 0 if there are no objects. + + The TQObjectList class is defined in the \c tqobjectlist.h header + file. + + The most recent root object created is the \link TQPtrList::first() + first\endlink object in the list and the first root object added + is the \link TQPtrList::last() last\endlink object in the list. + + \sa children(), parent(), insertChild(), removeChild() +*/ +const TQObjectList *TQObject::objectTrees() +{ + return object_trees; +} + + +/*! + 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 TQRegExp. 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 TQObject, + the way inherits() does. According to inherits(), TQMenuBar + inherits TQWidget but not TQMenuData. This does not quite match + reality, but is the best that can be done on the wide variety of + compilers TQt 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: + \code + TQObjectList *l = topLevelWidget()->queryList( "TQButton" ); + TQObjectListIt it( *l ); // iterate over the buttons + TQObject *obj; + + while ( (obj = it.current()) != 0 ) { + // for each found object... + ++it; + ((TQButton*)obj)->setEnabled( FALSE ); + } + delete l; // delete the list, not the objects + \endcode + + The TQObjectList class is defined in the \c tqobjectlist.h header + file. + + \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(), name(), TQRegExp +*/ + +TQObjectList *TQObject::queryList( const char *inheritsClass, + const char *objName, + bool regexpMatch, + bool recursiveSearch ) const +{ + TQObjectList *list = new TQObjectList; + TQ_CHECK_PTR( list ); + bool onlyWidgets = ( inheritsClass && qstrcmp(inheritsClass, "TQWidget") == 0 ); +#ifndef TQT_NO_REGEXP + if ( regexpMatch && objName ) { // regexp matching + TQRegExp rx(TQString::fromLatin1(objName)); + objSearch( list, (TQObjectList *)children(), inheritsClass, onlyWidgets, + 0, &rx, recursiveSearch ); + } else +#endif + { + objSearch( list, (TQObjectList *)children(), inheritsClass, onlyWidgets, + objName, 0, recursiveSearch ); + } + return list; +} + +/*! \internal + + Returns a list of objects/slot pairs that are connected to the + \a signal, or 0 if nothing is connected to it. +*/ + +TQConnectionList *TQObject::receivers( const char* signal ) const +{ + if ( connections && signal ) { + if ( *signal == '2' ) { // tag == 2, i.e. signal + TQCString s = qt_rmWS( signal+1 ); + return receivers( metaObject()->findSignal( (const char*)s, TRUE ) ); + } else { + return receivers( metaObject()->findSignal(signal, TRUE ) ); + } + } + return 0; +} + +/*! \internal + + Returns a list of objects/slot pairs that are connected to the + signal, or 0 if nothing is connected to it. +*/ + +TQConnectionList *TQObject::receivers( int signal ) const +{ +#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY + if ( tqt_preliminary_signal_spy && signal >= 0 ) { + if ( !connections ) { + TQObject* that = (TQObject*) this; + that->connections = new TQSignalVec( signal+1 ); + that->connections->setAutoDelete( TRUE ); + } + if ( !connections->at( signal ) ) { + TQConnectionList* clist = new TQConnectionList; + clist->setAutoDelete( TRUE ); + connections->insert( signal, clist ); + return clist; + } + } +#endif + if ( connections && signal >= 0 ) + return connections->at( signal ); + return 0; +} + + +/*! + Inserts an object \a obj into the list of child objects. + + \warning This function cannot be used to make one widget the child + widget of another widget. Child widgets can only be created by + setting the parent widget in the constructor or by calling + TQWidget::reparent(). + + \sa removeChild(), TQWidget::reparent() +*/ + +void TQObject::insertChild( TQObject *obj ) +{ +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker locker( d->childObjectListMutex ); +#endif // TQT_THREAD_SUPPORT + + if ( obj->isTree ) { + remove_tree( obj ); + obj->isTree = FALSE; + } + if ( obj->parentObj && obj->parentObj != this ) { +#if defined(QT_CHECK_STATE) + if ( obj->parentObj != this && obj->isWidgetType() ) + tqWarning( "TQObject::insertChild: Cannot reparent a widget, " + "use TQWidget::reparent() instead" ); +#endif + obj->parentObj->removeChild( obj ); + } + + if ( !childObjects ) { + childObjects = new TQObjectList; + TQ_CHECK_PTR( childObjects ); + } else if ( obj->parentObj == this ) { +#if defined(QT_CHECK_STATE) + tqWarning( "TQObject::insertChild: Object %s::%s already in list", + obj->className(), obj->name( "unnamed" ) ); +#endif + return; + } + obj->parentObj = this; + childObjects->append( obj ); + + TQChildEvent *e = new TQChildEvent( TQEvent::ChildInserted, obj ); + TQApplication::postEvent( this, e ); +} + +/*! + Removes the child object \a obj from the list of children. + + \warning This function will not remove a child widget from the + screen. It will only remove it from the parent widget's list of + children. + + \sa insertChild(), TQWidget::reparent() +*/ + +void TQObject::removeChild( TQObject *obj ) +{ +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker locker( d->childObjectListMutex ); +#endif // TQT_THREAD_SUPPORT + + if ( childObjects && childObjects->removeRef(obj) ) { + obj->parentObj = 0; + if ( !obj->wasDeleted ) { + insert_tree( obj ); // it's a root object now + obj->isTree = TRUE; + } + if ( childObjects->isEmpty() ) { + delete childObjects; // last child removed + childObjects = 0; // reset children list + } + + // remove events must be sent, not posted!!! + TQChildEvent ce( TQEvent::ChildRemoved, obj ); + TQApplication::sendEvent( this, &ce ); + } +} + + +/*! + \fn void TQObject::installEventFilter( const TQObject *filterObj ) + + Installs an event filter \a filterObj on this object. For example: + \code + monitoredObj->installEventFilter( filterObj ); + \endcode + + An event filter is an object that receives all events that are + sent to this object. The filter can either stop the event or + forward it to this object. The event filter \a filterObj receives + events via its eventFilter() function. The eventFilter() function + must return TRUE if the event should be filtered, (i.e. stopped); + otherwise it must return FALSE. + + If multiple event filters are installed on a single object, the + filter that was installed last is activated first. + + Here's a \c KeyPressEater class that eats the key presses of its + monitored objects: + \code + class KeyPressEater : public TQObject + { + ... + protected: + bool eventFilter( TQObject *o, TQEvent *e ); + }; + + bool KeyPressEater::eventFilter( TQObject *o, TQEvent *e ) + { + if ( e->type() == TQEvent::KeyPress ) { + // special processing for key press + TQKeyEvent *k = (TQKeyEvent *)e; + tqDebug( "Ate key press %d", k->key() ); + return TRUE; // eat event + } else { + // standard event processing + return FALSE; + } + } + \endcode + + And here's how to install it on two widgets: + \code + KeyPressEater *keyPressEater = new KeyPressEater( this ); + TQPushButton *pushButton = new TQPushButton( this ); + TQListView *listView = new TQListView( this ); + + pushButton->installEventFilter( keyPressEater ); + listView->installEventFilter( keyPressEater ); + \endcode + + The TQAccel class, for example, uses this technique to intercept + accelerator key presses. + + \warning If you delete the receiver object in your eventFilter() + function, be sure to return TRUE. If you return FALSE, TQt sends + the event to the deleted object and the program will crash. + + \sa removeEventFilter(), eventFilter(), event() +*/ + +void TQObject::installEventFilter( const TQObject *obj ) +{ + if ( !obj ) + return; + if ( eventFilters ) { + int c = eventFilters->findRef( obj ); + if ( c >= 0 ) + eventFilters->take( c ); + disconnect( obj, TQ_SIGNAL(destroyed(TQObject*)), + this, TQ_SLOT(cleanupEventFilter(TQObject*)) ); + } else { + eventFilters = new TQObjectList; + TQ_CHECK_PTR( eventFilters ); + } + eventFilters->insert( 0, obj ); + connect( obj, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(cleanupEventFilter(TQObject*)) ); +} + +/*! + Removes an event filter object \a obj from this object. The + request is ignored if such an event filter has not been installed. + + All event filters for this object are automatically removed when + this object is destroyed. + + It is always safe to remove an event filter, even during event + filter activation (i.e. from the eventFilter() function). + + \sa installEventFilter(), eventFilter(), event() +*/ + +void TQObject::removeEventFilter( const TQObject *obj ) +{ + if ( eventFilters && eventFilters->removeRef(obj) ) { + if ( eventFilters->isEmpty() ) { // last event filter removed + delete eventFilters; + eventFilters = 0; // reset event filter list + } + disconnect( obj, TQ_SIGNAL(destroyed(TQObject*)), + this, TQ_SLOT(cleanupEventFilter(TQObject*)) ); + } +} + + +/***************************************************************************** + Signal connection management + *****************************************************************************/ + +#if defined(QT_CHECK_RANGE) + +static bool check_signal_macro( const TQObject *sender, const char *signal, + const char *func, const char *op ) +{ + int sigcode = (int)(*signal) - '0'; + if ( sigcode != TQ_SIGNAL_CODE ) { + if ( sigcode == TQ_SLOT_CODE ) + tqWarning( "TQObject::%s: Attempt to %s non-signal %s::%s", + func, op, sender->className(), signal+1 ); + else + tqWarning( "TQObject::%s: Use the TQ_SIGNAL macro to %s %s::%s", + func, op, sender->className(), signal ); + return FALSE; + } + return TRUE; +} + +static bool check_member_code( int code, const TQObject *object, + const char *member, const char *func ) +{ + if ( code != TQ_SLOT_CODE && code != TQ_SIGNAL_CODE ) { + tqWarning( "TQObject::%s: Use the TQ_SLOT or TQ_SIGNAL macro to " + "%s %s::%s", func, func, object->className(), member ); + return FALSE; + } + return TRUE; +} + +static void err_member_notfound( int code, const TQObject *object, + const char *member, const char *func ) +{ + const char *type = 0; + switch ( code ) { + case TQ_SLOT_CODE: type = "slot"; break; + case TQ_SIGNAL_CODE: type = "signal"; break; + } + if ( strchr(member,')') == 0 ) // common typing mistake + tqWarning( "TQObject::%s: Parentheses expected, %s %s::%s", + func, type, object->className(), member ); + else + tqWarning( "TQObject::%s: No such %s %s::%s", + func, type, object->className(), member ); +} + + +static void err_info_about_objects( const char * func, + const TQObject * sender, + const TQObject * receiver ) +{ + const char * a = sender->name(), * b = receiver->name(); + if ( a ) + tqWarning( "TQObject::%s: (sender name: '%s')", func, a ); + if ( b ) + tqWarning( "TQObject::%s: (receiver name: '%s')", func, b ); +} + +static void err_info_about_candidates( int code, + const TQMetaObject* mo, + const char* member, + const char *func ) +{ + if ( strstr(member,"const char*") ) { + // porting help + TQCString newname = member; + int p; + while ( (p=newname.find("const char*")) >= 0 ) { + newname.replace(p, 11, "const TQString&"); + } + const TQMetaData *rm = 0; + switch ( code ) { + case TQ_SLOT_CODE: + rm = mo->slot( mo->findSlot( newname, TRUE ), TRUE ); + break; + case TQ_SIGNAL_CODE: + rm = mo->signal( mo->findSignal( newname, TRUE ), TRUE ); + break; + } + if ( rm ) { + tqWarning("TQObject::%s: Candidate: %s", func, newname.data()); + } + } +} + + +#endif // QT_CHECK_RANGE + + +/*! + Returns a pointer to the object that sent the signal, if called in + a slot activated by a signal; otherwise it returns 0. The pointer + is valid only during the execution of the slot that calls this + function. + + The pointer returned by this function becomes invalid if the + sender is destroyed, or if the slot is disconnected from the + sender's signal. + + \warning This function violates the object-oriented principle of + modularity. However, getting access to the sender might be useful + when many signals are connected to a single slot. The sender is + undefined if the slot is called as a normal C++ function. +*/ + +const TQObject *TQObject::sender() +{ +#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY + if ( this == tqt_preliminary_signal_spy ) { +# ifdef TQT_THREAD_SUPPORT + // protect access to qt_spy_signal_sender + void * const address = &qt_spy_signal_sender; + TQMutexLocker locker( tqt_global_mutexpool ? + tqt_global_mutexpool->get( address ) : 0 ); +# endif // TQT_THREAD_SUPPORT + return qt_spy_signal_sender; + } +#endif + if ( senderObjects && + senderObjects->currentSender && + /* + * currentSender may be a dangling pointer in case the object + * it was pointing to was destructed from inside a slot. Thus + * verify it still is contained inside the senderObjects list + * which gets cleaned on both destruction and disconnect. + */ + + senderObjects->findRef( senderObjects->currentSender ) != -1 ) + return senderObjects->currentSender; + return 0; +} + + +/*! + \fn void TQObject::connectNotify( const char *signal ) + + This virtual function is called when something has been connected + to \a signal in this object. + + \warning This function violates the object-oriented principle of + modularity. However, it might be useful when you need to perform + expensive initialization only if something is connected to a + signal. + + \sa connect(), disconnectNotify() +*/ + +void TQObject::connectNotify( const char * ) +{ +} + +/*! + \fn void TQObject::disconnectNotify( const char *signal ) + + This virtual function is called when something has been + disconnected from \a signal in this object. + + \warning This function violates the object-oriented principle of + modularity. However, it might be useful for optimizing access to + expensive resources. + + \sa disconnect(), connectNotify() +*/ + +void TQObject::disconnectNotify( const char * ) +{ +} + + +/*! + \fn bool TQObject::checkConnectArgs( const char *signal, const TQObject *receiver, const char *member ) + + Returns TRUE if the \a signal and the \a member arguments are + compatible; otherwise returns FALSE. (The \a receiver argument is + currently ignored.) + + \warning We recommend that you use the default implementation and + do not reimplement this function. + + \omit + TRUE: "signal()", "member()" + TRUE: "signal(a,b,c)", "member(a,b,c)" + TRUE: "signal(a,b,c)", "member(a,b)", "member(a)" etc. + FALSE: "signal(const a)", "member(a)" + FALSE: "signal(a)", "member(const a)" + FALSE: "signal(a)", "member(b)" + FALSE: "signal(a)", "member(a,b)" + \endomit +*/ + +bool TQObject::checkConnectArgs( const char *signal, + const TQObject *, + const char *member ) +{ + const char *s1 = signal; + const char *s2 = member; + while ( *s1++ != '(' ) { } // scan to first '(' + while ( *s2++ != '(' ) { } + if ( *s2 == ')' || qstrcmp(s1,s2) == 0 ) // member has no args or + return TRUE; // exact match + int s1len = tqstrlen(s1); + int s2len = tqstrlen(s2); + if ( s2len < s1len && tqstrncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==',' ) + return TRUE; // member has less args + return FALSE; +} + +/*! + Normlizes the signal or slot definition \a signalSlot by removing + unnecessary whitespace. +*/ + +TQCString TQObject::normalizeSignalSlot( const char *signalSlot ) +{ + if ( !signalSlot ) + return TQCString(); + return qt_rmWS( signalSlot ); +} + + + +/*! + \overload bool TQObject::connect( const TQObject *sender, const char *signal, const char *member ) const + + Connects \a signal from the \a sender object to this object's \a + member. + + Equivalent to: \c{TQObject::connect(sender, signal, this, member)}. + + \sa disconnect() +*/ + +/*! + Connects \a signal from the \a sender object to \a member in object + \a receiver, and returns TRUE if the connection succeeds; otherwise + returns FALSE. + + You must use the TQ_SIGNAL() and TQ_SLOT() macros when specifying the \a signal + and the \a member, for example: + \code + TQLabel *label = new TQLabel; + TQScrollBar *scroll = new TQScrollBar; + TQObject::connect( scroll, TQ_SIGNAL(valueChanged(int)), + label, TQ_SLOT(setNum(int)) ); + \endcode + + This example ensures that the label always displays the current + scroll bar value. Note that the signal and slots parameters must not + contain any variable names, only the type. E.g. the following would + not work and return FALSE: + TQObject::connect( scroll, TQ_SIGNAL(valueChanged(int v)), + label, TQ_SLOT(setNum(int v)) ); + + A signal can also be connected to another signal: + + \code + class MyWidget : public TQWidget + { + TQ_OBJECT + public: + MyWidget(); + + signals: + void myUsefulSignal(); + + private: + TQPushButton *aButton; + }; + + MyWidget::MyWidget() + { + aButton = new TQPushButton( this ); + connect( aButton, TQ_SIGNAL(clicked()), TQ_SIGNAL(myUsefulSignal()) ); + } + \endcode + + In this example, the MyWidget constructor relays a signal from a + private member variable, and makes it available under a name that + relates to MyWidget. + + A signal can be connected to many slots and signals. Many signals + can be connected to one slot. + + If a signal is connected to several slots, the slots are activated + in an arbitrary order when the signal is emitted. + + The function returns TRUE if it successfully connects the signal + to the slot. It will return FALSE if it cannot create the + connection, for example, if TQObject is unable to verify the + existence of either \a signal or \a member, or if their signatures + aren't compatible. + + A signal is emitted for \e{every} connection you make, so if you + duplicate a connection, two signals will be emitted. You can + always break a connection using \c{disconnect()}. + + \sa disconnect() +*/ + +bool TQObject::connect( const TQObject *sender, const char *signal, + const TQObject *receiver, const char *member ) +{ +#if defined(QT_CHECK_NULL) + if ( sender == 0 || receiver == 0 || signal == 0 || member == 0 ) { + tqWarning( "TQObject::connect: Cannot connect %s::%s to %s::%s", + sender ? sender->className() : "(null)", + signal ? signal+1 : "(null)", + receiver ? receiver->className() : "(null)", + member ? member+1 : "(null)" ); + return FALSE; + } +#endif + TQMetaObject *smeta = sender->metaObject(); + +#if defined(QT_CHECK_RANGE) + if ( !check_signal_macro( sender, signal, "connect", "bind" ) ) + return FALSE; +#endif + TQCString nw_signal(signal); // Assume already normalized + ++signal; // skip member type code + + int signal_index = smeta->findSignal( signal, TRUE ); + if ( signal_index < 0 ) { // normalize and retry + nw_signal = qt_rmWS( signal-1 ); // remove whitespace + signal = nw_signal.data()+1; // skip member type code + signal_index = smeta->findSignal( signal, TRUE ); + } + + if ( signal_index < 0 ) { // no such signal +#if defined(QT_CHECK_RANGE) + err_member_notfound( TQ_SIGNAL_CODE, sender, signal, "connect" ); + err_info_about_candidates( TQ_SIGNAL_CODE, smeta, signal, "connect" ); + err_info_about_objects( "connect", sender, receiver ); +#endif + return FALSE; + } + const TQMetaData *sm = smeta->signal( signal_index, TRUE ); + signal = sm->name; // use name from meta object + + int membcode = member[0] - '0'; // get member code + + TQObject *s = (TQObject *)sender; // we need to change them + TQObject *r = (TQObject *)receiver; // internally + +#if defined(QT_CHECK_RANGE) + if ( !check_member_code( membcode, r, member, "connect" ) ) + return FALSE; +#endif + member++; // skip code + + TQCString nw_member ; + TQMetaObject *rmeta = r->metaObject(); + int member_index = -1; + switch ( membcode ) { // get receiver member + case TQ_SLOT_CODE: + member_index = rmeta->findSlot( member, TRUE ); + if ( member_index < 0 ) { // normalize and retry + nw_member = qt_rmWS(member); // remove whitespace + member = nw_member; + member_index = rmeta->findSlot( member, TRUE ); + } + break; + case TQ_SIGNAL_CODE: + member_index = rmeta->findSignal( member, TRUE ); + if ( member_index < 0 ) { // normalize and retry + nw_member = qt_rmWS(member); // remove whitespace + member = nw_member; + member_index = rmeta->findSignal( member, TRUE ); + } + break; + } + if ( member_index < 0 ) { +#if defined(QT_CHECK_RANGE) + err_member_notfound( membcode, r, member, "connect" ); + err_info_about_candidates( membcode, rmeta, member, "connect" ); + err_info_about_objects( "connect", sender, receiver ); +#endif + return FALSE; + } +#if defined(QT_CHECK_RANGE) + if ( !s->checkConnectArgs(signal,receiver,member) ) { + tqWarning( "TQObject::connect: Incompatible sender/receiver arguments" + "\n\t%s::%s --> %s::%s", + s->className(), signal, + r->className(), member ); + return FALSE; + } else { + const TQMetaData *rm = membcode == TQ_SLOT_CODE ? + rmeta->slot( member_index, TRUE ) : + rmeta->signal( member_index, TRUE ); + if ( rm ) { + int si = 0; + int ri = 0; + while ( si < sm->method->count && ri < rm->method->count ) { + if ( sm->method->parameters[si].inOut == TQUParameter::Out ) + si++; + else if ( rm->method->parameters[ri].inOut == TQUParameter::Out ) + ri++; + else if ( !TQUType::isEqual( sm->method->parameters[si++].type, + rm->method->parameters[ri++].type ) ) { + if ( ( TQUType::isEqual( sm->method->parameters[si-1].type, &static_QUType_ptr ) + && TQUType::isEqual( rm->method->parameters[ri-1].type, &static_QUType_varptr ) ) + || ( TQUType::isEqual( sm->method->parameters[si-1].type, &static_QUType_varptr ) + && TQUType::isEqual( rm->method->parameters[ri-1].type, &static_QUType_ptr ) ) ) + continue; // varptr got introduced in 3.1 and is binary compatible with ptr + tqWarning( "TQObject::connect: Incompatible sender/receiver marshalling" + "\n\t%s::%s --> %s::%s", + s->className(), signal, + r->className(), member ); + return FALSE; + } + } + } + } +#endif + connectInternal( sender, signal_index, receiver, membcode, member_index ); + s->connectNotify( nw_signal ); + return TRUE; +} + +/*! \internal */ + +void TQObject::connectInternal( const TQObject *sender, int signal_index, const TQObject *receiver, + int membcode, int member_index ) +{ + TQObject *s = (TQObject*)sender; + TQObject *r = (TQObject*)receiver; + + if ( !s->connections ) { // create connections lookup table + s->connections = new TQSignalVec( signal_index+1 ); + TQ_CHECK_PTR( s->connections ); + s->connections->setAutoDelete( TRUE ); + } + + TQConnectionList *clist = s->connections->at( signal_index ); + if ( !clist ) { // create receiver list + clist = new TQConnectionList; + TQ_CHECK_PTR( clist ); + clist->setAutoDelete( TRUE ); + s->connections->insert( signal_index, clist ); + } + + TQMetaObject *rmeta = r->metaObject(); + const TQMetaData *rm = 0; + + switch ( membcode ) { // get receiver member + case TQ_SLOT_CODE: + rm = rmeta->slot( member_index, TRUE ); + break; + case TQ_SIGNAL_CODE: + rm = rmeta->signal( member_index, TRUE ); + break; + } + + TQConnection *c = new TQConnection( r, member_index, rm ? rm->name : "qt_invoke", membcode ); + TQ_CHECK_PTR( c ); + clist->append( c ); + if ( !r->senderObjects ) { // create list of senders +#ifdef TQT_THREAD_SUPPORT + r->d->senderObjectListMutex->lock(); +#endif // TQT_THREAD_SUPPORT + r->senderObjects = new TQSenderObjectList; +#ifdef TQT_THREAD_SUPPORT + r->senderObjects->listMutex->lock(); + r->d->senderObjectListMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + } + else { +#ifdef TQT_THREAD_SUPPORT + r->senderObjects->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + } + r->senderObjects->append( s ); // add sender to list +#ifdef TQT_THREAD_SUPPORT + r->senderObjects->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT +} + + +/*! + \overload bool TQObject::disconnect( const char *signal, const TQObject *receiver, const char *member ) + + Disconnects \a signal from \a member of \a receiver. + + A signal-slot connection is removed when either of the objects + involved are destroyed. +*/ + +/*! + \overload bool TQObject::disconnect( const TQObject *receiver, const char *member ) + + Disconnects all signals in this object from \a receiver's \a + member. + + A signal-slot connection is removed when either of the objects + involved are destroyed. +*/ + +/*! + Disconnects \a signal in object \a sender from \a member in object + \a receiver. + + A signal-slot connection is removed when either of the objects + involved are destroyed. + + disconnect() is typically used in three ways, as the following + examples demonstrate. + \list 1 + \i Disconnect everything connected to an object's signals: + \code + disconnect( myObject, 0, 0, 0 ); + \endcode + equivalent to the non-static overloaded function + \code + myObject->disconnect(); + \endcode + \i Disconnect everything connected to a specific signal: + \code + disconnect( myObject, TQ_SIGNAL(mySignal()), 0, 0 ); + \endcode + equivalent to the non-static overloaded function + \code + myObject->disconnect( TQ_SIGNAL(mySignal()) ); + \endcode + \i Disconnect a specific receiver: + \code + disconnect( myObject, 0, myReceiver, 0 ); + \endcode + equivalent to the non-static overloaded function + \code + myObject->disconnect( myReceiver ); + \endcode + \endlist + + 0 may be used as a wildcard, meaning "any signal", "any receiving + object", or "any slot in the receiving object", respectively. + + The \a sender may never be 0. (You cannot disconnect signals from + more than one object in a single call.) + + If \a signal is 0, it disconnects \a receiver and \a member from + any signal. If not, only the specified signal is disconnected. + + If \a receiver is 0, it disconnects anything connected to \a + signal. If not, slots in objects other than \a receiver are not + disconnected. + + If \a member is 0, it disconnects anything that is connected to \a + receiver. If not, only slots named \a member will be disconnected, + and all other slots are left alone. The \a member must be 0 if \a + receiver is left out, so you cannot disconnect a + specifically-named slot on all objects. + + \sa connect() +*/ + +bool TQObject::disconnect( const TQObject *sender, const char *signal, + const TQObject *receiver, const char *member ) +{ +#if defined(QT_CHECK_NULL) + if ( sender == 0 || (receiver == 0 && member != 0) ) { + tqWarning( "TQObject::disconnect: Unexpected null parameter" ); + return FALSE; + } +#endif + if ( !sender->connections ) // no connected signals + return FALSE; + TQObject *s = (TQObject *)sender; + TQObject *r = (TQObject *)receiver; + int member_index = -1; + int membcode = -1; + TQCString nw_member; + if ( member ) { + membcode = member[0] - '0'; +#if defined(QT_CHECK_RANGE) + if ( !check_member_code( membcode, r, member, "disconnect" ) ) + return FALSE; +#endif + ++member; + TQMetaObject *rmeta = r->metaObject(); + + switch ( membcode ) { // get receiver member + case TQ_SLOT_CODE: + member_index = rmeta->findSlot( member, TRUE ); + if ( member_index < 0 ) { // normalize and retry + nw_member = qt_rmWS(member); // remove whitespace + member = nw_member; + member_index = rmeta->findSlot( member, TRUE ); + } + break; + case TQ_SIGNAL_CODE: + member_index = rmeta->findSignal( member, TRUE ); + if ( member_index < 0 ) { // normalize and retry + nw_member = qt_rmWS(member); // remove whitespace + member = nw_member; + member_index = rmeta->findSignal( member, TRUE ); + } + break; + } + if ( member_index < 0 ) { // no such member +#if defined(QT_CHECK_RANGE) + err_member_notfound( membcode, r, member, "disconnect" ); + err_info_about_candidates( membcode, rmeta, member, "connect" ); + err_info_about_objects( "disconnect", sender, receiver ); +#endif + return FALSE; + } + } + + if ( signal == 0 ) { // any/all signals + if ( disconnectInternal( s, -1, r, membcode, member_index ) ) + s->disconnectNotify( 0 ); + else + return FALSE; + } else { // specific signal +#if defined(QT_CHECK_RANGE) + if ( !check_signal_macro( s, signal, "disconnect", "unbind" ) ) + return FALSE; +#endif + TQCString nw_signal(signal); // Assume already normalized + ++signal; // skip member type code + + TQMetaObject *smeta = s->metaObject(); + if ( !smeta ) // no meta object + return FALSE; + int signal_index = smeta->findSignal( signal, TRUE ); + if ( signal_index < 0 ) { // normalize and retry + nw_signal = qt_rmWS( signal-1 ); // remove whitespace + signal = nw_signal.data()+1; // skip member type code + signal_index = smeta->findSignal( signal, TRUE ); + } + if ( signal_index < 0 ) { +#if defined(QT_CHECK_RANGE) + tqWarning( "TQObject::disconnect: No such signal %s::%s", + s->className(), signal ); +#endif + return FALSE; + } + + /* compatibility and safety: If a receiver has several slots + * with the same name, disconnect them all*/ + bool res = FALSE; + if ( membcode == TQ_SLOT_CODE && r ) { + TQMetaObject * rmeta = r->metaObject(); + do { + int mi = rmeta->findSlot( member ); + if ( mi != -1 ) + res |= disconnectInternal( s, signal_index, r, membcode, mi ); + } while ( (rmeta = rmeta->superClass()) ); + } else { + res = disconnectInternal( s, signal_index, r, membcode, member_index ); + } + if ( res ) + s->disconnectNotify( nw_signal ); + return res; + } + return TRUE; +} + +/*! \internal */ + +bool TQObject::disconnectInternal( const TQObject *sender, int signal_index, + const TQObject *receiver, int membcode, int member_index ) +{ + TQObject *s = (TQObject*)sender; + TQObject *r = (TQObject*)receiver; + + if ( !s->connections ) + return FALSE; + + bool success = FALSE; + TQConnectionList *clist; + TQConnection *c; + if ( signal_index == -1 ) { + for ( int i = 0; i < (int) s->connections->size(); i++ ) { + clist = (*s->connections)[i]; // for all signals... + if ( !clist ) + continue; + c = clist->first(); + while ( c ) { // for all receivers... + if ( r == 0 ) { // remove all receivers +#ifdef TQT_THREAD_SUPPORT + if (c->object()->senderObjects) c->object()->senderObjects->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + removeObjFromList( c->object()->senderObjects, s ); +#ifdef TQT_THREAD_SUPPORT + if (c->object()->senderObjects) c->object()->senderObjects->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + success = TRUE; + c = clist->next(); + } else if ( r == c->object() && + ( (member_index == -1) || + ((member_index == c->member()) && (c->memberType() == membcode)) ) ) { +#ifdef TQT_THREAD_SUPPORT + if (c->object()->senderObjects) c->object()->senderObjects->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + removeObjFromList( c->object()->senderObjects, s, TRUE ); +#ifdef TQT_THREAD_SUPPORT + if (c->object()->senderObjects) c->object()->senderObjects->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + success = TRUE; + clist->remove(); + c = clist->current(); + } else { + c = clist->next(); + } + } + if ( r == 0 ) // disconnect all receivers + s->connections->insert( i, 0 ); + } + } else { + clist = s->connections->at( signal_index ); + if ( !clist ) + return FALSE; + + c = clist->first(); + while ( c ) { // for all receivers... + if ( r == 0 ) { // remove all receivers +#ifdef TQT_THREAD_SUPPORT + if (c->object()->senderObjects) c->object()->senderObjects->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + removeObjFromList( c->object()->senderObjects, s, TRUE ); +#ifdef TQT_THREAD_SUPPORT + if (c->object()->senderObjects) c->object()->senderObjects->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + success = TRUE; + c = clist->next(); + } else if ( r == c->object() && + ( (member_index == -1) || + ((member_index == c->member()) && (c->memberType() == membcode)) ) ) { +#ifdef TQT_THREAD_SUPPORT + if (c->object()->senderObjects) c->object()->senderObjects->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + removeObjFromList( c->object()->senderObjects, s, TRUE ); +#ifdef TQT_THREAD_SUPPORT + if (c->object()->senderObjects) c->object()->senderObjects->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + success = TRUE; + clist->remove(); + c = clist->current(); + } else { + c = clist->next(); + } + } + if ( r == 0 ) { // disconnect all receivers + s->connections->insert( signal_index, 0 ); + } + } + return success; +} + +/*! + \fn TQObject::destroyed() + + This signal is emitted when the object is being destroyed. + + Note that the signal is emitted by the TQObject destructor, so + the object's virtual table is already degenerated at this point, + and it is not safe to call any functions on the object emitting + the signal. This signal can not be blocked. + + All the objects's children are destroyed immediately after this + signal is emitted. +*/ + +/*! + \overload TQObject::destroyed( TQObject* obj) + + This signal is emitted immediately before the object \a obj is + destroyed, and can not be blocked. + + All the objects's children are destroyed immediately after this + signal is emitted. +*/ + +/*! + Performs a deferred deletion of this object. + + Instead of an immediate deletion this function schedules a + deferred delete event for processing when TQt returns to the main + event loop. +*/ +void TQObject::deleteLater() +{ + TQApplication::postEvent( this, new TQEvent( TQEvent::DeferredDelete) ); +} + +/*! + This slot is connected to the destroyed() signal of other objects + that have installed event filters on this object. When the other + object, \a obj, is destroyed, we want to remove its event filter. +*/ + +void TQObject::cleanupEventFilter(TQObject* obj) +{ + removeEventFilter( obj ); +} + + +/*! + \fn TQString TQObject::tr( const char *sourceText, const char * comment ) + \reentrant + + Returns a translated version of \a sourceText, or \a sourceText + itself if there is no appropriate translated version. The + translation context is TQObject with \a comment (0 by default). + All TQObject subclasses using the TQ_OBJECT macro automatically have + a reimplementation of this function with the subclass name as + context. + + \warning This method is reentrant only if all translators are + installed \e before calling this method. Installing or removing + translators while performing translations is not supported. Doing + so will probably result in crashes or other undesirable behavior. + + \sa trUtf8() TQApplication::translate() + \link i18n.html Internationalization with TQt\endlink +*/ + +/*! + \fn TQString TQObject::trUtf8( const char *sourceText, + const char *comment ) + \reentrant + + Returns a translated version of \a sourceText, or + TQString::fromUtf8(\a sourceText) if there is no appropriate + version. It is otherwise identical to tr(\a sourceText, \a + comment). + + \warning This method is reentrant only if all translators are + installed \e before calling this method. Installing or removing + translators while performing translations is not supported. Doing + so will probably result in crashes or other undesirable behavior. + + \sa tr() TQApplication::translate() +*/ + +static TQMetaObjectCleanUp cleanUp_TQt = TQMetaObjectCleanUp( "TQObject", &TQObject::staticMetaObject ); + +TQMetaObject* TQObject::staticTQtMetaObject() +{ + static TQMetaObject* qtMetaObject = 0; + if ( qtMetaObject ) + return qtMetaObject; + +#ifndef TQT_NO_PROPERTIES + static const TQMetaEnum::Item enum_0[] = { + { "AlignLeft", (int) TQt::AlignLeft }, + { "AlignRight", (int) TQt::AlignRight }, + { "AlignHCenter", (int) TQt::AlignHCenter }, + { "AlignTop", (int) TQt::AlignTop }, + { "AlignBottom", (int) TQt::AlignBottom }, + { "AlignVCenter", (int) TQt::AlignVCenter }, + { "AlignCenter", (int) TQt::AlignCenter }, + { "AlignAuto", (int) TQt::AlignAuto }, + { "AlignJustify", (int) TQt::AlignJustify }, + { "WordBreak", (int) TQt::WordBreak } + }; + + static const TQMetaEnum::Item enum_1[] = { + { "Horizontal", (int) TQt::Horizontal }, + { "Vertical", (int) TQt::Vertical } + }; + + static const TQMetaEnum::Item enum_2[] = { + { "PlainText", (int) TQt::PlainText }, + { "RichText", (int) TQt::RichText }, + { "AutoText", (int) TQt::AutoText }, + { "LogText", (int) TQt::LogText } + }; + + static const TQMetaEnum::Item enum_3[] = { + { "NoBackground", (int) TQt::NoBackground }, + { "PaletteForeground", (int) TQt::PaletteForeground }, + { "PaletteButton", (int) TQt::PaletteButton }, + { "PaletteLight", (int) TQt::PaletteLight }, + { "PaletteMidlight", (int) TQt::PaletteMidlight }, + { "PaletteDark", (int) TQt::PaletteDark }, + { "PaletteMid", (int) TQt::PaletteMid }, + { "PaletteText", (int) TQt::PaletteText }, + { "PaletteBrightText", (int) TQt::PaletteBrightText }, + { "PaletteBase", (int) TQt::PaletteBase }, + { "PaletteBackground", (int) TQt::PaletteBackground }, + { "PaletteShadow", (int) TQt::PaletteShadow }, + { "PaletteHighlight", (int) TQt::PaletteHighlight }, + { "PaletteHighlightedText", (int) TQt::PaletteHighlightedText }, + { "PaletteButtonText", (int) TQt::PaletteButtonText }, + { "PaletteLink", (int) TQt::PaletteLink }, + { "PaletteLinkVisited", (int) TQt::PaletteLinkVisited } + }; + + static const TQMetaEnum::Item enum_4[] = { + { "TextDate", (int) TQt::TextDate }, + { "ISODate", (int) TQt::ISODate }, + { "LocalDate", (int) TQt::LocalDate } + }; + + + static const TQMetaEnum enum_tbl[] = { + { "Alignment", 10, enum_0, TRUE }, + { "Orientation", 2, enum_1, FALSE }, + { "TextFormat", 4, enum_2, FALSE }, + { "BackgroundMode", 17, enum_3, FALSE }, + { "DateFormat", 3, enum_4, FALSE } + }; +#endif + + qtMetaObject = new TQMetaObject( "TQt", 0, + 0, 0, + 0, 0, +#ifndef TQT_NO_PROPERTIES + 0, 0, + enum_tbl, 5, +#endif + 0, 0 ); + cleanUp_TQt.setMetaObject( qtMetaObject ); + + return qtMetaObject; +} + +/*! + \internal + + Signal activation with the most frequently used parameter/argument + types. All other combinations are generated by the meta object + compiler. + */ +void TQObject::activate_signal( int signal ) +{ +#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY + if ( tqt_preliminary_signal_spy ) { + if ( !signalsBlocked() && signal >= 0 && + ( !connections || !connections->at( signal ) ) ) { + TQUObject o[1]; + o[0].isLastObject = true; + qt_spy_signal( this, signal, o ); + return; + } + } +#endif + + if ( !connections || signalsBlocked() || signal < 0 ) { + return; + } + TQConnectionList *clist = connections->at( signal ); + if ( !clist ) { + return; + } + TQUObject o[1]; + o[0].isLastObject = true; + activate_signal( clist, o ); +} + +/*! \internal */ + +void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o ) +{ + if ( !clist ) { + return; + } + +#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY + if ( tqt_preliminary_signal_spy ) { + qt_spy_signal( this, connections->findRef( clist), o ); + } +#endif + +#ifdef TQT_THREAD_SUPPORT + // NOTE currentThread could be NULL if the current thread was not started using the TQThread API + const TQThread *currentThread = TQThread::currentThreadObject(); +#endif // TQT_THREAD_SUPPORT + + TQObject *object; + TQSenderObjectList* sol; + TQObject* oldSender = 0; + TQConnection *c; + if ( clist->count() == 1 ) { // save iterator + c = clist->first(); + object = c->object(); + sol = object->senderObjects; +#ifdef TQT_THREAD_SUPPORT + sol->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + if ( sol ) { + oldSender = sol->currentSender; + sol->ref(); + sol->currentSender = this; + } + if ( c->memberType() == TQ_SIGNAL_CODE ) { +#if !defined(TQT_THREAD_SUPPORT) + object->tqt_emit( c->member(), o ); +#else // defined(TQT_THREAD_SUPPORT) + if ((d->disableThreadPostedEvents) || + (object->d->disableThreadPostedEvents) || + (currentThread && currentThread->threadPostedEventsDisabled()) || + (currentThread && object->d->ownThread == currentThread)) { + sol->listMutex->unlock(); + object->tqt_emit( c->member(), o ); + sol->listMutex->lock(); + } + else { + if (object->d->ownThread && !object->d->ownThread->finished()) { +#ifdef QT_DEBUG + tqDebug("TQObject::activate_signal: Emitting cross-thread signal from object %p (member %d receiver %p) (1)\n", this, c->member(), object); +#endif // QT_DEBUG + TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit)); + } + } +#endif // !defined(TQT_THREAD_SUPPORT) + } + else { +#if !defined(TQT_THREAD_SUPPORT) + object->tqt_invoke( c->member(), o ); +#else // defined(TQT_THREAD_SUPPORT) + if ((d->disableThreadPostedEvents) || + (object->d->disableThreadPostedEvents) || + (currentThread && currentThread->threadPostedEventsDisabled()) || + (currentThread && object->d->ownThread == currentThread)) { + sol->listMutex->unlock(); + object->tqt_invoke( c->member(), o ); + sol->listMutex->lock(); + } + else { + if (object->d->ownThread && !object->d->ownThread->finished()) { +#ifdef QT_DEBUG + tqDebug("TQObject::activate_signal: Invoking cross-thread method from object %p (member %d receiver %p) (1)\n", this, c->member(), object); +#endif // QT_DEBUG + TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke)); + } + } +#endif // !defined(TQT_THREAD_SUPPORT) + } + if ( sol ) { + sol->currentSender = oldSender; + if ( sol->deref() ) { +#ifdef TQT_THREAD_SUPPORT + sol->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + delete sol; + sol = NULL; + } + } +#ifdef TQT_THREAD_SUPPORT + if (sol) sol->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + } else { + TQConnection *cd = 0; + TQConnectionListIt it(*clist); + while ( (c=it.current()) ) { + ++it; + if ( c == cd ) + continue; + cd = c; + object = c->object(); + sol = object->senderObjects; +#ifdef TQT_THREAD_SUPPORT + sol->listMutex->lock(); +#endif // TQT_THREAD_SUPPORT + if ( sol ) { + oldSender = sol->currentSender; + sol->ref(); + sol->currentSender = this; + } + if ( c->memberType() == TQ_SIGNAL_CODE ) { +#if !defined(TQT_THREAD_SUPPORT) + object->tqt_emit( c->member(), o ); +#else // defined(TQT_THREAD_SUPPORT) + if ((d->disableThreadPostedEvents) || + (object->d->disableThreadPostedEvents) || + (currentThread && currentThread->threadPostedEventsDisabled()) || + (currentThread && object->d->ownThread == currentThread)) { + sol->listMutex->unlock(); + object->tqt_emit( c->member(), o ); + sol->listMutex->lock(); + } + else { + if (object->d->ownThread && !object->d->ownThread->finished()) { +#ifdef QT_DEBUG + tqDebug("TQObject::activate_signal: Emitting cross-thread signal from object %p (member %d receiver %p) (2)\n", this, c->member(), object); +#endif // QT_DEBUG + TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit)); + } + } +#endif // !defined(TQT_THREAD_SUPPORT) + } + else { +#if !defined(TQT_THREAD_SUPPORT) + object->tqt_invoke( c->member(), o ); +#else // defined(TQT_THREAD_SUPPORT) + if ((d->disableThreadPostedEvents) || + (object->d->disableThreadPostedEvents) || + (currentThread && currentThread->threadPostedEventsDisabled()) || + (currentThread && object->d->ownThread == currentThread)) { + sol->listMutex->unlock(); + object->tqt_invoke( c->member(), o ); + sol->listMutex->lock(); + } + else { + if (object->d->ownThread && !object->d->ownThread->finished()) { +#ifdef QT_DEBUG + tqDebug("TQObject::activate_signal: Invoking cross-thread method from object %p (member %d receiver %p) (2)\n", this, c->member(), object); +#endif // QT_DEBUG + TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke)); + } + } +#endif // !defined(TQT_THREAD_SUPPORT) + } + if (sol ) { + sol->currentSender = oldSender; + if ( sol->deref() ) { +#ifdef TQT_THREAD_SUPPORT + sol->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + delete sol; + sol = NULL; + } + } +#ifdef TQT_THREAD_SUPPORT + if (sol) sol->listMutex->unlock(); +#endif // TQT_THREAD_SUPPORT + } + } +} + +/*! + \overload void TQObject::activate_signal( int signal, int ) +*/ + +/*! + \overload void TQObject::activate_signal( int signal, double ) +*/ + +/*! + \overload void TQObject::activate_signal( int signal, TQString ) +*/ + +/*! + \fn void TQObject::activate_signal_bool( int signal, bool ) + \internal + + Like the above functions, but since bool is sometimes + only a typedef it cannot be a simple overload. +*/ + +#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY +#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \ +void TQObject::FNAME( int signal, TYPE param ) \ +{ \ + if ( tqt_preliminary_signal_spy ) { \ + if ( !signalsBlocked() && signal >= 0 && \ + ( !connections || !connections->at( signal ) ) ) { \ + TQUObject o[2]; \ + o[1].isLastObject = true; \ + static_QUType_##TYPE.set( o+1, param ); \ + qt_spy_signal( this, signal, o ); \ + return; \ + } \ + } \ + if ( !connections || signalsBlocked() || signal < 0 ) \ + return; \ + TQConnectionList *clist = connections->at( signal ); \ + if ( !clist ) \ + return; \ + TQUObject o[2]; \ + o[1].isLastObject = true; \ + static_QUType_##TYPE.set( o+1, param ); \ + activate_signal( clist, o ); \ +} +#else +#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \ +void TQObject::FNAME( int signal, TYPE param ) \ +{ \ + if ( !connections || signalsBlocked() || signal < 0 ) \ + return; \ + TQConnectionList *clist = connections->at( signal ); \ + if ( !clist ) \ + return; \ + TQUObject o[2]; \ + o[1].isLastObject = true; \ + static_QUType_##TYPE.set( o+1, param ); \ + activate_signal( clist, o ); \ +} + +#endif +// We don't want to duplicate too much text so... + +ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, int ) +ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, double ) +ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, TQString ) +ACTIVATE_SIGNAL_WITH_PARAM( activate_signal_bool, bool ) + + +/***************************************************************************** + TQObject debugging output routines. + *****************************************************************************/ + +static void dumpRecursive( int level, TQObject *object ) +{ +#if defined(QT_DEBUG) + if ( object ) { + TQString buf; + buf.fill( '\t', level/2 ); + if ( level % 2 ) + buf += " "; + const char *name = object->name(); + TQString flags=""; + if ( tqApp->focusWidget() == object ) + flags += 'F'; + if ( object->isWidgetType() ) { + TQWidget * w = (TQWidget *)object; + if ( w->isVisible() ) { + TQString t( "<%1,%2,%3,%4>" ); + flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height()); + } else { + flags += 'I'; + } + } + tqDebug( "%s%s::%s %s", (const char*)buf, object->className(), name, + flags.latin1() ); + if ( object->children() ) { + TQObjectListIt it(*object->children()); + TQObject * c; + while ( (c=it.current()) != 0 ) { + ++it; + dumpRecursive( level+1, c ); + } + } + } +#else + Q_UNUSED( level ) + Q_UNUSED( object ) +#endif +} + +/*! + Dumps a tree of children to the debug output. + + This function is useful for debugging, but does nothing if the + library has been compiled in release mode (i.e. without debugging + information). +*/ + +void TQObject::dumpObjectTree() +{ + dumpRecursive( 0, this ); +} + +/*! + Dumps information about signal connections, etc. for this object + to the debug output. + + This function is useful for debugging, but does nothing if the + library has been compiled in release mode (i.e. without debugging + information). +*/ + +void TQObject::dumpObjectInfo() +{ +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker locker( d->senderObjectListMutex ); +#endif // TQT_THREAD_SUPPORT + +#if defined(QT_DEBUG) + tqDebug( "OBJECT %s::%s", className(), name( "unnamed" ) ); + int n = 0; + tqDebug( " SIGNALS OUT" ); + if ( connections ) { + TQConnectionList *clist; + for ( uint i = 0; i < connections->size(); i++ ) { + if ( ( clist = connections->at( i ) ) ) { + tqDebug( "\t%s", metaObject()->signal( i, TRUE )->name ); + n++; + TQConnection *c; + TQConnectionListIt cit(*clist); + while ( (c=cit.current()) ) { + ++cit; + tqDebug( "\t --> %s::%s %s", c->object()->className(), + c->object()->name( "unnamed" ), c->memberName() ); + } + } + } + } + if ( n == 0 ) + tqDebug( "\t" ); + + tqDebug( " SIGNALS IN" ); + n = 0; + if ( senderObjects ) { + TQObject *sender = senderObjects->first(); + while ( sender ) { + tqDebug( "\t%s::%s", + sender->className(), sender->name( "unnamed" ) ); + n++; + sender = senderObjects->next(); + } + } + if ( n == 0 ) { + tqDebug( "\t" ); + } +#endif +} + +#ifndef TQT_NO_PROPERTIES + +/*! + Sets the value of the object's \a name property to \a value. + + Returns TRUE if the operation was successful; otherwise returns + FALSE. + + Information about all available properties is provided through the + metaObject(). + + \sa property(), metaObject(), TQMetaObject::propertyNames(), TQMetaObject::property() +*/ +bool TQObject::setProperty( const char *name, const TQVariant& value ) +{ + if ( !value.isValid() ) + return FALSE; + + TQVariant v = value; + + TQMetaObject* meta = metaObject(); + if ( !meta ) + return FALSE; + int id = meta->findProperty( name, TRUE ); + const TQMetaProperty* p = meta->property( id, TRUE ); + if ( !p || !p->isValid() || !p->writable() ) { + tqWarning( "%s::setProperty( \"%s\", value ) failed: property invalid, read-only or does not exist", + className(), name ); + return FALSE; + } + + if ( p->isEnumType() ) { + if ( v.type() == TQVariant::String || v.type() == TQVariant::CString ) { + if ( p->isSetType() ) { + TQString s = value.toString(); + // TQStrList does not support split, use TQStringList for that. + TQStringList l = TQStringList::split( '|', s ); + TQStrList keys; + for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it ) + keys.append( (*it).stripWhiteSpace().latin1() ); + v = TQVariant( p->keysToValue( keys ) ); + } else { + v = TQVariant( p->keyToValue( value.toCString().data() ) ); + } + } else if ( v.type() != TQVariant::Int && v.type() != TQVariant::UInt ) { + return FALSE; + } + return tqt_property( id, 0, &v ); + } + + TQVariant::Type type = (TQVariant::Type)(p->flags >> 24); + if ( type == TQVariant::Invalid ) + type = TQVariant::nameToType( p->type() ); + if ( type != TQVariant::Invalid && !v.canCast( type ) ) + return FALSE; + return tqt_property( id, 0, &v ); +} + +/*! + Returns the value of the object's \a name property. + + If no such property exists, the returned variant is invalid. + + Information about all available properties are provided through + the metaObject(). + + \sa setProperty(), TQVariant::isValid(), metaObject(), + TQMetaObject::propertyNames(), TQMetaObject::property() +*/ +TQVariant TQObject::property( const char *name ) const +{ + TQVariant v; + TQMetaObject* meta = metaObject(); + if ( !meta ) + return v; + int id = meta->findProperty( name, TRUE ); + const TQMetaProperty* p = meta->property( id, TRUE ); + if ( !p || !p->isValid() ) { + tqWarning( "%s::property( \"%s\" ) failed: property invalid or does not exist", + className(), name ); + return v; + } + TQObject* that = (TQObject*) this; // moc ensures constness for the tqt_property call + that->tqt_property( id, 1, &v ); + return v; +} + +#endif // TQT_NO_PROPERTIES + +#ifndef TQT_NO_USERDATA +/*!\internal + */ +uint TQObject::registerUserData() +{ + static int user_data_registration = 0; + return user_data_registration++; +} + +/*!\internal + */ +TQObjectUserData::~TQObjectUserData() +{ +} + +/*!\internal + */ +void TQObject::setUserData( uint id, TQObjectUserData* data) +{ + if ( !d ) + d = new TQObjectPrivate( id+1 ); + if ( id >= d->size() ) + d->resize( id+1 ); + d->insert( id, data ); +} + +/*!\internal + */ +TQObjectUserData* TQObject::userData( uint id ) const +{ + if ( d && id < d->size() ) + return d->at( id ); + return 0; +} + +#endif // TQT_NO_USERDATA diff --git a/src/kernel/tqobject.h b/src/kernel/tqobject.h new file mode 100644 index 000000000..0d63af0a3 --- /dev/null +++ b/src/kernel/tqobject.h @@ -0,0 +1,292 @@ +/**************************************************************************** +** +** Definition of TQObject class +** +** Created : 930418 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQOBJECT_H +#define TQOBJECT_H + +#ifndef QT_H +#include "tqobjectdefs.h" +#include "ntqwindowdefs.h" +#include "ntqstring.h" +#include "ntqevent.h" +#include "ntqmutex.h" +#include "ntqnamespace.h" +#endif // QT_H + +#include + +#define TQT_TR_NOOP(x) (x) +#define TQT_TRANSLATE_NOOP(scope,x) (x) + +class TQMetaObject; +class TQVariant; +class TQMetaProperty; +class TQPostEventList; +class TQSenderObjectList; +class TQObjectPrivate; +#ifndef TQT_NO_USERDATA +class TQObjectUserData; +#endif +struct TQUObject; + +#ifdef TQT_THREAD_SUPPORT +class TQThread; +#endif + +class TQStyleControlElementData; +class TQStyleControlElementDataPrivate; + +class TQ_EXPORT TQObject: public TQt +{ + TQ_OBJECT + TQ_PROPERTY( TQCString name READ name WRITE setName ) + +public: + TQObject( TQObject *parent=0, const char *name=0 ); + virtual ~TQObject(); + +#ifdef Q_QDOC + virtual const char *className() const; + static TQString tr( const char *, const char * ); + static TQString trUtf8( const char *, const char * ); + virtual TQMetaObject *metaObject() const; +#endif + + virtual bool event( TQEvent * ); + virtual bool eventFilter( TQObject *, TQEvent * ); + + bool isA( const char * ) const; + bool inherits( const char * ) const; + + const char *name() const; + const char *name( const char * defaultName ) const; + + virtual void setName( const char *name ); + bool isWidgetType() const { return isWidget; } + bool highPriority() const { return FALSE; } + + bool signalsBlocked() const { return blockSig; } + void blockSignals( bool b ); + + int startTimer( int interval ); + void killTimer( int id ); + void killTimers(); + + TQObject *child( const char *objName, const char *inheritsClass = 0, bool recursiveSearch = TRUE ); //### const in 4.0 + const TQObjectList *children() const { return childObjects; } + TQObjectList childrenListObject(); + const TQObjectList childrenListObject() const; + + static const TQObjectList *objectTrees(); + static const TQObjectList objectTreesListObject(); + + TQObjectList *queryList( const char *inheritsClass = 0, + const char *objName = 0, + bool regexpMatch = TRUE, + bool recursiveSearch = TRUE ) const; + + virtual void insertChild( TQObject * ); + virtual void removeChild( TQObject * ); + + void installEventFilter( const TQObject * ); + void removeEventFilter( const TQObject * ); + + static bool connect( const TQObject *sender, const char *signal, + const TQObject *receiver, const char *member ); + bool connect( const TQObject *sender, const char *signal, + const char *member ) const; + static bool disconnect( const TQObject *sender, const char *signal, + const TQObject *receiver, const char *member ); + bool disconnect( const char *signal=0, + const TQObject *receiver=0, const char *member=0 ); + bool disconnect( const TQObject *receiver, const char *member=0 ); + static void connectInternal( const TQObject *sender, int signal_index, + const TQObject *receiver, int membcode, int member_index ); + static bool disconnectInternal( const TQObject *sender, int signal_index, + const TQObject *receiver, int membcode, int member_index ); + + void dumpObjectTree(); + void dumpObjectInfo(); + + TQStyleControlElementData* controlElementDataObject(); + TQStyleControlElementDataPrivate* controlElementDataPrivateObject(); + +#ifndef TQT_NO_PROPERTIES + virtual bool setProperty( const char *name, const TQVariant& value ); + virtual TQVariant property( const char *name ) const; +#endif // TQT_NO_PROPERTIES +#ifdef TQT_NO_TRANSLATION + static TQString tr( const char *sourceText, const char * = 0); +#ifndef TQT_NO_TEXTCODEC + static TQString trUtf8( const char *sourceText, const char * = 0); +#endif +#endif //TQT_NO_TRANSLATION + +#ifndef TQT_NO_USERDATA + static uint registerUserData(); + void setUserData( uint id, TQObjectUserData* data); + TQObjectUserData* userData( uint id ) const; +#endif // TQT_NO_USERDATA + +signals: + void destroyed(); + void destroyed( TQObject* obj ); + +public: + TQObject *parent() const { return parentObj; } + +public slots: + void deleteLater(); + +private slots: + void cleanupEventFilter( TQObject* ); + +protected: + bool activate_filters( TQEvent * ); + TQConnectionList *receivers( const char* signal ) const; + TQConnectionList *receivers( int signal ) const; + void activate_signal( int signal ); + void activate_signal( int signal, int ); + void activate_signal( int signal, double ); + void activate_signal( int signal, TQString ); + void activate_signal_bool( int signal, bool ); + void activate_signal( TQConnectionList *clist, TQUObject *o ); + + const TQObject *sender(); + + virtual void timerEvent( TQTimerEvent * ); + virtual void childEvent( TQChildEvent * ); + virtual void customEvent( TQCustomEvent * ); + + virtual void connectNotify( const char *signal ); + virtual void disconnectNotify( const char *signal ); + virtual bool checkConnectArgs( const char *signal, const TQObject *receiver, + const char *member ); + static TQCString normalizeSignalSlot( const char *signalSlot ); + +private: + uint isSignal : 1; + uint isWidget : 1; + uint pendTimer : 1; + uint blockSig : 1; + uint wasDeleted : 1; + uint isTree : 1; + + const char *objname; + TQObject *parentObj; + TQObjectList *childObjects; + TQSignalVec *connections; + TQSenderObjectList *senderObjects; + TQObjectList *eventFilters; + TQPostEventList *postedEvents; + TQObjectPrivate* d; + + static TQMetaObject* staticTQtMetaObject(); + + friend class TQApplication; + friend class TQBaseApplication; + friend class TQWidget; + friend class TQSignal; + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQObject( const TQObject & ); + TQObject &operator=( const TQObject & ); +#endif + +public: +#ifdef TQT_THREAD_SUPPORT + TQThread* contextThreadObject() const; + void moveToThread(TQThread *targetThread); + void disableThreadPostedEvents(bool disable); +#endif + +private: + void cleanupControlElementData(); +#ifdef TQT_THREAD_SUPPORT + void moveToThread_helper(TQThread *targetThread); + void setThreadObject_helper(TQThread *targetThread); +#endif +}; + + +#ifndef TQT_NO_USERDATA +class TQ_EXPORT TQObjectUserData { +public: + virtual ~TQObjectUserData(); +}; +#endif + + +inline bool TQObject::connect( const TQObject *sender, const char *signal, + const char *member ) const +{ + return connect( sender, signal, this, member ); +} + + +inline bool TQObject::disconnect( const char *signal, + const TQObject *receiver, const char *member ) +{ + return disconnect( this, signal, receiver, member ); +} + + +inline bool TQObject::disconnect( const TQObject *receiver, const char *member ) +{ + return disconnect( this, 0, receiver, member ); +} + + +#ifdef TQT_NO_TRANSLATION +inline TQString TQObject::tr( const char *sourceText, const char * ) { + return TQString::fromLatin1( sourceText ); +} +#ifndef TQT_NO_TEXTCODEC +inline TQString TQObject::trUtf8( const char *sourceText, const char * ) { + return TQString::fromUtf8( sourceText ); +} +#endif +#endif //TQT_NO_TRANSLATION + + +#define Q_DEFINED_QOBJECT +#include "ntqwinexport.h" +#endif // TQOBJECT_H diff --git a/src/kernel/tqobjectcleanuphandler.cpp b/src/kernel/tqobjectcleanuphandler.cpp new file mode 100644 index 000000000..f06ebb7f3 --- /dev/null +++ b/src/kernel/tqobjectcleanuphandler.cpp @@ -0,0 +1,172 @@ +/**************************************************************************** +** +** Implementation of TQObjectCleanupHandler class +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqobjectcleanuphandler.h" +#include "tqobjectlist.h" + +/*! + \class TQObjectCleanupHandler tqobjectcleanuphandler.h + \brief The TQObjectCleanupHandler class watches the lifetime of multiple TQObjects. + + \ingroup objectmodel + + A TQObjectCleanupHandler is useful whenever you need to know when a + number of \l{TQObject}s that are owned by someone else have been + deleted. This is important, for example, when referencing memory + in an application that has been allocated in a shared library. + + Example: + + \code + class FactoryComponent : public FactoryInterface, public TQLibraryInterface + { + public: + ... + + TQObject *createObject(); + + bool init(); + void cleanup(); + bool canUnload() const; + + private: + TQObjectCleanupHandler objects; + }; + + // allocate a new object, and add it to the cleanup handler + TQObject *FactoryComponent::createObject() + { + return objects.add( new TQObject() ); + } + + // TQLibraryInterface implementation + bool FactoryComponent::init() + { + return TRUE; + } + + void FactoryComponent::cleanup() + { + } + + // it is only safe to unload the library when all TQObject's have been destroyed + bool FactoryComponent::canUnload() const + { + return objects.isEmpty(); + } + \endcode +*/ + +/*! + Constructs an empty TQObjectCleanupHandler. +*/ +TQObjectCleanupHandler::TQObjectCleanupHandler() +: TQObject(), cleanupObjects( 0 ) +{ +} + +/*! + Destroys the cleanup handler. All objects in this cleanup handler + will be deleted. +*/ +TQObjectCleanupHandler::~TQObjectCleanupHandler() +{ + clear(); +} + +/*! + Adds \a object to this cleanup handler and returns the pointer to + the object. +*/ +TQObject* TQObjectCleanupHandler::add( TQObject* object ) +{ + if ( !object ) + return 0; + + if ( !cleanupObjects ) { + cleanupObjects = new TQObjectList; + cleanupObjects->setAutoDelete( TRUE ); + } + connect( object, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(objectDestroyed(TQObject*)) ); + cleanupObjects->insert( 0, object ); + return object; +} + +/*! + Removes the \a object from this cleanup handler. The object will + not be destroyed. +*/ +void TQObjectCleanupHandler::remove( TQObject *object ) +{ + if ( !cleanupObjects ) + return; + if ( cleanupObjects->findRef( object ) >= 0 ) { + (void) cleanupObjects->take(); + disconnect( object, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(objectDestroyed(TQObject*)) ); + } +} + +/*! + Returns TRUE if this cleanup handler is empty or if all objects in + this cleanup handler have been destroyed; otherwise return FALSE. +*/ +bool TQObjectCleanupHandler::isEmpty() const +{ + return cleanupObjects ? cleanupObjects->isEmpty() : TRUE; +} + +/*! + Deletes all objects in this cleanup handler. The cleanup handler + becomes empty. +*/ +void TQObjectCleanupHandler::clear() +{ + delete cleanupObjects; + cleanupObjects = 0; +} + +void TQObjectCleanupHandler::objectDestroyed( TQObject*object ) +{ + if ( cleanupObjects ) + cleanupObjects->setAutoDelete( FALSE ); + + remove( object ); + + if ( cleanupObjects ) + cleanupObjects->setAutoDelete( TRUE ); +} diff --git a/src/kernel/tqobjectcleanuphandler.h b/src/kernel/tqobjectcleanuphandler.h new file mode 100644 index 000000000..a4b83ee91 --- /dev/null +++ b/src/kernel/tqobjectcleanuphandler.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Definition of ??? +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQOBJECTCLEANUPHANDLER_H +#define TQOBJECTCLEANUPHANDLER_H + +#ifndef QT_H +#include "tqobject.h" +#endif // QT_H + +class TQObjectList; + +class TQ_EXPORT TQObjectCleanupHandler : public TQObject +{ + TQ_OBJECT + +public: + TQObjectCleanupHandler(); + ~TQObjectCleanupHandler(); + + TQObject* add( TQObject* object ); + void remove( TQObject *object ); + bool isEmpty() const; + void clear(); + +private: + TQObjectList *cleanupObjects; + +private slots: + void objectDestroyed( TQObject * ); +}; + +#endif // TQOBJECTCLEANUPHANDLER_H diff --git a/src/kernel/tqobjectdefs.h b/src/kernel/tqobjectdefs.h new file mode 100644 index 000000000..ba5e12b88 --- /dev/null +++ b/src/kernel/tqobjectdefs.h @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Macros and definitions related to TQObject +** +** Created : 930419 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQOBJECTDEFS_H +#define TQOBJECTDEFS_H + +#ifndef QT_H +#include "ntqglobal.h" +#endif // QT_H + + +#ifndef TQT_NO_TRANSLATION +# ifndef TQT_NO_TEXTCODEC +// full set of tr functions +# define TQT_TR_FUNCTIONS \ + static TQString tr( const char *, const char * = 0 ); \ + static TQString trUtf8( const char *, const char * = 0 ); +# else +// no TQTextCodec, no utf8 +# define TQT_TR_FUNCTIONS \ + static TQString tr( const char *, const char * = 0 ); +# endif +#else +// inherit the ones from TQObject +# define TQT_TR_FUNCTIONS +#endif + +#ifndef TQT_NO_PROPERTIES +# define QT_PROP_FUNCTIONS \ + virtual bool tqt_property( int id, int f, TQVariant* v); \ + static bool tqt_static_property( TQObject* , int, int, TQVariant* ); +#else +# define QT_PROP_FUNCTIONS +#endif + +// The following macros are our "extensions" to C++ +// They are used, strictly speaking, only by the moc. +struct TQUObject; + +#ifdef QT_MOC_CPP +#define slots slots +#define signals signals +#define TQ_CLASSINFO( name, value ) TQ_CLASSINFO( name, value ) +#define TQ_PROPERTY( text ) TQ_PROPERTY( text ) +#define TQ_OVERRIDE( text ) TQ_OVERRIDE( text ) +#define TQ_ENUMS( x ) TQ_ENUMS( x ) +#define TQ_SETS( x ) TQ_SETS( x ) + /* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT TQ_OBJECT + /* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT_FAKE TQ_OBJECT_FAKE + +#else +#define slots // slots: in class +#define signals protected // signals: in class +#ifndef TQT_NO_EMIT +#define emit // emit signal +#endif +#define TQ_CLASSINFO( name, value ) // class info +#define TQ_PROPERTY( text ) // property +#define TQ_OVERRIDE( text ) // override property +#define TQ_ENUMS( x ) +#define TQ_SETS( x ) + +/* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT \ +public: \ + virtual TQMetaObject *metaObject() const { \ + return staticMetaObject(); \ + } \ + virtual const char *className() const; \ + virtual void* tqt_cast( const char* ); \ + virtual bool tqt_invoke( int, TQUObject* ); \ + virtual bool tqt_emit( int, TQUObject* ); \ + QT_PROP_FUNCTIONS \ + static TQMetaObject* staticMetaObject(); \ + TQObject* qObject() { return (TQObject*)this; } \ + TQT_TR_FUNCTIONS \ +private: \ + static TQMetaObject *metaObj; + +/* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT_FAKE TQ_OBJECT + +#endif + +// macro for naming members +#ifdef TQ_METHOD +#undef TQ_METHOD +#endif +#ifdef TQ_SLOT +#undef TQ_SLOT +#endif +#ifdef TQ_SIGNAL +#undef TQ_SIGNAL +#endif + +#if defined(_OLD_CPP_) +#define TQ_METHOD(a) "0""a" +#define TQ_SLOT(a) "1""a" +#define TQ_SIGNAL(a) "2""a" +#else +#define TQ_METHOD(a) "0"#a +#define TQ_SLOT(a) "1"#a +#define TQ_SIGNAL(a) "2"#a +#endif + +#define TQ_METHOD_CODE 0 // member type codes +#define TQ_SLOT_CODE 1 +#define TQ_SIGNAL_CODE 2 + +class TQObject; +class TQMetaObject; +class TQSignal; +class TQConnection; +class TQEvent; +class TQMutex; +struct TQMetaData; +class TQConnectionList; +class TQConnectionListIt; +class TQSignalVec; +class TQObjectList; +class TQObjectListIt; +class TQMemberDict; + +extern TQMutex *tqt_sharedMetaObjectMutex; + +TQ_EXPORT void *tqt_find_obj_child( TQObject *, const char *, const char * ); +#define Q_CHILD(parent,type,name) \ + ((type*)tqt_find_obj_child(parent,#type,name)) + +TQ_EXPORT void *tqt_inheritedBy( TQMetaObject *super, const TQObject *cls ); + +template +TQ_INLINE_TEMPLATES T tqt_cast(const TQObject *object) +{ return (T)tqt_inheritedBy( ((T)0)->staticMetaObject(), object ); } +#endif // TQOBJECTDEFS_H diff --git a/src/kernel/tqobjectdict.h b/src/kernel/tqobjectdict.h new file mode 100644 index 000000000..4ee49faf2 --- /dev/null +++ b/src/kernel/tqobjectdict.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Definition of TQObjectDictionary +** +** Created : 940807 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQOBJECTDICT_H +#define TQOBJECTDICT_H + +#ifndef QT_H +#include "ntqmetaobject.h" +#include "ntqasciidict.h" +#endif // QT_H + + +// +// The object dictionary is a collection of TQMetaObjects +// + +class TQ_EXPORT TQObjectDictionary : public TQAsciiDict +{ +public: + TQObjectDictionary(int size=17,bool cs=TRUE,bool ck=TRUE) + : TQAsciiDict(size,cs,ck) {} + TQObjectDictionary( const TQObjectDictionary &dict ) + : TQAsciiDict(dict) {} + ~TQObjectDictionary() { clear(); } + TQObjectDictionary &operator=(const TQObjectDictionary &dict) + { return (TQObjectDictionary&)TQAsciiDict::operator=(dict);} +}; + +#endif // TQOBJECTDICT_H diff --git a/src/kernel/tqobjectlist.h b/src/kernel/tqobjectlist.h new file mode 100644 index 000000000..830a32e33 --- /dev/null +++ b/src/kernel/tqobjectlist.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Definition of TQObjectList +** +** Created : 940807 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQOBJECTLIST_H +#define TQOBJECTLIST_H + +#ifndef QT_H +#include "tqobject.h" +#include "ntqptrlist.h" +#endif // QT_H + + +#if defined(Q_TEMPLATEDLL) +//Q_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrList; +//Q_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrListIterator; +#endif + + +class TQ_EXPORT TQObjectList : public TQPtrList +{ +public: + TQObjectList() : TQPtrList() {} + TQObjectList( const TQObjectList &list ) : TQPtrList(list) {} + ~TQObjectList() { clear(); } + TQObjectList &operator=(const TQObjectList &list) + { return (TQObjectList&)TQPtrList::operator=(list); } +}; + +class TQ_EXPORT TQObjectListIterator : public TQPtrListIterator +{ +public: + TQObjectListIterator( const TQObjectList &l ) + : TQPtrListIterator( l ) { } + TQObjectListIterator &operator=( const TQObjectListIterator &i ) + { return (TQObjectListIterator&) + TQPtrListIterator::operator=( i ); } +}; + +class TQ_EXPORT TQObjectListIt : public TQPtrListIterator +{ +public: + TQObjectListIt( const TQObjectList &l ) : TQPtrListIterator(l) {} + TQObjectListIt &operator=(const TQObjectListIt &i) + { return (TQObjectListIt&)TQPtrListIterator::operator=(i); } +}; + +#endif // TQOBJECTLIST_H diff --git a/src/moc/moc.y b/src/moc/moc.y index 4b754b7bc..796647595 100644 --- a/src/moc/moc.y +++ b/src/moc/moc.y @@ -2135,7 +2135,7 @@ void registerClassInNamespace() // // Remove white space from TQ_SIGNAL and TQ_SLOT names. -// This function has been copied from qobject.cpp. +// This function has been copied from tqobject.cpp. // inline bool isSpace( char x ) @@ -3116,7 +3116,7 @@ void generateClass() // generate C++ source code for a class if ( !predef_call_func && !included_list_headers ) { // yes we need it, because otherwise TQT_VERSION may not be defined - fprintf( out, "\n#include <%sntqobjectdefs.h>\n", (const char*)g->qtPath ); + fprintf( out, "\n#include <%stqobjectdefs.h>\n", (const char*)g->qtPath ); fprintf( out, "#include <%sntqsignalslotimp.h>\n", (const char*)g->qtPath ); included_list_headers = TRUE; } diff --git a/src/moc/moc_yacc.cpp b/src/moc/moc_yacc.cpp index ef980dd34..d6b97ad85 100644 --- a/src/moc/moc_yacc.cpp +++ b/src/moc/moc_yacc.cpp @@ -5010,7 +5010,7 @@ void registerClassInNamespace() // // Remove white space from TQ_SIGNAL and TQ_SLOT names. -// This function has been copied from qobject.cpp. +// This function has been copied from tqobject.cpp. // inline bool isSpace( char x ) @@ -5991,7 +5991,7 @@ void generateClass() // generate C++ source code for a class if ( !predef_call_func && !included_list_headers ) { // yes we need it, because otherwise TQT_VERSION may not be defined - fprintf( out, "\n#include <%sntqobjectdefs.h>\n", (const char*)g->qtPath ); + fprintf( out, "\n#include <%stqobjectdefs.h>\n", (const char*)g->qtPath ); fprintf( out, "#include <%sntqsignalslotimp.h>\n", (const char*)g->qtPath ); included_list_headers = TRUE; } diff --git a/src/network/ntqdns.h b/src/network/ntqdns.h index 1c0559151..7201c3043 100644 --- a/src/network/ntqdns.h +++ b/src/network/ntqdns.h @@ -42,7 +42,7 @@ #define TQDNS_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqhostaddress.h" #include "ntqsocketnotifier.h" #include "ntqstringlist.h" diff --git a/src/network/ntqhttp.h b/src/network/ntqhttp.h index 8fc966bc3..f201363c8 100644 --- a/src/network/ntqhttp.h +++ b/src/network/ntqhttp.h @@ -42,7 +42,7 @@ #define TQHTTP_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqnetworkprotocol.h" #include "ntqstringlist.h" #endif // QT_H diff --git a/src/network/ntqserversocket.h b/src/network/ntqserversocket.h index f00f4c775..ab9c242ed 100644 --- a/src/network/ntqserversocket.h +++ b/src/network/ntqserversocket.h @@ -42,7 +42,7 @@ #define TQSERVERSOCKET_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqhostaddress.h" #include "ntqsocketdevice.h" // ### remove or keep for users' convenience? #endif // QT_H diff --git a/src/network/ntqsocket.h b/src/network/ntqsocket.h index 90f1f74ac..4946e81f5 100644 --- a/src/network/ntqsocket.h +++ b/src/network/ntqsocket.h @@ -42,7 +42,7 @@ #define TQSOCKET_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqiodevice.h" #include "ntqhostaddress.h" // int->TQHostAddress conversion #endif // QT_H diff --git a/src/sql/ntqeditorfactory.h b/src/sql/ntqeditorfactory.h index 212424003..cea5885ac 100644 --- a/src/sql/ntqeditorfactory.h +++ b/src/sql/ntqeditorfactory.h @@ -42,7 +42,7 @@ #define TQEDITORFACTORY_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqvariant.h" #endif // QT_H diff --git a/src/sql/ntqsqldatabase.h b/src/sql/ntqsqldatabase.h index 1fed63e04..c50955e82 100644 --- a/src/sql/ntqsqldatabase.h +++ b/src/sql/ntqsqldatabase.h @@ -42,7 +42,7 @@ #define TQSQLDATABASE_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqstring.h" #include "ntqsqlquery.h" #include "ntqstringlist.h" diff --git a/src/sql/ntqsqldriver.h b/src/sql/ntqsqldriver.h index b1b2fcb3a..ce900b72a 100644 --- a/src/sql/ntqsqldriver.h +++ b/src/sql/ntqsqldriver.h @@ -42,7 +42,7 @@ #define TQSQLDRIVER_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqptrdict.h" #include "ntqstring.h" #include "ntqsqlerror.h" diff --git a/src/sql/ntqsqlform.h b/src/sql/ntqsqlform.h index 3d3b6272f..7771f7b70 100644 --- a/src/sql/ntqsqlform.h +++ b/src/sql/ntqsqlform.h @@ -42,7 +42,7 @@ #define TQSQLFORM_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqmap.h" #endif // QT_H diff --git a/src/sql/ntqsqlquery.h b/src/sql/ntqsqlquery.h index d1f56f858..62df18531 100644 --- a/src/sql/ntqsqlquery.h +++ b/src/sql/ntqsqlquery.h @@ -42,7 +42,7 @@ #define TQSQLQUERY_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqstring.h" #include "ntqvariant.h" #include "ntqvaluelist.h" diff --git a/src/sql/qsqldatabase.cpp b/src/sql/qsqldatabase.cpp index 66c1725aa..e21af1d36 100644 --- a/src/sql/qsqldatabase.cpp +++ b/src/sql/qsqldatabase.cpp @@ -81,7 +81,7 @@ #include "qsqldriverinterface_p.h" #include #include -#include "ntqobject.h" +#include "tqobject.h" #include "ntqguardedptr.h" #include "ntqcleanuphandler.h" #include "ntqdict.h" diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index f5c57d46f..3ce552ebd 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -172,7 +172,7 @@ static void tqt_style_control_element_data_null_cleanup() { #include -// Keep in sync with duplicate definition in qobject.cpp +// Keep in sync with duplicate definition in tqobject.cpp class TQStyleControlElementDataPrivate { public: bool isTQPushButton; diff --git a/src/styles/qstyleplugin.cpp b/src/styles/qstyleplugin.cpp index c6512de1f..2650708c1 100644 --- a/src/styles/qstyleplugin.cpp +++ b/src/styles/qstyleplugin.cpp @@ -44,7 +44,7 @@ #ifndef TQT_NO_COMPONENT #include "qstyleinterface_p.h" -#include "ntqobjectcleanuphandler.h" +#include "tqobjectcleanuphandler.h" #include "ntqstyle.h" /*! diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index d3b130707..1bf789d22 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -63,7 +63,7 @@ #include "ntqbitmap.h" #include "ntqcleanuphandler.h" #include "ntqdockwindow.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqmenubar.h" #include diff --git a/src/table/qtable.cpp b/src/table/qtable.cpp index bf27224c8..31fa8e25d 100644 --- a/src/table/qtable.cpp +++ b/src/table/qtable.cpp @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/tools/qfile.cpp b/src/tools/qfile.cpp index 709d175bb..d5dae9a7e 100644 --- a/src/tools/qfile.cpp +++ b/src/tools/qfile.cpp @@ -56,7 +56,7 @@ #endif -// Duplicated from ntqobject.h, but we cannot include ntqobject.h here since +// Duplicated from tqobject.h, but we cannot include tqobject.h here since // it causes qmake to not build on irix g++ #define TQT_TRANSLATE_NOOP(scope,x) (x) diff --git a/src/tools/qwinexport.cpp b/src/tools/qwinexport.cpp index 38592c9bb..9fae544ac 100644 --- a/src/tools/qwinexport.cpp +++ b/src/tools/qwinexport.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/widgets/ntqaction.h b/src/widgets/ntqaction.h index a00d7d8fd..326b5236d 100644 --- a/src/widgets/ntqaction.h +++ b/src/widgets/ntqaction.h @@ -42,7 +42,7 @@ #define TQACTION_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqiconset.h" #include "ntqstring.h" #include "ntqkeysequence.h" diff --git a/src/widgets/ntqvalidator.h b/src/widgets/ntqvalidator.h index c5ddedaac..406d210f0 100644 --- a/src/widgets/ntqvalidator.h +++ b/src/widgets/ntqvalidator.h @@ -42,7 +42,7 @@ #define TQVALIDATOR_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #include "ntqstring.h" // char*->TQString conversion #include "ntqregexp.h" // TQString->TQRegExp conversion #endif // QT_H diff --git a/src/widgets/ntqwhatsthis.h b/src/widgets/ntqwhatsthis.h index 98f1fd9fa..66b4b3c90 100644 --- a/src/widgets/ntqwhatsthis.h +++ b/src/widgets/ntqwhatsthis.h @@ -40,7 +40,7 @@ #define TQWHATSTHIS_H #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H #ifndef TQT_NO_WHATSTHIS diff --git a/src/widgets/qaction.cpp b/src/widgets/qaction.cpp index 361ed026e..cbeb093c3 100644 --- a/src/widgets/qaction.cpp +++ b/src/widgets/qaction.cpp @@ -49,7 +49,7 @@ #include "ntqtooltip.h" #include "ntqwhatsthis.h" #include "ntqstatusbar.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" /*! diff --git a/src/widgets/qgroupbox.cpp b/src/widgets/qgroupbox.cpp index 9a31d397f..f9b450e66 100644 --- a/src/widgets/qgroupbox.cpp +++ b/src/widgets/qgroupbox.cpp @@ -46,7 +46,7 @@ #include "ntqaccel.h" #include "ntqradiobutton.h" #include "ntqfocusdata.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqdrawutil.h" #include "ntqapplication.h" #include "ntqstyle.h" diff --git a/src/widgets/qhbox.cpp b/src/widgets/qhbox.cpp index 117164cfc..7f5e0c893 100644 --- a/src/widgets/qhbox.cpp +++ b/src/widgets/qhbox.cpp @@ -38,7 +38,7 @@ #ifndef TQT_NO_HBOX #include "ntqlayout.h" #include "ntqapplication.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" /*! diff --git a/src/widgets/qmainwindow.cpp b/src/widgets/qmainwindow.cpp index 69f4c16ad..970d8cdf4 100644 --- a/src/widgets/qmainwindow.cpp +++ b/src/widgets/qmainwindow.cpp @@ -43,7 +43,7 @@ #include "ntqtimer.h" #include "ntqlayout.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqintdict.h" #include "ntqapplication.h" #include "ntqptrlist.h" diff --git a/src/widgets/qpopupmenu.cpp b/src/widgets/qpopupmenu.cpp index ec93e3a22..afeb80f94 100644 --- a/src/widgets/qpopupmenu.cpp +++ b/src/widgets/qpopupmenu.cpp @@ -49,7 +49,7 @@ #include "ntqpixmapcache.h" #include "ntqtimer.h" #include "ntqwhatsthis.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqguardedptr.h" #include "qeffects_p.h" #include "ntqcursor.h" diff --git a/src/widgets/qscrollview.cpp b/src/widgets/qscrollview.cpp index 493b88f8b..4198e3132 100644 --- a/src/widgets/qscrollview.cpp +++ b/src/widgets/qscrollview.cpp @@ -41,7 +41,7 @@ #include "ntqwidget.h" #ifndef TQT_NO_SCROLLVIEW #include "ntqscrollbar.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqpainter.h" #include "ntqpixmap.h" #include "ntqcursor.h" diff --git a/src/widgets/qsplitter.cpp b/src/widgets/qsplitter.cpp index c94757620..33e5250bf 100644 --- a/src/widgets/qsplitter.cpp +++ b/src/widgets/qsplitter.cpp @@ -47,7 +47,7 @@ #include "ntqbitmap.h" #include "ntqdrawutil.h" #include "ntqmemarray.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqpainter.h" #include "ntqptrlist.h" #include "ntqstyle.h" diff --git a/src/widgets/qtabwidget.cpp b/src/widgets/qtabwidget.cpp index 5f1949099..f6c54524c 100644 --- a/src/widgets/qtabwidget.cpp +++ b/src/widgets/qtabwidget.cpp @@ -40,7 +40,7 @@ #include "ntqtabwidget.h" #ifndef TQT_NO_TABWIDGET -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqtabbar.h" #include "ntqapplication.h" #include "ntqwidgetstack.h" diff --git a/src/widgets/qtoolbar.cpp b/src/widgets/qtoolbar.cpp index dfff7c763..fd5bf56a2 100644 --- a/src/widgets/qtoolbar.cpp +++ b/src/widgets/qtoolbar.cpp @@ -46,7 +46,7 @@ #include "ntqcursor.h" #include "ntqlayout.h" #include "ntqframe.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqpainter.h" #include "ntqdrawutil.h" #include "ntqtoolbutton.h" diff --git a/src/widgets/qtoolbox.cpp b/src/widgets/qtoolbox.cpp index d5c906477..a8d2523ac 100644 --- a/src/widgets/qtoolbox.cpp +++ b/src/widgets/qtoolbox.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/widgets/qwidgetplugin.cpp b/src/widgets/qwidgetplugin.cpp index f7d0bb2f9..2d026221c 100644 --- a/src/widgets/qwidgetplugin.cpp +++ b/src/widgets/qwidgetplugin.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_WIDGETPLUGIN #include "qwidgetinterface_p.h" -#include "ntqobjectcleanuphandler.h" +#include "tqobjectcleanuphandler.h" #include "ntqwidget.h" #ifdef QT_CONTAINER_CUSTOM_WIDGETS #include "ntqwidgetlist.h" diff --git a/src/widgets/qwidgetresizehandler_p.h b/src/widgets/qwidgetresizehandler_p.h index 08f04b65d..30f8e088c 100644 --- a/src/widgets/qwidgetresizehandler_p.h +++ b/src/widgets/qwidgetresizehandler_p.h @@ -54,7 +54,7 @@ // #ifndef QT_H -#include "ntqobject.h" +#include "tqobject.h" #endif // QT_H #ifndef TQT_NO_RESIZEHANDLER class TQMouseEvent; diff --git a/src/widgets/qwidgetstack.cpp b/src/widgets/qwidgetstack.cpp index 457376191..b8cb9e76a 100644 --- a/src/widgets/qwidgetstack.cpp +++ b/src/widgets/qwidgetstack.cpp @@ -43,7 +43,7 @@ #include "../kernel/qlayoutengine_p.h" #ifndef TQT_NO_WIDGETSTACK -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqfocusdata.h" #include "ntqbutton.h" #include "ntqbuttongroup.h" diff --git a/src/workspace/qworkspace.cpp b/src/workspace/qworkspace.cpp index ff8e3d03c..a2cd96faf 100644 --- a/src/workspace/qworkspace.cpp +++ b/src/workspace/qworkspace.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_WORKSPACE #include "ntqapplication.h" #include "../widgets/qtitlebar_p.h" -#include "ntqobjectlist.h" +#include "tqobjectlist.h" #include "ntqlayout.h" #include "ntqtoolbutton.h" #include "ntqlabel.h" diff --git a/src/xml/qxml.cpp b/src/xml/qxml.cpp index 9acdafc79..e211a88b0 100644 --- a/src/xml/qxml.cpp +++ b/src/xml/qxml.cpp @@ -47,7 +47,7 @@ #include "ntqvaluestack.h" // needed for TQT_TRANSLATE_NOOP: -#include "ntqobject.h" +#include "tqobject.h" #ifndef TQT_NO_XML -- cgit v1.2.3