Remove Qt3 support functionality from parts of QtCore

Change-Id: I90f391e9bfc412087bd0401e28d2497571f81aa1
Reviewed-on: http://codereview.qt.nokia.com/825
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Liang Qi <liang.qi@nokia.com>
This commit is contained in:
Lars Knoll 2011-06-28 12:17:34 +02:00 committed by Qt by Nokia
parent fa65123a86
commit 118b3d3f84
9 changed files with 17 additions and 724 deletions

View File

@ -176,9 +176,6 @@ extern QString qAppFileName();
#endif
int QCoreApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0
#if defined(QT3_SUPPORT)
bool QCoreApplicationPrivate::useQt3Support = true;
#endif
#if !defined(Q_OS_WIN)
#ifdef Q_OS_MAC
@ -337,9 +334,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
in_exec(false), aboutToQuitEmitted(false)
{
app_compile_version = flags & 0xffffff;
#if defined(QT3_SUPPORT)
useQt3Support = !(flags & 0x01000000);
#endif
static const char *const empty = "";
if (argc == 0 || argv == 0) {
argc = 0;
@ -1370,20 +1364,6 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type
++data->postEventList.recursion;
#ifdef QT3_SUPPORT
if (event_type == QEvent::ChildInserted) {
if (receiver) {
// optimize sendPostedEvents(w, QEvent::ChildInserted) calls away
receiver->d_func()->sendPendingChildInsertedEvents();
--data->postEventList.recursion;
return;
}
// ChildInserted events are sent in response to *Request
event_type = QEvent::ChildInsertedRequest;
}
#endif
QMutexLocker locker(&data->postEventList.mutex);
// by default, we assume that the event dispatcher can go to sleep after
@ -1534,11 +1514,6 @@ void QCoreApplication::removePostedEvents(QObject *receiver)
void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
{
#ifdef QT3_SUPPORT
if (eventType == QEvent::ChildInserted)
eventType = QEvent::ChildInsertedRequest;
#endif
QThreadData *data = receiver ? receiver->d_func()->threadData : QThreadData::current();
QMutexLocker locker(&data->postEventList.mutex);
@ -1561,10 +1536,6 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
if ((!receiver || pe.receiver == receiver)
&& (pe.event && (eventType == 0 || pe.event->type() == eventType))) {
--pe.receiver->d_func()->postedEvents;
#ifdef QT3_SUPPORT
if (pe.event->type() == QEvent::ChildInsertedRequest)
pe.receiver->d_func()->pendingChildInsertedEvents.clear();
#endif
pe.event->posted = false;
events.append(pe.event);
const_cast<QPostEvent &>(pe).event = 0;
@ -2557,109 +2528,6 @@ bool QCoreApplication::hasPendingEvents()
return false;
}
#ifdef QT3_SUPPORT
/*! \fn void QCoreApplication::lock()
In Qt 3, this function locked the Qt library mutex, allowing
non-GUI threads to perform basic printing operations using
QPainter.
In Qt 4, this is no longer supported, since painting is only
supported from within a paint event handler. This function does
nothing.
\sa QWidget::paintEvent()
*/
/*! \fn void QCoreApplication::unlock(bool wakeUpGui)
In Qt 3, this function unlocked the Qt library mutex. The mutex
allowed non-GUI threads to perform basic printing operations
using QPainter.
In Qt 4, this is no longer supported, since painting is only
supported from within a paint event handler. This function does
nothing.
*/
/*! \fn bool QCoreApplication::locked()
This function does nothing. It is there to keep old code working.
It always returns false.
See lock() for details.
*/
/*! \fn bool QCoreApplication::tryLock()
This function does nothing. It is there to keep old code working.
It always returns false.
See lock() for details.
*/
/*! \fn void QCoreApplication::processOneEvent()
\obsolete
Waits for an event to occur, processes it, then returns.
This function is useful for adapting Qt to situations where the
event processing must be grafted onto existing program loops.
Using this function in new applications may be an indication of design
problems.
\sa processEvents(), exec(), QTimer
*/
/*! \obsolete
This function enters the main event loop (recursively). Do not call
it unless you really know what you are doing.
*/
int QCoreApplication::enter_loop()
{
if (!QCoreApplicationPrivate::checkInstance("enter_loop"))
return -1;
if (QThreadData::current() != self->d_func()->threadData) {
qWarning("QCoreApplication::enter_loop: Must be called from the main thread");
return -1;
}
QEventLoop eventLoop;
int returnCode = eventLoop.exec();
return returnCode;
}
/*! \obsolete
This function exits from a recursive call to the main event loop.
Do not call it unless you are an expert.
*/
void QCoreApplication::exit_loop()
{
if (!QCoreApplicationPrivate::checkInstance("exit_loop"))
return;
QThreadData *data = QThreadData::current();
if (data != self->d_func()->threadData) {
qWarning("QCoreApplication::exit_loop: Must be called from the main thread");
return;
}
if (!data->eventLoops.isEmpty())
data->eventLoops.top()->exit();
}
/*! \obsolete
Returns the current loop level.
*/
int QCoreApplication::loopLevel()
{
if (!QCoreApplicationPrivate::checkInstance("loopLevel"))
return -1;
return self->d_func()->threadData->eventLoops.size();
}
#endif
/*
\fn void QCoreApplication::watchUnixSignal(int signal, bool watch)
\internal

View File

@ -46,10 +46,6 @@
#include <QtCore/qcoreevent.h>
#include <QtCore/qeventloop.h>
#ifdef QT_INCLUDE_COMPAT
#include <QtCore/qstringlist.h>
#endif
#if defined(Q_WS_WIN) && !defined(tagMSG)
typedef struct tagMSG MSG;
#endif
@ -79,9 +75,6 @@ class Q_CORE_EXPORT QCoreApplication : public QObject
Q_DECLARE_PRIVATE(QCoreApplication)
public:
enum { ApplicationFlags = QT_VERSION
#if !defined(QT3_SUPPORT)
| 0x01000000
#endif
};
#if defined(QT_BUILD_CORE_LIB) || defined(qdoc)
@ -164,19 +157,6 @@ public:
static void flush();
#if defined(QT3_SUPPORT)
inline QT3_SUPPORT void lock() {}
inline QT3_SUPPORT void unlock(bool = true) {}
inline QT3_SUPPORT bool locked() { return false; }
inline QT3_SUPPORT bool tryLock() { return false; }
static inline QT3_SUPPORT void processOneEvent()
{ processEvents(QEventLoop::WaitForMoreEvents); }
static QT3_SUPPORT int enter_loop();
static QT3_SUPPORT void exit_loop();
static QT3_SUPPORT int loopLevel();
#endif
#if defined(Q_WS_WIN)
virtual bool winEventFilter(MSG *message, long *result);
#endif

View File

@ -504,65 +504,6 @@ QChildEvent::~QChildEvent()
false.
*/
/*!
\class QCustomEvent
\brief The QCustomEvent class provides support for custom events.
\compat
QCustomEvent has a \c{void *} that can be used to store custom
data.
In Qt 3, QObject::customEvent() took a QCustomEvent pointer. We
found out that this approach was unsatisfactory, because
there was often no safe way of deleting the data held in the
\c{void *}.
In Qt 4, QObject::customEvent() takes a plain QEvent pointer.
You can add custom data by subclassing.
\sa QObject::customEvent(), QCoreApplication::notify()
*/
/*!
\fn QCustomEvent::QCustomEvent(int type, void *data)
Constructs a custom event object with the event \a type and a
pointer to \a data. The value of \a type must be at least as
large as QEvent::User. By default, the data pointer is set to 0.
*/
#ifdef QT3_SUPPORT
QCustomEvent::QCustomEvent(int type, void *data)
: QEvent(static_cast<Type>(type))
{
d = reinterpret_cast<QEventPrivate *>(data);
}
/*! \internal
*/
QCustomEvent::~QCustomEvent()
{
}
#endif
/*!
\fn void QCustomEvent::setData(void *data)
\compat
Sets the generic data pointer to \a data.
\sa data()
*/
/*!
\fn void *QCustomEvent::data() const
\compat
Returns a pointer to the generic event data.
\sa setData()
*/
/*!
\fn bool QChildEvent::inserted() const

View File

@ -89,9 +89,6 @@ public:
Quit = 20, // request to quit application
ParentChange = 21, // widget has been reparented
ParentAboutToChange = 131, // sent just before the parent change is done
#ifdef QT3_SUPPORT
Reparent = ParentChange,
#endif
ThreadChange = 22, // object has changed threads
WindowActivate = 24, // window was activated
WindowDeactivate = 25, // window was deactivated
@ -118,11 +115,6 @@ public:
DragResponse = 64, // drag accepted/rejected
ChildAdded = 68, // new child widget
ChildPolished = 69, // polished child widget
#ifdef QT3_SUPPORT
ChildInsertedRequest = 67, // send ChildInserted compatibility events to receiver
ChildInserted = 70, // compatibility child inserted
LayoutHint = 72, // compatibility relayout request
#endif
ChildRemoved = 71, // deleted child widget
ShowWindowRequest = 73, // widget's window should be mapped
PolishRequest = 74, // widget should be polished
@ -357,26 +349,12 @@ public:
~QChildEvent();
QObject *child() const { return c; }
bool added() const { return type() == ChildAdded; }
#ifdef QT3_SUPPORT
QT3_SUPPORT bool inserted() const { return type() == ChildInserted; }
#endif
bool polished() const { return type() == ChildPolished; }
bool removed() const { return type() == ChildRemoved; }
protected:
QObject *c;
};
#ifdef QT3_SUPPORT
class Q_CORE_EXPORT QCustomEvent : public QEvent
{
public:
QT3_SUPPORT_CONSTRUCTOR QCustomEvent(int type, void *data = 0);
~QCustomEvent();
QT3_SUPPORT void *data() const { return d; }
QT3_SUPPORT void setData(void* aData) { d = reinterpret_cast<QEventPrivate *>(aData); }
};
#endif
class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent
{
public:

View File

@ -202,22 +202,6 @@ void QObjectPrivate::resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int dele
}
#endif
#ifdef QT3_SUPPORT
void QObjectPrivate::sendPendingChildInsertedEvents()
{
Q_Q(QObject);
for (int i = 0; i < pendingChildInsertedEvents.size(); ++i) {
QObject *c = pendingChildInsertedEvents.at(i).data();
if (!c || c->parent() != q)
continue;
QChildEvent childEvent(QEvent::ChildInserted, c);
QCoreApplication::sendEvent(q, &childEvent);
}
pendingChildInsertedEvents.clear();
}
#endif
/*!\internal
For a given metaobject, compute the signal offset, and the method offset (including signals)
@ -736,29 +720,6 @@ QObject::QObject(QObject *parent)
qt_addObject(this);
}
#ifdef QT3_SUPPORT
/*!
\overload QObject()
\obsolete
Creates a new QObject with the given \a parent and object \a name.
*/
QObject::QObject(QObject *parent, const char *name)
: d_ptr(new QObjectPrivate)
{
Q_D(QObject);
qt_addObject(d_ptr->q_ptr = this);
d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
d->threadData->ref();
if (parent) {
if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
parent = 0;
setParent(parent);
}
setObjectName(QString::fromAscii(name));
}
#endif
/*! \internal
*/
QObject::QObject(QObjectPrivate &dd, QObject *parent)
@ -1078,56 +1039,6 @@ void QObject::setObjectName(const QString &name)
d->declarativeData->objectNameChanged(d->declarativeData, this);
}
#ifdef QT3_SUPPORT
/*! \internal
QObject::child is compat but needs to call itself recursively,
that's why we need this helper.
*/
static QObject *qChildHelper(const char *objName, const char *inheritsClass,
bool recursiveSearch, const QObjectList &children)
{
if (children.isEmpty())
return 0;
bool onlyWidgets = (inheritsClass && qstrcmp(inheritsClass, "QWidget") == 0);
const QLatin1String oName(objName);
for (int i = 0; i < children.size(); ++i) {
QObject *obj = children.at(i);
if (onlyWidgets) {
if (obj->isWidgetType() && (!objName || obj->objectName() == oName))
return obj;
} else if ((!inheritsClass || obj->inherits(inheritsClass))
&& (!objName || obj->objectName() == oName))
return obj;
if (recursiveSearch && (obj = qChildHelper(objName, inheritsClass,
recursiveSearch, obj->children())))
return obj;
}
return 0;
}
/*!
Searches the children and optionally grandchildren of this object,
and returns a child that is called \a objName that inherits \a
inheritsClass. If \a inheritsClass is 0 (the default), any class
matches.
If \a recursiveSearch is true (the default), child() performs a
depth-first search of the object's children.
If there is no such object, this function returns 0. If there are
more than one, the first one found is returned.
*/
QObject* QObject::child(const char *objName, const char *inheritsClass,
bool recursiveSearch) const
{
Q_D(const QObject);
return qChildHelper(objName, inheritsClass, recursiveSearch, d->children);
}
#endif
/*!
\fn bool QObject::isWidgetType() const
@ -1156,17 +1067,8 @@ bool QObject::event(QEvent *e)
timerEvent((QTimerEvent*)e);
break;
#ifdef QT3_SUPPORT
case QEvent::ChildInsertedRequest:
d_func()->sendPendingChildInsertedEvents();
break;
#endif
case QEvent::ChildAdded:
case QEvent::ChildPolished:
#ifdef QT3_SUPPORT
case QEvent::ChildInserted:
#endif
case QEvent::ChildRemoved:
childEvent((QChildEvent*)e);
break;
@ -1635,102 +1537,6 @@ void QObject::killTimer(int id)
\sa findChild(), findChildren(), parent(), setParent()
*/
#ifdef QT3_SUPPORT
static void objSearch(QObjectList &result,
const QObjectList &list,
const char *inheritsClass,
bool onlyWidgets,
const char *objName,
QRegExp *rx,
bool recurse)
{
for (int i = 0; i < list.size(); ++i) {
QObject *obj = list.at(i);
if (!obj)
continue;
bool ok = true;
if (onlyWidgets)
ok = obj->isWidgetType();
else if (inheritsClass && !obj->inherits(inheritsClass))
ok = false;
if (ok) {
if (objName)
ok = (obj->objectName() == QLatin1String(objName));
#ifndef QT_NO_REGEXP
else if (rx)
ok = (rx->indexIn(obj->objectName()) != -1);
#endif
}
if (ok) // match!
result.append(obj);
if (recurse) {
QObjectList clist = obj->children();
if (!clist.isEmpty())
objSearch(result, clist, inheritsClass,
onlyWidgets, objName, rx, recurse);
}
}
}
/*!
\internal
Searches the children and optionally grandchildren of this object,
and returns a list of those objects that are named or that match
\a objName and inherit \a inheritsClass. If \a inheritsClass is 0
(the default), all classes match. If \a objName is 0 (the
default), all object names match.
If \a regexpMatch is true (the default), \a objName is a regular
expression that the objects's names must match. The syntax is that
of a QRegExp. If \a regexpMatch is false, \a objName is a string
and object names must match it exactly.
Note that \a inheritsClass uses single inheritance from QObject,
the way inherits() does. According to inherits(), QWidget
inherits QObject but not QPaintDevice. This does not quite match
reality, but is the best that can be done on the wide variety of
compilers Qt supports.
Finally, if \a recursiveSearch is true (the default), queryList()
searches \e{n}th-generation as well as first-generation children.
If all this seems a bit complex for your needs, the simpler
child() function may be what you want.
This somewhat contrived example disables all the buttons in this
window:
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 9
\warning Delete the list as soon you have finished using it. The
list contains pointers that may become invalid at almost any time
without notice (as soon as the user closes a window you may have
dangling pointers, for example).
\sa child() children(), parent(), inherits(), objectName(), QRegExp
*/
QObjectList QObject::queryList(const char *inheritsClass,
const char *objName,
bool regexpMatch,
bool recursiveSearch) const
{
Q_D(const QObject);
QObjectList list;
bool onlyWidgets = (inheritsClass && qstrcmp(inheritsClass, "QWidget") == 0);
#ifndef QT_NO_REGEXP
if (regexpMatch && objName) { // regexp matching
QRegExp rx(QString::fromLatin1(objName));
objSearch(list, d->children, inheritsClass, onlyWidgets, 0, &rx, recursiveSearch);
} else
#endif
{
objSearch(list, d->children, inheritsClass, onlyWidgets, objName, 0, recursiveSearch);
}
return list;
}
#endif
/*!
\fn T *QObject::findChild(const QString &name) const
@ -1948,16 +1754,6 @@ void QObjectPrivate::setParent_helper(QObject *o)
if (!isWidget) {
QChildEvent e(QEvent::ChildAdded, q);
QCoreApplication::sendEvent(parent, &e);
#ifdef QT3_SUPPORT
if (QCoreApplicationPrivate::useQt3Support) {
if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) {
QCoreApplication::postEvent(parent,
new QEvent(QEvent::ChildInsertedRequest),
Qt::HighEventPriority);
}
parent->d_func()->pendingChildInsertedEvents.append(q);
}
#endif
}
}
}

View File

@ -186,14 +186,6 @@ public:
}
#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; }
void setParent(QObject *);
@ -202,44 +194,14 @@ public:
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
);
const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection);
static bool connect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &method,
Qt::ConnectionType type =
#ifdef qdoc
Qt::AutoConnection
#else
#ifdef QT3_SUPPORT
Qt::AutoCompatConnection
#else
Qt::AutoConnection
#endif
#endif
);
Qt::ConnectionType type = Qt::AutoConnection);
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;
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
static bool disconnect(const QObject *sender, const char *signal,
const QObject *receiver, const char *member);
@ -290,29 +252,6 @@ protected:
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);

View File

@ -157,10 +157,6 @@ public:
void addConnection(int signal, Connection *c);
void cleanConnectionLists();
#ifdef QT3_SUPPORT
void sendPendingChildInsertedEvents();
#endif
static inline Sender *setCurrentSender(QObject *receiver,
Sender *sender);
static inline void resetCurrentSender(QObject *receiver,
@ -190,14 +186,6 @@ public:
Sender *currentSender; // object currently activating the object
mutable quint32 connectedSignals[2];
#ifdef QT3_SUPPORT
QVector< QWeakPointer<QObject> > pendingChildInsertedEvents;
#else
// preserve binary compatibility with code compiled without Qt 3 support
// keeping the binary layout stable helps the Qt Creator debugger
void *unused;
#endif
QList<QPointer<QObject> > eventFilters;
union {
QObject *currentChildBeingDeleted;

View File

@ -102,10 +102,6 @@ QT_BEGIN_NAMESPACE
QTextCodec *QString::codecForCStrings;
#endif
#ifdef QT3_SUPPORT
static QHash<void *, QByteArray> *asciiCache = 0;
#endif
#ifdef QT_USE_ICU
// qlocale_icu.cpp
extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result);
@ -802,9 +798,9 @@ const QString::Null QString::null = { };
*/
QString::Data QString::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1),
0, 0, shared_null.array, 0, 0, 0, 0, 0, 0, {0} };
0, 0, shared_null.array, 0, 0, 0, 0, 0, {0} };
QString::Data QString::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1),
0, 0, shared_empty.array, 0, 0, 0, 0, 0, 0, {0} };
0, 0, shared_empty.array, 0, 0, 0, 0, 0, {0} };
int QString::grow(int size)
{
@ -1058,7 +1054,7 @@ QString::QString(const QChar *unicode, int size)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
memcpy(d->array, unicode, size * sizeof(QChar));
d->array[size] = '\0';
@ -1091,7 +1087,7 @@ QString::QString(const QChar *unicode)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
memcpy(d->array, unicode, size * sizeof(QChar));
d->array[size] = '\0';
@ -1116,7 +1112,7 @@ QString::QString(int size, QChar ch)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
d->array[size] = '\0';
ushort *i = d->array + size;
@ -1139,7 +1135,7 @@ QString::QString(int size, Qt::Initialization)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
d->array[size] = '\0';
}
@ -1161,7 +1157,7 @@ QString::QString(QChar ch)
d = reinterpret_cast<Data *>(buf);
d->ref = 1;
d->alloc = d->size = 1;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
d->array[0] = ch.unicode();
d->array[1] = '\0';
@ -1222,12 +1218,6 @@ QString::QString(QChar ch)
// ### Qt 5: rename freeData() to avoid confusion. See task 197625.
void QString::free(Data *d)
{
#ifdef QT3_SUPPORT
if (d->asciiCache) {
Q_ASSERT(asciiCache);
asciiCache->remove(d);
}
#endif
qFree(d);
}
@ -1344,7 +1334,6 @@ void QString::realloc(int alloc)
x->size = qMin(alloc, d->size);
::memcpy(x->array, d->data, x->size * sizeof(QChar));
x->array[x->size] = 0;
x->asciiCache = 0;
x->ref = 1;
x->alloc = alloc;
x->clean = d->clean;
@ -1356,12 +1345,6 @@ void QString::realloc(int alloc)
QString::free(d);
d = x;
} else {
#ifdef QT3_SUPPORT
if (d->asciiCache) {
Q_ASSERT(asciiCache);
asciiCache->remove(d);
}
#endif
Data *p = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar)));
Q_CHECK_PTR(p);
d = p;
@ -3794,7 +3777,7 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
d->array[size] = '\0';
ushort *dst = d->data;
@ -3868,44 +3851,6 @@ QString QString::fromLatin1(const char *str, int size)
}
#ifdef QT3_SUPPORT
/*!
\internal
*/
const char *QString::ascii_helper() const
{
if (!asciiCache)
asciiCache = new QHash<void *, QByteArray>();
d->asciiCache = true;
QByteArray ascii = toAscii();
QByteArray old = asciiCache->value(d);
if (old == ascii)
return old.constData();
asciiCache->insert(d, ascii);
return ascii.constData();
}
/*!
\internal
*/
const char *QString::latin1_helper() const
{
if (!asciiCache)
asciiCache = new QHash<void *, QByteArray>();
d->asciiCache = true;
QByteArray ascii = toLatin1();
QByteArray old = asciiCache->value(d);
if (old == ascii)
return old.constData();
asciiCache->insert(d, ascii);
return ascii.constData();
}
#endif
/*!
Returns a QString initialized with the first \a size characters
of the 8-bit string \a str.
@ -4636,25 +4581,16 @@ QString& QString::fill(QChar ch, int size)
sensitivity setting \a cs.
*/
/*!
\overload compare()
\since 4.2
Lexically compares this string with the \a other string and
returns an integer less than, equal to, or greater than zero if
this string is less than, equal to, or greater than the other
string.
Equivalent to \c {compare(*this, other)}.
*/
int QString::compare(const QString &other) const
{
return ucstrcmp(constData(), length(), other.constData(), other.length());
}
/*!
\overload compare()
\since 4.2
Same as compare(*this, \a other, \a cs).
*/
int QString::compare(const QString &other, Qt::CaseSensitivity cs) const
@ -7196,7 +7132,7 @@ QString QString::fromRawData(const QChar *unicode, int size)
x->ref = 1;
x->alloc = x->size = size;
*x->array = '\0';
x->clean = x->asciiCache = x->simpletext = x->righttoleft = x->capacity = 0;
x->clean = x->simpletext = x->righttoleft = x->capacity = 0;
return QString(x, 0);
}
@ -7219,12 +7155,6 @@ QString &QString::setRawData(const QChar *unicode, int size)
if (d->ref != 1 || (d->data == d->array && d->alloc)) {
*this = fromRawData(unicode, size);
} else {
#ifdef QT3_SUPPORT
if (d->asciiCache) {
Q_ASSERT(asciiCache);
asciiCache->remove(d);
}
#endif
if (unicode) {
d->data = (ushort *)unicode;
} else {
@ -7233,7 +7163,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
}
d->alloc = d->size = size;
*d->array = '\0';
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
}
return *this;
}

View File

@ -46,9 +46,6 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qatomic.h>
#include <QtCore/qnamespace.h>
#ifdef QT_INCLUDE_COMPAT
#include <Qt3Support/q3cstring.h>
#endif
#ifndef QT_NO_STL
# include <string>
@ -340,16 +337,10 @@ public:
QString &setUnicode(const QChar *unicode, int size);
inline QString &setUtf16(const ushort *utf16, int size);
// ### Qt 5: merge these two functions
int compare(const QString &s) const;
int compare(const QString &s, Qt::CaseSensitivity cs) const;
int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int compare(const QLatin1String &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
// ### Qt 5: merge these two functions
static inline int compare(const QString &s1, const QString &s2)
{ return s1.compare(s2); }
static inline int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
static inline int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
{ return s1.compare(s2, cs); }
static inline int compare(const QString& s1, const QLatin1String &s2,
@ -504,86 +495,6 @@ public:
inline QString &operator=(const Null &) { *this = QString(); return *this; }
inline bool isNull() const { return d == &shared_null; }
#ifdef QT3_SUPPORT
inline QT3_SUPPORT const char *ascii() const { return ascii_helper(); }
inline QT3_SUPPORT const char *latin1() const { return latin1_helper(); }
inline QT3_SUPPORT QByteArray utf8() const { return toUtf8(); }
inline QT3_SUPPORT QByteArray local8Bit() const{ return toLocal8Bit(); }
inline QT3_SUPPORT void setLength(int nl) { resize(nl); }
inline QT3_SUPPORT QString copy() const { return *this; }
inline QT3_SUPPORT QString &remove(QChar c, bool cs)
{ return remove(c, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT QString &remove(const QString &s, bool cs)
{ return remove(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT QString &replace(QChar c, const QString &after, bool cs)
{ return replace(c, after, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT QString &replace(const QString &before, const QString &after, bool cs)
{ return replace(before, after, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
#ifndef QT_NO_CAST_FROM_ASCII
inline QT3_SUPPORT QString &replace(char c, const QString &after, bool cs)
{ return replace(QChar::fromAscii(c), after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); }
// strange overload, required to avoid GCC 3.3 error
inline QT3_SUPPORT QString &replace(char c, const QString &after, Qt::CaseSensitivity cs)
{ return replace(QChar::fromAscii(c), after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); }
#endif
inline QT3_SUPPORT int find(QChar c, int i = 0, bool cs = true) const
{ return indexOf(c, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT int find(const QString &s, int i = 0, bool cs = true) const
{ return indexOf(s, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT int findRev(QChar c, int i = -1, bool cs = true) const
{ return lastIndexOf(c, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT int findRev(const QString &s, int i = -1, bool cs = true) const
{ return lastIndexOf(s, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
#ifndef QT_NO_REGEXP
inline QT3_SUPPORT int find(const QRegExp &rx, int i=0) const
{ return indexOf(rx, i); }
inline QT3_SUPPORT int findRev(const QRegExp &rx, int i=-1) const
{ return lastIndexOf(rx, i); }
inline QT3_SUPPORT int find(QRegExp &rx, int i=0) const
{ return indexOf(rx, i); }
inline QT3_SUPPORT int findRev(QRegExp &rx, int i=-1) const
{ return lastIndexOf(rx, i); }
#endif
inline QT3_SUPPORT QBool contains(QChar c, bool cs) const
{ return contains(c, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT QBool contains(const QString &s, bool cs) const
{ return contains(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT bool startsWith(const QString &s, bool cs) const
{ return startsWith(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT bool endsWith(const QString &s, bool cs) const
{ return endsWith(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
inline QT3_SUPPORT QChar constref(uint i) const
{ return at(i); }
QT3_SUPPORT QChar &ref(uint i);
inline QT3_SUPPORT QString leftJustify(int width, QChar aFill = QLatin1Char(' '), bool trunc=false) const
{ return leftJustified(width, aFill, trunc); }
inline QT3_SUPPORT QString rightJustify(int width, QChar aFill = QLatin1Char(' '), bool trunc=false) const
{ return rightJustified(width, aFill, trunc); }
inline QT3_SUPPORT QString lower() const { return toLower(); }
inline QT3_SUPPORT QString upper() const { return toUpper(); }
inline QT3_SUPPORT QString stripWhiteSpace() const { return trimmed(); }
inline QT3_SUPPORT QString simplifyWhiteSpace() const { return simplified(); }
inline QT3_SUPPORT QString &setUnicodeCodes(const ushort *unicode_as_ushorts, int aSize)
{ return setUtf16(unicode_as_ushorts, aSize); }
inline QT3_SUPPORT const ushort *ucs2() const { return utf16(); }
inline static QT3_SUPPORT QString fromUcs2(const ushort *unicode, int size = -1)
{ return fromUtf16(unicode, size); }
inline QT3_SUPPORT QString &setAscii(const char *str, int len = -1)
{ *this = fromAscii(str, len); return *this; }
inline QT3_SUPPORT QString &setLatin1(const char *str, int len = -1)
{ *this = fromLatin1(str, len); return *this; }
protected:
friend class QObject;
const char *ascii_helper() const;
const char *latin1_helper() const;
public:
#ifndef QT_NO_CAST_TO_ASCII
inline QT3_SUPPORT operator const char *() const { return ascii_helper(); }
private:
QT3_SUPPORT operator QNoImplicitBoolCast() const;
public:
#endif
#endif
bool isSimpleText() const { if (!d->clean) updateProperties(); return d->simpletext; }
bool isRightToLeft() const;
@ -607,7 +518,6 @@ private:
ushort clean : 1;
ushort simpletext : 1;
ushort righttoleft : 1;
ushort asciiCache : 1;
ushort capacity : 1;
ushort reserved : 11;
// ### Qt5: try to ensure that "array" is aligned to 16 bytes on both 32- and 64-bit
@ -857,18 +767,6 @@ public:
#endif
ushort& unicode() { return s.data()[i].unicode(); }
#ifdef QT3_SUPPORT
inline QT3_SUPPORT bool mirrored() const { return hasMirrored(); }
inline QT3_SUPPORT QChar lower() const { return QChar(*this).toLower(); }
inline QT3_SUPPORT QChar upper() const { return QChar(*this).toUpper(); }
#ifdef Q_COMPILER_MANGLES_RETURN_TYPE
const QT3_SUPPORT char latin1() const { return QChar(*this).toLatin1(); }
const QT3_SUPPORT char ascii() const { return QChar(*this).toAscii(); }
#else
QT3_SUPPORT char latin1() const { return QChar(*this).toLatin1(); }
QT3_SUPPORT char ascii() const { return QChar(*this).toAscii(); }
#endif
#endif
};
inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); }
@ -1008,12 +906,6 @@ inline int QByteArray::indexOf(const QString &s, int from) const
{ return indexOf(s.toAscii(), from); }
inline int QByteArray::lastIndexOf(const QString &s, int from) const
{ return lastIndexOf(s.toAscii(), from); }
# ifdef QT3_SUPPORT
inline int QByteArray::find(const QString &s, int from) const
{ return indexOf(s.toAscii(), from); }
inline int QByteArray::findRev(const QString &s, int from) const
{ return lastIndexOf(s.toAscii(), from); }
# endif // QT3_SUPPORT
#endif // QT_NO_CAST_TO_ASCII
#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
@ -1066,30 +958,11 @@ inline QString QString::fromStdWString(const QStdWString &s)
# endif
#endif
#ifdef QT3_SUPPORT
inline QChar &QString::ref(uint i)
{
if (int(i) > d->size || d->ref != 1)
resize(qMax(int(i), d->size));
return reinterpret_cast<QChar&>(d->data[i]);
}
#endif
#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QString &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QString &);
#endif
#ifdef QT3_SUPPORT
class QConstString : public QString
{
public:
inline QT3_SUPPORT_CONSTRUCTOR QConstString(const QChar *aUnicode, int aSize)
:QString(aUnicode, aSize){} // cannot use fromRawData() due to changed semantics
inline QT3_SUPPORT const QString &string() const { return *this; }
};
#endif
Q_DECLARE_TYPEINFO(QString, Q_MOVABLE_TYPE);
Q_DECLARE_SHARED(QString)
Q_DECLARE_OPERATORS_FOR_FLAGS(QString::SectionFlags)