~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/corelib/kernel/qcoreapplication.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the core module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QCOREAPPLICATION_H
 
30
#define QCOREAPPLICATION_H
 
31
 
 
32
#include <QtCore/qobject.h>
 
33
#include <QtCore/qcoreevent.h>
 
34
#include <QtCore/qeventloop.h>
 
35
 
 
36
#ifdef QT_INCLUDE_COMPAT
 
37
#include <QtCore/qstringlist.h>
 
38
#endif
 
39
 
 
40
#if defined(Q_WS_WIN) && !defined(tagMSG)
 
41
typedef struct tagMSG MSG;
 
42
#endif
 
43
 
 
44
class QCoreApplicationPrivate;
 
45
class QTextCodec;
 
46
class QTranslator;
 
47
class QPostEventList;
 
48
class QStringList;
 
49
 
 
50
class Q_CORE_EXPORT QCoreApplication : public QObject
 
51
{
 
52
    Q_OBJECT
 
53
    Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName)
 
54
    Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName)
 
55
    Q_PROPERTY(QString organizationDomain READ organizationDomain WRITE setOrganizationDomain)
 
56
 
 
57
    Q_DECLARE_PRIVATE(QCoreApplication)
 
58
public:
 
59
    QCoreApplication(int &argc, char **argv);
 
60
    ~QCoreApplication();
 
61
 
 
62
    static int argc();
 
63
    static char **argv();
 
64
 
 
65
    static void setOrganizationDomain(const QString &orgDomain);
 
66
    static QString organizationDomain();
 
67
    static void setOrganizationName(const QString &orgName);
 
68
    static QString organizationName();
 
69
    static void setApplicationName(const QString &application);
 
70
    static QString applicationName();
 
71
 
 
72
    static QCoreApplication *instance() { return self; }
 
73
 
 
74
    static int exec();
 
75
    static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
 
76
    static void processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime);
 
77
    static void exit(int retcode=0);
 
78
 
 
79
    static bool sendEvent(QObject *receiver, QEvent *event);
 
80
    static void postEvent(QObject *receiver, QEvent *event);
 
81
    static void sendPostedEvents(QObject *receiver, int event_type);
 
82
    static void sendPostedEvents();
 
83
    static void removePostedEvents(QObject *receiver);
 
84
    static bool hasPendingEvents();
 
85
 
 
86
    virtual bool notify(QObject *, QEvent *);
 
87
 
 
88
    static bool startingUp();
 
89
    static bool closingDown();
 
90
 
 
91
#ifndef QT_NO_DIR
 
92
    static QString applicationDirPath();
 
93
    static QString applicationFilePath();
 
94
#endif
 
95
 
 
96
#ifndef QT_NO_COMPONENT
 
97
    static void setLibraryPaths(const QStringList &);
 
98
    static QStringList libraryPaths();
 
99
    static void addLibraryPath(const QString &);
 
100
    static void removeLibraryPath(const QString &);
 
101
#endif // QT_NO_COMPONENT
 
102
 
 
103
#ifndef QT_NO_TRANSLATION
 
104
    static void installTranslator(QTranslator *);
 
105
    static void removeTranslator(QTranslator *);
 
106
#endif
 
107
    enum Encoding { DefaultCodec, UnicodeUTF8 };
 
108
    static QString translate(const char * context,
 
109
                             const char * key,
 
110
                             const char * comment = 0,
 
111
                             Encoding encoding = DefaultCodec);
 
112
 
 
113
    static void flush();
 
114
 
 
115
#if defined(QT3_SUPPORT)
 
116
    inline QT3_SUPPORT void lock() {}
 
117
    inline QT3_SUPPORT void unlock(bool = true) {}
 
118
    inline QT3_SUPPORT bool locked() { return false; }
 
119
    inline QT3_SUPPORT bool tryLock() { return false; }
 
120
 
 
121
    static inline QT3_SUPPORT void processOneEvent()
 
122
    { processEvents(QEventLoop::WaitForMoreEvents); }
 
123
    static QT3_SUPPORT int enter_loop();
 
124
    static QT3_SUPPORT void exit_loop();
 
125
    static QT3_SUPPORT int loopLevel();
 
126
#endif
 
127
 
 
128
#if defined(Q_WS_WIN)
 
129
    virtual bool winEventFilter(MSG *message, long *result);
 
130
#endif
 
131
 
 
132
#ifdef Q_OS_UNIX
 
133
    static void watchUnixSignal(int signal, bool watch);
 
134
#endif
 
135
 
 
136
    typedef bool (*EventFilter)(void *message, long *result);
 
137
    EventFilter setEventFilter(EventFilter filter);
 
138
    bool filterEvent(void *message, long *result);
 
139
 
 
140
public slots:
 
141
    static void quit();
 
142
 
 
143
signals:
 
144
    void aboutToQuit();
 
145
    void unixSignal(int);
 
146
 
 
147
protected:
 
148
    bool event(QEvent *);
 
149
 
 
150
    virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
 
151
 
 
152
protected:
 
153
    QCoreApplication(QCoreApplicationPrivate &p);
 
154
 
 
155
private:
 
156
    static bool sendSpontaneousEvent(QObject *receiver, QEvent *event);
 
157
 
 
158
    void init();
 
159
 
 
160
    static QCoreApplication *self;
 
161
 
 
162
    friend class QEventDispatcherUNIXPrivate;
 
163
    friend class QApplication;
 
164
    friend class QApplicationPrivate;
 
165
    friend class QETWidget;
 
166
    friend class Q3AccelManager;
 
167
    friend class QShortcutMap;
 
168
    friend class QWidget;
 
169
    friend class QWidgetPrivate;
 
170
#if defined(Q_WS_WIN) || defined (Q_WS_MAC) || defined (Q_WS_QWS)
 
171
    friend bool qt_sendSpontaneousEvent(QObject*, QEvent*);
 
172
#endif
 
173
};
 
174
 
 
175
inline bool QCoreApplication::sendEvent(QObject *receiver, QEvent *event)
 
176
{  if (event) event->spont = false; return self ? self->notify(receiver, event) : false; }
 
177
 
 
178
inline bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event)
 
179
{ if (event) event->spont = true; return self ? self->notify(receiver, event) : false; }
 
180
 
 
181
inline void QCoreApplication::sendPostedEvents() { sendPostedEvents(0, 0); }
 
182
 
 
183
#ifdef QT_NO_TRANSLATION
 
184
// Simple versions
 
185
inline QString QCoreApplication::translate(const char *, const char *sourceText,
 
186
                                           const char *, Encoding encoding)
 
187
{
 
188
#ifndef QT_NO_TEXTCODEC
 
189
    if (encoding == UnicodeUTF8)
 
190
        return QString::fromUtf8(sourceText);
 
191
#else
 
192
    Q_UNUSED(encoding)
 
193
#endif
 
194
    return QString::fromLatin1(sourceText);
 
195
}
 
196
#endif
 
197
 
 
198
typedef void (*QtCleanUpFunction)();
 
199
 
 
200
Q_CORE_EXPORT void qAddPostRoutine(QtCleanUpFunction);
 
201
Q_CORE_EXPORT void qRemovePostRoutine(QtCleanUpFunction);
 
202
Q_CORE_EXPORT QString qAppName();                // get application name
 
203
 
 
204
#if defined(Q_WS_WIN) && !defined(QT_NO_DEBUG_STREAM)
 
205
Q_CORE_EXPORT QString decodeMSG(const MSG &);
 
206
Q_CORE_EXPORT QDebug operator<<(QDebug, const MSG &);
 
207
#endif
 
208
 
 
209
#endif // QCOREAPPLICATION_H