diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-12 13:55:57 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-12 13:55:57 (GMT) |
commit | 41cbfc5c8e6644ab21e92860db95b2e8da9aba6a (patch) | |
tree | 3629877036a08414a969d6f2693d7f5970dd62c3 /src/corelib | |
parent | 47760d59d57f548d5816ae43e456c86e01146491 (diff) | |
parent | bd11cdf472674af3b00d7d64c64023adbf5ee725 (diff) | |
download | Qt-41cbfc5c8e6644ab21e92860db95b2e8da9aba6a.zip Qt-41cbfc5c8e6644ab21e92860db95b2e8da9aba6a.tar.gz Qt-41cbfc5c8e6644ab21e92860db95b2e8da9aba6a.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (158 commits)
qdoc: Yet another revision of the top doc page.
Doc: Update on web template
Added QDateTime::msecsTo()
Doc: Fixed tables and images for the new docs
qdoc: Yet another revision of the top doc page.
Revert "Improve QUrl handling of local file paths"
Revert "[QNAM FTP] Check for the "ftp" scheme case-insensitively"
Revert "QUrl::fromLocalFile: fix silly mistake: it's fromNativeSeparators, not to"
Revert "Use QUrl::isLocalFile and fix the scheme checking in local URLs."
qdoc: Another revision of the top doc page.
Doc correction to css
Doc: Updates to the html template and javascript
tst_SuiteTest: Fix a meaningless switch statement
My 4.7.0 changelog entries.
qdoc: Fixed annotated list generation to use <td>, not <th>.
Doc: Tuning search script
qdoc: Reorganized examples panel.
Doc: Chages to search feature, css and table order
QtDeclarative: avoid waiting for a network load on URIs with empty schemes.
QtDeclarative: RFC 3986 requires schemes to be considered case-insensitively
...
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qurl.cpp | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel.cpp | 56 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 13 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication_p.h | 7 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_symbian.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_symbian_p.h | 1 | ||||
-rw-r--r-- | src/corelib/tools/qchar.cpp | 31 | ||||
-rw-r--r-- | src/corelib/tools/qchar.h | 9 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 44 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.h | 1 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 12 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 18 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_symbian.cpp | 53 | ||||
-rw-r--r-- | src/corelib/tools/qmap.h | 20 |
14 files changed, 259 insertions, 14 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 4e580dd..d4b8b5f 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5557,6 +5557,12 @@ QUrl QUrl::resolved(const QUrl &relative) const removeDotsFromPath(&t.d->encodedPath); t.d->path.clear(); +#if defined(QURL_DEBUG) + qDebug("QUrl(\"%s\").resolved(\"%s\") = \"%s\"", + toEncoded().constData(), + relative.toEncoded().constData(), + t.toEncoded().constData()); +#endif return t; } diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index b0503be..3660a3c 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -2530,6 +2530,62 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star condition is true, in which case you should abort your move operation. + \table 80% + \row + \o \inlineimage modelview-move-rows-1.png Moving rows to another parent + \o Specify the first and last row numbers for the span of rows in + the source parent you want to move in the model. Also specify + the row in the destination parent to move the span to. + + For example, as shown in the diagram, we move three rows from + row 2 to 4 in the source, so \a sourceFirst is 2 and \a sourceLast is 4. + We move those items to above row 2 in the destination, so \a destinationRow is 2. + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 6 + + This moves the three rows rows 2, 3, and 4 in the source to become 2, 3 and 4 in + the destination. Other affected siblings are displaced accordingly. + \row + \o \inlineimage modelview-move-rows-2.png Moving rows to append to another parent + \o To append rows to another parent, move them to after the last row. + + For example, as shown in the diagram, we move three rows to a + collection of 6 existing rows (ending in row 5), so \a destinationStart is 6: + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 7 + + This moves the target rows to the end of the target parent as 6, 7 and 8. + \row + \o \inlineimage modelview-move-rows-3.png Moving rows in the same parent up + \o To move rows within the same parent, specify the row to move them to. + + For example, as shown in the diagram, we move one item from row 2 to row 0, + so \a sourceFirst and \a sourceLast are 2 and \a destinationChild is 0. + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 8 + + Note that other rows may be displaced accordingly. Note also that when moving + items within the same parent you should not attempt invalid or no-op moves. In + the above example, item 2 is at row 2 before the move, so it can not be moved + to row 2 (where it is already) or row 3 (no-op as row 3 means above row 3, where + it is already) + + \row + \o \inlineimage modelview-move-rows-4.png Moving rows in the same parent down + \o To move rows within the same parent, specify the row to move them to. + + For example, as shown in the diagram, we move one item from row 2 to row 4, + so \a sourceFirst and \a sourceLast are 2 and \a destinationChild is 4. + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 9 + + Note that other rows may be displaced accordingly. + \endtable + + \note This function emits the rowsAboutToBeInserted() signal which + connected views (or proxies) must handle before the data is inserted. + Otherwise, the views may end up in an invalid state. + \sa endMoveRows() \since 4.6 diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 609e6b3..4e6e6b9 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -63,6 +63,7 @@ #include <qvarlengtharray.h> #include <private/qfactoryloader_p.h> #include <private/qfunctions_p.h> +#include <private/qlocale_p.h> #ifdef Q_OS_SYMBIAN # include <exception> @@ -521,6 +522,9 @@ QCoreApplication::QCoreApplication(int &argc, char **argv) QFactoryLoader::refreshAll(); #endif +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) + d_func()->symbianInit(); +#endif } // ### move to QCoreApplicationPrivate constructor? @@ -597,6 +601,15 @@ void QCoreApplication::init() qt_startup_hook(); } +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) +void QCoreApplicationPrivate::symbianInit() +{ + if (!environmentChangeNotifier) + environmentChangeNotifier.reset(new QEnvironmentChangeNotifier); +} +#endif + + /*! Destroys the QCoreApplication object. */ diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 77188d3..e066137 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -65,6 +65,9 @@ QT_BEGIN_NAMESPACE typedef QList<QTranslator*> QTranslatorList; +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) +class QEnvironmentChangeNotifier; +#endif class QAbstractEventDispatcher; class Q_CORE_EXPORT QCoreApplicationPrivate : public QObjectPrivate @@ -113,6 +116,10 @@ public: bool aboutToQuitEmitted; QString cachedApplicationDirPath; QString cachedApplicationFilePath; +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) + QScopedPointer<QEnvironmentChangeNotifier> environmentChangeNotifier; + void symbianInit(); +#endif static bool isTranslatorInstalled(QTranslator *translator); diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index a6d486e..687a6d9 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -1105,3 +1105,5 @@ void CQtActiveScheduler::Error(TInt aError) const } QT_END_NAMESPACE + +#include "moc_qeventdispatcher_symbian_p.cpp" diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 05758ca..bc42753 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -221,6 +221,7 @@ public: // from CActiveScheduler class Q_CORE_EXPORT QEventDispatcherSymbian : public QAbstractEventDispatcher { + Q_OBJECT Q_DECLARE_PRIVATE(QAbstractEventDispatcher) public: diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 67ea00d..2f09b0e 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -653,14 +653,41 @@ bool QChar::isSymbol() const \fn bool QChar::isHighSurrogate() const Returns true if the QChar is the high part of a utf16 surrogate - (ie. if its code point is between 0xd800 and 0xdbff). + (ie. if its code point is between 0xd800 and 0xdbff, inclusive). */ /*! \fn bool QChar::isLowSurrogate() const Returns true if the QChar is the low part of a utf16 surrogate - (ie. if its code point is between 0xdc00 and 0xdfff). + (ie. if its code point is between 0xdc00 and 0xdfff, inclusive). +*/ + +/*! + \fn static bool QChar::isHighSurrogate(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is the high part of a utf16 surrogate + (ie. if its code point is between 0xd800 and 0xdbff, inclusive). +*/ + +/*! + \fn static bool QChar::isLowSurrogate(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is the high part of a utf16 surrogate + (ie. if its code point is between 0xdc00 and 0xdfff, inclusive). +*/ + +/*! + \fn static bool QChar::requiresSurrogates(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + can be splited to the high and low parts of a utf16 surrogate + (ie. if its code point is greater than or equals to 0x10000). */ /*! diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index 1432c7f..205f911 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -285,6 +285,15 @@ public: inline void setCell(uchar cell); inline void setRow(uchar row); + static inline bool isHighSurrogate(uint ucs4) { + return ((ucs4 & 0xfffffc00) == 0xd800); + } + static inline bool isLowSurrogate(uint ucs4) { + return ((ucs4 & 0xfffffc00) == 0xdc00); + } + static inline bool requiresSurrogates(uint ucs4) { + return (ucs4 >= 0x10000); + } static inline uint surrogateToUcs4(ushort high, ushort low) { return (uint(high)<<10) + low - 0x35fdc00; } diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 9afcd80..9f5d8c6 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1705,7 +1705,7 @@ int QTime::secsTo(const QTime &t) const Note that the time will wrap if it passes midnight. See addSecs() for an example. - \sa addSecs(), msecsTo() + \sa addSecs(), msecsTo(), QDateTime::addMSecs() */ QTime QTime::addMSecs(int ms) const @@ -1734,7 +1734,7 @@ QTime QTime::addMSecs(int ms) const seconds in a day, the result is always between -86400000 and 86400000 ms. - \sa secsTo(), addMSecs() + \sa secsTo(), addMSecs(), QDateTime::msecsTo() */ int QTime::msecsTo(const QTime &t) const @@ -2042,10 +2042,11 @@ int QTime::elapsed() const later. You can increment (or decrement) a datetime by a given number of - seconds using addSecs(), or days using addDays(). Similarly you can - use addMonths() and addYears(). The daysTo() function returns the - number of days between two datetimes, and secsTo() returns the - number of seconds between two datetimes. + milliseconds using addMSecs(), seconds using addSecs(), or days + using addDays(). Similarly you can use addMonths() and addYears(). + The daysTo() function returns the number of days between two datetimes, + secsTo() returns the number of seconds between two datetimes, and + msecsTo() returns the number of milliseconds between two datetimes. QDateTime can store datetimes as \l{Qt::LocalTime}{local time} or as \l{Qt::UTC}{UTC}. QDateTime::currentDateTime() returns a @@ -2719,7 +2720,7 @@ QDateTime QDateTime::addSecs(int s) const later than the datetime of this object (or earlier if \a msecs is negative). - \sa addSecs(), secsTo(), addDays(), addMonths(), addYears() + \sa addSecs(), msecsTo(), addDays(), addMonths(), addYears() */ QDateTime QDateTime::addMSecs(qint64 msecs) const { @@ -2731,7 +2732,7 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const datetime. If the \a other datetime is earlier than this datetime, the value returned is negative. - \sa addDays(), secsTo() + \sa addDays(), secsTo(), msecsTo() */ int QDateTime::daysTo(const QDateTime &other) const @@ -2766,6 +2767,33 @@ int QDateTime::secsTo(const QDateTime &other) const } /*! + Returns the number of milliseconds from this datetime to the \a other + datetime. If the \a other datetime is earlier than this datetime, + the value returned is negative. + + Before performing the comparison, the two datetimes are converted + to Qt::UTC to ensure that the result is correct if one of the two + datetimes has daylight saving time (DST) and the other doesn't. + + \sa addMSecs(), daysTo(), QTime::msecsTo() +*/ + +qint64 QDateTime::msecsTo(const QDateTime &other) const +{ + QDate selfDate; + QDate otherDate; + QTime selfTime; + QTime otherTime; + + d->getUTC(selfDate, selfTime); + other.d->getUTC(otherDate, otherTime); + + return (static_cast<qint64>(selfDate.daysTo(otherDate)) * static_cast<qint64>(MSECS_PER_DAY)) + + static_cast<qint64>(selfTime.msecsTo(otherTime)); +} + + +/*! \fn QDateTime QDateTime::toTimeSpec(Qt::TimeSpec specification) const Returns a copy of this datetime configured to use the given time diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index f445f1c..2466aeb 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -251,6 +251,7 @@ public: inline QDateTime toUTC() const { return toTimeSpec(Qt::UTC); } int daysTo(const QDateTime &) const; int secsTo(const QDateTime &) const; + qint64 msecsTo(const QDateTime &) const; bool operator==(const QDateTime &other) const; inline bool operator!=(const QDateTime &other) const { return !(*this == other); } diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index c3f6783..20c2e27 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -129,6 +129,11 @@ inline bool isascii(int c) } #endif +#if defined(Q_OS_SYMBIAN) +void qt_symbianUpdateSystemPrivate(); +void qt_symbianInitSystemLocale(); +#endif + /****************************************************************************** ** Helpers for accessing Qt locale database */ @@ -1407,6 +1412,9 @@ static const QSystemLocale *systemLocale() { if (_systemLocale) return _systemLocale; +#if defined(Q_OS_SYMBIAN) + qt_symbianInitSystemLocale(); +#endif return QSystemLocale_globalSystemLocale(); } @@ -1417,6 +1425,10 @@ void QLocalePrivate::updateSystemPrivate() system_lp = globalLocalePrivate(); *system_lp = *sys_locale->fallbackLocale().d(); +#if defined(Q_OS_SYMBIAN) + qt_symbianUpdateSystemPrivate(); +#endif + QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant()); if (!res.isNull()) system_lp->m_language_id = res.toInt(); diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index ecf79e9..6205745 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -58,6 +58,10 @@ #include "qlocale.h" +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) +class CEnvironmentChangeNotifier; +#endif + QT_BEGIN_NAMESPACE struct Q_CORE_EXPORT QLocalePrivate @@ -201,6 +205,20 @@ inline char QLocalePrivate::digitToCLocale(const QChar &in) const return 0; } +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) +class QEnvironmentChangeNotifier +{ +public: + QEnvironmentChangeNotifier(); + ~QEnvironmentChangeNotifier(); + + static TInt localeChanged(TAny *data); + +private: + CEnvironmentChangeNotifier *iChangeNotifier; +}; +#endif + QT_END_NAMESPACE #endif // QLOCALE_P_H diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 01f56cc..6e36dcd 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -46,8 +46,14 @@ #include <QThread> #include <e32std.h> +#include <e32const.h> +#include <e32base.h> +#include <e32property.h> +#include <bacntf.h> #include "private/qcore_symbian_p.h" - +#include "private/qcoreapplication_p.h" +#include "private/qlocale_p.h" +#include <qdebug.h> QT_BEGIN_NAMESPACE @@ -771,13 +777,18 @@ static QLocale::MeasurementSystem symbianMeasurementSystem() return QLocale::MetricSystem; } -QLocale QSystemLocale::fallbackLocale() const +void qt_symbianUpdateSystemPrivate() { // load system data before query calls + _s60Locale.LoadSystemSettings(); +} + +void qt_symbianInitSystemLocale() +{ static QBasicAtomicInt initDone = Q_BASIC_ATOMIC_INITIALIZER(0); + if (initDone == 2) + return; if (initDone.testAndSetRelaxed(0, 1)) { - _s60Locale.LoadSystemSettings(); - // Initialize platform version dependent function pointers ptrTimeFormatL = reinterpret_cast<FormatFunc> (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL)); @@ -801,7 +812,10 @@ QLocale QSystemLocale::fallbackLocale() const } while(initDone != 2) QThread::yieldCurrentThread(); +} +QLocale QSystemLocale::fallbackLocale() const +{ TLanguage lang = User::Language(); QString locale = QLatin1String(qt_symbianLocaleName(lang)); return QLocale(locale); @@ -884,4 +898,35 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const return QVariant(); } +#if !defined(QT_NO_SYSTEMLOCALE) +QEnvironmentChangeNotifier::QEnvironmentChangeNotifier() +{ + // Create the change notifier and install the callback function + const TCallBack callback(&QEnvironmentChangeNotifier::localeChanged, this); + QT_TRAP_THROWING(iChangeNotifier = CEnvironmentChangeNotifier::NewL(CActive::EPriorityStandard, callback)); + iChangeNotifier->Start(); +} + +TInt QEnvironmentChangeNotifier::localeChanged(TAny *data) +{ + QEnvironmentChangeNotifier *that = reinterpret_cast<QEnvironmentChangeNotifier *>(data); + + TInt flag = that->iChangeNotifier->Change(); + if (flag & EChangesLocale) { + static bool first = true; + if (!first) { // skip the first notification on app startup + QT_TRYCATCH_LEAVING(QLocalePrivate::updateSystemPrivate()); + QT_TRYCATCH_LEAVING(QCoreApplication::postEvent(qApp, new QEvent(QEvent::LocaleChange))); + } + first = false; + } + return KErrNone; +} + +QEnvironmentChangeNotifier::~QEnvironmentChangeNotifier() +{ + delete iChangeNotifier; +} +#endif + QT_END_NAMESPACE diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index df0ae46..5696ba6 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -125,6 +125,10 @@ template <class Key, class T> struct QMapNode { Key key; T value; + +private: + // never access these members through this structure. + // see below QMapData::Node *backward; QMapData::Node *forward[1]; }; @@ -134,6 +138,22 @@ struct QMapPayloadNode { Key key; T value; + +private: + // QMap::e is a pointer to QMapData::Node, which matches the member + // below. However, the memory allocation node in QMapData::node_create + // allocates sizeof(QMapPayloNode) and incorrectly calculates the offset + // of 'backward' below. If the alignment of QMapPayloadNode is larger + // than the alignment of a pointer, the 'backward' member is aligned to + // the end of this structure, not to 'value' above, and will occupy the + // tail-padding area. + // + // e.g., on a 32-bit archictecture with Key = int and + // sizeof(T) = alignof(T) = 8 + // 0 4 8 12 16 20 24 byte + // | key | PAD | value |backward| PAD | correct layout + // | key | PAD | value | |backward| how it's actually used + // |<----- value of QMap::payload() = 20 ----->| QMapData::Node *backward; }; |