diff options
26 files changed, 403 insertions, 363 deletions
diff --git a/examples/widgets/calendarwidget/window.cpp b/examples/widgets/calendarwidget/window.cpp index 0a59640327..6796ef7f9d 100644 --- a/examples/widgets/calendarwidget/window.cpp +++ b/examples/widgets/calendarwidget/window.cpp @@ -452,10 +452,10 @@ void Window::createTextFormatsGroupBox() QComboBox *Window::createColorComboBox() { QComboBox *comboBox = new QComboBox; - comboBox->addItem(tr("Red"), Qt::red); - comboBox->addItem(tr("Blue"), Qt::blue); - comboBox->addItem(tr("Black"), Qt::black); - comboBox->addItem(tr("Magenta"), Qt::magenta); + comboBox->addItem(tr("Red"), QColor(Qt::red)); + comboBox->addItem(tr("Blue"), QColor(Qt::blue)); + comboBox->addItem(tr("Black"), QColor(Qt::black)); + comboBox->addItem(tr("Magenta"), QColor(Qt::magenta)); return comboBox; } //! [20] diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index cd330f5d34..246aa8376e 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -18,6 +18,10 @@ list(APPEND Qt5Core_INCLUDE_DIRS \"$${CMAKE_DATA_DIR}mkspecs/default\") !!ENDIF !!IF !isEmpty(CMAKE_ADD_FPIE_FLAGS) +# Targets using Qt need to use the POSITION_INDEPENDENT_CODE property. The +# Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module +# macro to add it. +set(Qt5_POSITION_INDEPENDENT_CODE True) set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIE\") !!ENDIF diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index bc4c020826..cbd141aeb3 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -223,16 +223,21 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.8) set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS}) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS}) - # We can't just append to the COMPILE_FLAGS property. That creats a ';' separated list - # which breaks the compile commmand line. - # Ensure non-duplication here manually instead. - get_property(_target_type TARGET ${_target} PROPERTY TYPE) - if ("${_target_type}" STREQUAL "EXECUTABLE" AND Qt5${_module}_EXECUTABLE_COMPILE_FLAGS) - get_target_property(_flags ${_target} COMPILE_FLAGS) - string(FIND "${_flags}" "${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}" _find_result) - if (NOT _find_result) - set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${_flags} ${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}") - endif() + if (Qt5_POSITION_INDEPENDENT_CODE) + set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) + if (CMAKE_VERSION VERSION_LESS 2.8.9) + # We can't just append to the COMPILE_FLAGS property. That creats a ';' separated list + # which breaks the compile commmand line. + # Ensure non-duplication here manually instead. + get_property(_target_type TARGET ${_target} PROPERTY TYPE) + if ("${_target_type}" STREQUAL "EXECUTABLE" AND Qt5${_module}_EXECUTABLE_COMPILE_FLAGS) + get_target_property(_flags ${_target} COMPILE_FLAGS) + string(FIND "${_flags}" "${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}" _find_result) + if (NOT _find_result) + set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${_flags} ${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}") + endif() + endif() + endif() endif() endforeach() endfunction() diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 8621d8b400..68c8f73fe3 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -779,4 +779,10 @@ # endif #endif +#ifdef Q_COMPILER_RVALUE_REFS +#define qMove(x) std::move(x) +#else +#define qMove(x) (x) +#endif + #endif // QCOMPILERDETECTION_H diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 1bc02e0a70..900859141d 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3006,4 +3006,12 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) {Debugging Techniques} */ +/*! + \macro qMove(x) + \relates <QtGlobal> + + It expands to "std::move" if your compiler supports that C++11 function, or to nothing + otherwise. +*/ + QT_END_NAMESPACE diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 38655f1776..93bdd3c03a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1193,7 +1193,7 @@ Q_CORE_EXPORT int qrand(); # define Q_OF_ELF #endif -#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__) +#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__) # error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\ "Compile your code with -fPIC or -fPIE." #endif diff --git a/src/corelib/io/qurlquery.h b/src/corelib/io/qurlquery.h index 4b9d104498..5939fd938a 100644 --- a/src/corelib/io/qurlquery.h +++ b/src/corelib/io/qurlquery.h @@ -145,7 +145,7 @@ inline void QUrl::removeAllEncodedQueryItems(const QByteArray &key) inline void QUrl::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &qry) { - QUrlQuery q(*this); + QUrlQuery q; QList<QPair<QByteArray, QByteArray> >::ConstIterator it = qry.constBegin(); for ( ; it != qry.constEnd(); ++it) q.addQueryItem(QString::fromUtf8(it->first), QString::fromUtf8(it->second)); diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 417c49bc42..3e82de78ea 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2056,20 +2056,8 @@ bool QMetaMethod::invoke(QObject *object, const char *retType = typeName(); if (qstrcmp(returnValue.name(), retType) != 0) { // normalize the return value as well - // the trick here is to make a function signature out of the return type - // so that we can call normalizedSignature() and avoid duplicating code - QByteArray unnormalized; - int len = qstrlen(returnValue.name()); - - unnormalized.reserve(len + 3); - unnormalized = "_("; // the function is called "_" - unnormalized.append(returnValue.name()); - unnormalized.append(')'); - - QByteArray normalized = QMetaObject::normalizedSignature(unnormalized.constData()); - normalized.truncate(normalized.length() - 1); // drop the ending ')' - - if (qstrcmp(normalized.constData() + 2, retType) != 0) + QByteArray normalized = QMetaObject::normalizedType(returnValue.name()); + if (qstrcmp(normalized.constData(), retType) != 0) return false; } } diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 021053fc6d..d2064b3e84 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -52,6 +52,7 @@ #include <locale.h> #endif +#include <cmath> #include <time.h> #ifdef Q_OS_WIN # include <qt_windows.h> @@ -767,9 +768,10 @@ QString QDate::toString(Qt::DateFormat f) const { if (year() < 0 || year() > 9999) return QString(); + QString year(QString::number(y).rightJustified(4, QLatin1Char('0'))); QString month(QString::number(m).rightJustified(2, QLatin1Char('0'))); QString day(QString::number(d).rightJustified(2, QLatin1Char('0'))); - return QString::number(y) + QLatin1Char('-') + month + QLatin1Char('-') + day; + return year + QLatin1Char('-') + month + QLatin1Char('-') + day; } } } @@ -1763,60 +1765,115 @@ int QTime::msecsTo(const QTime &t) const */ #ifndef QT_NO_DATESTRING -/*! - \fn QTime QTime::fromString(const QString &string, Qt::DateFormat format) - Returns the time represented in the \a string as a QTime using the - \a format given, or an invalid time if this is not possible. +// These anonymous functions tidy up QDateTime::fromString() +// and avoid confusion of reponsibility between it and QTime::fromString(). +namespace { +inline bool isMidnight(int hour, int minute, int second, int msec) +{ + return hour == 24 && minute == 0 && second == 0 && msec == 0; +} - Note that fromString() uses a "C" locale encoded string to convert - milliseconds to a float value. If the default locale is not "C", - this may result in two conversion attempts (if the conversion - fails for the default locale). This should be considered an - implementation detail. -*/ -QTime QTime::fromString(const QString& s, Qt::DateFormat f) +QTime fromStringImpl(const QString &s, Qt::DateFormat f, bool &isMidnight24) { if (s.isEmpty()) { - QTime t; - t.mds = NullTime; - return t; + // Return a null time. + return QTime(); } switch (f) { case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: case Qt::SystemLocaleLongDate: - return fromString(s, QLocale::system().timeFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat - : QLocale::ShortFormat)); + { + QLocale::FormatType formatType(Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); + return QTime::fromString(s, QLocale::system().timeFormat(formatType)); + } case Qt::LocaleDate: case Qt::DefaultLocaleShortDate: case Qt::DefaultLocaleLongDate: - return fromString(s, QLocale().timeFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat - : QLocale::ShortFormat)); - default: - { - bool ok = true; - const int hour(s.mid(0, 2).toInt(&ok)); - if (!ok) - return QTime(); - const int minute(s.mid(3, 2).toInt(&ok)); - if (!ok) - return QTime(); - if (f == Qt::ISODate && s.size() == 5) { + { + QLocale::FormatType formatType(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); + return QTime::fromString(s, QLocale().timeFormat(formatType)); + } + case Qt::TextDate: + case Qt::ISODate: + { + bool ok = true; + const int hour(s.mid(0, 2).toInt(&ok)); + if (!ok) + return QTime(); + const int minute(s.mid(3, 2).toInt(&ok)); + if (!ok) + return QTime(); + if (f == Qt::ISODate) { + if (s.size() == 5) { // Do not need to specify seconds if using ISO format. return QTime(hour, minute, 0, 0); + } else if ((s.size() > 6 && s[5] == QLatin1Char(',')) || s[5] == QLatin1Char('.')) { + // Possibly specifying fraction of a minute. + + // We only want 5 digits worth of fraction of minute. This follows the existing + // behaviour that determines how milliseconds are read; 4 millisecond digits are + // read and then rounded to 3. If we read at most 5 digits for fraction of minute, + // the maximum amount of millisecond digits it will expand to once converted to + // seconds is 4. E.g. 12:34,99999 will expand to 12:34:59.9994. The milliseconds + // will then be rounded up AND clamped to 999. + const QString minuteFractionStr(QLatin1String("0.") + s.mid(6, 5)); + const float minuteFraction = minuteFractionStr.toFloat(&ok); + if (!ok) + return QTime(); + const float secondWithMs = minuteFraction * 60; + const float second = std::floor(secondWithMs); + const float millisecond = 1000 * (secondWithMs - second); + const int millisecondRounded = qMin(qRound(millisecond), 999); + + if (isMidnight(hour, minute, second, millisecondRounded)) { + isMidnight24 = true; + return QTime(0, 0, 0, 0); + } + + return QTime(hour, minute, second, millisecondRounded); + } + } + + const int second(s.mid(6, 2).toInt(&ok)); + if (!ok) + return QTime(); + const QString msec_s(QLatin1String("0.") + s.mid(9, 4)); + const double msec(msec_s.toDouble(&ok)); + if (!ok) + return QTime(hour, minute, second, 0); + + if (f == Qt::ISODate) { + if (isMidnight(hour, minute, second, msec)) { + isMidnight24 = true; + return QTime(0, 0, 0, 0); } - const int second(s.mid(6, 2).toInt(&ok)); - if (!ok) - return QTime(); - const QString msec_s(QLatin1String("0.") + s.mid(9, 4)); - const float msec(msec_s.toFloat(&ok)); - if (!ok) - return QTime(hour, minute, second, 0); - return QTime(hour, minute, second, qMin(qRound(msec * 1000.0), 999)); } + return QTime(hour, minute, second, qMin(qRound(msec * 1000.0), 999)); } + } +} +} + + +/*! + \fn QTime QTime::fromString(const QString &string, Qt::DateFormat format) + + Returns the time represented in the \a string as a QTime using the + \a format given, or an invalid time if this is not possible. + + Note that fromString() uses a "C" locale encoded string to convert + milliseconds to a float value. If the default locale is not "C", + this may result in two conversion attempts (if the conversion + fails for the default locale). This should be considered an + implementation detail. +*/ +QTime QTime::fromString(const QString& s, Qt::DateFormat f) +{ + bool unused; + return fromStringImpl(s, f, unused); } /*! @@ -3245,11 +3302,12 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) } } - QTime time(QTime::fromString(tmp, Qt::ISODate)); - if (!time.isValid() && tmp == QString::fromLatin1("24:00:00")) { + bool isMidnight24 = false; + // Might be end of day (24:00, including variants), which QTime considers invalid. + QTime time(fromStringImpl(tmp, Qt::ISODate, isMidnight24)); + if (isMidnight24) { // ISO 8601 (section 4.2.3) says that 24:00 is equivalent to 00:00 the next day. date = date.addDays(1); - // Don't need to correct time since QDateTime constructor will do it for us. } return QDateTime(date, time, ts); diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 4a1a499be0..46cd1cc0a7 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -512,7 +512,7 @@ public: // special constructor that is enabled only if X derives from QObject #if QT_DEPRECATED_SINCE(5, 0) template <class X> - QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? d->getAndRef(ptr) : 0), value(ptr) + QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? Data::getAndRef(ptr) : 0), value(ptr) { } #endif #endif diff --git a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp index 56952dfb3e..64877d71ea 100644 --- a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp +++ b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp @@ -152,7 +152,6 @@ messageDebugEntries[] = { {WM_KILLFOCUS, "WM_KILLFOCUS", true}, {WM_ENABLE, "WM_ENABLE", true}, {WM_SHOWWINDOW, "WM_SHOWWINDOW", true}, - {WM_GETMINMAXINFO, "WM_GETMINMAXINFO"}, {WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING", true}, {WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED", true}, {WM_SETCURSOR, "WM_SETCURSOR", false}, @@ -199,13 +198,13 @@ messageDebugEntries[] = { {WM_RENDERALLFORMATS, "WM_RENDERALLFORMATS", true}, {WM_DESTROYCLIPBOARD, "WM_DESTROYCLIPBOARD", true}, {WM_CAPTURECHANGED, "WM_CAPTURECHANGED", true}, - {WM_IME_STARTCOMPOSITION, "WM_IME_STARTCOMPOSITION"}, - {WM_IME_COMPOSITION, "WM_IME_COMPOSITION"}, - {WM_IME_ENDCOMPOSITION, "WM_IME_ENDCOMPOSITION"}, - {WM_IME_NOTIFY, "WM_IME_NOTIFY"}, - {WM_IME_REQUEST, "WM_IME_REQUEST"}, - {WM_DISPLAYCHANGE, "WM_DISPLAYCHANGE"}, - {WM_THEMECHANGED , "WM_THEMECHANGED"} + {WM_IME_STARTCOMPOSITION, "WM_IME_STARTCOMPOSITION", true}, + {WM_IME_COMPOSITION, "WM_IME_COMPOSITION", true}, + {WM_IME_ENDCOMPOSITION, "WM_IME_ENDCOMPOSITION", true}, + {WM_IME_NOTIFY, "WM_IME_NOTIFY", true}, + {WM_IME_REQUEST, "WM_IME_REQUEST", true}, + {WM_DISPLAYCHANGE, "WM_DISPLAYCHANGE", true}, + {WM_THEMECHANGED, "WM_THEMECHANGED", true} }; static inline const MessageDebugEntry *messageDebugEntry(UINT msg) diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index d31b059445..52950ecde5 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -398,6 +398,7 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co case QPlatformIntegration::KeyboardInputInterval: case QPlatformIntegration::ShowIsFullScreen: case QPlatformIntegration::PasswordMaskDelay: + case QPlatformIntegration::StartDragVelocity: break; // Not implemented case QPlatformIntegration::FontSmoothingGamma: return QVariant(QWindowsFontDatabase::fontSmoothingGamma()); diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index ec37c4bbef..d3a3468037 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -796,10 +796,10 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // Get the modifier states (may be altered later, depending on key code) int state = 0; - state |= (nModifiers & ShiftAny ? Qt::ShiftModifier : 0); - state |= (nModifiers & ControlAny ? Qt::ControlModifier : 0); - state |= (nModifiers & AltAny ? Qt::AltModifier : 0); - state |= (nModifiers & MetaAny ? Qt::MetaModifier : 0); + state |= (nModifiers & ShiftAny ? int(Qt::ShiftModifier) : 0); + state |= (nModifiers & ControlAny ? int(Qt::ControlModifier) : 0); + state |= (nModifiers & AltAny ? int(Qt::AltModifier) : 0); + state |= (nModifiers & MetaAny ? int(Qt::MetaModifier) : 0); // Now we know enough to either have MapVirtualKey or our own keymap tell us if it's a deadkey const bool isDeadKey = isADeadKey(msg.wParam, state) @@ -920,7 +920,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms case Qt::Key_9: state |= ((msg.wParam >= '0' && msg.wParam <= '9') || (msg.wParam >= VK_OEM_PLUS && msg.wParam <= VK_OEM_3)) - ? 0 : Qt::KeypadModifier; + ? 0 : int(Qt::KeypadModifier); default: if ((uint)msg.lParam == 0x004c0001 || (uint)msg.lParam == 0xc04c0001) state |= Qt::KeypadModifier; diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 963ee88423..3c87a3a18d 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -150,7 +150,8 @@ static bool qt_write_dibv5(QDataStream &s, QImage image) //depth will be always 32 int bpl_bmp = image.width()*4; - BMP_BITMAPV5HEADER bi ={0}; + BMP_BITMAPV5HEADER bi; + ZeroMemory(&bi, sizeof(bi)); bi.bV5Size = sizeof(BMP_BITMAPV5HEADER); bi.bV5Width = image.width(); bi.bV5Height = image.height(); diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index e785fd9c72..0f69221f4c 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -543,6 +543,7 @@ void QXcbCursor::setPos(const QPoint &pos) xcb_window_t root; getPosAndRoot(conn, &root, 0); xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, pos.x(), pos.y()); + xcb_flush(conn); } QT_END_NAMESPACE diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 08c180f44b..7db8737975 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -67,7 +67,15 @@ static QByteArray combinePath(const QByteArray &infile, const QByteArray &outfil { QFileInfo inFileInfo(QDir::current(), QFile::decodeName(infile)); QFileInfo outFileInfo(QDir::current(), QFile::decodeName(outfile)); - return QFile::encodeName(outFileInfo.dir().relativeFilePath(inFileInfo.filePath())); + const QByteArray relativePath = QFile::encodeName(outFileInfo.dir().relativeFilePath(inFileInfo.filePath())); +#ifdef Q_OS_WIN + // It's a system limitation. + // It depends on the Win API function which is used by the program to open files. + // cl apparently uses the functions that have the MAX_PATH limitation. + if (outFileInfo.dir().absolutePath().length() + relativePath.length() + 1 >= 260) + return QFile::encodeName(inFileInfo.absoluteFilePath()); +#endif + return relativePath; } diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 17ba14de39..bf3c187d62 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -377,25 +377,6 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel } } - if (match & QAccessible::Controller) { - const QAccessible::Relation rel = QAccessible::Controller; - QACConnectionObject *connectionObject = (QACConnectionObject*)object(); - const QObjectList senderList = connectionObject->senderList(); - for (int s = 0; s < senderList.count(); ++s) { - QObject *sender = senderList.at(s); - if (sender->isWidgetType() && sender != object()) { - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(sender); - QACConnectionObject *connectionSender = (QACConnectionObject*)sender; - QStringList senderPrimarySignals = static_cast<QAccessibleWidget*>(iface)->d->primarySignals; - for (int sig = 0; sig < senderPrimarySignals.count(); ++sig) { - const QByteArray strSignal = senderPrimarySignals.at(sig).toLatin1(); - if (connectionSender->isSender(object(), strSignal.constData())) - rels.append(qMakePair(iface, rel)); - } - } - } - } - if (match & QAccessible::Controlled) { QObjectList allReceivers; QACConnectionObject *connectionObject = (QACConnectionObject*)object(); diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 6359ebfb09..4a4f109a82 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -306,7 +306,7 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) { bool value = false; if (vistaState() == VistaAero) { - WIZ_MARGINS mar = {0}; + WIZ_MARGINS mar = {0, 0, 0, 0}; if (type == NormalTitleBar) mar.cyTopHeight = 0; else @@ -639,13 +639,14 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) HFONT QVistaHelper::getCaptionFont(HANDLE hTheme) { - LOGFONT lf = {0}; + LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } }; if (!hTheme) pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf); else { - NONCLIENTMETRICS ncm = {sizeof(NONCLIENTMETRICS)}; + NONCLIENTMETRICS ncm; + ncm.cbSize = sizeof(NONCLIENTMETRICS); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false); lf = ncm.lfMessageFont; } @@ -662,7 +663,8 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q // Set up a memory DC and bitmap that we'll draw into HDC dcMem; HBITMAP bmp; - BITMAPINFO dib = {{0}}; + BITMAPINFO dib; + ZeroMemory(&dib, sizeof(dib)); dcMem = CreateCompatibleDC(hdc); dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -680,7 +682,8 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont); // Draw the text! - WIZ_DTTOPTS dto = { sizeof(WIZ_DTTOPTS) }; + WIZ_DTTOPTS dto; + dto.dwSize = sizeof(WIZ_DTTOPTS); const UINT uFormat = WIZ_DT_SINGLELINE|WIZ_DT_CENTER|WIZ_DT_VCENTER|WIZ_DT_NOPREFIX; RECT rctext ={0,0, rect.width(), rect.height()}; @@ -708,7 +711,8 @@ bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc) // Set up a memory DC and bitmap that we'll draw into HDC dcMem; HBITMAP bmp; - BITMAPINFO dib = {{0}}; + BITMAPINFO dib; + ZeroMemory(&dib, sizeof(dib)); dcMem = CreateCompatibleDC(hdc); dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index 731b547e2a..e81a8eee93 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -466,7 +466,7 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId) if (currentIconHandle == m_hwnd && currentIconId == iconId && !isHidden) { SendMessage(trayHandle, TB_GETITEMRECT, toolbarButton , (LPARAM)data); - RECT iconRect = {0, 0}; + RECT iconRect = {0, 0, 0, 0}; if(ReadProcessMemory(trayProcess, data, &iconRect, sizeof(RECT), &numBytes)) { MapWindowPoints(trayHandle, NULL, (LPPOINT)&iconRect, 2); QRect geometry(iconRect.left + 1, iconRect.top + 1, diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 8725c934b3..eee3a6258e 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -299,6 +299,8 @@ void tst_QMetaObject::connectSlotsByName() QCOMPARE(obj2.invokeCount2, 1); } +struct MyUnregisteredType { }; + class QtTestObject: public QObject { friend class tst_QMetaObject; @@ -335,6 +337,8 @@ public slots: void moveToThread(QThread *t) { QObject::moveToThread(t); } + void slotWithUnregisteredParameterType(MyUnregisteredType); + signals: void sig0(); QString sig1(QString s1); @@ -402,6 +406,9 @@ void QtTestObject::testSender() slotResult.sprintf("%p", sender()); } +void QtTestObject::slotWithUnregisteredParameterType(MyUnregisteredType) +{ slotResult = "slotWithUnregisteredReturnType"; } + void tst_QMetaObject::invokeMetaMember() { @@ -582,6 +589,14 @@ void tst_QMetaObject::invokeQueuedMetaMember() Q_ARG(quint64, ll2))); qApp->processEvents(QEventLoop::AllEvents); QCOMPARE(obj.slotResult, QString("testLongLong:-1,0")); + + obj.slotResult.clear(); + { + MyUnregisteredType t; + QTest::ignoreMessage(QtWarningMsg, "QMetaMethod::invoke: Unable to handle unregistered datatype 'MyUnregisteredType'"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "slotWithUnregisteredParameterType", Qt::QueuedConnection, Q_ARG(MyUnregisteredType, t))); + QVERIFY(obj.slotResult.isEmpty()); + } } void tst_QMetaObject::invokeBlockingQueuedMetaMember() diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp index 1c8c515f22..f83e2064c8 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp @@ -47,7 +47,6 @@ class tst_QDate : public QObject { Q_OBJECT private slots: - void toString(); void isNull_data(); void isNull(); void isValid_data(); @@ -86,6 +85,8 @@ private slots: void fromStringFormat(); void toStringFormat_data(); void toStringFormat(); + void toStringDateFormat_data(); + void toStringDateFormat(); void isLeapYear(); void yearsZeroToNinetyNine(); void negativeYear() const; @@ -106,6 +107,7 @@ private: }; Q_DECLARE_METATYPE(QDate) +Q_DECLARE_METATYPE(Qt::DateFormat) void tst_QDate::isNull_data() { @@ -960,6 +962,33 @@ void tst_QDate::toStringFormat() QCOMPARE( t.toString( format ), str ); } +void tst_QDate::toStringDateFormat_data() +{ + QTest::addColumn<QDate>("date"); + QTest::addColumn<Qt::DateFormat>("format"); + QTest::addColumn<QString>("expectedStr"); + + QTest::newRow("data0") << QDate(1,1,1) << Qt::ISODate << QString("0001-01-01"); + QTest::newRow("data1") << QDate(11,1,1) << Qt::ISODate << QString("0011-01-01"); + QTest::newRow("data2") << QDate(111,1,1) << Qt::ISODate << QString("0111-01-01"); + QTest::newRow("data3") << QDate(1974,12,1) << Qt::ISODate << QString("1974-12-01"); +} + +void tst_QDate::toStringDateFormat() +{ + QFETCH(QDate, date); + QFETCH(Qt::DateFormat, format); + QFETCH(QString, expectedStr); + + QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat)); + QCOMPARE(date.toString(Qt::LocaleDate), QLocale().toString(date, QLocale::ShortFormat)); + QLocale::setDefault(QLocale::German); + QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat)); + QCOMPARE(date.toString(Qt::LocaleDate), QLocale().toString(date, QLocale::ShortFormat)); + + QCOMPARE(date.toString(format), expectedStr); +} + void tst_QDate::isLeapYear() { QVERIFY(QDate::isLeapYear(-4801)); @@ -1053,19 +1082,6 @@ void tst_QDate::yearsZeroToNinetyNine() } } -void tst_QDate::toString() -{ - QDate date(1974,12,1); - QCOMPARE(date.toString(Qt::SystemLocaleDate), - QLocale::system().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::LocaleDate), - QLocale().toString(date, QLocale::ShortFormat)); - QLocale::setDefault(QLocale::German); - QCOMPARE(date.toString(Qt::SystemLocaleDate), - QLocale::system().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::LocaleDate), - QLocale().toString(date, QLocale::ShortFormat)); -} void tst_QDate::negativeYear() const { diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index f7925e849f..b54bf60908 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -108,12 +108,13 @@ private slots: void currentDateTime(); void currentDateTimeUtc(); void currentDateTimeUtc2(); - void fromStringTextDate_data(); - void fromStringTextDate(); - void dateTimeFromStringFormat_data(); - void dateTimeFromStringFormat(); + void fromStringDateFormat_data(); + void fromStringDateFormat(); + void fromStringStringFormat_data(); + void fromStringStringFormat(); void fromString_LOCALE_ILDATE(); - void fromString(); + void fromStringToStringLocale_data(); + void fromStringToStringLocale(); void utcOffset(); void setUtcOffset(); @@ -138,7 +139,7 @@ private: Q_DECLARE_METATYPE(QDateTime) Q_DECLARE_METATYPE(QDate) Q_DECLARE_METATYPE(QTime) - +Q_DECLARE_METATYPE(Qt::TimeSpec) tst_QDateTime::tst_QDateTime() { @@ -1214,116 +1215,146 @@ void tst_QDateTime::toString_strformat() QCOMPARE( dt.toString( format ), str ); } -void tst_QDateTime::fromStringTextDate_data() -{ - QTest::addColumn<QString>("dateTime"); - QTest::addColumn<int>("dateFormat"); - QTest::addColumn<int>("day"); - QTest::addColumn<int>("month"); - QTest::addColumn<int>("year"); - QTest::addColumn<int>("hour"); - QTest::addColumn<int>("minute"); - QTest::addColumn<int>("second"); - QTest::addColumn<int>("msec"); - QTest::addColumn<int>("timeSpec"); - - QTest::newRow("text date") << QString("Tue Jun 17 08:00:10 2003") - << int(Qt::TextDate) - << 17 << 6 << 2003 << 8 << 0 << 10 << 0 - << int(Qt::LocalTime); - QTest::newRow("ISO date") << QString("2005-06-28T07:57:30.0010000000Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 1 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 1") << QString("2005-06-28T07:57:30,0040000000Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 4 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 2") << QString("2005-06-28T07:57:30,0015Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 2 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 3") << QString("2005-06-28T07:57:30,0014Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 1 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 4") << QString("2005-06-28T07:57:30,1Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 100 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 5") << QString("2005-06-28T07:57:30,11") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 110 - << int(Qt::LocalTime); - - // Should be next day according to ISO 8601 section 4.2.3. - QTest::newRow("ISO date 24:00") << QString("2012-06-04T24:00:00") - << int(Qt::ISODate) - << 5 << 6 << 2012 << 0 << 0 << 0 << 0 - << int(Qt::LocalTime); - - QTest::newRow("ISO date 24:00 end of month") << QString("2012-06-30T24:00:00") - << int(Qt::ISODate) - << 1 << 7 << 2012 << 0 << 0 << 0 << 0 - << int(Qt::LocalTime); - - QTest::newRow("ISO date 24:00 end of month and year") << QString("2012-12-31T24:00:00") - << int(Qt::ISODate) - << 1 << 1 << 2013 << 0 << 0 << 0 << 0 - << int(Qt::LocalTime); - - QTest::newRow("Year 0999") << QString("Tue Jun 17 08:00:10 0999") - << int(Qt::TextDate) - << 17 << 6 << 999 << 8 << 0 << 10 << 0 - << int(Qt::LocalTime); - - QTest::newRow("Year 999") << QString("Tue Jun 17 08:00:10 999") - << int(Qt::TextDate) - << 17 << 6 << 999 << 8 << 0 << 10 << 0 - << int(Qt::LocalTime); - - QTest::newRow("Year 12345") << QString("Tue Jun 17 08:00:10 12345") - << int(Qt::TextDate) - << 17 << 6 << 12345 << 8 << 0 << 10 << 0 - << int(Qt::LocalTime); - - QTest::newRow("Year -4712") << QString("Tue Jan 1 00:01:02 -4712") - << int(Qt::TextDate) - << 1 << 1 << -4712 << 0 << 01 << 02 << 0 - << int(Qt::LocalTime); +void tst_QDateTime::fromStringDateFormat_data() +{ + QTest::addColumn<QString>("dateTimeStr"); + QTest::addColumn<Qt::DateFormat>("dateFormat"); + QTest::addColumn<QDateTime>("expected"); + QTest::addColumn<Qt::TimeSpec>("timeSpec"); + + // Test Qt::TextDate format. + QTest::newRow("text date") << QString::fromLatin1("Tue Jun 17 08:00:10 2003") + << Qt::TextDate << QDateTime(QDate(2003, 6, 17), QTime(8, 0, 10, 0)) << Qt::LocalTime; + QTest::newRow("text date Year 0999") << QString::fromLatin1("Tue Jun 17 08:00:10 0999") + << Qt::TextDate << QDateTime(QDate(999, 6, 17), QTime(8, 0, 10, 0)) << Qt::LocalTime; + QTest::newRow("text date Year 999") << QString::fromLatin1("Tue Jun 17 08:00:10 999") + << Qt::TextDate << QDateTime(QDate(999, 6, 17), QTime(8, 0, 10, 0)) << Qt::LocalTime; + QTest::newRow("text date Year 12345") << QString::fromLatin1("Tue Jun 17 08:00:10 12345") + << Qt::TextDate << QDateTime(QDate(12345, 6, 17), QTime(8, 0, 10, 0)) << Qt::LocalTime; + QTest::newRow("text date Year -4712") << QString::fromLatin1("Tue Jan 1 00:01:02 -4712") + << Qt::TextDate << QDateTime(QDate(-4712, 1, 1), QTime(0, 1, 2, 0)) << Qt::LocalTime; + QTest::newRow("data0") << QString::fromLatin1("Thu Jan 1 00:00:00 1970") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0)) << Qt::LocalTime; + QTest::newRow("data1") << QString::fromLatin1("Thu Jan 2 12:34 1970") + << Qt::TextDate << QDateTime(QDate(1970, 1, 2), QTime(12, 34, 0)) << Qt::LocalTime; + QTest::newRow("data2") << QString::fromLatin1("Thu Jan 1 00 1970") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data3") << QString::fromLatin1("Thu Jan 1 00:00:00:00 1970") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data4") << QString::fromLatin1("Thu Jan 1 00:00:00:00 1970") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data5") << QString::fromLatin1(" Thu Jan 1 00:00:00 1970 ") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0)) << Qt::LocalTime; + QTest::newRow("data6") << QString::fromLatin1("Thu Jan 1 00:00:00") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data7") << QString::fromLatin1("Thu Jan 1 1970 00:00:00") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0)) << Qt::LocalTime; + QTest::newRow("data8") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT+foo") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data9") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34)) << Qt::UTC; + QTest::newRow("data10") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT-0300") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(3, 12, 34)) << Qt::UTC; + QTest::newRow("data11") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT+0300") + << Qt::TextDate << QDateTime(QDate(1969, 12, 31), QTime(21, 12, 34)) << Qt::UTC; + QTest::newRow("data12") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 gmt") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34)) << Qt::UTC; + QTest::newRow("data13") << QString::fromLatin1("Thu Jan 1 1970 00:12:34 GMT+0100") + << Qt::TextDate << QDateTime(QDate(1969, 12, 31), QTime(23, 12, 34)) << Qt::UTC; + + // Test Qt::ISODate format. + QTest::newRow("data14") << QString::fromLatin1("1987-02-13T13:24:51+01:00") + << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51)) << Qt::UTC; + QTest::newRow("data15") << QString::fromLatin1("1987-02-13T13:24:51-01:00") + << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51)) << Qt::UTC; + // No time specified - defaults to Qt::LocalTime. + QTest::newRow("data16") << QString::fromLatin1("2002-10-01") + << Qt::ISODate << QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO") << QString::fromLatin1("2005-06-28T07:57:30.0010000000Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 1)) << Qt::UTC; + QTest::newRow("ISO with comma 1") << QString::fromLatin1("2005-06-28T07:57:30,0040000000Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 4)) << Qt::UTC; + QTest::newRow("ISO with comma 2") << QString::fromLatin1("2005-06-28T07:57:30,0015Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 2)) << Qt::UTC; + QTest::newRow("ISO with comma 3") << QString::fromLatin1("2005-06-28T07:57:30,0014Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 1)) << Qt::UTC; + QTest::newRow("ISO with comma 4") << QString::fromLatin1("2005-06-28T07:57:30,1Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 100)) << Qt::UTC; + QTest::newRow("ISO with comma 5") << QString::fromLatin1("2005-06-28T07:57:30,11") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 110)) << Qt::LocalTime; + // 24:00:00 Should be next day according to ISO 8601 section 4.2.3. + QTest::newRow("ISO 24:00") << QString::fromLatin1("2012-06-04T24:00:00") + << Qt::ISODate << QDateTime(QDate(2012, 6, 5), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO 24:00 end of month") << QString::fromLatin1("2012-06-30T24:00:00") + << Qt::ISODate << QDateTime(QDate(2012, 7, 1), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO 24:00 end of year") << QString::fromLatin1("2012-12-31T24:00:00") + << Qt::ISODate << QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO 24:00, fract ms") << QString::fromLatin1("2012-01-01T24:00:00.000") + << Qt::ISODate << QDateTime(QDate(2012, 1, 2), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO 24:00 end of year, fract ms") << QString::fromLatin1("2012-12-31T24:00:00.000") + << Qt::ISODate << QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0, 0)) << Qt::LocalTime; + // Test fractional seconds. + QTest::newRow("ISO .0 of a second (period)") << QString::fromLatin1("2012-01-01T08:00:00.0") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .00 of a second (period)") << QString::fromLatin1("2012-01-01T08:00:00.00") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .000 of a second (period)") << QString::fromLatin1("2012-01-01T08:00:00.000") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .1 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,1") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 100)) << Qt::LocalTime; + QTest::newRow("ISO .99 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,99") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 990)) << Qt::LocalTime; + QTest::newRow("ISO .998 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,998") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 998)) << Qt::LocalTime; + QTest::newRow("ISO .999 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,999") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 999)) << Qt::LocalTime; + QTest::newRow("ISO .3335 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,3335") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 334)) << Qt::LocalTime; + QTest::newRow("ISO .333333 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,333333") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 333)) << Qt::LocalTime; + QTest::newRow("ISO .00009 of a second (period)") << QString::fromLatin1("2012-01-01T08:00:00.00009") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO no fract specified") << QString::fromLatin1("2012-01-01T08:00:00.") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + // Test invalid characters (should ignore invalid characters at end of string). + QTest::newRow("ISO invalid character at end") << QString::fromLatin1("2012-01-01T08:00:00!") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO invalid character at front") << QString::fromLatin1("!2012-01-01T08:00:00") + << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("ISO invalid character both ends") << QString::fromLatin1("!2012-01-01T08:00:00!") + << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("ISO invalid character at front, 2 at back") << QString::fromLatin1("!2012-01-01T08:00:00..") + << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("ISO invalid character 2 at front") << QString::fromLatin1("!!2012-01-01T08:00:00") + << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + // Test fractional minutes. + QTest::newRow("ISO .0 of a minute (period)") << QString::fromLatin1("2012-01-01T08:00.0") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .8 of a minute (period)") << QString::fromLatin1("2012-01-01T08:00.8") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 48, 0)) << Qt::LocalTime; + QTest::newRow("ISO .99999 of a minute (period)") << QString::fromLatin1("2012-01-01T08:00.99999") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 59, 999)) << Qt::LocalTime; + QTest::newRow("ISO .0 of a minute (comma)") << QString::fromLatin1("2012-01-01T08:00,0") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .8 of a minute (comma)") << QString::fromLatin1("2012-01-01T08:00,8") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 48, 0)) << Qt::LocalTime; + QTest::newRow("ISO .99999 of a minute (comma)") << QString::fromLatin1("2012-01-01T08:00,99999") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 59, 999)) << Qt::LocalTime; } -void tst_QDateTime::fromStringTextDate() -{ - QFETCH(QString, dateTime); - QFETCH(int, dateFormat); - QFETCH(int, day); - QFETCH(int, month); - QFETCH(int, year); - QFETCH(int, hour); - QFETCH(int, minute); - QFETCH(int, second); - QFETCH(int, msec); - QFETCH(int, timeSpec); - - QDateTime dt = QDateTime::fromString(dateTime, (Qt::DateFormat)dateFormat); - QCOMPARE(dt.date().day(), day); - QCOMPARE(dt.date().month(), month); - QCOMPARE(dt.date().year(), year); - QCOMPARE(dt.time().hour(), hour); - QCOMPARE(dt.time().minute(), minute); - QCOMPARE(dt.time().second(), second); - QCOMPARE(dt.time().msec(), msec); - QCOMPARE(int(dt.timeSpec()), timeSpec); -} +void tst_QDateTime::fromStringDateFormat() +{ + QFETCH(QString, dateTimeStr); + QFETCH(Qt::DateFormat, dateFormat); + QFETCH(QDateTime, expected); + QFETCH(Qt::TimeSpec, timeSpec); + QDateTime dateTime = QDateTime::fromString(dateTimeStr, dateFormat); + expected.setTimeSpec(timeSpec); + QCOMPARE(dateTime, expected); +} -void tst_QDateTime::dateTimeFromStringFormat_data() +void tst_QDateTime::fromStringStringFormat_data() { QTest::addColumn<QString>("string"); QTest::addColumn<QString>("format"); @@ -1357,10 +1388,9 @@ void tst_QDateTime::dateTimeFromStringFormat_data() QTest::newRow("data16") << QString("2005-06-28T07:57:30.001Z") << QString("yyyy-MM-ddThh:mm:ss.zZ") << QDateTime(QDate(2005, 06, 28), QTime(07, 57, 30, 1)); - } -void tst_QDateTime::dateTimeFromStringFormat() +void tst_QDateTime::fromStringStringFormat() { QFETCH(QString, string); QFETCH(QString, format); @@ -1371,110 +1401,44 @@ void tst_QDateTime::dateTimeFromStringFormat() QCOMPARE(dt, expected); } -void tst_QDateTime::fromString() +void tst_QDateTime::fromString_LOCALE_ILDATE() { - QDateTime dt = QDateTime::fromString("Thu Jan 1 00:00:00 1970"); - QCOMPARE(dt, QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0))); - - dt = QDateTime::fromString("Thu Jan 2 12:34 1970"); - QCOMPARE(dt, QDateTime(QDate(1970, 1, 2), QTime(12, 34, 0))); - - dt = QDateTime::fromString("Thu Jan 1 00 1970"); - QCOMPARE(dt, QDateTime()); - - dt = QDateTime::fromString("Thu Jan 1 00:00:00:00 1970"); - QCOMPARE(dt, QDateTime()); - - dt = QDateTime::fromString(" Thu Jan 1 00:00:00 1970 "); - QCOMPARE(dt, QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0))); - - dt = QDateTime::fromString("Thu Jan 1 00:00:00"); - QCOMPARE(dt, QDateTime()); - - dt = QDateTime::fromString("2002-10-01", Qt::ISODate); - QCOMPARE(dt, QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0))); - - dt = QDateTime::fromString("1987-02-13T13:24:51+01:00", Qt::ISODate); - QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51), Qt::UTC)); - - dt = QDateTime::fromString("1987-02-13T13:24:51-01:00", Qt::ISODate); - QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT-0300"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(3, 12, 34), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT+0300"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1969, 12, 31), QTime(21, 12, 34), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT+foo"); - QCOMPARE(dt, QDateTime()); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 gmt"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 1970 00:00:00"); - QCOMPARE(dt, QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0))); - - dt = QDateTime::fromString("Thu Jan 1 1970 00:12:34 GMT+0100"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1969, 12, 31), QTime(23, 12, 34), Qt::UTC)); +#ifdef Q_OS_WIN + QString date1 = QLatin1String("Sun 1. Dec 13:02:00 1974"); + QString date2 = QLatin1String("Sun Dec 1 13:02:00 1974"); - QDate d = QDate::fromString("Thu Jan 1 1970"); - QCOMPARE(d, QDate(1970, 1, 1)); + QDateTime ref(QDate(1974, 12, 1), QTime(13, 2)); + QCOMPARE(ref, QDateTime::fromString(date2, Qt::TextDate)); + QCOMPARE(ref, QDateTime::fromString(date1, Qt::TextDate)); +#else + QSKIP("Windows only"); +#endif +} - d = QDate::fromString(" Thu Jan 1 1970 "); - QCOMPARE(d, QDate(1970, 1, 1)); +void tst_QDateTime::fromStringToStringLocale_data() +{ + QTest::addColumn<QDateTime>("dateTime"); - d = QDate::fromString("Thu Jan 1"); - QCOMPARE(d, QDate()); + QTest::newRow("data0") << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); +} - QDateTime dt2(QDate(1999, 1, 18), QTime(11, 49, 00)); +void tst_QDateTime::fromStringToStringLocale() +{ + QFETCH(QDateTime, dateTime); QLocale def; QLocale::setDefault(QLocale(QLocale::French, QLocale::France)); - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2); - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2); + QCOMPARE(QDateTime::fromString(dateTime.toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dateTime); + QCOMPARE(QDateTime::fromString(dateTime.toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dateTime); // obsolete - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleDate), Qt::SystemLocaleDate), dt2); - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::LocaleDate), Qt::LocaleDate), dt2); - -// cannot have these because of bug in datetime parser -// QCOMPARE(QDateTime::fromString(dt2.toString(Qt::DefaultLocaleLongDate), Qt::DefaultLocaleLongDate), dt2); -// QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleLongDate), Qt::SystemLocaleLongDate), dt2); - - - // same thing for QDate and QTime - - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2.date()); - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2.date()); - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::LocaleDate), Qt::LocaleDate), dt2.date()); - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::SystemLocaleDate), Qt::SystemLocaleDate), dt2.date()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2.time()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2.time()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::LocaleDate), Qt::LocaleDate), dt2.time()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::SystemLocaleDate), Qt::SystemLocaleDate), dt2.time()); + QCOMPARE(QDateTime::fromString(dateTime.toString(Qt::SystemLocaleDate), Qt::SystemLocaleDate), dateTime); + QCOMPARE(QDateTime::fromString(dateTime.toString(Qt::LocaleDate), Qt::LocaleDate), dateTime); QLocale::setDefault(def); } -void tst_QDateTime::fromString_LOCALE_ILDATE() -{ -#ifdef Q_OS_WIN - QString date1 = QLatin1String("Sun 1. Dec 13:02:00 1974"); - QString date2 = QLatin1String("Sun Dec 1 13:02:00 1974"); - - QDateTime ref(QDate(1974, 12, 1), QTime(13, 2)); - QCOMPARE(ref, QDateTime::fromString(date2, Qt::TextDate)); - QCOMPARE(ref, QDateTime::fromString(date1, Qt::TextDate)); -#else - QSKIP("Windows only"); -#endif -} - void tst_QDateTime::utcOffset() { /* Check default value. */ diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp index 1e000a1b40..1d6b0d2a01 100644 --- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp @@ -562,21 +562,22 @@ void tst_QTime::fromStringDateFormat_data() QTest::addColumn<Qt::DateFormat>("format"); QTest::addColumn<QTime>("expected"); - QTest::newRow("valid, start of day, omit seconds") << QString::fromLatin1("00:00") << Qt::ISODate << QTime(0, 0, 0); - QTest::newRow("valid, omit seconds") << QString::fromLatin1("22:21") << Qt::ISODate << QTime(22, 21, 0); - QTest::newRow("valid, omit seconds (2)") << QString::fromLatin1("23:59") << Qt::ISODate << QTime(23, 59, 0); - QTest::newRow("valid, end of day") << QString::fromLatin1("23:59:59") << Qt::ISODate << QTime(23, 59, 59); - - QTest::newRow("invalid, empty string") << QString::fromLatin1("") << Qt::ISODate << invalidTime(); - QTest::newRow("invalid, too many hours") << QString::fromLatin1("25:00") << Qt::ISODate << invalidTime(); - QTest::newRow("invalid, too many minutes") << QString::fromLatin1("10:70") << Qt::ISODate << invalidTime(); - QTest::newRow("invalid, too many seconds") << QString::fromLatin1("23:59:60") << Qt::ISODate << invalidTime(); - QTest::newRow("TextDate - data0") << QString("00:00:00") << Qt::TextDate << QTime(0,0,0,0); QTest::newRow("TextDate - data1") << QString("10:12:34") << Qt::TextDate << QTime(10,12,34,0); QTest::newRow("TextDate - data2") << QString("19:03:54.998601") << Qt::TextDate << QTime(19, 3, 54, 999); QTest::newRow("TextDate - data3") << QString("19:03:54.999601") << Qt::TextDate << QTime(19, 3, 54, 999); + QTest::newRow("IsoDate - valid, start of day, omit seconds") << QString::fromLatin1("00:00") << Qt::ISODate << QTime(0, 0, 0); + QTest::newRow("IsoDate - valid, omit seconds") << QString::fromLatin1("22:21") << Qt::ISODate << QTime(22, 21, 0); + QTest::newRow("IsoDate - valid, omit seconds (2)") << QString::fromLatin1("23:59") << Qt::ISODate << QTime(23, 59, 0); + QTest::newRow("IsoDate - valid, end of day") << QString::fromLatin1("23:59:59") << Qt::ISODate << QTime(23, 59, 59); + + QTest::newRow("IsoDate - invalid, empty string") << QString::fromLatin1("") << Qt::ISODate << invalidTime(); + QTest::newRow("IsoDate - invalid, too many hours") << QString::fromLatin1("25:00") << Qt::ISODate << invalidTime(); + QTest::newRow("IsoDate - invalid, too many minutes") << QString::fromLatin1("10:70") << Qt::ISODate << invalidTime(); + // This is a valid time if it happens on June 30 or December 31 (leap seconds). + QTest::newRow("IsoDate - invalid, too many seconds") << QString::fromLatin1("23:59:60") << Qt::ISODate << invalidTime(); + QTest::newRow("IsoDate - data0") << QString("00:00:00") << Qt::ISODate << QTime(0,0,0,0); QTest::newRow("IsoDate - data1") << QString("10:12:34") << Qt::ISODate << QTime(10,12,34,0); QTest::newRow("IsoDate - data2") << QString("19:03:54.998601") << Qt::ISODate << QTime(19, 3, 54, 999); diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp index 26e3ccfce4..f9905ce669 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/other/collections/tst_collections.cpp @@ -2556,6 +2556,9 @@ void testContainer() c1 = newInstance<Container>(); QVERIFY(c1.size() == 4); QVERIFY(c1 == newInstance<Container>()); + Container c2 = qMove(c1); + QVERIFY(c2.size() == 4); + QVERIFY(c2 == newInstance<Container>()); } } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 4607be4a7a..2a4013347e 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -906,30 +906,6 @@ void tst_QAccessibility::buttonTest() toggletool.setText("Toggle"); toggletool.setMinimumSize(20,20); - // test Controller/Controlled relations - { - QCheckBox toggler("Toggle me!", &window); - bool ok = connect(&pushButton, SIGNAL(clicked()), &toggler, SLOT(toggle())); - QCOMPARE(ok, true); - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&toggler); - QVERIFY(iface); - QCOMPARE(iface->role(), QAccessible::CheckBox); - QAccessibleInterface *buttonIFace = relatedInterface(iface, QAccessible::Controller); - QVERIFY(buttonIFace); - QCOMPARE(buttonIFace->role(), QAccessible::Button); - QCOMPARE(buttonIFace->object(), &pushButton); - delete buttonIFace; - delete iface; - - buttonIFace = QAccessible::queryAccessibleInterface(&pushButton); - QVERIFY(buttonIFace); - QCOMPARE(buttonIFace->role(), QAccessible::Button); - iface = relatedInterface(buttonIFace, QAccessible::Controlled); - QVERIFY(iface); - QCOMPARE(iface->object(), &toggler); - - } - // test push button QAccessibleInterface* interface = QAccessible::queryAccessibleInterface(&pushButton); QAccessibleActionInterface* actionInterface = interface->actionInterface(); diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro index 076025e325..4e575483af 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro @@ -1,5 +1,6 @@ CONFIG += testcase CONFIG += parallel_test +win32:testcase.timeout = 900 # this testcase can be slow on Windows QT += widgets widgets-private QT += core-private gui testlib |