diff options
80 files changed, 1009 insertions, 950 deletions
diff --git a/qmake/generators/symbian/symbian_makefile.h b/qmake/generators/symbian/symbian_makefile.h index f9d3c24..289f9ae 100644 --- a/qmake/generators/symbian/symbian_makefile.h +++ b/qmake/generators/symbian/symbian_makefile.h @@ -71,8 +71,9 @@ public: if (targetType == TypeExe) { generatePkg = true; } else { - foreach(QString item, this->project->values("DEPLOYMENT")) { - if (!this->project->values(item + ".sources").isEmpty()) { + const QStringList deployments = this->project->values("DEPLOYMENT"); + for (int i = 0; i < deployments.count(); ++i) { + if (!this->project->values(deployments.at(i) + ".sources").isEmpty()) { generatePkg = true; break; } diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StructureTransitionTable.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StructureTransitionTable.h index 35fb7e4..2ecf0d3 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StructureTransitionTable.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StructureTransitionTable.h @@ -143,14 +143,14 @@ namespace JSC { if (!specificValue) { TransitionTable::iterator find = table()->find(key); if (find == table()->end()) - table()->add(key, Transition(structure, 0)); + table()->add(key, Transition(structure, (Structure*)0)); else find->second.first = structure; } else { // If we're adding a transition to a specific value, then there cannot be // an existing transition ASSERT(!table()->contains(key)); - table()->add(key, Transition(0, structure)); + table()->add(key, Transition((Structure*)0, structure)); } } diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h index 5b655e8..85c8743 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h @@ -239,7 +239,7 @@ inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Bar inline int atomicIncrement(int volatile* addend) { return android_atomic_inc(addend); } inline int atomicDecrement(int volatile* addend) { return android_atomic_dec(addend); } -#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !defined(__SYMBIAN32__) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc +#elif COMPILER(GCC) && !CPU(SPARC64) && !defined(__SYMBIAN32__) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc #define WTF_USE_LOCKFREE_THREADSAFESHARED 1 inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; } diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/StructureTransitionTable.h b/src/3rdparty/webkit/JavaScriptCore/runtime/StructureTransitionTable.h index 0fa7b73..f39560a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/StructureTransitionTable.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/StructureTransitionTable.h @@ -143,14 +143,14 @@ namespace JSC { if (!specificValue) { TransitionTable::iterator find = table()->find(key); if (find == table()->end()) - table()->add(key, Transition(structure, 0)); + table()->add(key, Transition(structure, (Structure*)0)); else find->second.first = structure; } else { // If we're adding a transition to a specific value, then there cannot be // an existing transition ASSERT(!table()->contains(key)); - table()->add(key, Transition(0, structure)); + table()->add(key, Transition((Structure*)0, structure)); } } diff --git a/src/corelib/concurrent/qthreadpool.cpp b/src/corelib/concurrent/qthreadpool.cpp index 9e4189e..a4057f1 100644 --- a/src/corelib/concurrent/qthreadpool.cpp +++ b/src/corelib/concurrent/qthreadpool.cpp @@ -41,6 +41,7 @@ #include "qthreadpool.h" #include "qthreadpool_p.h" +#include "qelapsedtimer.h" #ifndef QT_NO_THREAD @@ -288,11 +289,18 @@ void QThreadPoolPrivate::reset() isExiting = false; } -void QThreadPoolPrivate::waitForDone() +void QThreadPoolPrivate::waitForDone(int msecs) { QMutexLocker locker(&mutex); - while (!(queue.isEmpty() && activeThreads == 0)) - noActiveThreads.wait(locker.mutex()); + if (msecs < 0){ + while (!(queue.isEmpty() && activeThreads == 0)) + noActiveThreads.wait(locker.mutex()); + } else { + QElapsedTimer timer; + timer.start(); + while (!(queue.isEmpty() && activeThreads == 0) && (timer.elapsed() < msecs)) + noActiveThreads.wait(locker.mutex(), msecs - timer.elapsed()); + } } /*! \internal @@ -610,10 +618,10 @@ void QThreadPool::releaseThread() /*! Waits for each thread to exit and removes all threads from the thread pool. */ -void QThreadPool::waitForDone() +void QThreadPool::waitForDone(int msecs) { Q_D(QThreadPool); - d->waitForDone(); + d->waitForDone(msecs); d->reset(); } diff --git a/src/corelib/concurrent/qthreadpool.h b/src/corelib/concurrent/qthreadpool.h index cc1e059..9895c41 100644 --- a/src/corelib/concurrent/qthreadpool.h +++ b/src/corelib/concurrent/qthreadpool.h @@ -84,7 +84,7 @@ public: void reserveThread(); void releaseThread(); - void waitForDone(); + void waitForDone(int msecs = -1); }; QT_END_NAMESPACE diff --git a/src/corelib/concurrent/qthreadpool_p.h b/src/corelib/concurrent/qthreadpool_p.h index 8a2cf98..1a0e4ab 100644 --- a/src/corelib/concurrent/qthreadpool_p.h +++ b/src/corelib/concurrent/qthreadpool_p.h @@ -82,7 +82,7 @@ public: void startThread(QRunnable *runnable = 0); void reset(); - void waitForDone(); + void waitForDone(int msecs = -1); bool startFrontRunnable(); void stealRunnable(QRunnable *); diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index eb42c20..417439f 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qwindowspipewriter_p.h" +#include <string.h> QT_BEGIN_NAMESPACE @@ -100,7 +101,8 @@ qint64 QWindowsPipeWriter::write(const char *ptr, qint64 maxlen) void QWindowsPipeWriter::run() { - OVERLAPPED overl = {0, 0, {{ 0 }}, 0}; + OVERLAPPED overl; + memset(&overl, 0, sizeof overl); overl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); forever { lock.lock(); diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index d0dad49..1851e04 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -33,7 +33,6 @@ HEADERS += \ kernel/qsystemsemaphore.h \ kernel/qsystemsemaphore_p.h \ kernel/qfunctions_p.h \ - kernel/qguard_p.h \ kernel/qmath.h SOURCES += \ diff --git a/src/corelib/kernel/qguard_p.h b/src/corelib/kernel/qguard_p.h deleted file mode 100644 index 0f7fd94..0000000 --- a/src/corelib/kernel/qguard_p.h +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGUARD_P_H -#define QGUARD_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// - -#include "QtCore/qglobal.h" - -QT_BEGIN_NAMESPACE - -class QObject; -template<class T> -class QGuard -{ - QObject *o; - QGuard<QObject> *next; - QGuard<QObject> **prev; - friend void q_guard_addGuard(QGuard<QObject> *); - friend void q_guard_removeGuard(QGuard<QObject> *); - friend class QObjectPrivate; -public: - inline QGuard(); - inline QGuard(T *); - inline QGuard(const QGuard<T> &); - inline virtual ~QGuard(); - - inline QGuard<T> &operator=(const QGuard<T> &o); - inline QGuard<T> &operator=(T *); - - inline bool isNull() const - { return !o; } - - inline T* operator->() const - { return static_cast<T*>(const_cast<QObject*>(o)); } - inline T& operator*() const - { return *static_cast<T*>(const_cast<QObject*>(o)); } - inline operator T*() const - { return static_cast<T*>(const_cast<QObject*>(o)); } - inline T* data() const - { return static_cast<T*>(const_cast<QObject*>(o)); } - -protected: - virtual void objectDestroyed(T *) {} -}; - -QT_END_NAMESPACE - -#include "private/qobject_p.h" - -QT_BEGIN_NAMESPACE - -inline void q_guard_addGuard(QGuard<QObject> *); -inline void q_guard_removeGuard(QGuard<QObject> *); - -template<class T> -QGuard<T>::QGuard() -: o(0), next(0), prev(0) -{ -} - -template<class T> -QGuard<T>::QGuard(T *g) -: o(g), next(0), prev(0) -{ - if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this)); -} - -template<class T> -QGuard<T>::QGuard(const QGuard<T> &g) -: o(g.o), next(0), prev(0) -{ - if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this)); -} - -template<class T> -QGuard<T>::~QGuard() -{ - if (prev) q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this)); - o = 0; -} - -template<class T> -QGuard<T> &QGuard<T>::operator=(const QGuard<T> &g) -{ - if (g.o != o) { - if (prev) - q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this)); - o = g.o; - if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this)); - } - return *this; -} - -template<class T> -inline QGuard<T> &QGuard<T>::operator=(T *g) -{ - if (g != o) { - if (prev) - q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this)); - o = g; - if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this)); - } - return *this; -} - -QT_END_NAMESPACE - -#endif // QGUARD_P_H diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 53c5b3b..330de20 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -496,15 +496,6 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o) void QObjectPrivate::clearGuards(QObject *object) { QObjectPrivate *priv = QObjectPrivate::get(object); - QGuard<QObject> *guard = priv->extraData ? priv->extraData->objectGuards : 0; - while (guard) { - QGuard<QObject> *g = guard; - guard = guard->next; - g->o = 0; - g->prev = 0; - g->next = 0; - g->objectDestroyed(object); - } if (!priv->hasGuards) return; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 20e3da1..3b59abb 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -60,7 +60,6 @@ #include "QtCore/qvector.h" #include "QtCore/qreadwritelock.h" #include "QtCore/qvariant.h" -#include "private/qguard_p.h" QT_BEGIN_NAMESPACE @@ -100,13 +99,12 @@ class Q_CORE_EXPORT QObjectPrivate : public QObjectData public: struct ExtraData { - ExtraData() : objectGuards(0) {} + ExtraData() {} #ifndef QT_NO_USERDATA QVector<QObjectUserData *> userData; #endif QList<QByteArray> propertyNames; QList<QVariant> propertyValues; - QGuard<QObject> *objectGuards; //linked list handle of QGuards }; struct Connection @@ -224,33 +222,6 @@ inline bool QObjectPrivate::isSignalConnected(uint signal_index) const } -inline void q_guard_addGuard(QGuard<QObject> *g) -{ - QObjectPrivate *p = QObjectPrivate::get(g->o); - if (p->wasDeleted) { - qWarning("QGuard: cannot add guard to deleted object"); - g->o = 0; - return; - } - - if (!p->extraData) - p->extraData = new QObjectPrivate::ExtraData; - - g->next = p->extraData->objectGuards; - p->extraData->objectGuards = g; - g->prev = &p->extraData->objectGuards; - if (g->next) - g->next->prev = &g->next; -} - -inline void q_guard_removeGuard(QGuard<QObject> *g) -{ - if (g->next) g->next->prev = g->prev; - *g->prev = g->next; - g->next = 0; - g->prev = 0; -} - Q_DECLARE_TYPEINFO(QObjectPrivate::Connection, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QObjectPrivate::Sender, Q_MOVABLE_TYPE); diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 3e34d62..459d76a 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2318,17 +2318,35 @@ void QDateTime::setTimeSpec(Qt::TimeSpec spec) } } -static uint toTime_tHelper(const QDate &utcDate, const QTime &utcTime) +qint64 toMSecsSinceEpoch_helper(qint64 jd, int msecs) { - int days = QDate(1970, 1, 1).daysTo(utcDate); - int secs = QTime().secsTo(utcTime); - if (days < 0 || (days == 0 && secs < 0)) - return uint(-1); + int days = jd - julianDayFromGregorianDate(1970, 1, 1); + qint64 retval = (qlonglong(days) * MSECS_PER_DAY) + msecs; + return retval; +} - qlonglong retval = (qlonglong(days) * SECS_PER_DAY) + secs; - if (retval >= Q_INT64_C(0xFFFFFFFF)) - return uint(-1); - return uint(retval); +/*! + \since 4.7 + + Returns the datetime as the number of milliseconds that have passed + since 1970-01-01T00:00:00.000, Coordinated Universal Time (Qt::UTC). + + On systems that do not support time zones, this function will + behave as if local time were Qt::UTC. + + The behavior for this function is undefined if the datetime stored in + this object is not valid. However, for all valid dates, this function + returns a unique value. + + \sa toTime_t(), setMSecsSinceEpoch() +*/ +qint64 QDateTime::toMSecsSinceEpoch() const +{ + QDate utcDate; + QTime utcTime; + d->getUTC(utcDate, utcTime); + + return toMSecsSinceEpoch_helper(utcDate.jd, utcTime.ds()); } /*! @@ -2338,16 +2356,63 @@ static uint toTime_tHelper(const QDate &utcDate, const QTime &utcTime) On systems that do not support time zones, this function will behave as if local time were Qt::UTC. - \sa setTime_t() + \note This function returns a 32-bit unsigned integer, so it does not + support dates before 1970, but it does support dates after + 2038-01-19T03:14:06, which may not be valid time_t values. Be careful + when passing those time_t values to system functions, which could + interpret them as negative dates. + + If the date is outside the range 1970-01-01T00:00:00 to + 2106-02-07T06:28:14, this function returns -1 cast to an unsigned integer + (i.e., 0xFFFFFFFF). + + To get an extended range, use toMSecsSinceEpoch(). + + \sa toMSecsSinceEpoch(), setTime_t() */ uint QDateTime::toTime_t() const { - QDate utcDate; - QTime utcTime; - d->getUTC(utcDate, utcTime); + qint64 retval = toMSecsSinceEpoch() / 1000; + if (quint64(retval) >= Q_UINT64_C(0xFFFFFFFF)) + return uint(-1); + return uint(retval); +} + +/*! + \since 4.7 - return toTime_tHelper(utcDate, utcTime); + Sets the date and time given the number of \a mulliseconds that have + passed since 1970-01-01T00:00:00.000, Coordinated Universal Time + (Qt::UTC). On systems that do not support time zones this function + will behave as if local time were Qt::UTC. + + Note that there are possible values for \a msecs that lie outside the + valid range of QDateTime, both negative and positive. The behavior of + this function is undefined for those values. + + \sa toMSecsSinceEpoch(), setTime_t() +*/ +void QDateTime::setMSecsSinceEpoch(qint64 msecs) +{ + detach(); + + QDateTimePrivate::Spec oldSpec = d->spec; + + int ddays = msecs / MSECS_PER_DAY; + msecs %= MSECS_PER_DAY; + if (msecs < 0) { + // negative + --ddays; + msecs += MSECS_PER_DAY; + } + + d->date = QDate(1970, 1, 1).addDays(ddays); + d->time = QTime().addMSecs(msecs); + d->spec = QDateTimePrivate::UTC; + + if (oldSpec != QDateTimePrivate::UTC) + d->spec = d->getLocal(d->date, d->time); } /*! @@ -2816,7 +2881,7 @@ bool QDateTime::operator<(const QDateTime &other) const */ /*! - \fn qint64 QDateTime::currentMsecsSinceEpoch() + \fn qint64 QDateTime::currentMSecsSinceEpoch() \since 4.7 Returns the number of milliseconds since 1970-01-01T00:00:00 Universal @@ -2879,7 +2944,7 @@ QDateTime QDateTime::currentDateTimeUtc() return QDateTime(d, t, Qt::UTC); } -qint64 QDateTime::currentMsecsSinceEpoch() +qint64 QDateTime::currentMSecsSinceEpoch() { QDate d; QTime t; @@ -2943,7 +3008,7 @@ QDateTime QDateTime::currentDateTimeUtc() return QDateTime(d, ct, Qt::UTC); } -qint64 QDateTime::currentMsecsSinceEpoch() +qint64 QDateTime::currentMSecsSinceEpoch() { QDate d; QTime ct; @@ -3060,7 +3125,7 @@ QDateTime QDateTime::currentDateTimeUtc() return dt; } -qint64 QDateTime::currentMsecsSinceEpoch() +qint64 QDateTime::currentMSecsSinceEpoch() { // posix compliant system // we have milliseconds @@ -3091,6 +3156,27 @@ QDateTime QDateTime::fromTime_t(uint seconds) } /*! + \since 4.7 + + Returns a datetime whose date and time are the number of milliseconds \a msec + that have passed since 1970-01-01T00:00:00.000, Coordinated Universal + Time (Qt::UTC). On systems that do not support time zones, the time + will be set as if local time were Qt::UTC. + + Note that there are possible values for \a msecs that lie outside the valid + range of QDateTime, both negative and positive. The behavior of this + function is undefined for those values. + + \sa toTime_t(), setTime_t() +*/ +QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs) +{ + QDateTime d; + d.setMSecsSinceEpoch(msecs); + return d; +} + +/*! \since 4.4 \internal @@ -3844,7 +3930,8 @@ static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time) { QDate fakeDate = adjustDate(date); - time_t secsSince1Jan1970UTC = toTime_tHelper(fakeDate, time); + // won't overflow because of fakeDate + time_t secsSince1Jan1970UTC = toMSecsSinceEpoch_helper(fakeDate.toJulianDay(), QTime().msecsTo(time)) / 1000; tm *brokenDown = 0; #if defined(Q_OS_WINCE) @@ -3929,7 +4016,7 @@ static void localToUtc(QDate &date, QTime &time, int isdst) localTM.tm_year = fakeDate.year() - 1900; localTM.tm_isdst = (int)isdst; #if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) - time_t secsSince1Jan1970UTC = toTime_tHelper(fakeDate, time); + time_t secsSince1Jan1970UTC = toMSecsSinceEpoch_helper(fakeDate.toJulianDay(), QTime().msecsTo(time)); #else #if defined(Q_OS_WIN) _tzset(); diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index ef5968e..f445f1c 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -230,10 +230,12 @@ public: QDate date() const; QTime time() const; Qt::TimeSpec timeSpec() const; + qint64 toMSecsSinceEpoch() const; uint toTime_t() const; void setDate(const QDate &date); void setTime(const QTime &time); void setTimeSpec(Qt::TimeSpec spec); + void setMSecsSinceEpoch(qint64 msecs); void setTime_t(uint secsSince1Jan1970UTC); #ifndef QT_NO_DATESTRING QString toString(Qt::DateFormat f = Qt::TextDate) const; @@ -267,7 +269,8 @@ public: static QDateTime fromString(const QString &s, const QString &format); #endif static QDateTime fromTime_t(uint secsSince1Jan1970UTC); - static qint64 currentMsecsSinceEpoch(); + static QDateTime fromMSecsSinceEpoch(qint64 msecs); + static qint64 currentMSecsSinceEpoch(); #ifdef QT3_SUPPORT inline QT3_SUPPORT void setTime_t(uint secsSince1Jan1970UTC, Qt::TimeSpec spec) { diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp index 9b589c1..85986e6 100644 --- a/src/corelib/tools/qelapsedtimer_generic.cpp +++ b/src/corelib/tools/qelapsedtimer_generic.cpp @@ -98,7 +98,7 @@ void QElapsedTimer::start() qint64 QElapsedTimer::restart() { qint64 old = t1; - t1 = QDateTime::currentMsecsSinceEpoch(); + t1 = QDateTime::currentMSecsSinceEpoch(); t2 = 0; return t1 - old; } @@ -112,7 +112,7 @@ qint64 QElapsedTimer::restart() */ qint64 QElapsedTimer::elapsed() const { - return QDateTime::currentMsecsSinceEpoch() - t1; + return QDateTime::currentMSecsSinceEpoch() - t1; } /*! diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp index 85d7fa8..2c4ea58 100644 --- a/src/corelib/tools/qelapsedtimer_unix.cpp +++ b/src/corelib/tools/qelapsedtimer_unix.cpp @@ -74,7 +74,7 @@ bool QElapsedTimer::isMonotonic() static int returnValue = 0; if (returnValue == 0) { -# if (_POSIX_MONOTONIC_CLOCK-0 < 0) +# if (_POSIX_MONOTONIC_CLOCK-0 < 0) || !defined(_SC_MONOTONIC_CLOCK) returnValue = -1; # elif (_POSIX_MONOTONIC_CLOCK == 0) // detect if the system support monotonic timers @@ -97,19 +97,19 @@ static inline QPair<long, long> do_gettime() #if (_POSIX_MONOTONIC_CLOCK-0 > 0) timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - return qMakePair(ts.tv_sec, ts.tv_nsec); + return qMakePair<long,long>(ts.tv_sec, ts.tv_nsec); #else # if !defined(QT_NO_CLOCK_MONOTONIC) && !defined(QT_BOOTSTRAPPED) if (QElapsedTimer::isMonotonic()) { timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - return qMakePair(ts.tv_sec, ts.tv_nsec); + return qMakePair<long,long>(ts.tv_sec, ts.tv_nsec); } # endif // use gettimeofday timeval tv; ::gettimeofday(&tv, 0); - return qMakePair(tv.tv_sec, tv.tv_usec); + return qMakePair<long,long>(tv.tv_sec, tv.tv_usec); #endif } diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index 0079891..a00f4c0 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -77,7 +77,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged) - Q_ENUMS(HighlightRangeMode); + Q_ENUMS(HighlightRangeMode) public: QDeclarativePathView(QDeclarativeItem *parent=0); diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp index 68ade38..d048b36 100644 --- a/src/gui/inputmethod/qximinputcontext_x11.cpp +++ b/src/gui/inputmethod/qximinputcontext_x11.cpp @@ -344,7 +344,13 @@ static XFontSet getFontSet(const QFont &f) return (fontsetCache[i] == (XFontSet)-1) ? 0 : fontsetCache[i]; } - +extern bool qt_use_rtl_extensions; // from qapplication_x11.cpp +#ifndef QT_NO_XKB +extern void q_getLocaleAndDirection(QLocale *locale, + Qt::LayoutDirection *direction, + const QByteArray &layoutName, + const QByteArray &variantName); +#endif QXIMInputContext::QXIMInputContext() { @@ -375,6 +381,52 @@ QXIMInputContext::QXIMInputContext() else QXIMInputContext::create_xim(); #endif // USE_X11R6_XIM + +#ifndef QT_NO_XKB + if (X11->use_xkb) { + QByteArray layoutName; + QByteArray variantName; + + Atom type = XNone; + int format = 0; + ulong nitems = 0; + ulong bytesAfter = 0; + uchar *data = 0; + if (XGetWindowProperty(X11->display, RootWindow(X11->display, 0), ATOM(_XKB_RULES_NAMES), 0, 1024, + false, XA_STRING, &type, &format, &nitems, &bytesAfter, &data) == Success + && type == XA_STRING && format == 8 && nitems > 2) { + + char *names[5] = { 0, 0, 0, 0, 0 }; + char *p = reinterpret_cast<char *>(data), *end = p + nitems; + int i = 0; + do { + names[i++] = p; + p += qstrlen(p) + 1; + } while (p < end); + + QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(','); + QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(','); + for (int i = 0; i < qMin(layoutNames.count(), variantNames.count()); ++i ) { + QLocale keyboardInputLocale; + Qt::LayoutDirection keyboardInputDirection; + QByteArray variantName = variantNames.at(i); + const int dashPos = variantName.indexOf("-"); + if (dashPos >= 0) + variantName.truncate(dashPos); + q_getLocaleAndDirection(&keyboardInputLocale, + &keyboardInputDirection, + layoutNames.at(i), + variantName); + if (keyboardInputDirection == Qt::RightToLeft) + qt_use_rtl_extensions = true; + } + } + + if (data) + XFree(data); + } +#endif // QT_NO_XKB + } diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp index 428ac3e..807959c 100644 --- a/src/gui/kernel/qkeymapper_x11.cpp +++ b/src/gui/kernel/qkeymapper_x11.cpp @@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF)) #endif -static void getLocaleAndDirection(QLocale *locale, +void q_getLocaleAndDirection(QLocale *locale, Qt::LayoutDirection *direction, const QByteArray &layoutName, const QByteArray &variantName) @@ -523,7 +523,7 @@ void QKeyMapperPrivate::clearMappings() // if (keyboardLayoutName.isEmpty()) // qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ? - getLocaleAndDirection(&keyboardInputLocale, + q_getLocaleAndDirection(&keyboardInputLocale, &keyboardInputDirection, layoutName, variantName); @@ -534,7 +534,6 @@ void QKeyMapperPrivate::clearMappings() << "direction =" << keyboardInputDirection; #endif - if (data) XFree(data); } else diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 4ae9f79..fbb5e4d 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -5846,7 +5846,6 @@ void QPlastiqueStyle::polish(QApplication *app) void QPlastiqueStyle::polish(QPalette &pal) { QWindowsStyle::polish(pal); - pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110)); #ifdef Q_WS_MAC pal.setBrush(QPalette::Shadow, Qt::black); #endif diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 60c06ca..1653baa 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -3105,7 +3105,9 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On), ©.palette.brush(QPalette::Button)); copy.rect.adjust(4, 1, -5, -1); - if (!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) ) { + if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) + && proxy()->styleHint(SH_EtchDisabledText, opt, widget) ) + { QStyleOptionSpinBox lightCopy = copy; lightCopy.rect.adjust(1, 1, 1, 1); lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light()); @@ -3138,7 +3140,9 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On), ©.palette.brush(QPalette::Button)); copy.rect.adjust(4, 0, -5, -1); - if (!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) ) { + if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) + && proxy()->styleHint(SH_EtchDisabledText, opt, widget) ) + { QStyleOptionSpinBox lightCopy = copy; lightCopy.rect.adjust(1, 1, 1, 1); lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light()); diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 5f31ef0..6c504a7 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -593,7 +593,11 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p) document.setDocumentMargin(0.0); if (textWidth >= 0.0) document.setTextWidth(textWidth); +#ifndef QT_NO_TEXTHTMLPARSER document.setHtml(text); +#else + document.setPlainText(text); +#endif document.adjustSize(); p->save(); diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 6864fe1..671dfc0 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_CONTEXTMENU -#if defined(Q_WS_WIN) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) extern bool qt_use_rtl_extensions; #endif #endif @@ -2080,7 +2080,7 @@ QMenu *QTextControl::createStandardContextMenu(const QPointF &pos, QWidget *pare } #endif -#if defined(Q_WS_WIN) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) if ((d->interactionFlags & Qt::TextEditable) && qt_use_rtl_extensions) { #else if (d->interactionFlags & Qt::TextEditable) { diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index c16f18a..b1a27f2 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -108,7 +108,15 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt const QModelIndex &index) const { QStyleOptionMenuItem menuOption; - menuOption.palette = option.palette.resolve(QApplication::palette("QMenu")); + + QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu")); + QVariant value = index.data(Qt::ForegroundRole); + if (qVariantCanConvert<QBrush>(value)) { + resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value)); + resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value)); + resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value)); + } + menuOption.palette = resolvedpalette; menuOption.state = QStyle::State_None; if (mCombo->window()->isActiveWindow()) menuOption.state = QStyle::State_Active; diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 817547c..0b8dca9 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -2046,7 +2046,7 @@ void QLineEdit::contextMenuEvent(QContextMenuEvent *event) } } -#if defined(Q_WS_WIN) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) extern bool qt_use_rtl_extensions; #endif @@ -2118,7 +2118,7 @@ QMenu *QLineEdit::createStandardContextMenu() } #endif -#if defined(Q_WS_WIN) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) if (!d->control->isReadOnly() && qt_use_rtl_extensions) { #else if (!d->control->isReadOnly()) { diff --git a/src/gui/widgets/qvalidator.cpp b/src/gui/widgets/qvalidator.cpp index 0b5cc5a..b75db45 100644 --- a/src/gui/widgets/qvalidator.cpp +++ b/src/gui/widgets/qvalidator.cpp @@ -523,7 +523,7 @@ public: In addition, QDoubleValidator is always guaranteed to accept a number formatted according to the "C" locale. QDoubleValidator will not accept - numbers with thousand-seperators. + numbers with thousand-separators. \sa QIntValidator, QRegExpValidator, {Line Edits Example} */ diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index bc7684a..17b864c 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -670,7 +670,8 @@ void QHttpNetworkConnectionChannel::allDone() close(); QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } else if (alreadyPipelinedRequests.isEmpty()) { - QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); + if (qobject_cast<QHttpNetworkConnection*>(connection)) + QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } } @@ -775,7 +776,8 @@ void QHttpNetworkConnectionChannel::handleStatus() } break; default: - QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); + if (qobject_cast<QHttpNetworkConnection*>(connection)) + QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } } @@ -823,7 +825,8 @@ void QHttpNetworkConnectionChannel::closeAndResendCurrentRequest() requeueCurrentlyPipelinedRequests(); close(); resendCurrent = true; - QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); + if (qobject_cast<QHttpNetworkConnection*>(connection)) + QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } bool QHttpNetworkConnectionChannel::isSocketBusy() const diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h index bb4d8a0..79bb27c 100644 --- a/src/network/bearer/qnetworkconfigmanager.h +++ b/src/network/bearer/qnetworkconfigmanager.h @@ -42,17 +42,26 @@ #ifndef QNETWORKCONFIGURATIONMANAGER_H #define QNETWORKCONFIGURATIONMANAGER_H +#ifdef QT_MOBILITY_BEARER +# include "qmobilityglobal.h" +#endif + #include <QtCore/qobject.h> #include <QtNetwork/qnetworkconfiguration.h> QT_BEGIN_HEADER +#ifndef QT_MOBILITY_BEARER QT_BEGIN_NAMESPACE - +#define QNetworkConfigurationManagerExport Q_NETWORK_EXPORT QT_MODULE(Network) +#else +QTM_BEGIN_NAMESPACE +#define QNetworkConfigurationManagerExport Q_BEARER_EXPORT +#endif class QNetworkConfigurationManagerPrivate; -class Q_NETWORK_EXPORT QNetworkConfigurationManager : public QObject +class QNetworkConfigurationManagerExport QNetworkConfigurationManager : public QObject { Q_OBJECT @@ -94,7 +103,11 @@ Q_SIGNALS: Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities) +#ifndef QT_MOBILITY_BEARER QT_END_NAMESPACE +#else +QTM_END_NAMESPACE +#endif QT_END_HEADER diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h index dad6198..dce39eb 100644 --- a/src/network/bearer/qnetworkconfiguration.h +++ b/src/network/bearer/qnetworkconfiguration.h @@ -42,19 +42,33 @@ #ifndef QNETWORKCONFIGURATION_H #define QNETWORKCONFIGURATION_H -#include <QtCore/qglobal.h> +#ifndef QT_MOBILITY_BEARER +# include <QtCore/qglobal.h> +#else +# include "qmobilityglobal.h" +#endif + #include <QtCore/qshareddata.h> #include <QtCore/qstring.h> #include <QtCore/qlist.h> +#if defined(Q_OS_WIN) && defined(interface) +#undef interface +#endif + QT_BEGIN_HEADER +#ifndef QT_MOBILITY_BEARER QT_BEGIN_NAMESPACE - QT_MODULE(Network) +#define QNetworkConfigurationExport Q_NETWORK_EXPORT +#else +QTM_BEGIN_NAMESPACE +#define QNetworkConfigurationExport Q_BEARER_EXPORT +#endif class QNetworkConfigurationPrivate; -class Q_NETWORK_EXPORT QNetworkConfiguration +class QNetworkConfigurationExport QNetworkConfiguration { public: QNetworkConfiguration(); @@ -108,7 +122,11 @@ private: QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> d; }; +#ifndef QT_MOBILITY_BEARER QT_END_NAMESPACE +#else +QTM_END_NAMESPACE +#endif QT_END_HEADER diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h index 596f527..2911d0a 100644 --- a/src/network/bearer/qnetworksession.h +++ b/src/network/bearer/qnetworksession.h @@ -54,12 +54,19 @@ QT_BEGIN_HEADER +#ifndef QT_MOBILITY_BEARER +#include <QtCore/qshareddata.h> QT_BEGIN_NAMESPACE - QT_MODULE(Network) +#define QNetworkSessionExport Q_NETWORK_EXPORT +#else +#include "qmobilityglobal.h" +QTM_BEGIN_NAMESPACE +#define QNetworkSessionExport Q_BEARER_EXPORT +#endif class QNetworkSessionPrivate; -class Q_NETWORK_EXPORT QNetworkSession : public QObject +class QNetworkSessionExport QNetworkSession : public QObject { Q_OBJECT public: @@ -80,8 +87,11 @@ public: OperationNotSupportedError, InvalidConfigurationError }; - - explicit QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0); +#ifndef QT_MOBILITY_BEARER + QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0); +#else + explicit QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0); +#endif virtual ~QNetworkSession(); bool isOpen() const; @@ -131,7 +141,11 @@ private: friend class QNetworkSessionPrivate; }; +#ifndef QT_MOBILITY_BEARER QT_END_NAMESPACE +#else +QTM_END_NAMESPACE +#endif QT_END_HEADER diff --git a/src/plugins/bearer/nativewifi/platformdefs.h b/src/plugins/bearer/nativewifi/platformdefs.h index 57ae852..d67525a 100644 --- a/src/plugins/bearer/nativewifi/platformdefs.h +++ b/src/plugins/bearer/nativewifi/platformdefs.h @@ -52,6 +52,8 @@ #define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 2 #define DOT11_SSID_MAX_LENGTH 32 +QT_BEGIN_NAMESPACE + struct WLAN_NOTIFICATION_DATA { DWORD NotificationSource; DWORD NotificationCode; @@ -319,4 +321,6 @@ extern WlanScanProto local_WlanScan; extern WlanFreeMemoryProto local_WlanFreeMemory; extern WlanCloseHandleProto local_WlanCloseHandle; +QT_END_NAMESPACE + #endif // PLATFORMDEFS_H diff --git a/src/plugins/bearer/platformdefs_win.h b/src/plugins/bearer/platformdefs_win.h index 37d099c..1a10ba7 100644 --- a/src/plugins/bearer/platformdefs_win.h +++ b/src/plugins/bearer/platformdefs_win.h @@ -47,6 +47,8 @@ #undef interface #include <winioctl.h> +QT_BEGIN_NAMESPACE + #ifndef NS_NLA #define NS_NLA 15 @@ -131,4 +133,6 @@ enum NDIS_PHYSICAL_MEDIUM { #define IOCTL_NDIS_QUERY_GLOBAL_STATS \ CTL_CODE(FILE_DEVICE_PHYSICAL_NETCARD, 0, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) +QT_END_NAMESPACE + #endif diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index b1732ee..639af80 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -161,6 +161,7 @@ QScriptContext::QScriptContext() QScriptValue QScriptContext::throwValue(const QScriptValue &value) { JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); JSC::JSValue jscValue = QScript::scriptEngineFromExec(frame)->scriptValueToJSCValue(value); frame->setException(jscValue); return value; @@ -183,6 +184,7 @@ QScriptValue QScriptContext::throwValue(const QScriptValue &value) QScriptValue QScriptContext::throwError(Error error, const QString &text) { JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); JSC::ErrorType jscError = JSC::GeneralError; switch (error) { case UnknownError: @@ -218,6 +220,7 @@ QScriptValue QScriptContext::throwError(Error error, const QString &text) QScriptValue QScriptContext::throwError(const QString &text) { JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); JSC::JSObject *result = JSC::throwError(frame, JSC::GeneralError, text); return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(result); } @@ -265,6 +268,7 @@ QScriptValue QScriptContext::argument(int index) const QScriptValue QScriptContext::callee() const { const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(frame->callee()); } @@ -286,6 +290,7 @@ QScriptValue QScriptContext::callee() const QScriptValue QScriptContext::argumentsObject() const { JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this)); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); if (frame == frame->lexicalGlobalObject()->globalExec()) { // <global> context doesn't have arguments. return an empty object @@ -322,6 +327,7 @@ QScriptValue QScriptContext::argumentsObject() const bool QScriptContext::isCalledAsConstructor() const { JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this)); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); //For native functions, look up flags. uint flags = QScriptEnginePrivate::contextFlags(frame); @@ -355,6 +361,7 @@ bool QScriptContext::isCalledAsConstructor() const QScriptContext *QScriptContext::parentContext() const { const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); JSC::CallFrame *callerFrame = frame->callerFrame()->removeHostCallFrameFlag(); return QScriptEnginePrivate::contextForFrame(callerFrame); } @@ -412,6 +419,7 @@ void QScriptContext::setReturnValue(const QScriptValue &result) QScriptValue QScriptContext::activationObject() const { JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this)); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); JSC::JSObject *result = 0; uint flags = QScriptEnginePrivate::contextFlags(frame); @@ -477,6 +485,7 @@ void QScriptContext::setActivationObject(const QScriptValue &activation) } JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame); + QScript::APIShim shim(engine); JSC::JSObject *object = JSC::asObject(engine->scriptValueToJSCValue(activation)); if (object == engine->originalGlobalObjectProxy) object = engine->originalGlobalObject(); @@ -521,6 +530,7 @@ QScriptValue QScriptContext::thisObject() const { JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this)); QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame); + QScript::APIShim shim(engine); JSC::JSValue result = engine->thisForContext(frame); if (!result || result.isNull()) result = frame->globalThisValue(); @@ -536,6 +546,7 @@ QScriptValue QScriptContext::thisObject() const void QScriptContext::setThisObject(const QScriptValue &thisObject) { JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); + QScript::APIShim shim(QScript::scriptEngineFromExec(frame)); if (!thisObject.isObject()) return; if (thisObject.engine() != engine()) { @@ -662,6 +673,7 @@ QScriptValueList QScriptContext::scopeChain() const activationObject(); //ensure the creation of the normal scope for native context const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame); + QScript::APIShim shim(engine); QScriptValueList result; JSC::ScopeChainNode *node = frame->scopeChain(); JSC::ScopeChainIterator it(node); @@ -700,6 +712,7 @@ void QScriptContext::pushScope(const QScriptValue &object) } JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame); + QScript::APIShim shim(engine); JSC::JSObject *jscObject = JSC::asObject(engine->scriptValueToJSCValue(object)); if (jscObject == engine->originalGlobalObjectProxy) jscObject = engine->originalGlobalObject(); @@ -733,6 +746,7 @@ QScriptValue QScriptContext::popScope() JSC::ScopeChainNode *scope = frame->scopeChain(); Q_ASSERT(scope != 0); QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame); + QScript::APIShim shim(engine); QScriptValue result = engine->scriptValueFromJSCValue(scope->object); if (!scope->next) { // We cannot have a null scope chain, so just zap the object pointer. diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 70f798e..13b8e7c 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1900,6 +1900,7 @@ QScriptEngine::~QScriptEngine() QScriptValue QScriptEngine::globalObject() const { Q_D(const QScriptEngine); + QScript::APIShim shim(const_cast<QScriptEnginePrivate*>(d)); JSC::JSObject *result = d->globalObject(); return const_cast<QScriptEnginePrivate*>(d)->scriptValueFromJSCValue(result); } @@ -1921,6 +1922,7 @@ void QScriptEngine::setGlobalObject(const QScriptValue &object) Q_D(QScriptEngine); if (!object.isObject()) return; + QScript::APIShim shim(d); JSC::JSObject *jscObject = JSC::asObject(d->scriptValueToJSCValue(object)); d->setGlobalObject(jscObject); } @@ -1977,6 +1979,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun, int length) { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::ExecState* exec = d->currentFrame; JSC::JSValue function = new (exec)QScript::FunctionWrapper(exec, length, JSC::Identifier(exec, ""), fun); QScriptValue result = d->scriptValueFromJSCValue(function); @@ -2000,6 +2003,7 @@ extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax); QScriptValue QScriptEngine::newRegExp(const QRegExp ®exp) { Q_D(QScriptEngine); + QScript::APIShim shim(d); return d->scriptValueFromJSCValue(d->newRegExp(d->currentFrame, regexp)); } @@ -2018,6 +2022,7 @@ QScriptValue QScriptEngine::newRegExp(const QRegExp ®exp) QScriptValue QScriptEngine::newVariant(const QVariant &value) { Q_D(QScriptEngine); + QScript::APIShim shim(d); return d->scriptValueFromJSCValue(d->newVariant(value)); } @@ -2051,6 +2056,7 @@ QScriptValue QScriptEngine::newVariant(const QScriptValue &object, const QVariant &value) { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::JSValue jsObject = d->scriptValueToJSCValue(object); return d->scriptValueFromJSCValue(d->newVariant(jsObject, value)); } @@ -2082,6 +2088,7 @@ QScriptValue QScriptEngine::newQObject(QObject *object, ValueOwnership ownership const QObjectWrapOptions &options) { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::JSValue jscQObject = d->newQObject(object, ownership, options); return d->scriptValueFromJSCValue(jscQObject); } @@ -2118,8 +2125,10 @@ QScriptValue QScriptEngine::newQObject(const QScriptValue &scriptObject, ValueOwnership ownership, const QObjectWrapOptions &options) { + Q_D(QScriptEngine); if (!scriptObject.isObject()) return newQObject(qtObject, ownership, options); + QScript::APIShim shim(d); JSC::JSObject *jscObject = JSC::asObject(QScriptValuePrivate::get(scriptObject)->jscValue); if (!jscObject->inherits(&QScriptObject::info)) { qWarning("QScriptEngine::newQObject(): changing class of non-QScriptObject not supported"); @@ -2150,6 +2159,7 @@ QScriptValue QScriptEngine::newQObject(const QScriptValue &scriptObject, QScriptValue QScriptEngine::newObject() { Q_D(QScriptEngine); + QScript::APIShim shim(d); return d->scriptValueFromJSCValue(d->newObject()); } @@ -2171,6 +2181,7 @@ QScriptValue QScriptEngine::newObject(QScriptClass *scriptClass, const QScriptValue &data) { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::ExecState* exec = d->currentFrame; QScriptObject *result = new (exec) QScriptObject(d->scriptObjectStructure); result->setDelegate(new QScript::ClassObjectDelegate(scriptClass)); @@ -2238,6 +2249,7 @@ QScriptValue QScriptEngine::newActivationObject() QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun, int length) { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::ExecState* exec = d->currentFrame; JSC::JSValue function = new (exec)QScript::FunctionWrapper(exec, length, JSC::Identifier(exec, ""), fun); QScriptValue result = d->scriptValueFromJSCValue(function); @@ -2255,6 +2267,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun, in QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionWithArgSignature fun, void *arg) { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::ExecState* exec = d->currentFrame; JSC::JSValue function = new (exec)QScript::FunctionWithArgWrapper(exec, /*length=*/0, JSC::Identifier(exec, ""), fun, arg); QScriptValue result = d->scriptValueFromJSCValue(function); @@ -2273,6 +2286,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionWithArgSignature QScriptValue QScriptEngine::newArray(uint length) { Q_D(QScriptEngine); + QScript::APIShim shim(d); return d->scriptValueFromJSCValue(d->newArray(d->currentFrame, length)); } @@ -2286,6 +2300,7 @@ QScriptValue QScriptEngine::newArray(uint length) QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &flags) { Q_D(QScriptEngine); + QScript::APIShim shim(d); return d->scriptValueFromJSCValue(d->newRegExp(d->currentFrame, pattern, flags)); } @@ -2297,6 +2312,7 @@ QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &fla QScriptValue QScriptEngine::newDate(qsreal value) { Q_D(QScriptEngine); + QScript::APIShim shim(d); return d->scriptValueFromJSCValue(d->newDate(d->currentFrame, value)); } @@ -2308,6 +2324,7 @@ QScriptValue QScriptEngine::newDate(qsreal value) QScriptValue QScriptEngine::newDate(const QDateTime &value) { Q_D(QScriptEngine); + QScript::APIShim shim(d); return d->scriptValueFromJSCValue(d->newDate(d->currentFrame, value)); } @@ -2331,6 +2348,7 @@ QScriptValue QScriptEngine::newQMetaObject( const QMetaObject *metaObject, const QScriptValue &ctor) { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::JSValue jscCtor = d->scriptValueToJSCValue(ctor); JSC::JSValue jscQMetaObject = d->newQMetaObject(metaObject, jscCtor); return d->scriptValueFromJSCValue(jscQMetaObject); @@ -2583,6 +2601,7 @@ QScriptContext *QScriptEngine::currentContext() const QScriptContext *QScriptEngine::pushContext() { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::CallFrame* newFrame = d->pushContext(d->currentFrame, d->currentFrame->globalData().dynamicGlobalObject, JSC::ArgList(), /*callee = */0); @@ -2674,6 +2693,7 @@ void QScriptEngine::popContext() if (agent()) agent()->contextPop(); Q_D(QScriptEngine); + QScript::APIShim shim(d); if (d->currentFrame->returnPC() != 0 || d->currentFrame->codeBlock() != 0 || !currentContext()->parentContext()) { qWarning("QScriptEngine::popContext() doesn't match with pushContext()"); @@ -2869,6 +2889,7 @@ void QScriptEngine::setDefaultPrototype(int metaTypeId, const QScriptValue &prot QScriptValue QScriptEngine::create(int type, const void *ptr) { Q_D(QScriptEngine); + QScript::APIShim shim(d); return d->scriptValueFromJSCValue(d->create(d->currentFrame, type, ptr)); } @@ -3315,6 +3336,7 @@ void QScriptEngine::registerCustomType(int type, MarshalFunction mf, const QScriptValue &prototype) { Q_D(QScriptEngine); + QScript::APIShim shim(d); QScriptTypeInfo *info = d->m_typeInfos.value(type); if (!info) { info = new QScriptTypeInfo(); @@ -3381,6 +3403,7 @@ QScriptValue QScriptEngine::importExtension(const QString &extension) Q_UNUSED(extension); #else Q_D(QScriptEngine); + QScript::APIShim shim(d); if (d->importedExtensions.contains(extension)) return undefinedValue(); // already imported @@ -4021,6 +4044,7 @@ bool qScriptConnect(QObject *sender, const char *signal, if (receiver.isObject() && (receiver.engine() != function.engine())) return false; QScriptEnginePrivate *engine = QScriptEnginePrivate::get(function.engine()); + QScript::APIShim shim(engine); JSC::JSValue jscReceiver = engine->scriptValueToJSCValue(receiver); JSC::JSValue jscFunction = engine->scriptValueToJSCValue(function); return engine->scriptConnect(sender, signal, jscReceiver, jscFunction, @@ -4047,6 +4071,7 @@ bool qScriptDisconnect(QObject *sender, const char *signal, if (receiver.isObject() && (receiver.engine() != function.engine())) return false; QScriptEnginePrivate *engine = QScriptEnginePrivate::get(function.engine()); + QScript::APIShim shim(engine); JSC::JSValue jscReceiver = engine->scriptValueToJSCValue(receiver); JSC::JSValue jscFunction = engine->scriptValueToJSCValue(function); return engine->scriptDisconnect(sender, signal, jscReceiver, jscFunction); @@ -4152,6 +4177,7 @@ QScriptString QScriptEngine::toStringHandle(const QString &str) QScriptValue QScriptEngine::toObject(const QScriptValue &value) { Q_D(QScriptEngine); + QScript::APIShim shim(d); JSC::JSValue jscValue = d->scriptValueToJSCValue(value); if (!jscValue || jscValue.isUndefined() || jscValue.isNull()) return QScriptValue(); diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 70ab7c9..5c2007f 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -798,7 +798,6 @@ inline void QScriptEnginePrivate::unregisterScriptString(QScriptStringPrivate *v registeredScriptStrings = value->next; value->prev = 0; value->next = 0; - JSC::setCurrentIdentifierTable(globalData->identifierTable); } inline QScriptContext *QScriptEnginePrivate::contextForFrame(JSC::ExecState *frame) diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp index 7978b61..d0b0ffd 100644 --- a/src/script/api/qscriptstring.cpp +++ b/src/script/api/qscriptstring.cpp @@ -92,8 +92,12 @@ QScriptString::~QScriptString() d->ref.ref(); // avoid deletion break; case QScriptStringPrivate::HeapAllocated: - if (d->engine && (d->ref == 1)) + if (d->engine && (d->ref == 1)) { + // Make sure the identifier is removed from the correct engine. + QScript::APIShim(d->engine); + d->identifier = JSC::Identifier(); d->engine->unregisterScriptString(d); + } break; } } diff --git a/src/script/api/qscriptvalueiterator.cpp b/src/script/api/qscriptvalueiterator.cpp index ecda5fc..77d43b3 100644 --- a/src/script/api/qscriptvalueiterator.cpp +++ b/src/script/api/qscriptvalueiterator.cpp @@ -150,6 +150,12 @@ QScriptValueIterator::QScriptValueIterator(const QScriptValue &object) */ QScriptValueIterator::~QScriptValueIterator() { + Q_D(QScriptValueIterator); + if (d && d->engine()) { + // Make sure identifiers are removed from the correct engine. + QScript::APIShim shim(d->engine()); + d->propertyNames.clear(); + } } /*! diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp index 0f450ca..1093448 100644 --- a/src/script/bridge/qscriptdeclarativeclass.cpp +++ b/src/script/bridge/qscriptdeclarativeclass.cpp @@ -154,9 +154,12 @@ QScriptDeclarativeClass::PersistentIdentifier::PersistentIdentifier() QScriptDeclarativeClass::PersistentIdentifier::~PersistentIdentifier() { - if (engine) - JSC::setCurrentIdentifierTable(engine->globalData->identifierTable); - ((JSC::Identifier &)d).JSC::Identifier::~Identifier(); + if (engine) { + QScript::APIShim shim(engine); + ((JSC::Identifier &)d).JSC::Identifier::~Identifier(); + } else { + ((JSC::Identifier &)d).JSC::Identifier::~Identifier(); + } } QScriptDeclarativeClass::PersistentIdentifier::PersistentIdentifier(const PersistentIdentifier &other) @@ -190,7 +193,8 @@ QScriptValue QScriptDeclarativeClass::newObject(QScriptEngine *engine, Q_ASSERT(engine); Q_ASSERT(scriptClass); - QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(engine)); + QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(engine)); + QScript::APIShim shim(p); JSC::ExecState* exec = p->currentFrame; QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure); @@ -207,6 +211,7 @@ QScriptDeclarativeClass::newObjectValue(QScriptEngine *engine, Q_ASSERT(scriptClass); QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(engine)); + QScript::APIShim shim(p); JSC::ExecState* exec = p->currentFrame; QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure); @@ -237,6 +242,7 @@ QScriptValue QScriptDeclarativeClass::function(const QScriptValue &v, const Iden if (!d->isObject()) return QScriptValue(); + QScript::APIShim shim(d->engine); JSC::ExecState *exec = d->engine->currentFrame; JSC::JSObject *object = d->jscValue.getObject(); JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object)); @@ -260,6 +266,7 @@ QScriptValue QScriptDeclarativeClass::property(const QScriptValue &v, const Iden if (!d->isObject()) return QScriptValue(); + QScript::APIShim shim(d->engine); JSC::ExecState *exec = d->engine->currentFrame; JSC::JSObject *object = d->jscValue.getObject(); JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object)); @@ -283,6 +290,7 @@ QScriptDeclarativeClass::functionValue(const QScriptValue &v, const Identifier & if (!d->isObject()) return Value(); + QScript::APIShim shim(d->engine); JSC::ExecState *exec = d->engine->currentFrame; JSC::JSObject *object = d->jscValue.getObject(); JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object)); @@ -307,6 +315,7 @@ QScriptDeclarativeClass::propertyValue(const QScriptValue &v, const Identifier & if (!d->isObject()) return Value(); + QScript::APIShim shim(d->engine); JSC::ExecState *exec = d->engine->currentFrame; JSC::JSObject *object = d->jscValue.getObject(); JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object)); @@ -332,6 +341,7 @@ QScriptValue QScriptDeclarativeClass::scopeChainValue(QScriptContext *context, i context->activationObject(); //ensure the creation of the normal scope for native context const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(context); QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame); + QScript::APIShim shim(engine); JSC::ScopeChainNode *node = frame->scopeChain(); JSC::ScopeChainIterator it(node); @@ -392,6 +402,7 @@ QScriptContext * QScriptDeclarativeClass::pushCleanContext(QScriptEngine *engine return 0; QScriptEnginePrivate *d = QScriptEnginePrivate::get(engine); + QScript::APIShim shim(d); JSC::CallFrame* newFrame = d->pushContext(d->currentFrame, d->currentFrame->globalData().dynamicGlobalObject, @@ -427,6 +438,7 @@ QScriptDeclarativeClass::createPersistentIdentifier(const QString &str) { QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(d_ptr->engine)); + QScript::APIShim shim(p); JSC::ExecState* exec = p->currentFrame; PersistentIdentifier rv(p); @@ -440,6 +452,7 @@ QScriptDeclarativeClass::createPersistentIdentifier(const Identifier &id) { QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(d_ptr->engine)); + QScript::APIShim shim(p); JSC::ExecState* exec = p->currentFrame; PersistentIdentifier rv(p); diff --git a/src/tools/uic/cpp/cppextractimages.cpp b/src/tools/uic/cpp/cppextractimages.cpp index d452168..52c1b9d 100644 --- a/src/tools/uic/cpp/cppextractimages.cpp +++ b/src/tools/uic/cpp/cppextractimages.cpp @@ -134,7 +134,7 @@ void ExtractImages::acceptImage(DomImage *image) QTextStream *imageOut = new QTextStream(&f); imageOut->setCodec(QTextCodec::codecForName("UTF-8")); - CPP::WriteIconData::writeImage(*imageOut, QString(), image); + CPP::WriteIconData::writeImage(*imageOut, QString(), m_option.limitXPM_LineLength, image); delete imageOut; } else { CPP::WriteIconData::writeImage(f, image); diff --git a/src/tools/uic/cpp/cppwriteicondata.cpp b/src/tools/uic/cpp/cppwriteicondata.cpp index 81ef56b..7e4b5c8 100644 --- a/src/tools/uic/cpp/cppwriteicondata.cpp +++ b/src/tools/uic/cpp/cppwriteicondata.cpp @@ -114,10 +114,12 @@ void WriteIconData::acceptImages(DomImages *images) void WriteIconData::acceptImage(DomImage *image) { - writeImage(output, option.indent, image); + // Limit line length when writing code. + writeImage(output, option.indent, true, image); } -void WriteIconData::writeImage(QTextStream &output, const QString &indent, DomImage *image) +void WriteIconData::writeImage(QTextStream &output, const QString &indent, + bool limitXPM_LineLength, const DomImage *image) { QString img = image->attributeName() + QLatin1String("_data"); QString data = image->elementData()->text(); @@ -133,7 +135,8 @@ void WriteIconData::writeImage(QTextStream &output, const QString &indent, DomIm int a = 0; int column = 0; bool inQuote = false; - output << indent << "static const char* const " << img << "[] = { \n"; + output << indent << "/* XPM */\n" + << indent << "static const char* const " << img << "[] = { \n"; while (baunzip[a] != '\"') a++; for (; a < (int) length; a++) { @@ -144,7 +147,8 @@ void WriteIconData::writeImage(QTextStream &output, const QString &indent, DomIm inQuote = !inQuote; } - if (column++ >= 511 && inQuote) { + column++; + if (limitXPM_LineLength && column >= 512 && inQuote) { output << "\"\n\""; // be nice with MSVC & Co. column = 1; } diff --git a/src/tools/uic/cpp/cppwriteicondata.h b/src/tools/uic/cpp/cppwriteicondata.h index 40d56bc..42cfab0 100644 --- a/src/tools/uic/cpp/cppwriteicondata.h +++ b/src/tools/uic/cpp/cppwriteicondata.h @@ -64,7 +64,8 @@ public: void acceptImages(DomImages *images); void acceptImage(DomImage *image); - static void writeImage(QTextStream &output, const QString &indent, DomImage *image); + static void writeImage(QTextStream &output, const QString &indent, + bool limitXPM_LineLength, const DomImage *image); static void writeImage(QIODevice &output, DomImage *image); private: diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h index f1198a0..8556728 100644 --- a/src/tools/uic/option.h +++ b/src/tools/uic/option.h @@ -61,6 +61,7 @@ struct Option unsigned int autoConnection : 1; unsigned int dependencies : 1; unsigned int extractImages : 1; + unsigned int limitXPM_LineLength : 1; unsigned int implicitIncludes: 1; Generator generator; @@ -85,6 +86,7 @@ struct Option autoConnection(1), dependencies(0), extractImages(0), + limitXPM_LineLength(0), implicitIncludes(1), generator(CppGenerator), prefix(QLatin1String("Ui_")) diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp index e1b4b38..2ee939d 100644 --- a/src/tools/uic3/converter.cpp +++ b/src/tools/uic3/converter.cpp @@ -518,6 +518,7 @@ DomUI *Ui3Reader::generateUi4(const QDomElement &widget) if (m_extractImages) { Option opt; opt.extractImages = m_extractImages; + opt.limitXPM_LineLength = (m_options & LimitXPM_LineLength) ? 1 : 0; opt.qrcOutputFile = m_qrcOutputFile; CPP::ExtractImages(opt).acceptUI(ui); diff --git a/src/tools/uic3/form.cpp b/src/tools/uic3/form.cpp index df1314f..9df644a 100644 --- a/src/tools/uic3/form.cpp +++ b/src/tools/uic3/form.cpp @@ -256,6 +256,7 @@ void Ui3Reader::createFormDecl(const QDomElement &e) d.option().headerProtection = false; d.option().copyrightHeader = false; d.option().extractImages = m_extractImages; + d.option().limitXPM_LineLength = (m_options & LimitXPM_LineLength) ? 1 : 0; d.option().qrcOutputFile = m_qrcOutputFile; d.option().implicitIncludes = (m_options & ImplicitIncludes) ? 1 : 0; if (trmacro.size()) diff --git a/src/tools/uic3/main.cpp b/src/tools/uic3/main.cpp index 1ebb76a..d7657b1 100644 --- a/src/tools/uic3/main.cpp +++ b/src/tools/uic3/main.cpp @@ -149,6 +149,8 @@ int runUic3(int argc, char * argv[]) readerOptions &= ~Ui3Reader::CustomWidgetForwardDeclarations; } else if (opt == "layout-names") { readerOptions |= Ui3Reader::PreserveLayoutNames; + } else if (opt == "limit-xpm-linelength") { + readerOptions |= Ui3Reader::LimitXPM_LineLength; } else if (opt == "nounload") { // skip } else if (opt == "convert") { @@ -251,6 +253,7 @@ int runUic3(int argc, char * argv[]) "Options:\n" "\t-o file Write output to file rather than stdout\n" "\t-extract qrcFile Create resource file and extract embedded images into \"image\" dir\n" + "\t-limit-xpm-linelength Limit the line length of XPM files for -extract.\n" "\t-pch file Add #include \"file\" as the first statement in implementation\n" "\t-nofwd Omit forward declarations of custom classes\n" "\t-layout-names Preserve layout names of Qt Designer 3\n" diff --git a/src/tools/uic3/ui3reader.h b/src/tools/uic3/ui3reader.h index 144ef05..abe323e 100644 --- a/src/tools/uic3/ui3reader.h +++ b/src/tools/uic3/ui3reader.h @@ -68,7 +68,8 @@ typedef QList<QPair<int, Color> > ColorGroup; class Ui3Reader { public: - enum Options { CustomWidgetForwardDeclarations = 0x1, ImplicitIncludes = 0x2, PreserveLayoutNames = 0x4 }; + enum Options { CustomWidgetForwardDeclarations = 0x1, ImplicitIncludes = 0x2, + PreserveLayoutNames = 0x4, LimitXPM_LineLength = 0x8 }; explicit Ui3Reader(QTextStream &stream, unsigned options); ~Ui3Reader(); diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index 56166f2..7d51bb6 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -43,7 +43,6 @@ #include <QtDeclarative/qdeclarativecomponent.h> #include <QtDeclarative/qdeclarativeproperty.h> #include <QtDeclarative/private/qdeclarativeproperty_p.h> -#include <private/qguard_p.h> #include <private/qdeclarativebinding_p.h> #include <QtGui/QLineEdit> #include <QtCore/qfileinfo.h> @@ -138,9 +137,9 @@ void tst_qdeclarativeproperty::qmlmetaproperty() { QDeclarativeProperty prop; - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -169,10 +168,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty() QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -234,9 +233,9 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() { QDeclarativeProperty prop(&object); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -265,10 +264,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -279,10 +278,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() { QDeclarativeProperty prop(&dobject); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); - binding->setTarget(prop); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -312,11 +311,11 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int"); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding != 0); - QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data()); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -333,9 +332,9 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() { QDeclarativeProperty prop(&object, QString("defaultProperty")); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -364,10 +363,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -378,10 +377,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() { QDeclarativeProperty prop(&dobject, QString("defaultProperty")); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); - binding->setTarget(prop); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -411,11 +410,11 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int"); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding != 0); - QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data()); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -426,10 +425,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() { QDeclarativeProperty prop(&dobject, QString("onClicked")); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); - binding->setTarget(prop); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -458,12 +457,12 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression != 0); - QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -473,10 +472,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() { QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); - binding->setTarget(prop); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -505,12 +504,12 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression != 0); - QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -526,9 +525,9 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() { QDeclarativeProperty prop(&object, engine.rootContext()); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -557,10 +556,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -571,10 +570,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() { QDeclarativeProperty prop(&dobject, engine.rootContext()); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); - binding->setTarget(prop); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -604,11 +603,11 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int"); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding != 0); - QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data()); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -625,9 +624,9 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() { QDeclarativeProperty prop(&object, QString("defaultProperty"), engine.rootContext()); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -656,10 +655,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -670,10 +669,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() { QDeclarativeProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); - binding->setTarget(prop); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -703,11 +702,11 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int"); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding != 0); - QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data()); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression == 0); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -718,10 +717,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() { QDeclarativeProperty prop(&dobject, QString("onClicked"), engine.rootContext()); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); - binding->setTarget(prop); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -750,12 +749,12 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression != 0); - QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -765,10 +764,10 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() { QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); - QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); - binding->setTarget(prop); + QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); QVERIFY(binding != 0); - QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression()); + QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression()); QVERIFY(expression != 0); QObject *obj = new QObject; @@ -797,12 +796,12 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0); QVERIFY(expression != 0); - QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index 10a760c..a8fd2b4 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -78,7 +78,6 @@ SUBDIRS=\ qgraphicswidget \ qgridlayout \ qgroupbox \ - qguard \ qguivariant \ qheaderview \ qhelpcontentmodel \ diff --git a/tests/auto/linguist/lconvert/data/endless-po-loop.ts b/tests/auto/linguist/lconvert/data/endless-po-loop.ts index 6212fbd..8aa7215 100644 --- a/tests/auto/linguist/lconvert/data/endless-po-loop.ts +++ b/tests/auto/linguist/lconvert/data/endless-po-loop.ts @@ -5,12 +5,12 @@ <name>Assistant</name> <message> <source>This is some text which introduces the DonauDampfSchifffahrtsKapitaensMuetzeMitKomischenUltraViolettenFransenUndEinemKnopf</source> - <translation></translation> + <translation type="unfinished"></translation> </message> <message> <location filename="this/is/a/really/really/absurdly/no,/grotesquely/long/path/supposed/to/blow/up.cpp" line="20"/> <source>%n document(s) found.</source> - <translation></translation> + <translation type="unfinished"></translation> </message> </context> </TS> diff --git a/tests/auto/linguist/lconvert/data/makeplurals.pl b/tests/auto/linguist/lconvert/data/makeplurals.pl index d933a3e..a2d1d700 100755 --- a/tests/auto/linguist/lconvert/data/makeplurals.pl +++ b/tests/auto/linguist/lconvert/data/makeplurals.pl @@ -57,14 +57,18 @@ sub makeit2($$$) } } -sub makeit($$) +sub makeit($$$) { open OUTFILE, ">${OUTDIR}plural-$_[0].po" || die "cannot write file in $OUTDIR"; print OUTFILE <<EOF; msgid "" msgstr "" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=UTF-8\\n" +"Content-Transfer-Encoding: 8bit\\n" "X-FooBar: yup\\n" "X-Language: $_[1]\\n" +"Plural-Forms: $_[2]\\n" EOF makeit2($_[0], "one", ""); makeit2($_[0], "two", "#, fuzzy @@ -77,6 +81,6 @@ EOF } $OUTDIR = $ARGV[0]; -makeit(1, "zh_CN"); -makeit(2, "de_DE"); -makeit(3, "pl_PL"); +makeit(1, "zh_CN", "nplurals=1; plural=0;"); +makeit(2, "de_DE", "nplurals=2; plural=(n != 1);"); +makeit(3, "pl_PL", "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"); diff --git a/tests/auto/linguist/lconvert/data/msgid.ts b/tests/auto/linguist/lconvert/data/msgid.ts index ab65845..39401d8 100644 --- a/tests/auto/linguist/lconvert/data/msgid.ts +++ b/tests/auto/linguist/lconvert/data/msgid.ts @@ -1,27 +1,27 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> -<TS version="2.0" sourcelanguage="en"> +<TS version="2.0"> <context> <name>Dialog2</name> <message numerus="yes"> <source>%n files</source> - <translation> + <translation type="unfinished"> <numerusform></numerusform> </translation> </message> <message id="this_is_some_id" numerus="yes"> <source>%n cars</source> - <translation> + <translation type="unfinished"> <numerusform></numerusform> </translation> </message> <message> <source>Age: %1</source> - <translation></translation> + <translation type="unfinished"></translation> </message> <message id="this_is_another_id"> <source>func3</source> - <translation></translation> + <translation type="unfinished"></translation> </message> </context> </TS> diff --git a/tests/auto/linguist/lconvert/data/singular.po b/tests/auto/linguist/lconvert/data/singular.po index a0d4019..9a2c91c 100644 --- a/tests/auto/linguist/lconvert/data/singular.po +++ b/tests/auto/linguist/lconvert/data/singular.po @@ -1,5 +1,8 @@ msgid "" msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" msgid "untranslated one" msgstr "translated" @@ -9,7 +12,6 @@ msgstr "translated" msgid "untranslated two" msgstr "translated" -#, fuzzy #| msgid "old untranslated" msgid "untranslated two b" msgstr "" @@ -20,7 +22,6 @@ msgstr "" msgid "untranslated three" msgstr "translated" -#, fuzzy #| msgid "old untranslated" #| msgid_plural "old untranslated plural" msgid "untranslated three b" @@ -31,7 +32,6 @@ msgstr "" msgid "untranslated four" msgstr "translated" -#, fuzzy #| msgid_plural "old untranslated only plural" msgid "untranslated four b" msgstr "" diff --git a/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out b/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out index 0a9f4c8..20fee33 100644 --- a/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out +++ b/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out @@ -1,6 +1,9 @@ # no comment msgid "" msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" msgid "this works" msgstr "das geht: ä" diff --git a/tests/auto/linguist/lconvert/data/test-escapes.po.out b/tests/auto/linguist/lconvert/data/test-escapes.po.out index 10eefb2..055fa79 100644 --- a/tests/auto/linguist/lconvert/data/test-escapes.po.out +++ b/tests/auto/linguist/lconvert/data/test-escapes.po.out @@ -1,5 +1,8 @@ msgid "" msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" msgid "" "this comes\n" diff --git a/tests/auto/linguist/lconvert/data/test-kde-fuzzy.po b/tests/auto/linguist/lconvert/data/test-kde-fuzzy.po index b3f6e03..fc9ae77 100644 --- a/tests/auto/linguist/lconvert/data/test-kde-fuzzy.po +++ b/tests/auto/linguist/lconvert/data/test-kde-fuzzy.po @@ -16,7 +16,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KAider 0.1\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: kgverify.cpp:459 #, fuzzy, kde-format diff --git a/tests/auto/linguist/lconvert/data/test-kde-multiline.po b/tests/auto/linguist/lconvert/data/test-kde-multiline.po index 0ca714c..662c02e 100644 --- a/tests/auto/linguist/lconvert/data/test-kde-multiline.po +++ b/tests/auto/linguist/lconvert/data/test-kde-multiline.po @@ -16,7 +16,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KAider 0.1\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: kdmshutdown.cpp:706 #, kde-format diff --git a/tests/auto/linguist/lconvert/data/test-kde-plurals.po b/tests/auto/linguist/lconvert/data/test-kde-plurals.po index 6c85d74..9f74de0 100644 --- a/tests/auto/linguist/lconvert/data/test-kde-plurals.po +++ b/tests/auto/linguist/lconvert/data/test-kde-plurals.po @@ -16,7 +16,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KAider 0.1\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Language: de_DE\n" #: kgverify.cpp:505 diff --git a/tests/auto/linguist/lconvert/data/test-slurp.po.out b/tests/auto/linguist/lconvert/data/test-slurp.po.out index 8859a70..11a874e 100644 --- a/tests/auto/linguist/lconvert/data/test-slurp.po.out +++ b/tests/auto/linguist/lconvert/data/test-slurp.po.out @@ -2,6 +2,9 @@ msgid "" msgstr "" "Project-Id-Version: kdmgreet\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" msgid "just a line" msgstr "indeed" diff --git a/tests/auto/linguist/lconvert/data/test1-de.po b/tests/auto/linguist/lconvert/data/test1-de.po index 256b8e9..a4523bb 100644 --- a/tests/auto/linguist/lconvert/data/test1-de.po +++ b/tests/auto/linguist/lconvert/data/test1-de.po @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KAider 0.1\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Language: de_DE\n" #: lib/acl.c:107 lib/acl.c:121 lib/acl.c:138 lib/acl.c:165 lib/acl.c:174 diff --git a/tests/auto/linguist/lconvert/data/wrapping.po b/tests/auto/linguist/lconvert/data/wrapping.po index 39b7fbe..9feb4a0 100644 --- a/tests/auto/linguist/lconvert/data/wrapping.po +++ b/tests/auto/linguist/lconvert/data/wrapping.po @@ -3,7 +3,6 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" @@ -13,7 +12,7 @@ msgstr "" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #, no-wrap diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index a6b9a5f..6aca996 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -83,6 +83,8 @@ private slots: void setTime(); void setTimeSpec(); void setTime_t(); + void setMSecsSinceEpoch_data(); + void setMSecsSinceEpoch(); void toString_enumformat(); void toString_strformat_data(); void toString_strformat(); @@ -437,6 +439,71 @@ void tst_QDateTime::setTime_t() } } +void tst_QDateTime::setMSecsSinceEpoch_data() +{ + QTest::addColumn<qint64>("msecs"); + QTest::addColumn<QDateTime>("utc"); + QTest::addColumn<QDateTime>("european"); + + QTest::newRow("zero") + << Q_INT64_C(0) + << QDateTime(QDate(1970, 1, 1), QTime(), Qt::UTC) + << QDateTime(QDate(1970, 1, 1), QTime(1, 0)); + QTest::newRow("-1") + << Q_INT64_C(-1) + << QDateTime(QDate(1969, 12, 31), QTime(23, 59, 59, 999), Qt::UTC) + << QDateTime(QDate(1970, 1, 1), QTime(0, 59, 59, 999)); + QTest::newRow("123456789") + << Q_INT64_C(123456789) + << QDateTime(QDate(1970, 1, 2), QTime(10, 17, 36, 789), Qt::UTC) + << QDateTime(QDate(1970, 1, 2), QTime(11, 17, 36, 789), Qt::LocalTime); + QTest::newRow("-123456789") + << Q_INT64_C(-123456789) + << QDateTime(QDate(1969, 12, 30), QTime(13, 42, 23, 211), Qt::UTC) + << QDateTime(QDate(1969, 12, 30), QTime(14, 42, 23, 211), Qt::LocalTime); + QTest::newRow("non-time_t") + << (Q_INT64_C(1000) << 32) + << QDateTime(QDate(2106, 2, 7), QTime(6, 28, 16), Qt::UTC) + << QDateTime(QDate(2106, 2, 7), QTime(7, 28, 16)); + QTest::newRow("very-large") + << (Q_INT64_C(123456) << 32) + << QDateTime(QDate(18772, 8, 15), QTime(1, 8, 14, 976), Qt::UTC) + << QDateTime(QDate(18772, 8, 15), QTime(3, 8, 14, 976)); + QTest::newRow("min_date") // julian day 0 is an invalid date for QDate + << Q_INT64_C(-210866716800000) + << QDateTime(QDate::fromJulianDay(1), QTime(), Qt::UTC) + << QDateTime(QDate::fromJulianDay(1), QTime(1, 0)); + QTest::newRow("max_date") // technically jd is unsigned, but fromJulianDay takes int + << Q_INT64_C(185331720376799999) + << QDateTime(QDate::fromJulianDay(0x7fffffff), QTime(21, 59, 59, 999), Qt::UTC) + << QDateTime(QDate::fromJulianDay(0x7fffffff), QTime(23, 59, 59, 999)); +} + +void tst_QDateTime::setMSecsSinceEpoch() +{ + QFETCH(qint64, msecs); + QFETCH(QDateTime, utc); + QFETCH(QDateTime, european); + + QDateTime dt; + dt.setTimeSpec(Qt::UTC); + dt.setMSecsSinceEpoch(msecs); + + QCOMPARE(dt, utc); + if (europeanTimeZone) { + QCOMPARE(dt.toLocalTime(), european); + } + + QCOMPARE(dt.toMSecsSinceEpoch(), msecs); + + if (quint64(msecs / 1000) < 0xFFFFFFFF) { + QCOMPARE(qint64(dt.toTime_t()), msecs / 1000); + } + + QDateTime reference(QDate(1970, 1, 1), QTime(), Qt::UTC); + QCOMPARE(dt, reference.addMSecs(msecs)); +} + void tst_QDateTime::toString_enumformat() { QDateTime dt1(QDate(1995, 5, 20), QTime(12, 34, 56)); @@ -932,7 +999,7 @@ void tst_QDateTime::currentDateTimeUtc2() do { local = QDateTime::currentDateTime(); utc = QDateTime::currentDateTimeUtc(); - msec = QDateTime::currentMsecsSinceEpoch(); + msec = QDateTime::currentMSecsSinceEpoch(); ok = local.time().msec() == utc.time().msec() && utc.time().msec() == (msec % 1000); } while (--i && !ok); @@ -953,6 +1020,8 @@ void tst_QDateTime::currentDateTimeUtc2() // and finally, the time_t should equal our number QCOMPARE(qint64(utc.toTime_t()), msec / 1000); QCOMPARE(qint64(local.toTime_t()), msec / 1000); + QCOMPARE(utc.toMSecsSinceEpoch(), msec); + QCOMPARE(local.toMSecsSinceEpoch(), msec); } void tst_QDateTime::toTime_t_data() diff --git a/tests/auto/qguard/qguard.pro b/tests/auto/qguard/qguard.pro deleted file mode 100644 index f249dde..0000000 --- a/tests/auto/qguard/qguard.pro +++ /dev/null @@ -1,2 +0,0 @@ -load(qttest_p4) -SOURCES += tst_qguard.cpp diff --git a/tests/auto/qguard/tst_qguard.cpp b/tests/auto/qguard/tst_qguard.cpp deleted file mode 100644 index 465ad0e..0000000 --- a/tests/auto/qguard/tst_qguard.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/**************************************************************************** -** -** 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 test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// NOTE: This is identical to the QPointer autotest - -#include <QtTest/QtTest> - -#include <QApplication> -#include <QDebug> -#include <QWidget> -#include <private/qguard_p.h> - -class tst_QGuard : public QObject -{ - Q_OBJECT -public: - tst_QGuard(); - ~tst_QGuard(); - - inline tst_QGuard *me() const - { return const_cast<tst_QGuard *>(this); } - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); -private slots: - void constructors(); - void destructor(); - void assignment_operators(); - void equality_operators(); - void isNull(); - void dereference_operators(); - void disconnect(); - void castDuringDestruction(); - void data() const; - void dataSignature() const; -}; - -tst_QGuard::tst_QGuard() -{ } - -tst_QGuard::~tst_QGuard() -{ } - -void tst_QGuard::initTestCase() -{ } - -void tst_QGuard::cleanupTestCase() -{ } - -void tst_QGuard::init() -{ } - -void tst_QGuard::cleanup() -{ } - -void tst_QGuard::constructors() -{ - QGuard<QObject> p1; - QGuard<QObject> p2(this); - QGuard<QObject> p3(p2); - QCOMPARE(p1, QGuard<QObject>(0)); - QCOMPARE(p2, QGuard<QObject>(this)); - QCOMPARE(p3, QGuard<QObject>(this)); -} - -void tst_QGuard::destructor() -{ - QObject *object = new QObject; - QGuard<QObject> p = object; - QCOMPARE(p, QGuard<QObject>(object)); - delete object; - QCOMPARE(p, QGuard<QObject>(0)); -} - -void tst_QGuard::assignment_operators() -{ - QGuard<QObject> p1; - QGuard<QObject> p2; - - p1 = this; - p2 = p1; - - QCOMPARE(p1, QGuard<QObject>(this)); - QCOMPARE(p2, QGuard<QObject>(this)); - QCOMPARE(p1, QGuard<QObject>(p2)); - - p1 = 0; - p2 = p1; - QCOMPARE(p1, QGuard<QObject>(0)); - QCOMPARE(p2, QGuard<QObject>(0)); - QCOMPARE(p1, QGuard<QObject>(p2)); - - QObject *object = new QObject; - - p1 = object; - p2 = p1; - QCOMPARE(p1, QGuard<QObject>(object)); - QCOMPARE(p2, QGuard<QObject>(object)); - QCOMPARE(p1, QGuard<QObject>(p2)); - - delete object; - QCOMPARE(p1, QGuard<QObject>(0)); - QCOMPARE(p2, QGuard<QObject>(0)); - QCOMPARE(p1, QGuard<QObject>(p2)); -} - -void tst_QGuard::equality_operators() -{ - QGuard<QObject> p1; - QGuard<QObject> p2; - - QVERIFY(p1 == p2); - - QObject *object = 0; - QWidget *widget = 0; - - p1 = object; - QVERIFY(p1 == p2); - QVERIFY(p1 == object); - p2 = object; - QVERIFY(p2 == p1); - QVERIFY(p2 == object); - - p1 = this; - QVERIFY(p1 != p2); - p2 = p1; - QVERIFY(p1 == p2); - - // compare to zero - p1 = 0; - QVERIFY(p1 == 0); - QVERIFY(0 == p1); - QVERIFY(p2 != 0); - QVERIFY(0 != p2); - QVERIFY(p1 == object); - QVERIFY(object == p1); - QVERIFY(p2 != object); - QVERIFY(object != p2); - QVERIFY(p1 == widget); - QVERIFY(widget == p1); - QVERIFY(p2 != widget); - QVERIFY(widget != p2); -} - -void tst_QGuard::isNull() -{ - QGuard<QObject> p1; - QVERIFY(p1.isNull()); - p1 = this; - QVERIFY(!p1.isNull()); - p1 = 0; - QVERIFY(p1.isNull()); -} - -void tst_QGuard::dereference_operators() -{ - QGuard<tst_QGuard> p1 = this; - - QObject *object = p1->me(); - QVERIFY(object == this); - - QObject &ref = *p1; - QVERIFY(&ref == this); - - object = static_cast<QObject *>(p1); - QVERIFY(object == this); -} - -void tst_QGuard::disconnect() -{ - QGuard<QObject> p1 = new QObject; - QVERIFY(!p1.isNull()); - p1->disconnect(); - QVERIFY(!p1.isNull()); - delete static_cast<QObject *>(p1); - QVERIFY(p1.isNull()); -} - -class ChildObject : public QObject -{ - QGuard<QObject> guardedPointer; - -public: - ChildObject(QObject *parent) - : QObject(parent), guardedPointer(parent) - { } - ~ChildObject(); -}; - -ChildObject::~ChildObject() -{ - QCOMPARE(static_cast<QObject *>(guardedPointer), static_cast<QObject *>(0)); - QCOMPARE(qobject_cast<QObject *>(guardedPointer), static_cast<QObject *>(0)); -} - -class ChildWidget : public QWidget -{ - QGuard<QWidget> guardedPointer; - -public: - ChildWidget(QWidget *parent) - : QWidget(parent), guardedPointer(parent) - { } - ~ChildWidget(); -}; - -ChildWidget::~ChildWidget() -{ - QCOMPARE(static_cast<QWidget *>(guardedPointer), static_cast<QWidget *>(0)); - QCOMPARE(qobject_cast<QWidget *>(guardedPointer), static_cast<QWidget *>(0)); -} - -class DerivedChild; - -class DerivedParent : public QObject -{ - Q_OBJECT - - DerivedChild *derivedChild; - -public: - DerivedParent(); - ~DerivedParent(); -}; - -class DerivedChild : public QObject -{ - Q_OBJECT - - DerivedParent *parentPointer; - QGuard<DerivedParent> guardedParentPointer; - -public: - DerivedChild(DerivedParent *parent) - : QObject(parent), parentPointer(parent), guardedParentPointer(parent) - { } - ~DerivedChild(); -}; - -DerivedParent::DerivedParent() - : QObject() -{ - derivedChild = new DerivedChild(this); -} - -DerivedParent::~DerivedParent() -{ - delete derivedChild; -} - -DerivedChild::~DerivedChild() -{ - QCOMPARE(static_cast<DerivedParent *>(guardedParentPointer), parentPointer); - QCOMPARE(qobject_cast<DerivedParent *>(guardedParentPointer), parentPointer); -} - -void tst_QGuard::castDuringDestruction() -{ - { - QObject *parentObject = new QObject(); - (void) new ChildObject(parentObject); - delete parentObject; - } - - { - QWidget *parentWidget = new QWidget(); - (void) new ChildWidget(parentWidget); - delete parentWidget; - } - - { - delete new DerivedParent(); - } -} - -void tst_QGuard::data() const -{ - /* Check value of a default constructed object. */ - { - QGuard<QObject> p; - QCOMPARE(p.data(), static_cast<QObject *>(0)); - } - - /* Check value of a default constructed object. */ - { - QObject *const object = new QObject(); - QGuard<QObject> p(object); - QCOMPARE(p.data(), object); - } -} - -void tst_QGuard::dataSignature() const -{ - /* data() should be const. */ - { - const QGuard<QObject> p; - p.data(); - } - - /* The return type should be T. */ - { - const QGuard<QWidget> p; - /* If the types differs, the QCOMPARE will fail to instansiate. */ - QCOMPARE(p.data(), static_cast<QWidget *>(0)); - } -} - -QTEST_MAIN(tst_QGuard) -#include "tst_qguard.moc" diff --git a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp index a3dfd6c..5f9a578 100644 --- a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp +++ b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp @@ -255,10 +255,6 @@ tst_Suite::tst_Suite() addTestExclusion("string-case", "V8-specific behavior? (Doesn't pass on SpiderMonkey either)"); -#ifdef Q_CC_MINGW - addTestExclusion("date$", "QTBUG-7698: Date.prototype.setMonth() crashes on win32-g++"); -#endif - #ifdef Q_OS_WINCE addTestExclusion("deep-recursion", "Demands too much memory on WinCE"); addTestExclusion("nested-repetition-count-overflow", "Demands too much memory on WinCE"); diff --git a/tests/auto/uic/baseline/config_fromuic3.ui.h b/tests/auto/uic/baseline/config_fromuic3.ui.h index c77b303..7e0189e 100644 --- a/tests/auto/uic/baseline/config_fromuic3.ui.h +++ b/tests/auto/uic/baseline/config_fromuic3.ui.h @@ -670,6 +670,7 @@ protected: }; static QPixmap qt_get_icon(IconID id) { + /* XPM */ static const char* const image0_data[] = { "22 22 2 1", ". c None", diff --git a/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h b/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h index 50cc4c8..40485ac 100644 --- a/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h +++ b/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h @@ -439,6 +439,7 @@ protected: }; static QPixmap qt_get_icon(IconID id) { + /* XPM */ static const char* const image0_data[] = { "22 22 2 1", ". c None", diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index 4e2b473..39ba9fd 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -402,7 +402,7 @@ bool DataModel::setLanguageAndCountry(QLocale::Language lang, QLocale::Country c if (lang == QLocale::C || uint(lang) > uint(QLocale::LastLanguage)) // XXX does this make any sense? lang = QLocale::English; QByteArray rules; - bool ok = getNumerusInfo(lang, country, &rules, &m_numerusForms); + bool ok = getNumerusInfo(lang, country, &rules, &m_numerusForms, 0); m_localizedLanguage = QCoreApplication::translate("MessageEditor", QLocale::languageToString(lang).toAscii()); m_countRefNeeds.clear(); for (int i = 0; i < rules.size(); ++i) { diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 0003baa..6c9157a 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -409,7 +409,7 @@ static void processProjects( int main(int argc, char **argv) { QCoreApplication app(argc, argv); - m_defaultExtensions = QLatin1String("ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx"); + m_defaultExtensions = QLatin1String("java,jui,ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx,js,qs,qml"); QStringList args = app.arguments(); QStringList tsFileNames; @@ -634,6 +634,7 @@ int main(int argc, char **argv) sourceFiles << fn; if (!fn.endsWith(QLatin1String(".java")) + && !fn.endsWith(QLatin1String(".jui")) && !fn.endsWith(QLatin1String(".ui")) && !fn.endsWith(QLatin1String(".js")) && !fn.endsWith(QLatin1String(".qs")) diff --git a/tools/linguist/shared/numerus.cpp b/tools/linguist/shared/numerus.cpp index d45dfed..6066732 100644 --- a/tools/linguist/shared/numerus.cpp +++ b/tools/linguist/shared/numerus.cpp @@ -64,7 +64,7 @@ static const uchar icelandicRules[] = static const uchar irishStyleRules[] = { Q_EQ, 1, Q_NEWRULE, Q_EQ, 2 }; -static const uchar slovakRules[] = +static const uchar slovakStyleRules[] = { Q_EQ, 1, Q_NEWRULE, Q_BETWEEN, 2, 4 }; static const uchar macedonianRules[] = @@ -100,7 +100,7 @@ static const uchar arabicRules[] = Q_EQ, 1, Q_NEWRULE, Q_EQ, 2, Q_NEWRULE, Q_MOD_100 | Q_BETWEEN, 3, 10, Q_NEWRULE, - Q_MOD_100 | Q_NOT | Q_BETWEEN, 0, 2 }; + Q_MOD_100 | Q_GEQ, 11 }; static const uchar tagalogRules[] = { Q_LEQ, 1, Q_NEWRULE, Q_MOD_10 | Q_EQ, 4, Q_OR, Q_MOD_10 | Q_EQ, 6, Q_OR, Q_MOD_10 | Q_EQ, 9 }; @@ -114,7 +114,7 @@ static const char * const frenchStyleForms[] = { "Singular", "Plural", 0 }; static const char * const icelandicForms[] = { "Singular", "Plural", 0 }; static const char * const latvianForms[] = { "Singular", "Plural", "Nullar", 0 }; static const char * const irishStyleForms[] = { "Singular", "Dual", "Plural", 0 }; -static const char * const slovakForms[] = { "Singular", "Paucal", "Plural", 0 }; +static const char * const slovakStyleForms[] = { "Singular", "Paucal", "Plural", 0 }; static const char * const macedonianForms[] = { "Singular", "Dual", "Plural", 0 }; static const char * const lithuanianForms[] = { "Singular", "Paucal", "Plural", 0 }; static const char * const russianStyleForms[] = { "Singular", "Dual", "Plural", 0 }; @@ -279,7 +279,7 @@ static const QLocale::Language irishStyleLanguages[] = { QLocale::Sanskrit, EOL }; -static const QLocale::Language slovakLanguages[] = { QLocale::Slovak, QLocale::Czech, EOL }; +static const QLocale::Language slovakStyleLanguages[] = { QLocale::Slovak, QLocale::Czech, EOL }; static const QLocale::Language macedonianLanguage[] = { QLocale::Macedonian, EOL }; static const QLocale::Language lithuanianLanguage[] = { QLocale::Lithuanian, EOL }; static const QLocale::Language russianStyleLanguages[] = { @@ -318,28 +318,45 @@ struct NumerusTableEntry { const char * const *forms; const QLocale::Language *languages; const QLocale::Country *countries; + const char * const gettextRules; }; static const NumerusTableEntry numerusTable[] = { - { 0, 0, japaneseStyleForms, japaneseStyleLanguages, 0 }, - { englishStyleRules, sizeof(englishStyleRules), englishStyleForms, englishStyleLanguages, 0 }, + { 0, 0, japaneseStyleForms, japaneseStyleLanguages, 0, "nplurals=1; plural=0;" }, + { englishStyleRules, sizeof(englishStyleRules), englishStyleForms, englishStyleLanguages, 0, + "nplurals=2; plural=(n != 1);" }, { frenchStyleRules, sizeof(frenchStyleRules), frenchStyleForms, frenchStyleLanguages, - frenchStyleCountries }, - { latvianRules, sizeof(latvianRules), latvianForms, latvianLanguage, 0 }, - { icelandicRules, sizeof(icelandicRules), icelandicForms, icelandicLanguage, 0 }, - { irishStyleRules, sizeof(irishStyleRules), irishStyleForms, irishStyleLanguages, 0 }, - { slovakRules, sizeof(slovakRules), slovakForms, slovakLanguages, 0 }, - { macedonianRules, sizeof(macedonianRules), macedonianForms, macedonianLanguage, 0 }, - { lithuanianRules, sizeof(lithuanianRules), lithuanianForms, lithuanianLanguage, 0 }, - { russianStyleRules, sizeof(russianStyleRules), russianStyleForms, russianStyleLanguages, 0 }, - { polishRules, sizeof(polishRules), polishForms, polishLanguage, 0 }, - { romanianRules, sizeof(romanianRules), romanianForms, romanianLanguages, 0 }, - { slovenianRules, sizeof(slovenianRules), slovenianForms, slovenianLanguage, 0 }, - { malteseRules, sizeof(malteseRules), malteseForms, malteseLanguage, 0 }, - { welshRules, sizeof(welshRules), welshForms, welshLanguage, 0 }, - { arabicRules, sizeof(arabicRules), arabicForms, arabicLanguage, 0 }, - { tagalogRules, sizeof(tagalogRules), tagalogForms, tagalogLanguage, 0 }, - { catalanRules, sizeof(catalanRules), catalanForms, catalanLanguage, 0 } + frenchStyleCountries, "nplurals=2; plural=(n > 1);" }, + { latvianRules, sizeof(latvianRules), latvianForms, latvianLanguage, 0, + "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);" }, + { icelandicRules, sizeof(icelandicRules), icelandicForms, icelandicLanguage, 0, + "nplurals=2; plural=(n%10==1 && n%100!=11 ? 0 : 1);" }, + { irishStyleRules, sizeof(irishStyleRules), irishStyleForms, irishStyleLanguages, 0, + "nplurals=3; plural=(n==1 ? 0 : n==2 ? 1 : 2);" }, + { slovakStyleRules, sizeof(slovakStyleRules), slovakStyleForms, slovakStyleLanguages, 0, + "nplurals=3; plural=((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);" }, + { macedonianRules, sizeof(macedonianRules), macedonianForms, macedonianLanguage, 0, + "nplurals=3; plural=(n%100==1 ? 0 : n%100==2 ? 1 : 2);" }, + { lithuanianRules, sizeof(lithuanianRules), lithuanianForms, lithuanianLanguage, 0, + "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);" }, + { russianStyleRules, sizeof(russianStyleRules), russianStyleForms, russianStyleLanguages, 0, + "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" }, + { polishRules, sizeof(polishRules), polishForms, polishLanguage, 0, + "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" }, + { romanianRules, sizeof(romanianRules), romanianForms, romanianLanguages, 0, + "nplurals=3; plural=(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);" }, + { slovenianRules, sizeof(slovenianRules), slovenianForms, slovenianLanguage, 0, + "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);" }, + { malteseRules, sizeof(malteseRules), malteseForms, malteseLanguage, 0, + "nplurals=4; plural=(n==1 ? 0 : (n==0 || (n%100>=1 && n%100<=10)) ? 1 : (n%100>=11 && n%100<=19) ? 2 : 3);" }, + { welshRules, sizeof(welshRules), welshForms, welshLanguage, 0, + "nplurals=5; plural=(n==0 ? 0 : n==1 ? 1 : (n>=2 && n<=5) ? 2 : n==6 ? 3 : 4);" }, + { arabicRules, sizeof(arabicRules), arabicForms, arabicLanguage, 0, + "nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : (n%100>=3 && n%100<=10) ? 3 : n%100>=11 ? 4 : 5);" }, + { tagalogRules, sizeof(tagalogRules), tagalogForms, tagalogLanguage, 0, + "nplurals=3; plural=(n==1 ? 0 : (n%10==4 || n%10==6 || n%10== 9) ? 1 : 2);" }, + { catalanRules, sizeof(catalanRules), catalanForms, catalanLanguage, 0, + "nplurals=3; plural=(n==1 ? 0 : (n==11 || n/1000==11 || n/1000000==11 || n/1000000000==11) ? 1 : 2);" }, }; static const int NumerusTableSize = sizeof(numerusTable) / sizeof(numerusTable[0]); @@ -352,7 +369,7 @@ static const uchar magic[MagicLength] = { }; bool getNumerusInfo(QLocale::Language language, QLocale::Country country, - QByteArray *rules, QStringList *forms) + QByteArray *rules, QStringList *forms, const char **gettextRules) { while (true) { for (int i = 0; i < NumerusTableSize; ++i) { @@ -365,6 +382,8 @@ bool getNumerusInfo(QLocale::Language language, QLocale::Country country, *rules = QByteArray::fromRawData(reinterpret_cast<const char *>(entry.rules), entry.rulesSize); } + if (gettextRules) + *gettextRules = entry.gettextRules; if (forms) { forms->clear(); for (int k = 0; entry.forms[k]; ++k) diff --git a/tools/linguist/shared/po.cpp b/tools/linguist/shared/po.cpp index 3354d61..097b4bf 100644 --- a/tools/linguist/shared/po.cpp +++ b/tools/linguist/shared/po.cpp @@ -45,6 +45,7 @@ #include <QtCore/QIODevice> #include <QtCore/QHash> #include <QtCore/QString> +#include <QtCore/QTextCodec> #include <QtCore/QTextStream> #include <ctype.h> @@ -201,55 +202,54 @@ public: public: - QString id; - QString context; - QString tscomment; - QString oldTscomment; - QString lineNumber; - QString fileName; - QString references; - QString translatorComments; - QString automaticComments; - QString msgId; - QString oldMsgId; - QStringList msgStr; + QByteArray id; + QByteArray context; + QByteArray tscomment; + QByteArray oldTscomment; + QByteArray lineNumber; + QByteArray fileName; + QByteArray references; + QByteArray translatorComments; + QByteArray automaticComments; + QByteArray msgId; + QByteArray oldMsgId; + QList<QByteArray> msgStr; bool isPlural; bool isFuzzy; QHash<QString, QString> extra; }; -static bool isTranslationLine(const QString &line) +static bool isTranslationLine(const QByteArray &line) { - return line.startsWith(QLatin1String("#~ msgstr")) - || line.startsWith(QLatin1String("msgstr")); + return line.startsWith("#~ msgstr") || line.startsWith("msgstr"); } -static QString slurpEscapedString(const QStringList &lines, int & l, - int offset, const QString &prefix, ConversionData &cd) +static QByteArray slurpEscapedString(const QList<QByteArray> &lines, int &l, + int offset, const QByteArray &prefix, ConversionData &cd) { - QString msg; + QByteArray msg; int stoff; for (; l < lines.size(); ++l) { - const QString &line = lines.at(l); + const QByteArray &line = lines.at(l); if (line.isEmpty() || !line.startsWith(prefix)) break; - while (line[offset].isSpace()) // No length check, as string has no trailing spaces. + while (::isspace(line[offset])) // No length check, as string has no trailing spaces. offset++; - if (line[offset].unicode() != '"') + if (line[offset] != '"') break; offset++; forever { if (offset == line.length()) goto premature_eol; - ushort c = line[offset++].unicode(); + uchar c = line[offset++]; if (c == '"') { if (offset == line.length()) break; - while (line[offset].isSpace()) + while (::isspace(line[offset])) offset++; - if (line[offset++].unicode() != '"') { + if (line[offset++] != '"') { cd.appendError(QString::fromLatin1( "PO parsing error: extra characters on line %1.") .arg(l + 1)); @@ -260,34 +260,34 @@ static QString slurpEscapedString(const QStringList &lines, int & l, if (c == '\\') { if (offset == line.length()) goto premature_eol; - c = line[offset++].unicode(); + c = line[offset++]; switch (c) { case 'r': - msg += QLatin1Char('\r'); // Maybe just throw it away? + msg += '\r'; // Maybe just throw it away? break; case 'n': - msg += QLatin1Char('\n'); + msg += '\n'; break; case 't': - msg += QLatin1Char('\t'); + msg += '\t'; break; case 'v': - msg += QLatin1Char('\v'); + msg += '\v'; break; case 'a': - msg += QLatin1Char('\a'); + msg += '\a'; break; case 'b': - msg += QLatin1Char('\b'); + msg += '\b'; break; case 'f': - msg += QLatin1Char('\f'); + msg += '\f'; break; case '"': - msg += QLatin1Char('"'); + msg += '"'; break; case '\\': - msg += QLatin1Char('\\'); + msg += '\\'; break; case '0': case '1': @@ -298,28 +298,28 @@ static QString slurpEscapedString(const QStringList &lines, int & l, case '6': case '7': stoff = offset - 1; - while ((c = line[offset].unicode()) >= '0' && c <= '7') + while ((c = line[offset]) >= '0' && c <= '7') if (++offset == line.length()) goto premature_eol; - msg += QChar(line.mid(stoff, offset - stoff).toUInt(0, 8)); + msg += line.mid(stoff, offset - stoff).toUInt(0, 8); break; case 'x': stoff = offset; - while (isxdigit(line[offset].unicode())) + while (::isxdigit(line[offset])) if (++offset == line.length()) goto premature_eol; - msg += QChar(line.mid(stoff, offset - stoff).toUInt(0, 16)); + msg += line.mid(stoff, offset - stoff).toUInt(0, 16); break; default: cd.appendError(QString::fromLatin1( "PO parsing error: invalid escape '\\%1' (line %2).") - .arg(QChar(c)).arg(l + 1)); - msg += QLatin1Char('\\'); - msg += QChar(c); + .arg(QChar((uint)c)).arg(l + 1)); + msg += '\\'; + msg += c; break; } } else { - msg += QChar(c); + msg += c; } } offset = prefix.size(); @@ -330,36 +330,61 @@ static QString slurpEscapedString(const QStringList &lines, int & l, premature_eol: cd.appendError(QString::fromLatin1( "PO parsing error: premature end of line %1.").arg(l + 1)); - return QString(); + return QByteArray(); } -static void slurpComment(QString &msg, const QStringList &lines, int & l) +static void slurpComment(QByteArray &msg, const QList<QByteArray> &lines, int & l) { - const QChar newline = QLatin1Char('\n'); - QString prefix = lines.at(l); + QByteArray prefix = lines.at(l); for (int i = 1; ; i++) { - if (prefix.at(i).unicode() != ' ') { + if (prefix.at(i) != ' ') { prefix.truncate(i); break; } } for (; l < lines.size(); ++l) { - const QString &line = lines.at(l); + const QByteArray &line = lines.at(l); if (line.startsWith(prefix)) msg += line.mid(prefix.size()); - else if (line != QLatin1String("#")) + else if (line != "#") break; - msg += newline; + msg += '\n'; } --l; } +static QString makePoHeader(const QString &str) +{ + return QLatin1String("po-header-") + str.toLower().replace(QLatin1Char('-'), QLatin1Char('_')); +} + +static QByteArray QByteArrayList_join(const QList<QByteArray> &that, char sep) +{ + int totalLength = 0; + const int size = that.size(); + + for (int i = 0; i < size; ++i) + totalLength += that.at(i).size(); + + if (size > 0) + totalLength += size - 1; + + QByteArray res; + if (totalLength == 0) + return res; + res.reserve(totalLength); + for (int i = 0; i < that.size(); ++i) { + if (i) + res += sep; + res += that.at(i); + } + return res; +} + bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) { - const QChar quote = QLatin1Char('"'); - const QChar newline = QLatin1Char('\n'); - QTextStream in(&dev); - in.setCodec(cd.m_codecForSource.isEmpty() ? QByteArray("UTF-8") : cd.m_codecForSource); + QTextCodec *codec = QTextCodec::codecForName( + cd.m_codecForSource.isEmpty() ? QByteArray("UTF-8") : cd.m_codecForSource); bool error = false; // format of a .po file entry: @@ -380,25 +405,23 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) // ... // we need line based lookahead below. - QStringList lines; - while (!in.atEnd()) - lines.append(in.readLine().trimmed()); - lines.append(QString()); + QList<QByteArray> lines; + while (!dev.atEnd()) + lines.append(dev.readLine().trimmed()); + lines.append(QByteArray()); - int l = 0; + int l = 0, lastCmtLine = -1; PoItem item; for (; l != lines.size(); ++l) { - QString line = lines.at(l); + QByteArray line = lines.at(l); if (line.isEmpty()) continue; if (isTranslationLine(line)) { - bool isObsolete = line.startsWith(QLatin1String("#~ msgstr")); - const QString prefix = QLatin1String(isObsolete ? "#~ " : ""); + bool isObsolete = line.startsWith("#~ msgstr"); + const QByteArray prefix = isObsolete ? "#~ " : ""; while (true) { - int idx = line.indexOf(QLatin1Char(' '), prefix.length()); - QString str = slurpEscapedString(lines, l, idx, prefix, cd); - str.replace(QChar(Translator::TextVariantSeparator), - QChar(Translator::BinaryVariantSeparator)); + int idx = line.indexOf(' ', prefix.length()); + QByteArray str = slurpEscapedString(lines, l, idx, prefix, cd); item.msgStr.append(str); if (l + 1 >= lines.size() || !isTranslationLine(lines.at(l + 1))) break; @@ -406,31 +429,109 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) line = lines.at(l); } if (item.msgId.isEmpty()) { - QRegExp rx(QLatin1String("\\bX-Language: ([^\n]*)\n")); - int idx = rx.indexIn(item.msgStr.first()); - if (idx >= 0) { - translator.setLanguageCode(rx.cap(1)); - item.msgStr.first().remove(idx, rx.matchedLength()); + QHash<QString, QByteArray> extras; + QList<QByteArray> hdrOrder; + QByteArray pluralForms; + foreach (const QByteArray &hdr, item.msgStr.first().split('\n')) { + if (hdr.isEmpty()) + continue; + int idx = hdr.indexOf(':'); + if (idx < 0) { + cd.appendError(QString::fromLatin1("Unexpected PO header format '%1'\n") + .arg(QString::fromLatin1(hdr))); + error = true; + break; + } + QByteArray hdrName = hdr.left(idx).trimmed(); + QByteArray hdrValue = hdr.mid(idx + 1).trimmed(); + hdrOrder << hdrName; + if (hdrName == "X-Language") { + translator.setLanguageCode(QString::fromLatin1(hdrValue)); + } else if (hdrName == "X-Source-Language") { + translator.setSourceLanguageCode(QString::fromLatin1(hdrValue)); + } else if (hdrName == "Plural-Forms") { + pluralForms = hdrValue; + } else if (hdrName == "MIME-Version") { + // just assume it is 1.0 + } else if (hdrName == "Content-Type") { + if (cd.m_codecForSource.isEmpty()) { + if (!hdrValue.startsWith("text/plain; charset=")) { + cd.appendError(QString::fromLatin1("Unexpected Content-Type header '%1'\n") + .arg(QString::fromLatin1(hdrValue))); + error = true; + // This will avoid a flood of conversion errors. + codec = QTextCodec::codecForName("latin1"); + } else { + QByteArray cod = hdrValue.mid(20); + QTextCodec *cdc = QTextCodec::codecForName(cod); + if (!cdc) { + cd.appendError(QString::fromLatin1("Unsupported codec '%1'\n") + .arg(QString::fromLatin1(cod))); + error = true; + // This will avoid a flood of conversion errors. + codec = QTextCodec::codecForName("latin1"); + } else { + codec = cdc; + } + } + } + } else if (hdrName == "Content-Transfer-Encoding") { + if (hdrValue != "8bit") { + cd.appendError(QString::fromLatin1("Unexpected Content-Transfer-Encoding '%1'\n") + .arg(QString::fromLatin1(hdrValue))); + return false; + } + } else if (hdrName == "X-Virgin-Header") { + // legacy + } else { + extras[makePoHeader(QString::fromLatin1(hdrName))] = hdrValue; + } } - QRegExp rx2(QLatin1String("\\bX-Source-Language: ([^\n]*)\n")); - int idx2 = rx2.indexIn(item.msgStr.first()); - if (idx2 >= 0) { - translator.setSourceLanguageCode(rx2.cap(1)); - item.msgStr.first().remove(idx2, rx2.matchedLength()); + if (!pluralForms.isEmpty()) { + if (translator.languageCode().isEmpty()) { + extras[makePoHeader(QLatin1String("Plural-Forms"))] = pluralForms; + } else { + // FIXME: have fun with making a consistency check ... + } } - if (item.msgStr.first().indexOf( - QRegExp(QLatin1String("\\bX-Virgin-Header:[^\n]*\n"))) >= 0) { - item = PoItem(); - continue; + // Eliminate the field if only headers we added are present in standard order. + // Keep in sync with savePO + static const char * const dfltHdrs[] = { + "MIME-Version", "Content-Type", "Content-Transfer-Encoding", + "Plural-Forms", "X-Language", "X-Source-Language" + }; + uint cdh = 0; + for (int cho = 0; cho < hdrOrder.length(); cho++) { + for (;; cdh++) { + if (cdh == sizeof(dfltHdrs)/sizeof(dfltHdrs[0])) { + extras[QLatin1String("po-headers")] = + QByteArrayList_join(hdrOrder, ','); + goto doneho; + } + if (hdrOrder.at(cho) == dfltHdrs[cdh]) { + cdh++; + break; + } + } } + doneho: + if (lastCmtLine != -1) + extras[QLatin1String("po-header_comment")] = + QByteArrayList_join(lines.mid(0, lastCmtLine + 1), '\n'); + for (QHash<QString, QByteArray>::ConstIterator it = extras.constBegin(), + end = extras.constEnd(); + it != end; ++it) + translator.setExtra(it.key(), codec->toUnicode(it.value())); + item = PoItem(); + continue; } // build translator message TranslatorMessage msg; - msg.setContext(item.context); + msg.setContext(codec->toUnicode(item.context)); if (!item.references.isEmpty()) { foreach (const QString &ref, - item.references.split(QRegExp(QLatin1String("\\s")), - QString::SkipEmptyParts)) { + codec->toUnicode(item.references).split( + QRegExp(QLatin1String("\\s")), QString::SkipEmptyParts)) { int pos = ref.lastIndexOf(QLatin1Char(':')); if (pos != -1) msg.addReference(ref.left(pos), ref.mid(pos + 1).toInt()); @@ -438,18 +539,25 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) } else if (isObsolete) { msg.setFileName(QLatin1String(MAGIC_OBSOLETE_REFERENCE)); } - msg.setId(item.id); - msg.setSourceText(item.msgId); - msg.setOldSourceText(item.oldMsgId); - msg.setComment(item.tscomment); - msg.setOldComment(item.oldTscomment); - msg.setExtraComment(item.automaticComments); - msg.setTranslatorComment(item.translatorComments); + msg.setId(codec->toUnicode(item.id)); + msg.setSourceText(codec->toUnicode(item.msgId)); + msg.setOldSourceText(codec->toUnicode(item.oldMsgId)); + msg.setComment(codec->toUnicode(item.tscomment)); + msg.setOldComment(codec->toUnicode(item.oldTscomment)); + msg.setExtraComment(codec->toUnicode(item.automaticComments)); + msg.setTranslatorComment(codec->toUnicode(item.translatorComments)); msg.setPlural(item.isPlural || item.msgStr.size() > 1); - msg.setTranslations(item.msgStr); + QStringList translations; + foreach (const QByteArray &bstr, item.msgStr) { + QString str = codec->toUnicode(bstr); + str.replace(QChar(Translator::TextVariantSeparator), + QChar(Translator::BinaryVariantSeparator)); + translations << str; + } + msg.setTranslations(translations); if (isObsolete) msg.setType(TranslatorMessage::Obsolete); - else if (item.isFuzzy) + else if (item.isFuzzy || (!msg.sourceText().isEmpty() && !msg.isTranslated())) msg.setType(TranslatorMessage::Unfinished); else msg.setType(TranslatorMessage::Finished); @@ -460,18 +568,19 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) //qDebug() << flags << msg.m_extra; translator.append(msg); item = PoItem(); - } else if (line.startsWith(QLatin1Char('#'))) { - switch(line.size() < 2 ? 0 : line.at(1).unicode()) { + } else if (line.startsWith('#')) { + switch (line.size() < 2 ? 0 : line.at(1)) { case ':': item.references += line.mid(3); - item.references += newline; + item.references += '\n'; break; case ',': { QStringList flags = - line.mid(2).split(QRegExp(QLatin1String("[, ]")), - QString::SkipEmptyParts); + QString::fromLatin1(line.mid(2)).split( + QRegExp(QLatin1String("[, ]")), QString::SkipEmptyParts); if (flags.removeOne(QLatin1String("fuzzy"))) item.isFuzzy = true; + flags.removeOne(QLatin1String("qt-format")); TranslatorMessage::ExtraData::const_iterator it = item.extra.find(QLatin1String("po-flags")); if (it != item.extra.end()) @@ -481,103 +590,130 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) break; } case 0: - item.translatorComments += newline; + item.translatorComments += '\n'; break; case ' ': slurpComment(item.translatorComments, lines, l); break; case '.': - if (line.startsWith(QLatin1String("#. ts-context "))) { + if (line.startsWith("#. ts-context ")) { item.context = line.mid(14); - } else if (line.startsWith(QLatin1String("#. ts-id "))) { + } else if (line.startsWith("#. ts-id ")) { item.id = line.mid(9); } else { item.automaticComments += line.mid(3); - item.automaticComments += newline; + item.automaticComments += '\n'; } break; case '|': - if (line.startsWith(QLatin1String("#| msgid "))) { - item.oldMsgId = slurpEscapedString(lines, l, 9, QLatin1String("#| "), cd); - } else if (line.startsWith(QLatin1String("#| msgid_plural "))) { - QString extra = slurpEscapedString(lines, l, 16, QLatin1String("#| "), cd); + if (line.startsWith("#| msgid ")) { + item.oldMsgId = slurpEscapedString(lines, l, 9, "#| ", cd); + } else if (line.startsWith("#| msgid_plural ")) { + QByteArray extra = slurpEscapedString(lines, l, 16, "#| ", cd); if (extra != item.oldMsgId) - item.extra[QLatin1String("po-old_msgid_plural")] = extra; - } else if (line.startsWith(QLatin1String("#| msgctxt "))) { - item.oldTscomment = slurpEscapedString(lines, l, 11, QLatin1String("#| "), cd); + item.extra[QLatin1String("po-old_msgid_plural")] = + codec->toUnicode(extra); + } else if (line.startsWith("#| msgctxt ")) { + item.oldTscomment = slurpEscapedString(lines, l, 11, "#| ", cd); } else { cd.appendError(QString(QLatin1String("PO-format parse error in line %1: '%2'\n")) - .arg(l + 1).arg(lines[l])); + .arg(l + 1).arg(codec->toUnicode(lines[l]))); error = true; } break; case '~': - if (line.startsWith(QLatin1String("#~ msgid "))) { - item.msgId = slurpEscapedString(lines, l, 9, QLatin1String("#~ "), cd); - } else if (line.startsWith(QLatin1String("#~ msgid_plural "))) { - QString extra = slurpEscapedString(lines, l, 16, QLatin1String("#~ "), cd); + if (line.startsWith("#~ msgid ")) { + item.msgId = slurpEscapedString(lines, l, 9, "#~ ", cd); + } else if (line.startsWith("#~ msgid_plural ")) { + QByteArray extra = slurpEscapedString(lines, l, 16, "#~ ", cd); if (extra != item.msgId) - item.extra[QLatin1String("po-msgid_plural")] = extra; + item.extra[QLatin1String("po-msgid_plural")] = + codec->toUnicode(extra); item.isPlural = true; - } else if (line.startsWith(QLatin1String("#~ msgctxt "))) { - item.tscomment = slurpEscapedString(lines, l, 11, QLatin1String("#~ "), cd); + } else if (line.startsWith("#~ msgctxt ")) { + item.tscomment = slurpEscapedString(lines, l, 11, "#~ ", cd); } else { cd.appendError(QString(QLatin1String("PO-format parse error in line %1: '%2'\n")) - .arg(l + 1).arg(lines[l])); + .arg(l + 1).arg(codec->toUnicode(lines[l]))); error = true; } break; default: cd.appendError(QString(QLatin1String("PO-format parse error in line %1: '%2'\n")) - .arg(l + 1).arg(lines[l])); + .arg(l + 1).arg(codec->toUnicode(lines[l]))); error = true; break; } - } else if (line.startsWith(QLatin1String("msgctxt "))) { - item.tscomment = slurpEscapedString(lines, l, 8, QString(), cd); - } else if (line.startsWith(QLatin1String("msgid "))) { - item.msgId = slurpEscapedString(lines, l, 6, QString(), cd); - } else if (line.startsWith(QLatin1String("msgid_plural "))) { - QString extra = slurpEscapedString(lines, l, 13, QString(), cd); + lastCmtLine = l; + } else if (line.startsWith("msgctxt ")) { + item.tscomment = slurpEscapedString(lines, l, 8, QByteArray(), cd); + } else if (line.startsWith("msgid ")) { + item.msgId = slurpEscapedString(lines, l, 6, QByteArray(), cd); + } else if (line.startsWith("msgid_plural ")) { + QByteArray extra = slurpEscapedString(lines, l, 13, QByteArray(), cd); if (extra != item.msgId) - item.extra[QLatin1String("po-msgid_plural")] = extra; + item.extra[QLatin1String("po-msgid_plural")] = codec->toUnicode(extra); item.isPlural = true; } else { cd.appendError(QString(QLatin1String("PO-format error in line %1: '%2'\n")) - .arg(l + 1).arg(lines[l])); + .arg(l + 1).arg(codec->toUnicode(lines[l]))); error = true; } } return !error && cd.errors().isEmpty(); } +static void addPoHeader(Translator::ExtraData &headers, QStringList &hdrOrder, + const char *name, const QString &value) +{ + QString qName = QLatin1String(name); + if (!hdrOrder.contains(qName)) + hdrOrder << qName; + headers[makePoHeader(qName)] = value; +} + bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd) { + QString str_format = QLatin1String("-format"); + bool ok = true; QTextStream out(&dev); out.setCodec(cd.m_outputCodec.isEmpty() ? QByteArray("UTF-8") : cd.m_outputCodec); - bool first = true; - if (translator.messages().isEmpty() || !translator.messages().first().sourceText().isEmpty()) { - out << - "# SOME DESCRIPTIVE TITLE.\n" - "# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER\n" - "# This file is distributed under the same license as the PACKAGE package.\n" - "# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\n" - "#\n" - "#, fuzzy\n" - "msgid \"\"\n" - "msgstr \"\"\n" - "\"X-Virgin-Header: remove this line if you change anything in the header.\\n\"\n"; - if (!translator.languageCode().isEmpty()) - out << "\"X-Language: " << translator.languageCode() << "\\n\"\n"; - if (!translator.sourceLanguageCode().isEmpty()) - out << "\"X-Source-Language: " << translator.sourceLanguageCode() << "\\n\"\n"; - first = false; + QString cmt = translator.extra(QLatin1String("po-header_comment")); + if (!cmt.isEmpty()) + out << cmt << '\n'; + out << "msgid \"\"\n"; + Translator::ExtraData headers = translator.extras(); + QStringList hdrOrder = translator.extra(QLatin1String("po-headers")).split( + QLatin1Char(','), QString::SkipEmptyParts); + // Keep in sync with loadPO + addPoHeader(headers, hdrOrder, "MIME-Version", QLatin1String("1.0")); + addPoHeader(headers, hdrOrder, "Content-Type", + QLatin1String("text/plain; charset=" + out.codec()->name())); + addPoHeader(headers, hdrOrder, "Content-Transfer-Encoding", QLatin1String("8bit")); + if (!translator.languageCode().isEmpty()) { + QLocale::Language l; + QLocale::Country c; + Translator::languageAndCountry(translator.languageCode(), &l, &c); + const char *gettextRules; + if (getNumerusInfo(l, c, 0, 0, &gettextRules)) + addPoHeader(headers, hdrOrder, "Plural-Forms", QLatin1String(gettextRules)); + addPoHeader(headers, hdrOrder, "X-Language", translator.languageCode()); } + if (!translator.sourceLanguageCode().isEmpty()) + addPoHeader(headers, hdrOrder, "X-Source-Language", translator.sourceLanguageCode()); + QString hdrStr; + foreach (const QString &hdr, hdrOrder) { + hdrStr += hdr; + hdrStr += QLatin1String(": "); + hdrStr += headers.value(makePoHeader(hdr)); + hdrStr += QLatin1Char('\n'); + } + out << poEscapedString(QString(), QString::fromLatin1("msgstr"), true, hdrStr); + foreach (const TranslatorMessage &msg, translator.messages()) { - if (!first) - out << endl; + out << endl; if (!msg.translatorComment().isEmpty()) out << poEscapedLines(QLatin1String("#"), true, msg.translatorComment()); @@ -599,16 +735,36 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd) } bool noWrap = false; + bool skipFormat = false; QStringList flags; - if (msg.type() == TranslatorMessage::Unfinished) + if (msg.type() == TranslatorMessage::Unfinished && msg.isTranslated()) flags.append(QLatin1String("fuzzy")); TranslatorMessage::ExtraData::const_iterator itr = msg.extras().find(QLatin1String("po-flags")); if (itr != msg.extras().end()) { - if (itr->split(QLatin1String(", ")).contains(QLatin1String("no-wrap"))) + QStringList atoms = itr->split(QLatin1String(", ")); + foreach (const QString &atom, atoms) + if (atom.endsWith(str_format)) { + skipFormat = true; + break; + } + if (atoms.contains(QLatin1String("no-wrap"))) noWrap = true; flags.append(*itr); } + if (!skipFormat) { + QString source = msg.sourceText(); + // This is fuzzy logic, as we don't know whether the string is + // actually used with QString::arg(). + for (int off = 0; (off = source.indexOf(QLatin1Char('%'), off)) >= 0; ) { + if (++off >= source.length()) + break; + if (source.at(off) == QLatin1Char('n') || source.at(off).isDigit()) { + flags.append(QLatin1String("qt-format")); + break; + } + } + } if (!flags.isEmpty()) out << "#, " << flags.join(QLatin1String(", ")) << '\n'; @@ -626,11 +782,8 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd) out << poEscapedString(prefix, QLatin1String("msgid"), noWrap, msg.sourceText()); if (!msg.isPlural()) { QString transl = msg.translation(); - if (first) { - transl.remove(QRegExp(QLatin1String("\\bX-Language:[^\n]*\n"))); - if (!translator.languageCode().isEmpty()) - transl += QLatin1String("X-Language: ") + translator.languageCode() + QLatin1Char('\n'); - } + transl.replace(QChar(Translator::BinaryVariantSeparator), + QChar(Translator::TextVariantSeparator)); out << poEscapedString(prefix, QLatin1String("msgstr"), noWrap, transl); } else { QString plural = msg.extra(QLatin1String("po-msgid_plural")); @@ -646,11 +799,17 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd) str); } } - first = false; } return ok; } +static bool savePOT(const Translator &translator, QIODevice &dev, ConversionData &cd) +{ + Translator ttor = translator; + ttor.dropTranslations(); + return savePO(ttor, dev, cd); +} + int initPO() { Translator::FileFormat format; @@ -661,6 +820,13 @@ int initPO() format.fileType = Translator::FileFormat::TranslationSource; format.priority = 1; Translator::registerFileFormat(format); + format.extension = QLatin1String("pot"); + format.description = QObject::tr("GNU Gettext localization template files"); + format.loader = &loadPO; + format.saver = &savePOT; + format.fileType = Translator::FileFormat::TranslationSource; + format.priority = -1; + Translator::registerFileFormat(format); return 1; } diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index de1284f..e2c4f4a 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -564,7 +564,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) Translator::languageAndCountry(translator.languageCode(), &l, &c); QStringList numerusForms; bool guessPlurals = true; - if (getNumerusInfo(l, c, 0, &numerusForms)) + if (getNumerusInfo(l, c, 0, &numerusForms, 0)) guessPlurals = (numerusForms.count() == 1); QString context, contextUtf8; @@ -704,7 +704,7 @@ static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData QLocale::Country c; Translator::languageAndCountry(translator.languageCode(), &l, &c); QByteArray rules; - if (getNumerusInfo(l, c, &rules, 0)) + if (getNumerusInfo(l, c, &rules, 0, 0)) releaser.setNumerusRules(rules); releaser.setCodecName(translator.codecName()); diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 4331ce6..465355d 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -652,7 +652,7 @@ void Translator::normalizeTranslations(ConversionData &cd) int numPlurals = 1; if (l != QLocale::C) { QStringList forms; - if (getNumerusInfo(l, c, 0, &forms)) + if (getNumerusInfo(l, c, 0, &forms, 0)) numPlurals = forms.count(); // includes singular } for (int i = 0; i < m_messages.count(); ++i) { diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 0b88c07..bb199f0 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -233,7 +233,7 @@ private: }; bool getNumerusInfo(QLocale::Language language, QLocale::Country country, - QByteArray *rules, QStringList *forms); + QByteArray *rules, QStringList *forms, const char **gettextRules); /* This is a quick hack. The proper way to handle this would be diff --git a/tools/linguist/shared/xliff.cpp b/tools/linguist/shared/xliff.cpp index 20303ec..6411426 100644 --- a/tools/linguist/shared/xliff.cpp +++ b/tools/linguist/shared/xliff.cpp @@ -503,6 +503,8 @@ bool XLIFFHandler::startElement(const QString& namespaceURI, m_language.replace(QLatin1Char('-'), QLatin1Char('_')); m_sourceLanguage = atts.value(QLatin1String("source-language")); m_sourceLanguage.replace(QLatin1Char('-'), QLatin1Char('_')); + if (m_sourceLanguage == QLatin1String("en")) + m_sourceLanguage.clear(); } else if (localName == QLatin1String("group")) { if (atts.value(QLatin1String("restype")) == QLatin1String(restypeContext)) { m_context = atts.value(QLatin1String("resname")); diff --git a/tools/qdoc3/codemarker.cpp b/tools/qdoc3/codemarker.cpp index 15f2c2d..818a91f 100644 --- a/tools/qdoc3/codemarker.cpp +++ b/tools/qdoc3/codemarker.cpp @@ -457,7 +457,7 @@ bool CodeMarker::insertReimpFunc(FastSection& fs, Node* node, Status status) void CodeMarker::append(QList<Section>& sectionList, const FastSection& fs) { if (!fs.isEmpty()) { - Section section(fs.name,fs.singularMember,fs.pluralMember); + Section section(fs.name,fs.divClass,fs.singularMember,fs.pluralMember); section.members = fs.memberMap.values(); section.reimpMembers = fs.reimpMemberMap.values(); section.inherited = fs.inherited; diff --git a/tools/qdoc3/codemarker.h b/tools/qdoc3/codemarker.h index 1b21753..aab8a9c 100644 --- a/tools/qdoc3/codemarker.h +++ b/tools/qdoc3/codemarker.h @@ -58,6 +58,7 @@ class Tree; struct Section { QString name; + QString divClass; QString singularMember; QString pluralMember; NodeList members; @@ -66,9 +67,11 @@ struct Section Section() { } Section(const QString& name0, + const QString& divClass0, const QString& singularMember0, const QString& pluralMember0) - : name(name0), + : name(name0), + divClass(divClass0), singularMember(singularMember0), pluralMember(pluralMember0) { } void appendMember(Node* node) { members.append(node); } @@ -79,6 +82,7 @@ struct FastSection { const InnerNode *innerNode; QString name; + QString divClass; QString singularMember; QString pluralMember; QMap<QString, Node *> memberMap; @@ -86,20 +90,30 @@ struct FastSection QList<QPair<ClassNode *, int> > inherited; FastSection(const InnerNode *innerNode0, - const QString& name0 = "", - const QString& singularMember0 = "member", - const QString& pluralMember0 = "members") + const QString& name0, + const QString& divClass0, + const QString& singularMember0, + const QString& pluralMember0) : innerNode(innerNode0), name(name0), + divClass(divClass0), singularMember(singularMember0), pluralMember(pluralMember0) { } bool isEmpty() const { - return (memberMap.isEmpty() && inherited.isEmpty() && + return (memberMap.isEmpty() && + inherited.isEmpty() && reimpMemberMap.isEmpty()); } }; +#if 0 + const QString& name0 = "", + const QString& divClass0 = "", + const QString& singularMember0 = "member", + const QString& pluralMember0 = "members") +#endif + class CodeMarker { public: diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index 3ff6ebe..c4ee054 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -482,55 +482,66 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner, if (style == Summary) { FastSection privateFunctions(classe, "Private Functions", + "", "private function", "private functions"); - FastSection privateSlots(classe, "Private Slots", "private slot", "private slots"); - FastSection privateTypes(classe, "Private Types", "private type", "private types"); + FastSection privateSlots(classe, "Private Slots", "", "private slot", "private slots"); + FastSection privateTypes(classe, "Private Types", "", "private type", "private types"); FastSection protectedFunctions(classe, "Protected Functions", + "", "protected function", "protected functions"); FastSection protectedSlots(classe, "Protected Slots", + "", "protected slot", "protected slots"); FastSection protectedTypes(classe, "Protected Types", + "", "protected type", "protected types"); FastSection protectedVariables(classe, "Protected Variables", + "", "protected type", "protected variables"); FastSection publicFunctions(classe, "Public Functions", + "", "public function", "public functions"); - FastSection publicSignals(classe, "Signals", "signal", "signals"); - FastSection publicSlots(classe, "Public Slots", "public slot", "public slots"); - FastSection publicTypes(classe, "Public Types", "public type", "public types"); + FastSection publicSignals(classe, "Signals", "", "signal", "signals"); + FastSection publicSlots(classe, "Public Slots", "", "public slot", "public slots"); + FastSection publicTypes(classe, "Public Types", "", "public type", "public types"); FastSection publicVariables(classe, "Public Variables", - "public type", + "", + "public variable", "public variables"); - FastSection properties(classe, "Properties", "property", "properties"); + FastSection properties(classe, "Properties", "", "property", "properties"); FastSection relatedNonMembers(classe, "Related Non-Members", + "", "related non-member", "related non-members"); FastSection staticPrivateMembers(classe, "Static Private Members", + "", "static private member", "static private members"); FastSection staticProtectedMembers(classe, "Static Protected Members", + "", "static protected member", "static protected members"); FastSection staticPublicMembers(classe, "Static Public Members", + "", "static public member", "static public members"); - FastSection macros(inner, "Macros", "macro", "macros"); + FastSection macros(inner, "Macros", "", "macro", "macros"); NodeList::ConstIterator r = classe->relatedNodes().begin(); while (r != classe->relatedNodes().end()) { @@ -666,12 +677,12 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner, append(sections, macros); } else if (style == Detailed) { - FastSection memberFunctions(classe,"Member Function Documentation"); - FastSection memberTypes(classe,"Member Type Documentation"); - FastSection memberVariables(classe,"Member Variable Documentation"); - FastSection properties(classe,"Property Documentation"); - FastSection relatedNonMembers(classe,"Related Non-Members"); - FastSection macros(classe,"Macro Documentation"); + FastSection memberFunctions(classe,"Member Function Documentation","func","member","members"); + FastSection memberTypes(classe,"Member Type Documentation","types","member","members"); + FastSection memberVariables(classe,"Member Variable Documentation","vars","member","members"); + FastSection properties(classe,"Property Documentation","prop","member","members"); + FastSection relatedNonMembers(classe,"Related Non-Members","relnonmem","member","members"); + FastSection macros(classe,"Macro Documentation","macros","member","members"); NodeList::ConstIterator r = classe->relatedNodes().begin(); while (r != classe->relatedNodes().end()) { @@ -717,7 +728,7 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner, append(sections, macros); } else { - FastSection all(classe); + FastSection all(classe,"","","member","members"); QStack<const ClassNode *> stack; stack.push(classe); @@ -747,25 +758,29 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner, if (style == Summary || style == Detailed) { FastSection namespaces(inner, "Namespaces", + style == Detailed ? "nmspace" : "", "namespace", "namespaces"); FastSection classes(inner, "Classes", + style == Detailed ? "classes" : "", "class", "classes"); FastSection types(inner, - style == Summary ? - "Types" : "Type Documentation", + style == Summary ? "Types" : "Type Documentation", + style == Detailed ? "types" : "", "type", "types"); FastSection functions(inner, style == Summary ? "Functions" : "Function Documentation", + style == Detailed ? "func" : "", "function", "functions"); FastSection macros(inner, style == Summary ? "Macros" : "Macro Documentation", + style == Detailed ? "macros" : "", "macro", "macros"); @@ -1116,26 +1131,32 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, if (style == Summary) { FastSection qmlproperties(qmlClassNode, "Properties", + "", "property", "properties"); FastSection qmlattachedproperties(qmlClassNode, "Attached Properties", + "", "property", "properties"); FastSection qmlsignals(qmlClassNode, - "Signals", - "signal", - "signals"); + "Signals", + "", + "signal", + "signals"); FastSection qmlattachedsignals(qmlClassNode, "Attached Signals", + "", "signal", "signals"); FastSection qmlmethods(qmlClassNode, "Methods", + "", "method", "methods"); FastSection qmlattachedmethods(qmlClassNode, "Attached Methods", + "", "method", "methods"); @@ -1179,12 +1200,15 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, append(sections,qmlattachedmethods); } else if (style == Detailed) { - FastSection qmlproperties(qmlClassNode, "Property Documentation"); - FastSection qmlattachedproperties(qmlClassNode,"Attached Property Documentation"); - FastSection qmlsignals(qmlClassNode,"Signal Documentation"); - FastSection qmlattachedsignals(qmlClassNode,"Attached Signal Documentation"); - FastSection qmlmethods(qmlClassNode,"Method Documentation"); - FastSection qmlattachedmethods(qmlClassNode,"Attached Method Documentation"); + FastSection qmlproperties(qmlClassNode, "Property Documentation","qmlprop","member","members"); + FastSection qmlattachedproperties(qmlClassNode,"Attached Property Documentation","qmlattprop", + "member","members"); + FastSection qmlsignals(qmlClassNode,"Signal Documentation","qmlsig","member","members"); + FastSection qmlattachedsignals(qmlClassNode,"Attached Signal Documentation","qmlattsig", + "member","members"); + FastSection qmlmethods(qmlClassNode,"Method Documentation","qmlmeth","member","members"); + FastSection qmlattachedmethods(qmlClassNode,"Attached Method Documentation","qmlattmeth", + "member","members"); NodeList::ConstIterator c = qmlClassNode->childNodes().begin(); while (c != qmlClassNode->childNodes().end()) { if ((*c)->subType() == Node::QmlPropertyGroup) { diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index cd3da3e..fb9fa95 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -696,7 +696,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, QList<Section> sections; QList<Section>::ConstIterator s; for (int i=0; i<LastSinceType; ++i) - sections.append(Section(sinceTitle(i),QString(),QString())); + sections.append(Section(sinceTitle(i),QString(),QString(),QString())); NodeMultiMap::const_iterator n = nsmap.value().constBegin(); while (n != nsmap.value().constEnd()) { @@ -1356,8 +1356,10 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, if (!inner->doc().isEmpty()) { out() << "<hr />\n" + << "<div class=\"descr\"/>\n" << "<h2>" << "Detailed Description" << "</h2>\n"; generateBody(inner, marker); + out() << "</div>\n"; generateAlsoList(inner, marker); } @@ -1365,6 +1367,8 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, s = sections.begin(); while (s != sections.end()) { out() << "<hr />\n"; + if (!(*s).divClass.isEmpty()) + out() << "<div class=\"" << (*s).divClass << "\"/>\n"; out() << "<h2>" << protectEnc((*s).name) << "</h2>\n"; NodeList::ConstIterator m = (*s).members.begin(); @@ -1414,6 +1418,8 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, } ++m; } + if (!(*s).divClass.isEmpty()) + out() << "</div>\n"; ++s; } generateFooter(inner); diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 37d6b31..a2bd948 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -1334,7 +1334,7 @@ QString QmlClassNode::fileBase() const void QmlClassNode::addInheritedBy(const QString& base, Node* sub) { inheritedBy.insert(base,sub); -#ifdef DEBUG_MULTIPLE-QDOCCONF_FILES +#ifdef DEBUG_MULTIPLE_QDOCCONF_FILES qDebug() << "QmlClassNode::addInheritedBy(): insert" << base << sub->name() << inheritedBy.size(); #endif } diff --git a/tools/qdoc3/qscodemarker.cpp b/tools/qdoc3/qscodemarker.cpp index 89c9c5c..d4b8e80 100644 --- a/tools/qdoc3/qscodemarker.cpp +++ b/tools/qdoc3/qscodemarker.cpp @@ -279,11 +279,11 @@ QList<Section> QsCodeMarker::sections( const InnerNode *inner, SynopsisStyle sty const ClassNode *classe = static_cast<const ClassNode *>(inner); if ( style == Summary ) { - FastSection enums(classe, "Enums", "enum", "enums"); - FastSection functions(classe, "Functions", "function", "functions"); - FastSection readOnlyProperties(classe, "Read-Only Properties", "property", "properties"); - FastSection signalz(classe, "Signals", "signal", "signals"); - FastSection writableProperties(classe, "Writable Properties", "property", "properties"); + FastSection enums(classe, "Enums", "", "enum", "enums"); + FastSection functions(classe, "Functions", "", "function", "functions"); + FastSection readOnlyProperties(classe, "", "Read-Only Properties", "property", "properties"); + FastSection signalz(classe, "Signals", "", "signal", "signals"); + FastSection writableProperties(classe, "", "Writable Properties", "property", "properties"); QStack<const ClassNode *> stack; stack.push( classe ); @@ -328,9 +328,9 @@ QList<Section> QsCodeMarker::sections( const InnerNode *inner, SynopsisStyle sty append( sections, functions ); append( sections, signalz ); } else if ( style == Detailed ) { - FastSection enums( classe, "Enum Documentation" ); - FastSection functionsAndSignals( classe, "Function and Signal Documentation" ); - FastSection properties( classe, "Property Documentation" ); + FastSection enums( classe, "Enum Documentation", "", "member", "members"); + FastSection functionsAndSignals( classe, "Function and Signal Documentation", "", "member", "members"); + FastSection properties( classe, "Property Documentation", "", "member", "members"); NodeList::ConstIterator c = classe->childNodes().begin(); while ( c != classe->childNodes().end() ) { @@ -349,7 +349,7 @@ QList<Section> QsCodeMarker::sections( const InnerNode *inner, SynopsisStyle sty append( sections, properties ); append( sections, functionsAndSignals ); } else { // ( style == SeparateList ) - FastSection all( classe ); + FastSection all(classe, "", "", "member", "members"); QStack<const ClassNode *> stack; stack.push( classe ); |