Yet more Qt4 API extensions...

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/dependencies/tqtinterface@1160323 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 14 years ago
parent 0630a9067e
commit 77ead0ba5f

@ -858,6 +858,10 @@ find ./ -type f -iname "*.c*" -exec sed -i 's/QToolTipGroup\([ :<>"()*&.,^;]\)/T
find ./ -type f -iname "*.h*" -exec sed -i 's/QToolTipGroup\([ :<>"()*&.,^;]\)/TQToolTipGroup\1/g' {} \;
find ./ -type f -iname "*.c*" -exec sed -i 's/QToolTip\([ :<>"()*&.,^;]\)/TQToolTip\1/g' {} \;
find ./ -type f -iname "*.h*" -exec sed -i 's/QToolTip\([ :<>"()*&.,^;]\)/TQToolTip\1/g' {} \;
find ./ -type f -iname "*.c*" -exec sed -i 's/QTranslator\([ :<>"()*&.,^;]\)/TQTranslator\1/g' {} \;
find ./ -type f -iname "*.h*" -exec sed -i 's/QTranslator\([ :<>"()*&.,^;]\)/TQTranslator\1/g' {} \;
find ./ -type f -iname "*.c*" -exec sed -i 's/QTranslatorMessage\([ :<>"()*&.,^;]\)/TQTranslatorMessage\1/g' {} \;
find ./ -type f -iname "*.h*" -exec sed -i 's/QTranslatorMessage\([ :<>"()*&.,^;]\)/TQTranslatorMessage\1/g' {} \;
find ./ -type f -iname "*.c*" -exec sed -i 's/QTsciiCodec\([ :<>"()*&.,^;]\)/TQTsciiCodec\1/g' {} \;
find ./ -type f -iname "*.h*" -exec sed -i 's/QTsciiCodec\([ :<>"()*&.,^;]\)/TQTsciiCodec\1/g' {} \;
find ./ -type f -iname "*.c*" -exec sed -i 's/QUrl\([ :<>"()*&.,^;]\)/TQUrl\1/g' {} \;

@ -34,4 +34,14 @@ TQEventLoop *QApplication::eventLoop()
return TQEventLoop::eventLoop();
}
void QApplication::installTranslator( QTranslator * mf )
{
#warning "!!! WARNING: QApplication::installTranslator() UNIMPLEMENTED !!!"
}
void QApplication::removeTranslator( QTranslator * mf )
{
#warning "!!! WARNING: QApplication::removeTranslator() UNIMPLEMENTED !!!"
}
#endif // USE_QT4

@ -21,3 +21,20 @@ Boston, MA 02110-1301, USA.
#include <tqt.h>
#include <tqdir.h>
#ifdef USE_QT4
bool QDir::exists( const QString &name, bool acceptAbsPath )
{
if ( name.isEmpty() ) {
#if defined(QT_CHECK_NULL)
qWarning( "QDir::exists: Empty or null file name" );
#endif
return FALSE;
}
// QString tmp = filePath( name, acceptAbsPath );
QString tmp = filePath( name );
return QFile::exists( tmp );
}
#endif // USE_QT4

@ -38,7 +38,7 @@ Boston, MA 02110-1301, USA.
// Reimplement the QDir class
// For Qt4, some changes are needed
#include <Qt/qdir.h>
#include <tqt4/Qt/qdir.h>
#endif // USE_QT4

@ -29,4 +29,54 @@ Q3PopupMenu *QMenuItem::popup() const {
return &Q3PopupMenu(menu());
}
/*!
\overload
Inserts a menu item that consists of the widget \a widget with
optional id \a id, and optional \a index position.
Ownership of \a widget is transferred to the popup menu or to the
menu bar.
Theoretically, any widget can be inserted into a popup menu. In
practice, this only makes sense with certain widgets.
If a widget is not focus-enabled (see
\l{QWidget::isFocusEnabled()}), the menu treats it as a separator;
this means that the item is not selectable and will never get
focus. In this way you can, for example, simply insert a QLabel if
you need a popup menu with a title.
If the widget is focus-enabled it will get focus when the user
traverses the popup menu with the arrow keys. If the widget does
not accept \c ArrowUp and \c ArrowDown in its key event handler,
the focus will move back to the menu when the respective arrow key
is hit one more time. This works with a QLineEdit, for example. If
the widget accepts the arrow key itself, it must also provide the
possibility to put the focus back on the menu again by calling
QWidget::focusNextPrevChild(). Futhermore, if the embedded widget
closes the menu when the user made a selection, this can be done
safely by calling:
\code
if ( isVisible() &&
parentWidget() &&
parentWidget()->inherits("QPopupMenu") )
parentWidget()->close();
\endcode
Returns the allocated menu identifier number (\a id if \a id >= 0).
\sa removeItem()
*/
int QMenu::insertItem( QWidget* widget, int id, int index )
{
#warning "QMenuData::insertItem(QWidget* widget, int id, int index) unimplemented!"
// New method is const QIcon*, const QString*, const QObject*, const char*, const QKeySequence*, const QMenu*, int, int
// Qt4 does not seem to support arbitrary widgets being added to menus (!!!)
// This will need to be reimplemented somehow as it is a very useful feature (e.g. Start menu text filter box)
//return insertAny( 0, 0, 0, 0, id, index, widget );
return insertAny( 0, &QString("UNIMPLEMENTED"), widget, 0, 0, 0, id, index );
}
#endif // USE_QT4

@ -38,7 +38,7 @@ Boston, MA 02110-1301, USA.
// Reimplement the QMenuData class
// For Qt4, some changes are needed
#include <Qt/qmenudata.h>
#include <tqt4/Qt/qmenudata.h>
#endif // USE_QT4

@ -53,6 +53,10 @@ QPixmap::QPixmap( int w, int h, int depth, Optimization optim ) {
QPixmap(w, h);
}
QPixmap::operator QPixmap *() const {
return const_cast<QPixmap *>(this);
}
const QBitmap *QPixmap::ptrmask() const {
QBitmap pm = mask();
QBitmap *pr = &pm;

@ -65,6 +65,14 @@ Boston, MA 02110-1301, USA.
#define TQ_Key_Super_R Key_Super_R
#define TQ_Key_Hyper_L Key_Hyper_L
#define TQ_Key_Hyper_R Key_Hyper_R
#define TQ_ButtonState ButtonState
#define TQ_LeftButton LeftButton
#define TQ_MidButton MidButton
#define TQ_RightButton RightButton
#define TQ_ShiftButton ShiftButton
#define TQ_ControlButton ControlButton
#define TQ_AltButton AltButton
#define TQ_MetaButton MetaButton
#define TQAlignCenter AlignCenter
#define TQNoBrush NoBrush
@ -516,6 +524,8 @@ Boston, MA 02110-1301, USA.
#define TQToolButton QToolButton
#define TQToolTipGroup QToolTipGroup
#define TQToolTip QToolTip
#define TQTranslator QTranslator
#define TQTranslatorMessage QTranslatorMessage
#define TQTsciiCodec QTsciiCodec
#define TQUrl QUrl
#define TQUrlInfo QUrlInfo
@ -595,6 +605,7 @@ class QUObject;
#include <tqt4/Qt/qmetaobject.h>
#include <tqeventloop.h>
#include <tqt4/Qt/qpaintdevice.h>
#include <tqt4/Qt/qvector.h>
#include <tqt4/Qt/qimage.h>
#include <tqt4/Qt/qpixmap.h>
#include <tqt4/Qt/qwidget.h>
@ -608,7 +619,10 @@ class QUObject;
#include <tqt4/Qt/qslider.h>
#include <tqt4/Qt/qscrollbar.h>
#include <tqt4/Qt/qfileinfo.h>
#include <tqt4/Qt/qmenu.h>
#include <tqt4/Qt/qmenudata.h>
#include <tqt4/Qt/qdir.h>
#include <tqt4/Qt/qtooltip.h>
#include <Qt/q3strlist.h>
#include <Qt/qx11info_x11.h>
@ -642,6 +656,14 @@ class QUObject;
#define TQ_Key_Super_R Qt::Key_Super_R
#define TQ_Key_Hyper_L Qt::Key_Hyper_L
#define TQ_Key_Hyper_R Qt::Key_Hyper_R
#define TQ_ButtonState ButtonState
#define TQ_LeftButton Qt::LeftButton
#define TQ_MidButton Qt::MidButton
#define TQ_RightButton Qt::RightButton
#define TQ_ShiftButton Qt::ShiftButton
#define TQ_ControlButton Qt::ControlButton
#define TQ_AltButton Qt::AltButton
#define TQ_MetaButton Qt::MetaButton
#define TQAlignCenter Qt::AlignCenter
#define TQNoBrush Qt::NoBrush
@ -967,8 +989,8 @@ class QUObject;
#define TQAsciiBucket QAsciiBucket
#define TQIntBucket QIntBucket
#define TQPtrBucket QPtrBucket
#define TQGDict QGDict
#define TQGDictIterator QGDictIterator
#define TQGDict Q3GDict
#define TQGDictIterator Q3GDictIterator
#define TQGLColormap QGLColormap
#define TQGL QGL
#define TQGLFormat QGLFormat
@ -1214,6 +1236,8 @@ class QUObject;
#define TQToolButton QToolButton
#define TQToolTipGroup QToolTipGroup
#define TQToolTip QToolTip
#define TQTranslator QTranslator
#define TQTranslatorMessage QTranslatorMessage
#define TQTsciiCodec QTsciiCodec
#define TQUrl Q3Url
#define TQUrlInfo QUrlInfo

@ -118,6 +118,9 @@ class Q_GUI_EXPORT QApplication : public QCoreApplication
public:
enum Type { Tty, GuiClient, GuiServer };
void installTranslator( QTranslator * );
void removeTranslator( QTranslator * );
#ifdef Q_WS_S60
typedef CApaApplication * (*QS60MainApplicationFactory)();
#endif

@ -0,0 +1,266 @@
/****************************************************************************
**
** 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 QDIR_H
#define QDIR_H
#include <QtCore/qstring.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Core)
class QDirPrivate;
class Q_CORE_EXPORT QDir
{
protected:
QScopedPointer<QDirPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QDir)
public:
enum Filter { Dirs = 0x001,
Files = 0x002,
Drives = 0x004,
NoSymLinks = 0x008,
AllEntries = Dirs | Files | Drives,
TypeMask = 0x00f,
#ifdef QT3_SUPPORT
All = AllEntries,
#endif
Readable = 0x010,
Writable = 0x020,
Executable = 0x040,
PermissionMask = 0x070,
#ifdef QT3_SUPPORT
RWEMask = 0x070,
#endif
Modified = 0x080,
Hidden = 0x100,
System = 0x200,
AccessMask = 0x3F0,
AllDirs = 0x400,
CaseSensitive = 0x800,
NoDotAndDotDot = 0x1000,
NoFilter = -1
#ifdef QT3_SUPPORT
,DefaultFilter = NoFilter
#endif
};
Q_DECLARE_FLAGS(Filters, Filter)
#ifdef QT3_SUPPORT
typedef Filters FilterSpec;
#endif
enum SortFlag { Name = 0x00,
Time = 0x01,
Size = 0x02,
Unsorted = 0x03,
SortByMask = 0x03,
DirsFirst = 0x04,
Reversed = 0x08,
IgnoreCase = 0x10,
DirsLast = 0x20,
LocaleAware = 0x40,
Type = 0x80,
NoSort = -1
#ifdef QT3_SUPPORT
,DefaultSort = NoSort
#endif
};
Q_DECLARE_FLAGS(SortFlags, SortFlag)
QDir(const QDir &);
QDir(const QString &path = QString());
QDir(const QString &path, const QString &nameFilter,
SortFlags sort = SortFlags(Name | IgnoreCase), Filters filter = AllEntries);
~QDir();
QDir &operator=(const QDir &);
QDir &operator=(const QString &path);
void setPath(const QString &path);
QString path() const;
QString absolutePath() const;
QString canonicalPath() const;
static void addResourceSearchPath(const QString &path);
static void setSearchPaths(const QString &prefix, const QStringList &searchPaths);
static void addSearchPath(const QString &prefix, const QString &path);
static QStringList searchPaths(const QString &prefix);
QString dirName() const;
QString filePath(const QString &fileName) const;
QString absoluteFilePath(const QString &fileName) const;
QString relativeFilePath(const QString &fileName) const;
#ifdef QT_DEPRECATED
QT_DEPRECATED static QString convertSeparators(const QString &pathName);
#endif
static QString toNativeSeparators(const QString &pathName);
static QString fromNativeSeparators(const QString &pathName);
bool cd(const QString &dirName);
bool cdUp();
QStringList nameFilters() const;
void setNameFilters(const QStringList &nameFilters);
Filters filter() const;
void setFilter(Filters filter);
SortFlags sorting() const;
void setSorting(SortFlags sort);
uint count() const;
QString operator[](int) const;
static QStringList nameFiltersFromString(const QString &nameFilter);
QStringList entryList(Filters filters = NoFilter, SortFlags sort = NoSort) const;
QStringList entryList(const QStringList &nameFilters, Filters filters = NoFilter,
SortFlags sort = NoSort) const;
QFileInfoList entryInfoList(Filters filters = NoFilter, SortFlags sort = NoSort) const;
QFileInfoList entryInfoList(const QStringList &nameFilters, Filters filters = NoFilter,
SortFlags sort = NoSort) const;
bool mkdir(const QString &dirName) const;
bool rmdir(const QString &dirName) const;
bool mkpath(const QString &dirPath) const;
bool rmpath(const QString &dirPath) const;
bool isReadable() const;
bool exists() const;
bool isRoot() const;
static bool isRelativePath(const QString &path);
inline static bool isAbsolutePath(const QString &path) { return !isRelativePath(path); }
bool isRelative() const;
inline bool isAbsolute() const { return !isRelative(); }
bool makeAbsolute();
bool operator==(const QDir &dir) const;
inline bool operator!=(const QDir &dir) const { return !operator==(dir); }
bool remove(const QString &fileName);
bool rename(const QString &oldName, const QString &newName);
bool exists(const QString &name) const;
virtual bool exists( const QString &name, bool acceptAbsPath = TRUE );
static QFileInfoList drives();
static QChar separator();
static bool setCurrent(const QString &path);
static inline QDir current() { return QDir(currentPath()); }
static QString currentPath();
static inline QDir home() { return QDir(homePath()); }
static QString homePath();
static inline QDir root() { return QDir(rootPath()); }
static QString rootPath();
static inline QDir temp() { return QDir(tempPath()); }
static QString tempPath();
#ifndef QT_NO_REGEXP
static bool match(const QStringList &filters, const QString &fileName);
static bool match(const QString &filter, const QString &fileName);
#endif
static QString cleanPath(const QString &path);
void refresh() const;
#ifdef QT3_SUPPORT
typedef SortFlags SortSpec;
inline QT3_SUPPORT QString absPath() const { return absolutePath(); }
inline QT3_SUPPORT QString absFilePath(const QString &fileName, bool acceptAbsPath = true) const
{ Q_UNUSED(acceptAbsPath); return absoluteFilePath(fileName); }
QT3_SUPPORT bool matchAllDirs() const;
QT3_SUPPORT void setMatchAllDirs(bool on);
inline QT3_SUPPORT QStringList entryList(const QString &nameFilter, Filters filters = NoFilter,
SortFlags sort = NoSort) const
{ return entryList(nameFiltersFromString(nameFilter), filters, sort); }
inline QT3_SUPPORT QFileInfoList entryInfoList(const QString &nameFilter,
Filters filters = NoFilter,
SortFlags sort = NoSort) const
{ return entryInfoList(nameFiltersFromString(nameFilter), filters, sort); }
QT3_SUPPORT QString nameFilter() const;
QT3_SUPPORT void setNameFilter(const QString &nameFilter);
inline QT3_SUPPORT bool mkdir(const QString &dirName, bool acceptAbsPath) const
{ Q_UNUSED(acceptAbsPath); return mkdir(dirName); }
inline QT3_SUPPORT bool rmdir(const QString &dirName, bool acceptAbsPath) const
{ Q_UNUSED(acceptAbsPath); return rmdir(dirName); }
inline QT3_SUPPORT void convertToAbs() { makeAbsolute(); }
inline QT3_SUPPORT static QString currentDirPath() { return currentPath(); }
inline QT3_SUPPORT static QString homeDirPath() { return homePath(); }
inline QT3_SUPPORT static QString rootDirPath() { return rootPath(); }
inline QT3_SUPPORT static QString cleanDirPath(const QString &name) { return cleanPath(name); }
#endif
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::Filters)
Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::SortFlags)
#ifndef QT_NO_DEBUG_STREAM
class QDebug;
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters);
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QDir &dir);
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif // QDIR_H

@ -110,8 +110,8 @@ class QList
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(); }
inline QList() : d(&QListData::shared_null) { d->ref.ref(); current_index=0; }
inline QList(const QList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); current_index=0; }
~QList();
QList<T> &operator=(const QList<T> &l);
bool operator==(const QList<T> &l) const;
@ -120,6 +120,7 @@ public:
operator bool() const;
inline operator const QList<T> *() const { return const_cast<QList<T> *>(this); }
inline operator QList<T> *() const { return const_cast<QList<T> *>(this); }
inline int size() const { return p.size(); }
@ -159,8 +160,12 @@ public:
int indexOf(const T &t, int from = 0) const;
int lastIndexOf(const T &t, int from = -1) const;
QBool contains(const T &t) const;
inline uint containsRef( const T &t ) { return count(t); };
int count(const T &t) const;
inline T next() { current_index++; return *this[current_index]; }
inline T prev() { current_index--; return *this[current_index]; }
class const_iterator;
class iterator {
@ -264,10 +269,10 @@ public:
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(); }
inline T& first() { Q_ASSERT(!isEmpty()); current_index=0; return *begin(); }
inline const T& first() const { Q_ASSERT(!isEmpty()); current_index=0; return *begin(); }
T& last() { Q_ASSERT(!isEmpty()); return *(--end()); }
const T& last() const { Q_ASSERT(!isEmpty()); return *(--end()); }
const T& last() const { Q_ASSERT(!isEmpty()); current_index=count()-1; 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; }
@ -341,6 +346,8 @@ private:
void node_destruct(Node *n);
void node_copy(Node *from, Node *to, Node *src);
void node_destruct(Node *from, Node *to);
int current_index;
};
#if defined(Q_CC_BOR)

@ -0,0 +1,429 @@
/****************************************************************************
**
** 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 QMENU_H
#define QMENU_H
#include <QtGui/qwidget.h>
#include <QtCore/qstring.h>
#include <QtGui/qicon.h>
#include <QtGui/qaction.h>
#ifdef QT3_SUPPORT
#include <QtGui/qpixmap.h>
#endif
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#ifndef QT_NO_MENU
class QMenuPrivate;
class QStyleOptionMenuItem;
#ifdef QT3_SUPPORT
class QMenuItem;
#endif
class Q_GUI_EXPORT QMenu : public QWidget
{
private:
Q_OBJECT
Q_DECLARE_PRIVATE(QMenu)
Q_PROPERTY(bool tearOffEnabled READ isTearOffEnabled WRITE setTearOffEnabled)
Q_PROPERTY(QString title READ title WRITE setTitle)
Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
Q_PROPERTY(bool separatorsCollapsible READ separatorsCollapsible WRITE setSeparatorsCollapsible)
public:
explicit QMenu(QWidget *parent = 0);
explicit QMenu(const QString &title, QWidget *parent = 0);
~QMenu();
#ifdef Q_NO_USING_KEYWORD
inline void addAction(QAction *action) { QWidget::addAction(action); }
#else
using QWidget::addAction;
#endif
QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, const QString &text);
QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
QAction *addMenu(QMenu *menu);
QMenu *addMenu(const QString &title);
QMenu *addMenu(const QIcon &icon, const QString &title);
QAction *addSeparator();
QAction *insertMenu(QAction *before, QMenu *menu);
QAction *insertSeparator(QAction *before);
bool isEmpty() const;
void clear();
void setTearOffEnabled(bool);
bool isTearOffEnabled() const;
bool isTearOffMenuVisible() const;
void hideTearOffMenu();
void setDefaultAction(QAction *);
QAction *defaultAction() const;
void setActiveAction(QAction *act);
QAction *activeAction() const;
void popup(const QPoint &pos, QAction *at=0);
QAction *exec();
QAction *exec(const QPoint &pos, QAction *at=0);
// ### Qt 5: merge
static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at=0);
static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at, QWidget *parent);
QSize sizeHint() const;
QRect actionGeometry(QAction *) const;
QAction *actionAt(const QPoint &) const;
QAction *menuAction() const;
QString title() const;
void setTitle(const QString &title);
QIcon icon() const;
void setIcon(const QIcon &icon);
void setNoReplayFor(QWidget *widget);
#ifdef Q_WS_MAC
OSMenuRef macMenu(OSMenuRef merge=0);
#endif
#ifdef Q_WS_WINCE
HMENU wceMenu(bool create = false);
#endif
bool separatorsCollapsible() const;
void setSeparatorsCollapsible(bool collapse);
Q_SIGNALS:
void aboutToShow();
void aboutToHide();
void triggered(QAction *action);
void hovered(QAction *action);
protected:
int columnCount() const;
void changeEvent(QEvent *);
void keyPressEvent(QKeyEvent *);
void mouseReleaseEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void wheelEvent(QWheelEvent *);
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void hideEvent(QHideEvent *);
void paintEvent(QPaintEvent *);
void actionEvent(QActionEvent *);
void timerEvent(QTimerEvent *);
bool event(QEvent *);
bool focusNextPrevChild(bool next);
void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
#ifdef Q_WS_WINCE
QAction* wceCommands(uint command);
#endif
private Q_SLOTS:
void internalSetSloppyAction();
void internalDelayedPopup();
private:
Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
Q_PRIVATE_SLOT(d_func(), void _q_overrideMenuActionDestroyed())
#ifdef QT3_SUPPORT
public:
//menudata
inline QT3_SUPPORT uint count() const { return actions().count(); }
inline QT3_SUPPORT int insertItem(const QString &text, const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
return insertAny(0, &text, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text,
const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
return insertAny(&icon, &text, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QString &text, int id=-1, int index=-1) {
return insertAny(0, &text, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, int id=-1, int index=-1) {
return insertAny(&icon, &text, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QString &text, QMenu *popup, int id=-1, int index=-1) {
return insertAny(0, &text, 0, 0, 0, popup, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id=-1, int index=-1) {
return insertAny(&icon, &text, 0, 0, 0, popup, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, int id=-1, int index=-1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, QMenu *popup, int id=-1, int index=-1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, 0, 0, 0, popup, id, index);
}
QT3_SUPPORT int insertItem(QMenuItem *item, int id=-1, int index=-1);
int insertItem( QWidget* widget, int id=-1, int index=-1 );
QT3_SUPPORT int insertSeparator(int index=-1);
inline QT3_SUPPORT void removeItem(int id) {
if(QAction *act = findActionForId(id))
removeAction(act); }
inline QT3_SUPPORT void removeItemAt(int index) {
if(QAction *act = actions().value(index))
removeAction(act); }
#ifndef QT_NO_SHORTCUT
inline QT3_SUPPORT QKeySequence accel(int id) const {
if(QAction *act = findActionForId(id))
return act->shortcut();
return QKeySequence(); }
inline QT3_SUPPORT void setAccel(const QKeySequence& key, int id) {
if(QAction *act = findActionForId(id))
act->setShortcut(key);
}
#endif
inline QT3_SUPPORT QIcon iconSet(int id) const {
if(QAction *act = findActionForId(id))
return act->icon();
return QIcon(); }
inline QT3_SUPPORT QString text(int id) const {
if(QAction *act = findActionForId(id))
return act->text();
return QString(); }
inline QT3_SUPPORT QPixmap pixmap(int id) const {
if(QAction *act = findActionForId(id))
return act->icon().pixmap(QSize(22, 22));
return QPixmap(); }
inline QT3_SUPPORT void setWhatsThis(int id, const QString &w) {
if(QAction *act = findActionForId(id))
act->setWhatsThis(w); }
inline QT3_SUPPORT QString whatsThis(int id) const {
if(QAction *act = findActionForId(id))
return act->whatsThis();
return QString(); }
inline QT3_SUPPORT void changeItem(int id, const QString &text) {
if(QAction *act = findActionForId(id))
act->setText(text); }
inline QT3_SUPPORT void changeItem(int id, const QPixmap &pixmap) {
if(QAction *act = findActionForId(id))
act->setIcon(QIcon(pixmap)); }
inline QT3_SUPPORT void changeItem(int id, const QIcon &icon, const QString &text) {
if(QAction *act = findActionForId(id)) {
act->setIcon(icon);
act->setText(text);
}
}
inline QT3_SUPPORT void setActiveItem(int id) {
setActiveAction(findActionForId(id));
}
inline QT3_SUPPORT bool isItemActive(int id) const {
return findActionForId(id) == activeAction();
}
inline QT3_SUPPORT bool isItemEnabled(int id) const {
if(QAction *act = findActionForId(id))
return act->isEnabled();
return false; }
inline QT3_SUPPORT void setItemEnabled(int id, bool enable) {
if(QAction *act = findActionForId(id))
act->setEnabled(enable);
}
inline QT3_SUPPORT bool isItemChecked(int id) const {
if(QAction *act = findActionForId(id))
return act->isChecked();
return false;
}
inline QT3_SUPPORT void setItemChecked(int id, bool check) {
if(QAction *act = findActionForId(id)) {
act->setCheckable(true);
act->setChecked(check);
}
}
inline QT3_SUPPORT bool isItemVisible(int id) const {
if(QAction *act = findActionForId(id))
return act->isVisible();
return false;
}
inline QT3_SUPPORT void setItemVisible(int id, bool visible) {
if(QAction *act = findActionForId(id))
act->setVisible(visible);
}
inline QT3_SUPPORT QRect itemGeometry(int index) {
if(QAction *act = actions().value(index))
return actionGeometry(act);
return QRect();
}
inline QT3_SUPPORT QFont itemFont(int id) const {
if(QAction *act = findActionForId(id))
return act->font();
return QFont();
}
inline QT3_SUPPORT void setItemFont(int id, const QFont &font) {
if(QAction *act = findActionForId(id))
act->setFont(font);
}
inline QT3_SUPPORT int indexOf(int id) const {
return actions().indexOf(findActionForId(id));
}
inline QT3_SUPPORT int idAt(int index) const {
return findIdForAction(actions().value(index));
}
QT3_SUPPORT void setId (int index, int id);
inline QT3_SUPPORT void activateItemAt(int index) {
if(QAction *ret = actions().value(index))
ret->activate(QAction::Trigger);
}
inline QT3_SUPPORT bool connectItem(int id, const QObject *receiver, const char* member) {
if(QAction *act = findActionForId(id)) {
QObject::connect(act, SIGNAL(activated(int)), receiver, member);
return true;
}
return false;
}
inline QT3_SUPPORT bool disconnectItem(int id,const QObject *receiver, const char* member) {
if(QAction *act = findActionForId(id)) {
QObject::disconnect(act, SIGNAL(triggered()), receiver, member);
return true;
}
return false;
}
inline QT3_SUPPORT QMenuItem *findItem(int id) const {
return reinterpret_cast<QMenuItem*>(findActionForId(id));
}
inline QT3_SUPPORT void setCheckable(bool){}
inline QT3_SUPPORT bool isCheckable() const {return true;}
QT3_SUPPORT QMenuItem *findPopup( QMenu *popup, int *index );
QT3_SUPPORT bool setItemParameter(int id, int param);
QT3_SUPPORT int itemParameter(int id) const;
//frame
QT3_SUPPORT int frameWidth() const;
//popupmenu
inline QT3_SUPPORT void popup(const QPoint & pos, int indexAtPoint) { popup(pos, actions().value(indexAtPoint)); }
inline QT3_SUPPORT int insertTearOffHandle(int = 0, int = 0) {
setTearOffEnabled(true);
return -1;
}
protected:
inline QT3_SUPPORT int itemAtPos(const QPoint &p, bool ignoreSeparator = true) {
QAction *ret = actionAt(p);
if(ignoreSeparator && ret && ret->isSeparator())
return -1;
return findIdForAction(ret);
}
inline QT3_SUPPORT int columns() const { return columnCount(); }
inline QT3_SUPPORT int itemHeight(int index) {
return actionGeometry(actions().value(index)).height();
}
inline QT3_SUPPORT int itemHeight(QMenuItem *mi) {
return actionGeometry(reinterpret_cast<QAction *>(mi)).height();
}
Q_SIGNALS:
QT_MOC_COMPAT void activated(int itemId);
QT_MOC_COMPAT void highlighted(int itemId);
private:
int insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
const QKeySequence *shorcut, const QMenu *popup, int id, int index);
QAction *findActionForId(int id) const;
int findIdForAction(QAction*) const;
#endif
protected:
QMenu(QMenuPrivate &dd, QWidget* parent = 0);
private:
Q_DISABLE_COPY(QMenu)
friend class QMenuBar;
friend class QMenuBarPrivate;
friend class QTornOffMenu;
friend class Q3PopupMenu;
friend class QComboBox;
friend class QAction;
friend class QToolButtonPrivate;
#ifdef Q_WS_MAC
friend void qt_mac_trayicon_activate_action(QMenu *, QAction *action);
friend bool qt_mac_watchingAboutToShow(QMenu *);
friend OSStatus qt_mac_menu_event(EventHandlerCallRef, EventRef, void *);
friend bool qt_mac_activate_action(OSMenuRef, uint, QAction::ActionEvent, bool);
friend void qt_mac_emit_menuSignals(QMenu *, bool);
#endif
};
#endif // QT_NO_MENU
QT_END_NAMESPACE
QT_END_HEADER
#endif // QMENU_H

@ -244,6 +244,7 @@ public:
void setOptimization( Optimization );
static Optimization defaultOptimization();
static void setDefaultOptimization( Optimization );
operator QPixmap *() const;
#endif
private:

@ -0,0 +1,87 @@
/****************************************************************************
**
** 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 QTOOLTIP_H
#define QTOOLTIP_H
#include <QtGui/qwidget.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#ifndef QT_NO_TOOLTIP
class Q_GUI_EXPORT QToolTip
{
QToolTip();
public:
static void showText(const QPoint &pos, const QString &text, QWidget *w = 0);
static void showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect);
static inline void hideText() { showText(QPoint(), QString()); }
static bool isVisible();
static QString text();
static QPalette palette();
static void setPalette(const QPalette &);
static QFont font();
static void setFont(const QFont &);
#ifdef QT3_SUPPORT
static inline QT3_SUPPORT void add(QWidget *w, const QString &s) { w->setToolTip(s); }
static inline QT3_SUPPORT void add(QWidget *w, const QRect &, const QString &s)
{ w->setToolTip(s); }
static inline QT3_SUPPORT void remove(QWidget *w) { w->setToolTip(QString()); }
#endif
static void setGloballyEnabled( bool );
static bool isGloballyEnabled();
};
#endif // QT_NO_TOOLTIP
QT_END_NAMESPACE
QT_END_HEADER
#endif // QTOOLTIP_H

@ -0,0 +1,802 @@
/****************************************************************************
**
** 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 QVECTOR_H
#define QVECTOR_H
#include <QtCore/qiterator.h>
#include <QtCore/qatomic.h>
#include <QtCore/qalgorithms.h>
#include <QtCore/qlist.h>
#ifndef QT_NO_STL
#include <iterator>
#include <vector>
#endif
#include <stdlib.h>
#include <string.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Core)
struct Q_CORE_EXPORT QVectorData
{
QBasicAtomicInt ref;
int alloc;
int size;
#if defined(QT_ARCH_SPARC) && defined(Q_CC_GNU) && defined(__LP64__) && defined(QT_BOOTSTRAPPED)
// workaround for bug in gcc 3.4.2
uint sharable;
uint capacity;
uint reserved;
#else
uint sharable : 1;
uint capacity : 1;
uint reserved : 30;
#endif
static QVectorData shared_null;
// ### Qt 5: rename to 'allocate()'. The current name causes problems for
// some debugges when the QVector is member of a class within an unnamed namespace.
// ### Qt 5: can be removed completely. (Ralf)
static QVectorData *malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init);
static QVectorData *allocate(int size, int alignment);
static QVectorData *reallocate(QVectorData *old, int newsize, int oldsize, int alignment);
static void free(QVectorData *data, int alignment);
static int grow(int sizeofTypedData, int size, int sizeofT, bool excessive);
};
template <typename T>
struct QVectorTypedData : private QVectorData
{ // private inheritance as we must not access QVectorData member thought QVectorTypedData
// as this would break strict aliasing rules. (in the case of shared_null)
T array[1];
static inline void free(QVectorTypedData<T> *x, int alignment) { QVectorData::free(static_cast<QVectorData *>(x), alignment); }
};
class QRegion;
template <typename T>
class QVector
{
typedef QVectorTypedData<T> Data;
union {
QVectorData *d;
#if defined(Q_CC_SUN) && (__SUNPRO_CC <= 0x550)
QVectorTypedData<T> *p;
#else
Data *p;
#endif
};
public:
inline QVector() : d(&QVectorData::shared_null) { d->ref.ref(); }
explicit QVector(int size);
QVector(int size, const T &t);
inline QVector(const QVector<T> &v) : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }
inline ~QVector() { if (!d) return; if (!d->ref.deref()) free(p); }
QVector<T> &operator=(const QVector<T> &v);
bool operator==(const QVector<T> &v) const;
inline bool operator!=(const QVector<T> &v) const { return !(*this == v); }
inline int size() const { return d->size; }
inline bool isEmpty() const { return d->size == 0; }
void resize(int size);
inline int capacity() const { return d->alloc; }
void reserve(int size);
inline void squeeze() { realloc(d->size, d->size); d->capacity = 0; }
inline void detach() { if (d->ref != 1) detach_helper(); }
inline bool isDetached() const { return d->ref == 1; }
inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
inline T *data() { detach(); return p->array; }
inline const T *data() const { return p->array; }
inline const T *constData() const { return p->array; }
void clear();
inline operator unsigned int *() const { return p->array; }
const T &at(int i) const;
T &operator[](int i);
const T &operator[](int i) const;
void append(const T &t);
void prepend(const T &t);
void insert(int i, const T &t);
void insert(int i, int n, const T &t);
void replace(int i, const T &t);
void remove(int i);
void remove(int i, int n);
QVector<T> &fill(const T &t, int size = -1);
int indexOf(const T &t, int from = 0) const;
int lastIndexOf(const T &t, int from = -1) const;
bool contains(const T &t) const;
int count(const T &t) const;
#ifdef QT_STRICT_ITERATORS
class iterator {
public:
T *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(T *n) : i(n) {}
inline iterator(const iterator &o): i(o.i){}
inline T &operator*() const { return *i; }
inline T *operator->() const { return i; }
inline T &operator[](int j) const { return *(i + j); }
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; }
inline iterator &operator++() { ++i; return *this; }
inline iterator operator++(int) { T *n = i; ++i; return n; }
inline iterator &operator--() { i--; return *this; }
inline iterator operator--(int) { T *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 i - j.i; }
};
friend class iterator;
class const_iterator {
public:
T *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(T *n) : i(n) {}
inline const_iterator(const const_iterator &o): i(o.i) {}
inline explicit const_iterator(const iterator &o): i(o.i) {}
inline const T &operator*() const { return *i; }
inline const T *operator->() const { return i; }
inline const T &operator[](int j) const { return *(i + j); }
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) { T *n = i; ++i; return n; }
inline const_iterator &operator--() { i--; return *this; }
inline const_iterator operator--(int) { T *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;
#else
// STL-style
typedef T* iterator;
typedef const T* const_iterator;
#endif
inline iterator begin() { detach(); return p->array; }
inline const_iterator begin() const { return p->array; }
inline const_iterator constBegin() const { return p->array; }
inline iterator end() { detach(); return p->array + d->size; }
inline const_iterator end() const { return p->array + d->size; }
inline const_iterator constEnd() const { return p->array + d->size; }
iterator insert(iterator before, int n, const T &x);
inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); }
iterator erase(iterator begin, iterator end);
inline iterator erase(iterator pos) { return erase(pos, pos+1); }
// more Qt
inline int count() const { return d->size; }
inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); }
inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
QVector<T> mid(int pos, int length = -1) const;
T value(int i) const;
T value(int i, const T &defaultValue) const;
// STL compatibility
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;
typedef iterator Iterator;
typedef const_iterator ConstIterator;
typedef int size_type;
inline void push_back(const T &t) { append(t); }
inline void push_front(const T &t) { prepend(t); }
void pop_back() { Q_ASSERT(!isEmpty()); erase(end()-1); }
void pop_front() { Q_ASSERT(!isEmpty()); erase(begin()); }
inline bool empty() const
{ return d->size == 0; }
inline T& front() { return first(); }
inline const_reference front() const { return first(); }
inline reference back() { return last(); }
inline const_reference back() const { return last(); }
// comfort
QVector<T> &operator+=(const QVector<T> &l);
inline QVector<T> operator+(const QVector<T> &l) const
{ QVector n = *this; n += l; return n; }
inline QVector<T> &operator+=(const T &t)
{ append(t); return *this; }
inline QVector<T> &operator<< (const T &t)
{ append(t); return *this; }
inline QVector<T> &operator<<(const QVector<T> &l)
{ *this += l; return *this; }
QList<T> toList() const;
static QVector<T> fromList(const QList<T> &list);
#ifndef QT_NO_STL
static inline QVector<T> fromStdVector(const std::vector<T> &vector)
{ QVector<T> tmp; qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
inline std::vector<T> toStdVector() const
{ std::vector<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
#endif
private:
friend class QRegion; // Optimization for QRegion::rects()
void detach_helper();
QVectorData *malloc(int alloc);
void realloc(int size, int alloc);
void free(Data *d);
int sizeOfTypedData() {
// this is more or less the same as sizeof(Data), except that it doesn't
// count the padding at the end
return reinterpret_cast<const char *>(&(reinterpret_cast<const Data *>(this))->array[1]) - reinterpret_cast<const char *>(this);
}
inline int alignOfTypedData() const
{
#ifdef Q_ALIGNOF
return qMax<int>(sizeof(void*), Q_ALIGNOF(Data));
#else
return 0;
#endif
}
};
template <typename T>
void QVector<T>::detach_helper()
{ realloc(d->size, d->alloc); }
template <typename T>
void QVector<T>::reserve(int asize)
{ if (asize > d->alloc) realloc(d->size, asize); if (d->ref == 1) d->capacity = 1; }
template <typename T>
void QVector<T>::resize(int asize)
{ realloc(asize, (asize > d->alloc || (!d->capacity && asize < d->size && asize < (d->alloc >> 1))) ?
QVectorData::grow(sizeOfTypedData(), asize, sizeof(T), QTypeInfo<T>::isStatic)
: d->alloc); }
template <typename T>
inline void QVector<T>::clear()
{ *this = QVector<T>(); }
template <typename T>
inline const T &QVector<T>::at(int i) const
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::at", "index out of range");
return p->array[i]; }
template <typename T>
inline const T &QVector<T>::operator[](int i) const
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range");
return p->array[i]; }
template <typename T>
inline T &QVector<T>::operator[](int i)
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range");
return data()[i]; }
template <typename T>
inline void QVector<T>::insert(int i, const T &t)
{ Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range");
insert(begin() + i, 1, t); }
template <typename T>
inline void QVector<T>::insert(int i, int n, const T &t)
{ Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range");
insert(begin() + i, n, t); }
template <typename T>
inline void QVector<T>::remove(int i, int n)
{ Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= d->size, "QVector<T>::remove", "index out of range");
erase(begin() + i, begin() + i + n); }
template <typename T>
inline void QVector<T>::remove(int i)
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::remove", "index out of range");
erase(begin() + i, begin() + i + 1); }
template <typename T>
inline void QVector<T>::prepend(const T &t)
{ insert(begin(), 1, t); }
template <typename T>
inline void QVector<T>::replace(int i, const T &t)
{
Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range");
const T copy(t);
data()[i] = copy;
}
template <typename T>
QVector<T> &QVector<T>::operator=(const QVector<T> &v)
{
v.d->ref.ref();
if (!d->ref.deref())
free(p);
d = v.d;
if (!d->sharable)
detach_helper();
return *this;
}
template <typename T>
inline QVectorData *QVector<T>::malloc(int aalloc)
{
QVectorData *vectordata = QVectorData::allocate(sizeOfTypedData() + (aalloc - 1) * sizeof(T), alignOfTypedData());
Q_CHECK_PTR(vectordata);
return vectordata;
}
template <typename T>
QVector<T>::QVector(int asize)
{
d = malloc(asize);
d->ref = 1;
d->alloc = d->size = asize;
d->sharable = true;
d->capacity = false;
if (QTypeInfo<T>::isComplex) {
T* b = p->array;
T* i = p->array + d->size;
while (i != b)
new (--i) T;
} else {
qMemSet(p->array, 0, asize * sizeof(T));
}
}
template <typename T>
QVector<T>::QVector(int asize, const T &t)
{
d = malloc(asize);
d->ref = 1;
d->alloc = d->size = asize;
d->sharable = true;
d->capacity = false;
T* i = p->array + d->size;
while (i != p->array)
new (--i) T(t);
}
template <typename T>
void QVector<T>::free(Data *x)
{
if (QTypeInfo<T>::isComplex) {
T* b = x->array;
union { QVectorData *d; Data *p; } u;
u.p = x;
T* i = b + u.d->size;
while (i-- != b)
i->~T();
}
x->free(x, alignOfTypedData());
}
template <typename T>
void QVector<T>::realloc(int asize, int aalloc)
{
Q_ASSERT(asize <= aalloc);
T *pOld;
T *pNew;
union { QVectorData *d; Data *p; } x;
x.d = d;
if (QTypeInfo<T>::isComplex && asize < d->size && d->ref == 1 ) {
// call the destructor on all objects that need to be
// destroyed when shrinking
pOld = p->array + d->size;
pNew = p->array + asize;
while (asize < d->size) {
(--pOld)->~T();
d->size--;
}
}
if (aalloc != d->alloc || d->ref != 1) {
// (re)allocate memory
if (QTypeInfo<T>::isStatic) {
x.d = malloc(aalloc);
Q_CHECK_PTR(x.p);
x.d->size = 0;
} else if (d->ref != 1) {
x.d = malloc(aalloc);
Q_CHECK_PTR(x.p);
if (QTypeInfo<T>::isComplex) {
x.d->size = 0;
} else {
::memcpy(x.p, p, sizeOfTypedData() + (qMin(aalloc, d->alloc) - 1) * sizeof(T));
x.d->size = d->size;
}
} else {
QT_TRY {
QVectorData *mem = QVectorData::reallocate(d, sizeOfTypedData() + (aalloc - 1) * sizeof(T),
sizeOfTypedData() + (d->alloc - 1) * sizeof(T), alignOfTypedData());
Q_CHECK_PTR(mem);
x.d = d = mem;
x.d->size = d->size;
} QT_CATCH (const std::bad_alloc &) {
if (aalloc > d->alloc) // ignore the error in case we are just shrinking.
QT_RETHROW;
}
}
x.d->ref = 1;
x.d->alloc = aalloc;
x.d->sharable = true;
x.d->capacity = d->capacity;
x.d->reserved = 0;
}
if (QTypeInfo<T>::isComplex) {
QT_TRY {
pOld = p->array + x.d->size;
pNew = x.p->array + x.d->size;
// copy objects from the old array into the new array
const int toMove = qMin(asize, d->size);
while (x.d->size < toMove) {
new (pNew++) T(*pOld++);
x.d->size++;
}
// construct all new objects when growing
while (x.d->size < asize) {
new (pNew++) T;
x.d->size++;
}
} QT_CATCH (...) {
free(x.p);
QT_RETHROW;
}
} else if (asize > x.d->size) {
// initialize newly allocated memory to 0
qMemSet(x.p->array + x.d->size, 0, (asize - x.d->size) * sizeof(T));
}
x.d->size = asize;
if (d != x.d) {
if (!d->ref.deref())
free(p);
d = x.d;
}
}
template<typename T>
Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i) const
{
if (i < 0 || i >= d->size) {
return T();
}
return p->array[i];
}
template<typename T>
Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i, const T &defaultValue) const
{
return ((i < 0 || i >= d->size) ? defaultValue : p->array[i]);
}
template <typename T>
void QVector<T>::append(const T &t)
{
if (d->ref != 1 || d->size + 1 > d->alloc) {
const T copy(t);
realloc(d->size, QVectorData::grow(sizeOfTypedData(), d->size + 1, sizeof(T),
QTypeInfo<T>::isStatic));
if (QTypeInfo<T>::isComplex)
new (p->array + d->size) T(copy);
else
p->array[d->size] = copy;
} else {
if (QTypeInfo<T>::isComplex)
new (p->array + d->size) T(t);
else
p->array[d->size] = t;
}
++d->size;
}
template <typename T>
Q_TYPENAME QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, const T &t)
{
int offset = int(before - p->array);
if (n != 0) {
const T copy(t);
if (d->ref != 1 || d->size + n > d->alloc)
realloc(d->size, QVectorData::grow(sizeOfTypedData(), d->size + n, sizeof(T),
QTypeInfo<T>::isStatic));
if (QTypeInfo<T>::isStatic) {
T *b = p->array + d->size;
T *i = p->array + d->size + n;
while (i != b)
new (--i) T;
i = p->array + d->size;
T *j = i + n;
b = p->array + offset;
while (i != b)
*--j = *--i;
i = b+n;
while (i != b)
*--i = copy;
} else {
T *b = p->array + offset;
T *i = b + n;
memmove(i, b, (d->size - offset) * sizeof(T));
while (i != b)
new (--i) T(copy);
}
d->size += n;
}
return p->array + offset;
}
template <typename T>
Q_TYPENAME QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend)
{
int f = int(abegin - p->array);
int l = int(aend - p->array);
int n = l - f;
detach();
if (QTypeInfo<T>::isComplex) {
qCopy(p->array+l, p->array+d->size, p->array+f);
T *i = p->array+d->size;
T* b = p->array+d->size-n;
while (i != b) {
--i;
i->~T();
}
} else {
memmove(p->array + f, p->array + l, (d->size-l)*sizeof(T));
}
d->size -= n;
return p->array + f;
}
template <typename T>
bool QVector<T>::operator==(const QVector<T> &v) const
{
if (d->size != v.d->size)
return false;
if (d == v.d)
return true;
T* b = p->array;
T* i = b + d->size;
T* j = v.p->array + d->size;
while (i != b)
if (!(*--i == *--j))
return false;
return true;
}
template <typename T>
QVector<T> &QVector<T>::fill(const T &from, int asize)
{
const T copy(from);
resize(asize < 0 ? d->size : asize);
if (d->size) {
T *i = p->array + d->size;
T *b = p->array;
while (i != b)
*--i = copy;
}
return *this;
}
template <typename T>
QVector<T> &QVector<T>::operator+=(const QVector &l)
{
int newSize = d->size + l.d->size;
realloc(d->size, newSize);
T *w = p->array + newSize;
T *i = l.p->array + l.d->size;
T *b = l.p->array;
while (i != b) {
if (QTypeInfo<T>::isComplex)
new (--w) T(*--i);
else
*--w = *--i;
}
d->size = newSize;
return *this;
}
template <typename T>
int QVector<T>::indexOf(const T &t, int from) const
{
if (from < 0)
from = qMax(from + d->size, 0);
if (from < d->size) {
T* n = p->array + from - 1;
T* e = p->array + d->size;
while (++n != e)
if (*n == t)
return n - p->array;
}
return -1;
}
template <typename T>
int QVector<T>::lastIndexOf(const T &t, int from) const
{
if (from < 0)
from += d->size;
else if (from >= d->size)
from = d->size-1;
if (from >= 0) {
T* b = p->array;
T* n = p->array + from + 1;
while (n != b) {
if (*--n == t)
return n - b;
}
}
return -1;
}
template <typename T>
bool QVector<T>::contains(const T &t) const
{
T* b = p->array;
T* i = p->array + d->size;
while (i != b)
if (*--i == t)
return true;
return false;
}
template <typename T>
int QVector<T>::count(const T &t) const
{
int c = 0;
T* b = p->array;
T* i = p->array + d->size;
while (i != b)
if (*--i == t)
++c;
return c;
}
template <typename T>
Q_OUTOFLINE_TEMPLATE QVector<T> QVector<T>::mid(int pos, int length) const
{
if (length < 0)
length = size() - pos;
if (pos == 0 && length == size())
return *this;
QVector<T> copy;
if (pos + length > size())
length = size() - pos;
for (int i = pos; i < pos + length; ++i)
copy += at(i);
return copy;
}
template <typename T>
Q_OUTOFLINE_TEMPLATE QList<T> QVector<T>::toList() const
{
QList<T> result;
for (int i = 0; i < size(); ++i)
result.append(at(i));
return result;
}
template <typename T>
Q_OUTOFLINE_TEMPLATE QVector<T> QList<T>::toVector() const
{
QVector<T> result(size());
for (int i = 0; i < size(); ++i)
result[i] = at(i);
return result;
}
template <typename T>
QVector<T> QVector<T>::fromList(const QList<T> &list)
{
return list.toVector();
}
template <typename T>
QList<T> QList<T>::fromVector(const QVector<T> &vector)
{
return vector.toList();
}
Q_DECLARE_SEQUENTIAL_ITERATOR(Vector)
Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(Vector)
/*
### Qt 5:
### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
### Qt exports QPolygon and QPolygonF that inherit QVector<QPoint> and
### QVector<QPointF> respectively.
*/
#ifdef Q_CC_MSVC
QT_BEGIN_INCLUDE_NAMESPACE
#include <QtCore/QPointF>
#include <QtCore/QPoint>
QT_END_INCLUDE_NAMESPACE
#if defined(QT_BUILD_CORE_LIB)
#define Q_TEMPLATE_EXTERN
#else
#define Q_TEMPLATE_EXTERN extern
#endif
# pragma warning(push) /* MSVC 6.0 doesn't care about the disabling in qglobal.h (why?), so do it here */
# pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */
Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector<QPointF>;
Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector<QPoint>;
# pragma warning(pop)
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif // QVECTOR_H

@ -251,6 +251,7 @@ public:
bool isEnabledToTLW() const;
Qt::WidgetAttribute testWState( Qt::WidgetAttribute s ) const;
Qt::WindowFlags testWFlags( Qt::WindowFlags f ) const;
public Q_SLOTS:
void setEnabled(bool);

@ -21,3 +21,19 @@ Boston, MA 02110-1301, USA.
#include <tqt.h>
#include <tqtooltip.h>
#ifdef USE_QT4
static bool globally_enabled = TRUE;
void QToolTip::setGloballyEnabled( bool enable )
{
//globally_enabled = enable;
}
bool QToolTip::isGloballyEnabled()
{
return globally_enabled;
}
#endif // USE_QT4

@ -38,7 +38,7 @@ Boston, MA 02110-1301, USA.
// Reimplement the QToolTip class
// For Qt4, some changes are needed
#include <Qt/qtooltip.h>
#include <tqt4/Qt/qtooltip.h>
#endif // USE_QT4

@ -21,3 +21,384 @@ Boston, MA 02110-1301, USA.
#include <tqt.h>
#include <tqtranslator.h>
#ifdef USE_QT4
static uint elfHash( const char * name )
{
const uchar *k;
uint h = 0;
uint g;
if ( name ) {
k = (const uchar *) name;
while ( *k ) {
h = ( h << 4 ) + *k++;
if ( (g = (h & 0xf0000000)) != 0 )
h ^= g >> 24;
h &= ~g;
}
}
if ( !h )
h = 1;
return h;
}
/*!
\class QTranslatorMessage
\brief The QTranslatorMessage class contains a translator message and its
properties.
\ingroup i18n
\ingroup environment
This class is of no interest to most applications. It is useful
for translation tools such as \link linguist-manual.book Qt
Linguist\endlink. It is provided simply to make the API complete
and regular.
For a QTranslator object, a lookup key is a triple (\e context, \e
{source text}, \e comment) that uniquely identifies a message. An
extended key is a quadruple (\e hash, \e context, \e {source
text}, \e comment), where \e hash is computed from the source text
and the comment. Unless you plan to read and write messages
yourself, you need not worry about the hash value.
QTranslatorMessage stores this triple or quadruple and the relevant
translation if there is any.
\sa QTranslator
*/
/*!
Constructs a translator message with the extended key (0, 0, 0, 0)
and QString::null as translation.
*/
QTranslatorMessage::QTranslatorMessage()
: h( 0 ), cx( 0 ), st( 0 ), cm( 0 )
{
}
/*!
Constructs an translator message with the extended key (\e h, \a
context, \a sourceText, \a comment), where \e h is computed from
\a sourceText and \a comment, and possibly with a \a translation.
*/
QTranslatorMessage::QTranslatorMessage( const char * context,
const char * sourceText,
const char * comment,
const QString& translation )
: cx( context ), st( sourceText ), cm( comment ), tn( translation )
{
// 0 means we don't know, "" means empty
if ( cx == (const char*)0 )
cx = "";
if ( st == (const char*)0 )
st = "";
if ( cm == (const char*)0 )
cm = "";
h = elfHash( st + cm );
}
/*!
Constructs a translator message read from the \a stream. The
resulting message may have any combination of content.
\sa QTranslator::save()
*/
QTranslatorMessage::QTranslatorMessage( QDataStream & stream )
: cx( 0 ), st( 0 ), cm( 0 )
{
QString str16;
char tag;
Q_UINT8 obs1;
for ( ;; ) {
tag = 0;
if ( !stream.atEnd() )
stream.readRawBytes( &tag, 1 );
switch( (Tag)tag ) {
case Tag_End:
if ( h == 0 )
h = elfHash( st + cm );
return;
case Tag_SourceText16: // obsolete
stream >> str16;
st = str16.latin1();
break;
case Tag_Translation:
stream >> tn;
break;
case Tag_Context16: // obsolete
stream >> str16;
cx = str16.latin1();
break;
case Tag_Hash:
stream >> h;
break;
case Tag_SourceText:
stream >> st;
break;
case Tag_Context:
stream >> cx;
if ( cx == "" ) // for compatibility
cx = 0;
break;
case Tag_Comment:
stream >> cm;
break;
case Tag_Obsolete1: // obsolete
stream >> obs1;
break;
default:
h = 0;
st = 0;
cx = 0;
cm = 0;
tn = QString::null;
return;
}
}
}
/*!
Constructs a copy of translator message \a m.
*/
QTranslatorMessage::QTranslatorMessage( const QTranslatorMessage & m )
: cx( m.cx ), st( m.st ), cm( m.cm ), tn( m.tn )
{
h = m.h;
}
/*!
Assigns message \a m to this translator message and returns a
reference to this translator message.
*/
QTranslatorMessage & QTranslatorMessage::operator=(
const QTranslatorMessage & m )
{
h = m.h;
cx = m.cx;
st = m.st;
cm = m.cm;
tn = m.tn;
return *this;
}
/*!
\fn uint QTranslatorMessage::hash() const
Returns the hash value used internally to represent the lookup
key. This value is zero only if this translator message was
constructed from a stream containing invalid data.
The hashing function is unspecified, but it will remain unchanged
in future versions of Qt.
*/
/*!
\fn const char *QTranslatorMessage::context() const
Returns the context for this message (e.g. "MyDialog").
\warning This may return 0 if the QTranslator object is stripped
(compressed).
*/
/*!
\fn const char *QTranslatorMessage::sourceText() const
Returns the source text of this message (e.g. "&Save").
\warning This may return 0 if the QTranslator object is stripped
(compressed).
*/
/*!
\fn const char *QTranslatorMessage::comment() const
Returns the comment for this message (e.g. "File|Save").
\warning This may return 0 if the QTranslator object is stripped
(compressed).
*/
/*!
\fn void QTranslatorMessage::setTranslation( const QString & translation )
Sets the translation of the source text to \a translation.
\sa translation()
*/
/*!
\fn QString QTranslatorMessage::translation() const
Returns the translation of the source text (e.g., "&Sauvegarder").
\sa setTranslation()
*/
/*!
\enum QTranslatorMessage::Prefix
Let (\e h, \e c, \e s, \e m) be the extended key. The possible
prefixes are
\value NoPrefix no prefix
\value Hash only (\e h)
\value HashContext only (\e h, \e c)
\value HashContextSourceText only (\e h, \e c, \e s)
\value HashContextSourceTextComment the whole extended key, (\e
h, \e c, \e s, \e m)
\sa write() commonPrefix()
*/
/*!
Writes this translator message to the \a stream. If \a strip is
FALSE (the default), all the information in the message is
written. If \a strip is TRUE, only the part of the extended key
specified by \a prefix is written with the translation (\c
HashContextSourceTextComment by default).
\sa commonPrefix()
*/
void QTranslatorMessage::write( QDataStream & stream, bool strip,
Prefix prefix ) const
{
char tag;
tag = (char)Tag_Translation;
stream.writeRawBytes( &tag, 1 );
stream << tn;
bool mustWriteHash = TRUE;
if ( !strip )
prefix = HashContextSourceTextComment;
switch ( prefix ) {
case HashContextSourceTextComment:
tag = (char)Tag_Comment;
stream.writeRawBytes( &tag, 1 );
stream << cm;
// fall through
case HashContextSourceText:
tag = (char)Tag_SourceText;
stream.writeRawBytes( &tag, 1 );
stream << st;
// fall through
case HashContext:
tag = (char)Tag_Context;
stream.writeRawBytes( &tag, 1 );
stream << cx;
// fall through
default:
if ( mustWriteHash ) {
tag = (char)Tag_Hash;
stream.writeRawBytes( &tag, 1 );
stream << h;
}
}
tag = (char)Tag_End;
stream.writeRawBytes( &tag, 1 );
}
/*!
Returns the widest lookup prefix that is common to this translator
message and to message \a m.
For example, if the extended key is for this message is (71,
"PrintDialog", "Yes", "Print?") and that for \a m is (71,
"PrintDialog", "No", "Print?"), this function returns \c
HashContext.
\sa write()
*/
QTranslatorMessage::Prefix QTranslatorMessage::commonPrefix(
const QTranslatorMessage& m ) const
{
if ( h != m.h )
return NoPrefix;
if ( cx != m.cx )
return Hash;
if ( st != m.st )
return HashContext;
if ( cm != m.cm )
return HashContextSourceText;
return HashContextSourceTextComment;
}
/*!
Returns TRUE if the extended key of this object is equal to that of
\a m; otherwise returns FALSE.
*/
bool QTranslatorMessage::operator==( const QTranslatorMessage& m ) const
{
return h == m.h && cx == m.cx && st == m.st && cm == m.cm;
}
/*!
\fn bool QTranslatorMessage::operator!=( const QTranslatorMessage& m ) const
Returns TRUE if the extended key of this object is different from
that of \a m; otherwise returns FALSE.
*/
/*!
Returns TRUE if the extended key of this object is
lexicographically before than that of \a m; otherwise returns
FALSE.
*/
bool QTranslatorMessage::operator<( const QTranslatorMessage& m ) const
{
return h != m.h ? h < m.h
: ( cx != m.cx ? cx < m.cx
: (st != m.st ? st < m.st : cm < m.cm) );
}
/*!
\fn bool QTranslatorMessage::operator<=( const QTranslatorMessage& m ) const
Returns TRUE if the extended key of this object is
lexicographically before that of \a m or if they are equal;
otherwise returns FALSE.
*/
/*!
\fn bool QTranslatorMessage::operator>( const QTranslatorMessage& m ) const
Returns TRUE if the extended key of this object is
lexicographically after that of \a m; otherwise returns FALSE.
*/
/*!
\fn bool QTranslatorMessage::operator>=( const QTranslatorMessage& m ) const
Returns TRUE if the extended key of this object is
lexicographically after that of \a m or if they are equal;
otherwise returns FALSE.
*/
#endif // USE_QT4

@ -40,6 +40,57 @@ Boston, MA 02110-1301, USA.
#include <Qt/qtranslator.h>
//class Q_EXPORT QTranslatorMessage
class QTranslatorMessage
{
public:
QTranslatorMessage();
QTranslatorMessage( const char * context,
const char * sourceText,
const char * comment,
const QString& translation = QString::null );
QTranslatorMessage( QDataStream & );
QTranslatorMessage( const QTranslatorMessage & m );
QTranslatorMessage & operator=( const QTranslatorMessage & m );
uint hash() const { return h; }
const char *context() const { return cx; }
const char *sourceText() const { return st; }
const char *comment() const { return cm; }
void setTranslation( const QString & translation ) { tn = translation; }
QString translation() const { return tn; }
enum Prefix { NoPrefix, Hash, HashContext, HashContextSourceText,
HashContextSourceTextComment };
void write( QDataStream & s, bool strip = FALSE,
Prefix prefix = HashContextSourceTextComment ) const;
Prefix commonPrefix( const QTranslatorMessage& ) const;
bool operator==( const QTranslatorMessage& m ) const;
bool operator!=( const QTranslatorMessage& m ) const
{ return !operator==( m ); }
bool operator<( const QTranslatorMessage& m ) const;
bool operator<=( const QTranslatorMessage& m ) const
{ return !m.operator<( *this ); }
bool operator>( const QTranslatorMessage& m ) const
{ return m.operator<( *this ); }
bool operator>=( const QTranslatorMessage& m ) const
{ return !operator<( m ); }
private:
uint h;
Q3CString cx;
Q3CString st;
Q3CString cm;
QString tn;
enum Tag { Tag_End = 1, Tag_SourceText16, Tag_Translation, Tag_Context16,
Tag_Hash, Tag_SourceText, Tag_Context, Tag_Comment,
Tag_Obsolete1 };
};
#endif // USE_QT4
#endif /* TQTRANSLATOR_H */

@ -28,4 +28,8 @@ Qt::WidgetAttribute QWidget::testWState( Qt::WidgetAttribute s ) const {
return (Qt::WidgetAttribute)(data->widget_attributes & s);
}
Qt::WindowFlags QWidget::testWFlags( Qt::WindowFlags f ) const {
return (Qt::WindowFlags)(data->window_flags & f);
}
#endif // USE_QT4
Loading…
Cancel
Save