diff options
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qcollator_icu.cpp | 43 | ||||
-rw-r--r-- | src/corelib/tools/qelapsedtimer_win.cpp | 10 | ||||
-rw-r--r-- | src/corelib/tools/qmargins.cpp | 21 | ||||
-rw-r--r-- | src/corelib/tools/qpoint.cpp | 13 | ||||
-rw-r--r-- | src/corelib/tools/qrect.cpp | 15 | ||||
-rw-r--r-- | src/corelib/tools/qsize.cpp | 13 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 6 | ||||
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 9 | ||||
-rw-r--r-- | src/corelib/tools/qvarlengtharray.qdoc | 9 |
9 files changed, 94 insertions, 45 deletions
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp index 6fa681b63b..f068f22d13 100644 --- a/src/corelib/tools/qcollator_icu.cpp +++ b/src/corelib/tools/qcollator_icu.cpp @@ -52,8 +52,12 @@ void QCollatorPrivate::init() UErrorCode status = U_ZERO_ERROR; QByteArray name = locale.bcp47Name().replace(QLatin1Char('-'), QLatin1Char('_')).toLatin1(); collator = ucol_open(name.constData(), &status); - if (U_FAILURE(status)) + if (U_FAILURE(status)) { qWarning("Could not create collator: %d", status); + collator = 0; + dirty = false; + return; + } // enable normalization by default ucol_setAttribute(collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status); @@ -97,17 +101,26 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con if (d->dirty) d->init(); - return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2); + if (d->collator) + return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2); + + return QString::compare(QString(s1, len1), QString(s2, len2), d->caseSensitivity); } int QCollator::compare(const QString &s1, const QString &s2) const { - return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); + if (d->collator) + return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); + + return QString::compare(s1, s2, d->caseSensitivity); } int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const { - return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); + if (d->collator) + return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); + + return QStringRef::compare(s1, s2, d->caseSensitivity); } QCollatorSortKey QCollator::sortKey(const QString &string) const @@ -115,16 +128,20 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const if (d->dirty) d->init(); - QByteArray result(16 + string.size() + (string.size() >> 2), Qt::Uninitialized); - int size = ucol_getSortKey(d->collator, (const UChar *)string.constData(), - string.size(), (uint8_t *)result.data(), result.size()); - if (size > result.size()) { - result.resize(size); - size = ucol_getSortKey(d->collator, (const UChar *)string.constData(), - string.size(), (uint8_t *)result.data(), result.size()); + if (d->collator) { + QByteArray result(16 + string.size() + (string.size() >> 2), Qt::Uninitialized); + int size = ucol_getSortKey(d->collator, (const UChar *)string.constData(), + string.size(), (uint8_t *)result.data(), result.size()); + if (size > result.size()) { + result.resize(size); + size = ucol_getSortKey(d->collator, (const UChar *)string.constData(), + string.size(), (uint8_t *)result.data(), result.size()); + } + result.truncate(size); + return QCollatorSortKey(new QCollatorSortKeyPrivate(result)); } - result.truncate(size); - return QCollatorSortKey(new QCollatorSortKeyPrivate(result)); + + return QCollatorSortKey(new QCollatorSortKeyPrivate(QByteArray())); } int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp index dcddc96e32..eab2f8ef6c 100644 --- a/src/corelib/tools/qelapsedtimer_win.cpp +++ b/src/corelib/tools/qelapsedtimer_win.cpp @@ -52,19 +52,13 @@ static void resolveLibs() if (done) return; -#ifndef Q_OS_WINRT +#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE) // try to get GetTickCount64 from the system HMODULE kernel32 = GetModuleHandleW(L"kernel32"); if (!kernel32) return; - -#if defined(Q_OS_WINCE) - // does this function exist on WinCE, or will ever exist? - ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, L"GetTickCount64"); -#else ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64"); -#endif -#endif // !Q_OS_WINRT +#endif // !Q_OS_WINRT && !Q_OS_WINCE // Retrieve the number of high-resolution performance counter ticks per second LARGE_INTEGER frequency; diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index a9413d6b5c..92c977a73b 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -33,7 +33,8 @@ #include "qmargins.h" #include "qdatastream.h" -#include "qdebug.h" + +#include <private/qdebug_p.h> QT_BEGIN_NAMESPACE @@ -431,10 +432,13 @@ QDataStream &operator>>(QDataStream &s, QMargins &m) #endif // QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QMargins &m) { +QDebug operator<<(QDebug dbg, const QMargins &m) +{ QDebugStateSaver saver(dbg); - dbg.nospace() << "QMargins(" << m.left() << ", " - << m.top() << ", " << m.right() << ", " << m.bottom() << ')'; + dbg.nospace(); + dbg << "QMargins" << '('; + QtDebugUtils::formatQMargins(dbg, m); + dbg << ')'; return dbg; } #endif @@ -764,10 +768,13 @@ QDataStream &operator>>(QDataStream &s, QMarginsF &m) #endif // QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QMarginsF &m) { +QDebug operator<<(QDebug dbg, const QMarginsF &m) +{ QDebugStateSaver saver(dbg); - dbg.nospace() << "QMarginsF(" << m.left() << ", " - << m.top() << ", " << m.right() << ", " << m.bottom() << ')'; + dbg.nospace(); + dbg << "QMarginsF" << '('; + QtDebugUtils::formatQMargins(dbg, m); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index ebce6c9422..dc2a2d9739 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -33,7 +33,8 @@ #include "qpoint.h" #include "qdatastream.h" -#include "qdebug.h" + +#include <private/qdebug_p.h> QT_BEGIN_NAMESPACE @@ -447,14 +448,20 @@ QDataStream &operator>>(QDataStream &s, QPoint &p) QDebug operator<<(QDebug dbg, const QPoint &p) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QPoint(" << p.x() << ',' << p.y() << ')'; + dbg.nospace(); + dbg << "QPoint" << '('; + QtDebugUtils::formatQPoint(dbg, p); + dbg << ')'; return dbg; } QDebug operator<<(QDebug dbg, const QPointF &p) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QPointF(" << p.x() << ',' << p.y() << ')'; + dbg.nospace(); + dbg << "QPointF" << '('; + QtDebugUtils::formatQPoint(dbg, p); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 35cf2d5e5b..b2174745e4 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -33,9 +33,10 @@ #include "qrect.h" #include "qdatastream.h" -#include "qdebug.h" #include "qmath.h" +#include <private/qdebug_p.h> + QT_BEGIN_NAMESPACE /*! @@ -1279,8 +1280,10 @@ QDataStream &operator>>(QDataStream &s, QRect &r) QDebug operator<<(QDebug dbg, const QRect &r) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QRect(" << r.x() << ',' << r.y() << ' ' - << r.width() << 'x' << r.height() << ')'; + dbg.nospace(); + dbg << "QRect" << '('; + QtDebugUtils::formatQRect(dbg, r); + dbg << ')'; return dbg; } #endif @@ -2488,8 +2491,10 @@ QDataStream &operator>>(QDataStream &s, QRectF &r) QDebug operator<<(QDebug dbg, const QRectF &r) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' ' - << r.width() << 'x' << r.height() << ')'; + dbg.nospace(); + dbg << "QRectF" << '('; + QtDebugUtils::formatQRect(dbg, r); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index d91dd0d130..19227432f2 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -33,7 +33,8 @@ #include "qsize.h" #include "qdatastream.h" -#include "qdebug.h" + +#include <private/qdebug_p.h> QT_BEGIN_NAMESPACE @@ -440,7 +441,10 @@ QDataStream &operator>>(QDataStream &s, QSize &sz) QDebug operator<<(QDebug dbg, const QSize &s) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QSize(" << s.width() << ", " << s.height() << ')'; + dbg.nospace(); + dbg << "QSize("; + QtDebugUtils::formatQSize(dbg, s); + dbg << ')'; return dbg; } #endif @@ -867,7 +871,10 @@ QDataStream &operator>>(QDataStream &s, QSizeF &sz) QDebug operator<<(QDebug dbg, const QSizeF &s) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QSizeF(" << s.width() << ", " << s.height() << ')'; + dbg.nospace(); + dbg << "QSizeF("; + QtDebugUtils::formatQSize(dbg, s); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 7a5f9b3614..56dab68f33 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -8507,12 +8507,6 @@ QDataStream &operator<<(QDataStream &out, const QString &str) QDataStream &operator>>(QDataStream &in, QString &str) { -#ifdef QT_QSTRING_UCS_4 -#if defined(Q_CC_GNU) -#warning "operator>> not working properly" -#endif -#endif - if (in.version() == 1) { QByteArray l; in >> l; diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 2933e40549..bb15d66439 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -92,6 +92,15 @@ public: return *this; } +#ifdef Q_COMPILER_INITIALIZER_LISTS + QVarLengthArray<T, Prealloc> &operator=(std::initializer_list<T> list) + { + resize(list.size()); + std::copy(list.begin(), list.end(), this->begin()); + return *this; + } +#endif + inline void removeLast() { Q_ASSERT(s > 0); realloc(s - 1, a); diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 1f3a73073f..2b7f9c5241 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -362,6 +362,15 @@ Assigns \a other to this array and returns a reference to this array. */ +/*! \fn QVarLengthArray<T, Prealloc> &QVarLengthArray::operator=(std::initializer_list<T> list) + \since 5.5 + + Assigns the values of \a list to this array, and returns a reference to this array. + + This constructor is only enabled if the compiler supports C++11 initializer + lists. +*/ + /*! \fn QVarLengthArray::QVarLengthArray(const QVarLengthArray<T, Prealloc> &other) Constructs a copy of \a other. */ |