diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-02 19:12:15 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-02 19:12:15 +0000 |
commit | 4c3c7eaa2d225ecc0c16644f1a23e848bf539164 (patch) | |
tree | e2ec7ae4bdc3be1f6ffbc999802b6db8db1ad9c3 /qtinterface/tqt4/Qt | |
parent | 60cbdb4674377338156be84fc3890358e44f23ba (diff) | |
download | tqtinterface-4c3c7eaa2d225ecc0c16644f1a23e848bf539164.tar.gz tqtinterface-4c3c7eaa2d225ecc0c16644f1a23e848bf539164.zip |
Starting work on Qt4 interface...
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/dependencies/tqtinterface@1158413 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtinterface/tqt4/Qt')
-rw-r--r-- | qtinterface/tqt4/Qt/q3cstring.h | 278 | ||||
-rw-r--r-- | qtinterface/tqt4/Qt/qapplication.h | 416 | ||||
-rw-r--r-- | qtinterface/tqt4/Qt/qbytearray.h | 597 | ||||
-rw-r--r-- | qtinterface/tqt4/Qt/qlist.h | 786 | ||||
-rw-r--r-- | qtinterface/tqt4/Qt/qobject.h | 499 | ||||
-rw-r--r-- | qtinterface/tqt4/Qt/qobjectdefs.h | 492 |
6 files changed, 3068 insertions, 0 deletions
diff --git a/qtinterface/tqt4/Qt/q3cstring.h b/qtinterface/tqt4/Qt/q3cstring.h new file mode 100644 index 0000000..240ff8e --- /dev/null +++ b/qtinterface/tqt4/Qt/q3cstring.h @@ -0,0 +1,278 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt3Support module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q3CSTRING_H +#define Q3CSTRING_H + +#include <QtCore/qbytearray.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Qt3SupportLight) + +/***************************************************************************** + QCString class + *****************************************************************************/ + +class QRegExp; + +class Q_COMPAT_EXPORT Q3CString : public QByteArray +{ +public: + Q3CString() {} + Q3CString(int size) : QByteArray(size, '\0') {} + Q3CString(const Q3CString &s) : QByteArray(s) {} + Q3CString(const QByteArray &ba) : QByteArray(ba) {} + Q3CString(const char *str) : QByteArray(str) {} + Q3CString(const char *str, uint maxlen) : QByteArray(str, qMin(qstrlen(str), maxlen - 1)) {} + + Q3CString &operator=(const Q3CString &s) { + QByteArray::operator=(s); return *this; + } + Q3CString &operator=(const char *str) { + QByteArray::operator=(str); return *this; + } + Q3CString &operator=(const QByteArray &ba) { + QByteArray::operator=(ba); return *this; + } + + Q3CString copy() const { return *this; } + Q3CString &sprintf(const char *format, ...); + + Q3CString left(uint len) const { return QByteArray::left(len); } + Q3CString right(uint len) const { return QByteArray::right(len); } + Q3CString mid(uint index, uint len=0xffffffff) const { return QByteArray::mid(index, len); } + + Q3CString leftJustify(uint width, char fill=' ', bool trunc=false)const; + Q3CString rightJustify(uint width, char fill=' ',bool trunc=false)const; + + Q3CString lower() const { return QByteArray::toLower(); } + Q3CString upper() const { return QByteArray::toUpper(); } + + Q3CString stripWhiteSpace() const { return QByteArray::trimmed(); } + Q3CString simplifyWhiteSpace() const { return QByteArray::simplified(); } + + Q3CString &insert(uint index, const char *c) { QByteArray::insert(index, c); return *this; } + Q3CString &insert(uint index, char c) { QByteArray::insert(index, c); return *this; } + Q3CString &append(const char *c) { QByteArray::append(c); return *this; } + Q3CString &prepend(const char *c) { QByteArray::prepend(c); return *this; } + Q3CString &remove(uint index, uint len) { QByteArray::remove(index, len); return *this; } + Q3CString &replace(uint index, uint len, const char *c) + { QByteArray::replace(index, len, c); return *this; } + Q3CString &replace(char c, const Q3CString &after) { return replace(c, after.constData()); } + Q3CString &replace(char c, const char *after) { QByteArray::replace(c, after); return *this; } + Q3CString &replace(const Q3CString &b, const Q3CString &a) + { return replace(b.constData(), a.constData()); } + Q3CString &replace(const char *b, const char *a) { QByteArray::replace(b, a); return *this; } + Q3CString &replace(char b, char a) { QByteArray::replace(b, a); return *this; } + + short toShort(bool *ok=0) const; + ushort toUShort(bool *ok=0) const; + int toInt(bool *ok=0) const; + uint toUInt(bool *ok=0) const; + long toLong(bool *ok=0) const; + ulong toULong(bool *ok=0) const; + float toFloat(bool *ok=0) const; + double toDouble(bool *ok=0) const; + + Q3CString &setStr(const char *s) { *this = s; return *this; } + Q3CString &setNum(short); + Q3CString &setNum(ushort); + Q3CString &setNum(int); + Q3CString &setNum(uint); + Q3CString &setNum(long); + Q3CString &setNum(ulong); + Q3CString &setNum(float, char f='g', int prec=6); + Q3CString &setNum(double, char f='g', int prec=6); + + bool setExpand(uint index, char c); + +public: +#ifndef QT_NO_REGEXP + int contains( const QRegExp & ) const; +#endif + int contains(const char *a) const; +}; + + +/***************************************************************************** + Q3CString stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +Q_COMPAT_EXPORT QDataStream &operator<<(QDataStream &d, const Q3CString &s); +Q_COMPAT_EXPORT QDataStream &operator>>(QDataStream &d, Q3CString &s); +#endif + +/***************************************************************************** + Q3CString inline functions + *****************************************************************************/ + +inline Q3CString &Q3CString::setNum(short n) +{ return setNum(long(n)); } + +inline Q3CString &Q3CString::setNum(ushort n) +{ return setNum(ulong(n)); } + +inline Q3CString &Q3CString::setNum(int n) +{ return setNum(long(n)); } + +inline Q3CString &Q3CString::setNum(uint n) +{ return setNum(ulong(n)); } + +inline Q3CString &Q3CString::setNum(float n, char f, int prec) +{ return setNum(double(n),f,prec); } + +/***************************************************************************** + Q3CString non-member operators + *****************************************************************************/ + +Q_COMPAT_EXPORT inline bool operator==(const Q3CString &s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) == 0; } + +Q_COMPAT_EXPORT inline bool operator==(const Q3CString &s1, const char *s2) +{ return qstrcmp(s1, s2) == 0; } + +Q_COMPAT_EXPORT inline bool operator==(const char *s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) == 0; } + +Q_COMPAT_EXPORT inline bool operator!=(const Q3CString &s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) != 0; } + +Q_COMPAT_EXPORT inline bool operator!=(const Q3CString &s1, const char *s2) +{ return qstrcmp(s1, s2) != 0; } + +Q_COMPAT_EXPORT inline bool operator!=(const char *s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) != 0; } + +Q_COMPAT_EXPORT inline bool operator<(const Q3CString &s1, const Q3CString& s2) +{ return qstrcmp(s1, s2) < 0; } + +Q_COMPAT_EXPORT inline bool operator<(const Q3CString &s1, const char *s2) +{ return qstrcmp(s1, s2) < 0; } + +Q_COMPAT_EXPORT inline bool operator<(const char *s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) < 0; } + +Q_COMPAT_EXPORT inline bool operator<=(const Q3CString &s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) <= 0; } + +Q_COMPAT_EXPORT inline bool operator<=(const Q3CString &s1, const char *s2) +{ return qstrcmp(s1, s2) <= 0; } + +Q_COMPAT_EXPORT inline bool operator<=(const char *s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) <= 0; } + +Q_COMPAT_EXPORT inline bool operator>(const Q3CString &s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) > 0; } + +Q_COMPAT_EXPORT inline bool operator>(const Q3CString &s1, const char *s2) +{ return qstrcmp(s1, s2) > 0; } + +Q_COMPAT_EXPORT inline bool operator>(const char *s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) > 0; } + +Q_COMPAT_EXPORT inline bool operator>=(const Q3CString &s1, const Q3CString& s2) +{ return qstrcmp(s1, s2) >= 0; } + +Q_COMPAT_EXPORT inline bool operator>=(const Q3CString &s1, const char *s2) +{ return qstrcmp(s1, s2) >= 0; } + +Q_COMPAT_EXPORT inline bool operator>=(const char *s1, const Q3CString &s2) +{ return qstrcmp(s1, s2) >= 0; } + +Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, + const Q3CString &s2) +{ + Q3CString tmp(s1); + tmp += s2; + return tmp; +} +Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, + const QByteArray &s2) +{ + QByteArray tmp(s1); + tmp += s2; + return tmp; +} +Q_COMPAT_EXPORT inline const Q3CString operator+(const QByteArray &s1, + const Q3CString &s2) +{ + QByteArray tmp(s1); + tmp += s2; + return tmp; +} + +Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, const char *s2) +{ + Q3CString tmp(s1); + tmp += s2; + return tmp; +} + +Q_COMPAT_EXPORT inline const Q3CString operator+(const char *s1, const Q3CString &s2) +{ + Q3CString tmp(s1); + tmp += s2; + return tmp; +} + +Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, char c2) +{ + Q3CString tmp(s1); + tmp += c2; + return tmp; +} + +Q_COMPAT_EXPORT inline const Q3CString operator+(char c1, const Q3CString &s2) +{ + Q3CString tmp; + tmp += c1; + tmp += s2; + return tmp; +} + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // Q3CSTRING_H diff --git a/qtinterface/tqt4/Qt/qapplication.h b/qtinterface/tqt4/Qt/qapplication.h new file mode 100644 index 0000000..a9c22bb --- /dev/null +++ b/qtinterface/tqt4/Qt/qapplication.h @@ -0,0 +1,416 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QAPPLICATION_H +#define QAPPLICATION_H + +#include <QtCore/qcoreapplication.h> +#include <QtGui/qwindowdefs.h> +#include <QtCore/qpoint.h> +#include <QtCore/qsize.h> +#include <QtGui/qcursor.h> +#ifdef QT_INCLUDE_COMPAT +# include <QtGui/qdesktopwidget.h> +#endif +#ifdef QT3_SUPPORT +# include <QtGui/qwidget.h> +# include <QtGui/qpalette.h> +#endif +#ifdef Q_WS_QWS +# include <QtGui/qrgb.h> +# include <QtGui/qtransportauth_qws.h> +#endif + +QT_BEGIN_HEADER + +#if defined(Q_WS_S60) +class CApaApplication; +#endif + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QSessionManager; +class QDesktopWidget; +class QStyle; +class QEventLoop; +class QIcon; +class QInputContext; +template <typename T> class QList; +class QLocale; +#if defined(Q_WS_QWS) +class QDecoration; +#endif +#if defined(Q_OS_SYMBIAN) +class QSymbianEvent; +#endif + +class QApplication; +class QApplicationPrivate; +#if defined(qApp) +#undef qApp +#endif +#define qApp (static_cast<QApplication *>(QCoreApplication::instance())) + + +class Q_GUI_EXPORT QApplication : public QCoreApplication +{ + Q_OBJECT + Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection) + Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon) + Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime) + Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval) + Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval) +#ifndef QT_NO_WHEELEVENT + Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines) +#endif + Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut) + Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime) + Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance) + Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed) +#ifndef QT_NO_STYLE_STYLESHEET + Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) +#endif +#ifdef Q_WS_WINCE + Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold) +#endif + Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) + +public: + enum Type { Tty, GuiClient, GuiServer }; + +#ifdef Q_WS_S60 + typedef CApaApplication * (*QS60MainApplicationFactory)(); +#endif + +#ifndef qdoc + QApplication(int &argc, char **argv, int = QT_VERSION); + QApplication(int &argc, char **argv, bool GUIenabled, int = QT_VERSION); + QApplication(int &argc, char **argv, Type, int = QT_VERSION); +#if defined(Q_WS_X11) + QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = QT_VERSION); + QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION); +#endif +#if defined(Q_WS_S60) + QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION); +#endif +#endif + virtual ~QApplication(); + + static Type type(); + + static QStyle *style(); + static void setStyle(QStyle*); + static QStyle *setStyle(const QString&); + enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }; + static int colorSpec(); + static void setColorSpec(int); + static void setGraphicsSystem(const QString &); + +#ifndef QT_NO_CURSOR + static QCursor *overrideCursor(); + static void setOverrideCursor(const QCursor &); + static void changeOverrideCursor(const QCursor &); + static void restoreOverrideCursor(); +#endif + static QPalette palette(); + static QPalette palette(const QWidget *); + static QPalette palette(const char *className); + static void setPalette(const QPalette &, const char* className = 0); + static QFont font(); + static QFont font(const QWidget*); + static QFont font(const char *className); + static void setFont(const QFont &, const char* className = 0); + static QFontMetrics fontMetrics(); + + static void setWindowIcon(const QIcon &icon); + static QIcon windowIcon(); + + +#ifdef QT3_SUPPORT + static QT3_SUPPORT QWidget *mainWidget(); + static QT3_SUPPORT void setMainWidget(QWidget *); +#endif + + static QWidgetList allWidgets(); + static QWidgetList topLevelWidgets(); + + static QDesktopWidget *desktop(); + + static QWidget *activePopupWidget(); + static QWidget *activeModalWidget(); +#ifndef QT_NO_CLIPBOARD + static QClipboard *clipboard(); +#endif + static QWidget *focusWidget(); + + static QWidget *activeWindow(); + static void setActiveWindow(QWidget* act); + + static QWidget *widgetAt(const QPoint &p); + static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); } + static QWidget *topLevelAt(const QPoint &p); + static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); } + + static void syncX(); + static void beep(); + static void alert(QWidget *widget, int duration = 0); + + static Qt::KeyboardModifiers keyboardModifiers(); + static Qt::MouseButtons mouseButtons(); + + static void setDesktopSettingsAware(bool); + static bool desktopSettingsAware(); + + static void setCursorFlashTime(int); + static int cursorFlashTime(); + + static void setDoubleClickInterval(int); + static int doubleClickInterval(); + + static void setKeyboardInputInterval(int); + static int keyboardInputInterval(); + +#ifndef QT_NO_WHEELEVENT + static void setWheelScrollLines(int); + static int wheelScrollLines(); +#endif + static void setGlobalStrut(const QSize &); + static QSize globalStrut(); + + static void setStartDragTime(int ms); + static int startDragTime(); + static void setStartDragDistance(int l); + static int startDragDistance(); + + static void setLayoutDirection(Qt::LayoutDirection direction); + static Qt::LayoutDirection layoutDirection(); + + static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; } + static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; } + + static bool isEffectEnabled(Qt::UIEffect); + static void setEffectEnabled(Qt::UIEffect, bool enable = true); + +#if defined(Q_WS_MAC) + virtual bool macEventFilter(EventHandlerCallRef, EventRef); +#endif +#if defined(Q_WS_X11) + virtual bool x11EventFilter(XEvent *); + virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only); + int x11ProcessEvent(XEvent*); +#endif +#if defined(Q_OS_SYMBIAN) + int symbianProcessEvent(const QSymbianEvent *event); + virtual bool symbianEventFilter(const QSymbianEvent *event); +#endif +#if defined(Q_WS_QWS) + virtual bool qwsEventFilter(QWSEvent *); + int qwsProcessEvent(QWSEvent*); + void qwsSetCustomColors(QRgb *colortable, int start, int numColors); +#ifndef QT_NO_QWS_MANAGER + static QDecoration &qwsDecoration(); + static void qwsSetDecoration(QDecoration *); + static QDecoration *qwsSetDecoration(const QString &decoration); +#endif +#endif + + +#if defined(Q_WS_WIN) + void winFocus(QWidget *, bool); + static void winMouseButtonUp(); +#endif +#ifndef QT_NO_SESSIONMANAGER + // session management + bool isSessionRestored() const; + QString sessionId() const; + QString sessionKey() const; + virtual void commitData(QSessionManager& sm); + virtual void saveState(QSessionManager& sm); +#endif + void setInputContext(QInputContext *); + QInputContext *inputContext() const; + + static QLocale keyboardInputLocale(); + static Qt::LayoutDirection keyboardInputDirection(); + + static int exec(); + bool notify(QObject *, QEvent *); + + + static void setQuitOnLastWindowClosed(bool quit); + static bool quitOnLastWindowClosed(); + +#ifdef QT_KEYPAD_NAVIGATION + static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool); + static bool keypadNavigationEnabled(); + static void setNavigationMode(Qt::NavigationMode mode); + static Qt::NavigationMode navigationMode(); +#endif + +Q_SIGNALS: + void lastWindowClosed(); + void focusChanged(QWidget *old, QWidget *now); + void fontDatabaseChanged(); +#ifndef QT_NO_SESSIONMANAGER + void commitDataRequest(QSessionManager &sessionManager); + void saveStateRequest(QSessionManager &sessionManager); +#endif + +public: + QString styleSheet() const; +public Q_SLOTS: +#ifndef QT_NO_STYLE_STYLESHEET + void setStyleSheet(const QString& sheet); +#endif +#ifdef Q_WS_WINCE + void setAutoMaximizeThreshold(const int threshold); + int autoMaximizeThreshold() const; +#endif + void setAutoSipEnabled(const bool enabled); + bool autoSipEnabled() const; + static void closeAllWindows(); + static void aboutQt(); + +protected: +#if defined(Q_WS_QWS) + void setArgs(int, char **); +#endif + bool event(QEvent *); + bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); + +#ifdef QT3_SUPPORT +public: + static TQEventLoop *eventLoop(); + static inline QT3_SUPPORT void setReverseLayout(bool b) { setLayoutDirection(b?Qt::RightToLeft:Qt::LeftToRight); } + static inline bool QT3_SUPPORT reverseLayout() { return layoutDirection() == Qt::RightToLeft; } + static QT3_SUPPORT Qt::Alignment horizontalAlignment(Qt::Alignment align); + typedef int ColorMode; + enum { NormalColors = NormalColor, CustomColors = CustomColor }; + static inline QT3_SUPPORT ColorMode colorMode() { return static_cast<ColorMode>(colorSpec()); } + static inline QT3_SUPPORT void setColorMode(ColorMode mode) { setColorSpec(int(mode)); } +#if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN) + static QT3_SUPPORT Qt::WindowsVersion winVersion() { return (Qt::WindowsVersion)QSysInfo::WindowsVersion; } +#endif +#if defined(Q_OS_MAC) + static QT3_SUPPORT Qt::MacintoshVersion macVersion() { return (Qt::MacintoshVersion)QSysInfo::MacintoshVersion; } +#endif +# ifndef QT_NO_CURSOR + inline static QT3_SUPPORT void setOverrideCursor(const QCursor &cursor, bool replace) + { if (replace) changeOverrideCursor(cursor); else setOverrideCursor(cursor); } +# endif + inline static QT3_SUPPORT bool hasGlobalMouseTracking() {return true;} + inline static QT3_SUPPORT void setGlobalMouseTracking(bool) {} + inline static QT3_SUPPORT void flushX() { flush(); } + static inline QT3_SUPPORT void setWinStyleHighlightColor(const QColor &c) { + QPalette p(palette()); + p.setColor(QPalette::Highlight, c); + setPalette(p); + } + static inline QT3_SUPPORT const QColor &winStyleHighlightColor() + { return palette().color(QPalette::Active, QPalette::Highlight); } + static inline QT3_SUPPORT void setPalette(const QPalette &pal, bool, const char* className = 0) + { setPalette(pal, className); } + static inline QT3_SUPPORT void setFont(const QFont &font, bool, const char* className = 0) + { setFont(font, className); } + + static inline QT3_SUPPORT QWidget *widgetAt(int x, int y, bool child) + { QWidget *w = widgetAt(x, y); return child ? w : (w ? w->window() : 0); } + static inline QT3_SUPPORT QWidget *widgetAt(const QPoint &p, bool child) + { QWidget *w = widgetAt(p); return child ? w : (w ? w->window() : 0); } +#endif // QT3_SUPPORT + +#if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc) + QApplication(int &argc, char **argv); + QApplication(int &argc, char **argv, bool GUIenabled); + QApplication(int &argc, char **argv, Type); +#if defined(Q_WS_X11) + QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); + QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); +#endif +#if defined(Q_WS_S60) || defined(qdoc) + QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv); +#endif +#endif + +private: + Q_DISABLE_COPY(QApplication) + Q_DECLARE_PRIVATE(QApplication) + + friend class QGraphicsWidget; + friend class QGraphicsScene; + friend class QGraphicsScenePrivate; + friend class QWidget; + friend class QWidgetPrivate; + friend class QETWidget; + friend class Q3AccelManager; + friend class QTranslator; + friend class QWidgetAnimator; +#ifndef QT_NO_SHORTCUT + friend class QShortcut; + friend class QLineEdit; + friend class QTextControl; +#endif + friend class QAction; + friend class QFontDatabasePrivate; + +#if defined(Q_WS_QWS) + friend class QInputContext; + friend class QWSDirectPainterSurface; + friend class QDirectPainter; + friend class QDirectPainterPrivate; +#endif + friend class QGestureManager; + +#if defined(Q_WS_MAC) || defined(Q_WS_X11) + Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut()) +#endif +#if defined(QT_RX71_MULTITOUCH) + Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents()) +#endif +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAPPLICATION_H diff --git a/qtinterface/tqt4/Qt/qbytearray.h b/qtinterface/tqt4/Qt/qbytearray.h new file mode 100644 index 0000000..6dd4026 --- /dev/null +++ b/qtinterface/tqt4/Qt/qbytearray.h @@ -0,0 +1,597 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBYTEARRAY_H +#define QBYTEARRAY_H + +#include <QtCore/qatomic.h> +#include <QtCore/qnamespace.h> + +#include <string.h> +#include <stdarg.h> + +#ifdef truncate +#error qbytearray.h must be included before any header file that defines truncate +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +/***************************************************************************** + Safe and portable C string functions; extensions to standard string.h + *****************************************************************************/ + +Q_CORE_EXPORT char *qstrdup(const char *); + +inline uint qstrlen(const char *str) +{ return str ? uint(strlen(str)) : 0; } + +inline uint qstrnlen(const char *str, uint maxlen) +{ + uint length = 0; + if (str) { + while (length < maxlen && *str++) + length++; + } + return length; +} + +Q_CORE_EXPORT char *qstrcpy(char *dst, const char *src); +Q_CORE_EXPORT char *qstrncpy(char *dst, const char *src, uint len); + +Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2); +Q_CORE_EXPORT int qstrcmp(const QByteArray &str1, const QByteArray &str2); +Q_CORE_EXPORT int qstrcmp(const QByteArray &str1, const char *str2); +static inline int qstrcmp(const char *str1, const QByteArray &str2) +{ return -qstrcmp(str2, str1); } + +inline int qstrncmp(const char *str1, const char *str2, uint len) +{ + return (str1 && str2) ? strncmp(str1, str2, len) + : (str1 ? 1 : (str2 ? -1 : 0)); +} +Q_CORE_EXPORT int qstricmp(const char *, const char *); +Q_CORE_EXPORT int qstrnicmp(const char *, const char *, uint len); + +// implemented in qvsnprintf.cpp +Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap); +Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...); + +#ifdef QT3_SUPPORT +inline QT3_SUPPORT void *qmemmove(void *dst, const void *src, uint len) +{ return memmove(dst, src, len); } +inline QT3_SUPPORT uint cstrlen(const char *str) +{ return uint(strlen(str)); } +inline QT3_SUPPORT char *cstrcpy(char *dst, const char *src) +{ return qstrcpy(dst,src); } +inline QT3_SUPPORT int cstrcmp(const char *str1, const char *str2) +{ return strcmp(str1,str2); } +inline QT3_SUPPORT int cstrncmp(const char *str1, const char *str2, uint len) +{ return strncmp(str1,str2,len); } +#endif + +// qChecksum: Internet checksum + +Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len); + +class QByteRef; +class QString; +class QDataStream; +template <typename T> class QList; + +class Q_CORE_EXPORT QByteArray +{ +private: + struct Data { + QBasicAtomicInt ref; + int alloc, size; + // ### Qt 5.0: We need to add the missing capacity bit + // (like other tool classes have), to maintain the + // reserved memory on resize. + char *data; + char array[1]; + }; + +public: + inline QByteArray(); + QByteArray(const char *); + QByteArray(const char *, int size); + QByteArray(int size, char c); + QByteArray(int size, Qt::Initialization); + inline QByteArray(const QByteArray &); + inline ~QByteArray(); + + QByteArray &operator=(const QByteArray &); + QByteArray &operator=(const char *str); + + inline int size() const; + bool isEmpty() const; + void resize(int size); + + QByteArray &fill(char c, int size = -1); + + int capacity() const; + void reserve(int size); + void squeeze(); + +#ifndef QT_NO_CAST_FROM_BYTEARRAY + operator const char *() const; + operator const void *() const; + operator QByteArray *() const; +#endif + char *data(); + char *data() const; + inline const char *constData() const; + inline void detach(); + bool isDetached() const; + void clear(); + +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE + const char at(int i) const; + const char operator[](int i) const; + const char operator[](uint i) const; +#else + char at(int i) const; + char operator[](int i) const; + char operator[](uint i) const; +#endif + QByteRef operator[](int i); + QByteRef operator[](uint i); + + int indexOf(char c, int from = 0) const; + int indexOf(const char *c, int from = 0) const; + int indexOf(const QByteArray &a, int from = 0) const; + int lastIndexOf(char c, int from = -1) const; + int lastIndexOf(const char *c, int from = -1) const; + int lastIndexOf(const QByteArray &a, int from = -1) const; + + QBool contains(char c) const; + QBool contains(const char *a) const; + QBool contains(const QByteArray &a) const; + int count(char c) const; + int count(const char *a) const; + int count(const QByteArray &a) const; + + QByteArray left(int len) const; + QByteArray right(int len) const; + QByteArray mid(int index, int len = -1) const; + + bool startsWith(const QByteArray &a) const; + bool startsWith(char c) const; + bool startsWith(const char *c) const; + + bool endsWith(const QByteArray &a) const; + bool endsWith(char c) const; + bool endsWith(const char *c) const; + + void truncate(int pos); + void chop(int n); + + QByteArray toLower() const; + QByteArray toUpper() const; + + QByteArray trimmed() const; + QByteArray simplified() const; + QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const; + QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const; + +#ifdef QT3_SUPPORT + inline QT3_SUPPORT QByteArray leftJustify(uint width, char aFill = ' ', bool aTruncate = false) const + { return leftJustified(int(width), aFill, aTruncate); } + inline QT3_SUPPORT QByteArray rightJustify(uint width, char aFill = ' ', bool aTruncate = false) const + { return rightJustified(int(width), aFill, aTruncate); } +#endif + + QByteArray &prepend(char c); + QByteArray &prepend(const char *s); + QByteArray &prepend(const char *s, int len); + QByteArray &prepend(const QByteArray &a); + QByteArray &append(char c); + QByteArray &append(const char *s); + QByteArray &append(const char *s, int len); + QByteArray &append(const QByteArray &a); + QByteArray &insert(int i, char c); + QByteArray &insert(int i, const char *s); + QByteArray &insert(int i, const char *s, int len); + QByteArray &insert(int i, const QByteArray &a); + QByteArray &remove(int index, int len); + QByteArray &replace(int index, int len, const char *s); + QByteArray &replace(int index, int len, const QByteArray &s); + QByteArray &replace(char before, const char *after); + QByteArray &replace(char before, const QByteArray &after); + QByteArray &replace(const char *before, const char *after); + QByteArray &replace(const char *before, int bsize, const char *after, int asize); + QByteArray &replace(const QByteArray &before, const QByteArray &after); + QByteArray &replace(const QByteArray &before, const char *after); + QByteArray &replace(const char *before, const QByteArray &after); + QByteArray &replace(char before, char after); + QByteArray &operator+=(char c); + QByteArray &operator+=(const char *s); + QByteArray &operator+=(const QByteArray &a); + + QList<QByteArray> split(char sep) const; + + QByteArray repeated(int times) const; + +#ifndef QT_NO_CAST_TO_ASCII + QT_ASCII_CAST_WARN QByteArray &append(const QString &s); + QT_ASCII_CAST_WARN QByteArray &insert(int i, const QString &s); + QT_ASCII_CAST_WARN QByteArray &replace(const QString &before, const char *after); + QT_ASCII_CAST_WARN QByteArray &replace(char c, const QString &after); + QT_ASCII_CAST_WARN QByteArray &replace(const QString &before, const QByteArray &after); + + QT_ASCII_CAST_WARN QByteArray &operator+=(const QString &s); + QT_ASCII_CAST_WARN int indexOf(const QString &s, int from = 0) const; + QT_ASCII_CAST_WARN int lastIndexOf(const QString &s, int from = -1) const; +#endif +#ifndef QT_NO_CAST_FROM_ASCII + inline QT_ASCII_CAST_WARN bool operator==(const QString &s2) const; + inline QT_ASCII_CAST_WARN bool operator!=(const QString &s2) const; + inline QT_ASCII_CAST_WARN bool operator<(const QString &s2) const; + inline QT_ASCII_CAST_WARN bool operator>(const QString &s2) const; + inline QT_ASCII_CAST_WARN bool operator<=(const QString &s2) const; + inline QT_ASCII_CAST_WARN bool operator>=(const QString &s2) const; +#endif + + short toShort(bool *ok = 0, int base = 10) const; + ushort toUShort(bool *ok = 0, int base = 10) const; + int toInt(bool *ok = 0, int base = 10) const; + uint toUInt(bool *ok = 0, int base = 10) const; + long toLong(bool *ok = 0, int base = 10) const; + ulong toULong(bool *ok = 0, int base = 10) const; + qlonglong toLongLong(bool *ok = 0, int base = 10) const; + qulonglong toULongLong(bool *ok = 0, int base = 10) const; + float toFloat(bool *ok = 0) const; + double toDouble(bool *ok = 0) const; + QByteArray toBase64() const; + QByteArray toHex() const; + QByteArray toPercentEncoding(const QByteArray &exclude = QByteArray(), + const QByteArray &include = QByteArray(), + char percent = '%') const; + + QByteArray &setNum(short, int base = 10); + QByteArray &setNum(ushort, int base = 10); + QByteArray &setNum(int, int base = 10); + QByteArray &setNum(uint, int base = 10); + QByteArray &setNum(qlonglong, int base = 10); + QByteArray &setNum(qulonglong, int base = 10); + QByteArray &setNum(float, char f = 'g', int prec = 6); + QByteArray &setNum(double, char f = 'g', int prec = 6); + + static QByteArray number(int, int base = 10); + static QByteArray number(uint, int base = 10); + static QByteArray number(qlonglong, int base = 10); + static QByteArray number(qulonglong, int base = 10); + static QByteArray number(double, char f = 'g', int prec = 6); + static QByteArray fromRawData(const char *, int size); + static QByteArray fromBase64(const QByteArray &base64); + static QByteArray fromHex(const QByteArray &hexEncoded); + static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%'); + + + typedef char *iterator; + typedef const char *const_iterator; + typedef iterator Iterator; + typedef const_iterator ConstIterator; + iterator begin(); + const_iterator begin() const; + const_iterator constBegin() const; + iterator end(); + const_iterator end() const; + const_iterator constEnd() const; + + // stl compatibility + typedef const char & const_reference; + typedef char & reference; + typedef char value_type; + void push_back(char c); + void push_back(const char *c); + void push_back(const QByteArray &a); + void push_front(char c); + void push_front(const char *c); + void push_front(const QByteArray &a); + + inline int count() const { return d->size; } + int length() const { return d->size; } + bool isNull() const; + + // compatibility +#ifdef QT3_SUPPORT + QT3_SUPPORT_CONSTRUCTOR QByteArray(int size); + inline QT3_SUPPORT QByteArray& duplicate(const QByteArray& a) { *this = a; return *this; } + inline QT3_SUPPORT QByteArray& duplicate(const char *a, uint n) + { *this = QByteArray(a, n); return *this; } + inline QT3_SUPPORT QByteArray& setRawData(const char *a, uint n) + { *this = fromRawData(a, n); return *this; } + inline QT3_SUPPORT void resetRawData(const char *, uint) { clear(); } + inline QT3_SUPPORT QByteArray lower() const { return toLower(); } + inline QT3_SUPPORT QByteArray upper() const { return toUpper(); } + inline QT3_SUPPORT QByteArray stripWhiteSpace() const { return trimmed(); } + inline QT3_SUPPORT QByteArray simplifyWhiteSpace() const { return simplified(); } + inline QT3_SUPPORT int find(char c, int from = 0) const { return indexOf(c, from); } + inline QT3_SUPPORT int find(const char *c, int from = 0) const { return indexOf(c, from); } + inline QT3_SUPPORT int find(const QByteArray &ba, int from = 0) const { return indexOf(ba, from); } + inline QT3_SUPPORT int findRev(char c, int from = -1) const { return lastIndexOf(c, from); } + inline QT3_SUPPORT int findRev(const char *c, int from = -1) const { return lastIndexOf(c, from); } + inline QT3_SUPPORT int findRev(const QByteArray &ba, int from = -1) const { return lastIndexOf(ba, from); } +#ifndef QT_NO_CAST_TO_ASCII + QT3_SUPPORT int find(const QString &s, int from = 0) const; + QT3_SUPPORT int findRev(const QString &s, int from = -1) const; +#endif +#endif + +private: + operator QNoImplicitBoolCast() const; + static Data shared_null; + static Data shared_empty; + Data *d; + QByteArray(Data *dd, int /*dummy*/, int /*dummy*/) : d(dd) {} + void realloc(int alloc); + void expand(int i); + QByteArray nulTerminated() const; + + friend class QByteRef; + friend class QString; + friend Q_CORE_EXPORT QByteArray qUncompress(const uchar *data, int nbytes); +public: + typedef Data * DataPtr; + inline DataPtr &data_ptr() { return d; } +}; + +inline QByteArray::QByteArray(): d(&shared_null) { d->ref.ref(); } +inline QByteArray::~QByteArray() { if (!d->ref.deref()) qFree(d); } +inline int QByteArray::size() const +{ return d->size; } + +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE +inline const char QByteArray::at(int i) const +{ Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } +inline const char QByteArray::operator[](int i) const +{ Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } +inline const char QByteArray::operator[](uint i) const +{ Q_ASSERT(i < uint(size())); return d->data[i]; } +#else +inline char QByteArray::at(int i) const +{ Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } +inline char QByteArray::operator[](int i) const +{ Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } +inline char QByteArray::operator[](uint i) const +{ Q_ASSERT(i < uint(size())); return d->data[i]; } +#endif + +inline bool QByteArray::isEmpty() const +{ return d->size == 0; } +#ifndef QT_NO_CAST_FROM_BYTEARRAY +inline QByteArray::operator const char *() const +{ return d->data; } +inline QByteArray::operator const void *() const +{ return d->data; } +#endif +inline char *QByteArray::data() +{ detach(); return d->data; } +inline char *QByteArray::data() const +{ return d->data; } +inline const char *QByteArray::constData() const +{ return d->data; } +inline void QByteArray::detach() +{ if (d->ref != 1 || d->data != d->array) realloc(d->size); } +inline bool QByteArray::isDetached() const +{ return d->ref == 1; } +inline QByteArray::QByteArray(const QByteArray &a) : d(a.d) +{ d->ref.ref(); } +#ifdef QT3_SUPPORT +inline QByteArray::QByteArray(int aSize) : d(&shared_null) +{ d->ref.ref(); if (aSize > 0) fill('\0', aSize); } +#endif + +inline int QByteArray::capacity() const +{ return d->alloc; } + +inline void QByteArray::reserve(int asize) +{ if (d->ref != 1 || asize > d->alloc) realloc(asize); } + +inline void QByteArray::squeeze() +{ if (d->size < d->alloc) realloc(d->size); } + +class Q_CORE_EXPORT QByteRef { + QByteArray &a; + int i; + inline QByteRef(QByteArray &array, int idx) + : a(array),i(idx) {} + friend class QByteArray; +public: +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE + inline operator const char() const + { return i < a.d->size ? a.d->data[i] : char(0); } +#else + inline operator char() const + { return i < a.d->size ? a.d->data[i] : char(0); } +#endif + inline QByteRef &operator=(char c) + { if (i >= a.d->size) a.expand(i); else a.detach(); + a.d->data[i] = c; return *this; } + inline QByteRef &operator=(const QByteRef &c) + { if (i >= a.d->size) a.expand(i); else a.detach(); + a.d->data[i] = c.a.d->data[c.i]; return *this; } + inline bool operator==(char c) const + { return a.d->data[i] == c; } + inline bool operator!=(char c) const + { return a.d->data[i] != c; } + inline bool operator>(char c) const + { return a.d->data[i] > c; } + inline bool operator>=(char c) const + { return a.d->data[i] >= c; } + inline bool operator<(char c) const + { return a.d->data[i] < c; } + inline bool operator<=(char c) const + { return a.d->data[i] <= c; } +}; + +inline QByteRef QByteArray::operator[](int i) +{ Q_ASSERT(i >= 0); return QByteRef(*this, i); } +inline QByteRef QByteArray::operator[](uint i) +{ return QByteRef(*this, i); } +inline QByteArray::iterator QByteArray::begin() +{ detach(); return d->data; } +inline QByteArray::const_iterator QByteArray::begin() const +{ return d->data; } +inline QByteArray::const_iterator QByteArray::constBegin() const +{ return d->data; } +inline QByteArray::iterator QByteArray::end() +{ detach(); return d->data + d->size; } +inline QByteArray::const_iterator QByteArray::end() const +{ return d->data + d->size; } +inline QByteArray::const_iterator QByteArray::constEnd() const +{ return d->data + d->size; } +inline QByteArray &QByteArray::operator+=(char c) +{ return append(c); } +inline QByteArray &QByteArray::operator+=(const char *s) +{ return append(s); } +inline QByteArray &QByteArray::operator+=(const QByteArray &a) +{ return append(a); } +inline void QByteArray::push_back(char c) +{ append(c); } +inline void QByteArray::push_back(const char *c) +{ append(c); } +inline void QByteArray::push_back(const QByteArray &a) +{ append(a); } +inline void QByteArray::push_front(char c) +{ prepend(c); } +inline void QByteArray::push_front(const char *c) +{ prepend(c); } +inline void QByteArray::push_front(const QByteArray &a) +{ prepend(a); } +inline QBool QByteArray::contains(const QByteArray &a) const +{ return QBool(indexOf(a) != -1); } +inline QBool QByteArray::contains(char c) const +{ return QBool(indexOf(c) != -1); } +inline bool operator==(const QByteArray &a1, const QByteArray &a2) +{ return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); } +inline bool operator==(const QByteArray &a1, const char *a2) +{ return a2 ? qstrcmp(a1,a2) == 0 : a1.isEmpty(); } +inline bool operator==(const char *a1, const QByteArray &a2) +{ return a1 ? qstrcmp(a1,a2) == 0 : a2.isEmpty(); } +inline bool operator!=(const QByteArray &a1, const QByteArray &a2) +{ return !(a1==a2); } +inline bool operator!=(const QByteArray &a1, const char *a2) +{ return a2 ? qstrcmp(a1,a2) != 0 : !a1.isEmpty(); } +inline bool operator!=(const char *a1, const QByteArray &a2) +{ return a1 ? qstrcmp(a1,a2) != 0 : !a2.isEmpty(); } +inline bool operator<(const QByteArray &a1, const QByteArray &a2) +{ return qstrcmp(a1, a2) < 0; } + inline bool operator<(const QByteArray &a1, const char *a2) +{ return qstrcmp(a1, a2) < 0; } +inline bool operator<(const char *a1, const QByteArray &a2) +{ return qstrcmp(a1, a2) < 0; } +inline bool operator<=(const QByteArray &a1, const QByteArray &a2) +{ return qstrcmp(a1, a2) <= 0; } +inline bool operator<=(const QByteArray &a1, const char *a2) +{ return qstrcmp(a1, a2) <= 0; } +inline bool operator<=(const char *a1, const QByteArray &a2) +{ return qstrcmp(a1, a2) <= 0; } +inline bool operator>(const QByteArray &a1, const QByteArray &a2) +{ return qstrcmp(a1, a2) > 0; } +inline bool operator>(const QByteArray &a1, const char *a2) +{ return qstrcmp(a1, a2) > 0; } +inline bool operator>(const char *a1, const QByteArray &a2) +{ return qstrcmp(a1, a2) > 0; } +inline bool operator>=(const QByteArray &a1, const QByteArray &a2) +{ return qstrcmp(a1, a2) >= 0; } +inline bool operator>=(const QByteArray &a1, const char *a2) +{ return qstrcmp(a1, a2) >= 0; } +inline bool operator>=(const char *a1, const QByteArray &a2) +{ return qstrcmp(a1, a2) >= 0; } +inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2) +{ return QByteArray(a1) += a2; } +inline const QByteArray operator+(const QByteArray &a1, const char *a2) +{ return QByteArray(a1) += a2; } +inline const QByteArray operator+(const QByteArray &a1, char a2) +{ return QByteArray(a1) += a2; } +inline const QByteArray operator+(const char *a1, const QByteArray &a2) +{ return QByteArray(a1) += a2; } +inline const QByteArray operator+(char a1, const QByteArray &a2) +{ return QByteArray(&a1, 1) += a2; } +inline QBool QByteArray::contains(const char *c) const +{ return QBool(indexOf(c) != -1); } +inline QByteArray &QByteArray::replace(char before, const char *c) +{ return replace(&before, 1, c, qstrlen(c)); } +inline QByteArray &QByteArray::replace(const QByteArray &before, const char *c) +{ return replace(before.constData(), before.size(), c, qstrlen(c)); } +inline QByteArray &QByteArray::replace(const char *before, const char *after) +{ return replace(before, qstrlen(before), after, qstrlen(after)); } + +inline QByteArray &QByteArray::setNum(short n, int base) +{ return setNum(qlonglong(n), base); } +inline QByteArray &QByteArray::setNum(ushort n, int base) +{ return setNum(qulonglong(n), base); } +inline QByteArray &QByteArray::setNum(int n, int base) +{ return setNum(qlonglong(n), base); } +inline QByteArray &QByteArray::setNum(uint n, int base) +{ return setNum(qulonglong(n), base); } +inline QByteArray &QByteArray::setNum(float n, char f, int prec) +{ return setNum(double(n),f,prec); } + + +#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)) +Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QByteArray &); +Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QByteArray &); +#endif + +#ifndef QT_NO_COMPRESS +Q_CORE_EXPORT QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel = -1); +Q_CORE_EXPORT QByteArray qUncompress(const uchar* data, int nbytes); +inline QByteArray qCompress(const QByteArray& data, int compressionLevel = -1) +{ return qCompress(reinterpret_cast<const uchar *>(data.constData()), data.size(), compressionLevel); } +inline QByteArray qUncompress(const QByteArray& data) +{ return qUncompress(reinterpret_cast<const uchar*>(data.constData()), data.size()); } +#endif + +Q_DECLARE_TYPEINFO(QByteArray, Q_MOVABLE_TYPE); +Q_DECLARE_SHARED(QByteArray) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QBYTEARRAY_H diff --git a/qtinterface/tqt4/Qt/qlist.h b/qtinterface/tqt4/Qt/qlist.h new file mode 100644 index 0000000..c3661e9 --- /dev/null +++ b/qtinterface/tqt4/Qt/qlist.h @@ -0,0 +1,786 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QLIST_H +#define QLIST_H + +#include <QtCore/qiterator.h> +#include <QtCore/qatomic.h> +#include <QtCore/qalgorithms.h> + +#ifndef QT_NO_STL +#include <iterator> +#include <list> +#endif + +#include <new> +#include <string.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +template <typename T> class QVector; +template <typename T> class QSet; + +struct Q_CORE_EXPORT QListData { + struct Data { + QBasicAtomicInt ref; + int alloc, begin, end; + uint sharable : 1; + void *array[1]; + }; + enum { DataHeaderSize = sizeof(Data) - sizeof(void *) }; + + Data *detach(); // remove in 5.0 + Data *detach2(); // remove in 5.0 + Data *detach3(); + void realloc(int alloc); + static Data shared_null; + Data *d; + void **erase(void **xi); + void **append(); + void **append(const QListData &l); + void **append2(const QListData &l); // remove in 5.0 + void **prepend(); + void **insert(int i); + void remove(int i); + void remove(int i, int n); + void move(int from, int to); + inline int size() const { return d->end - d->begin; } + inline bool isEmpty() const { return d->end == d->begin; } + inline void **at(int i) const { return d->array + d->begin + i; } + inline void **begin() const { return d->array + d->begin; } + inline void **end() const { return d->array + d->end; } +}; + +template <typename T> +class QList +{ + struct Node { void *v; +#if defined(Q_CC_BOR) + Q_INLINE_TEMPLATE T &t(); +#else + Q_INLINE_TEMPLATE T &t() + { return *reinterpret_cast<T*>(QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic + ? v : this); } +#endif + }; + + union { QListData p; QListData::Data *d; }; + +public: + inline QList() : d(&QListData::shared_null) { d->ref.ref(); } + inline QList(const QList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); } + ~QList(); + QList<T> &operator=(const QList<T> &l); + bool operator==(const QList<T> &l) const; + inline bool operator!=(const QList<T> &l) const { return !(*this == l); } + + operator bool() const; + + inline int size() const { return p.size(); } + + inline void detach() { if (d->ref != 1) detach_helper(); } + + inline void detachShared() + { + // The "this->" qualification is needed for GCCE. + if (d->ref != 1 && this->d != &QListData::shared_null) + detach_helper(); + } + + inline bool isDetached() const { return d->ref == 1; } + inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } + + inline bool isEmpty() const { return p.isEmpty(); } + + void clear(); + + const T &at(int i) const; + const T &operator[](int i) const; + T &operator[](int i); + + void append(const T &t); + void append(const QList<T> &t); + void prepend(const T &t); + void insert(int i, const T &t); + void replace(int i, const T &t); + void removeAt(int i); + int removeAll(const T &t); + bool removeOne(const T &t); + T takeAt(int i); + T takeFirst(); + T takeLast(); + void move(int from, int to); + void swap(int i, int j); + int indexOf(const T &t, int from = 0) const; + int lastIndexOf(const T &t, int from = -1) const; + QBool contains(const T &t) const; + int count(const T &t) const; + + class const_iterator; + + class iterator { + public: + Node *i; + typedef std::random_access_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef T *pointer; + typedef T &reference; + + inline iterator() : i(0) {} + inline iterator(Node *n) : i(n) {} + inline iterator(const iterator &o): i(o.i){} + inline T &operator*() const { return i->t(); } + inline T *operator->() const { return &i->t(); } + inline T &operator[](int j) const { return i[j].t(); } + inline bool operator==(const iterator &o) const { return i == o.i; } + inline bool operator!=(const iterator &o) const { return i != o.i; } + inline bool operator<(const iterator& other) const { return i < other.i; } + inline bool operator<=(const iterator& other) const { return i <= other.i; } + inline bool operator>(const iterator& other) const { return i > other.i; } + inline bool operator>=(const iterator& other) const { return i >= other.i; } +#ifndef QT_STRICT_ITERATORS + inline bool operator==(const const_iterator &o) const + { return i == o.i; } + inline bool operator!=(const const_iterator &o) const + { return i != o.i; } + inline bool operator<(const const_iterator& other) const + { return i < other.i; } + inline bool operator<=(const const_iterator& other) const + { return i <= other.i; } + inline bool operator>(const const_iterator& other) const + { return i > other.i; } + inline bool operator>=(const const_iterator& other) const + { return i >= other.i; } +#endif + inline iterator &operator++() { ++i; return *this; } + inline iterator operator++(int) { Node *n = i; ++i; return n; } + inline iterator &operator--() { i--; return *this; } + inline iterator operator--(int) { Node *n = i; i--; return n; } + inline iterator &operator+=(int j) { i+=j; return *this; } + inline iterator &operator-=(int j) { i-=j; return *this; } + inline iterator operator+(int j) const { return iterator(i+j); } + inline iterator operator-(int j) const { return iterator(i-j); } + inline int operator-(iterator j) const { return int(i - j.i); } + }; + friend class iterator; + + class const_iterator { + public: + Node *i; + typedef std::random_access_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef const T *pointer; + typedef const T &reference; + + inline const_iterator() : i(0) {} + inline const_iterator(Node *n) : i(n) {} + inline const_iterator(const const_iterator &o): i(o.i) {} +#ifdef QT_STRICT_ITERATORS + inline explicit const_iterator(const iterator &o): i(o.i) {} +#else + inline const_iterator(const iterator &o): i(o.i) {} +#endif + inline const T &operator*() const { return i->t(); } + inline const T *operator->() const { return &i->t(); } + inline const T &operator[](int j) const { return i[j].t(); } + inline bool operator==(const const_iterator &o) const { return i == o.i; } + inline bool operator!=(const const_iterator &o) const { return i != o.i; } + inline bool operator<(const const_iterator& other) const { return i < other.i; } + inline bool operator<=(const const_iterator& other) const { return i <= other.i; } + inline bool operator>(const const_iterator& other) const { return i > other.i; } + inline bool operator>=(const const_iterator& other) const { return i >= other.i; } + inline const_iterator &operator++() { ++i; return *this; } + inline const_iterator operator++(int) { Node *n = i; ++i; return n; } + inline const_iterator &operator--() { i--; return *this; } + inline const_iterator operator--(int) { Node *n = i; i--; return n; } + inline const_iterator &operator+=(int j) { i+=j; return *this; } + inline const_iterator &operator-=(int j) { i-=j; return *this; } + inline const_iterator operator+(int j) const { return const_iterator(i+j); } + inline const_iterator operator-(int j) const { return const_iterator(i-j); } + inline int operator-(const_iterator j) const { return i - j.i; } + }; + friend class const_iterator; + + // stl style + inline iterator begin() { detach(); return reinterpret_cast<Node *>(p.begin()); } + inline const_iterator begin() const { return reinterpret_cast<Node *>(p.begin()); } + inline const_iterator constBegin() const { return reinterpret_cast<Node *>(p.begin()); } + inline iterator end() { detach(); return reinterpret_cast<Node *>(p.end()); } + inline const_iterator end() const { return reinterpret_cast<Node *>(p.end()); } + inline const_iterator constEnd() const { return reinterpret_cast<Node *>(p.end()); } + iterator insert(iterator before, const T &t); + iterator erase(iterator pos); + iterator erase(iterator first, iterator last); + + // more Qt + typedef iterator Iterator; + typedef const_iterator ConstIterator; + inline int count() const { return p.size(); } + inline int length() const { return p.size(); } // Same as count() + inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); } + inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); } + T& last() { Q_ASSERT(!isEmpty()); return *(--end()); } + const T& last() const { Q_ASSERT(!isEmpty()); return *(--end()); } + inline void removeFirst() { Q_ASSERT(!isEmpty()); erase(begin()); } + inline void removeLast() { Q_ASSERT(!isEmpty()); erase(--end()); } + inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; } + inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; } + QList<T> mid(int pos, int length = -1) const; + + T value(int i) const; + T value(int i, const T &defaultValue) const; + + // stl compatibility + inline void push_back(const T &t) { append(t); } + inline void push_front(const T &t) { prepend(t); } + inline T& front() { return first(); } + inline const T& front() const { return first(); } + inline T& back() { return last(); } + inline const T& back() const { return last(); } + inline void pop_front() { removeFirst(); } + inline void pop_back() { removeLast(); } + inline bool empty() const { return isEmpty(); } + typedef int size_type; + typedef T value_type; + typedef value_type *pointer; + typedef const value_type *const_pointer; + typedef value_type &reference; + typedef const value_type &const_reference; + typedef ptrdiff_t difference_type; + +#ifdef QT3_SUPPORT + inline QT3_SUPPORT iterator remove(iterator pos) { return erase(pos); } + inline QT3_SUPPORT int remove(const T &t) { return removeAll(t); } + inline QT3_SUPPORT int findIndex(const T& t) const { return indexOf(t); } + inline QT3_SUPPORT iterator find(const T& t) + { int i = indexOf(t); return (i == -1 ? end() : (begin()+i)); } + inline QT3_SUPPORT const_iterator find (const T& t) const + { int i = indexOf(t); return (i == -1 ? end() : (begin()+i)); } + inline QT3_SUPPORT iterator find(iterator from, const T& t) + { int i = indexOf(t, from - begin()); return i == -1 ? end() : begin()+i; } + inline QT3_SUPPORT const_iterator find(const_iterator from, const T& t) const + { int i = indexOf(t, from - begin()); return i == -1 ? end() : begin()+i; } +#endif + + // comfort + QList<T> &operator+=(const QList<T> &l); + inline QList<T> operator+(const QList<T> &l) const + { QList n = *this; n += l; return n; } + inline QList<T> &operator+=(const T &t) + { append(t); return *this; } + inline QList<T> &operator<< (const T &t) + { append(t); return *this; } + inline QList<T> &operator<<(const QList<T> &l) + { *this += l; return *this; } + + QVector<T> toVector() const; + QSet<T> toSet() const; + + static QList<T> fromVector(const QVector<T> &vector); + static QList<T> fromSet(const QSet<T> &set); + +#ifndef QT_NO_STL + static inline QList<T> fromStdList(const std::list<T> &list) + { QList<T> tmp; qCopy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; } + inline std::list<T> toStdList() const + { std::list<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } +#endif + +private: + void detach_helper(); + void free(QListData::Data *d); + + void node_construct(Node *n, const T &t); + void node_destruct(Node *n); + void node_copy(Node *from, Node *to, Node *src); + void node_destruct(Node *from, Node *to); +}; + +#if defined(Q_CC_BOR) +template <typename T> +Q_INLINE_TEMPLATE T &QList<T>::Node::t() +{ return QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic ? *(T*)v:*(T*)this; } +#endif + +template <typename T> +Q_INLINE_TEMPLATE void QList<T>::node_construct(Node *n, const T &t) +{ + if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) n->v = new T(t); + else if (QTypeInfo<T>::isComplex) new (n) T(t); + else *reinterpret_cast<T*>(n) = t; +} + +template <typename T> +Q_INLINE_TEMPLATE void QList<T>::node_destruct(Node *n) +{ + if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) delete reinterpret_cast<T*>(n->v); + else if (QTypeInfo<T>::isComplex) reinterpret_cast<T*>(n)->~T(); +} + +template <typename T> +Q_INLINE_TEMPLATE void QList<T>::node_copy(Node *from, Node *to, Node *src) +{ + Node *current = from; + if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) { + QT_TRY { + while(current != to) { + current->v = new T(*reinterpret_cast<T*>(src->v)); + ++current; + ++src; + } + } QT_CATCH(...) { + while (current-- != from) + delete reinterpret_cast<T*>(current->v); + QT_RETHROW; + } + + } else if (QTypeInfo<T>::isComplex) { + QT_TRY { + while(current != to) { + new (current) T(*reinterpret_cast<T*>(src)); + ++current; + ++src; + } + } QT_CATCH(...) { + while (current-- != from) + (reinterpret_cast<T*>(current))->~T(); + QT_RETHROW; + } + } else { + if (src != from && to - from > 0) + memcpy(from, src, (to - from) * sizeof(Node *)); + } +} + +template <typename T> +Q_INLINE_TEMPLATE void QList<T>::node_destruct(Node *from, Node *to) +{ + if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) + while(from != to) --to, delete reinterpret_cast<T*>(to->v); + else if (QTypeInfo<T>::isComplex) + while (from != to) --to, reinterpret_cast<T*>(to)->~T(); +} + +template <typename T> +Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l) +{ + if (d != l.d) { + l.d->ref.ref(); + if (!d->ref.deref()) + free(d); + d = l.d; + if (!d->sharable) + detach_helper(); + } + return *this; +} +template <typename T> +inline typename QList<T>::iterator QList<T>::insert(iterator before, const T &t) +{ + int iBefore = int(before.i - reinterpret_cast<Node *>(p.begin())); + Node *n = reinterpret_cast<Node *>(p.insert(iBefore)); + QT_TRY { + node_construct(n, t); + } QT_CATCH(...) { + p.remove(iBefore); + QT_RETHROW; + } + return n; +} +template <typename T> +inline typename QList<T>::iterator QList<T>::erase(iterator it) +{ node_destruct(it.i); + return reinterpret_cast<Node *>(p.erase(reinterpret_cast<void**>(it.i))); } +template <typename T> +inline const T &QList<T>::at(int i) const +{ Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::at", "index out of range"); + return reinterpret_cast<Node *>(p.at(i))->t(); } +template <typename T> +inline const T &QList<T>::operator[](int i) const +{ Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::operator[]", "index out of range"); + return reinterpret_cast<Node *>(p.at(i))->t(); } +template <typename T> +inline T &QList<T>::operator[](int i) +{ Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::operator[]", "index out of range"); + detach(); return reinterpret_cast<Node *>(p.at(i))->t(); } +template <typename T> +inline void QList<T>::removeAt(int i) +{ if(i >= 0 && i < p.size()) { detach(); + node_destruct(reinterpret_cast<Node *>(p.at(i))); p.remove(i); } } +template <typename T> +inline T QList<T>::takeAt(int i) +{ Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::take", "index out of range"); + detach(); Node *n = reinterpret_cast<Node *>(p.at(i)); T t = n->t(); node_destruct(n); + p.remove(i); return t; } +template <typename T> +inline T QList<T>::takeFirst() +{ T t = first(); removeFirst(); return t; } +template <typename T> +inline T QList<T>::takeLast() +{ T t = last(); removeLast(); return t; } + +template <typename T> +Q_OUTOFLINE_TEMPLATE void QList<T>::append(const T &t) +{ + detach(); + if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) { + Node *n = reinterpret_cast<Node *>(p.append()); + QT_TRY { + node_construct(n, t); + } QT_CATCH(...) { + --d->end; + QT_RETHROW; + } + } else { + const T cpy(t); + Node *n = reinterpret_cast<Node *>(p.append()); + QT_TRY { + node_construct(n, cpy); + } QT_CATCH(...) { + --d->end; + QT_RETHROW; + } + } +} + +template <typename T> +inline void QList<T>::prepend(const T &t) +{ + detach(); + if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) { + Node *n = reinterpret_cast<Node *>(p.prepend()); + QT_TRY { + node_construct(n, t); + } QT_CATCH(...) { + ++d->begin; + QT_RETHROW; + } + } else { + const T cpy(t); + Node *n = reinterpret_cast<Node *>(p.prepend()); + QT_TRY { + node_construct(n, cpy); + } QT_CATCH(...) { + ++d->begin; + QT_RETHROW; + } + } +} + +template <typename T> +inline void QList<T>::insert(int i, const T &t) +{ + detach(); + if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) { + Node *n = reinterpret_cast<Node *>(p.insert(i)); + QT_TRY { + node_construct(n, t); + } QT_CATCH(...) { + p.remove(i); + QT_RETHROW; + } + } else { + const T cpy(t); + Node *n = reinterpret_cast<Node *>(p.insert(i)); + QT_TRY { + node_construct(n, cpy); + } QT_CATCH(...) { + p.remove(i); + QT_RETHROW; + } + } +} + +template <typename T> +inline void QList<T>::replace(int i, const T &t) +{ + Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::replace", "index out of range"); + detach(); + if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) { + reinterpret_cast<Node *>(p.at(i))->t() = t; + } else { + const T cpy(t); + reinterpret_cast<Node *>(p.at(i))->t() = cpy; + } +} + +template <typename T> +inline void QList<T>::swap(int i, int j) +{ + Q_ASSERT_X(i >= 0 && i < p.size() && j >= 0 && j < p.size(), + "QList<T>::swap", "index out of range"); + detach(); + void *t = d->array[d->begin + i]; + d->array[d->begin + i] = d->array[d->begin + j]; + d->array[d->begin + j] = t; +} + +template <typename T> +inline void QList<T>::move(int from, int to) +{ + Q_ASSERT_X(from >= 0 && from < p.size() && to >= 0 && to < p.size(), + "QList<T>::move", "index out of range"); + detach(); + p.move(from, to); +} + +template<typename T> +Q_OUTOFLINE_TEMPLATE QList<T> QList<T>::mid(int pos, int alength) const +{ + if (alength < 0) + alength = size() - pos; + if (pos == 0 && alength == size()) + return *this; + QList<T> cpy; + if (pos + alength > size()) + alength = size() - pos; + for (int i = pos; i < pos + alength; ++i) + cpy += at(i); + return cpy; +} + +template<typename T> +Q_OUTOFLINE_TEMPLATE T QList<T>::value(int i) const +{ + if (i < 0 || i >= p.size()) { + return T(); + } + return reinterpret_cast<Node *>(p.at(i))->t(); +} + +template<typename T> +Q_OUTOFLINE_TEMPLATE T QList<T>::value(int i, const T& defaultValue) const +{ + return ((i < 0 || i >= p.size()) ? defaultValue : reinterpret_cast<Node *>(p.at(i))->t()); +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE void QList<T>::detach_helper() +{ + Node *n = reinterpret_cast<Node *>(p.begin()); + QListData::Data *x = p.detach3(); + QT_TRY { + node_copy(reinterpret_cast<Node *>(p.begin()), reinterpret_cast<Node *>(p.end()), n); + } QT_CATCH(...) { + qFree(d); + d = x; + QT_RETHROW; + } + + if (!x->ref.deref()) + free(x); +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE QList<T>::~QList() +{ + if (d && !d->ref.deref()) + free(d); +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE bool QList<T>::operator==(const QList<T> &l) const +{ + if (p.size() != l.p.size()) + return false; + if (d == l.d) + return true; + Node *i = reinterpret_cast<Node *>(p.end()); + Node *b = reinterpret_cast<Node *>(p.begin()); + Node *li = reinterpret_cast<Node *>(l.p.end()); + while (i != b) { + --i; --li; + if (!(i->t() == li->t())) + return false; + } + return true; +} + +// ### Qt 5: rename freeData() to avoid confusion with std::free() +template <typename T> +Q_OUTOFLINE_TEMPLATE void QList<T>::free(QListData::Data *data) +{ + node_destruct(reinterpret_cast<Node *>(data->array + data->begin), + reinterpret_cast<Node *>(data->array + data->end)); + if (data->ref == 0) + qFree(data); +} + + +template <typename T> +Q_OUTOFLINE_TEMPLATE void QList<T>::clear() +{ + *this = QList<T>(); +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE int QList<T>::removeAll(const T &_t) +{ + detachShared(); + const T t = _t; + int removedCount=0, i=0; + Node *n; + while (i < p.size()) + if ((n = reinterpret_cast<Node *>(p.at(i)))->t() == t) { + node_destruct(n); + p.remove(i); + ++removedCount; + } else { + ++i; + } + return removedCount; +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE bool QList<T>::removeOne(const T &_t) +{ + detachShared(); + int index = indexOf(_t); + if (index != -1) { + removeAt(index); + return true; + } + return false; +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE typename QList<T>::iterator QList<T>::erase(typename QList<T>::iterator afirst, + typename QList<T>::iterator alast) +{ + for (Node *n = afirst.i; n < alast.i; ++n) + node_destruct(n); + int idx = afirst - begin(); + p.remove(idx, alast - afirst); + return begin() + idx; +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE QList<T> &QList<T>::operator+=(const QList<T> &l) +{ + detach(); + Node *n = reinterpret_cast<Node *>(p.append2(l.p)); + QT_TRY{ + node_copy(n, reinterpret_cast<Node *>(p.end()), reinterpret_cast<Node *>(l.p.begin())); + } QT_CATCH(...) { + // restore the old end + d->end -= int(reinterpret_cast<Node *>(p.end()) - n); + QT_RETHROW; + } + return *this; +} + +template <typename T> +inline void QList<T>::append(const QList<T> &t) +{ + *this += t; +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE int QList<T>::indexOf(const T &t, int from) const +{ + if (from < 0) + from = qMax(from + p.size(), 0); + if (from < p.size()) { + Node *n = reinterpret_cast<Node *>(p.at(from -1)); + Node *e = reinterpret_cast<Node *>(p.end()); + while (++n != e) + if (n->t() == t) + return int(n - reinterpret_cast<Node *>(p.begin())); + } + return -1; +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE int QList<T>::lastIndexOf(const T &t, int from) const +{ + if (from < 0) + from += p.size(); + else if (from >= p.size()) + from = p.size()-1; + if (from >= 0) { + Node *b = reinterpret_cast<Node *>(p.begin()); + Node *n = reinterpret_cast<Node *>(p.at(from + 1)); + while (n-- != b) { + if (n->t() == t) + return n - b; + } + } + return -1; +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE QBool QList<T>::contains(const T &t) const +{ + Node *b = reinterpret_cast<Node *>(p.begin()); + Node *i = reinterpret_cast<Node *>(p.end()); + while (i-- != b) + if (i->t() == t) + return QBool(true); + return QBool(false); +} + +template <typename T> +Q_OUTOFLINE_TEMPLATE int QList<T>::count(const T &t) const +{ + int c = 0; + Node *b = reinterpret_cast<Node *>(p.begin()); + Node *i = reinterpret_cast<Node *>(p.end()); + while (i-- != b) + if (i->t() == t) + ++c; + return c; +} + +Q_DECLARE_SEQUENTIAL_ITERATOR(List) +Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QLIST_H diff --git a/qtinterface/tqt4/Qt/qobject.h b/qtinterface/tqt4/Qt/qobject.h new file mode 100644 index 0000000..558c368 --- /dev/null +++ b/qtinterface/tqt4/Qt/qobject.h @@ -0,0 +1,499 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOBJECT_H +#define QOBJECT_H + +#ifndef QT_NO_QOBJECT + +#include <QtCore/qobjectdefs.h> +#include <QtCore/qstring.h> +#include <QtCore/qbytearray.h> +#include <QtCore/qlist.h> +#ifdef QT_INCLUDE_COMPAT +#include <QtCore/qcoreevent.h> +#endif +#include <QtCore/qscopedpointer.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +class QEvent; +class QTimerEvent; +class QChildEvent; +struct QMetaObject; +class QVariant; +class QObjectPrivate; +class QObject; +class QThread; +class QWidget; +#ifndef QT_NO_REGEXP +class QRegExp; +#endif +#ifndef QT_NO_USERDATA +class QObjectUserData; +#endif + +typedef QList<QObject*> QObjectList; + +#if defined Q_CC_MSVC && _MSC_VER < 1300 +template<typename T> inline T qFindChild(const QObject *o, const QString &name = QString(), T = 0); +template<typename T> inline QList<T> qFindChildren(const QObject *o, const QString &name = QString(), T = 0); +# ifndef QT_NO_REGEXP +template<typename T> inline QList<T> qFindChildren(const QObject *o, const QRegExp &re, T = 0); +# endif +#else +template<typename T> inline T qFindChild(const QObject *, const QString & = QString()); +template<typename T> inline QList<T> qFindChildren(const QObject *, const QString & = QString()); +# ifndef QT_NO_REGEXP +template<typename T> inline QList<T> qFindChildren(const QObject *, const QRegExp &); +# endif +#endif + +class +#if defined(__INTEL_COMPILER) && defined(Q_OS_WIN) +Q_CORE_EXPORT +#endif +QObjectData { +public: + virtual ~QObjectData() = 0; + QObject *q_ptr; + QObject *parent; + QObjectList children; + + uint isWidget : 1; + uint pendTimer : 1; + uint blockSig : 1; + uint wasDeleted : 1; + uint ownObjectName : 1; + uint sendChildEvents : 1; + uint receiveChildEvents : 1; + uint inEventHandler : 1; + uint inThreadChangeEvent : 1; + uint hasGuards : 1; //true iff there is one or more QPointer attached to this object + uint unused : 22; + int postedEvents; + QMetaObject *metaObject; // assert dynamic +}; + + +class Q_CORE_EXPORT QObject +{ + Q_OBJECT + Q_PROPERTY(QString objectName READ objectName WRITE setObjectName) + Q_DECLARE_PRIVATE(QObject) + +public: + Q_INVOKABLE explicit QObject(QObject *parent=0); + virtual ~QObject(); + + virtual bool event(QEvent *); + virtual bool eventFilter(QObject *, QEvent *); + +#ifdef qdoc + static QString tr(const char *sourceText, const char *comment = 0, int n = -1); + static QString trUtf8(const char *sourceText, const char *comment = 0, int n = -1); + virtual const QMetaObject *metaObject() const; + static const QMetaObject staticMetaObject; +#endif +#ifdef QT_NO_TRANSLATION + static QString tr(const char *sourceText, const char *, int) + { return QString::fromLatin1(sourceText); } + static QString tr(const char *sourceText, const char * = 0) + { return QString::fromLatin1(sourceText); } +#ifndef QT_NO_TEXTCODEC + static QString trUtf8(const char *sourceText, const char *, int) + { return QString::fromUtf8(sourceText); } + static QString trUtf8(const char *sourceText, const char * = 0) + { return QString::fromUtf8(sourceText); } +#endif +#endif //QT_NO_TRANSLATION + + QString objectName() const; + void setObjectName(const QString &name); + + inline bool isWidgetType() const { return d_ptr->isWidget; } + + inline bool signalsBlocked() const { return d_ptr->blockSig; } + bool blockSignals(bool b); + + QThread *thread() const; + void moveToThread(QThread *thread); + + int startTimer(int interval); + void killTimer(int id); + +#ifndef QT_NO_MEMBER_TEMPLATES + template<typename T> + inline T findChild(const QString &aName = QString()) const + { return qFindChild<T>(this, aName); } + + template<typename T> + inline QList<T> findChildren(const QString &aName = QString()) const + { return qFindChildren<T>(this, aName); } + +#ifndef QT_NO_REGEXP + template<typename T> + inline QList<T> findChildren(const QRegExp &re) const + { return qFindChildren<T>(this, re); } +#endif +#endif + +#ifdef QT3_SUPPORT + QT3_SUPPORT QObject *child(const char *objName, const char *inheritsClass = 0, + bool recursiveSearch = true) const; + QT3_SUPPORT QObjectList queryList(const char *inheritsClass = 0, + const char *objName = 0, + bool regexpMatch = true, + bool recursiveSearch = true) const; +#endif + inline const QObjectList &children() const { return d_ptr->children; } + const QObjectList *ptrchildren() const; + static const QObjectList *objectTrees(); + + void setParent(QObject *); + void installEventFilter(QObject *); + void removeEventFilter(QObject *); + + + static bool connect(const QObject *sender, const char *signal, + const QObject *receiver, const char *member, Qt::ConnectionType = +#ifdef qdoc + Qt::AutoConnection +#else +#ifdef QT3_SUPPORT + Qt::AutoCompatConnection +#else + Qt::AutoConnection +#endif +#endif + ); + inline bool connect(const QObject *sender, const char *signal, + const char *member, Qt::ConnectionType type = +#ifdef qdoc + Qt::AutoConnection +#else +#ifdef QT3_SUPPORT + Qt::AutoCompatConnection +#else + Qt::AutoConnection +#endif +#endif + ) const; + + static bool disconnect(const QObject *sender, const char *signal, + const QObject *receiver, const char *member); + inline bool disconnect(const char *signal = 0, + const QObject *receiver = 0, const char *member = 0) + { return disconnect(this, signal, receiver, member); } + inline bool disconnect(const QObject *receiver, const char *member = 0) + { return disconnect(this, 0, receiver, member); } + + void dumpObjectTree(); + void dumpObjectInfo(); + +#ifndef QT_NO_PROPERTIES + bool setProperty(const char *name, const QVariant &value); + QVariant property(const char *name) const; + QList<QByteArray> dynamicPropertyNames() const; +#endif // QT_NO_PROPERTIES + +#ifndef QT_NO_USERDATA + static uint registerUserData(); + void setUserData(uint id, QObjectUserData* data); + QObjectUserData* userData(uint id) const; +#endif // QT_NO_USERDATA + +Q_SIGNALS: + void destroyed(QObject * = 0); + +public: + inline QObject *parent() const { return d_ptr->parent; } + + inline bool inherits(const char *classname) const + { return const_cast<QObject *>(this)->qt_metacast(classname) != 0; } + +public Q_SLOTS: + void deleteLater(); + +protected: + QObject *sender() const; + int receivers(const char* signal) const; + + virtual void timerEvent(QTimerEvent *); + virtual void childEvent(QChildEvent *); + virtual void customEvent(QEvent *); + + virtual void connectNotify(const char *signal); + virtual void disconnectNotify(const char *signal); + +#ifdef QT3_SUPPORT +public: + QT3_SUPPORT_CONSTRUCTOR QObject(QObject *parent, const char *name); + inline QT3_SUPPORT void insertChild(QObject *o) + { if (o) o->setParent(this); } + inline QT3_SUPPORT void removeChild(QObject *o) + { if (o) o->setParent(0); } + inline QT3_SUPPORT bool isA(const char *classname) const + { return qstrcmp(classname, metaObject()->className()) == 0; } + inline QT3_SUPPORT const char *className() const { return metaObject()->className(); } + inline QT3_SUPPORT const char *name() const { return objectName().latin1_helper(); } + inline QT3_SUPPORT const char *name(const char *defaultName) const + { QString s = objectName(); return s.isEmpty()?defaultName:s.latin1_helper(); } + inline QT3_SUPPORT void setName(const char *aName) { setObjectName(QLatin1String(aName)); } +protected: + inline QT3_SUPPORT bool checkConnectArgs(const char *signal, + const QObject *, + const char *member) + { return QMetaObject::checkConnectArgs(signal, member); } + static inline QT3_SUPPORT QByteArray normalizeSignalSlot(const char *signalSlot) + { return QMetaObject::normalizedSignature(signalSlot); } +#endif + +protected: + QObject(QObjectPrivate &dd, QObject *parent = 0); + +protected: + QScopedPointer<QObjectData> d_ptr; + + static const QMetaObject staticQtMetaObject; + + friend struct QMetaObject; + friend class QApplication; + friend class QApplicationPrivate; + friend class QCoreApplication; + friend class QCoreApplicationPrivate; + friend class QWidget; + friend class QThreadData; + +private: + Q_DISABLE_COPY(QObject) + Q_PRIVATE_SLOT(d_func(), void _q_reregisterTimers(void *)) +}; + +inline bool QObject::connect(const QObject *asender, const char *asignal, + const char *amember, Qt::ConnectionType atype) const +{ return connect(asender, asignal, this, amember, atype); } + +#ifndef QT_NO_USERDATA +class Q_CORE_EXPORT QObjectUserData { +public: + virtual ~QObjectUserData(); +}; +#endif + +Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re, + const QMetaObject &mo, QList<void *> *list); +Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo); + +#if defined Q_CC_MSVC && _MSC_VER < 1300 + +template<typename T> +inline T qFindChild(const QObject *o, const QString &name, T) +{ return static_cast<T>(qt_qFindChild_helper(o, name, ((T)0)->staticMetaObject)); } + +template<typename T> +inline QList<T> qFindChildren(const QObject *o, const QString &name, T) +{ + QList<T> list; + union { + QList<T> *typedList; + QList<void *> *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(o, name, 0, ((T)0)->staticMetaObject, u.voidList); + return list; +} + +template<typename T> +inline T qFindChild(const QObject *o, const QString &name) +{ return qFindChild<T>(o, name, T(0)); } + +template<typename T> +inline T qFindChild(const QObject *o) +{ return qFindChild<T>(o, QString(), T(0)); } + +template<typename T> +inline QList<T> qFindChildren(const QObject *o, const QString &name) +{ return qFindChildren<T>(o, name, T(0)); } + +template<typename T> +inline QList<T> qFindChildren(const QObject *o) +{ return qFindChildren<T>(o, QString(), T(0)); } + +#ifndef QT_NO_REGEXP +template<typename T> +inline QList<T> qFindChildren(const QObject *o, const QRegExp &re, T) +{ + QList<T> list; + union { + QList<T> *typedList; + QList<void *> *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(o, 0, &re, ((T)0)->staticMetaObject, u.voidList); + return list; +} + +template<typename T> +inline QList<T> qFindChildren(const QObject *o, const QRegExp &re) +{ return qFindChildren<T>(o, re, T(0)); } + +#endif + +#ifdef Q_MOC_RUN +# define Q_DECLARE_INTERFACE(IFace, IId) Q_DECLARE_INTERFACE(IFace, IId) +#endif // Q_MOC_RUN + + +template <class T> inline const char * qobject_interface_iid() +{ return 0; } + +template <class T> inline T qobject_cast_helper(QObject *object, T) +{ return static_cast<T>(((T)0)->staticMetaObject.cast(object)); } + +template <class T> inline T qobject_cast_helper(const QObject *object, T) +{ return static_cast<T>(const_cast<const QObject *>(((T)0)->staticMetaObject.cast(const_cast<QObject *>(object)))); } + +template <class T> +inline T qobject_cast(QObject *object) +{ return qobject_cast_helper<T>(object, T(0)); } + +template <class T> +inline T qobject_cast(const QObject *object) +{ return qobject_cast_helper<T>(object, T(0)); } + +#ifndef Q_MOC_RUN +# define Q_DECLARE_INTERFACE(IFace, IId) \ + template <> inline const char *qobject_interface_iid<IFace *>() \ + { return IId; } \ + template <> inline IFace *qobject_cast_helper<IFace *>(QObject *object, IFace *) \ + { return (IFace *)(object ? object->qt_metacast(IId) : 0); } \ + template <> inline IFace *qobject_cast_helper<IFace *>(const QObject *object, IFace *) \ + { return (IFace *)(object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0); } +#endif // Q_MOC_RUN + +#else + +template<typename T> +inline T qFindChild(const QObject *o, const QString &name) +{ return static_cast<T>(qt_qFindChild_helper(o, name, reinterpret_cast<T>(0)->staticMetaObject)); } + +template<typename T> +inline QList<T> qFindChildren(const QObject *o, const QString &name) +{ + QList<T> list; + union { + QList<T> *typedList; + QList<void *> *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(o, name, 0, reinterpret_cast<T>(0)->staticMetaObject, u.voidList); + return list; +} + +#ifndef QT_NO_REGEXP +template<typename T> +inline QList<T> qFindChildren(const QObject *o, const QRegExp &re) +{ + QList<T> list; + union { + QList<T> *typedList; + QList<void *> *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(o, QString(), &re, reinterpret_cast<T>(0)->staticMetaObject, u.voidList); + return list; +} +#endif + +template <class T> +inline T qobject_cast(QObject *object) +{ +#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) + reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object)); +#endif + return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object)); +} + +template <class T> +inline T qobject_cast(const QObject *object) +{ + // this will cause a compilation error if T is not const + register T ptr = static_cast<T>(object); + Q_UNUSED(ptr); + +#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) + reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object))); +#endif + return static_cast<T>(const_cast<QObject *>(reinterpret_cast<T>(0)->staticMetaObject.cast(const_cast<QObject *>(object)))); +} + + +template <class T> inline const char * qobject_interface_iid() +{ return 0; } + +#ifndef Q_MOC_RUN +# define Q_DECLARE_INTERFACE(IFace, IId) \ + template <> inline const char *qobject_interface_iid<IFace *>() \ + { return IId; } \ + template <> inline IFace *qobject_cast<IFace *>(QObject *object) \ + { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : 0)); } \ + template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \ + { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0)); } +#endif // Q_MOC_RUN + +#endif + +#ifndef QT_NO_DEBUG_STREAM +Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *); +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif + +#endif // QOBJECT_H diff --git a/qtinterface/tqt4/Qt/qobjectdefs.h b/qtinterface/tqt4/Qt/qobjectdefs.h new file mode 100644 index 0000000..32f9b80 --- /dev/null +++ b/qtinterface/tqt4/Qt/qobjectdefs.h @@ -0,0 +1,492 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOBJECTDEFS_H +#define QOBJECTDEFS_H + +#include <QtCore/qnamespace.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +class QByteArray; + +class QString; +class QStringList; + +#ifndef Q_MOC_OUTPUT_REVISION +#define Q_MOC_OUTPUT_REVISION 62 +#endif + +// The following macros are our "extensions" to C++ +// They are used, strictly speaking, only by the moc. + +#ifndef Q_MOC_RUN +# if defined(QT_NO_KEYWORDS) +# define QT_NO_EMIT +# else +# define slots +# define signals protected +# endif +# define Q_SLOTS +# define Q_SIGNALS protected +# define Q_PRIVATE_SLOT(d, signature) +# define Q_EMIT +#ifndef QT_NO_EMIT +# define emit +#endif +#define Q_CLASSINFO(name, value) +#define Q_INTERFACES(x) +#define Q_PROPERTY(text) +#define Q_OVERRIDE(text) +#define Q_ENUMS(x) +#define Q_FLAGS(x) +#ifdef QT3_SUPPORT +# define Q_SETS(x) +#endif +#define Q_SCRIPTABLE +#define Q_INVOKABLE +#define Q_SIGNAL +#define Q_SLOT + +#ifndef QT_NO_TRANSLATION +# ifndef QT_NO_TEXTCODEC +// full set of tr functions +// ### Qt 5: merge overloads +# define QT_TR_FUNCTIONS \ + static inline QString tr(const char *s, const char *c = 0) \ + { return staticMetaObject.tr(s, c); } \ + static inline QString trUtf8(const char *s, const char *c = 0) \ + { return staticMetaObject.trUtf8(s, c); } \ + static inline QString tr(const char *s, const char *c, int n) \ + { return staticMetaObject.tr(s, c, n); } \ + static inline QString trUtf8(const char *s, const char *c, int n) \ + { return staticMetaObject.trUtf8(s, c, n); } +# else +// no QTextCodec, no utf8 +// ### Qt 5: merge overloads +# define QT_TR_FUNCTIONS \ + static inline QString tr(const char *s, const char *c = 0) \ + { return staticMetaObject.tr(s, c); } \ + static inline QString tr(const char *s, const char *c, int n) \ + { return staticMetaObject.tr(s, c, n); } +# endif +#else +// inherit the ones from QObject +# define QT_TR_FUNCTIONS +#endif + +#if defined(QT_NO_MEMBER_TEMPLATES) || defined(QT_NO_QOBJECT_CHECK) +/* tmake ignore Q_OBJECT */ +#define Q_OBJECT_CHECK +#else + +/* This is a compile time check that ensures that any class cast with qobject_cast + actually contains a Q_OBJECT macro. Note: qobject_cast will fail if a QObject + subclass doesn't contain Q_OBJECT. + + In qt_check_for_QOBJECT_macro, we call a dummy templated function with two + parameters, the first being "this" and the other the target of the qobject + cast. If the types are not identical, we know that a Q_OBJECT macro is missing. + + If you get a compiler error here, make sure that the class you are casting + to contains a Q_OBJECT macro. +*/ + +/* tmake ignore Q_OBJECT */ +#define Q_OBJECT_CHECK \ + template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const \ + { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i; } + +template <typename T> +inline int qYouForgotTheQ_OBJECT_Macro(T, T) { return 0; } + +template <typename T1, typename T2> +inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {} +#endif // QT_NO_MEMBER_TEMPLATES + +#ifdef Q_NO_DATA_RELOCATION +#define Q_OBJECT_GETSTATICMETAOBJECT static const QMetaObject &getStaticMetaObject(); +#else +#define Q_OBJECT_GETSTATICMETAOBJECT +#endif + +/* tmake ignore Q_OBJECT */ +#define Q_OBJECT \ +public: \ + Q_OBJECT_CHECK \ + static const QMetaObject staticMetaObject; \ + Q_OBJECT_GETSTATICMETAOBJECT \ + virtual const QMetaObject *metaObject() const; \ + virtual void *qt_metacast(const char *); \ + QT_TR_FUNCTIONS \ + virtual int qt_metacall(QMetaObject::Call, int, void **); \ +private: +/* tmake ignore Q_OBJECT */ +#define Q_OBJECT_FAKE Q_OBJECT +/* tmake ignore Q_GADGET */ +#define Q_GADGET \ +public: \ + static const QMetaObject staticMetaObject; \ + Q_OBJECT_GETSTATICMETAOBJECT \ +private: +#else // Q_MOC_RUN +#define slots slots +#define signals signals +#define Q_SLOTS Q_SLOTS +#define Q_SIGNALS Q_SIGNALS +#define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value) +#define Q_INTERFACES(x) Q_INTERFACES(x) +#define Q_PROPERTY(text) Q_PROPERTY(text) +#define Q_OVERRIDE(text) Q_OVERRIDE(text) +#define Q_ENUMS(x) Q_ENUMS(x) +#define Q_FLAGS(x) Q_FLAGS(x) +#ifdef QT3_SUPPORT +# define Q_SETS(x) Q_SETS(x) +#endif + /* tmake ignore Q_OBJECT */ +#define Q_OBJECT Q_OBJECT + /* tmake ignore Q_OBJECT */ +#define Q_OBJECT_FAKE Q_OBJECT_FAKE + /* tmake ignore Q_GADGET */ +#define Q_GADGET Q_GADGET +#define Q_SCRIPTABLE Q_SCRIPTABLE +#define Q_INVOKABLE Q_INVOKABLE +#define Q_SIGNAL Q_SIGNAL +#define Q_SLOT Q_SLOT +#endif //Q_MOC_RUN + +// macro for onaming members +#ifdef METHOD +#undef METHOD +#endif +#ifdef SLOT +#undef SLOT +#endif +#ifdef SIGNAL +#undef SIGNAL +#endif + +Q_CORE_EXPORT const char *qFlagLocation(const char *method); + +#define QTOSTRING_HELPER(s) #s +#define QTOSTRING(s) QTOSTRING_HELPER(s) +#ifndef QT_NO_DEBUG +# define QLOCATION "\0"__FILE__":"QTOSTRING(__LINE__) +# define METHOD(a) qFlagLocation("0"#a QLOCATION) +# define SLOT(a) qFlagLocation("1"#a QLOCATION) +# define SIGNAL(a) qFlagLocation("2"#a QLOCATION) +#else +# define METHOD(a) "0"#a +# define SLOT(a) "1"#a +# define SIGNAL(a) "2"#a +#endif + +#ifdef QT3_SUPPORT +#define METHOD_CODE 0 // member type codes +#define SLOT_CODE 1 +#define SIGNAL_CODE 2 +#endif + +#define QMETHOD_CODE 0 // member type codes +#define QSLOT_CODE 1 +#define QSIGNAL_CODE 2 + +#define Q_ARG(type, data) QArgument<type >(#type, data) +#define Q_RETURN_ARG(type, data) QReturnArgument<type >(#type, data) + +class QObject; +class QMetaMethod; +class QMetaEnum; +class QMetaProperty; +class QMetaClassInfo; + + +class Q_CORE_EXPORT QGenericArgument +{ +public: + inline QGenericArgument(const char *aName = 0, const void *aData = 0) + : _data(aData), _name(aName) {} + inline void *data() const { return const_cast<void *>(_data); } + inline const char *name() const { return _name; } + +private: + const void *_data; + const char *_name; +}; + +class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument +{ +public: + inline QGenericReturnArgument(const char *aName = 0, void *aData = 0) + : QGenericArgument(aName, aData) + {} +}; + +template <class T> +class QArgument: public QGenericArgument +{ +public: + inline QArgument(const char *aName, const T &aData) + : QGenericArgument(aName, static_cast<const void *>(&aData)) + {} +}; + + +template <typename T> +class QReturnArgument: public QGenericReturnArgument +{ +public: + inline QReturnArgument(const char *aName, T &aData) + : QGenericReturnArgument(aName, static_cast<void *>(&aData)) + {} +}; + +struct Q_CORE_EXPORT QMetaObject +{ + const char *className() const; + const QMetaObject *superClass() const; + + QObject *cast(QObject *obj) const; + +#ifndef QT_NO_TRANSLATION + // ### Qt 4: Merge overloads + QString tr(const char *s, const char *c) const; + QString trUtf8(const char *s, const char *c) const; + QString tr(const char *s, const char *c, int n) const; + QString trUtf8(const char *s, const char *c, int n) const; +#endif // QT_NO_TRANSLATION + + int methodOffset() const; + int enumeratorOffset() const; + int propertyOffset() const; + int classInfoOffset() const; + + int constructorCount() const; + int methodCount() const; + int enumeratorCount() const; + int propertyCount() const; + int classInfoCount() const; + + int indexOfConstructor(const char *constructor) const; + int indexOfMethod(const char *method) const; + int indexOfSignal(const char *signal) const; + int indexOfSlot(const char *slot) const; + int indexOfEnumerator(const char *name) const; + int indexOfProperty(const char *name) const; + int indexOfClassInfo(const char *name) const; + + QMetaMethod constructor(int index) const; + QMetaMethod method(int index) const; + QMetaEnum enumerator(int index) const; + QMetaProperty property(int index) const; + QMetaClassInfo classInfo(int index) const; + QMetaProperty userProperty() const; + + static bool checkConnectArgs(const char *signal, const char *method); + static QByteArray normalizedSignature(const char *method); + static QByteArray normalizedType(const char *type); + + // internal index-based connect + static bool connect(const QObject *sender, int signal_index, + const QObject *receiver, int method_index, + int type = 0, int *types = 0); + // internal index-based disconnect + static bool disconnect(const QObject *sender, int signal_index, + const QObject *receiver, int method_index); + static bool disconnectOne(const QObject *sender, int signal_index, + const QObject *receiver, int method_index); + // internal slot-name based connect + static void connectSlotsByName(QObject *o); + + // internal index-based signal activation + static void activate(QObject *sender, int signal_index, void **argv); //obsolete + static void activate(QObject *sender, int from_signal_index, int to_signal_index, void **argv); //obsolete + static void activate(QObject *sender, const QMetaObject *, int local_signal_index, void **argv); + static void activate(QObject *sender, const QMetaObject *, int from_local_signal_index, int to_local_signal_index, void **argv); //obsolete + + // internal guarded pointers + static void addGuard(QObject **ptr); + static void removeGuard(QObject **ptr); + static void changeGuard(QObject **ptr, QObject *o); + + static bool invokeMethod(QObject *obj, const char *member, + Qt::ConnectionType, + QGenericReturnArgument ret, + QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()); + + static inline bool invokeMethod(QObject *obj, const char *member, + QGenericReturnArgument ret, + QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()) + { + return invokeMethod(obj, member, Qt::AutoConnection, ret, val0, val1, val2, val3, + val4, val5, val6, val7, val8, val9); + } + + static inline bool invokeMethod(QObject *obj, const char *member, + Qt::ConnectionType type, + QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()) + { + return invokeMethod(obj, member, type, QGenericReturnArgument(), val0, val1, val2, + val3, val4, val5, val6, val7, val8, val9); + } + + static inline bool invokeMethod(QObject *obj, const char *member, + QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()) + { + return invokeMethod(obj, member, Qt::AutoConnection, QGenericReturnArgument(), val0, + val1, val2, val3, val4, val5, val6, val7, val8, val9); + } + + QObject *newInstance(QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()) const; + + enum Call { + InvokeMetaMethod, + ReadProperty, + WriteProperty, + ResetProperty, + QueryPropertyDesignable, + QueryPropertyScriptable, + QueryPropertyStored, + QueryPropertyEditable, + QueryPropertyUser, + CreateInstance + }; + + int static_metacall(Call, int, void **) const; + static int metacall(QObject *, Call, int, void **); + +#ifdef QT3_SUPPORT + QT3_SUPPORT const char *superClassName() const; +#endif + + int numSlots( bool super = FALSE ) const; + int numSignals( bool super = FALSE ) const; + const QMetaMethod *slot( int index, bool super = FALSE ) const; + const QMetaMethod *signal( int index, bool super = FALSE ) const; + QStringList slotNames( bool super = FALSE ) const; + QStringList signalNames( bool super = FALSE ) const; + + struct { // private data + const QMetaObject *superdata; + const char *stringdata; + const uint *data; + const void *extradata; + } d; + +}; + +typedef const QMetaObject& (*QMetaObjectAccessor)(); + +struct QMetaObjectExtraData +{ +#ifdef Q_NO_DATA_RELOCATION + const QMetaObjectAccessor *objects; +#else + const QMetaObject **objects; +#endif + int (*static_metacall)(QMetaObject::Call, int, void **); +}; + +inline const char *QMetaObject::className() const +{ return d.stringdata; } + +inline const QMetaObject *QMetaObject::superClass() const +{ return d.superdata; } + +#ifdef QT3_SUPPORT +inline const char *QMetaObject::superClassName() const +{ return d.superdata ? d.superdata->className() : 0; } +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QOBJECTDEFS_H |