source: trunk/include/qobject.h@ 90

Last change on this file since 90 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 7.9 KB
Line 
1/****************************************************************************
2** $Id: qobject.h 2 2005-11-16 15:49:26Z dmik $
3**
4** Definition of QObject class
5**
6** Created : 930418
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the kernel module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QOBJECT_H
39#define QOBJECT_H
40
41#ifndef QT_H
42#include "qobjectdefs.h"
43#include "qwindowdefs.h"
44#include "qstring.h"
45#include "qevent.h"
46#include "qnamespace.h"
47#endif // QT_H
48
49#define QT_TR_NOOP(x) (x)
50#define QT_TRANSLATE_NOOP(scope,x) (x)
51
52class QMetaObject;
53class QVariant;
54class QMetaProperty;
55class QPostEventList;
56class QSenderObjectList;
57class QObjectPrivate;
58#ifndef QT_NO_USERDATA
59class QObjectUserData;
60#endif
61struct QUObject;
62
63class Q_EXPORT QObject: public Qt
64{
65 Q_OBJECT
66 Q_PROPERTY( QCString name READ name WRITE setName )
67
68public:
69 QObject( QObject *parent=0, const char *name=0 );
70 virtual ~QObject();
71
72#ifdef Q_QDOC
73 virtual const char *className() const;
74 static QString tr( const char *, const char * );
75 static QString trUtf8( const char *, const char * );
76 virtual QMetaObject *metaObject() const;
77#endif
78
79 virtual bool event( QEvent * );
80 virtual bool eventFilter( QObject *, QEvent * );
81
82 bool isA( const char * ) const;
83 bool inherits( const char * ) const;
84
85 const char *name() const;
86 const char *name( const char * defaultName ) const;
87
88 virtual void setName( const char *name );
89 bool isWidgetType() const { return isWidget; }
90 bool highPriority() const { return FALSE; }
91
92 bool signalsBlocked() const { return blockSig; }
93 void blockSignals( bool b );
94
95 int startTimer( int interval );
96 void killTimer( int id );
97 void killTimers();
98
99 QObject *child( const char *objName, const char *inheritsClass = 0, bool recursiveSearch = TRUE ); //### const in 4.0
100 const QObjectList *children() const { return childObjects; }
101
102 static const QObjectList *objectTrees();
103
104 QObjectList *queryList( const char *inheritsClass = 0,
105 const char *objName = 0,
106 bool regexpMatch = TRUE,
107 bool recursiveSearch = TRUE ) const;
108
109 virtual void insertChild( QObject * );
110 virtual void removeChild( QObject * );
111
112 void installEventFilter( const QObject * );
113 void removeEventFilter( const QObject * );
114
115 static bool connect( const QObject *sender, const char *signal,
116 const QObject *receiver, const char *member );
117 bool connect( const QObject *sender, const char *signal,
118 const char *member ) const;
119 static bool disconnect( const QObject *sender, const char *signal,
120 const QObject *receiver, const char *member );
121 bool disconnect( const char *signal=0,
122 const QObject *receiver=0, const char *member=0 );
123 bool disconnect( const QObject *receiver, const char *member=0 );
124 static void connectInternal( const QObject *sender, int signal_index,
125 const QObject *receiver, int membcode, int member_index );
126 static bool disconnectInternal( const QObject *sender, int signal_index,
127 const QObject *receiver, int membcode, int member_index );
128
129 void dumpObjectTree();
130 void dumpObjectInfo();
131
132#ifndef QT_NO_PROPERTIES
133 virtual bool setProperty( const char *name, const QVariant& value );
134 virtual QVariant property( const char *name ) const;
135#endif // QT_NO_PROPERTIES
136#ifdef QT_NO_TRANSLATION
137 static QString tr( const char *sourceText, const char * = 0);
138#ifndef QT_NO_TEXTCODEC
139 static QString trUtf8( const char *sourceText, const char * = 0);
140#endif
141#endif //QT_NO_TRANSLATION
142
143#ifndef QT_NO_USERDATA
144 static uint registerUserData();
145 void setUserData( uint id, QObjectUserData* data);
146 QObjectUserData* userData( uint id ) const;
147#endif // QT_NO_USERDATA
148
149signals:
150 void destroyed();
151 void destroyed( QObject* obj );
152
153public:
154 QObject *parent() const { return parentObj; }
155
156public slots:
157 void deleteLater();
158
159private slots:
160 void cleanupEventFilter( QObject* );
161
162protected:
163 bool activate_filters( QEvent * );
164 QConnectionList *receivers( const char* signal ) const;
165 QConnectionList *receivers( int signal ) const;
166 void activate_signal( int signal );
167 void activate_signal( int signal, int );
168 void activate_signal( int signal, double );
169 void activate_signal( int signal, QString );
170 void activate_signal_bool( int signal, bool );
171 void activate_signal( QConnectionList *clist, QUObject *o );
172
173 const QObject *sender();
174
175 virtual void timerEvent( QTimerEvent * );
176 virtual void childEvent( QChildEvent * );
177 virtual void customEvent( QCustomEvent * );
178
179 virtual void connectNotify( const char *signal );
180 virtual void disconnectNotify( const char *signal );
181 virtual bool checkConnectArgs( const char *signal, const QObject *receiver,
182 const char *member );
183 static QCString normalizeSignalSlot( const char *signalSlot );
184
185private:
186 uint isSignal : 1;
187 uint isWidget : 1;
188 uint pendTimer : 1;
189 uint blockSig : 1;
190 uint wasDeleted : 1;
191 uint isTree : 1;
192
193 const char *objname;
194 QObject *parentObj;
195 QObjectList *childObjects;
196 QSignalVec *connections;
197 QSenderObjectList *senderObjects;
198 QObjectList *eventFilters;
199 QPostEventList *postedEvents;
200 QObjectPrivate* d;
201
202 static QMetaObject* staticQtMetaObject();
203
204 friend class QApplication;
205 friend class QBaseApplication;
206 friend class QWidget;
207 friend class QSignal;
208
209private: // Disabled copy constructor and operator=
210#if defined(Q_DISABLE_COPY)
211 QObject( const QObject & );
212 QObject &operator=( const QObject & );
213#endif
214};
215
216
217#ifndef QT_NO_USERDATA
218class Q_EXPORT QObjectUserData {
219public:
220 virtual ~QObjectUserData();
221};
222#endif
223
224
225inline bool QObject::connect( const QObject *sender, const char *signal,
226 const char *member ) const
227{
228 return connect( sender, signal, this, member );
229}
230
231
232inline bool QObject::disconnect( const char *signal,
233 const QObject *receiver, const char *member )
234{
235 return disconnect( this, signal, receiver, member );
236}
237
238
239inline bool QObject::disconnect( const QObject *receiver, const char *member )
240{
241 return disconnect( this, 0, receiver, member );
242}
243
244
245#ifdef QT_NO_TRANSLATION
246inline QString QObject::tr( const char *sourceText, const char * ) {
247 return QString::fromLatin1( sourceText );
248}
249#ifndef QT_NO_TEXTCODEC
250inline QString QObject::trUtf8( const char *sourceText, const char * ) {
251 return QString::fromUtf8( sourceText );
252}
253#endif
254#endif //QT_NO_TRANSLATION
255
256
257#define Q_DEFINED_QOBJECT
258#include "qwinexport.h"
259#endif // QOBJECT_H
Note: See TracBrowser for help on using the repository browser.