From 0e39a0efd43f5036fdf746626afffebd2af71a2a Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Thu, 25 Oct 2012 11:27:04 +0200 Subject: [PATCH 001/134] Make compile on WCE after c3b9398 Change-Id: I594893eb80ecade903e592c41c7117b08bc946a5 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowstheme.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index d9de9119141..2fb905d23b9 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -509,6 +509,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con case TrashIcon: resourceId = 191; break; +#ifndef Q_OS_WINCE case MessageBoxInformation: iconName = IDI_INFORMATION; break; @@ -538,6 +539,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con } } break; +#endif default: break; } From 0f14ea3f3a05ef785b44fa610bf90ff3b5ba7beb Mon Sep 17 00:00:00 2001 From: Cyril Oblikov Date: Tue, 23 Oct 2012 18:00:58 +0300 Subject: [PATCH 002/134] New-style Windows cursors when dragging object from outside New-style drag&drop cursors are used now on Windows when user drags object to application from outside (e.g. image from Explorer). This is achieved by using IDropTargetHelper. Change-Id: I67e1db73cf433e235fce891eef0093cd4e605904 Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowsdrag.cpp | 35 +++++++++++++++++-- src/plugins/platforms/windows/qwindowsdrag.h | 6 ++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index f74b2140f65..ad2ff22f1d7 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -595,6 +595,9 @@ QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP QWindowsOleDropTarget::DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) { + if (IDropTargetHelper* dh = QWindowsDrag::instance()->dropHelper()) + dh->DragEnter(reinterpret_cast(m_window->winId()), pDataObj, reinterpret_cast(&pt), *pdwEffect); + if (QWindowsContext::verboseOLE) qDebug("%s widget=%p key=%lu, pt=%ld,%ld", __FUNCTION__, m_window, grfKeyState, pt.x, pt.y); @@ -608,6 +611,9 @@ QWindowsOleDropTarget::DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP QWindowsOleDropTarget::DragOver(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) { + if (IDropTargetHelper* dh = QWindowsDrag::instance()->dropHelper()) + dh->DragOver(reinterpret_cast(&pt), *pdwEffect); + QWindow *dragOverWindow = findDragOverWindow(pt); if (QWindowsContext::verboseOLE) qDebug("%s widget=%p key=%lu, pt=%ld,%ld", __FUNCTION__, dragOverWindow, grfKeyState, pt.x, pt.y); @@ -628,6 +634,9 @@ QWindowsOleDropTarget::DragOver(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP QWindowsOleDropTarget::DragLeave() { + if (IDropTargetHelper* dh = QWindowsDrag::instance()->dropHelper()) + dh->DragLeave(); + if (QWindowsContext::verboseOLE) qDebug().nospace() <<__FUNCTION__ << ' ' << m_window; @@ -640,9 +649,12 @@ QWindowsOleDropTarget::DragLeave() #define KEY_STATE_BUTTON_MASK (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON) QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP -QWindowsOleDropTarget::Drop(LPDATAOBJECT /*pDataObj*/, DWORD grfKeyState, +QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) { + if (IDropTargetHelper* dh = QWindowsDrag::instance()->dropHelper()) + dh->Drop(pDataObj, reinterpret_cast(&pt), *pdwEffect); + QWindow *dropWindow = findDragOverWindow(pt); if (QWindowsContext::verboseOLE) @@ -700,6 +712,10 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT /*pDataObj*/, DWORD grfKeyState, return NOERROR; } +#if defined(Q_CC_MINGW) && !defined(_WIN32_IE) +# define _WIN32_IE 0x0501 +#endif + /*! \class QWindowsDrag \brief Windows drag implementation. @@ -707,12 +723,15 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT /*pDataObj*/, DWORD grfKeyState, \ingroup qt-lighthouse-win */ -QWindowsDrag::QWindowsDrag() : m_dropDataObject(0) +QWindowsDrag::QWindowsDrag() : + m_dropDataObject(0), m_cachedDropTargetHelper(0) { } QWindowsDrag::~QWindowsDrag() { + if (m_cachedDropTargetHelper) + m_cachedDropTargetHelper->Release(); } /*! @@ -726,6 +745,18 @@ QMimeData *QWindowsDrag::dropData() return &m_dropData; } +/*! + \brief May be used to handle extended cursors functionality for drags from outside the app. +*/ +IDropTargetHelper* QWindowsDrag::dropHelper() { + if (!m_cachedDropTargetHelper) { + CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, + IID_IDropTargetHelper, + reinterpret_cast(&m_cachedDropTargetHelper)); + } + return m_cachedDropTargetHelper; +} + QPixmap QWindowsDrag::defaultCursor(Qt::DropAction action) const { switch (action) { diff --git a/src/plugins/platforms/windows/qwindowsdrag.h b/src/plugins/platforms/windows/qwindowsdrag.h index ab065458848..d3bfd369557 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.h +++ b/src/plugins/platforms/windows/qwindowsdrag.h @@ -47,6 +47,8 @@ #include #include +struct IDropTargetHelper; + QT_BEGIN_NAMESPACE class QWindowsDropMimeData : public QWindowsInternalMimeData { public: @@ -100,12 +102,16 @@ public: void releaseDropDataObject(); QMimeData *dropData(); + IDropTargetHelper* dropHelper(); + QPixmap defaultCursor(Qt::DropAction action) const; private: QWindowsDropMimeData m_dropData; IDataObject *m_dropDataObject; + IDropTargetHelper* m_cachedDropTargetHelper; + mutable QPixmap m_copyDragCursor; mutable QPixmap m_moveDragCursor; mutable QPixmap m_linkDragCursor; From 8ac2ea94d37126ef68d394e056bcaf7769a99956 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 26 Oct 2012 11:30:22 +0300 Subject: [PATCH 003/134] Fix enter/leave event generation between native widgets when grabbing. Removed enter/leave event generation when moving between between related windows in QWidgetWindow (i.e. native widgets) while some widget was explicitly grabbing the mouse input. This makes enter/leave event generation identical to non-native widgets. Task-number: QTBUG-27551 Change-Id: I4996007bd7922e073a2957ad267a6373e8f3fecc Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidgetwindow.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 900818d5c64..b3d46d5c284 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -239,9 +239,14 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) } } } - QWidget *leave = qt_last_mouse_receiver ? qt_last_mouse_receiver.data() : m_widget; - QApplicationPrivate::dispatchEnterLeave(enter, leave); - qt_last_mouse_receiver = enter; + // Enter-leave between sibling widgets is ignored when there is a mousegrabber - this makes + // both native and non-native widgets work similarly. + // When mousegrabbing, leaves are only generated if leaving the parent window. + if (!enter || !QWidget::mouseGrabber()) { + QWidget *leave = qt_last_mouse_receiver ? qt_last_mouse_receiver.data() : m_widget; + QApplicationPrivate::dispatchEnterLeave(enter, leave); + qt_last_mouse_receiver = enter; + } } else { QApplicationPrivate::dispatchEnterLeave(m_widget, 0); qt_last_mouse_receiver = m_widget; From d0aa81ee104107db1ce41a9bf0f91d4cb144f7de Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 26 Oct 2012 10:44:00 +0200 Subject: [PATCH 004/134] Fix a crash in QFileDialog when selecting an invalid name filter. When nameDetailsVisible is set to false and an invalid/empty string is passed to selectNameFilter(), the regexp used to strip the filter off the suffixes returns empty and a crash occurs. Change-Id: I926ea49514ff25a103977d8121fca1cf83d647f5 Reviewed-by: Miikka Heikkinen Reviewed-by: Sean Harmer --- src/widgets/dialogs/qfiledialog.cpp | 12 +++-- .../dialogs/qfiledialog/tst_qfiledialog.cpp | 47 ++++++++++++++++++- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index d9d318765d8..2ff0d03c350 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1201,9 +1201,11 @@ void QFileDialog::selectNameFilter(const QString &filter) d->selectNameFilter_sys(filter); return; } - int i; + int i = -1; if (testOption(HideNameFilterDetails)) { - i = d->qFileDialogUi->fileTypeCombo->findText(qt_strip_filters(qt_make_filter_list(filter)).first()); + const QStringList filters = qt_strip_filters(qt_make_filter_list(filter)); + if (!filters.isEmpty()) + i = d->qFileDialogUi->fileTypeCombo->findText(filters.first()); } else { i = d->qFileDialogUi->fileTypeCombo->findText(filter); } @@ -1770,7 +1772,7 @@ QString QFileDialog::getOpenFileName(QWidget *parent, // create a qt dialog QFileDialog dialog(args); - if (selectedFilter) + if (selectedFilter && !selectedFilter->isEmpty()) dialog.selectNameFilter(*selectedFilter); if (dialog.exec() == QDialog::Accepted) { if (selectedFilter) @@ -1855,7 +1857,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent, // create a qt dialog QFileDialog dialog(args); - if (selectedFilter) + if (selectedFilter && !selectedFilter->isEmpty()) dialog.selectNameFilter(*selectedFilter); if (dialog.exec() == QDialog::Accepted) { if (selectedFilter) @@ -1942,7 +1944,7 @@ QString QFileDialog::getSaveFileName(QWidget *parent, // create a qt dialog QFileDialog dialog(args); dialog.setAcceptMode(AcceptSave); - if (selectedFilter) + if (selectedFilter && !selectedFilter->isEmpty()) dialog.selectNameFilter(*selectedFilter); if (dialog.exec() == QDialog::Accepted) { if (selectedFilter) diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 32610fda187..8ce07428540 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -130,7 +130,9 @@ private slots: void selectFilter(); void viewMode(); void proxymodel(); + void setNameFilter_data(); void setNameFilter(); + void setEmptyNameFilter(); void focus(); void caption(); void historyBack(); @@ -1003,13 +1005,56 @@ void tst_QFiledialog::proxymodel() QCOMPARE(fd.proxyModel(), (QAbstractProxyModel*)0); } -void tst_QFiledialog::setNameFilter() +void tst_QFiledialog::setEmptyNameFilter() { QNonNativeFileDialog fd; fd.setNameFilter(QString()); fd.setNameFilters(QStringList()); } +void tst_QFiledialog::setNameFilter_data() +{ + QTest::addColumn("nameFilterDetailsVisible"); + QTest::addColumn("filters"); + QTest::addColumn("selectFilter"); + QTest::addColumn("expectedSelectedFilter"); + + QTest::newRow("namedetailsvisible-empty") << true << QStringList() << QString() << QString(); + QTest::newRow("namedetailsinvisible-empty") << false << QStringList() << QString() << QString(); + + const QString anyFileNoDetails = QLatin1String("Any files"); + const QString anyFile = anyFileNoDetails + QLatin1String(" (*)"); + const QString imageFilesNoDetails = QLatin1String("Image files"); + const QString imageFiles = imageFilesNoDetails + QLatin1String(" (*.png *.xpm *.jpg)"); + const QString textFileNoDetails = QLatin1String("Text files"); + const QString textFile = textFileNoDetails + QLatin1String(" (*.txt)"); + + QStringList filters; + filters << anyFile << imageFiles << textFile; + + QTest::newRow("namedetailsvisible-images") << true << filters << imageFiles << imageFiles; + QTest::newRow("namedetailsinvisible-images") << false << filters << imageFiles << imageFilesNoDetails; + + const QString invalid = "foo"; + QTest::newRow("namedetailsvisible-invalid") << true << filters << invalid << anyFile; + // Potential crash when trying to convert the invalid filter into a list and stripping it, resulting in an empty list. + QTest::newRow("namedetailsinvisible-invalid") << false << filters << invalid << anyFileNoDetails; +} + +void tst_QFiledialog::setNameFilter() +{ + QFETCH(bool, nameFilterDetailsVisible); + QFETCH(QStringList, filters); + QFETCH(QString, selectFilter); + QFETCH(QString, expectedSelectedFilter); + + QNonNativeFileDialog fd; + fd.setNameFilters(filters); + fd.setNameFilterDetailsVisible(nameFilterDetailsVisible); + fd.selectNameFilter(selectFilter); + QCOMPARE(fd.selectedNameFilter(), expectedSelectedFilter); +} + void tst_QFiledialog::focus() { QNonNativeFileDialog fd; From 08a64a2e756fe121f6bd4aaa7aab3df35f543668 Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 22 Oct 2012 11:04:27 +0200 Subject: [PATCH 005/134] Drop Symbian Carbide settings from .gitignore Change-Id: I429343246714e26690ffd9748e5e6873509c6625 Reviewed-by: Paul Olav Tvete --- .gitignore | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.gitignore b/.gitignore index f4d8fff9461..e7ebe50cc2d 100644 --- a/.gitignore +++ b/.gitignore @@ -261,13 +261,6 @@ d_exc_*.stk # Generated by abldfast.bat from devtools. .abldsteps.* -# Carbide project files -# --------------------- -.project -.cproject -.make.cache -*.d - qtc-debugging-helper qtc-qmldump qtc-qmldbg From 03967c4f0b5dbbd134da676846a20f6e5b9a2554 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 24 Oct 2012 10:42:37 +0200 Subject: [PATCH 006/134] Adjust autotest files for raster engine to new default pen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix those test scripts that assumed cosmetic default pen, and improve testing coverage of cosmetic vs non-cosmetic pens in general. Ref. I04d910e9700baf7f13a8aac07a3633014bb9283e Change-Id: I2bb3525c21a8e9c8dd1f16e7dcd225195df43c1b Reviewed-by: Samuel Rødal --- tests/auto/other/lancelot/scripts/arcs.qps | 4 +- tests/auto/other/lancelot/scripts/beziers.qps | 3 +- ...in_cap_styles_duplicate_control_points.qps | 18 +- tests/auto/other/lancelot/scripts/lines.qps | 129 +------------ tests/auto/other/lancelot/scripts/lines3.qps | 171 ++++++++++++++++++ tests/auto/other/lancelot/scripts/paths.qps | 19 +- .../other/lancelot/scripts/pens_cosmetic.qps | 6 + 7 files changed, 209 insertions(+), 141 deletions(-) create mode 100644 tests/auto/other/lancelot/scripts/lines3.qps diff --git a/tests/auto/other/lancelot/scripts/arcs.qps b/tests/auto/other/lancelot/scripts/arcs.qps index 8a7a468df1b..8afaf73ff1b 100644 --- a/tests/auto/other/lancelot/scripts/arcs.qps +++ b/tests/auto/other/lancelot/scripts/arcs.qps @@ -3,7 +3,7 @@ setRenderHint LineAntialiasing -setPen red +setPen red 0 drawEllipse 0 0 600 400 @@ -59,7 +59,7 @@ drawPath arcs translate 200 400 rotate 10 scale 0.5 0.5 -setPen red +setPen red 0 setBrush nobrush drawEllipse 0 0 600 400 diff --git a/tests/auto/other/lancelot/scripts/beziers.qps b/tests/auto/other/lancelot/scripts/beziers.qps index 9b47cd05ace..62d9d031a62 100644 --- a/tests/auto/other/lancelot/scripts/beziers.qps +++ b/tests/auto/other/lancelot/scripts/beziers.qps @@ -1,9 +1,10 @@ # Version: 1 # CheckVsReference: 5% - setRenderHint LineAntialiasing +setPen green 0 + translate 20 20 path_moveTo fullSize 0 0 path_cubicTo fullSize 200 100 -100 100 100 0 diff --git a/tests/auto/other/lancelot/scripts/join_cap_styles_duplicate_control_points.qps b/tests/auto/other/lancelot/scripts/join_cap_styles_duplicate_control_points.qps index b4630148e27..96405ceae7b 100644 --- a/tests/auto/other/lancelot/scripts/join_cap_styles_duplicate_control_points.qps +++ b/tests/auto/other/lancelot/scripts/join_cap_styles_duplicate_control_points.qps @@ -16,53 +16,53 @@ scale 2 2 setPen black 10 solidline roundcap roundjoin drawPath p -setPen red +setPen red 0 drawPath p translate 100 0 setPen black 10 solidline roundcap miterjoin drawPath p -setPen red +setPen red 0 drawPath p translate 100 0 setPen black 10 solidline roundcap beveljoin drawPath p -setPen red +setPen red 0 drawPath p translate -200 100 setPen black 10 solidline squarecap roundjoin drawPath p -setPen red +setPen red 0 drawPath p translate 100 0 setPen black 10 solidline squarecap miterjoin drawPath p -setPen red +setPen red 0 drawPath p translate 100 0 setPen black 10 solidline squarecap beveljoin drawPath p -setPen red +setPen red 0 drawPath p translate -200 100 setPen black 10 solidline flatcap roundjoin drawPath p -setPen red +setPen red 0 drawPath p translate 100 0 setPen black 10 solidline flatcap miterjoin drawPath p -setPen red +setPen red 0 drawPath p translate 100 0 setPen black 10 solidline flatcap beveljoin drawPath p -setPen red +setPen red 0 drawPath p \ No newline at end of file diff --git a/tests/auto/other/lancelot/scripts/lines.qps b/tests/auto/other/lancelot/scripts/lines.qps index c0daffb1b09..274a7f31ec1 100644 --- a/tests/auto/other/lancelot/scripts/lines.qps +++ b/tests/auto/other/lancelot/scripts/lines.qps @@ -1,7 +1,6 @@ # Version: 1 # CheckVsReference: 5% (0 0 310 425) - translate 10 10 begin_block draw_lines @@ -260,132 +259,8 @@ save repeat_block draw_lines restore -translate 320 0 - -setPen black 0 solidline squarecap - -begin_block lines - -# 0 -> 45 degress -drawLine 100 100 200 90 -drawLine 100 100 200 80 -drawLine 100 100 200 70 -drawLine 100 100 200 60 -drawLine 100 100 200 50 -drawLine 100 100 200 40 -drawLine 100 100 200 30 -drawLine 100 100 200 20 -drawLine 100 100 200 10 - -# 45 -drawLine 100 100 200 0 - -# 45 -> 90 -drawLine 100 100 190 0 -drawLine 100 100 180 0 -drawLine 100 100 170 0 -drawLine 100 100 160 0 -drawLine 100 100 150 0 -drawLine 100 100 140 0 -drawLine 100 100 130 0 -drawLine 100 100 120 0 -drawLine 100 100 110 0 - -# 90 -drawLine 100 100 100 0 - -# 90 -> 135 -drawLine 100 100 90 0 -drawLine 100 100 80 0 -drawLine 100 100 70 0 -drawLine 100 100 60 0 -drawLine 100 100 50 0 -drawLine 100 100 40 0 -drawLine 100 100 30 0 -drawLine 100 100 20 0 -drawLine 100 100 10 0 - -# 135 -drawLine 100 100 0 0 - -# 135 -> 180 degress -drawLine 100 100 0 10 -drawLine 100 100 0 20 -drawLine 100 100 0 30 -drawLine 100 100 0 40 -drawLine 100 100 0 50 -drawLine 100 100 0 60 -drawLine 100 100 0 70 -drawLine 100 100 0 80 -drawLine 100 100 0 90 - -# 180 -drawLine 100 100 0 100 - -# 180 -> 225 -drawLine 100 100 0 110 -drawLine 100 100 0 120 -drawLine 100 100 0 130 -drawLine 100 100 0 140 -drawLine 100 100 0 150 -drawLine 100 100 0 160 -drawLine 100 100 0 170 -drawLine 100 100 0 180 -drawLine 100 100 0 190 - -# 225 -drawLine 100 100 0 200 - -# 225 -> 270 -drawLine 100 100 10 200 -drawLine 100 100 20 200 -drawLine 100 100 30 200 -drawLine 100 100 40 200 -drawLine 100 100 50 200 -drawLine 100 100 60 200 -drawLine 100 100 70 200 -drawLine 100 100 80 200 -drawLine 100 100 90 200 - -# 270 -drawLine 100 100 100 200 - -# 270 -> 315 degrees -drawLine 100 100 110 200 -drawLine 100 100 120 200 -drawLine 100 100 130 200 -drawLine 100 100 140 200 -drawLine 100 100 150 200 -drawLine 100 100 160 200 -drawLine 100 100 170 200 -drawLine 100 100 180 200 -drawLine 100 100 190 200 - -# 315 -drawLine 100 100 200 200 - -# 315 -> 360 degress -drawLine 100 100 200 100 -drawLine 100 100 200 110 -drawLine 100 100 200 120 -drawLine 100 100 200 130 -drawLine 100 100 200 140 -drawLine 100 100 200 150 -drawLine 100 100 200 160 -drawLine 100 100 200 170 -drawLine 100 100 200 180 -drawLine 100 100 200 190 - -end_block - - -setRenderHint Antialiasing -setPen 0x7fff0000 -translate 0.5 0.5 -repeat_block lines - setPen 0x000000 8 -translate 20 240 +translate 350 240 drawText 0 0 "Steep slopes:" translate 0 10 @@ -555,4 +430,4 @@ drawRect 0.5 0.5 64 64 setPen red 2 solidline flatcap setClipRect 2 2 63 63 -drawLine 1.5 1.5 33560000 33560000 \ No newline at end of file +drawLine 1.5 1.5 33560000 33560000 diff --git a/tests/auto/other/lancelot/scripts/lines3.qps b/tests/auto/other/lancelot/scripts/lines3.qps new file mode 100644 index 00000000000..676235e6521 --- /dev/null +++ b/tests/auto/other/lancelot/scripts/lines3.qps @@ -0,0 +1,171 @@ + +clearRenderHint +setPen black 0 solidline squarecap + +save +translate 20 20 + +begin_block lines + +# 0 -> 45 degress +drawLine 100 100 200 90 +drawLine 100 100 200 80 +drawLine 100 100 200 70 +drawLine 100 100 200 60 +drawLine 100 100 200 50 +drawLine 100 100 200 40 +drawLine 100 100 200 30 +drawLine 100 100 200 20 +drawLine 100 100 200 10 + +# 45 +drawLine 100 100 200 0 + +# 45 -> 90 +drawLine 100 100 190 0 +drawLine 100 100 180 0 +drawLine 100 100 170 0 +drawLine 100 100 160 0 +drawLine 100 100 150 0 +drawLine 100 100 140 0 +drawLine 100 100 130 0 +drawLine 100 100 120 0 +drawLine 100 100 110 0 + +# 90 +drawLine 100 100 100 0 + +# 90 -> 135 +drawLine 100 100 90 0 +drawLine 100 100 80 0 +drawLine 100 100 70 0 +drawLine 100 100 60 0 +drawLine 100 100 50 0 +drawLine 100 100 40 0 +drawLine 100 100 30 0 +drawLine 100 100 20 0 +drawLine 100 100 10 0 + +# 135 +drawLine 100 100 0 0 + +# 135 -> 180 degress +drawLine 100 100 0 10 +drawLine 100 100 0 20 +drawLine 100 100 0 30 +drawLine 100 100 0 40 +drawLine 100 100 0 50 +drawLine 100 100 0 60 +drawLine 100 100 0 70 +drawLine 100 100 0 80 +drawLine 100 100 0 90 + +# 180 +drawLine 100 100 0 100 + +# 180 -> 225 +drawLine 100 100 0 110 +drawLine 100 100 0 120 +drawLine 100 100 0 130 +drawLine 100 100 0 140 +drawLine 100 100 0 150 +drawLine 100 100 0 160 +drawLine 100 100 0 170 +drawLine 100 100 0 180 +drawLine 100 100 0 190 + +# 225 +drawLine 100 100 0 200 + +# 225 -> 270 +drawLine 100 100 10 200 +drawLine 100 100 20 200 +drawLine 100 100 30 200 +drawLine 100 100 40 200 +drawLine 100 100 50 200 +drawLine 100 100 60 200 +drawLine 100 100 70 200 +drawLine 100 100 80 200 +drawLine 100 100 90 200 + +# 270 +drawLine 100 100 100 200 + +# 270 -> 315 degrees +drawLine 100 100 110 200 +drawLine 100 100 120 200 +drawLine 100 100 130 200 +drawLine 100 100 140 200 +drawLine 100 100 150 200 +drawLine 100 100 160 200 +drawLine 100 100 170 200 +drawLine 100 100 180 200 +drawLine 100 100 190 200 + +# 315 +drawLine 100 100 200 200 + +# 315 -> 360 degress +drawLine 100 100 200 100 +drawLine 100 100 200 110 +drawLine 100 100 200 120 +drawLine 100 100 200 130 +drawLine 100 100 200 140 +drawLine 100 100 200 150 +drawLine 100 100 200 160 +drawLine 100 100 200 170 +drawLine 100 100 200 180 +drawLine 100 100 200 190 + +end_block + +setRenderHint Antialiasing +setPen 0x7fff0000 0 solidline squarecap +repeat_block lines + +translate 250.5 0.5 +clearRenderHint +setPen black 0 solidline squarecap +repeat_block lines +setRenderHint Antialiasing +setPen 0x7fff0000 0 solidline squarecap +repeat_block lines + +restore + +save + +translate 20 250 +clearRenderHint +setPen black 1 solidline squarecap +repeat_block lines +setRenderHint Antialiasing +setPen 0x7fff0000 1 solidline squarecap +repeat_block lines + +translate 250.5 0.5 +clearRenderHint +setPen black 1 soslidline squarecap +repeat_block lines +setRenderHint Antialiasing +setPen 0x7fff0000 0 solidline squarecap +repeat_block lines + +restore + +translate 20 500 +scale 1.5 1.5 +clearRenderHint +setPen black 1 solidline squarecap +repeat_block lines +setRenderHint Antialiasing +setPen 0x7fff0000 1 solidline squarecap +repeat_block lines + +translate 250.5 0.5 +clearRenderHint +setPen black 1 soslidline squarecap +repeat_block lines +setRenderHint Antialiasing +setPen 0x7fff0000 0 solidline squarecap +repeat_block lines diff --git a/tests/auto/other/lancelot/scripts/paths.qps b/tests/auto/other/lancelot/scripts/paths.qps index 555390de45e..454b2a039d6 100644 --- a/tests/auto/other/lancelot/scripts/paths.qps +++ b/tests/auto/other/lancelot/scripts/paths.qps @@ -1,8 +1,12 @@ # Version: 1 -setPen black +setPen black 1 setBrush 7f7fff +setFont "arial" 12 +drawText 10 330 "Non-Cosmetic" +drawText 10 730 "Cosmetic" + path_moveTo star 50 0 path_lineTo star 30 90 path_lineTo star 100 60 @@ -29,6 +33,17 @@ translate -200 100 drawPath text end_block -translate 50 100 +begin_block xform +save +translate 50 60 rotate 10 +scale 1.0 0.7 repeat_block drawing +restore +end_block xform + +setPen black 0 +setBrush ff7f7f +translate 0 300 +repeat_block drawing +repeat_block xform diff --git a/tests/auto/other/lancelot/scripts/pens_cosmetic.qps b/tests/auto/other/lancelot/scripts/pens_cosmetic.qps index d1a60d150d1..91202904622 100644 --- a/tests/auto/other/lancelot/scripts/pens_cosmetic.qps +++ b/tests/auto/other/lancelot/scripts/pens_cosmetic.qps @@ -6,6 +6,9 @@ path_addRect path 25 5 4 4 translate 20 20 +setPen black 0 +pen_setCosmetic false + begin_block lines save drawLine 0 0 10 10 @@ -58,6 +61,7 @@ drawText 580 15 "non-cosmetic, 0-width" translate 0 50 setPen black 2 +pen_setCosmetic false repeat_block lines drawText 580 15 "non-cosmetic, 2-width" @@ -80,12 +84,14 @@ translate 0 20 translate 0 50 setPen black 0 +pen_setCosmetic false repeat_block lines drawText 580 15 "non-cosmetic, 0-width" translate 0 50 setPen black 2 +pen_setCosmetic false repeat_block lines drawText 580 15 "non-cosmetic, 2-width" From 9214b39beb01d69d3667328e7e62ef8d779b3957 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Wed, 24 Oct 2012 16:04:15 +0200 Subject: [PATCH 007/134] Add glxContextForContext function to QXcbNativeInterface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change enables receiving the native GLXContext object that is used by a QOpenGLContext in case of GLX. This clearly is non-public api that is only meant to be used as a last resort for cases where it is really necessary to get hold of a native context object. Change-Id: I7f1f974f18063ed334b8034a0c0192c875c10cec Reviewed-by: Samuel Rødal --- .../platforms/xcb/qxcbnativeinterface.cpp | 19 +++++++++++++++++++ .../platforms/xcb/qxcbnativeinterface.h | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 2a36fb73696..fa5f5f43d08 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -53,6 +53,8 @@ #if defined(XCB_USE_EGL) #include "QtPlatformSupport/private/qeglplatformcontext_p.h" +#elif defined (XCB_USE_GLX) +#include "qglxintegration.h" #endif QT_BEGIN_NAMESPACE @@ -68,6 +70,7 @@ public: insert("connection",QXcbNativeInterface::Connection); insert("screen",QXcbNativeInterface::Screen); insert("eglcontext",QXcbNativeInterface::EglContext); + insert("glxcontext",QXcbNativeInterface::GLXContext); } }; @@ -91,6 +94,9 @@ void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceSt case EglContext: result = eglContextForContext(context); break; + case GLXContext: + result = glxContextForContext(context); + break; default: break; } @@ -191,4 +197,17 @@ void * QXcbNativeInterface::eglContextForContext(QOpenGLContext *context) #endif } +void *QXcbNativeInterface::glxContextForContext(QOpenGLContext *context) +{ + Q_ASSERT(context); +#if defined(XCB_USE_GLX) + QGLXContext *glxPlatformContext = static_cast(context->handle()); + return glxPlatformContext->glxContext(); +#else + Q_UNUSED(context); + return 0; +#endif + +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index 1223fdc39cf..c15d00255a4 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -58,7 +58,8 @@ public: Connection, Screen, GraphicsDevice, - EglContext + EglContext, + GLXContext }; QXcbNativeInterface(); @@ -76,6 +77,7 @@ public: void *screenForWindow(QWindow *window); void *graphicsDeviceForWindow(QWindow *window); static void *eglContextForContext(QOpenGLContext *context); + static void *glxContextForContext(QOpenGLContext *context); private: const QByteArray m_genericEventFilterType; From b229eff08c816ebe8100dca00ab80ccd88541a5e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 23 Oct 2012 16:46:32 +0200 Subject: [PATCH 008/134] make qmltypes target properly respect debug vs. release Change-Id: Ia4f5ccb2b795a7594b74ea95aa0cc56a91aa7043 Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qml_plugin.prf | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf index ae5fbf28a21..8efc8c99598 100644 --- a/mkspecs/features/qml_plugin.prf +++ b/mkspecs/features/qml_plugin.prf @@ -42,13 +42,17 @@ load(qt_targets) # directory. Then review and commit the changes made to plugins.qmltypes. # !cross_compile { - isEmpty(IMPORT_VERSION): IMPORT_VERSION = $$eval(QT.$${CXX_MODULE}.MAJOR_VERSION).$$eval(QT.$${CXX_MODULE}.MINOR_VERSION) + build_pass|!debug_and_release { + isEmpty(IMPORT_VERSION): IMPORT_VERSION = $$eval(QT.$${CXX_MODULE}.MAJOR_VERSION).$$eval(QT.$${CXX_MODULE}.MINOR_VERSION) - load(resolve_target) - qtPrepareTool(QMLPLUGINDUMP, qmlplugindump) - qmltypes.target = qmltypes - qmltypes.commands = $$QMLPLUGINDUMP $$replace(TARGETPATH, /, .) $$IMPORT_VERSION $$QMAKE_RESOLVED_TARGET > $$QMLTYPEFILE - qmltypes.depends = $$QMAKE_RESOLVED_TARGET + load(resolve_target) + qtPrepareTool(QMLPLUGINDUMP, qmlplugindump) + qmltypes.target = qmltypes + qmltypes.commands = $$QMLPLUGINDUMP $$replace(TARGETPATH, /, .) $$IMPORT_VERSION $$QMAKE_RESOLVED_TARGET > $$QMLTYPEFILE + qmltypes.depends = $$QMAKE_RESOLVED_TARGET + } else { + qmltypes.CONFIG += recursive + } QMAKE_EXTRA_TARGETS += qmltypes } From 315c58509dcd3a2729b4efabef40fd76a6e0c5fa Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 23 Oct 2012 20:10:25 +0200 Subject: [PATCH 009/134] fix 'qmltypes' targets should now actually work for all build types Change-Id: I2dc1f8231737c13e95ce8aab1330b4f063951547 Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qml_plugin.prf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf index 8efc8c99598..8a24e9b36c1 100644 --- a/mkspecs/features/qml_plugin.prf +++ b/mkspecs/features/qml_plugin.prf @@ -47,8 +47,17 @@ load(qt_targets) load(resolve_target) qtPrepareTool(QMLPLUGINDUMP, qmlplugindump) + importpath.value = + for(qmod, QMAKEMODULES) { + qmod = $$section(qmod, /, 0, -3)/imports + exists($$qmod): importpath.value += $$shell_path($$qmod) + } + importpath.name = QML_IMPORT_PATH + importpath.value = $$unique(importpath.value) + qtAddToolEnv(QMLPLUGINDUMP, importpath) + TARGETPATHBASE = $$replace(TARGETPATH, \\.\\d+\$, ) qmltypes.target = qmltypes - qmltypes.commands = $$QMLPLUGINDUMP $$replace(TARGETPATH, /, .) $$IMPORT_VERSION $$QMAKE_RESOLVED_TARGET > $$QMLTYPEFILE + qmltypes.commands = $$QMLPLUGINDUMP $$replace(TARGETPATHBASE, /, .) $$IMPORT_VERSION > $$QMLTYPEFILE qmltypes.depends = $$QMAKE_RESOLVED_TARGET } else { qmltypes.CONFIG += recursive From 938dbe1d93a10d6a68d0d715c2c9d508aa1c2b37 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 21 Sep 2012 15:57:49 +0200 Subject: [PATCH 010/134] remove last traces of qpluginbase.pri Change-Id: Idafdab98016cd20f0605a46bf9cb8938da41a99e Reviewed-by: Joerg Bornemann --- src/plugins/platforms/qnx/qnx.pro | 3 ++- src/plugins/qpluginbase.pri | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 src/plugins/qpluginbase.pri diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index dc16016af3b..6c13be59656 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -1,5 +1,4 @@ TARGET = qnx -include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += platformsupport platformsupport-private @@ -140,3 +139,5 @@ include (../../../platformsupport/fontdatabases/fontdatabases.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target + +load(qt_plugin) diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri deleted file mode 100644 index b22a5277613..00000000000 --- a/src/plugins/qpluginbase.pri +++ /dev/null @@ -1 +0,0 @@ -load(qt_plugin) From e8170aee1fd2e423d92616fbdf1c173d9e4b7913 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 18 Sep 2012 18:26:09 +0200 Subject: [PATCH 011/134] move QMAKEMODULES addition to .qmake.super to qt_build_config.prf this is qt module specific magic that has no business in the generic default_pre.prf. a side effect is that every qt module now needs to have a .qmake.conf (unless it sets MODULE_QMAKE_OUTDIR, like webkit does). Change-Id: Id9e5f6eee2d8ec0c711e7217d9e1893fc9c88132 Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- mkspecs/features/default_pre.prf | 14 -------------- mkspecs/features/qt_build_config.prf | 10 ++++++++++ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/mkspecs/features/default_pre.prf b/mkspecs/features/default_pre.prf index 8b9cae5a6d8..8f8916ae195 100644 --- a/mkspecs/features/default_pre.prf +++ b/mkspecs/features/default_pre.prf @@ -1,20 +1,6 @@ load(exclusive_builds) CONFIG = lex yacc warn_on debug exceptions depend_includepath $$CONFIG -!build_pass:exists($$_PRO_FILE_PWD_/sync.profile) { - !exists($$[QT_HOST_DATA]/.qmake.cache) { - !isEmpty(_QMAKE_SUPER_CACHE_) { - # When doing a -prefix build of top-level qt5/qt.pro, we need to announce - # this repo's module pris' location to the other repos. - isEmpty(MODULE_QMAKE_OUTDIR): MODULE_QMAKE_OUTDIR = $$OUT_PWD - modpath = $$MODULE_QMAKE_OUTDIR/mkspecs/modules - !contains(QMAKEMODULES, $$modpath): \ - cache(QMAKEMODULES, add super, modpath) - unset(modpath) - } - } -} - # Populate the installdir which will be passed to qdoc in the default_post.prf # This allows a project to remove the installdir if need be, to trigger building online docs, # which Qt Creator does. diff --git a/mkspecs/features/qt_build_config.prf b/mkspecs/features/qt_build_config.prf index a2ad4429c19..01605da5e86 100644 --- a/mkspecs/features/qt_build_config.prf +++ b/mkspecs/features/qt_build_config.prf @@ -9,6 +9,16 @@ debug(1, "Not loading qmodule.pri twice") } +!build_pass:!isEmpty(_QMAKE_SUPER_CACHE_):!exists($$[QT_HOST_DATA]/.qmake.cache) { + # When doing a -prefix build of top-level qt5/qt.pro, we need to announce + # this repo's module pris' location to the other repos. + isEmpty(MODULE_QMAKE_OUTDIR): MODULE_QMAKE_OUTDIR = $$shadowed($$dirname(_QMAKE_CONF_)) + modpath = $$MODULE_QMAKE_OUTDIR/mkspecs/modules + !contains(QMAKEMODULES, $$modpath): \ + cache(QMAKEMODULES, add super, modpath) + unset(modpath) +} + mac { !isEmpty(QMAKE_RPATHDIR){ CONFIG += absolute_library_soname From c89dc4fdd2770ba3ad52303a2f4cb0c6403a2ecd Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Wed, 24 Oct 2012 16:27:24 -0200 Subject: [PATCH 012/134] QNX: Query dynamic buffer count at runtime While unlikely, there are cases in which QQnxWindow::renderBuffer() is called before the window buffers have been created. Without this check, the program will abort on QQnxBuffer constructor, since the value that will be passed to it will be of an invalid buffer. Change-Id: I9ad5926dca856570032dcf10b6975e8f3364c284 Reviewed-by: Thomas McGuire Reviewed-by: Sean Harmer --- .../platforms/qnx/qqnxrasterbackingstore.cpp | 5 ++++- src/plugins/platforms/qnx/qqnxwindow.cpp | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp index b8ec91d4888..11babe3aaaa 100644 --- a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp @@ -71,7 +71,10 @@ QQnxRasterBackingStore::~QQnxRasterBackingStore() QPaintDevice *QQnxRasterBackingStore::paintDevice() { - return m_platformWindow->renderBuffer().image(); + if (m_platformWindow->hasBuffers()) + return m_platformWindow->renderBuffer().image(); + + return 0; } void QQnxRasterBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 097b5788f60..c668a8867d1 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -374,10 +374,22 @@ QQnxBuffer &QQnxWindow::renderBuffer() // Check if render buffer is invalid if (m_currentBufferIndex == -1) { + // check if there are any buffers available + int bufferCount = 0; + int result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount); + + if (result != 0) { + qFatal("QQnxWindow: failed to query window buffer count, errno=%d", errno); + } + + if (bufferCount != MAX_BUFFER_COUNT) { + qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d", MAX_BUFFER_COUNT, bufferCount); + } + // Get all buffers available for rendering errno = 0; screen_buffer_t buffers[MAX_BUFFER_COUNT]; - int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers); + result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers); if (result != 0) { qFatal("QQnxWindow: failed to query window buffers, errno=%d", errno); } From b9551c1b47277d58d86a82ce15501663257ed9a1 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 23 Oct 2012 12:42:20 +0200 Subject: [PATCH 013/134] Blackberry bearer plugin: Only Report working interfaces as active Some interfaces might be connected but not working (e.g. no IP address, no gateway etc.) In practice, this prevents the USB interface (among others) from being reported as active and thus the QNetworkConfigurationManager as being reported as online. We only want Wifi and 3G etc. connections to be reported as online when they are up. Change-Id: I59fbe53bed8392d363a0191d589737f2304c853f Reviewed-by: Rafael Roquetto Reviewed-by: Andrey Leonov Reviewed-by: Sean Harmer --- src/plugins/bearer/blackberry/qbbengine.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/bearer/blackberry/qbbengine.cpp b/src/plugins/bearer/blackberry/qbbengine.cpp index 79452aeae57..d64a8fe20f8 100644 --- a/src/plugins/bearer/blackberry/qbbengine.cpp +++ b/src/plugins/bearer/blackberry/qbbengine.cpp @@ -316,15 +316,14 @@ void QBBEngine::updateConfiguration(const char *interface) const QString id = idForName(name); - const int numberOfIpAddresses = netstatus_interface_get_num_ip_addresses(details); - const bool isConnected = netstatus_interface_is_connected(details); const netstatus_interface_type_t type = netstatus_interface_get_type(details); + const netstatus_ip_status_t ipStatus = netstatus_interface_get_ip_status(details); netstatus_free_interface_details(&details); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined; - if (isConnected && (numberOfIpAddresses > 0)) + if (ipStatus == NETSTATUS_IP_STATUS_OK) state |= QNetworkConfiguration::Active; QMutexLocker locker(&mutex); From 3ab4afb7439953948f38f3a21f049ad9eb3c4332 Mon Sep 17 00:00:00 2001 From: Yuchen Deng Date: Thu, 25 Oct 2012 20:57:06 +0800 Subject: [PATCH 014/134] Angle: Fix shadow build Change-Id: I4ce4741ba1aa4009bd4984b4fad5a1b407d2cce5 Reviewed-by: Oswald Buddenhagen Reviewed-by: Friedemann Kleint --- src/angle/src/config.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/angle/src/config.pri b/src/angle/src/config.pri index 3770d6ef09e..7aedbc92cb5 100644 --- a/src/angle/src/config.pri +++ b/src/angle/src/config.pri @@ -13,7 +13,7 @@ isEmpty(ANGLE_DIR) { } win32 { - GNUTOOLS_DIR=$$[QT_HOST_DATA]/../gnuwin32/bin + GNUTOOLS_DIR=$$PWD/../../../../gnuwin32/bin exists($$GNUTOOLS_DIR/gperf.exe) { GNUTOOLS = "(set $$escape_expand(\\\")PATH=$$replace(GNUTOOLS_DIR, [/\\\\], $${QMAKE_DIR_SEP});%PATH%$$escape_expand(\\\"))" } From 8c22c9be3e684db90cb97177e97d1ab40866e680 Mon Sep 17 00:00:00 2001 From: Sergey Borovkov Date: Thu, 25 Oct 2012 01:20:01 +0400 Subject: [PATCH 015/134] Remove unnecessary call to png_set_sBit when writing png files According to libpng documentation - PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If data is of another bit depth, it's possible to write an sBIT chunk into the file so that decoders can recover the original data if desired. Since we hardcode depth to 8 there is no need to call png_set_sBit Change-Id: I8e3941675019b920051775128ff4cf2bf1ca7c4a Reviewed-by: aavit --- src/gui/image/qpnghandler.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 2307ceb7ae4..84342821780 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -849,13 +849,6 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, vo png_set_gAMA(png_ptr, info_ptr, 1.0/gamma); } - png_color_8 sig_bit; - sig_bit.red = 8; - sig_bit.green = 8; - sig_bit.blue = 8; - sig_bit.alpha = image.hasAlphaChannel() ? 8 : 0; - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - if (image.format() == QImage::Format_MonoLSB) png_set_packswap(png_ptr); From a3941c2f6ef31986bd315fa41bc4df7330a89109 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 18 Oct 2012 19:20:34 +0200 Subject: [PATCH 016/134] escape constructed command for makefiles Change-Id: Iec7f2bd7b02d03bf6a99dde363a41578924e523c Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_functions.prf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 2d8f81bae18..1d24ed9c005 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -192,13 +192,16 @@ defineTest(qtAddToolEnv) { equals(QMAKE_DIR_SEP, /) { contains($${env}.CONFIG, prepend): infix = \${$$name:+:\$$$name} else: infix = - $$1 = "$$name=$$join(value, :)$$infix $$eval($$1)" + val = "$$name=$$join(value, :)$$infix" } else { # Escape closing parens when expanding the variable, otherwise cmd confuses itself. contains($${env}.CONFIG, prepend): infix = ;%$$name:)=^)% else: infix = - $$1 = "(set $$name=$$join(value, ;)$$infix) & $$eval($$1)" + val = "(set $$name=$$join(value, ;)$$infix) &" } + contains(MAKEFILE_GENERATOR, MS.*): val ~= s,%,%%,g + else: val ~= s,\\\$,\$\$,g + $$1 = "$$val $$eval($$1)" } } export($$1) From 356f3c89b83704591e3c37cf8c322b52d6840763 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 28 Sep 2012 15:58:58 +0200 Subject: [PATCH 017/134] Fix syncing of visibility and enabled for menus on Cocoa Fixed menu handling on Cocoa so if a menu is enabled/disabled or made visible or not then it will keep this in sync with the appropriate native menu entry. Change-Id: If269185fcf065fb1b2f60d6ef8c27c107eb4509f Reviewed-by: Pasi Matilainen Reviewed-by: James Turner Reviewed-by: Andy Shaw --- src/gui/kernel/qplatformmenu.h | 1 + src/plugins/platforms/cocoa/qcocoamenu.h | 1 + src/plugins/platforms/cocoa/qcocoamenu.mm | 6 ++ src/plugins/platforms/cocoa/qcocoamenuitem.mm | 2 +- src/widgets/widgets/qmenubar.cpp | 2 + tests/manual/cocoa/menus/main.cpp | 74 +++++++++++++++++-- 6 files changed, 78 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h index 64f738b3313..7e7ccdb2946 100644 --- a/src/gui/kernel/qplatformmenu.h +++ b/src/gui/kernel/qplatformmenu.h @@ -102,6 +102,7 @@ public: virtual void setText(const QString &text) = 0; virtual void setEnabled(bool enabled) = 0; + virtual void setVisible(bool visible) = 0; virtual QPlatformMenuItem *menuItemAt(int position) const = 0; virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const = 0; diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index 38952a2e5d7..3afe089225b 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -70,6 +70,7 @@ public: void removeMenuItem(QPlatformMenuItem *menuItem); void syncMenuItem(QPlatformMenuItem *menuItem); void setEnabled(bool enabled); + void setVisible(bool visible); void syncSeparatorsCollapsible(bool enable); void syncModalState(bool modal); diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 4d35b3202e8..36d5c81f348 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -268,6 +268,12 @@ void QCocoaMenu::setParentItem(QCocoaMenuItem *item) void QCocoaMenu::setEnabled(bool enabled) { m_enabled = enabled; + syncModalState(!m_enabled); +} + +void QCocoaMenu::setVisible(bool visible) +{ + [m_nativeItem setSubmenu:(visible ? m_nativeMenu : nil)]; } QPlatformMenuItem *QCocoaMenu::menuItemAt(int position) const diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 150d3eef7d7..d78ff73bb6f 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -263,7 +263,7 @@ NSMenuItem *QCocoaMenuItem::sync() // [m_native setHidden:YES]; // [m_native setHidden:NO]; [m_native setHidden: !m_isVisible]; - + [m_native setEnabled: m_enabled]; QString text = m_text; QKeySequence accel = m_shortcut; diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index e53dc2cac26..f6665cba9a5 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1285,6 +1285,8 @@ void QMenuBar::actionEvent(QActionEvent *e) } } else if (menu) { menu->setText(e->action()->text()); + menu->setVisible(e->action()->isVisible()); + menu->setEnabled(e->action()->isEnabled()); d->platformMenuBar->syncMenu(menu); } } diff --git a/tests/manual/cocoa/menus/main.cpp b/tests/manual/cocoa/menus/main.cpp index 736ca134ffd..760115ce252 100644 --- a/tests/manual/cocoa/menus/main.cpp +++ b/tests/manual/cocoa/menus/main.cpp @@ -39,9 +39,12 @@ ** ****************************************************************************/ -#include -#include - +#include +#include +#include +#include +#include +#include class Responder : public QObject { @@ -49,13 +52,34 @@ class Responder : public QObject public: Responder(QObject *pr) : - QObject(pr) + QObject(pr), visibleMenu(0), visibleSubMenu(0), enabledMenu(0), enabledSubMenu(0), visibleAction(0), enabledAction(0) { } - + void setVisibleObjects(QMenu *vm, QMenu *vsm, QAction *va) + { + visibleMenu = vm; + visibleSubMenu = vsm; + visibleAction = va; + } + void setEnabledObjects(QMenu *em, QMenu *esm, QAction *ea) + { + enabledMenu = em; + enabledSubMenu = esm; + enabledAction = ea; + } public slots: - - + void toggleVisiblity() + { + visibleMenu->menuAction()->setVisible(!visibleMenu->menuAction()->isVisible()); + visibleSubMenu->menuAction()->setVisible(!visibleSubMenu->menuAction()->isVisible()); + visibleAction->setVisible(!visibleAction->isVisible()); + } + void toggleEnabled() + { + enabledMenu->menuAction()->setEnabled(!enabledMenu->menuAction()->isEnabled()); + enabledSubMenu->menuAction()->setEnabled(!enabledSubMenu->menuAction()->isEnabled()); + enabledAction->setEnabled(!enabledAction->isEnabled()); + } void toggleChecked(bool b) { QAction *a = qobject_cast(sender()); @@ -82,6 +106,9 @@ public slots: m->addAction(QString("Recent File %1").arg(i + 1)); } } +private: + QMenu *visibleMenu, *visibleSubMenu, *enabledMenu, *enabledSubMenu; + QAction *visibleAction, *enabledAction; }; void createWindow1() @@ -156,6 +183,39 @@ void createWindow1() menu2->addAction(checkableAction); + QMenu *menu4 = new QMenu("Toggle menu", window); + QAction *toggleVisiblity = new QAction("Toggle visibility", window); + QAction *toggleEnabled = new QAction("Toggle enabled", window); + QObject::connect(toggleVisiblity, SIGNAL(triggered()), r, SLOT(toggleVisiblity())); + QObject::connect(toggleEnabled, SIGNAL(triggered()), r, SLOT(toggleEnabled())); + menu4->addAction(toggleVisiblity); + menu4->addAction(toggleEnabled); + window->menuBar()->addMenu(menu4); + + QMenu *menu5 = new QMenu("Visible Menu", window); + menu5->addAction("Dummy action"); + window->menuBar()->addMenu(menu5); + QMenu *menu6 = new QMenu("Menu with visible action and submenu", window); + QAction *visibleAction = new QAction("Visible action", window); + menu6->addAction(visibleAction); + QMenu *subMenu6 = new QMenu("Submenu"); + subMenu6->addAction("Dummy action"); + menu6->addMenu(subMenu6); + window->menuBar()->addMenu(menu6); + + QMenu *menu7 = new QMenu("Enabled Menu", window); + menu7->addAction("Dummy action"); + window->menuBar()->addMenu(menu7); + QMenu *menu8 = new QMenu("Menu with enabled action and submenu", window); + QAction *enabledAction = new QAction("Enabled action", window); + menu8->addAction(enabledAction); + QMenu *subMenu8 = new QMenu("Submenu"); + subMenu8->addAction("Dummy action"); + menu8->addMenu(subMenu8); + window->menuBar()->addMenu(menu8); + + r->setVisibleObjects(menu5, subMenu6, visibleAction); + r->setEnabledObjects(menu7, subMenu8, enabledAction); window->show(); } From 49555e3ac956d9f90b01d136c510206cf50d0a8b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 19 Oct 2012 16:59:53 +0200 Subject: [PATCH 018/134] Add a CMake macro to test module includes The variations of includes which should work are tested. For example, in the case of testing the QtCore module and QObject include, the following includes are generated and compiled: #include #include #include #include As the private include directories are not available to the compiler, this also tests that private headers are not included from public ones. Change-Id: Id03d0fe290c9691e0f7515015892991d1701ab72 Reviewed-by: Stephen Kelly --- src/corelib/Qt5CTestMacros.cmake | 75 ++++++++++++++++++++++++++++++++ tests/auto/cmake/CMakeLists.txt | 23 ++++++++++ 2 files changed, 98 insertions(+) diff --git a/src/corelib/Qt5CTestMacros.cmake b/src/corelib/Qt5CTestMacros.cmake index 3d1b3b31919..0db83e3fb3a 100644 --- a/src/corelib/Qt5CTestMacros.cmake +++ b/src/corelib/Qt5CTestMacros.cmake @@ -59,3 +59,78 @@ macro(expect_fail _dir) --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} ) endmacro() + +function(test_module_includes) + + set(all_args ${ARGN}) + set(packages_string "") + set(libraries_string "") + + foreach(_package ${Qt5_MODULE_TEST_DEPENDS}) + set(packages_string + " + ${packages_string} + find_package(Qt5${_package} REQUIRED) + " + ) + endforeach() + + while(all_args) + list(GET all_args 0 qtmodule) + list(REMOVE_AT all_args 0 1) + set(packages_string + "${packages_string} + find_package(Qt5${qtmodule} REQUIRED) + include_directories(\${Qt5${qtmodule}_INCLUDE_DIRS}) + add_definitions(\${Qt5${qtmodule}_DEFINITIONS})\n" + ) + set(libraries_string "${libraries_string} Qt5::${qtmodule}") + endwhile() + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/module_includes/CMakeLists.txt" + " + cmake_minimum_required(VERSION 2.8) + project(module_includes) + + ${packages_string} + + set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} \${Qt5Core_EXECUTABLE_COMPILE_FLAGS}\") + + add_executable(module_includes_exe \"\${CMAKE_CURRENT_SOURCE_DIR}/main.cpp\") + target_link_libraries(module_includes_exe ${libraries_string})\n" + ) + + set(all_args ${ARGN}) + set(includes_string "") + while(all_args) + list(GET all_args 0 qtmodule) + list(GET all_args 1 qtinclude) + list(REMOVE_AT all_args 0 1) + set(includes_string + "${includes_string} + #include <${qtinclude}> + #include + #include + #include " + ) + endwhile() + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/module_includes/main.cpp" + " + + ${includes_string} + + int main(int, char **) { return 0; }\n" + ) + + add_test(module_includes ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMAKE_CURRENT_BINARY_DIR}/module_includes/" + "${CMAKE_CURRENT_BINARY_DIR}/module_includes/build" + --build-config "${CMAKE_BUILD_TYPE}" + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-project module_includes + --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} + ) +endfunction() diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 3217fa3cfd1..367832efb6f 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -89,3 +89,26 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/test_testlib_definitions/main.cpp" "${CMAKE_CURRENT_BINARY_DIR}/failbuild/test_testlib_no_link_widgets/test_testlib_no_link_widgets/" ) + +set(qt_module_includes + Core QObject + Concurrent QtConcurrentRun + Gui QImage + Widgets QWidget + Network QHostInfo + OpenGL QGLContext + Sql QSqlError + Test QSignalSpy + Xml QDomDocument + PrintSupport QPrintDialog +) + +if (UNIX AND NOT APPLE AND NOT QNXNTO) + list(APPEND qt_module_includes + DBus QDBusConnection + ) +endif() + +test_module_includes( + ${qt_module_includes} +) From 67cabd464dfe567c11f2d8fc4a1ced7a7c05e5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Thu, 25 Oct 2012 15:44:11 +0200 Subject: [PATCH 019/134] Qt 5.0 - Add QHeaderView refactor to changes notes. Some widgets users could get the picture that nothing has happened in that area. So lets at least write that something has been improved. Change-Id: Ic314ab06d28e687986a8ab472d8b58830cb0ad90 Reviewed-by: Stephen Kelly --- dist/changes-5.0.0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index a9fe12bd2f3..4c7cebfa8e3 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -550,7 +550,7 @@ QtWidgets the proper Qt API: due to the version bump, QStyle will try to use the additional QStyleOption members, which are left default-initialized. -* QHeaderView - The following functions have been obsoleted. +* QHeaderView has been refactored and the following functions have been obsoleted: * void setMovable(bool movable) - use void setSectionsMovable(bool movable) instead. From 4fbdb969fb4e446eab01f27eb2c880f8d6cb9106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Thu, 25 Oct 2012 06:49:20 +0200 Subject: [PATCH 020/134] QHeaderView 5.0 - no emit of sortIndicatorChanged when unchanged There is no reason to emit this when there is no change. Change-Id: I34f0ceec7c4b0959b77bc5be3ce2c2ad55864598 Reviewed-by: Stephen Kelly --- dist/changes-5.0.0 | 2 ++ src/widgets/itemviews/qheaderview.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 4c7cebfa8e3..5a32b46a17b 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -566,6 +566,8 @@ QtWidgets * ResizeMode resizeMode(int logicalindex) const - use sectionResizeMode(int logicalindex) instead. + * setSortIndicator will no longer emit sortIndicatorChanged when the sort indicator is unchanged. + * QDateEdit and QTimeEdit have re-gained a USER property. These were originally removed before Qt 4.7.0, and are re-added for 5.0. This means that the userProperty for those classes are now QDate and QTime respectively, not QDateTime as they have been diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 08f10defb84..e7e3a586702 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1349,6 +1349,8 @@ void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order) // This is so that people can set the position of the sort indicator before the fill the model int old = d->sortIndicatorSection; + if (old == logicalIndex && order == d->sortIndicatorOrder) + return; d->sortIndicatorSection = logicalIndex; d->sortIndicatorOrder = order; From 84787d82ee9369b2a83c5b0568ee62ab602a5528 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Sat, 13 Oct 2012 13:41:30 +0200 Subject: [PATCH 021/134] QComboBox: fix use in QDataWidgetMapper/QItemDelegate QItemDelegate and QDataWidgetMapper use the WRITE method on the USER property to set a value in a widget. This did not work for QComboBox whose USER property currentText lacked a WRITE method. This change adds the missing setter and flags it as the WRITE method. The setter setCurrentText() simply calls setEditText() if the combo box is editable. Otherwise, if there is a matching text in the list, currentIndex is set to the corresponding index. Test included. Follow-up to 816c5540179362500dfc175b77f05abf3ef25233 which restored currentText as the USER property. Task-number: QTBUG-26501 Change-Id: I5f2f999e60b09728ca03ead4e28fe36d1f3ee189 Reviewed-by: Andy Shaw Reviewed-by: David Faure Reviewed-by: Stephen Kelly --- src/widgets/widgets/qcombobox.cpp | 17 +++++- src/widgets/widgets/qcombobox.h | 3 +- .../tst_qdatawidgetmapper.cpp | 5 +- .../widgets/qcombobox/tst_qcombobox.cpp | 53 +++++++++++++++++++ 4 files changed, 74 insertions(+), 4 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 74b3dc77d37..27fc3f9015c 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2001,6 +2001,17 @@ void QComboBox::setCurrentIndex(int index) d->setCurrentIndex(mi); } +void QComboBox::setCurrentText(const QString &text) +{ + if (isEditable()) { + setEditText(text); + } else { + const int i = findText(text); + if (i > -1) + setCurrentIndex(i); + } +} + void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) { Q_Q(QComboBox); @@ -2034,7 +2045,11 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) by the line edit. Otherwise, it is the value of the current item or an empty string if the combo box is empty or no current item is set. - \sa editable + The setter setCurrentText() simply calls setEditText() if the combo box is editable. + Otherwise, if there is a matching text in the list, currentIndex is set to the + corresponding index. + + \sa editable, setEditText() */ QString QComboBox::currentText() const { diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index f1f1b133cba..1d0e892fd8c 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -66,7 +66,7 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget Q_ENUMS(SizeAdjustPolicy) Q_PROPERTY(bool editable READ isEditable WRITE setEditable) Q_PROPERTY(int count READ count) - Q_PROPERTY(QString currentText READ currentText USER true) + Q_PROPERTY(QString currentText READ currentText WRITE setCurrentText USER true) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems) Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount) @@ -211,6 +211,7 @@ public Q_SLOTS: void clearEditText(); void setEditText(const QString &text); void setCurrentIndex(int index); + void setCurrentText(const QString &text); Q_SIGNALS: void editTextChanged(const QString &); diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp index 85ee7144c92..6ef0988f317 100644 --- a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp +++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp @@ -362,8 +362,10 @@ void tst_QDataWidgetMapper::comboBox() mapper.addMapping(&readWriteBox, 1, "currentText"); mapper.toFirst(); + // setCurrentIndex caused the value at index 0 to be displayed QCOMPARE(readOnlyBox.currentText(), QString("read only item 0")); - QCOMPARE(readWriteBox.currentText(), QString("read write item 0")); + // setCurrentText set the value in the line edit since the combobox is editable + QCOMPARE(readWriteBox.currentText(), QString("item 0 1")); // set some new values on the boxes readOnlyBox.setCurrentIndex(1); @@ -380,7 +382,6 @@ void tst_QDataWidgetMapper::comboBox() model->setData(model->index(0, 1), QString("read write item z"), Qt::EditRole); QCOMPARE(readOnlyBox.currentIndex(), 2); - QEXPECT_FAIL("", "See task 125493 and QTBUG-428", Abort); QCOMPARE(readWriteBox.currentText(), QString("read write item z")); } diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 11e9a9d82f7..df0eb89682d 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -121,6 +121,8 @@ private slots: void modelDeleted(); void setMaxCount(); void setCurrentIndex(); + void setCurrentText_data(); + void setCurrentText(); void convenienceViews(); void findText_data(); void findText(); @@ -1355,6 +1357,57 @@ void tst_QComboBox::setCurrentIndex() QCOMPARE(testWidget->currentText(), QString("foo")); } +void tst_QComboBox::setCurrentText_data() +{ + QTest::addColumn("editable"); + QTest::newRow("editable") << true; + QTest::newRow("not editable") << false; +} + +void tst_QComboBox::setCurrentText() +{ + QFETCH(bool, editable); + + QCOMPARE(testWidget->count(), 0); + testWidget->addItems(QStringList() << "foo" << "bar"); + QCOMPARE(testWidget->count(), 2); + + testWidget->setEditable(editable); + testWidget->setCurrentIndex(0); + QCOMPARE(testWidget->currentIndex(), 0); + + // effect on currentText and currentIndex + // currentIndex not changed if editable + QCOMPARE(testWidget->currentText(), QString("foo")); + testWidget->setCurrentText(QString("bar")); + QCOMPARE(testWidget->currentText(), QString("bar")); + if (editable) + QCOMPARE(testWidget->currentIndex(), 0); + else + QCOMPARE(testWidget->currentIndex(), 1); + + testWidget->setCurrentText(QString("foo")); + QCOMPARE(testWidget->currentIndex(), 0); + QCOMPARE(testWidget->currentText(), QString("foo")); + + // effect of text not found in list + testWidget->setCurrentText(QString("qt")); + QCOMPARE(testWidget->currentIndex(), 0); + if (editable) + QCOMPARE(testWidget->currentText(), QString("qt")); + else + QCOMPARE(testWidget->currentText(), QString("foo")); + +#ifndef QT_NO_PROPERTIES + // verify WRITE for currentText property + testWidget->setCurrentIndex(0); + const QByteArray n("currentText"); + QCOMPARE(testWidget->property(n).toString(), QString("foo")); + testWidget->setProperty(n, QString("bar")); + QCOMPARE(testWidget->property(n).toString(), QString("bar")); +#endif +} + void tst_QComboBox::editTextChanged() { QCOMPARE(testWidget->count(), 0); From 5bddaf76e027a4688a9f26a6a6b3fa80e0903cb7 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Sat, 13 Oct 2012 15:08:11 +0200 Subject: [PATCH 022/134] QComboBox: new signal currentTextChanged Adds NOTIFY to currentText property. Test included. Change-Id: I3e92b585ad6697891d61537c82f6ab9e8beb1a00 Reviewed-by: Andy Shaw Reviewed-by: Konstantin Ritt Reviewed-by: Stephen Kelly --- src/widgets/widgets/qcombobox.cpp | 20 ++++++- src/widgets/widgets/qcombobox.h | 3 +- .../widgets/qcombobox/tst_qcombobox.cpp | 55 +++++++++++++++++++ 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 27fc3f9015c..ef908d62c6f 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -821,6 +821,14 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const item's \a text is passed. */ +/*! + \fn void QComboBox::currentTextChanged(const QString &text) + \since 5.0 + + This signal is sent whenever currentText changes. The new value + is passed as \a text. +*/ + /*! Constructs a combobox with the given \a parent, using the default model QStandardItemModel. @@ -980,9 +988,12 @@ void QComboBoxPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIn } if (currentIndex.row() >= topLeft.row() && currentIndex.row() <= bottomRight.row()) { + const QString text = q->itemText(currentIndex.row()); if (lineEdit) { - lineEdit->setText(q->itemText(currentIndex.row())); + lineEdit->setText(text); updateLineEditGeometry(); + } else { + emit q->currentTextChanged(text); } q->update(); } @@ -1242,7 +1253,11 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index) { Q_Q(QComboBox); emit q->currentIndexChanged(index.row()); - emit q->currentIndexChanged(itemText(index)); + const QString text = itemText(index); + emit q->currentIndexChanged(text); + // signal lineEdit.textChanged already connected to signal currentTextChanged, so don't emit double here + if (!lineEdit) + emit q->currentTextChanged(text); #ifndef QT_NO_ACCESSIBILITY QAccessibleEvent event(q, QAccessible::NameChanged); QAccessible::updateAccessibility(&event); @@ -1714,6 +1729,7 @@ void QComboBox::setLineEdit(QLineEdit *edit) connect(d->lineEdit, SIGNAL(returnPressed()), this, SLOT(_q_returnPressed())); connect(d->lineEdit, SIGNAL(editingFinished()), this, SLOT(_q_editingFinished())); connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(editTextChanged(QString))); + connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(currentTextChanged(QString))); d->lineEdit->setFrame(false); d->lineEdit->setContextMenuPolicy(Qt::NoContextMenu); d->lineEdit->setFocusProxy(this); diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 1d0e892fd8c..bce6c98f2c3 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -66,7 +66,7 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget Q_ENUMS(SizeAdjustPolicy) Q_PROPERTY(bool editable READ isEditable WRITE setEditable) Q_PROPERTY(int count READ count) - Q_PROPERTY(QString currentText READ currentText WRITE setCurrentText USER true) + Q_PROPERTY(QString currentText READ currentText WRITE setCurrentText NOTIFY currentTextChanged USER true) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems) Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount) @@ -221,6 +221,7 @@ Q_SIGNALS: void highlighted(const QString &); void currentIndexChanged(int index); void currentIndexChanged(const QString &); + void currentTextChanged(const QString &); protected: void focusInEvent(QFocusEvent *e); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index df0eb89682d..3b9f408e73a 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -116,6 +116,8 @@ private slots: void insertOnCurrentIndex(); void textpixmapdata_data(); void textpixmapdata(); + void currentTextChanged_data(); + void currentTextChanged(); void editTextChanged(); void setModel(); void modelDeleted(); @@ -1408,6 +1410,59 @@ void tst_QComboBox::setCurrentText() #endif } +void tst_QComboBox::currentTextChanged_data() +{ + QTest::addColumn("editable"); + QTest::newRow("editable") << true; + QTest::newRow("not editable") << false; +} + +void tst_QComboBox::currentTextChanged() +{ + QFETCH(bool, editable); + + QCOMPARE(testWidget->count(), 0); + testWidget->addItems(QStringList() << "foo" << "bar"); + QCOMPARE(testWidget->count(), 2); + + QSignalSpy spy(testWidget, SIGNAL(currentTextChanged(QString))); + + testWidget->setEditable(editable); + + // set text in list + testWidget->setCurrentIndex(0); + QCOMPARE(testWidget->currentIndex(), 0); + spy.clear(); + testWidget->setCurrentText(QString("bar")); + QCOMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast(spy.at(0).at(0)), QString("bar")); + + // set text not in list + testWidget->setCurrentIndex(0); + QCOMPARE(testWidget->currentIndex(), 0); + spy.clear(); + testWidget->setCurrentText(QString("qt")); + if (editable) { + QCOMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast(spy.at(0).at(0)), QString("qt")); + } else { + QCOMPARE(spy.count(), 0); + } + + // item changed + testWidget->setCurrentIndex(0); + QCOMPARE(testWidget->currentIndex(), 0); + spy.clear(); + testWidget->setItemText(0, QString("ape")); + QCOMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast(spy.at(0).at(0)), QString("ape")); + // change it back + spy.clear(); + testWidget->setItemText(0, QString("foo")); + QCOMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast(spy.at(0).at(0)), QString("foo")); +} + void tst_QComboBox::editTextChanged() { QCOMPARE(testWidget->count(), 0); From 8900bc778f326e6b22ecfceb0b0b64394f3510fb Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Fri, 26 Oct 2012 22:53:56 +1100 Subject: [PATCH 023/134] QGLTextureGlyphCache: Fix text rendering artifacts on NVIDIA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check GL_VENDOR to test whether using NVIDIA graphics. On Linux, GL_VERSION and GL_VENDOR contains "NVIDIA". On Windows, only GL_VENDOR contains "NVIDIA". Task-number: QTBUG-27658 Change-Id: I5e74d07ecb9522d1a86ac2953415a51bbdbe8c49 Reviewed-by: Samuel Rødal --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 469ac59dcfa..ec2f1b02af0 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -339,8 +339,8 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed sub if (!ctx->d_ptr->workaround_brokenAlphaTexSubImage_init) { // don't know which driver versions exhibit this bug, so be conservative for now - const QByteArray versionString(reinterpret_cast(glGetString(GL_VERSION))); - ctx->d_ptr->workaround_brokenAlphaTexSubImage = versionString.indexOf("NVIDIA") >= 0; + const QByteArray vendorString(reinterpret_cast(glGetString(GL_VENDOR))); + ctx->d_ptr->workaround_brokenAlphaTexSubImage = vendorString.indexOf("NVIDIA") >= 0; ctx->d_ptr->workaround_brokenAlphaTexSubImage_init = true; } From 80e87c0241fb2b82e4f44ce7228764514ddb00e5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 22 Oct 2012 17:00:59 +0200 Subject: [PATCH 024/134] Remove compatibility headers for QPA classes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The handling of deprecated headers in syncqt causes those headers to end up in the master include when shadowbuilding on another drive on Windows. Task-number: QTBUG-27497 Change-Id: I9318ae670c50bc010b6bf97cd5fd003e08db84c8 Reviewed-by: Oswald Buddenhagen Reviewed-by: Peter Kümmel Reviewed-by: Samuel Rødal --- sync.profile | 59 ---------------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/sync.profile b/sync.profile index d3994fe3145..e71ce10e7cc 100644 --- a/sync.profile +++ b/sync.profile @@ -38,65 +38,6 @@ ); %deprecatedheaders = ( "QtGui" => { - "qplatformaccessibility_qpa.h" => "qpa/qplatformaccessibility.h", - "QPlatformAccessibility" => "qpa/qplatformaccessibility.h", - "qplatformbackingstore_qpa.h" => "qpa/qplatformbackingstore.h", - "QPlatformBackingStore" => "qpa/qplatformbackingstore.h", - "qplatformclipboard_qpa.h" => "qpa/qplatformclipboard.h", - "QPlatformClipboard" => "qpa/qplatformclipboard.h", - "QPlatformColorDialogHelper" => "qpa/qplatformdialoghelper.h", - "qplatformcursor_qpa.h" => "qpa/qplatformcursor.h", - "QPlatformCursor" => "qpa/qplatformcursor.h", - "QPlatformCursorImage" => "qpa/qplatformcursor.h", - "QPlatformCursorPrivate" => "qpa/qplatformcursor.h", - "qplatformdrag_qpa.h" => "qpa/qplatformdrag.h", - "QPlatformDrag" => "qpa/qplatformdrag.h", - "QPlatformDragQtResponse" => "qpa/qplatformdrag.h", - "QPlatformDropQtResponse" => "qpa/qplatformdrag.h", - "qplatformdialoghelper_qpa.h" => "qpa/qplatformdialoghelper.h", - "QPlatformDialogHelper" => "qpa/qplatformdialoghelper.h", - "QPlatformFileDialogHelper" => "qpa/qplatformdialoghelper.h", - "qplatformfontdatabase_qpa.h" => "qpa/qplatformfontdatabase.h", - "QPlatformFontDatabase" => "qpa/qplatformfontdatabase.h", - "qplatforminputcontext_qpa.h" => "qpa/qplatforminputcontext.h", - "QPlatformInputContext" => "qpa/qplatforminputcontext.h", - "qplatforminputcontext_qpa_p.h" => "qpa/qplatforminputcontext_p.h", - "qplatformintegration_qpa.h" => "qpa/qplatformintegration.h", - "QPlatformIntegration" => "qpa/qplatformintegration.h", - "qplatformintegrationfactory_qpa_p.h" => "qpa/qplatformintegrationfactory_p.h", - "QPlatformIntegrationFactory" => "qpa/qplatformintegrationfactory_p.h", - "qplatformintegrationplugin_qpa.h" => "qpa/qplatformintegrationplugin.h", - "QPlatformIntegrationPlugin" => "qpa/qplatformintegrationplugin.h", - "qplatformnativeinterface_qpa.h" => "qpa/qplatformnativeinterface.h", - "QPlatformNativeInterface" => "qpa/qplatformnativeinterface.h", - "qplatformopenglcontext_qpa.h" => "qpa/qplatformopenglcontext.h", - "QPlatformOpenGLContext" => "qpa/qplatformopenglcontext.h", - "qplatformpixmap_qpa.h" => "qpa/qplatformpixmap.h", - "QPlatformPixmap" => "qpa/qplatformpixmap.h", - "qplatformscreen_qpa.h" => "qpa/qplatformscreen.h", - "QPlatformScreen" => "qpa/qplatformscreen.h", - "qplatformscreen_qpa_p.h" => "qpa/qplatformscreen_p.h", - "QPlatformScreenBuffer" => "qpa/qplatformscreenpageflipper.h", - "qplatformscreenpageflipper_qpa.h" => "qpa/qplatformscreenpageflipper.h", - "QPlatformScreenPageFlipper" => "qpa/qplatformscreenpageflipper.h", - "qplatformservices_qpa.h" => "qpa/qplatformservices.h", - "QPlatformServices" => "qpa/qplatformservices.h", - "qplatformsharedgraphicscache_qpa.h" => "qpa/qplatformsharedgraphicscache.h", - "QPlatformSharedGraphicsCache" => "qpa/qplatformsharedgraphicscache.h", - "qplatformsurface_qpa.h" => "qpa/qplatformsurface.h", - "QPlatformSurface" => "qpa/qplatformsurface.h", - "qplatformtheme_qpa.h" => "qpa/qplatformtheme.h", - "QPlatformTheme" => "qpa/qplatformtheme.h", - "qplatformthemefactory_qpa_p.h" => "qpa/qplatformthemefactory_p.h", - "qplatformthemeplugin_qpa.h" => "qpa/qplatformthemeplugin.h", - "QPlatformThemePlugin" => "qpa/qplatformthemeplugin.h", - "qplatformwindow_qpa.h" => "qpa/qplatformwindow.h", - "QPlatformWindow" => "qpa/qplatformwindow.h", - "qwindowsysteminterface_qpa.h" => "qpa/qwindowsysteminterface.h", - "QWindowSystemInterface" => "qpa/qwindowsysteminterface.h", - "qwindowsysteminterface_qpa_p.h" => "qpa/qwindowsysteminterface_p.h", - "qgenericpluginfactory_qpa.h" => "QtGui/qgenericpluginfactory.h", - "qgenericplugin_qpa.h" => "QtGui/qgenericplugin.h", "QGenericPlugin" => "QtGui/QGenericPlugin", "QGenericPluginFactory" => "QtGui/QGenericPluginFactory" }, From 38e02188ee132fd8c483fcb9773979875677c070 Mon Sep 17 00:00:00 2001 From: Cyril Oblikov Date: Thu, 27 Sep 2012 17:55:16 +0300 Subject: [PATCH 025/134] Possibility to change custom Drag&Drop cursors while dragging something. Implementation for Windows and X11. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additional checks to figure out if new Drag&Drop cursors where set. This means it is possible now to keep QDrag object in your program and call setDragCursor() method every time we need to change cursor depending on context. Change-Id: I4be69e44b2863371a7ffbb29efc17c18210d6cde Reviewed-by: Friedemann Kleint Reviewed-by: Gatis Paeglis Reviewed-by: Samuel Rødal --- src/platformsupport/dnd/qsimpledrag.cpp | 15 ++++++- .../platforms/windows/qwindowsdrag.cpp | 40 +++++++++++-------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/platformsupport/dnd/qsimpledrag.cpp b/src/platformsupport/dnd/qsimpledrag.cpp index d8ef17ede3d..18e6b97e3cb 100644 --- a/src/platformsupport/dnd/qsimpledrag.cpp +++ b/src/platformsupport/dnd/qsimpledrag.cpp @@ -253,8 +253,19 @@ void QBasicDrag::updateCursor(Qt::DropAction action) } QCursor *cursor = qApp->overrideCursor(); - if (cursor && cursorShape != cursor->shape()) { - qApp->changeOverrideCursor(QCursor(cursorShape)); + QPixmap pixmap = m_drag->dragCursor(action); + if (!cursor) { + qApp->changeOverrideCursor((pixmap.isNull()) ? QCursor(cursorShape) : QCursor(pixmap)); + } else { + if (!pixmap.isNull()) { + if ((cursor->pixmap().cacheKey() != pixmap.cacheKey())) { + qApp->changeOverrideCursor(QCursor(pixmap)); + } + } else { + if (cursorShape != cursor->shape()) { + qApp->changeOverrideCursor(QCursor(cursorShape)); + } + } } updateAction(action); } diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index ad2ff22f1d7..a0434fb6f39 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -301,9 +301,15 @@ public: STDMETHOD(GiveFeedback)(DWORD dwEffect); private: - typedef QMap ActionCursorMap; - - inline void clearCursors(); + class DragCursorHandle { + Q_DISABLE_COPY(DragCursorHandle) + public: + DragCursorHandle(HCURSOR c, quint64 k) : cursor(c), cacheKey(k) {} + ~DragCursorHandle() { DestroyCursor(cursor); } + HCURSOR cursor; + quint64 cacheKey; + }; + typedef QMap > ActionCursorMap; QWindowsDrag *m_drag; Qt::MouseButtons m_currentButtons; @@ -322,7 +328,7 @@ QWindowsOleDropSource::QWindowsOleDropSource(QWindowsDrag *drag) : QWindowsOleDropSource::~QWindowsOleDropSource() { - clearCursors(); + m_cursors.clear(); if (QWindowsContext::verboseOLE) qDebug("%s", __FUNCTION__); } @@ -347,10 +353,14 @@ void QWindowsOleDropSource::createCursors() QPixmap cpm = drag->dragCursor(action); if (cpm.isNull()) cpm = m_drag->defaultCursor(action); + QSharedPointer cursorHandler = m_cursors.value(action); + if (!cursorHandler.isNull() && cpm.cacheKey() == cursorHandler->cacheKey) + continue; if (cpm.isNull()) { qWarning("%s: Unable to obtain drag cursor for %d.", __FUNCTION__, action); continue; } + int w = cpm.width(); int h = cpm.height(); @@ -380,23 +390,14 @@ void QWindowsOleDropSource::createCursors() const int hotX = hasPixmap ? qMax(0,newHotSpot.x()) : 0; const int hotY = hasPixmap ? qMax(0,newHotSpot.y()) : 0; - if (const HCURSOR sysCursor = QWindowsCursor::createPixmapCursor(newCursor, hotX, hotY)) - m_cursors.insert(actions.at(cnum), sysCursor); + if (const HCURSOR sysCursor = QWindowsCursor::createPixmapCursor(newCursor, hotX, hotY)) { + m_cursors.insert(action, QSharedPointer(new DragCursorHandle(sysCursor, cpm.cacheKey()))); + } } if (QWindowsContext::verboseOLE) qDebug("%s %d cursors", __FUNCTION__, m_cursors.size()); } -void QWindowsOleDropSource::clearCursors() -{ - if (!m_cursors.isEmpty()) { - const ActionCursorMap::const_iterator cend = m_cursors.constEnd(); - for (ActionCursorMap::const_iterator it = m_cursors.constBegin(); it != cend; ++it) - DestroyCursor(it.value()); - m_cursors.clear(); - } -} - //--------------------------------------------------------------------- // IUnknown Methods //--------------------------------------------------------------------- @@ -488,9 +489,14 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect) if (QWindowsContext::verboseOLE > 2) qDebug("%s dwEffect=%lu, action=%d", __FUNCTION__, dwEffect, action); + QSharedPointer cursorHandler = m_cursors.value(action); + quint64 currentCacheKey = m_drag->currentDrag()->dragCursor(action).cacheKey(); + if (cursorHandler.isNull() || currentCacheKey != cursorHandler->cacheKey) + createCursors(); + const ActionCursorMap::const_iterator it = m_cursors.constFind(action); if (it != m_cursors.constEnd()) { - SetCursor(it.value()); + SetCursor(it.value()->cursor); return ResultFromScode(S_OK); } From 9bf017680229b7e1677d9c347cb36fce8c52a610 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Thu, 18 Oct 2012 15:37:50 +0200 Subject: [PATCH 026/134] Qt Core: Adding a landing page and sorted the documentation. -Added \annotatedlist for the groups -Sorted and placed the pages on the index page. Change-Id: Id1a4344c0b39f00036f5ac29b1fcb869d5602d2b Reviewed-by: Lars Knoll --- src/corelib/codecs/codecs.qdoc | 6 +- src/corelib/doc/src/animation.qdoc | 8 +- src/corelib/doc/src/containers.qdoc | 19 ++-- src/corelib/doc/src/eventsandfilters.qdoc | 7 +- src/corelib/doc/src/implicit-sharing.qdoc | 6 ++ src/corelib/doc/src/io.qdoc | 8 +- src/corelib/doc/src/json.qdoc | 3 +- src/corelib/doc/src/plugins-howto.qdoc | 8 +- src/corelib/doc/src/qtcore-index.qdoc | 121 ++++++++++++++++++++++ src/corelib/doc/src/qtcore.qdoc | 7 +- src/corelib/doc/src/statemachine.qdoc | 7 +- src/corelib/doc/src/threads.qdoc | 28 ++--- 12 files changed, 186 insertions(+), 42 deletions(-) create mode 100644 src/corelib/doc/src/qtcore-index.qdoc diff --git a/src/corelib/codecs/codecs.qdoc b/src/corelib/codecs/codecs.qdoc index b9823023551..3a9f5c8f794 100644 --- a/src/corelib/codecs/codecs.qdoc +++ b/src/corelib/codecs/codecs.qdoc @@ -31,10 +31,10 @@ \ingroup groups \brief Codec support in Qt. - These codecs provide facilities for conversion between Unicode and - specific text encodings. + These \l{Qt Core} codecs classes provide facilities for conversion between + Unicode and specific text encodings. - \generatelist{related} + \annotatedlist codecs */ /*! diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc index c76845c93ce..7724d533d6e 100644 --- a/src/corelib/doc/src/animation.qdoc +++ b/src/corelib/doc/src/animation.qdoc @@ -28,6 +28,11 @@ /*! \group animation \title Animation Framework + + This page lists classes belonging to \l{Qt Core}'s + \l{The Animation Framework}{animation framework}. + + \annotatedlist animation */ /*! @@ -102,7 +107,7 @@ the framework, please look up their class descriptions. \section1 Classes in the Animation Framework - + These classes provide a framework for creating both simple and complex animations. @@ -361,4 +366,3 @@ framework for animations, see the states example (it lives in the \c{examples/animation/states} directory). */ - diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index 24c5629ae2c..29c30869bab 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -33,12 +33,13 @@ \brief Collection classes such as list, queue, stack and string, along with other classes that can be used without needing QApplication. - The non-GUI classes are general-purpose collection and string classes - that may be used independently of the GUI classes. + These \l{Qt Core} non-GUI classes are general-purpose collection and string + classes that may be used independently of the GUI classes. In particular, these classes do not depend on QApplication at all, and so can be used in non-GUI programs. + \annotatedlist tools */ /*! @@ -394,13 +395,13 @@ QMapIterator, which is somewhat different because it iterates on (key, value) pairs. - Like QListIterator, QMapIterator provides - \l{QMapIterator::toFront()}{toFront()}, - \l{QMapIterator::toBack()}{toBack()}, - \l{QMapIterator::hasNext()}{hasNext()}, - \l{QMapIterator::next()}{next()}, - \l{QMapIterator::peekNext()}{peekNext()}, - \l{QMapIterator::hasPrevious()}{hasPrevious()}, + Like QListIterator, QMapIterator provides + \l{QMapIterator::toFront()}{toFront()}, + \l{QMapIterator::toBack()}{toBack()}, + \l{QMapIterator::hasNext()}{hasNext()}, + \l{QMapIterator::next()}{next()}, + \l{QMapIterator::peekNext()}{peekNext()}, + \l{QMapIterator::hasPrevious()}{hasPrevious()}, \l{QMapIterator::previous()}{previous()}, and \l{QMapIterator::peekPrevious()}{peekPrevious()}. The key and value components are extracted by calling key() and value() on diff --git a/src/corelib/doc/src/eventsandfilters.qdoc b/src/corelib/doc/src/eventsandfilters.qdoc index 5fe444538d9..e4605afb0b5 100644 --- a/src/corelib/doc/src/eventsandfilters.qdoc +++ b/src/corelib/doc/src/eventsandfilters.qdoc @@ -32,10 +32,11 @@ \brief Classes used to create and handle events. - These classes are used to create and handle events. + These \l{Qt Core} classes are used to create and handle events. - For more information see the \link object.html Object model\endlink - and \link signalsandslots.html Signals and Slots\endlink. + For more information see the \l{The Event System}{Event System} page. + + \annotatedlist events */ /*! diff --git a/src/corelib/doc/src/implicit-sharing.qdoc b/src/corelib/doc/src/implicit-sharing.qdoc index 7b29998951d..2038d432304 100644 --- a/src/corelib/doc/src/implicit-sharing.qdoc +++ b/src/corelib/doc/src/implicit-sharing.qdoc @@ -31,6 +31,12 @@ /*! \group shared \title Implicitly Shared Classes + + These \l{Qt Core} classes provides a safe and efficient way of sharing and + manipulating data by \l{Implicit Sharing}{implicitly sharing} data. + + \annotatedlist shared + */ /*! diff --git a/src/corelib/doc/src/io.qdoc b/src/corelib/doc/src/io.qdoc index cd967844c0b..7aff2279310 100644 --- a/src/corelib/doc/src/io.qdoc +++ b/src/corelib/doc/src/io.qdoc @@ -33,7 +33,9 @@ \brief Classes providing file input and output along with directory and network handling. - These classes are used to handle input and output to and from external - devices, processes, files etc. as well as manipulating files and directories. -*/ + These \l{Qt Core} classes are used to handle input and output to and from + external devices, processes, files etc. as well as manipulating files and + directories. + \annotatedlist io +*/ diff --git a/src/corelib/doc/src/json.qdoc b/src/corelib/doc/src/json.qdoc index 25496dd7593..9e6e190dcb8 100644 --- a/src/corelib/doc/src/json.qdoc +++ b/src/corelib/doc/src/json.qdoc @@ -108,5 +108,6 @@ \annotatedlist json - All JSON classes are value based, implicitly shared classes. + All JSON classes are value based, + \l{Implicit Sharing}{implicitly shared classes}. */ diff --git a/src/corelib/doc/src/plugins-howto.qdoc b/src/corelib/doc/src/plugins-howto.qdoc index f0031ee26b5..bc387aeed9e 100644 --- a/src/corelib/doc/src/plugins-howto.qdoc +++ b/src/corelib/doc/src/plugins-howto.qdoc @@ -32,12 +32,14 @@ \brief Plugin related classes. - These classes deal with shared libraries, (e.g. .so and DLL files), - and with Qt plugins. + These \l{Qt Core} classes deal with shared libraries, (e.g. .so and DLL + files), and with Qt plugins. - See the \link plugins-howto.html plugins documentation\endlink. + See the \l{How to Create Qt Plugins} page for more information.. See also the \l{ActiveQt framework} for Windows. + + \annotatedlist plugins */ /*! diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc new file mode 100644 index 00000000000..5cf187172b8 --- /dev/null +++ b/src/corelib/doc/src/qtcore-index.qdoc @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtcore-index.html + \title Qt Core + \ingroup modules + + \brief The Qt Core module is part of Qt's essential modules. + + \section1 Getting Started + All other Qt modules rely on this module. To include the + definitions of the module's classes, use the following directive: + + \snippet code/doc_src_qtcore.cpp 0 + + \section1 Core Functionalities + + Qt adds these features to C++: + + \list + \li a very powerful mechanism for seamless object communication called + signals and slots + \li queryable and designable object properties + \li hierarchical and queryable object trees that organize + \li object ownership in a natural way with guarded pointers (QPointer) + \li a dynamic cast that works across library boundaries + \endlist + + The following pages provide more information about Qt's core features: + \list + \li \l{The Meta-Object System} + \li \l{The Property System} + \li \l{Object Model} + \li \l{Object Trees & Ownership} + \li \l{Signals & Slots} + \endlist + + \section1 Threading and Concurrent Programming + + Qt provides thread support in the form of platform-independent \l{Threading + Classes}{threading classes}, a thread-safe way of posting events, and + signal-slot connections across threads. Multithreaded programming is also a + useful paradigm for performing time-consuming operations without freezing + the user interface of an application. + + The \l{Thread Support in Qt} page contains information on implementing + threads in applications. Additional concurrent classes are provided by the + \l{Qt Concurrent} module. + + \section1 Input/Output, Resources, and Containers + + Qt provides a resource system for organizing application files and assets, + a set of containers, and classes for receiving input and printing output. + \list + \li \l{Container Classes} + \li \l{Serializing Qt Data Types} + \li \l{Implicit Sharing} + \endlist + + In addition, Qt Core provides a platform-independent mechanism for storing + binary files in the application's executable. + + \list + \li \l{The Qt Resource System} + \endlist + + \section1 Additional Frameworks + Qt Core also provides some of Qt's key frameworks. + + \list + \li \l{The Animation Framework} + \li \l{JSON Support in Qt} + \li \l{The State Machine Framework} + \li \l{How to Create Qt Plugins} + \li \l{The Event System} + \endlist + + \section1 Related Information + \section1 Reference + These are links to the API reference materials. + \list + \li \l{Qt Core C++ Classes}{C++ classes} + \list + \li \l{Animation Framework}{Animation Classes} + \li \l{Threading Classes} + \li \l{Non-GUI Classes} + \li \l{Container Classes} + \li \l{Plugin Classes} + \li \l{Implicitly Shared Classes} + \li \l{State Machine Classes} + \li \l{Input/Output and Networking}{Input/Output Classes} + \li \l{Event Classes} + \endlist + \endlist + +*/ diff --git a/src/corelib/doc/src/qtcore.qdoc b/src/corelib/doc/src/qtcore.qdoc index 0d06bb7998b..4b4814d5b72 100644 --- a/src/corelib/doc/src/qtcore.qdoc +++ b/src/corelib/doc/src/qtcore.qdoc @@ -27,16 +27,13 @@ /*! \module QtCore - \title QtCore Module + \title Qt Core C++ Classes \ingroup modules - \keyword QtCore - - \brief The QtCore module contains core non-GUI functionality. + \brief Provides core non-GUI functionality. All other Qt modules rely on this module. To include the definitions of the module's classes, use the following directive: \snippet code/doc_src_qtcore.cpp 0 */ - diff --git a/src/corelib/doc/src/statemachine.qdoc b/src/corelib/doc/src/statemachine.qdoc index dd4f9922884..1a5c216e048 100644 --- a/src/corelib/doc/src/statemachine.qdoc +++ b/src/corelib/doc/src/statemachine.qdoc @@ -28,6 +28,11 @@ /*! \group statemachine \title State Machine Classes + + These \l{Qt Core} classes are part of the \l{The State Machine Framework}{ + State Machine Framework}. + + \annotatedlist statemachine */ /*! @@ -69,7 +74,7 @@ \section1 Classes in the State Machine Framework These classes are provided by qt for creating event-driven state machines. - + \annotatedlist statemachine \section1 A Simple State Machine diff --git a/src/corelib/doc/src/threads.qdoc b/src/corelib/doc/src/threads.qdoc index 0f752bc726a..64d33e3b34f 100644 --- a/src/corelib/doc/src/threads.qdoc +++ b/src/corelib/doc/src/threads.qdoc @@ -28,6 +28,10 @@ /*! \group thread \title Threading Classes + + These \l{Qt Core} classes provide threading support to applications. + The \l{Thread Support in Qt} page covers how to use these classes. + \annotatedlist thread */ /*! @@ -111,13 +115,13 @@ /*! \page threads-starting.html \title Starting Threads with QThread - + \contentspage Thread Support in Qt \nextpage Synchronizing Threads A QThread instance represents a thread and provides the means to \l{QThread::start()}{start()} a thread, which will then execute the - reimplementation of QThread::run(). The \c run() implementation is for a + reimplementation of QThread::run(). The \c run() implementation is for a thread what the \c main() entry point is for the application. All code executed in a call stack that starts in the \c run() function is executed by the new thread, and the thread finishes when the function returns. @@ -141,12 +145,12 @@ Then, create an instance of the thread object and call QThread::start(). Note that you must create the QApplication (or QCoreApplication) object before you can create a QThread. - - The function will return immediately and the + + The function will return immediately and the main thread will continue. The code that appears in the \l{QThread::run()}{run()} reimplementation will then be executed in a separate thread. - + Creating threads is explained in more detail in the QThread documentation. @@ -160,7 +164,7 @@ /*! \page threads-synchronizing.html \title Synchronizing Threads - + \previouspage Starting Threads with QThread \contentspage Thread Support in Qt \nextpage Reentrancy and Thread-Safety @@ -227,7 +231,7 @@ \list \li A \e thread-safe function can be called simultaneously from - multiple threads, even when the invocations use shared data, + multiple threads, even when the invocations use shared data, because all references to the shared data are serialized. \li A \e reentrant function can also be called simultaneously from multiple threads, but only if each invocation uses its own data. @@ -577,8 +581,8 @@ \endlist - Qt Concurrent supports several STL-compatible container and iterator types, - but works best with Qt containers that have random-access iterators, such as + Qt Concurrent supports several STL-compatible container and iterator types, + but works best with Qt containers that have random-access iterators, such as QList or QVector. The map and filter functions accept both containers and begin/end iterators. STL Iterator support overview: @@ -609,14 +613,14 @@ \li QList, QVector, std::vector \li Supported and Recommended \endtable - + Random access iterators can be faster in cases where Qt Concurrent is iterating over a large number of lightweight items, since they allow skipping to any point in the container. In addition, using random access iterators allows Qt Concurrent to provide progress information trough QFuture::progressValue() and QFutureWatcher:: progressValueChanged(). - The non in-place modifying functions such as mapped() and filtered() makes a + The non in-place modifying functions such as mapped() and filtered() makes a copy of the container when called. If you are using STL containers this copy operation might take some time, in this case we recommend specifying the begin and end iterators for the container instead. @@ -643,7 +647,7 @@ QPainter can be used in a thread to paint onto QImage, QPrinter, and QPicture paint devices. Painting onto QPixmaps and QWidgets is \e not - supported. On Mac OS X the automatic progress dialog will not be + supported. On Mac OS X the automatic progress dialog will not be displayed if you are printing from outside the GUI thread. Any number of threads can paint at any given time, however only From f224d073d5212a8b358253d209030925cbdb00b3 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Thu, 25 Oct 2012 19:42:33 +0200 Subject: [PATCH 027/134] test: Don't fail if the network test server is not set up Leftover from 704a4e4747b2c42e262d9b4bd440ff365ab92a35 Change-Id: I437da91be31259a748303bd7cf20ff0c8bcf53b4 Reviewed-by: Caroline Chao --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 284768ea13d..b3282beaf53 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1354,7 +1354,8 @@ void tst_QNetworkReply::initTestCase() if (testDataDir.isEmpty()) testDataDir = QCoreApplication::applicationDirPath(); - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #if !defined Q_OS_WIN wronlyFileName = testDataDir + "/write-only" + uniqueExtension; QFile wr(wronlyFileName); From ae789544e4a239a1e26ab96fd07603cee016cd18 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 20 Sep 2012 12:17:30 +0200 Subject: [PATCH 028/134] simplify determination of static plugin link line qt_debug & qt_release are dead, so collapse the respective paths and use an existing function. Change-Id: Ie800be477186a6eab72682d367b24e83c3b9bbc0 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 8f797a59603..28f8c8dd6dd 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -38,16 +38,6 @@ plugin { #Qt plugins QT_PLUGIN_VERIFY = QTPLUGIN DEPLOYMENT_PLUGIN for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) { for(QTPLUG, $$list($$lower($$unique($$QT_CURRENT_VERIFY)))) { - qplugin_style = - !qt_debug:!qt_release { - CONFIG(debug, debug|release):qplugin_style = debug - else:qplugin_style = release - } else:CONFIG(qt_debug, qt_debug|qt_release) { - qplugin_style = debug - } else { - qplugin_style = release - } - # Check if the plugin is known to Qt. We can use this to determine # the plugin path. Unknown plugins must rely on the default link path. ACCESSIBLEPLUGINS = qtaccessiblewidgets qtaccessiblecompatwidgets @@ -86,12 +76,7 @@ for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) { target_qt:isEqual(TARGET, QTPLUG) { warning($$TARGET cannot have a QTPLUGIN of $$QTPLUG) } else { - QT_LINKAGE = -l$${QTPLUG} - win32 { - CONFIG(debug, debug|release):QT_LINKAGE = -l$${QTPLUG}d - } else:mac { - isEqual(qplugin_style, debug):QT_LINKAGE = -l$${QTPLUG}_debug - } + QT_LINKAGE = -l$${QTPLUG}$$qtPlatformTargetSuffix() } # Only link against plugin in static builds From bb8c83986f9ebfb324210a08aea7b182c3afa219 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 13 Jul 2012 19:38:32 +0200 Subject: [PATCH 029/134] Set the Directory flag when we find a directory. Change-Id: I103a0b8e7b7ba673d00f920944026d7d04fac193 Reviewed-by: hjk --- src/tools/rcc/rcc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 10d7c093fcf..969b644d847 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -535,7 +535,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, child, language, country, - RCCFileInfo::NoFlags, + child.isDir() ? RCCFileInfo::Directory : RCCFileInfo::NoFlags, compressLevel, compressThreshold) ); From 5ca03eddd372c00714d11211caae4c7b7959cfd4 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Sat, 13 Oct 2012 22:21:00 +0200 Subject: [PATCH 030/134] QSqlRelationalDelegate: remove setEditorData reimplementation Since commit 84787d82ee9369b2a83c5b0568ee62ab602a5528 QItemDelegate::setEditorData() works out of the box on QComboBox. Change-Id: Ic9839f7eccccbdb787ce204fe98311335ee16b92 Reviewed-by: Stephen Kelly --- src/sql/models/qsqlrelationaldelegate.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/sql/models/qsqlrelationaldelegate.h b/src/sql/models/qsqlrelationaldelegate.h index 439dde2662c..52a19dbb0a8 100644 --- a/src/sql/models/qsqlrelationaldelegate.h +++ b/src/sql/models/qsqlrelationaldelegate.h @@ -82,17 +82,6 @@ QWidget *createEditor(QWidget *aParent, return combo; } -void setEditorData(QWidget *editor, const QModelIndex &index) const -{ - const QSqlRelationalTableModel *sqlModel = qobject_cast(index.model()); - QComboBox *combo = qobject_cast(editor); - if (!sqlModel || !combo) { - QItemDelegate::setEditorData(editor, index); - return; - } - combo->setCurrentIndex(combo->findText(sqlModel->data(index).toString())); -} - void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { if (!index.isValid()) From 02dacc2c064339f557101db98bd40ace361e1bb6 Mon Sep 17 00:00:00 2001 From: Jon Severinsson Date: Fri, 26 Oct 2012 01:49:28 +0200 Subject: [PATCH 031/134] Change one int to qint64 in QDateTime::setMSecsSinceEpoch(qint64) This one was missed when the QDate range was extended. Change-Id: I0dbcc9fdebca88f7397203d8e539429dcff9ac30 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 7d18e93dce8..67dbbef9ad7 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2418,7 +2418,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs) QDateTimePrivate::Spec oldSpec = d->spec; - int ddays = msecs / MSECS_PER_DAY; + qint64 ddays = msecs / MSECS_PER_DAY; msecs %= MSECS_PER_DAY; if (msecs < 0) { // negative From 9dacccd0391219c97c01e89f0547ee002abb1e55 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Thu, 25 Oct 2012 10:53:35 +0200 Subject: [PATCH 032/134] Removed usage of pipe in Blackberry event dispatcher Using a pipe for thread wake-ups is inefficient and can introduce significant latency. Replaced the pipe by directly sending a BPS event. Refactored the wake-up code in the private class of the UNIX event dispatcher. Change-Id: Ic073b0b56c3cbf8327fc6bc3c37132cc3583ef86 Reviewed-by: Thomas McGuire Reviewed-by: Thiago Macieira Reviewed-by: Rafael Roquetto --- .../kernel/qeventdispatcher_blackberry.cpp | 55 +++++++++++------- .../kernel/qeventdispatcher_blackberry_p.h | 6 ++ src/corelib/kernel/qeventdispatcher_unix.cpp | 57 +++++++++++-------- src/corelib/kernel/qeventdispatcher_unix_p.h | 2 + 4 files changed, 78 insertions(+), 42 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp index b2ec574c893..4be1d73b7af 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp +++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp @@ -67,7 +67,7 @@ struct bpsIOHandlerData { fd_set *exceptfds; }; -static int bpsIOReadyDomain = -1; +static int bpsUnblockDomain = -1; static int bpsIOHandler(int fd, int io_events, void *data) { @@ -103,13 +103,13 @@ static int bpsIOHandler(int fd, int io_events, void *data) qEventDispatcherDebug << "Sending bpsIOReadyDomain event"; // create IO ready event bps_event_t *event; - int result = bps_event_create(&event, bpsIOReadyDomain, 0, NULL, NULL); + int result = bps_event_create(&event, bpsUnblockDomain, 0, NULL, NULL); if (result != BPS_SUCCESS) { qWarning("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_event_create() failed"); return BPS_FAILURE; } - // post IO ready event to our thread + // post unblock event to our thread result = bps_push_event(event); if (result != BPS_SUCCESS) { qWarning("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_push_event() failed"); @@ -129,31 +129,33 @@ QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberryPrivate() if (result != BPS_SUCCESS) qFatal("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_initialize() failed"); - // get domain for IO ready events - ignoring race condition here for now - if (bpsIOReadyDomain == -1) { - bpsIOReadyDomain = bps_register_domain(); - if (bpsIOReadyDomain == -1) + bps_channel = bps_channel_get_active(); + + // get domain for IO ready and wake up events - ignoring race condition here for now + if (bpsUnblockDomain == -1) { + bpsUnblockDomain = bps_register_domain(); + if (bpsUnblockDomain == -1) qWarning("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_register_domain() failed"); } - - // Register thread_pipe[0] with bps - int io_events = BPS_IO_INPUT; - result = bps_add_fd(thread_pipe[0], io_events, &bpsIOHandler, ioData.data()); - if (result != BPS_SUCCESS) - qWarning() << Q_FUNC_INFO << "bps_add_fd() failed"; } QEventDispatcherBlackberryPrivate::~QEventDispatcherBlackberryPrivate() { - // Unregister thread_pipe[0] from bps - const int result = bps_remove_fd(thread_pipe[0]); - if (result != BPS_SUCCESS) - qWarning() << Q_FUNC_INFO << "bps_remove_fd() failed"; - // we're done using BPS bps_shutdown(); } +int QEventDispatcherBlackberryPrivate::initThreadWakeUp() +{ + return -1; // no fd's used +} + +int QEventDispatcherBlackberryPrivate::processThreadWakeUp(int nsel) +{ + Q_UNUSED(nsel); + return wakeUps.fetchAndStoreRelaxed(0); +} + ///////////////////////////////////////////////////////////////////////////// QEventDispatcherBlackberry::QEventDispatcherBlackberry(QObject *parent) @@ -317,7 +319,7 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef if (!event) // In case of !event, we break out of the loop to let Qt process the timers break; // (since timeout has expired) and socket notifiers that are now ready. - if (bps_event_get_domain(event) == bpsIOReadyDomain) { + if (bps_event_get_domain(event) == bpsUnblockDomain) { timeoutTotal = 0; // in order to immediately drain the event queue of native events event = 0; // (especially touch move events) we don't break out here } @@ -339,6 +341,21 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef return d->ioData->count; } +void QEventDispatcherBlackberry::wakeUp() +{ + Q_D(QEventDispatcherBlackberry); + if (d->wakeUps.testAndSetAcquire(0, 1)) { + bps_event_t *event; + if (bps_event_create(&event, bpsUnblockDomain, 0, 0, 0) == BPS_SUCCESS) { + if (bps_channel_push_event(d->bps_channel, event) == BPS_SUCCESS) + return; + else + bps_event_destroy(event); + } + qWarning("QEventDispatcherBlackberryPrivate::wakeUp failed"); + } +} + int QEventDispatcherBlackberry::ioEvents(int fd) { int io_events = 0; diff --git a/src/corelib/kernel/qeventdispatcher_blackberry_p.h b/src/corelib/kernel/qeventdispatcher_blackberry_p.h index 84cdf9e2ddc..79ed21dbf26 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry_p.h +++ b/src/corelib/kernel/qeventdispatcher_blackberry_p.h @@ -71,6 +71,8 @@ public: void registerSocketNotifier(QSocketNotifier *notifier); void unregisterSocketNotifier(QSocketNotifier *notifier); + void wakeUp(); + protected: QEventDispatcherBlackberry(QEventDispatcherBlackberryPrivate &dd, QObject *parent = 0); @@ -89,6 +91,10 @@ public: QEventDispatcherBlackberryPrivate(); ~QEventDispatcherBlackberryPrivate(); + int initThreadWakeUp(); + int processThreadWakeUp(int nsel); + + int bps_channel; QScopedPointer ioData; }; diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 44715b05533..6c2a610a56c 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -110,7 +110,7 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate() bool pipefail = false; // initialize the common parts of the event loop -#if defined(Q_OS_NACL) +#if defined(Q_OS_NACL) || defined (Q_OS_BLACKBERRY) // do nothing. #elif defined(Q_OS_INTEGRITY) // INTEGRITY doesn't like a "select" on pipes, so use socketpair instead @@ -157,7 +157,7 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate() QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate() { -#if defined(Q_OS_NACL) +#if defined(Q_OS_NACL) || defined (Q_OS_BLACKBERRY) // do nothing. #elif defined(Q_OS_VXWORKS) close(thread_pipe[0]); @@ -211,8 +211,8 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, FD_ZERO(&sn_vec[2].select_fds); } - FD_SET(thread_pipe[0], &sn_vec[0].select_fds); - highest = qMax(highest, thread_pipe[0]); + int wakeUpFd = initThreadWakeUp(); + highest = qMax(highest, wakeUpFd); nsel = q->select(highest + 1, &sn_vec[0].select_fds, @@ -271,25 +271,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, } } - // some other thread woke us up... consume the data on the thread pipe so that - // select doesn't immediately return next time - int nevents = 0; - if (nsel > 0 && FD_ISSET(thread_pipe[0], &sn_vec[0].select_fds)) { -#if defined(Q_OS_VXWORKS) - char c[16]; - ::read(thread_pipe[0], c, sizeof(c)); - ::ioctl(thread_pipe[0], FIOFLUSH, 0); -#else - char c[16]; - while (::read(thread_pipe[0], c, sizeof(c)) > 0) - ; -#endif - if (!wakeUps.testAndSetRelease(1, 0)) { - // hopefully, this is dead code - qWarning("QEventDispatcherUNIX: internal error, wakeUps.testAndSetRelease(1, 0) failed!"); - } - ++nevents; - } + int nevents = processThreadWakeUp(nsel); // activate socket notifiers if (! (flags & QEventLoop::ExcludeSocketNotifiers) && nsel > 0 && sn_highest >= 0) { @@ -307,6 +289,35 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, return (nevents + q->activateSocketNotifiers()); } +int QEventDispatcherUNIXPrivate::initThreadWakeUp() +{ + FD_SET(thread_pipe[0], &sn_vec[0].select_fds); + return thread_pipe[0]; +} + +int QEventDispatcherUNIXPrivate::processThreadWakeUp(int nsel) +{ + if (nsel > 0 && FD_ISSET(thread_pipe[0], &sn_vec[0].select_fds)) { + // some other thread woke us up... consume the data on the thread pipe so that + // select doesn't immediately return next time +#if defined(Q_OS_VXWORKS) + char c[16]; + ::read(thread_pipe[0], c, sizeof(c)); + ::ioctl(thread_pipe[0], FIOFLUSH, 0); +#else + char c[16]; + while (::read(thread_pipe[0], c, sizeof(c)) > 0) + ; +#endif + if (!wakeUps.testAndSetRelease(1, 0)) { + // hopefully, this is dead code + qWarning("QEventDispatcherUNIX: internal error, wakeUps.testAndSetRelease(1, 0) failed!"); + } + return 1; + } + return 0; +} + QEventDispatcherUNIX::QEventDispatcherUNIX(QObject *parent) : QAbstractEventDispatcher(*new QEventDispatcherUNIXPrivate, parent) { } diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index 0c5d06ddd11..98ea19ced85 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -144,6 +144,8 @@ public: ~QEventDispatcherUNIXPrivate(); int doSelect(QEventLoop::ProcessEventsFlags flags, timeval *timeout); + virtual int initThreadWakeUp(); + virtual int processThreadWakeUp(int nsel); bool mainThread; int thread_pipe[2]; From fe4068a12b135add4e1203fc1214d238865b49a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 25 Oct 2012 14:36:45 +0200 Subject: [PATCH 033/134] Check the EGL error before calling eglTerminate(). Otherwise we always get EGL_SUCCESS, which is not very informative. Change-Id: I25311c14108ae385913aa9dc159a1f5fad142342 Reviewed-by: Rainer Keller Reviewed-by: Andy Nichols --- src/plugins/platforms/eglfs/qeglfswindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 036b26a1659..32d20e6aaa7 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -89,8 +89,9 @@ void QEglFSWindow::create() m_window = hooks->createNativeWindow(hooks->screenSize(), m_format); m_surface = eglCreateWindowSurface(display, config, m_window, NULL); if (m_surface == EGL_NO_SURFACE) { + EGLint error = eglGetError(); eglTerminate(display); - qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", eglGetError()); + qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", error); } } From d9984697401460c64d1a49838b61a298f291b9dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 23 Oct 2012 17:19:29 +0200 Subject: [PATCH 034/134] Prevent potential crash in QXcbCursor::queryPointer(). xcb_get_setup might return 0, but we already have it in QXcbConnection. Task-number: QTBUG-27686 Change-Id: I58418aedd6bc121ae2b9605389beb3f6612d7fb7 Reviewed-by: Friedemann Kleint Reviewed-by: Shawn Rutledge Reviewed-by: Gatis Paeglis Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbcursor.cpp | 17 ++++++++--------- src/plugins/platforms/xcb/qxcbcursor.h | 2 +- src/plugins/platforms/xcb/qxcbintegration.cpp | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 0510c1db5bb..c1cfbd02d6e 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -508,16 +508,16 @@ xcb_cursor_t QXcbCursor::createBitmapCursor(QCursor *cursor) return c; } -void QXcbCursor::queryPointer(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint *pos, int *keybMask) +void QXcbCursor::queryPointer(QXcbConnection *c, xcb_window_t *rootWin, QPoint *pos, int *keybMask) { if (pos) *pos = QPoint(); - xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(conn)); + xcb_screen_iterator_t it = xcb_setup_roots_iterator(c->setup()); while (it.rem) { xcb_window_t root = it.data->root; - xcb_query_pointer_cookie_t cookie = xcb_query_pointer(conn, root); + xcb_query_pointer_cookie_t cookie = xcb_query_pointer(c->xcb_connection(), root); xcb_generic_error_t *err = 0; - xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(conn, cookie, &err); + xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(c->xcb_connection(), cookie, &err); if (!err && reply) { if (pos) *pos = QPoint(reply->root_x, reply->root_y); @@ -537,17 +537,16 @@ void QXcbCursor::queryPointer(xcb_connection_t *conn, xcb_window_t *rootWin, QPo QPoint QXcbCursor::pos() const { QPoint p; - queryPointer(xcb_connection(), 0, &p); + queryPointer(connection(), 0, &p); return p; } void QXcbCursor::setPos(const QPoint &pos) { - xcb_connection_t *conn = xcb_connection(); xcb_window_t root; - queryPointer(conn, &root, 0); - xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, pos.x(), pos.y()); - xcb_flush(conn); + queryPointer(connection(), &root, 0); + xcb_warp_pointer(xcb_connection(), XCB_NONE, root, 0, 0, 0, 0, pos.x(), pos.y()); + xcb_flush(xcb_connection()); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h index 9726c5955ad..4c74034988f 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.h +++ b/src/plugins/platforms/xcb/qxcbcursor.h @@ -56,7 +56,7 @@ public: QPoint pos() const; void setPos(const QPoint &pos); - static void queryPointer(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint *pos, int *keybMask = 0); + static void queryPointer(QXcbConnection *c, xcb_window_t *rootWin, QPoint *pos, int *keybMask = 0); private: xcb_cursor_t createFontCursor(int cshape); diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 5170ff9e101..a46d51127fb 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -275,8 +275,8 @@ QPlatformServices *QXcbIntegration::services() const Qt::KeyboardModifiers QXcbIntegration::queryKeyboardModifiers() const { int keybMask = 0; - QXcbConnection* conn = m_connections.at(0); - QXcbCursor::queryPointer(conn->xcb_connection(), 0, 0, &keybMask); + QXcbConnection *conn = m_connections.at(0); + QXcbCursor::queryPointer(conn, 0, 0, &keybMask); return conn->keyboard()->translateModifiers(keybMask); } From 67a0f546c507d4113de895df297815adcb5d489e Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Fri, 26 Oct 2012 12:51:03 +0200 Subject: [PATCH 035/134] test: Remove dead code from tst_QPixmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1945a0f431364f47a43cf7f600ad38fdba5f4a08 Reviewed-by: Caroline Chao Reviewed-by: Samuel Rødal --- tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 1918841d241..6a7ce66bd78 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -439,12 +439,7 @@ void tst_QPixmap::fill_data() QTest::newRow(QString("syscolor_%1").arg(color).toLatin1()) << uint(color) << true << false; -#ifdef Q_WS_QWS - if (QScreen::instance()->depth() >= 24) { -#elif defined (Q_WS_X11) - QPixmap pm(1, 1); - if (pm.x11PictureHandle()) { -#elif defined (Q_OS_WINCE) +#if defined (Q_OS_WINCE) QPixmap pixmap(1,1); if (QApplication::desktop()->grab().depth() >= 24) { #else From cfc3eeea1b3fbf31998deef65fb01214d44d36fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Mon, 1 Oct 2012 06:42:28 +0200 Subject: [PATCH 036/134] QMap - use hint on insert in QMap::toStdMap Giving the std-map a hint (normally) improves insert performance. There seems to be no reason not to provide this hint. Change-Id: I4344607ebf54574a3ae9666d87a41a3c14762361 Reviewed-by: Robin Burchell Reviewed-by: Lars Knoll --- src/corelib/tools/qmap.h | 2 +- tests/benchmarks/corelib/tools/qmap/main.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 642cf82f085..0e726e8394b 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -946,7 +946,7 @@ Q_OUTOFLINE_TEMPLATE std::map QMap::toStdMap() const const_iterator it = end(); while (it != begin()) { --it; - map.insert(std::pair(it.key(), it.value())); + map.insert(map.begin(), std::pair(it.key(), it.value())); } return map; } diff --git a/tests/benchmarks/corelib/tools/qmap/main.cpp b/tests/benchmarks/corelib/tools/qmap/main.cpp index 05b52ba42f3..c3b9c18cd27 100644 --- a/tests/benchmarks/corelib/tools/qmap/main.cpp +++ b/tests/benchmarks/corelib/tools/qmap/main.cpp @@ -60,6 +60,7 @@ private slots: void lookup_string_int(); void iteration(); + void toStdMap(); }; @@ -159,6 +160,17 @@ void tst_QMap::iteration() } } +void tst_QMap::toStdMap() +{ + QMap map; + for (int i = 0; i < 100000; ++i) + map.insert(i, i); + + QBENCHMARK { + std::map n = map.toStdMap(); + n.begin(); + } +} QTEST_MAIN(tst_QMap) From 6e4d7bbb0baeff2362e3d25be6aedcb68e7909b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Thu, 27 Sep 2012 14:56:43 +0200 Subject: [PATCH 037/134] QMap 5.0 - keep track of leftmost node (BIC) This suggestion keeps track of the most left node. The point is that constBegin() becomes a lot faster. That speeds up iteration a bit, and makes it O(1) to get the first element. The penalty in insert and remove is very small. On large trees it seems to be less than 1%. It should be noticed that constBegin() is a very common hint on my planned change to 5.1, and this opperation will without this patch cost 2 x log N. One when the user calls the hint with begin - and one where it is compared with begin. Other std::maps has a very fast begin(). E.g http://www.cplusplus.com/reference/stl/map/begin/ (begin with constant time) Change-Id: I221f6755aa8bd16a5189771c5bc8ae56c8ee0fb4 Reviewed-by: Lars Knoll --- src/corelib/tools/qmap.cpp | 18 +++- src/corelib/tools/qmap.h | 8 +- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 94 +++++++++++++++++++- tests/benchmarks/corelib/tools/qmap/main.cpp | 17 ++++ 4 files changed, 133 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index dea87c6b639..7c33d607501 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE -const QMapDataBase QMapDataBase::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, { 0, 0, 0 } }; +const QMapDataBase QMapDataBase::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, { 0, 0, 0 }, 0 }; const QMapNodeBase *QMapNodeBase::nextNode() const { @@ -177,6 +177,12 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z) QMapNodeBase *x_parent; if (y->left == 0) { x = y->right; + if (y == mostLeftNode) { + if (x) + mostLeftNode = x; // It cannot have (left) children due the red black invariant. + else + mostLeftNode = y->parent(); + } } else { if (y->right == 0) { x = y->left; @@ -290,6 +296,13 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z) --size; } +void QMapDataBase::recalcMostLeftNode() +{ + mostLeftNode = &header; + while (mostLeftNode->left) + mostLeftNode = mostLeftNode->left; +} + static inline int qMapAlignmentThreshold() { // malloc on 32-bit platforms should return pointers that are 8-byte @@ -324,6 +337,8 @@ QMapNodeBase *QMapDataBase::createNode(int alloc, int alignment, QMapNodeBase *p if (parent) { if (left) { parent->left = node; + if (parent == mostLeftNode) + mostLeftNode = node; } else { parent->right = node; } @@ -352,6 +367,7 @@ QMapDataBase *QMapDataBase::createData() d->header.p = 0; d->header.left = 0; d->header.right = 0; + d->mostLeftNode = &(d->header); return d; } diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 0e726e8394b..e0b267ce208 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -173,11 +173,13 @@ struct Q_CORE_EXPORT QMapDataBase QtPrivate::RefCount ref; int size; QMapNodeBase header; + QMapNodeBase *mostLeftNode; void rotateLeft(QMapNodeBase *x); void rotateRight(QMapNodeBase *x); void rebalance(QMapNodeBase *x); void freeNodeAndRebalance(QMapNodeBase *z); + void recalcMostLeftNode(); QMapNodeBase *createNode(int size, int alignment, QMapNodeBase *parent, bool left); void freeTree(QMapNodeBase *root, int alignment); @@ -197,8 +199,8 @@ struct QMapData : public QMapDataBase const Node *end() const { return static_cast(&header); } Node *end() { return static_cast(&header); } - const Node *begin() const { if (root()) return root()->minimumNode(); return end(); } - Node *begin() { if (root()) return root()->minimumNode(); return end(); } + const Node *begin() const { if (root()) return static_cast(mostLeftNode); return end(); } + Node *begin() { if (root()) return static_cast(mostLeftNode); return end(); } void deleteNode(Node *z); Node *findNode(const Key &akey) const; @@ -555,6 +557,7 @@ inline QMap::QMap(const QMap &other) if (other.d->header.left) { d->header.left = static_cast(other.d->header.left)->copy(d); d->header.left->setParent(&d->header); + d->recalcMostLeftNode(); } } } @@ -780,6 +783,7 @@ Q_OUTOFLINE_TEMPLATE void QMap::detach_helper() if (!d->ref.deref()) d->destroy(); d = x; + d->recalcMostLeftNode(); } template diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index e07b3fc81e1..9c53563a5cb 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -49,6 +49,9 @@ class tst_QMap : public QObject { Q_OBJECT +protected: + template + void sanityCheckTree(const QMap &m, int calledFromLine); public slots: void init(); private slots: @@ -79,6 +82,7 @@ private slots: void setSharable(); void insert(); + void checkMostLeftNode(); }; typedef QMap StringMap; @@ -115,6 +119,28 @@ QDebug operator << (QDebug d, const MyClass &c) { return d; } +template +void tst_QMap::sanityCheckTree(const QMap &m, int calledFromLine) +{ + QString possibleFrom; + possibleFrom.setNum(calledFromLine); + possibleFrom = "Called from line: " + possibleFrom; + int count = 0; + typename QMap::const_iterator oldite = m.constBegin(); + for (typename QMap::const_iterator i = m.constBegin(); i != m.constEnd(); ++i) { + count++; + bool oldIteratorIsLarger = i.key() < oldite.key(); + QVERIFY2(!oldIteratorIsLarger, possibleFrom.toUtf8()); + oldite = i; + } + if (m.size() != count) { // Fail + qDebug() << possibleFrom; + QCOMPARE(m.size(), count); + } + if (m.size() == 0) + QVERIFY(m.constBegin() == m.constEnd()); +} + void tst_QMap::init() { MyClass::count = 0; @@ -280,6 +306,7 @@ void tst_QMap::clear() map.insert( "key0", MyClass( "value1" ) ); map.insert( "key1", MyClass( "value2" ) ); map.clear(); + sanityCheckTree(map, __LINE__); QVERIFY( map.isEmpty() ); } QCOMPARE( MyClass::count, int(0) ); @@ -400,6 +427,8 @@ void tst_QMap::swap() m1.swap(m2); QCOMPARE(m1.value(1),QLatin1String("m2[1]")); QCOMPARE(m2.value(0),QLatin1String("m1[0]")); + sanityCheckTree(m1, __LINE__); + sanityCheckTree(m2, __LINE__); } void tst_QMap::operator_eq() @@ -631,7 +660,7 @@ void tst_QMap::lowerUpperBound() void tst_QMap::mergeCompare() { - QMap map1, map2, map3; + QMap map1, map2, map3, map1b, map2b; map1.insert(1,"ett"); map1.insert(3,"tre"); @@ -641,6 +670,13 @@ void tst_QMap::mergeCompare() map2.insert(4,"fyra"); map1.unite(map2); + sanityCheckTree(map1, __LINE__); + + map1b = map1; + map2b = map2; + map2b.insert(0, "nul"); + map1b.unite(map2b); + sanityCheckTree(map1b, __LINE__); QVERIFY(map1.value(1) == "ett"); QVERIFY(map1.value(2) == "tvo"); @@ -958,9 +994,11 @@ void tst_QMap::setSharable() QVERIFY(!map.isDetached()); QVERIFY(copy.isSharedWith(map)); + sanityCheckTree(copy, __LINE__); } map.setSharable(false); + sanityCheckTree(map, __LINE__); QVERIFY(map.isDetached()); QCOMPARE(map.size(), 4); QCOMPARE(const_(map)[4], QString("quatro")); @@ -975,6 +1013,8 @@ void tst_QMap::setSharable() QCOMPARE(const_(copy)[4], QString("quatro")); QCOMPARE(map, copy); + sanityCheckTree(map, __LINE__); + sanityCheckTree(copy, __LINE__); } map.setSharable(true); @@ -1012,5 +1052,57 @@ void tst_QMap::insert() } } +void tst_QMap::checkMostLeftNode() +{ + QMap map; + + map.insert(100, 1); + sanityCheckTree(map, __LINE__); + + // insert + map.insert(99, 1); + sanityCheckTree(map, __LINE__); + map.insert(98, 1); + sanityCheckTree(map, __LINE__); + map.insert(97, 1); + sanityCheckTree(map, __LINE__); + map.insert(96, 1); + sanityCheckTree(map, __LINE__); + map.insert(95, 1); + + // remove + sanityCheckTree(map, __LINE__); + map.take(95); + sanityCheckTree(map, __LINE__); + map.remove(96); + sanityCheckTree(map, __LINE__); + map.erase(map.begin()); + sanityCheckTree(map, __LINE__); + map.remove(97); + sanityCheckTree(map, __LINE__); + map.remove(98); + sanityCheckTree(map, __LINE__); + map.remove(99); + sanityCheckTree(map, __LINE__); + map.remove(100); + sanityCheckTree(map, __LINE__); + map.insert(200, 1); + QCOMPARE(map.constBegin().key(), 200); + sanityCheckTree(map, __LINE__); + // remove the non left most node + map.insert(202, 2); + map.insert(203, 3); + map.insert(204, 4); + map.remove(202); + sanityCheckTree(map, __LINE__); + map.remove(203); + sanityCheckTree(map, __LINE__); + map.remove(204); + sanityCheckTree(map, __LINE__); + // erase last item + map.erase(map.begin()); + sanityCheckTree(map, __LINE__); +} + QTEST_APPLESS_MAIN(tst_QMap) #include "tst_qmap.moc" diff --git a/tests/benchmarks/corelib/tools/qmap/main.cpp b/tests/benchmarks/corelib/tools/qmap/main.cpp index c3b9c18cd27..4d9833b7a18 100644 --- a/tests/benchmarks/corelib/tools/qmap/main.cpp +++ b/tests/benchmarks/corelib/tools/qmap/main.cpp @@ -61,6 +61,7 @@ private slots: void iteration(); void toStdMap(); + void iterator_begin(); }; @@ -172,6 +173,22 @@ void tst_QMap::toStdMap() } } +void tst_QMap::iterator_begin() +{ + QMap map; + for (int i = 0; i < 100000; ++i) + map.insert(i, i); + + QBENCHMARK { + for (int i = 0; i < 100000; ++i) { + QMap::const_iterator it = map.constBegin(); + QMap::const_iterator end = map.constEnd(); + if (it == end) // same as if (false) + ++it; + } + } +} + QTEST_MAIN(tst_QMap) #include "main.moc" From 1baadd85130812161f6a56aa05ab5bf2cac99cef Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 26 Oct 2012 13:12:03 -0700 Subject: [PATCH 038/134] Fix compilation: QChar(char) is "from ASCII" This fixes the build if QT_NO_CAST_FROM_ASCII is defined. Change-Id: I0273794a83b0adaa0c15a9910cbcc9ea5d48ef7a Reviewed-by: Konstantin Ritt --- src/corelib/io/qstandardpaths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 91e343b021b..4d7e3591177 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -272,7 +272,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr searchPaths.reserve(rawPaths.size()); foreach (const QString &rawPath, rawPaths) { QString cleanPath = QDir::cleanPath(rawPath); - if (cleanPath.size() > 1 && cleanPath.endsWith('/')) + if (cleanPath.size() > 1 && cleanPath.endsWith(QLatin1Char('/'))) cleanPath.truncate(cleanPath.size() - 1); searchPaths.push_back(cleanPath); } From 2a806f85229d4790850a412c31d61682a612ea61 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Tue, 16 Oct 2012 00:53:29 +0200 Subject: [PATCH 039/134] mention QComboBox::currentText changes in change list Change-Id: Iaea8b8e7d86c29902d9c0d6a38058cea40f1c0b7 Reviewed-by: David Faure --- dist/changes-5.0.0 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 5a32b46a17b..e41fc5d3934 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -588,6 +588,11 @@ QtWidgets returned from permissions() or data(FilePermissions), even if in read-only mode (QFileSystemModel::isReadOnly()). +* [QTBUG-158 QTBUG-428 QTBUG-26501] QComboBox::currentText improvements + Restored currentText as USER property. + New setter setCurrentText(), marked as WRITE method, usable by QItemDelegate and QDataWidgetMapper. + New signal currentTextChanged() marked as NOTIFY method. + QtNetwork --------- * QHostAddress::isLoopback() API added. Returns true if the address is From 0ceb6541d7ae4958684422083e30fd9c222aa857 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 15 Oct 2012 13:44:40 +0200 Subject: [PATCH 040/134] Make table test use smart pointers for interfaces. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I9669da2ef398f12c4d6d584e7032dea13b148a81 Reviewed-by: Jan Arve Sæther --- .../qaccessibility/tst_qaccessibility.cpp | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 58ddf531c50..ab9473302a8 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -2570,44 +2570,38 @@ void tst_QAccessibility::tableTest() tableView->resize(600,600); tableView->show(); - QTest::qWait(1); // Need this for indexOfchild to work. - QCoreApplication::processEvents(); - QTest::qWait(100); + QTest::qWaitForWindowExposed(tableView); - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(tableView); - QCOMPARE(verifyHierarchy(iface), 0); + QAIPtr iface = QAIPtr(QAccessible::queryAccessibleInterface(tableView)); + QCOMPARE(verifyHierarchy(iface.data()), 0); - QCOMPARE((int)iface->role(), (int)QAccessible::Table); + QCOMPARE(iface->role(), QAccessible::Table); // header and 2 rows (the others are not expanded, thus not visible) QCOMPARE(iface->childCount(), 9+3+3+1); // cell+headers+topleft button - QAccessibleInterface *cornerButton = iface->child(0); + QAIPtr cornerButton(iface->child(0)); QVERIFY(cornerButton); - QCOMPARE(iface->indexOfChild(cornerButton), 0); + QCOMPARE(iface->indexOfChild(cornerButton.data()), 0); QCOMPARE(cornerButton->role(), QAccessible::Pane); - delete cornerButton; - QAccessibleInterface *child1 = iface->child(2); + QAIPtr child1(iface->child(2)); QVERIFY(child1); - QCOMPARE(iface->indexOfChild(child1), 2); + QCOMPARE(iface->indexOfChild(child1.data()), 2); QCOMPARE(child1->text(QAccessible::Name), QString("h2")); QCOMPARE(child1->role(), QAccessible::ColumnHeader); QVERIFY(!(child1->state().expanded)); - delete child1; - QAccessibleInterface *child2 = iface->child(10); + QAIPtr child2(iface->child(10)); QVERIFY(child2); - QCOMPARE(iface->indexOfChild(child2), 10); + QCOMPARE(iface->indexOfChild(child2.data()), 10); QCOMPARE(child2->text(QAccessible::Name), QString("1.1")); QAccessibleTableCellInterface *cell2Iface = child2->tableCellInterface(); QCOMPARE(cell2Iface->rowIndex(), 1); QCOMPARE(cell2Iface->columnIndex(), 1); - delete child2; - QAccessibleInterface *child3 = iface->child(11); - QCOMPARE(iface->indexOfChild(child3), 11); + QAIPtr child3(iface->child(11)); + QCOMPARE(iface->indexOfChild(child3.data()), 11); QCOMPARE(child3->text(QAccessible::Name), QString("1.2")); - delete child3; QTestAccessibility::clearEvents(); @@ -2621,23 +2615,21 @@ void tst_QAccessibility::tableTest() QCOMPARE(cell1->text(QAccessible::Name), QString("0.0")); QCOMPARE(iface->indexOfChild(cell1), 5); - QAccessibleInterface *cell2; - QVERIFY(cell2 = table2->cellAt(0,1)); + QAIPtr cell2(table2->cellAt(0,1)); + QVERIFY(cell2); QCOMPARE(cell2->text(QAccessible::Name), QString("0.1")); QCOMPARE(cell2->role(), QAccessible::Cell); QCOMPARE(cell2->tableCellInterface()->rowIndex(), 0); QCOMPARE(cell2->tableCellInterface()->columnIndex(), 1); - QCOMPARE(iface->indexOfChild(cell2), 6); - delete cell2; + QCOMPARE(iface->indexOfChild(cell2.data()), 6); - QAccessibleInterface *cell3; - QVERIFY(cell3 = table2->cellAt(1,2)); + QAIPtr cell3(table2->cellAt(1,2)); + QVERIFY(cell3); QCOMPARE(cell3->text(QAccessible::Name), QString("1.2")); QCOMPARE(cell3->role(), QAccessible::Cell); QCOMPARE(cell3->tableCellInterface()->rowIndex(), 1); QCOMPARE(cell3->tableCellInterface()->columnIndex(), 2); - QCOMPARE(iface->indexOfChild(cell3), 11); - delete cell3; + QCOMPARE(iface->indexOfChild(cell3.data()), 11); QCOMPARE(table2->columnDescription(0), QString("h1")); QCOMPARE(table2->columnDescription(1), QString("h2")); @@ -2646,8 +2638,6 @@ void tst_QAccessibility::tableTest() QCOMPARE(table2->rowDescription(1), QString("v2")); QCOMPARE(table2->rowDescription(2), QString("v3")); - delete iface; - delete tableView; QTestAccessibility::clearEvents(); From 596f23554ab82a87a05f9c5c7a6752448345a769 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 15 Oct 2012 14:22:25 +0200 Subject: [PATCH 041/134] Clean up index handling in itemviews accessibility. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icc017c7df9cb0dc4bf17e5168c1e3acda6af7523 Reviewed-by: Jan Arve Sæther --- src/plugins/accessible/widgets/itemviews.cpp | 30 ++++++---- .../qaccessibility/tst_qaccessibility.cpp | 60 ++++++++++++++----- 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/plugins/accessible/widgets/itemviews.cpp b/src/plugins/accessible/widgets/itemviews.cpp index 0aeff6e1a3b..301838997f5 100644 --- a/src/plugins/accessible/widgets/itemviews.cpp +++ b/src/plugins/accessible/widgets/itemviews.cpp @@ -79,8 +79,7 @@ int QAccessibleTable::logicalIndex(const QModelIndex &index) const return -1; int vHeader = verticalHeader() ? 1 : 0; int hHeader = horizontalHeader() ? 1 : 0; - // row * number columns + column + 1 for one based counting - return (index.row() + hHeader)*(index.model()->columnCount() + vHeader) + (index.column() + vHeader) + 1; + return (index.row() + hHeader)*(index.model()->columnCount() + vHeader) + (index.column() + vHeader); } QAccessibleInterface *QAccessibleTable::childFromLogical(int logicalIndex) const @@ -88,7 +87,6 @@ QAccessibleInterface *QAccessibleTable::childFromLogical(int logicalIndex) const if (!view()->model()) return 0; - logicalIndex--; // one based counting ftw int vHeader = verticalHeader() ? 1 : 0; int hHeader = horizontalHeader() ? 1 : 0; @@ -376,16 +374,20 @@ int QAccessibleTable::indexOfChild(const QAccessibleInterface *iface) const { if (!view()->model()) return -1; + QSharedPointer parent(iface->parent()); + if (parent->object() != view()) + return -1; + Q_ASSERT(iface->role() != QAccessible::TreeItem); // should be handled by tree class if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) { const QAccessibleTableCell* cell = static_cast(iface); - return logicalIndex(cell->m_index) - 1; + return logicalIndex(cell->m_index); } else if (iface->role() == QAccessible::ColumnHeader){ const QAccessibleTableHeaderCell* cell = static_cast(iface); return cell->index + (verticalHeader() ? 1 : 0); } else if (iface->role() == QAccessible::RowHeader){ const QAccessibleTableHeaderCell* cell = static_cast(iface); - return (cell->index+1) * (view()->model()->rowCount()+1); + return (cell->index + 1) * (view()->model()->rowCount() + 1); } else if (iface->role() == QAccessible::Pane) { return 0; // corner button } else { @@ -424,8 +426,7 @@ QAccessibleInterface *QAccessibleTable::parent() const QAccessibleInterface *QAccessibleTable::child(int index) const { - // Fixme: get rid of the +1 madness - return childFromLogical(index + 1); + return childFromLogical(index); } void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t) @@ -470,9 +471,8 @@ QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0); int column = index.column(); - int i = row * view()->model()->columnCount() + column + 1; - Q_ASSERT(i > view()->model()->columnCount()); - return child(i - 1); + int i = row * view()->model()->columnCount() + column; + return child(i); } int QAccessibleTree::childCount() const @@ -521,7 +521,11 @@ int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const { if (!view()->model()) return -1; - if (iface->role() == QAccessible::TreeItem) { + QSharedPointer parent(iface->parent()); + if (parent->object() != view()) + return -1; + + if (iface->role() == QAccessible::TreeItem) { const QAccessibleTableCell* cell = static_cast(iface); const QTreeView *treeView = qobject_cast(view()); Q_ASSERT(treeView); @@ -534,7 +538,7 @@ int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const return index; } else if (iface->role() == QAccessible::ColumnHeader){ const QAccessibleTableHeaderCell* cell = static_cast(iface); - //qDebug() << "QAccessibleTree::indexOfChild header " << cell->index << "is: " << cell->index + 1; + //qDebug() << "QAccessibleTree::indexOfChild header " << cell->index; return cell->index; } else { qWarning() << "WARNING QAccessibleTable::indexOfChild invalid child" @@ -846,7 +850,7 @@ void QAccessibleTableHeaderCell::setText(QAccessible::Text, const QString &) bool QAccessibleTableHeaderCell::isValid() const { - return view && view->model() && (index > 0) + return view && view->model() && (index >= 0) && ((orientation == Qt::Horizontal) ? (index < view->model()->columnCount()) : (index < view->model()->rowCount())); } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index ab9473302a8..80f52cbbff9 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -2543,13 +2543,27 @@ void tst_QAccessibility::treeTest() QVERIFY(!(cell2->state().expandable)); QCOMPARE(iface->indexOfChild(cell2), 10); + QPoint pos = treeView->mapToGlobal(QPoint(0,0)); + QModelIndex index = treeView->model()->index(0, 0, treeView->model()->index(1, 0)); + pos += treeView->visualRect(index).center(); + pos += QPoint(0, treeView->header()->height()); + QAIPtr childAt2(iface->childAt(pos.x(), pos.y())); + QVERIFY(childAt2); + QCOMPARE(childAt2->text(QAccessible::Name), QString("Klimt")); + QCOMPARE(table2->columnDescription(0), QString("Artist")); QCOMPARE(table2->columnDescription(1), QString("Work")); delete iface; + delete treeView; QTestAccessibility::clearEvents(); } +// The table used below is this: +// Button (0) | h1 (1) | h2 (2) | h3 (3) +// v1 (4) | 0.0 (5) | 1.0 (6) | 2.0 (7) +// v2 (8) | 0.1 (9) | 1.1 (10) | 2.1 (11) +// v3 (12) | 0.2 (13) | 1.2 (14) | 2.2 (15) void tst_QAccessibility::tableTest() { QTableWidget *tableView = new QTableWidget(3, 3); @@ -2584,24 +2598,38 @@ void tst_QAccessibility::tableTest() QCOMPARE(iface->indexOfChild(cornerButton.data()), 0); QCOMPARE(cornerButton->role(), QAccessible::Pane); - QAIPtr child1(iface->child(2)); - QVERIFY(child1); - QCOMPARE(iface->indexOfChild(child1.data()), 2); - QCOMPARE(child1->text(QAccessible::Name), QString("h2")); - QCOMPARE(child1->role(), QAccessible::ColumnHeader); - QVERIFY(!(child1->state().expanded)); + QAIPtr h2(iface->child(2)); + QVERIFY(h2); + QCOMPARE(iface->indexOfChild(h2.data()), 2); + QCOMPARE(h2->text(QAccessible::Name), QString("h2")); + QCOMPARE(h2->role(), QAccessible::ColumnHeader); + QVERIFY(!(h2->state().expanded)); - QAIPtr child2(iface->child(10)); - QVERIFY(child2); - QCOMPARE(iface->indexOfChild(child2.data()), 10); - QCOMPARE(child2->text(QAccessible::Name), QString("1.1")); - QAccessibleTableCellInterface *cell2Iface = child2->tableCellInterface(); - QCOMPARE(cell2Iface->rowIndex(), 1); - QCOMPARE(cell2Iface->columnIndex(), 1); + QAIPtr v3(iface->child(12)); + QVERIFY(v3); + QCOMPARE(iface->indexOfChild(v3.data()), 12); + QCOMPARE(v3->text(QAccessible::Name), QString("v3")); + QCOMPARE(v3->role(), QAccessible::RowHeader); + QVERIFY(!(v3->state().expanded)); + + + QAIPtr child10(iface->child(10)); + QVERIFY(child10); + QCOMPARE(iface->indexOfChild(child10.data()), 10); + QCOMPARE(child10->text(QAccessible::Name), QString("1.1")); + QAccessibleTableCellInterface *cell10Iface = child10->tableCellInterface(); + QCOMPARE(cell10Iface->rowIndex(), 1); + QCOMPARE(cell10Iface->columnIndex(), 1); + QPoint pos = tableView->mapToGlobal(QPoint(0,0)); + pos += tableView->visualRect(tableView->model()->index(1, 1)).center(); + pos += QPoint(tableView->verticalHeader()->width(), tableView->horizontalHeader()->height()); + QAIPtr childAt10(iface->childAt(pos.x(), pos.y())); + QCOMPARE(childAt10->text(QAccessible::Name), QString("1.1")); + + QAIPtr child11(iface->child(11)); + QCOMPARE(iface->indexOfChild(child11.data()), 11); + QCOMPARE(child11->text(QAccessible::Name), QString("1.2")); - QAIPtr child3(iface->child(11)); - QCOMPARE(iface->indexOfChild(child3.data()), 11); - QCOMPARE(child3->text(QAccessible::Name), QString("1.2")); QTestAccessibility::clearEvents(); From 8a0602873e4a224cdd3d835f3ab1b08dcc2ef246 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 16 Oct 2012 12:55:49 +0200 Subject: [PATCH 042/134] Doc fixes for qcoreapplication. Change-Id: I58806424b37ebf7bdf9b7f1ead9953b605332361 Reviewed-by: Jerome Pasion Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/kernel/qcoreapplication.cpp | 28 ++++++++++++++++++------- src/corelib/kernel/qcoreapplication.h | 6 +++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 8ff4aa7c545..590d1270943 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -577,8 +577,12 @@ void QCoreApplication::flush() \a argc must be greater than zero and \a argv must contain at least one valid character string. */ -QCoreApplication::QCoreApplication(int &argc, char **argv, int _internal) -: QObject(*new QCoreApplicationPrivate(argc, argv, _internal)) +QCoreApplication::QCoreApplication(int &argc, char **argv +#ifndef Q_QDOC + , int _internal +#endif + ) + : QObject(*new QCoreApplicationPrivate(argc, argv, _internal)) { init(); QCoreApplicationPrivate::eventDispatcher->startingUp(); @@ -698,7 +702,17 @@ bool QCoreApplication::testAttribute(Qt::ApplicationAttribute attribute) return QCoreApplicationPrivate::testAttribute(attribute); } -/*!/ + +/*! + \property QCoreApplication::quitLockEnabled + + Returns true if the use of the QEventLoopLocker feature can cause the + application to quit, otherwise returns false. + + \sa QEventLoopLocker +*/ + +/*! Returns true if the use of the QEventLoopLocker feature can cause the application to quit, otherwise returns false. @@ -2220,7 +2234,7 @@ void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filt } /*! - Removes an event filter object \a obj from this object. The + Removes an event \a filterObject from this object. The request is ignored if such an event filter has not been installed. All event filters for this object are automatically removed when @@ -2232,12 +2246,12 @@ void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filt \sa installNativeEventFilter() \since 5.0 */ -void QCoreApplication::removeNativeEventFilter(QAbstractNativeEventFilter *filterObj) +void QCoreApplication::removeNativeEventFilter(QAbstractNativeEventFilter *filterObject) { QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); - if (!filterObj || !eventDispatcher) + if (!filterObject || !eventDispatcher) return; - eventDispatcher->removeNativeEventFilter(filterObj); + eventDispatcher->removeNativeEventFilter(filterObject); } /*! diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 46eab4e7403..b65f0cd314d 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -85,7 +85,11 @@ public: GuiServer // # deprecated }; - QCoreApplication(int &argc, char **argv, int = ApplicationFlags); + QCoreApplication(int &argc, char **argv +#ifndef Q_QDOC + , int = ApplicationFlags +#endif + ); ~QCoreApplication(); From 31b4507cf46a4be8b15e52973cf132a51bf85870 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 18 Oct 2012 16:24:37 +0200 Subject: [PATCH 043/134] Be more careful about asserting in accessibility. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is possible to call the accessibility update for any widget, even if it doesn't implement the right interfaces. While that is bad, warning about it is better than asserting. Change-Id: I23c0c783083f73fb816d75b2c9b78efd603edcb6 Reviewed-by: Jan Arve Sæther --- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index f69e2365d81..79d732504aa 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -1023,7 +1023,11 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) case QAccessible::TextCaretMoved: { if (sendObject || sendObject_text_caret_moved) { QAIPointer iface = QAIPointer(event->accessibleInterface()); - Q_ASSERT(iface->textInterface()); + if (!iface->textInterface()) { + qWarning() << "Sending TextCaretMoved from object that does not implement text interface: " << iface << iface->object(); + return; + } + QString path = pathForInterface(iface); QDBusVariant cursorData; int pos = iface->textInterface()->cursorPosition(); From e6258e390a446d3b5af9eb0ad378d651c2a4053c Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 19 Oct 2012 11:13:09 +0200 Subject: [PATCH 044/134] Accessibility: make sure right objects are cached on linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch goes together with 730a5a994ff46055055c58b25bd059373dddb934 and is the second code path that deals with the hash of valid objects. Change-Id: Ia7b0995cb667cfce5f7697aa61856e44f745a932 Reviewed-by: Jan Arve Sæther --- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 79d732504aa..6926f546a24 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -1507,7 +1507,7 @@ QString AtSpiAdaptor::pathForObject(QObject *object) const qAtspiDebug() << "AtSpiAdaptor::pathForObject: warning: creating path with QAction as object."; } quintptr uintptr = reinterpret_cast(object); - if (!m_handledObjects.contains(uintptr)) + if (!m_handledObjects.contains(uintptr) || m_handledObjects.value(uintptr) == 0) m_handledObjects[uintptr] = QPointer(object); return QLatin1String(QSPI_OBJECT_PATH_PREFIX) + QString::number(uintptr); } From b36e254e4114119486e43e40f22c09490468192c Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 19 Oct 2012 15:08:42 +0200 Subject: [PATCH 045/134] Accessibility: remove redundant role function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The role is already set through the ctor, no need to explicitly do it again. Change-Id: I0027068c66b5771b628a9fe10fbfe929e7bf1554 Reviewed-by: Jan Arve Sæther --- src/plugins/accessible/widgets/qaccessiblewidgets.cpp | 5 ----- src/plugins/accessible/widgets/qaccessiblewidgets.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp index eac31b80688..9d0d3f01452 100644 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp +++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp @@ -592,11 +592,6 @@ int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const return -1; } -QAccessible::Role QAccessibleDockWidget::role() const -{ - return QAccessible::Window; -} - QRect QAccessibleDockWidget::rect() const { QRect rect; diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h index ec2583235f8..b309d59c54d 100644 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.h +++ b/src/plugins/accessible/widgets/qaccessiblewidgets.h @@ -275,7 +275,6 @@ public: int indexOfChild(const QAccessibleInterface *child) const; int childCount() const; QRect rect () const; - QAccessible::Role role() const; QDockWidget *dockWidget() const; }; From 47459d33500b757386573cf802c4aac9a6be8e7e Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Fri, 26 Oct 2012 20:58:33 +0800 Subject: [PATCH 046/134] Enable the "#include " camel-case header, for the QSql namespace The sync.profile Perl script will now generate the "QSql" header file during compilation. By removing the \inheaderfile command, the documentation will now display the namespace's own name as the header (i.e. "QSql" in this case). Previously, the only documented way to include the namespace was to include the whole module, which is expensive. This change also makes QSql consistent with other namespaces, such as QSsl and QAudio, which have their own dedicated camel-case headers. Part of the Header Consistency Project (http://lists.qt-project.org/pipermail/development/2012-October/007421.html) Change-Id: Ibb82d442956e767c13b82f1e552aabdf2e8ff110 Reviewed-by: Mark Brand --- src/sql/kernel/qsql.qdoc | 1 - sync.profile | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/kernel/qsql.qdoc b/src/sql/kernel/qsql.qdoc index 3b0e848af1f..b3afe82245e 100644 --- a/src/sql/kernel/qsql.qdoc +++ b/src/sql/kernel/qsql.qdoc @@ -31,7 +31,6 @@ \brief The QSql namespace contains miscellaneous identifiers used throughout the Qt SQL library. - \inheaderfile QtSql \ingroup database diff --git a/sync.profile b/sync.profile index e71ce10e7cc..e51e0aa0c22 100644 --- a/sync.profile +++ b/sync.profile @@ -30,6 +30,7 @@ "qevent.h" => "QtEvents", "qnamespace.h" => "Qt", "qnumeric.h" => "QtNumeric", + "qsql.h" => "QSql", "qssl.h" => "QSsl", "qtest.h" => "QTest", "qtconcurrentmap.h" => "QtConcurrentMap", From b626b98b9552b459919f90496e60931e9f2071f1 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Tue, 14 Aug 2012 12:47:48 +0200 Subject: [PATCH 047/134] Implement QAccessibleLineEdit::characterRect() It was probably not implemented because it needed to access private APIs. However, accessing those from this a11y plugin is unproblematic. Forward-ported from Qt 4.8 with change d2fb64d52fc6ec229d775f829a9a0cb3d251aad3 (and then slightly improved) Change-Id: Ifa2d48c152fd75fc1fff49a05369787a7db3b902 Reviewed-by: Frederik Gladhorn --- .../accessible/widgets/simplewidgets.cpp | 17 ++++++++++++++--- src/widgets/widgets/qlineedit.h | 1 + .../other/qaccessibility/tst_qaccessibility.cpp | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index bb90061a7ee..9bdb1decdee 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -672,10 +673,20 @@ int QAccessibleLineEdit::cursorPosition() const return lineEdit()->cursorPosition(); } -QRect QAccessibleLineEdit::characterRect(int /*offset*/) const +QRect QAccessibleLineEdit::characterRect(int offset) const { - // QLineEdit doesn't hand out character rects - return QRect(); + int x = lineEdit()->d_func()->control->cursorToX(offset); + int y; + lineEdit()->getTextMargins(0, &y, 0, 0); + QFontMetrics fm(lineEdit()->font()); + const QString ch = text(offset, offset + 1); + if (ch.isEmpty()) + return QRect(); + int w = fm.width(ch); + int h = fm.height(); + QRect r(x, y, w, h); + r.moveTo(lineEdit()->mapToGlobal(r.topLeft())); + return r; } int QAccessibleLineEdit::selectionCount() const diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 71ffbf2847c..f18fd4a34bd 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -225,6 +225,7 @@ public: private: friend class QAbstractSpinBox; + friend class QAccessibleLineEdit; #ifdef QT_KEYPAD_NAVIGATION friend class QDateTimeEdit; #endif diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 80f52cbbff9..1b8ac101bc5 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1906,6 +1906,22 @@ void tst_QAccessibility::lineEditTest() QTestAccessibility::clearEvents(); } + { + QLineEdit le(QStringLiteral("My characters have geometries."), toplevel); + // characterRect() + le.show(); + QTest::qWaitForWindowShown(&le); + QAIPtr iface(QAccessible::queryAccessibleInterface(&le)); + QAccessibleTextInterface* textIface = iface->textInterface(); + QVERIFY(textIface); + const QRect lineEditRect = iface->rect(); + // Only first 10 characters, check if they are within the bounds of line edit + for (int i = 0; i < 10; ++i) { + QVERIFY(lineEditRect.contains(textIface->characterRect(i))); + } + QTestAccessibility::clearEvents(); + } + { // Test events: cursor movement, selection, text changes QString text = "Hello, world"; From 8fedf683691d4ce6e1c1aea5dda3a4f16f29b635 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 26 Oct 2012 17:18:22 +0200 Subject: [PATCH 048/134] Fix qfile:invalidFile() test. The test expects 'fail:invalid' to be an invalid file, which it no longer is on Windows 7. It also assumes that f: is an invalid drive. Fix by picking a drive that does not exist. Task-number: QTBUG-27306 Change-Id: I9d9b36c50fc31d2561d3c4eec66f65d96084f0d7 Reviewed-by: Caroline Chao --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 37 ++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 1f2d4fe4f59..fe378b20957 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -1027,14 +1027,44 @@ void tst_QFile::ungetChar() QCOMPARE(buf[2], '4'); } +#ifdef Q_OS_WIN +QString driveLetters() +{ + wchar_t volumeName[MAX_PATH]; + wchar_t path[MAX_PATH]; + const HANDLE h = FindFirstVolumeW(volumeName, MAX_PATH); + if (h == INVALID_HANDLE_VALUE) + return QString(); + QString result; + do { + if (GetVolumePathNamesForVolumeNameW(volumeName, path, MAX_PATH, NULL)) { + if (path[1] == L':') + result.append(QChar(path[0])); + } + } while (FindNextVolumeW(h, volumeName, MAX_PATH)); + FindVolumeClose(h); + return result; +} + +static inline QChar invalidDriveLetter() +{ + const QString drives = driveLetters().toLower(); + for (char c = 'a'; c <= 'z'; ++c) + if (!drives.contains(QLatin1Char(c))) + return QLatin1Char(c); + Q_ASSERT(false); // All drive letters used?! + return QChar(); +} + +#endif // Q_OS_WIN + void tst_QFile::invalidFile_data() { QTest::addColumn("fileName"); #if !defined(Q_OS_WIN) QTest::newRow( "x11" ) << QString( "qwe//" ); #else - QTest::newRow( "colon1" ) << QString( "fail:invalid" ); - QTest::newRow( "colon2" ) << QString( "f:ail:invalid" ); + QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid"); QTest::newRow( "colon3" ) << QString( ":failinvalid" ); QTest::newRow( "forwardslash" ) << QString( "fail/invalid" ); QTest::newRow( "asterisk" ) << QString( "fail*invalid" ); @@ -1050,8 +1080,7 @@ void tst_QFile::invalidFile() { QFETCH( QString, fileName ); QFile f( fileName ); - QEXPECT_FAIL("colon1", "QTBUG-27306", Continue); - QVERIFY( !f.open( QIODevice::ReadWrite ) ); + QVERIFY2( !f.open( QIODevice::ReadWrite ), qPrintable(fileName) ); } void tst_QFile::createFile() From e880ff9cae5cfd215a9fea0bce27a8f3d2d227b0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 29 Oct 2012 12:18:11 +0100 Subject: [PATCH 049/134] List possible matches when specifying invalid test function. List functions matching the command line parameter instead of dumping all functions. Change-Id: Ic504587b1036f09702f47579f90406333c4efbeb Reviewed-by: Caroline Chao --- src/testlib/qtestcase.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index d302a77206c..6ff449fbcb1 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1203,12 +1203,15 @@ Q_TESTLIB_EXPORT bool printAvailableFunctions = false; Q_TESTLIB_EXPORT QStringList testFunctions; Q_TESTLIB_EXPORT QStringList testTags; -static void qPrintTestSlots(FILE *stream) +static void qPrintTestSlots(FILE *stream, const char *filter = 0) { for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) { QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i); - if (isValidSlot(sl)) - fprintf(stream, "%s\n", sl.methodSignature().constData()); + if (isValidSlot(sl)) { + const QByteArray signature = sl.methodSignature(); + if (!filter || QString::fromLatin1(signature).contains(QLatin1String(filter), Qt::CaseInsensitive)) + fprintf(stream, "%s\n", signature.constData()); + } } } @@ -1570,9 +1573,10 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) qsnprintf(buf + off, qMin(512 - off, 3), "()"); // append "()" int idx = QTest::currentTestObject->metaObject()->indexOfMethod(buf); if (idx < 0 || !isValidSlot(QTest::currentTestObject->metaObject()->method(idx))) { - fprintf(stderr, "Unknown testfunction: '%s'\n", buf); - fprintf(stderr, "Available testfunctions:\n"); - qPrintTestSlots(stderr); + fprintf(stderr, "Unknown test function: '%s'. Possible matches:\n", buf); + buf[off] = 0; + qPrintTestSlots(stderr, buf); + fprintf(stderr, "\n%s -functions\nlists all available test functions.\n", argv[0]); exit(1); } testFuncs[testFuncCount].set(idx, data); From 914e1f360868e844577dd98a179a7c8bc37bf272 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sat, 27 Oct 2012 16:45:32 +0200 Subject: [PATCH 050/134] Remove some dead code in switch statements Following the Code Style described in http://qt-project.org/wiki/Qt_Coding_Style#e289ee44592e9c32d4212069f0806daf There is no need for a 'break' after a 'return'. Change-Id: I1eca350391a7e4e14e504d60b24b69982cc5ac47 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmimedata.cpp | 3 --- src/corelib/tools/qregexp.cpp | 3 --- src/dbus/qdbusdemarshaller.cpp | 1 - src/gui/image/qimage.cpp | 10 ---------- src/gui/opengl/qopenglframebufferobject.cpp | 1 - src/gui/painting/qpathclipper.cpp | 1 - src/network/access/qhttpnetworkconnectionchannel.cpp | 1 - src/network/access/qhttpnetworkrequest.cpp | 9 --------- src/network/access/qnetworkrequest.cpp | 12 ------------ src/opengl/qglframebufferobject.cpp | 1 - src/widgets/itemviews/qcolumnview.cpp | 2 -- src/widgets/statemachine/qguistatemachine.cpp | 1 - src/widgets/styles/qcommonstyle.cpp | 1 - 13 files changed, 46 deletions(-) diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index f48d1c75763..bbc9577b8cf 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -192,13 +192,10 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty case QVariant::ByteArray: case QVariant::Color: return data.toByteArray(); - break; case QVariant::String: return data.toString().toUtf8(); - break; case QVariant::Url: return data.toUrl().toEncoded(); - break; case QVariant::List: { // has to be list of URLs QByteArray result; diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index e87e5efc1fb..7aea0837887 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -1324,14 +1324,11 @@ Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &pattern, QRegExp::Pat #ifndef QT_NO_REGEXP_WILDCARD case QRegExp::Wildcard: return wc2rx(pattern, false); - break; case QRegExp::WildcardUnix: return wc2rx(pattern, true); - break; #endif case QRegExp::FixedString: return QRegExp::escape(pattern); - break; case QRegExp::W3CXmlSchema11: default: return pattern; diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index c25e7a33ec5..31e3fe2bdbf 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -300,7 +300,6 @@ QVariant QDBusDemarshaller::toVariantInternal() // I hope you never dereference this pointer! return QVariant::fromValue(ptr); - break; }; } diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 25999b7d06a..9da360bc26f 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4915,43 +4915,33 @@ int QImage::metric(PaintDeviceMetric metric) const switch (metric) { case PdmWidth: return d->width; - break; case PdmHeight: return d->height; - break; case PdmWidthMM: return qRound(d->width * 1000 / d->dpmx); - break; case PdmHeightMM: return qRound(d->height * 1000 / d->dpmy); - break; case PdmNumColors: return d->colortable.size(); - break; case PdmDepth: return d->depth; - break; case PdmDpiX: return qRound(d->dpmx * 0.0254); - break; case PdmDpiY: return qRound(d->dpmy * 0.0254); - break; case PdmPhysicalDpiX: return qRound(d->dpmx * 0.0254); - break; case PdmPhysicalDpiY: return qRound(d->dpmy * 0.0254); - break; default: qWarning("QImage::metric(): Unhandled metric type %d", metric); diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index ef8e420c270..380ada37e02 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -349,7 +349,6 @@ bool QOpenGLFramebufferObjectPrivate::checkFramebufferStatus(QOpenGLContext *ctx case GL_NO_ERROR: case GL_FRAMEBUFFER_COMPLETE: return true; - break; case GL_FRAMEBUFFER_UNSUPPORTED: qDebug("QOpenGLFramebufferObject: Unsupported framebuffer format."); break; diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 8cf57a89879..4b532578329 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -1630,7 +1630,6 @@ QPainterPath QPathClipper::clip(Operation operation) result.addRect(subjectBounds); return result; } - break; case BoolAnd: return clipPath; case BoolOr: diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 51076c6c229..34496cb3802 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -296,7 +296,6 @@ bool QHttpNetworkConnectionChannel::sendRequest() // premature eof happened connection->d_func()->emitReplyError(socket, reply, QNetworkReply::UnknownNetworkError); return false; - break; } else if (readPointer == 0 || currentReadSize == 0) { // nothing to read currently, break the loop break; diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index e9a66287f9b..ef65efddca0 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -83,31 +83,22 @@ QByteArray QHttpNetworkRequestPrivate::methodName() const switch (operation) { case QHttpNetworkRequest::Get: return "GET"; - break; case QHttpNetworkRequest::Head: return "HEAD"; - break; case QHttpNetworkRequest::Post: return "POST"; - break; case QHttpNetworkRequest::Options: return "OPTIONS"; - break; case QHttpNetworkRequest::Put: return "PUT"; - break; case QHttpNetworkRequest::Delete: return "DELETE"; - break; case QHttpNetworkRequest::Trace: return "TRACE"; - break; case QHttpNetworkRequest::Connect: return "CONNECT"; - break; case QHttpNetworkRequest::Custom: return customVerb; - break; default: break; } diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 6d036ad4910..b7d8dbbb201 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -979,53 +979,41 @@ static int name_to_month(const char* month_str) switch (month_str[1]) { case 'a': return 1; - break; case 'u': switch (month_str[2] ) { case 'n': return 6; - break; case 'l': return 7; - break; } } break; case 'F': return 2; - break; case 'M': switch (month_str[2] ) { case 'r': return 3; - break; case 'y': return 5; - break; } break; case 'A': switch (month_str[1]) { case 'p': return 4; - break; case 'u': return 8; - break; } break; case 'O': return 10; - break; case 'S': return 9; - break; case 'N': return 11; - break; case 'D': return 12; - break; } return 0; diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 413c7f54105..a5c2d1c8b27 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -393,7 +393,6 @@ bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const case GL_NO_ERROR: case GL_FRAMEBUFFER_COMPLETE: return true; - break; case GL_FRAMEBUFFER_UNSUPPORTED: qDebug("QGLFramebufferObject: Unsupported framebuffer format."); break; diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index ec5f2d56557..a320e6134a9 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -365,14 +365,12 @@ QModelIndex QColumnView::moveCursor(CursorAction cursorAction, Qt::KeyboardModif return (current.parent()); else return current; - break; case MoveRight: if (model()->hasChildren(current)) return model()->index(0, 0, current); else return current.sibling(current.row() + 1, current.column()); - break; default: break; diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp index 98d40986345..fcb3a6df031 100644 --- a/src/widgets/statemachine/qguistatemachine.cpp +++ b/src/widgets/statemachine/qguistatemachine.cpp @@ -69,7 +69,6 @@ static QEvent *cloneEvent(QEvent *e) return new QEvent(*e); case QEvent::Leave: return new QEvent(*e); - break; case QEvent::Paint: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 990245a1132..99ef88af00c 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -2777,7 +2777,6 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, return widget->style()->subElementRect(QStyle::SE_FrameContents, opt, widget); else return subElementRect(QStyle::SE_FrameContents, opt, widget); - break; case QFrame::WinPanel: frameWidth = 2; From 328a9420d0e473a4adde9bcbad2bad1ecde7aba2 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sat, 27 Oct 2012 11:46:37 +0200 Subject: [PATCH 051/134] test: Update task number for QAccesibilityLinux autotest. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reference tasks with detailed information of failures rather than generic task for blacklisted tests. Task-number: QTBUG-27732 Change-Id: I0f0f500d255ea8748dd98d066deeaf1dfcdb7ec8 Reviewed-by: Frederik Gladhorn Reviewed-by: Jan Arve Sæther --- tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro index be6b537c0c2..a6fb145604f 100644 --- a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro +++ b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro @@ -1,7 +1,7 @@ CONFIG += testcase # This is temporary to start running the test as part of normal CI. -CONFIG += insignificant_test +CONFIG += insignificant_test # QTBUG-27732 TARGET = tst_qaccessibilitylinux From 9c0544f8848e3552c7c5ce79d8908d08d51a0f28 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 18 Oct 2012 10:24:28 +0200 Subject: [PATCH 052/134] Test: remove QSKIP in tst_QEventLoop::throwInExec() Instead omit the whole test when appropriate. Change-Id: I60c34b020f6e25e865bbe0182395d4fc6419f65e Reviewed-by: Sergio Ahumada Reviewed-by: Rohan McGovern Reviewed-by: Friedemann Kleint --- .../kernel/qeventloop/tst_qeventloop.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index 956a3e67aac..24649bf5875 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -183,7 +183,9 @@ private slots: // This test *must* run first. See the definition for why. void processEvents(); void exec(); +#if !defined(QT_NO_EXCEPTIONS) && !defined(Q_OS_WINCE_WM) void throwInExec(); +#endif void reexec(); void execAfterExit(); void wakeUp(); @@ -320,17 +322,15 @@ void tst_QEventLoop::exec() } } +#if !defined(QT_NO_EXCEPTIONS) && !defined(Q_OS_WINCE_WM) +// Exceptions need to be enabled for this test +// Q_OS_WINCE_WM case: this platform doesn't support propagating exceptions through the event loop +// Windows Mobile cannot handle cross library exceptions +// qobject.cpp will try to rethrow the exception after handling +// which causes gwes.exe to crash void tst_QEventLoop::throwInExec() { -#if defined(QT_NO_EXCEPTIONS) || defined(NO_EVENTLOOP_EXCEPTIONS) - QSKIP("Exceptions are disabled"); -#elif defined(Q_OS_WINCE_WM) - // Windows Mobile cannot handle cross library exceptions - // qobject.cpp will try to rethrow the exception after handling - // which causes gwes.exe to crash - QSKIP("This platform doesn't support propagating exceptions through the event loop"); -#else - // exceptions compiled in, runtime tests follow. +// exceptions compiled in, runtime tests follow. #if defined(Q_OS_LINUX) // C++ exceptions can't be passed through glib callbacks. Skip the test if // we're using the glib event loop. @@ -366,8 +366,8 @@ void tst_QEventLoop::throwInExec() } QCOMPARE(caughtExceptions, 2); } -#endif } +#endif void tst_QEventLoop::reexec() { From 2eefa819c4350a09994221f20168fc00be1d0910 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 13:56:49 +0200 Subject: [PATCH 053/134] Test: refactor tst_QProcess Remove QSKIP and instead omit the whole tests when appropriate. Remove QSKIP from crashTest, crashTest2 and exitStatus on Windows, the tests are now passing. Add a guard in testForwarding to check if QT_NO_PROCESS is defined. Change-Id: Icba4d773315e3bf87764a381742168b51cf169c0 Reviewed-by: J-P Nurmi --- .../io/qprocess/testForwarding/main.cpp | 3 +- .../auto/corelib/io/qprocess/tst_qprocess.cpp | 349 ++++++++---------- 2 files changed, 165 insertions(+), 187 deletions(-) diff --git a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp index ca0dc3986ab..126a63c19c8 100644 --- a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp +++ b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp @@ -43,6 +43,7 @@ int main() { +#ifndef QT_NO_PROCESS QProcess process; process.setProcessChannelMode(QProcess::ForwardedChannels); if (process.processChannelMode() != QProcess::ForwardedChannels) @@ -62,6 +63,6 @@ int main() process.closeWriteChannel(); process.waitForFinished(5000); - +#endif return 0; } diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 22c88ca1fa5..94ecffb1472 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -75,6 +75,8 @@ class tst_QProcess : public QObject public slots: void initTestCase(); + void cleanupTestCase(); + #ifndef QT_NO_PROCESS private slots: void getSetCheck(); @@ -84,27 +86,23 @@ private slots: void startDetached(); void crashTest(); void crashTest2(); +#ifndef Q_OS_WINCE void echoTest_data(); void echoTest(); void echoTest2(); -#if defined Q_OS_WIN +#ifdef Q_OS_WIN void echoTestGui(); void batFiles_data(); void batFiles(); #endif - void exitStatus_data(); - void exitStatus(); void loopBackTest(); void readTimeoutAndThenCrash(); - void waitForFinished(); void deadWhileReading(); void restartProcessDeadlock(); void closeWriteChannel(); void closeReadChannel(); void openModes(); void emitReadyReadOnlyWhenNewDataArrives(); - void hardExit(); - void softExit(); void softExitInSlots_data(); void softExitInSlots(); void mergedChannels(); @@ -112,25 +110,14 @@ private slots: void forwardedChannelsOutput(); void atEnd(); void atEnd2(); - void processInAThread(); - void processesInMultipleThreads(); void waitForFinishedWithTimeout(); void waitForReadyReadInAReadyReadSlot(); void waitForBytesWrittenInABytesWrittenSlot(); - void spaceArgsTest_data(); - void spaceArgsTest(); -#if defined(Q_OS_WIN) - void nativeArguments(); -#endif - void exitCodeTest(); void setEnvironment_data(); void setEnvironment(); void setProcessEnvironment_data(); void setProcessEnvironment(); - void systemEnvironment(); void spaceInName(); - void lockupsInStartDetached(); - void waitForReadyReadForNonexistantProcess(); void setStandardInputFile(); void setStandardOutputFile_data(); void setStandardOutputFile(); @@ -138,9 +125,29 @@ private slots: void setStandardOutputProcess(); void removeFileWhileProcessIsRunning(); void fileWriterProcess(); - void detachedWorkingDirectoryAndPid(); void switchReadChannels(); +#ifdef Q_OS_WIN void setWorkingDirectory(); +#endif // Q_OS_WIN +#endif // not Q_OS_WINCE + + void exitStatus_data(); + void exitStatus(); + void waitForFinished(); + void hardExit(); + void softExit(); + void processInAThread(); + void processesInMultipleThreads(); + void spaceArgsTest_data(); + void spaceArgsTest(); +#if defined(Q_OS_WIN) + void nativeArguments(); +#endif + void exitCodeTest(); + void systemEnvironment(); + void lockupsInStartDetached(); + void waitForReadyReadForNonexistantProcess(); + void detachedWorkingDirectoryAndPid(); void startFinishStartFinish(); void invalidProgramString_data(); void invalidProgramString(); @@ -155,14 +162,16 @@ private slots: protected slots: void readFromProcess(); void exitLoopSlot(); +#ifndef Q_OS_WINCE void restartProcess(); void waitForReadyReadInAReadyReadSlotSlot(); void waitForBytesWrittenInABytesWrittenSlotSlot(); +#endif private: QProcess *process; qint64 bytesAvailable; -#endif +#endif //QT_NO_PROCESS }; void tst_QProcess::initTestCase() @@ -176,6 +185,13 @@ void tst_QProcess::initTestCase() #endif } +void tst_QProcess::cleanupTestCase() +{ +#ifdef QT_NO_PROCESS + QSKIP("This test requires QProcess support"); +#endif +} + #ifndef QT_NO_PROCESS // Testing get/set functions @@ -299,9 +315,6 @@ void tst_QProcess::readFromProcess() void tst_QProcess::crashTest() { qRegisterMetaType("QProcess::ProcessState"); -#ifdef Q_OS_WIN - QSKIP("This test opens a crash dialog on Windows"); -#endif process = new QProcess; QSignalSpy stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState))); QVERIFY(stateSpy.isValid()); @@ -339,9 +352,6 @@ void tst_QProcess::crashTest() //----------------------------------------------------------------------------- void tst_QProcess::crashTest2() { -#ifdef Q_OS_WIN - QSKIP("This test opens a crash dialog on Windows"); -#endif process = new QProcess; process->start("testProcessCrash/testProcessCrash"); QVERIFY(process->waitForStarted(5000)); @@ -373,6 +383,8 @@ void tst_QProcess::crashTest2() process = 0; } +#ifndef Q_OS_WINCE +//Reading and writing to a process is not supported on Qt/CE //----------------------------------------------------------------------------- void tst_QProcess::echoTest_data() { @@ -389,12 +401,9 @@ void tst_QProcess::echoTest_data() } //----------------------------------------------------------------------------- + void tst_QProcess::echoTest() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - QFETCH(QByteArray, input); process = new QProcess; @@ -435,6 +444,7 @@ void tst_QProcess::echoTest() delete process; process = 0; } +#endif //----------------------------------------------------------------------------- void tst_QProcess::exitLoopSlot() @@ -443,11 +453,11 @@ void tst_QProcess::exitLoopSlot() } //----------------------------------------------------------------------------- + +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::echoTest2() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif process = new QProcess; connect(process, SIGNAL(readyRead()), this, SLOT(exitLoopSlot())); @@ -491,15 +501,14 @@ void tst_QProcess::echoTest2() delete process; process = 0; } +#endif -#if defined Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +//Batch files are not supported on Winfows CE +// Reading and writing to a process is not supported on Qt/CE //----------------------------------------------------------------------------- void tst_QProcess::echoTestGui() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - QProcess process; process.start("testProcessEchoGui/testProcessEchoGui"); @@ -513,8 +522,11 @@ void tst_QProcess::echoTestGui() QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello")); QCOMPARE(process.readAllStandardError(), QByteArray("Hello")); } +#endif // !Q_OS_WINCE && Q_OS_WIN //----------------------------------------------------------------------------- +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +//Batch files are not supported on Winfows CE void tst_QProcess::batFiles_data() { QTest::addColumn("batFile"); @@ -526,9 +538,6 @@ void tst_QProcess::batFiles_data() void tst_QProcess::batFiles() { -#if defined(Q_OS_WINCE) - QSKIP("Batch files are not supported on Windows CE"); -#endif QFETCH(QString, batFile); QFETCH(QByteArray, output); @@ -542,8 +551,7 @@ void tst_QProcess::batFiles() QVERIFY(proc.readAll().startsWith(output)); } - -#endif +#endif // !Q_OS_WINCE && Q_OS_WIN //----------------------------------------------------------------------------- void tst_QProcess::exitStatus_data() @@ -576,11 +584,6 @@ void tst_QProcess::exitStatus() QFETCH(QStringList, processList); QFETCH(QList, exitStatus); -#ifdef Q_OS_WIN - if (exitStatus.contains(QProcess::CrashExit)) - QSKIP("This test opens a crash dialog on Windows"); -#endif - QCOMPARE(exitStatus.count(), processList.count()); for (int i = 0; i < processList.count(); ++i) { process->start(processList.at(i)); @@ -594,11 +597,10 @@ void tst_QProcess::exitStatus() process = 0; } //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::loopBackTest() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif process = new QProcess; process->start("testProcessEcho/testProcessEcho"); @@ -618,13 +620,13 @@ void tst_QProcess::loopBackTest() delete process; process = 0; } +#endif //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::readTimeoutAndThenCrash() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif process = new QProcess; process->start("testProcessEcho/testProcessEcho"); @@ -652,6 +654,7 @@ void tst_QProcess::readTimeoutAndThenCrash() delete process; process = 0; } +#endif void tst_QProcess::waitForFinished() { @@ -677,12 +680,10 @@ void tst_QProcess::waitForFinished() QCOMPARE(process.error(), QProcess::FailedToStart); } +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::deadWhileReading() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - QProcess process; process.start("testProcessDeadWhileReading/testProcessDeadWhileReading"); @@ -696,13 +697,13 @@ void tst_QProcess::deadWhileReading() QCOMPARE(output.count("\n"), 10*1024); process.waitForFinished(); } +#endif //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::restartProcessDeadlock() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif // The purpose of this test is to detect whether restarting a // process in the finished() connected slot causes a deadlock @@ -726,14 +727,13 @@ void tst_QProcess::restartProcess() { process->start("testProcessEcho/testProcessEcho"); } - -//----------------------------------------------------------------------------- -void tst_QProcess::closeWriteChannel() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::closeWriteChannel() +{ QProcess more; more.start("testProcessEOF/testProcessEOF"); @@ -755,14 +755,13 @@ void tst_QProcess::closeWriteChannel() more.write("q"); QVERIFY(more.waitForFinished(5000)); } - -//----------------------------------------------------------------------------- -void tst_QProcess::closeReadChannel() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE" +void tst_QProcess::closeReadChannel() +{ for (int i = 0; i < 10; ++i) { QProcess::ProcessChannel channel1 = QProcess::StandardOutput; QProcess::ProcessChannel channel2 = QProcess::StandardError; @@ -788,14 +787,13 @@ void tst_QProcess::closeReadChannel() QVERIFY(proc.waitForFinished(5000)); } } - -//----------------------------------------------------------------------------- -void tst_QProcess::openModes() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::openModes() +{ QProcess proc; QVERIFY(!proc.isOpen()); QVERIFY(proc.openMode() == QProcess::NotOpen); @@ -834,13 +832,13 @@ void tst_QProcess::openModes() QVERIFY(!proc.isWritable()); QCOMPARE(proc.state(), QProcess::NotRunning); } +#endif //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif QProcess proc; connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot())); @@ -870,6 +868,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() proc.write("", 1); QVERIFY(proc.waitForFinished(5000)); } +#endif //----------------------------------------------------------------------------- void tst_QProcess::hardExit() @@ -914,6 +913,8 @@ void tst_QProcess::softExit() QCOMPARE(int(proc.error()), int(QProcess::UnknownError)); } +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE class SoftExitProcess : public QProcess { Q_OBJECT @@ -1011,14 +1012,10 @@ void tst_QProcess::softExitInSlots_data() #endif QTest::newRow("console app") << "testProcessEcho2/testProcessEcho2"; } - //----------------------------------------------------------------------------- + void tst_QProcess::softExitInSlots() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - QFETCH(QString, appName); for (int i = 0; i < 5; ++i) { @@ -1029,14 +1026,13 @@ void tst_QProcess::softExitInSlots() QCOMPARE(proc.state(), QProcess::NotRunning); } } - -//----------------------------------------------------------------------------- -void tst_QProcess::mergedChannels() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::mergedChannels() +{ QProcess process; process.setReadChannelMode(QProcess::MergedChannels); QCOMPARE(process.readChannelMode(), QProcess::MergedChannels); @@ -1055,14 +1051,13 @@ void tst_QProcess::mergedChannels() process.closeWriteChannel(); QVERIFY(process.waitForFinished(5000)); } - -//----------------------------------------------------------------------------- -void tst_QProcess::forwardedChannels() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::forwardedChannels() +{ QProcess process; process.setReadChannelMode(QProcess::ForwardedChannels); QCOMPARE(process.readChannelMode(), QProcess::ForwardedChannels); @@ -1077,13 +1072,12 @@ void tst_QProcess::forwardedChannels() process.closeWriteChannel(); QVERIFY(process.waitForFinished(5000)); } - -void tst_QProcess::forwardedChannelsOutput() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::forwardedChannelsOutput() +{ QProcess process; process.start("testForwarding/testForwarding"); QVERIFY(process.waitForStarted(5000)); @@ -1093,14 +1087,13 @@ void tst_QProcess::forwardedChannelsOutput() QVERIFY(!data.isEmpty()); QVERIFY(data.contains("forwarded")); } - -//----------------------------------------------------------------------------- -void tst_QProcess::atEnd() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::atEnd() +{ QProcess process; process.start("testProcessEcho/testProcessEcho"); @@ -1118,6 +1111,7 @@ void tst_QProcess::atEnd() process.write("", 1); QVERIFY(process.waitForFinished(5000)); } +#endif class TestThread : public QThread { @@ -1190,12 +1184,10 @@ void tst_QProcess::processesInMultipleThreads() } //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::waitForFinishedWithTimeout() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - process = new QProcess(this); process->start("testProcessEcho/testProcessEcho"); @@ -1210,14 +1202,13 @@ void tst_QProcess::waitForFinishedWithTimeout() delete process; process = 0; } - -//----------------------------------------------------------------------------- -void tst_QProcess::waitForReadyReadInAReadyReadSlot() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::waitForReadyReadInAReadyReadSlot() +{ process = new QProcess(this); connect(process, SIGNAL(readyRead()), this, SLOT(waitForReadyReadInAReadyReadSlotSlot())); connect(process, SIGNAL(finished(int)), this, SLOT(exitLoopSlot())); @@ -1240,27 +1231,25 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot() delete process; process = 0; } - -//----------------------------------------------------------------------------- -void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot() +{ bytesAvailable = process->bytesAvailable(); process->write("bar", 4); QVERIFY(process->waitForReadyRead(5000)); QTestEventLoop::instance().exitLoop(); } - -//----------------------------------------------------------------------------- -void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot() +{ process = new QProcess(this); connect(process, SIGNAL(bytesWritten(qint64)), this, SLOT(waitForBytesWrittenInABytesWrittenSlotSlot())); bytesAvailable = 0; @@ -1282,19 +1271,18 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot() delete process; process = 0; } - -//----------------------------------------------------------------------------- -void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot() +{ process->write("b"); QVERIFY(process->waitForBytesWritten(5000)); QTestEventLoop::instance().exitLoop(); } - +#endif //----------------------------------------------------------------------------- void tst_QProcess::spaceArgsTest_data() { @@ -1604,12 +1592,10 @@ void tst_QProcess::failToStartWithEventLoop() } //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::removeFileWhileProcessIsRunning() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - QFile file("removeFile.txt"); QVERIFY(file.open(QFile::WriteOnly)); @@ -1623,8 +1609,10 @@ void tst_QProcess::removeFileWhileProcessIsRunning() process.write("", 1); QVERIFY(process.waitForFinished(5000)); } - +#endif //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// OS doesn't support environment variables void tst_QProcess::setEnvironment_data() { QTest::addColumn("name"); @@ -1644,10 +1632,6 @@ void tst_QProcess::setEnvironment_data() void tst_QProcess::setEnvironment() { -#if defined (Q_OS_WINCE) - QSKIP("OS doesn't support environment variables"); -#endif - // make sure our environment variables are correct QVERIFY(qgetenv("tst_QProcess").isEmpty()); QVERIFY(!qgetenv("PATH").isEmpty()); @@ -1703,8 +1687,10 @@ void tst_QProcess::setEnvironment() QCOMPARE(process.readAll(), value.toLocal8Bit()); } } - +#endif //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// OS doesn't support environment variables void tst_QProcess::setProcessEnvironment_data() { setEnvironment_data(); @@ -1712,10 +1698,6 @@ void tst_QProcess::setProcessEnvironment_data() void tst_QProcess::setProcessEnvironment() { -#if defined (Q_OS_WINCE) - QSKIP("OS doesn't support environment variables"); -#endif - // make sure our environment variables are correct QVERIFY(qgetenv("tst_QProcess").isEmpty()); QVERIFY(!qgetenv("PATH").isEmpty()); @@ -1746,6 +1728,7 @@ void tst_QProcess::setProcessEnvironment() QCOMPARE(process.readAll(), value.toLocal8Bit()); } } +#endif //----------------------------------------------------------------------------- void tst_QProcess::systemEnvironment() { @@ -1763,17 +1746,17 @@ void tst_QProcess::systemEnvironment() } //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::spaceInName() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif QProcess process; process.start("test Space In Name/testSpaceInName", QStringList()); QVERIFY(process.waitForStarted()); process.write("", 1); QVERIFY(process.waitForFinished()); } +#endif //----------------------------------------------------------------------------- void tst_QProcess::lockupsInStartDetached() @@ -1790,12 +1773,10 @@ void tst_QProcess::lockupsInStartDetached() } //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::atEnd2() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - QProcess process; process.start("testProcessEcho/testProcessEcho"); @@ -1808,6 +1789,7 @@ void tst_QProcess::atEnd2() } QCOMPARE(lines.size(), 7); } +#endif //----------------------------------------------------------------------------- void tst_QProcess::waitForReadyReadForNonexistantProcess() @@ -1835,12 +1817,10 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() } //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::setStandardInputFile() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - static const char data[] = "A bunch\1of\2data\3\4\5\6\7..."; QProcess process; QFile file("data"); @@ -1857,8 +1837,11 @@ void tst_QProcess::setStandardInputFile() QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0 QVERIFY(all == data); } +#endif //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::setStandardOutputFile_data() { QTest::addColumn("channelToTest"); @@ -1889,10 +1872,6 @@ void tst_QProcess::setStandardOutputFile_data() void tst_QProcess::setStandardOutputFile() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - static const char data[] = "Original data. "; static const char testdata[] = "Test data."; @@ -1939,8 +1918,11 @@ void tst_QProcess::setStandardOutputFile() QCOMPARE(all.size(), expectedsize); } +#endif //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::setStandardOutputProcess_data() { QTest::addColumn("merged"); @@ -1950,9 +1932,6 @@ void tst_QProcess::setStandardOutputProcess_data() void tst_QProcess::setStandardOutputProcess() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif QProcess source; QProcess sink; @@ -1976,14 +1955,13 @@ void tst_QProcess::setStandardOutputProcess() else QCOMPARE(all, QByteArray("HHeelllloo,, WWoorrlldd")); } - -//----------------------------------------------------------------------------- -void tst_QProcess::fileWriterProcess() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); #endif +//----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::fileWriterProcess() +{ QString stdinStr; for (int i = 0; i < 5000; ++i) stdinStr += QString::fromLatin1("%1 -- testing testing 1 2 3\n").arg(i); @@ -2005,6 +1983,7 @@ void tst_QProcess::fileWriterProcess() QCOMPARE(QFile("fileWriterProcess.txt").size(), qint64(stdinStr.size())); } while (stopWatch.elapsed() < 3000); } +#endif //----------------------------------------------------------------------------- void tst_QProcess::detachedWorkingDirectoryAndPid() @@ -2051,11 +2030,10 @@ void tst_QProcess::detachedWorkingDirectoryAndPid() } //----------------------------------------------------------------------------- +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE void tst_QProcess::switchReadChannels() { -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif const char data[] = "ABCD"; QProcess process; @@ -2080,16 +2058,14 @@ void tst_QProcess::switchReadChannels() process.setReadChannel(QProcess::StandardOutput); QCOMPARE(process.read(1), QByteArray("D")); } +#endif //----------------------------------------------------------------------------- +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +// Q_OS_WIN - setWorkingDirectory will chdir before starting the process on unices +// Windows CE does not support working directory logic void tst_QProcess::setWorkingDirectory() { -#ifdef Q_OS_WINCE - QSKIP("Windows CE does not support working directory logic"); -#endif -#ifndef Q_OS_WIN - QSKIP("setWorkingDirectory will chdir before starting the process on unices"); -#endif process = new QProcess; process->setWorkingDirectory("test"); process->start("testSetWorkingDirectory/testSetWorkingDirectory"); @@ -2101,6 +2077,7 @@ void tst_QProcess::setWorkingDirectory() delete process; process = 0; } +#endif //----------------------------------------------------------------------------- void tst_QProcess::startFinishStartFinish() @@ -2173,7 +2150,7 @@ void tst_QProcess::onlyOneStartedSignal() QCOMPARE(spyFinished.count(), 1); } -#endif +#endif //QT_NO_PROCESS QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" From 63e451194e9f736fe4e35abd6a2a68c507ec9f5f Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 27 Oct 2012 14:52:42 +0300 Subject: [PATCH 054/134] Fix build on MinGW after 0f14ea3f3a05ef785b44fa610bf90ff3b5ba7beb Also generalize set _WIN32_WINNT to 0x0501 and _WIN32_IE to 0x0501 globally, as it is out minimal requirement these days. Change-Id: I8ca9102d49c37f908fd8ac032f707f8fe4fdcb22 Reviewed-by: Friedemann Kleint --- src/corelib/global/qt_windows.h | 13 ++++++++++--- src/plugins/platforms/windows/qwindowsdrag.cpp | 3 --- src/widgets/itemviews/qfileiconprovider.cpp | 4 ---- src/widgets/util/qsystemtrayicon_win.cpp | 14 ++++++++++---- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h index 4bd8d60754a..00a511a96f8 100644 --- a/src/corelib/global/qt_windows.h +++ b/src/corelib/global/qt_windows.h @@ -46,17 +46,17 @@ // Borland's windows.h does not set these correctly, resulting in // unusable WinSDK standard dialogs #ifndef WINVER -#define WINVER 0x400 +# define WINVER 0x0501 #endif #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x400 +# define _WIN32_WINNT 0x0501 #endif #endif #if defined(Q_CC_MINGW) // mingw's windows.h does not set _WIN32_WINNT, resulting breaking compilation #ifndef WINVER -#define WINVER 0x500 +# define WINVER 0x501 #endif #endif @@ -65,6 +65,13 @@ #endif #include +#if defined(_WIN32_IE) && _WIN32_IE < 0x0501 +# undef _WIN32_IE +#endif +#if !defined(_WIN32_IE) +# define _WIN32_IE 0x0501 +#endif + #ifdef _WIN32_WCE #include #endif diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index a0434fb6f39..805046c7154 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -718,9 +718,6 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, return NOERROR; } -#if defined(Q_CC_MINGW) && !defined(_WIN32_IE) -# define _WIN32_IE 0x0501 -#endif /*! \class QWindowsDrag diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index 70750c60068..d073867dbb4 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -53,10 +53,6 @@ #include #if defined(Q_OS_WIN) -#if defined(_WIN32_IE) -# undef _WIN32_IE -#endif -# define _WIN32_IE 0x0500 # include # include # include diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index 108e65a2d1b..896d5c22131 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -42,12 +42,18 @@ #include "qsystemtrayicon_p.h" #ifndef QT_NO_SYSTEMTRAYICON -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600 +# undef _WIN32_WINNT +#endif +#if !defined(_WIN32_WINNT) +# define _WIN32_WINNT 0x0600 #endif -#ifndef _WIN32_IE -#define _WIN32_IE 0x600 +#if defined(_WIN32_IE) && _WIN32_IE < 0x0600 +# undef _WIN32_IE +#endif +#if !defined(_WIN32_IE) +# define _WIN32_IE 0x0600 //required for NOTIFYICONDATA_V2_SIZE #endif #include From c360fbcd6c9276b8a3fa8a200fa489b7b69e3aaa Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Mon, 22 Oct 2012 13:48:59 +0200 Subject: [PATCH 055/134] Do the actual removal of the Soft Keys API and related code In addition to the actual removal of the softkeys API in QAction, this commit removes some enums related to the softkeys feature: Qt::WA_MergeSoftkeys Qt::WA_MergeSoftkeysRecursively It also removes some "zombie" enums: Qt::WindowSoftkeysVisibleHint = 0x40000000, Qt::WindowSoftkeysRespondHint = 0x80000000, (The only implementation that used these were removed when qapplication_s60.cpp and qwidget_s60.cpp were removed.) Change-Id: Ib6fc6d543def4757383d5f19256199d9d190c614 Reviewed-by: Lars Knoll Reviewed-by: Janne Anttila Reviewed-by: J-P Nurmi --- dist/changes-5.0.0 | 9 + examples/widgets/widgets/softkeys/main.cpp | 50 ---- .../widgets/widgets/softkeys/softkeys.cpp | 188 ------------ .../widgets/widgets/softkeys/softkeys.desktop | 11 - examples/widgets/widgets/softkeys/softkeys.h | 88 ------ .../widgets/widgets/softkeys/softkeys.pro | 13 - examples/widgets/widgets/wiggly/dialog.cpp | 11 - src/corelib/global/qfeatures.h | 5 - src/corelib/global/qfeatures.txt | 7 - src/corelib/global/qnamespace.h | 5 - src/corelib/global/qnamespace.qdoc | 19 -- src/corelib/kernel/qcoreevent.cpp | 1 - src/corelib/kernel/qcoreevent.h | 2 - src/widgets/dialogs/qdialog.cpp | 4 +- src/widgets/dialogs/qerrormessage.cpp | 16 -- src/widgets/dialogs/qprogressdialog.cpp | 22 -- src/widgets/dialogs/qwizard.cpp | 56 +--- src/widgets/itemviews/qabstractitemview.cpp | 29 -- src/widgets/itemviews/qabstractitemview_p.h | 4 - src/widgets/kernel/kernel.pri | 3 - src/widgets/kernel/qaction.cpp | 51 +--- src/widgets/kernel/qaction.h | 14 - src/widgets/kernel/qaction_p.h | 4 - src/widgets/kernel/qapplication.cpp | 3 - src/widgets/kernel/qsoftkeymanager.cpp | 270 ------------------ src/widgets/kernel/qsoftkeymanager_common_p.h | 85 ------ src/widgets/kernel/qsoftkeymanager_p.h | 112 -------- src/widgets/kernel/qwidget.cpp | 37 --- src/widgets/statemachine/qguistatemachine.cpp | 3 - src/widgets/widgets/qcombobox.cpp | 13 - src/widgets/widgets/qcombobox_p.h | 4 - src/widgets/widgets/qdialogbuttonbox.cpp | 134 --------- src/widgets/widgets/qmenu.cpp | 23 -- src/widgets/widgets/qmenubar.cpp | 12 - src/widgets/widgets/qmenubar_p.h | 3 - .../kernel/qactiongroup/tst_qactiongroup.cpp | 14 +- .../qdialogbuttonbox/tst_qdialogbuttonbox.cpp | 48 ---- .../widgets/qmainwindow/tst_qmainwindow.cpp | 34 +-- .../auto/widgets/widgets/qmenu/tst_qmenu.cpp | 17 +- 39 files changed, 31 insertions(+), 1393 deletions(-) delete mode 100644 examples/widgets/widgets/softkeys/main.cpp delete mode 100644 examples/widgets/widgets/softkeys/softkeys.cpp delete mode 100644 examples/widgets/widgets/softkeys/softkeys.desktop delete mode 100644 examples/widgets/widgets/softkeys/softkeys.h delete mode 100644 examples/widgets/widgets/softkeys/softkeys.pro delete mode 100644 src/widgets/kernel/qsoftkeymanager.cpp delete mode 100644 src/widgets/kernel/qsoftkeymanager_common_p.h delete mode 100644 src/widgets/kernel/qsoftkeymanager_p.h diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index e41fc5d3934..b54ab54b0f8 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -481,6 +481,15 @@ QtCore - StartWord/EndWord enum values has been logically replaced with StartOfItem/EndOfItem ones to mention they are not about the word boundaries only. +* Softkeys API was removed. The following functions and enums were removed: + - QAction::setSoftKeyRole() + - QAction::softKeyRole() + - QAction::SoftKeyRole + - Qt::WA_MergeSoftkeys + - Qt::WA_MergeSoftkeysRecursively + - Qt::WindowSoftkeysVisibleHint + - Qt::WindowSoftkeysRespondHint + QtGui ----- * Accessibility has been refactored. The hierachy of accessible objects is implemented via diff --git a/examples/widgets/widgets/softkeys/main.cpp b/examples/widgets/widgets/softkeys/main.cpp deleted file mode 100644 index 566a70ae6fc..00000000000 --- a/examples/widgets/widgets/softkeys/main.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "softkeys.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow mw; - mw.showMaximized(); - return app.exec(); -} diff --git a/examples/widgets/widgets/softkeys/softkeys.cpp b/examples/widgets/widgets/softkeys/softkeys.cpp deleted file mode 100644 index d75fd232b42..00000000000 --- a/examples/widgets/widgets/softkeys/softkeys.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "softkeys.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - central = new QWidget(this); - central->setContextMenuPolicy(Qt::NoContextMenu); // explicitly forbid usage of context menu so actions item is not shown menu - setCentralWidget(central); - - // Create text editor and set softkeys to it - textEditor= new QTextEdit(tr("Navigate in UI to see context sensitive softkeys in action"), this); - QAction* clear = new QAction(tr("Clear"), this); - clear->setSoftKeyRole(QAction::NegativeSoftKey); - - textEditor->addAction(clear); - - ok = new QAction(tr("Ok"), this); - ok->setSoftKeyRole(QAction::PositiveSoftKey); - connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); - - cancel = new QAction(tr("Cancel"), this); - cancel->setSoftKeyRole(QAction::NegativeSoftKey); - connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); - - infoLabel = new QLabel(tr(""), this); - infoLabel->setContextMenuPolicy(Qt::NoContextMenu); - - toggleButton = new QPushButton(tr("Custom"), this); - toggleButton->setContextMenuPolicy(Qt::NoContextMenu); - toggleButton->setCheckable(true); - - modeButton = new QPushButton(tr("Loop SK window type"), this); - modeButton->setContextMenuPolicy(Qt::NoContextMenu); - - modeLabel = new QLabel(tr("Normal maximized"), this); - modeLabel->setContextMenuPolicy(Qt::NoContextMenu); - - pushButton = new QPushButton(tr("File Dialog"), this); - pushButton->setContextMenuPolicy(Qt::NoContextMenu); - - QComboBox* comboBox = new QComboBox(this); - comboBox->setContextMenuPolicy(Qt::NoContextMenu); - comboBox->insertItems(0, QStringList() - << QApplication::translate("MainWindow", "Selection1", 0, QApplication::UnicodeUTF8) - << QApplication::translate("MainWindow", "Selection2", 0, QApplication::UnicodeUTF8) - << QApplication::translate("MainWindow", "Selection3", 0, QApplication::UnicodeUTF8) - ); - - layout = new QGridLayout; - layout->addWidget(textEditor, 0, 0, 1, 2); - layout->addWidget(infoLabel, 1, 0, 1, 2); - layout->addWidget(toggleButton, 2, 0); - layout->addWidget(pushButton, 2, 1); - layout->addWidget(comboBox, 3, 0, 1, 2); - layout->addWidget(modeButton, 4, 0, 1, 2); - layout->addWidget(modeLabel, 5, 0, 1, 2); - central->setLayout(layout); - - fileMenu = menuBar()->addMenu(tr("&File")); - exit = new QAction(tr("&Exit"), this); - fileMenu->addAction(exit); - - connect(clear, SIGNAL(triggered()), this, SLOT(clearTextEditor())); - connect(pushButton, SIGNAL(clicked()), this, SLOT(openDialog())); - connect(exit, SIGNAL(triggered()), this, SLOT(exitApplication())); - connect(toggleButton, SIGNAL(clicked()), this, SLOT(setCustomSoftKeys())); - connect(modeButton, SIGNAL(clicked()), this, SLOT(setMode())); - pushButton->setFocus(); -} - -MainWindow::~MainWindow() -{ -} - -void MainWindow::clearTextEditor() -{ - textEditor->setText(tr("")); -} - -void MainWindow::openDialog() -{ - QFileDialog::getOpenFileName(this); -} - -void MainWindow::addSoftKeys() -{ - addAction(ok); - addAction(cancel); -} - -void MainWindow::setCustomSoftKeys() -{ - if (toggleButton->isChecked()) { - infoLabel->setText(tr("Custom softkeys set")); - addSoftKeys(); - } - else { - infoLabel->setText(tr("Custom softkeys removed")); - removeAction(ok); - removeAction(cancel); - } -} - -void MainWindow::setMode() -{ - if(isMaximized()) { - showFullScreen(); - modeLabel->setText(tr("Normal Fullscreen")); - } else { - Qt::WindowFlags flags = windowFlags(); - if(flags & Qt::WindowSoftkeysRespondHint) { - flags |= Qt::WindowSoftkeysVisibleHint; - flags &= ~Qt::WindowSoftkeysRespondHint; - setWindowFlags(flags); // Hides visible window - showFullScreen(); - modeLabel->setText(tr("Fullscreen with softkeys")); - } else if(flags & Qt::WindowSoftkeysVisibleHint) { - flags &= ~Qt::WindowSoftkeysVisibleHint; - flags &= ~Qt::WindowSoftkeysRespondHint; - setWindowFlags(flags); // Hides visible window - showMaximized(); - modeLabel->setText(tr("Normal Maximized")); - } else { - flags &= ~Qt::WindowSoftkeysVisibleHint; - flags |= Qt::WindowSoftkeysRespondHint; - setWindowFlags(flags); // Hides visible window - showFullScreen(); - modeLabel->setText(tr("Fullscreen with SK respond")); - } - } -} - -void MainWindow::exitApplication() -{ - qApp->exit(); -} - -void MainWindow::okPressed() -{ - infoLabel->setText(tr("OK pressed")); -} - -void MainWindow::cancelPressed() -{ - infoLabel->setText(tr("Cancel pressed")); -} - - diff --git a/examples/widgets/widgets/softkeys/softkeys.desktop b/examples/widgets/widgets/softkeys/softkeys.desktop deleted file mode 100644 index 7f4993a5888..00000000000 --- a/examples/widgets/widgets/softkeys/softkeys.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Soft Keys -Exec=/opt/usr/bin/softkeys -Icon=softkeys -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/widgets/widgets/softkeys/softkeys.h b/examples/widgets/widgets/softkeys/softkeys.h deleted file mode 100644 index 35440b9719e..00000000000 --- a/examples/widgets/widgets/softkeys/softkeys.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SOFTKEYS_H -#define SOFTKEYS_H - -#include - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - -private slots: - void clearTextEditor(); - void openDialog(); - void addSoftKeys(); - void exitApplication(); - void okPressed(); - void cancelPressed(); - void setCustomSoftKeys(); - void setMode(); -public: - MainWindow(QWidget *parent = 0); - ~MainWindow(); -private: - QGridLayout *layout; - QWidget *central; - QTextEdit *textEditor; - QLabel *infoLabel; - QPushButton *toggleButton; - QPushButton *pushButton; - QPushButton *modeButton; - QLabel *modeLabel; - QMenu *fileMenu; - QAction *addSoftKeysAct; - QAction *exit; - QAction *ok; - QAction *cancel; -}; - -//! [0] -class SoftKey : public QWidget -{ - Q_OBJECT -public: - SoftKey(QWidget *parent = 0); -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/softkeys/softkeys.pro b/examples/widgets/widgets/softkeys/softkeys.pro deleted file mode 100644 index 5473069bb18..00000000000 --- a/examples/widgets/widgets/softkeys/softkeys.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = softkeys.h -SOURCES += \ - main.cpp \ - softkeys.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/softkeys -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS softkeys.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/softkeys -INSTALLS += target sources - -QT += widgets - diff --git a/examples/widgets/widgets/wiggly/dialog.cpp b/examples/widgets/widgets/wiggly/dialog.cpp index fb18997a9a1..4389159d1fc 100644 --- a/examples/widgets/widgets/wiggly/dialog.cpp +++ b/examples/widgets/widgets/wiggly/dialog.cpp @@ -56,17 +56,6 @@ Dialog::Dialog(QWidget *parent, bool smallScreen) layout->addWidget(lineEdit); setLayout(layout); -#ifdef QT_SOFTKEYS_ENABLED - QAction *exitAction = new QAction(tr("Exit"), this); - exitAction->setSoftKeyRole(QAction::NegativeSoftKey); - connect (exitAction, SIGNAL(triggered()),this, SLOT(close())); - addAction (exitAction); - - Qt::WindowFlags flags = windowFlags(); - flags |= Qt::WindowSoftkeysVisibleHint; - setWindowFlags(flags); -#endif - connect(lineEdit, SIGNAL(textChanged(QString)), wigglyWidget, SLOT(setText(QString))); if (!smallScreen){ diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index b4b73a9aaac..b4194c18f83 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -326,11 +326,6 @@ #define QT_NO_SOCKS5 #endif -// QSoftKeyManager -#if !defined(QT_NO_SOFTKEYMANAGER) && (defined(QT_NO_ACTION)) -#define QT_NO_SOFTKEYMANAGER -#endif - // QSplitter #if !defined(QT_NO_SPLITTER) && (defined(QT_NO_RUBBERBAND)) #define QT_NO_SPLITTER diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 7f31259c163..0f3a5c9a1dd 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -63,13 +63,6 @@ Requires: Name: QAction SeeAlso: ??? -Feature: SOFTKEYMANAGER -Description: Supports softkeys. -Section: Gui -Requires: ACTION -Name: QSoftKeyManager -SeeAlso: ??? - Feature: CURSOR Description: Supports mouse cursors. Section: Kernel diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index e7953b47dd1..6430c859362 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -311,8 +311,6 @@ public: BypassGraphicsProxyWidget = 0x20000000, WindowOkButtonHint = 0x00080000, WindowCancelButtonHint = 0x00100000, - WindowSoftkeysVisibleHint = 0x40000000, - WindowSoftkeysRespondHint = 0x80000000, NoDropShadowWindowHint = 0x40000000 }; @@ -470,9 +468,6 @@ public: WA_WState_AcceptedTouchBeginEvent = 122, WA_TouchPadAcceptSingleTouchEvents = 123, - WA_MergeSoftkeys = 124, - WA_MergeSoftkeysRecursively = 125, - WA_X11DoNotAcceptFocus = 126, WA_MacNoShadow = 127, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 50578d78c57..66442a83c72 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1160,17 +1160,6 @@ \value WA_TouchPadAcceptSingleTouchEvents Allows touchpad single touch events to be sent to the widget. - \value WA_MergeSoftkeys Allows widget to merge softkeys with parent widget, - i.e. widget can set only one softkeys and request softkey implementation - to take rest of the softkeys from the parent. Note parents are traversed until - WA_MergeSoftkeys is not set. See also Qt::WA_MergeSoftkeysRecursively - This attribute currently has effect only on Symbian platforms - - \value WA_MergeSoftkeysRecursively Allows widget to merge softkeys recursively - with all parents. If this attribute is set, the widget parents are traversed until - window boundary (widget without parent or dialog) is found. - This attribute currently has effect only on Symbian platforms - \value WA_X11DoNotAcceptFocus Asks the window manager to not give focus to this top level window. This attribute has no effect on non-X11 platforms. @@ -2031,14 +2020,6 @@ \value WindowCancelButtonHint Adds a Cancel button to the window decoration of a dialog. Only supported for Windows CE. - \value WindowSoftkeysVisibleHint Makes softkeys visible when widget is fullscreen. - Only supported for Symbian. - - \value WindowSoftkeysRespondHint Makes softkeys to receive key events even - when invisible. With this hint the softkey actions are triggered - even the softkeys are invisible i.e. the window is displayed with - \c showFullscreen(). Only supported for Symbian. - \value WindowTransparentForInput Informs the window system that this window is used only for output (displaying something) and does not take input. Therefore input events should pass through as if it wasn't there. diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index 71690ba90be..c0292ee984f 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -270,7 +270,6 @@ QT_BEGIN_NAMESPACE \omitvalue MacGLClearDrawable \omitvalue NetworkReplyUpdated \omitvalue FutureCallOut - \omitvalue UpdateSoftKeys \omitvalue NativeGesture */ diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index d30f93f9f35..6cce8386496 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -256,8 +256,6 @@ public: RequestSoftwareInputPanel = 199, CloseSoftwareInputPanel = 200, - UpdateSoftKeys = 201, // Internal for compressing soft key updates - WinIdChange = 203, #ifndef QT_NO_GESTURES Gesture = 198, diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 261039009cb..d2c3b2ad0ec 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -517,10 +517,8 @@ int QDialog::exec() setResult(0); bool showSystemDialogFullScreen = false; - if (showSystemDialogFullScreen) { - setWindowFlags(windowFlags() | Qt::WindowSoftkeysVisibleHint); + if (showSystemDialogFullScreen) setWindowState(Qt::WindowFullScreen); - } show(); QPointer guard = this; diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index a7c257b300d..fa240ccaf3b 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -66,10 +66,6 @@ extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp #endif -#if defined(QT_SOFTKEYS_ENABLED) -#include -#endif - QT_BEGIN_NAMESPACE class QErrorMessagePrivate : public QDialogPrivate @@ -80,9 +76,6 @@ public: QCheckBox * again; QTextEdit * errors; QLabel * icon; -#ifdef QT_SOFTKEYS_ENABLED - QAction *okAction; -#endif QQueue > pending; QSet doNotShow; QSet doNotShowType; @@ -245,12 +238,6 @@ QErrorMessage::QErrorMessage(QWidget * parent) d->again->setChecked(true); grid->addWidget(d->again, 1, 1, Qt::AlignTop); d->ok = new QPushButton(this); -#ifdef QT_SOFTKEYS_ENABLED - d->okAction = new QAction(d->ok); - d->okAction->setSoftKeyRole(QAction::PositiveSoftKey); - connect(d->okAction, SIGNAL(triggered()), this, SLOT(accept())); - addAction(d->okAction); -#endif #if defined(Q_OS_WINCE) @@ -402,9 +389,6 @@ void QErrorMessagePrivate::retranslateStrings() { again->setText(QErrorMessage::tr("&Show this message again")); ok->setText(QErrorMessage::tr("&OK")); -#ifdef QT_SOFTKEYS_ENABLED - okAction->setText(ok->text()); -#endif } QT_END_NAMESPACE diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index fe7aeae558d..fbbc4191bcc 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -57,10 +57,6 @@ #include #include -#if defined(QT_SOFTKEYS_ENABLED) -#include -#endif - QT_BEGIN_NAMESPACE // If the operation is expected to take this long (as predicted by @@ -80,9 +76,6 @@ public: showTime(defaultShowTime), #ifndef QT_NO_SHORTCUT escapeShortcut(0), -#endif -#ifdef QT_SOFTKEYS_ENABLED - cancelAction(0), #endif useDefaultCancelText(false) { @@ -109,9 +102,6 @@ public: bool forceHide; #ifndef QT_NO_SHORTCUT QShortcut *escapeShortcut; -#endif -#ifdef QT_SOFTKEYS_ENABLED - QAction *cancelAction; #endif bool useDefaultCancelText; QPointer receiverToDisconnectOnClose; @@ -443,16 +433,7 @@ void QProgressDialog::setCancelButton(QPushButton *cancelButton) int h = qMax(isVisible() ? height() : 0, sizeHint().height()); resize(w, h); if (cancelButton) -#if !defined(QT_SOFTKEYS_ENABLED) cancelButton->show(); -#else - { - d->cancelAction = new QAction(cancelButton->text(), cancelButton); - d->cancelAction->setSoftKeyRole(QAction::NegativeSoftKey); - connect(d->cancelAction, SIGNAL(triggered()), this, SIGNAL(canceled())); - addAction(d->cancelAction); - } -#endif } /*! @@ -471,9 +452,6 @@ void QProgressDialog::setCancelButtonText(const QString &cancelButtonText) if (!cancelButtonText.isNull()) { if (d->cancel) { d->cancel->setText(cancelButtonText); -#ifdef QT_SOFTKEYS_ENABLED - d->cancelAction->setText(cancelButtonText); -#endif } else { setCancelButton(new QPushButton(cancelButtonText, this)); } diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 58aa4743685..7f1cb092251 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -75,10 +75,6 @@ extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp #include // for memset() -#ifdef QT_SOFTKEYS_ENABLED -#include "qaction.h" -#endif - QT_BEGIN_NAMESPACE // These fudge terms were needed a few places to obtain pixel-perfect results @@ -565,12 +561,9 @@ public: , maximumWidth(QWIDGETSIZE_MAX) , maximumHeight(QWIDGETSIZE_MAX) { - for (int i = 0; i < QWizard::NButtons; ++i) { + for (int i = 0; i < QWizard::NButtons; ++i) btns[i] = 0; -#ifdef QT_SOFTKEYS_ENABLED - softKeys[i] = 0; -#endif - } + #if !defined(QT_NO_STYLE_WINDOWSVISTA) if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) @@ -657,9 +650,6 @@ public: QLabel *titleLabel; QLabel *subTitleLabel; QWizardRuler *bottomRuler; -#ifdef QT_SOFTKEYS_ENABLED - mutable QAction *softKeys[QWizard::NButtons]; -#endif QVBoxLayout *pageVBoxLayout; QHBoxLayout *buttonLayout; @@ -1387,28 +1377,6 @@ bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const if (which < QWizard::NStandardButtons) pushButton->setText(buttonDefaultText(wizStyle, which, this)); -#ifdef QT_SOFTKEYS_ENABLED - QAction *softKey = new QAction(pushButton->text(), pushButton); - QAction::SoftKeyRole softKeyRole; - switch(which) { - case QWizard::NextButton: - case QWizard::FinishButton: - case QWizard::CancelButton: - softKeyRole = QAction::NegativeSoftKey; - break; - case QWizard::BackButton: - case QWizard::CommitButton: - case QWizard::HelpButton: - case QWizard::CustomButton1: - case QWizard::CustomButton2: - case QWizard::CustomButton3: - default: - softKeyRole = QAction::PositiveSoftKey; - break; - } - softKey->setSoftKeyRole(softKeyRole); - softKeys[which] = softKey; -#endif connectButton(which); } return true; @@ -1422,10 +1390,6 @@ void QWizardPrivate::connectButton(QWizard::WizardButton which) const } else { QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked())); } - -#ifdef QT_SOFTKEYS_ENABLED - QObject::connect(softKeys[which], SIGNAL(triggered()), btns[which], SIGNAL(clicked())); -#endif } void QWizardPrivate::updateButtonTexts() @@ -1439,9 +1403,6 @@ void QWizardPrivate::updateButtonTexts() btns[i]->setText(buttonCustomTexts.value(i)); else if (i < QWizard::NStandardButtons) btns[i]->setText(buttonDefaultText(wizStyle, i, this)); -#ifdef QT_SOFTKEYS_ENABLED - softKeys[i]->setText(btns[i]->text()); -#endif } } } @@ -1686,19 +1647,6 @@ void QWizardPrivate::_q_updateButtonStates() } #endif -#ifdef QT_SOFTKEYS_ENABLED - QAbstractButton *wizardButton; - for (int i = 0; i < QWizard::NButtons; ++i) { - wizardButton = btns[i]; - if (wizardButton && !wizardButton->testAttribute(Qt::WA_WState_Hidden)) { - wizardButton->hide(); - q->addAction(softKeys[i]); - } else { - q->removeAction(softKeys[i]); - } - } -#endif - enableUpdates(); } diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 8cb6d70d15e..0308fb44a98 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -62,7 +62,6 @@ #include #include #endif -#include #ifndef QT_NO_GESTURE # include #endif @@ -94,9 +93,6 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() overwrite(false), dropIndicatorPosition(QAbstractItemView::OnItem), defaultDropAction(Qt::IgnoreAction), -#endif -#ifdef QT_SOFTKEYS_ENABLED - doneSoftKey(0), #endif autoScroll(true), autoScrollMargin(16), @@ -139,10 +135,6 @@ void QAbstractItemViewPrivate::init() viewport->setBackgroundRole(QPalette::Base); q->setAttribute(Qt::WA_InputMethodEnabled); - -#ifdef QT_SOFTKEYS_ENABLED - doneSoftKey = QSoftKeyManager::createKeyedAction(QSoftKeyManager::DoneSoftKey, Qt::Key_Back, q); -#endif } void QAbstractItemViewPrivate::setHoverIndex(const QPersistentModelIndex &index) @@ -1611,11 +1603,6 @@ bool QAbstractItemView::event(QEvent *event) case QEvent::FontChange: d->doDelayedItemsLayout(); // the size of the items will change break; -#ifdef QT_SOFTKEYS_ENABLED - case QEvent::LanguageChange: - d->doneSoftKey->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::DoneSoftKey)); - break; -#endif default: break; } @@ -2197,11 +2184,6 @@ void QAbstractItemView::focusOutEvent(QFocusEvent *event) Q_D(QAbstractItemView); QAbstractScrollArea::focusOutEvent(event); d->viewport->update(); - -#ifdef QT_SOFTKEYS_ENABLED - if(!hasEditFocus()) - removeAction(d->doneSoftKey); -#endif } /*! @@ -2226,23 +2208,12 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) if (QApplication::keypadNavigationEnabled()) { if (!hasEditFocus()) { setEditFocus(true); -#ifdef QT_SOFTKEYS_ENABLED - // If we can't keypad navigate to any direction, there is no sense to add - // "Done" softkey, since it basically does nothing when there is - // only one widget in screen - if(QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) - || QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) - addAction(d->doneSoftKey); -#endif return; } } break; case Qt::Key_Back: if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { -#ifdef QT_SOFTKEYS_ENABLED - removeAction(d->doneSoftKey); -#endif setEditFocus(false); } else { event->ignore(); diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index 5fa658d4b05..99d064ddba8 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -402,10 +402,6 @@ public: Qt::DropAction defaultDropAction; #endif -#ifdef QT_SOFTKEYS_ENABLED - QAction *doneSoftKey; -#endif - QString keyboardInput; QElapsedTimer keyboardInputTime; diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri index b2f05e3cabd..4d3d7c4e0a4 100644 --- a/src/widgets/kernel/kernel.pri +++ b/src/widgets/kernel/kernel.pri @@ -33,8 +33,6 @@ HEADERS += \ kernel/qstandardgestures_p.h \ kernel/qgesturerecognizer.h \ kernel/qgesturemanager_p.h \ - kernel/qsoftkeymanager_p.h \ - kernel/qsoftkeymanager_common_p.h \ kernel/qdesktopwidget_qpa_p.h \ kernel/qwidgetwindow_qpa_p.h @@ -59,7 +57,6 @@ SOURCES += \ kernel/qstandardgestures.cpp \ kernel/qgesturerecognizer.cpp \ kernel/qgesturemanager.cpp \ - kernel/qsoftkeymanager.cpp \ kernel/qdesktopwidget.cpp \ kernel/qwidgetsvariant.cpp \ kernel/qapplication_qpa.cpp \ diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index e835f927d08..64b856ea96b 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -81,9 +81,8 @@ static QString qt_strippedText(QString s) QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), - forceEnabledInSoftkeys(false), menuActionSoftkeys(false), iconVisibleInMenu(-1), - menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey), + menuRole(QAction::TextHeuristicRole), priority(QAction::NormalPriority) { #ifndef QT_NO_SHORTCUT @@ -280,27 +279,7 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) File menu in your menubar and the File menu has a submenu, setting the MenuRole for the actions in that submenu have no effect. They will never be moved. */ -#ifndef qdoc -/*! \since 4.6 - \enum QAction::SoftKeyRole - - This enum describes how an action should be placed in the softkey bar. Currently this enum only - has an effect on the Symbian platform. - - \value NoSoftKey This action should not be used as a softkey - \value PositiveSoftKey This action is used to describe a softkey with a positive or non-destructive - role such as Ok, Select, or Options. - \value NegativeSoftKey This action is used to describe a soft ey with a negative or destructive role - role such as Cancel, Discard, or Close. - \value SelectSoftKey This action is used to describe a role that selects a particular item or widget - in the application. - - Actions with a softkey role defined are only visible in the softkey bar when the widget containing - the action has focus. If no widget currently has focus, the softkey framework will traverse up the - widget parent hierarchy looking for a widget containing softkey actions. - */ -#endif /*! Constructs an action with \a parent. If \a parent is an action group the action will be automatically inserted into the group. @@ -1287,34 +1266,6 @@ QAction::MenuRole QAction::menuRole() const return d->menuRole; } -#ifndef qdoc -/*! - \property QAction::softKeyRole - \brief the action's softkey role - \since 4.6 - - This indicates what type of role this action describes in the softkey framework - on platforms where such a framework is supported. Currently this is only - supported on the Symbian platform. - - The softkey role can be changed any time. -*/ -void QAction::setSoftKeyRole(SoftKeyRole softKeyRole) -{ - Q_D(QAction); - if (d->softKeyRole == softKeyRole) - return; - - d->softKeyRole = softKeyRole; - d->sendDataChanged(); -} - -QAction::SoftKeyRole QAction::softKeyRole() const -{ - Q_D(const QAction); - return d->softKeyRole; -} -#endif /*! \property QAction::iconVisibleInMenu \brief Whether or not an action should show an icon in a menu diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index e149975de72..6a3c0bee686 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -66,9 +66,6 @@ class Q_WIDGETS_EXPORT QAction : public QObject Q_DECLARE_PRIVATE(QAction) Q_ENUMS(MenuRole) -#ifndef qdoc - Q_ENUMS(SoftKeyRole) -#endif Q_ENUMS(Priority) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY changed) Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled) @@ -87,9 +84,6 @@ class Q_WIDGETS_EXPORT QAction : public QObject #endif Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY changed) Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed) -#ifndef qdoc - Q_PROPERTY(SoftKeyRole softKeyRole READ softKeyRole WRITE setSoftKeyRole NOTIFY changed) -#endif Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed) Q_PROPERTY(Priority priority READ priority WRITE setPriority) @@ -97,10 +91,6 @@ public: // note this is copied into qplatformmenu.h, which must stay in sync enum MenuRole { NoRole = 0, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, AboutRole, PreferencesRole, QuitRole }; -#ifndef qdoc - enum SoftKeyRole { - NoSoftKey, PositiveSoftKey, NegativeSoftKey, SelectSoftKey }; -#endif enum Priority { LowPriority = 0, NormalPriority = 128, HighPriority = 256}; @@ -178,10 +168,6 @@ public: void setMenuRole(MenuRole menuRole); MenuRole menuRole() const; -#ifndef qdoc - void setSoftKeyRole(SoftKeyRole softKeyRole); - SoftKeyRole softKeyRole() const; -#endif void setIconVisibleInMenu(bool visible); bool isIconVisibleInMenu() const; diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h index 6e25427b310..32c55e6de2f 100644 --- a/src/widgets/kernel/qaction_p.h +++ b/src/widgets/kernel/qaction_p.h @@ -106,13 +106,9 @@ public: uint separator : 1; uint fontSet : 1; - //for soft keys management - uint forceEnabledInSoftkeys : 1; - uint menuActionSoftkeys : 1; int iconVisibleInMenu : 3; // Only has values -1, 0, and 1 QAction::MenuRole menuRole; - QAction::SoftKeyRole softKeyRole; QAction::Priority priority; QList widgets; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 3e0f803f5d6..efa52456e84 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -902,7 +902,6 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis || event->type() == QEvent::Resize || event->type() == QEvent::Move || event->type() == QEvent::LanguageChange - || event->type() == QEvent::UpdateSoftKeys || event->type() == QEvent::InputMethod)) { for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) { const QPostEvent &cur = *it; @@ -917,8 +916,6 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis ((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p; } else if (cur.event->type() == QEvent::LanguageChange) { ; - } else if (cur.event->type() == QEvent::UpdateSoftKeys) { - ; } else if ( cur.event->type() == QEvent::InputMethod ) { *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event; } else { diff --git a/src/widgets/kernel/qsoftkeymanager.cpp b/src/widgets/kernel/qsoftkeymanager.cpp deleted file mode 100644 index 64ee6b0f2eb..00000000000 --- a/src/widgets/kernel/qsoftkeymanager.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qapplication.h" -#include "qevent.h" -#include "qbitmap.h" -#include "private/qsoftkeymanager_p.h" -#include "private/qaction_p.h" -#include "private/qsoftkeymanager_common_p.h" - -#ifndef QT_NO_SOFTKEYMANAGER -QT_BEGIN_NAMESPACE - -QSoftKeyManager *QSoftKeyManagerPrivate::self = 0; - -QString QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey) -{ - QString softKeyText; - switch (standardKey) { - case OkSoftKey: - softKeyText = QSoftKeyManager::tr("Ok"); - break; - case SelectSoftKey: - softKeyText = QSoftKeyManager::tr("Select"); - break; - case DoneSoftKey: - softKeyText = QSoftKeyManager::tr("Done"); - break; - case MenuSoftKey: - softKeyText = QSoftKeyManager::tr("Options"); - break; - case CancelSoftKey: - softKeyText = QSoftKeyManager::tr("Cancel"); - break; - default: - break; - }; - - return softKeyText; -} - -QSoftKeyManager *QSoftKeyManager::instance() -{ - if (!QSoftKeyManagerPrivate::self) - QSoftKeyManagerPrivate::self = new QSoftKeyManager; - - return QSoftKeyManagerPrivate::self; -} - -QSoftKeyManager::QSoftKeyManager() : - QObject(*(new QSoftKeyManagerPrivate), 0) -{ -} - -QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *actionWidget) -{ - QAction *action = new QAction(standardSoftKeyText(standardKey), actionWidget); - QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey; - switch (standardKey) { - case MenuSoftKey: // FALL-THROUGH - QActionPrivate::get(action)->menuActionSoftkeys = true; - case OkSoftKey: - case SelectSoftKey: - case DoneSoftKey: - softKeyRole = QAction::PositiveSoftKey; - break; - case CancelSoftKey: - softKeyRole = QAction::NegativeSoftKey; - break; - } - action->setSoftKeyRole(softKeyRole); - action->setVisible(false); - setForceEnabledInSoftkeys(action); - return action; -} - -/*! \internal - - Creates a QAction and registers the 'triggered' signal to send the given key event to - \a actionWidget as a convenience. - -*/ -QAction *QSoftKeyManager::createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget) -{ -#ifndef QT_NO_ACTION - QScopedPointer action(createAction(standardKey, actionWidget)); - - connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent())); - connect(action.data(), SIGNAL(destroyed(QObject*)), QSoftKeyManager::instance(), SLOT(cleanupHash(QObject*))); - QSoftKeyManager::instance()->d_func()->keyedActions.insert(action.data(), key); - return action.take(); -#endif //QT_NO_ACTION -} - -void QSoftKeyManager::cleanupHash(QObject *obj) -{ - Q_D(QSoftKeyManager); - QAction *action = qobject_cast(obj); - d->keyedActions.remove(action); -} - -void QSoftKeyManager::sendKeyEvent() -{ - Q_D(QSoftKeyManager); - QAction *action = qobject_cast(sender()); - - if (!action) - return; - - Qt::Key keyToSend = d->keyedActions.value(action, Qt::Key_unknown); - - if (keyToSend != Qt::Key_unknown) - QApplication::postEvent(action->parentWidget(), - new QKeyEvent(QEvent::KeyPress, keyToSend, Qt::NoModifier)); -} - -void QSoftKeyManager::updateSoftKeys() -{ - QSoftKeyManager::instance()->d_func()->pendingUpdate = true; - QEvent *event = new QEvent(QEvent::UpdateSoftKeys); - QApplication::postEvent(QSoftKeyManager::instance(), event); -} - -bool QSoftKeyManager::appendSoftkeys(const QWidget &source, int level) -{ - Q_D(QSoftKeyManager); - bool ret = false; - foreach(QAction *action, source.actions()) { - if (action->softKeyRole() != QAction::NoSoftKey - && (action->isVisible() || isForceEnabledInSofkeys(action))) { - d->requestedSoftKeyActions.insert(level, action); - ret = true; - } - } - return ret; -} - - -static bool isChildOf(const QWidget *c, const QWidget *p) -{ - while (c) { - if (c == p) - return true; - c = c->parentWidget(); - } - return false; -} - -QWidget *QSoftKeyManager::softkeySource(QWidget *previousSource, bool& recursiveMerging) -{ - Q_D(QSoftKeyManager); - QWidget *source = NULL; - if (!previousSource) { - // Initial source is primarily focuswidget and secondarily activeWindow - QWidget *focus = QApplication::focusWidget(); - QWidget *popup = QApplication::activePopupWidget(); - if (popup) { - if (isChildOf(focus, popup)) - source = focus; - else - source = popup; - } - if (!source) { - QWidget *modal = QApplication::activeModalWidget(); - if (modal) { - if (isChildOf(focus, modal)) - source = focus; - else - source = modal; - } - } - if (!source) { - source = focus; - if (!source) - source = QApplication::activeWindow(); - } - } else { - // Softkey merging is based on four criterias - // 1. Implicit merging is used whenever focus widget does not specify any softkeys - bool implicitMerging = d->requestedSoftKeyActions.isEmpty(); - // 2. Explicit merging with parent is used whenever WA_MergeSoftkeys widget attribute is set - bool explicitMerging = previousSource->testAttribute(Qt::WA_MergeSoftkeys); - // 3. Explicit merging with all parents - recursiveMerging |= previousSource->testAttribute(Qt::WA_MergeSoftkeysRecursively); - // 4. Implicit and explicit merging always stops at window boundary - bool merging = (implicitMerging || explicitMerging || recursiveMerging) && !previousSource->isWindow(); - - source = merging ? previousSource->parentWidget() : NULL; - } - return source; -} - -bool QSoftKeyManager::handleUpdateSoftKeys() -{ - Q_D(QSoftKeyManager); - int level = 0; - d->requestedSoftKeyActions.clear(); - bool recursiveMerging = false; - QWidget *source = softkeySource(NULL, recursiveMerging); - d->initialSoftKeySource = source; - while (source) { - if (appendSoftkeys(*source, level)) - ++level; - source = softkeySource(source, recursiveMerging); - } - - d->updateSoftKeys_sys(); - d->pendingUpdate = false; - return true; -} - -void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action) -{ - QActionPrivate::get(action)->forceEnabledInSoftkeys = true; -} - -bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action) -{ - return QActionPrivate::get(action)->forceEnabledInSoftkeys; -} - -bool QSoftKeyManager::event(QEvent *e) -{ -#ifndef QT_NO_ACTION - if (e->type() == QEvent::UpdateSoftKeys) - return handleUpdateSoftKeys(); -#endif //QT_NO_ACTION - return false; -} - -QT_END_NAMESPACE -#endif //QT_NO_SOFTKEYMANAGER diff --git a/src/widgets/kernel/qsoftkeymanager_common_p.h b/src/widgets/kernel/qsoftkeymanager_common_p.h deleted file mode 100644 index 27e1b869ae6..00000000000 --- a/src/widgets/kernel/qsoftkeymanager_common_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOFTKEYMANAGER_COMMON_P_H -#define QSOFTKEYMANAGER_COMMON_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_HEADER - -#ifndef QT_NO_SOFTKEYMANAGER - -QT_BEGIN_NAMESPACE - -class QSoftKeyManagerPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QSoftKeyManager) - -public: - virtual void updateSoftKeys_sys() {} - -protected: - static QSoftKeyManager *self; - QHash keyedActions; - QMultiHash requestedSoftKeyActions; - QWidget *initialSoftKeySource; - bool pendingUpdate; -}; - -QT_END_NAMESPACE - -#endif //QT_NO_SOFTKEYMANAGER - -QT_END_HEADER - -#endif // QSOFTKEYMANAGER_COMMON_P_H diff --git a/src/widgets/kernel/qsoftkeymanager_p.h b/src/widgets/kernel/qsoftkeymanager_p.h deleted file mode 100644 index a80088d33c7..00000000000 --- a/src/widgets/kernel/qsoftkeymanager_p.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOFTKEYMANAGER_P_H -#define QSOFTKEYMANAGER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include "QtWidgets/qaction.h" - -QT_BEGIN_HEADER - -#ifndef QT_NO_SOFTKEYMANAGER -QT_BEGIN_NAMESPACE - -class QSoftKeyManagerPrivate; - -class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QSoftKeyManager) - -public: - - enum StandardSoftKey { - OkSoftKey, - SelectSoftKey, - DoneSoftKey, - MenuSoftKey, - CancelSoftKey - }; - - static void updateSoftKeys(); - - static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget); - static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget); - static QString standardSoftKeyText(StandardSoftKey standardKey); - static void setForceEnabledInSoftkeys(QAction *action); - static bool isForceEnabledInSofkeys(QAction *action); - -protected: - bool event(QEvent *e); - -private: - QSoftKeyManager(); - static QSoftKeyManager *instance(); - bool appendSoftkeys(const QWidget &source, int level); - QWidget *softkeySource(QWidget *previousSource, bool& recursiveMerging); - bool handleUpdateSoftKeys(); - -private Q_SLOTS: - void cleanupHash(QObject* obj); - void sendKeyEvent(); - -private: - Q_DISABLE_COPY(QSoftKeyManager) -}; - -QT_END_NAMESPACE -#endif //QT_NO_SOFTKEYMANAGER - -QT_END_HEADER - -#endif //QSOFTKEYMANAGER_P_H diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 07dab9e784e..2feb7979852 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -77,7 +77,6 @@ #include "private/qstylesheetstyle_p.h" #include "private/qstyle_p.h" #include "qfileinfo.h" -#include "private/qsoftkeymanager_p.h" #include #include @@ -906,30 +905,6 @@ void QWidget::setAutoFillBackground(bool enabled) \sa QEvent, QPainter, QGridLayout, QBoxLayout - \section1 Softkeys - - Since Qt 4.6, Softkeys are usually physical keys on a device that have a corresponding label or - other visual representation on the screen that is generally located next to its - physical counterpart. They are most often found on mobile phone platforms. In - modern touch based user interfaces it is also possible to have softkeys that do - not correspond to any physical keys. Softkeys differ from other onscreen labels - in that they are contextual. - - In Qt, contextual softkeys are added to a widget by calling addAction() and - passing a \c QAction with a softkey role set on it. When the widget - containing the softkey actions has focus, its softkeys should appear in - the user interface. Softkeys are discovered by traversing the widget - hierarchy so it is possible to define a single set of softkeys that are - present at all times by calling addAction() for a given top level widget. - - On some platforms, this concept overlaps with \c QMenuBar such that if no - other softkeys are found and the top level widget is a QMainWindow containing - a QMenuBar, the menubar actions may appear on one of the softkeys. - - Note: Currently softkeys are only supported on the Symbian Platform. - - \sa addAction(), QAction, QMenuBar - */ QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid @@ -7956,9 +7931,6 @@ bool QWidget::event(QEvent *event) } break; case QEvent::FocusIn: -#ifdef QT_SOFTKEYS_ENABLED - QSoftKeyManager::updateSoftKeys(); -#endif focusInEvent((QFocusEvent*)event); d->updateWidgetTransform(); break; @@ -8109,12 +8081,6 @@ bool QWidget::event(QEvent *event) if (w && w->isVisible() && !w->isWindow()) QApplication::sendEvent(w, event); } - -#ifdef QT_SOFTKEYS_ENABLED - if (isWindow()) - QSoftKeyManager::updateSoftKeys(); -#endif - break; } case QEvent::LanguageChange: @@ -8199,9 +8165,6 @@ bool QWidget::event(QEvent *event) case QEvent::ActionAdded: case QEvent::ActionRemoved: case QEvent::ActionChanged: -#ifdef QT_SOFTKEYS_ENABLED - QSoftKeyManager::updateSoftKeys(); -#endif actionEvent((QActionEvent*)event); break; #endif diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp index fcb3a6df031..8c66ec40513 100644 --- a/src/widgets/statemachine/qguistatemachine.cpp +++ b/src/widgets/statemachine/qguistatemachine.cpp @@ -442,9 +442,6 @@ static QEvent *cloneEvent(QEvent *e) break; #endif - case QEvent::UpdateSoftKeys: - return new QEvent(*e); - case QEvent::User: case QEvent::MaxUser: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index ef908d62c6f..f22fc196a26 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -64,7 +64,6 @@ #include #include #include -#include #include #if defined(Q_WS_MAC) && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC) #include @@ -561,13 +560,6 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView) #endif connect(view, SIGNAL(destroyed()), this, SLOT(viewDestroyed())); - -#ifdef QT_SOFTKEYS_ENABLED - selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, itemView); - cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, itemView); - addAction(selectAction); - addAction(cancelAction); -#endif } /*! @@ -617,11 +609,6 @@ void QComboBoxPrivateContainer::changeEvent(QEvent *e) view->setMouseTracking(combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) || combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)); setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo)); -#ifdef QT_SOFTKEYS_ENABLED - } else if (e->type() == QEvent::LanguageChange) { - selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey)); - cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey)); -#endif } QWidget::changeEvent(e); diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index eaf218283da..c51e6bb3883 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -254,10 +254,6 @@ private: QAbstractItemView *view; QComboBoxPrivateScroller *top; QComboBoxPrivateScroller *bottom; -#ifdef QT_SOFTKEYS_ENABLED - QAction *selectAction; - QAction *cancelAction; -#endif }; class QComboMenuDelegate : public QAbstractItemDelegate diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index d25332a077b..f20fc522ba0 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -255,31 +255,6 @@ static const uint layouts[2][5][14] = } }; -#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) -class QDialogButtonEnabledProxy : public QObject -{ -public: - QDialogButtonEnabledProxy(QObject *parent, QWidget *src, QAction *trg) : QObject(parent), source(src), target(trg) - { - source->installEventFilter(this); - target->setEnabled(source->isEnabled()); - } - ~QDialogButtonEnabledProxy() - { - source->removeEventFilter(this); - } - bool eventFilter(QObject *object, QEvent *event) - { - if (object == source && event->type() == QEvent::EnabledChange) { - target->setEnabled(source->isEnabled()); - } - return false; - }; -private: - QWidget *source; - QAction *target; -}; -#endif class QDialogButtonBoxPrivate : public QWidgetPrivate { @@ -290,9 +265,6 @@ public: QList buttonLists[QDialogButtonBox::NRoles]; QHash standardButtonHash; -#ifdef QT_SOFTKEYS_ENABLED - QHash softKeyActions; -#endif Qt::Orientation orientation; QDialogButtonBox::ButtonLayout layoutPolicy; @@ -312,9 +284,6 @@ public: void addButtonsToLayout(const QList &buttonList, bool reverse); void retranslateStrings(); const char *standardButtonText(QDialogButtonBox::StandardButton sbutton) const; -#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) - QAction *createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role); -#endif }; QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient) @@ -577,62 +546,10 @@ void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBo QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_handleButtonClicked())); QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed())); buttonLists[role].append(button); -#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) - QAction *action = createSoftKey(button, role); - softKeyActions.insert(button, action); - new QDialogButtonEnabledProxy(action, button, action); -#endif if (doLayout) layoutButtons(); } -#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) -QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role) -{ - Q_Q(QDialogButtonBox); - QAction::SoftKeyRole softkeyRole; - - QAction *action = new QAction(button->text(), button); - - switch (role) { - case ApplyRole: - case AcceptRole: - case YesRole: - case ActionRole: - case HelpRole: - softkeyRole = QAction::PositiveSoftKey; - break; - case RejectRole: - case DestructiveRole: - case NoRole: - case ResetRole: - softkeyRole = QAction::NegativeSoftKey; - break; - default: - break; - } - QObject::connect(action, SIGNAL(triggered()), button, SIGNAL(clicked())); - action->setSoftKeyRole(softkeyRole); - - - QWidget *dialog = 0; - QWidget *p = q; - while (p && !p->isWindow()) { - p = p->parentWidget(); - if ((dialog = qobject_cast(p))) - break; - } - - if (dialog) { - dialog->addAction(action); - } else { - q->addAction(action); - } - - return action; -} -#endif - void QDialogButtonBoxPrivate::createStandardButtons(QDialogButtonBox::StandardButtons buttons) { uint i = QDialogButtonBox::FirstButton; @@ -724,11 +641,6 @@ void QDialogButtonBoxPrivate::retranslateStrings() if (buttonText) { QPushButton *button = it.key(); button->setText(QDialogButtonBox::tr(buttonText)); -#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) - QAction *action = softKeyActions.value(button, 0); - if (action) - action->setText(button->text()); -#endif } ++it; } @@ -921,11 +833,6 @@ void QDialogButtonBox::setOrientation(Qt::Orientation orientation) void QDialogButtonBox::clear() { Q_D(QDialogButtonBox); -#ifdef QT_SOFTKEYS_ENABLED - // Delete softkey actions as they have the buttons as parents - qDeleteAll(d->softKeyActions.values()); - d->softKeyActions.clear(); -#endif // Remove the created standard buttons, they should be in the other lists, which will // do the deletion d->standardButtonHash.clear(); @@ -1003,13 +910,6 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) } } } -#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) - QAction *action = d->softKeyActions.value(button, 0); - if (action) { - d->softKeyActions.remove(button); - delete action; - } -#endif if (!d->internalRemove) button->setParent(0); } @@ -1080,11 +980,6 @@ QPushButton *QDialogButtonBox::addButton(StandardButton button) void QDialogButtonBox::setStandardButtons(StandardButtons buttons) { Q_D(QDialogButtonBox); -#ifdef QT_SOFTKEYS_ENABLED - // Delete softkey actions since they have the buttons as parents - qDeleteAll(d->softKeyActions.values()); - d->softKeyActions.clear(); -#endif // Clear out all the old standard buttons, then recreate them. qDeleteAll(d->standardButtonHash.keys()); d->standardButtonHash.clear(); @@ -1242,38 +1137,9 @@ bool QDialogButtonBox::event(QEvent *event) } if (!hasDefault && firstAcceptButton) firstAcceptButton->setDefault(true); -#ifdef QT_SOFTKEYS_ENABLED - if (dialog) - setFixedSize(0,0); -#endif }else if (event->type() == QEvent::LanguageChange) { d->retranslateStrings(); } -#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) - else if (event->type() == QEvent::ParentChange) { - QWidget *dialog = 0; - QWidget *p = this; - while (p && !p->isWindow()) { - p = p->parentWidget(); - if ((dialog = qobject_cast(p))) - break; - } - - // If the parent changes, then move the softkeys - for (QHash::const_iterator it = d->softKeyActions.constBegin(); - it != d->softKeyActions.constEnd(); ++it) { - QAction *current = it.value(); - QList widgets = current->associatedWidgets(); - foreach (QWidget *w, widgets) - w->removeAction(current); - if (dialog) - dialog->addAction(current); - else - addAction(current); - } - } -#endif - return QWidget::event(event); } diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index ffded7839f4..fe7e444e86d 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -69,7 +69,6 @@ #include "qpushbutton.h" #include #include -#include #include QT_BEGIN_NAMESPACE @@ -158,15 +157,6 @@ void QMenuPrivate::init() QObject::connect(platformMenu, SIGNAL(aboutToShow()), q, SIGNAL(aboutToShow())); QObject::connect(platformMenu, SIGNAL(aboutToHide()), q, SIGNAL(aboutToHide())); } - -#ifdef QT_SOFTKEYS_ENABLED - selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, q); - cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Back, q); - selectAction->setPriority(QAction::HighPriority); - cancelAction->setPriority(QAction::HighPriority); - q->addAction(selectAction); - q->addAction(cancelAction); -#endif } int QMenuPrivate::scrollerHeight() const @@ -1674,12 +1664,6 @@ void QMenu::clear() QList acts = actions(); for(int i = 0; i < acts.size(); i++) { -#ifdef QT_SOFTKEYS_ENABLED - Q_D(QMenu); - // Lets not touch to our internal softkey actions - if(acts[i] == d->selectAction || acts[i] == d->cancelAction) - continue; -#endif removeAction(acts[i]); if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty()) delete acts[i]; @@ -2382,13 +2366,6 @@ QMenu::event(QEvent *e) e->accept(); } return true; -#endif -#ifdef QT_SOFTKEYS_ENABLED - case QEvent::LanguageChange: { - d->selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey)); - d->cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey)); - } - break; #endif default: break; diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index f6665cba9a5..35c665bb25d 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -70,10 +70,6 @@ extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp #endif -#ifdef QT_SOFTKEYS_ENABLED -#include -#endif - QT_BEGIN_NAMESPACE class QMenuBarExtension : public QToolButton @@ -719,9 +715,6 @@ void QMenuBarPrivate::init() #endif q->setBackgroundRole(QPalette::Button); oldWindow = oldParent = 0; -#ifdef QT_SOFTKEYS_ENABLED - menuBarAction = 0; -#endif handleReparent(); q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q)); @@ -1405,11 +1398,6 @@ void QMenuBar::changeEvent(QEvent *e) || e->type() == QEvent::ApplicationFontChange) { d->itemsDirty = true; d->updateGeometries(); -#ifdef QT_SOFTKEYS_ENABLED - } else if (e->type() == QEvent::LanguageChange) { - if (d->menuBarAction) - d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey)); -#endif } QWidget::changeEvent(e); diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h index 4960c60f83c..0f08a4e414f 100644 --- a/src/widgets/widgets/qmenubar_p.h +++ b/src/widgets/widgets/qmenubar_p.h @@ -188,9 +188,6 @@ public: void wceRefresh(); bool wceEmitSignals(QList actions, uint command); #endif -#ifdef QT_SOFTKEYS_ENABLED - QAction *menuBarAction; -#endif }; #endif // QT_NO_MENUBAR diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp index bd4e53e7ed6..7d724514b90 100644 --- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp @@ -171,14 +171,6 @@ void tst_QActionGroup::separators() mw.show(); -#ifdef QT_SOFTKEYS_ENABLED - // Softkeys add extra "Select" and "Back" actions to menu by default. - // Two first actions will be Select and Back when softkeys are enabled - int numSoftkeyActions = 2; -#else - int numSoftkeyActions = 0; -#endif - QAction *action = new QAction(&actGroup); action->setText("test one"); @@ -190,13 +182,13 @@ void tst_QActionGroup::separators() while (it.hasNext()) menu.addAction(it.next()); - QCOMPARE((int)menu.actions().size(), 2 + numSoftkeyActions); + QCOMPARE((int)menu.actions().size(), 2); it = QListIterator(actGroup.actions()); while (it.hasNext()) menu.removeAction(it.next()); - QCOMPARE((int)menu.actions().size(), 0 + numSoftkeyActions); + QCOMPARE((int)menu.actions().size(), 0); action = new QAction(&actGroup); action->setText("test two"); @@ -205,7 +197,7 @@ void tst_QActionGroup::separators() while (it.hasNext()) menu.addAction(it.next()); - QCOMPARE((int)menu.actions().size(), 3 + numSoftkeyActions); + QCOMPARE((int)menu.actions().size(), 3); } void tst_QActionGroup::testActionInTwoQActionGroup() diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index 8c8f5b5d71f..74b30039f8f 100644 --- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -107,9 +107,6 @@ private slots: void testSignalOrder(); void testDefaultButton_data(); void testDefaultButton(); -#ifdef QT_SOFTKEYS_ENABLED - void testSoftKeyReparenting(); -#endif void task191642_default(); private: @@ -714,51 +711,6 @@ void tst_QDialogButtonBox::testDefaultButton_data() QTest::newRow("third accept explicit after add") << 0 << 2 << 2; } -static int softKeyCount(QWidget *widget) -{ - int softkeyCount = 0; -#ifndef QT_NO_ACTION - QList actions = widget->actions(); - foreach (QAction *action, actions) { - if (action->softKeyRole() != QAction::NoSoftKey) - softkeyCount++; - } -#endif - return softkeyCount; -} - -#ifdef QT_SOFTKEYS_ENABLED -void tst_QDialogButtonBox::testSoftKeyReparenting() -{ - QDialog dialog; - QDialogButtonBox *buttonBox = new QDialogButtonBox; - buttonBox->addButton(QDialogButtonBox::Ok); - buttonBox->addButton(QDialogButtonBox::Cancel); - -#ifndef QT_NO_ACTION - QCOMPARE(softKeyCount(&dialog), 0); - QCOMPARE(softKeyCount(buttonBox), 2); -#endif - - // Were the softkeys re-parented correctly? - dialog.setLayout(new QVBoxLayout); - dialog.layout()->addWidget(buttonBox); -#ifndef QT_NO_ACTION - QCOMPARE(softKeyCount(&dialog), 2); - QCOMPARE(softKeyCount(buttonBox), 0); -#endif - - // Softkeys are only added to QDialog, not QWidget - QWidget *nested = new QWidget; - nested->setLayout(new QVBoxLayout); - nested->layout()->addWidget(buttonBox); -#ifndef QT_NO_ACTION - QCOMPARE(softKeyCount(nested), 0); - QCOMPARE(softKeyCount(buttonBox), 2); -#endif -} -#endif - void tst_QDialogButtonBox::testDefaultButton() { QFETCH(int, whenToSetDefault); diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index cf2d0de0e2d..5f0a1e84b08 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -1322,26 +1322,18 @@ void tst_QMainWindow::createPopupMenu() mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget4); -#ifdef QT_SOFTKEYS_ENABLED - // Softkeys add extra "Select" and "Back" actions to menu by default. - // Two first actions will be Select and Back when softkeys are enabled - int numSoftkeyActions = 2; -#else - int numSoftkeyActions = 0; -#endif - QMenu *menu = mainwindow.createPopupMenu(); QVERIFY(menu != 0); QList actions = menu->actions(); - QCOMPARE(actions.size(), 7 + numSoftkeyActions); + QCOMPARE(actions.size(), 7); - QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget1.toggleViewAction()); - QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget2.toggleViewAction()); - QCOMPARE(actions.at(2 + numSoftkeyActions), dockwidget3.toggleViewAction()); - QCOMPARE(actions.at(3 + numSoftkeyActions), dockwidget4.toggleViewAction()); - QVERIFY(actions.at(4 + numSoftkeyActions)->isSeparator()); - QCOMPARE(actions.at(5 + numSoftkeyActions), toolbar1.toggleViewAction()); - QCOMPARE(actions.at(6 + numSoftkeyActions), toolbar2.toggleViewAction()); + QCOMPARE(actions.at(0), dockwidget1.toggleViewAction()); + QCOMPARE(actions.at(1), dockwidget2.toggleViewAction()); + QCOMPARE(actions.at(2), dockwidget3.toggleViewAction()); + QCOMPARE(actions.at(3), dockwidget4.toggleViewAction()); + QVERIFY(actions.at(4)->isSeparator()); + QCOMPARE(actions.at(5), toolbar1.toggleViewAction()); + QCOMPARE(actions.at(6), toolbar2.toggleViewAction()); delete menu; @@ -1352,12 +1344,12 @@ void tst_QMainWindow::createPopupMenu() menu = mainwindow.createPopupMenu(); QVERIFY(menu != 0); actions = menu->actions(); - QCOMPARE(actions.size(), 4 + numSoftkeyActions); + QCOMPARE(actions.size(), 4); - QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget2.toggleViewAction()); - QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget3.toggleViewAction()); - QVERIFY(actions.at(2 + numSoftkeyActions)->isSeparator()); - QCOMPARE(actions.at(3 + numSoftkeyActions), toolbar2.toggleViewAction()); + QCOMPARE(actions.at(0), dockwidget2.toggleViewAction()); + QCOMPARE(actions.at(1), dockwidget3.toggleViewAction()); + QVERIFY(actions.at(2)->isSeparator()); + QCOMPARE(actions.at(3), toolbar2.toggleViewAction()); delete menu; } diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 4a534739031..28068a808d4 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -243,17 +243,9 @@ void tst_QMenu::onStatusMessageChanged(const QString &s) void tst_QMenu::addActionsAndClear() { -#ifdef QT_SOFTKEYS_ENABLED - // Softkeys add extra "Select" and "Back" actions to menu by default. - // Two first actions will be Select and Back when softkeys are enabled - int numSoftkeyActions = 2; -#else - int numSoftkeyActions = 0; -#endif - - QCOMPARE(menus[0]->actions().count(), 0 + numSoftkeyActions); + QCOMPARE(menus[0]->actions().count(), 0); createActions(); - QCOMPARE(menus[0]->actions().count(), 8 + numSoftkeyActions); + QCOMPARE(menus[0]->actions().count(), 8); menus[0]->clear(); QCOMPARE(menus[0]->actions().count(), 0); } @@ -730,11 +722,6 @@ void tst_QMenu::menuSizeHint() int maxWidth =0; QRect result; foreach (QAction *action, menu.actions()) { -#ifdef QT_SOFTKEYS_ENABLED - // Softkey actions are not widgets and have no geometry. - if (menu.actionGeometry(action).topLeft() == QPoint(0,0)) - continue; -#endif maxWidth = qMax(maxWidth, menu.actionGeometry(action).width()); result |= menu.actionGeometry(action); QCOMPARE(result.x(), left + hmargin + panelWidth); From c21564b1ef2fe7959907ef9fefe44fad58738710 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 26 Oct 2012 11:01:47 +0200 Subject: [PATCH 056/134] Remove some dead code This code became dead when the Symbian code was removed, and should ideally have been removed at that point. You can find the old code in 4.8 repo: bool showSystemDialogFullScreen = false; if (qobject_cast(this) || qobject_cast(this) || qobject_cast(this)) { showSystemDialogFullScreen = true; } if (showSystemDialogFullScreen) { setWindowFlags(windowFlags() | Qt::WindowSoftkeysVisibleHint); setWindowState(Qt::WindowFullScreen); } So, obviously, stuff inside the #ifdef Q_OS_SYMBIAN was removed, but the side-effect of that was not realized..... Change-Id: I6b5d1066c97367c354af4da1ce6b9c60c8dc2120 Reviewed-by: J-P Nurmi --- src/widgets/dialogs/qdialog.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index d2c3b2ad0ec..7b47f4e135b 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -516,9 +516,6 @@ int QDialog::exec() setAttribute(Qt::WA_ShowModal, true); setResult(0); - bool showSystemDialogFullScreen = false; - if (showSystemDialogFullScreen) - setWindowState(Qt::WindowFullScreen); show(); QPointer guard = this; From 7aa0adf130447214ff3a7bb8144d35b366e94d77 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 29 Oct 2012 12:03:34 +0200 Subject: [PATCH 057/134] QFontEngineMulti: Fix possible crash in stringToCMap() in case when the layout is partially initialized. We shouldn't access any data except of indices if GlyphIndicesOnly flag has been passed in. Change-Id: I264689b498e0f9de8b5c040d47dbae4f6ef391c4 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine.cpp | 7 ++-- .../gui/text/qfontmetrics/qfontmetrics.pro | 2 +- .../text/qfontmetrics/tst_qfontmetrics.cpp | 34 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index bdcf1662438..fa4e7a75bc0 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1370,7 +1370,9 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, bool surrogate = (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate()); uint ucs4 = surrogate ? QChar::surrogateToUcs4(str[i], str[i+1]) : str[i].unicode(); if (glyphs->glyphs[glyph_pos] == 0 && str[i].category() != QChar::Separator_Line) { - QGlyphLayoutInstance tmp = glyphs->instance(glyph_pos); + QGlyphLayoutInstance tmp; + if (!(flags & GlyphIndicesOnly)) + tmp = glyphs->instance(glyph_pos); for (int x=1; x < engines.size(); ++x) { if (engines.at(x) == 0 && !shouldLoadFontEngineForCharacter(x, ucs4)) continue; @@ -1400,9 +1402,8 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, } // ensure we use metrics from the 1st font when we use the fallback image. - if (!glyphs->glyphs[glyph_pos]) { + if (!(flags & GlyphIndicesOnly) && !glyphs->glyphs[glyph_pos]) glyphs->setInstance(glyph_pos, tmp); - } } if (surrogate) diff --git a/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro b/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro index ef08458c56f..88436f6a0e1 100644 --- a/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro +++ b/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro @@ -1,7 +1,7 @@ CONFIG += testcase CONFIG += parallel_test TARGET = tst_qfontmetrics -QT += testlib +QT += testlib core-private gui-private SOURCES += tst_qfontmetrics.cpp RESOURCES += testfont.qrc DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 4f502ae5f2e..b457e17b484 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -279,6 +280,39 @@ void tst_QFontMetrics::inFontUcs4() QVERIFY(fm.inFontUcs4(0x1D7FF)); } + { + QFontEngine *engine = QFontPrivate::get(font)->engineForScript(QUnicodeTables::Common); + QGlyphLayout glyphs; + glyphs.numGlyphs = 3; + uint buf[3]; + glyphs.glyphs = buf; + + QString string; + { + string.append(QChar::highSurrogate(0x1D7FF)); + string.append(QChar::lowSurrogate(0x1D7FF)); + + glyphs.numGlyphs = 3; + glyphs.glyphs[0] = 0; + QVERIFY(engine->stringToCMap(string.constData(), string.size(), + &glyphs, &glyphs.numGlyphs, + QFontEngine::GlyphIndicesOnly)); + QCOMPARE(glyphs.numGlyphs, 1); + QCOMPARE(glyphs.glyphs[0], uint(1)); + } + { + string.clear(); + string.append(QChar::ObjectReplacementCharacter); + + glyphs.numGlyphs = 3; + glyphs.glyphs[0] = 0; + QVERIFY(engine->stringToCMap(string.constData(), string.size(), + &glyphs, &glyphs.numGlyphs, + QFontEngine::GlyphIndicesOnly)); + QVERIFY(glyphs.glyphs[0] != 1); + } + } + QFontDatabase::removeApplicationFont(id); } From c9266e7cb93cc9c265f0de69e3660ee7dc4492c6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 20 Sep 2012 12:53:33 +0200 Subject: [PATCH 058/134] redo QT_PLUGIN_PATH assembly for non-installed execution it is a bad idea to extract plugin paths from library modules. instead, just collect plugin paths from all known repositories. Change-Id: I527325f20e9cf98ae974997530af1b2893537e5d Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_functions.prf | 14 +++++++------- mkspecs/features/qt_module_fwdpri.prf | 4 ---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 1d24ed9c005..f8922e68efd 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -210,12 +210,10 @@ defineTest(qtAddToolEnv) { defineTest(qtAddTargetEnv) { deps = $$resolve_depends(QT, "QT.") !isEmpty(deps) { - plugin_paths = for(dep, deps) { deppath += $$shell_path($$eval(QT.$${dep}.libs)) for(rpath, QT.$${dep}.rpath_link): \ deppath += $$shell_path($$rpath) - plugin_paths += $$eval(QT.$${dep}.plugin_path) $$eval(QT.$${dep}.plugins) } equals(QMAKE_HOST.os, Windows): \ deppath.name = PATH @@ -227,12 +225,14 @@ defineTest(qtAddTargetEnv) { error("Operating system not supported.") deppath.value = $$unique(deppath) deppath.CONFIG = prepend - pluginpath.name = QT_PLUGIN_PATH + pluginpath.value = - plugin_paths = $$unique(plugin_paths) - for(ppath, plugin_paths): \ - exists($$ppath): \ - pluginpath.value += $$shell_path($$ppath) + for(qmod, QMAKEMODULES) { + qmod = $$section(qmod, /, 0, -3)/plugins + exists($$qmod): pluginpath.value += $$shell_path($$qmod) + } + pluginpath.name = QT_PLUGIN_PATH + QT_TOOL_ENV += deppath pluginpath } qtAddToolEnv($$1, $$QT_TOOL_ENV) diff --git a/mkspecs/features/qt_module_fwdpri.prf b/mkspecs/features/qt_module_fwdpri.prf index 5dc63ebdfda..9a0fd360193 100644 --- a/mkspecs/features/qt_module_fwdpri.prf +++ b/mkspecs/features/qt_module_fwdpri.prf @@ -32,11 +32,9 @@ privqt = $$replace(QT_PRIVATE, -private$, ) privdep = $$resolve_depends(privqt, "QT.") rpaths = - pluginpath = alldep = $$pubdep $$privdep for(dep, alldep) { # Inherit link-rpaths from all our dependencies rpaths += $$eval(QT.$${dep}.rpath_link) $$eval(QT.$${dep}.rpath_link_private) - pluginpath += $$eval(QT.$${dep}.plugin_path) $$eval(QT.$${dep}.plugins) } privdep -= $$pubdep for(dep, privdep): \ # Add our private dependencies' lib paths as new link-rpaths @@ -58,7 +56,6 @@ } else { module_rpathlink_priv = } - pluginpath = $$unique(pluginpath) # Create a forwarding module .pri file MODULE_FWD_PRI_CONT = \ @@ -71,7 +68,6 @@ $$module_rpathlink \ $$module_rpathlink_priv \ "QT.$${MODULE}.rpath = $$MODULE_INSTALL_LIBS" \ - "QT.$${MODULE}.plugin_path = $$val_escape(pluginpath)" \ "include($$MODULE_PRI)" write_file($$MODULE_FWD_PRI, MODULE_FWD_PRI_CONT)|error("Aborting.") touch($$MODULE_FWD_PRI, $$MODULE_PRI) From 4a9ffb5c9ee3f2b307fd9dc794d1467ed03f9bdb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 23 Oct 2012 22:15:43 +0200 Subject: [PATCH 059/134] centralize module directory calculation Change-Id: I5db529676b3287013008f28623a541fee1cde6a0 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_build_paths.prf | 25 +++++++++++++++++++++++++ mkspecs/features/qt_module.prf | 20 +------------------- mkspecs/features/qt_module_fwdpri.prf | 11 +---------- mkspecs/features/qt_module_headers.prf | 6 +----- mkspecs/features/qt_tool.prf | 15 +-------------- 5 files changed, 29 insertions(+), 48 deletions(-) create mode 100644 mkspecs/features/qt_build_paths.prf diff --git a/mkspecs/features/qt_build_paths.prf b/mkspecs/features/qt_build_paths.prf new file mode 100644 index 00000000000..75b83c0a5a6 --- /dev/null +++ b/mkspecs/features/qt_build_paths.prf @@ -0,0 +1,25 @@ +# Find the module's source root dir. +MODULE_PROFILE_DIR = $$_PRO_FILE_PWD_ +for(ever) { + exists($$MODULE_PROFILE_DIR/sync.profile):break() + nmpri = $$dirname(MODULE_PROFILE_DIR) + equals(nmpri, $$MODULE_PROFILE_DIR):error("No sync.profile found. This does not look like a Qt module source tree.") + MODULE_PROFILE_DIR = $$nmpri + unset(nmpri) +} + +isEmpty(MODULE_BASE_DIR): MODULE_BASE_DIR = $$MODULE_PROFILE_DIR +isEmpty(MODULE_BASE_OUTDIR): MODULE_BASE_OUTDIR = $$shadowed($$MODULE_BASE_DIR) +isEmpty(MODULE_QMAKE_OUTDIR): MODULE_QMAKE_OUTDIR = $$MODULE_BASE_OUTDIR + +QTDIR = $$[QT_HOST_PREFIX] +exists($$QTDIR/.qmake.cache) { + mod_component_base = $$QTDIR + mod_qmake_base = $$QTDIR +} else { + mod_component_base = $$MODULE_BASE_OUTDIR + mod_qmake_base = $$MODULE_QMAKE_OUTDIR +} +# Permit modules to enforce being built outside QTDIR. +force_independent: mod_component_base = $$MODULE_BASE_OUTDIR + diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index 23541930e31..ac9852b0e8f 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -32,19 +32,7 @@ else: \ MODULE_DEFINE = QT_$${ucmodule}_LIB MODULE_DEFINES = $$MODULE_DEFINE $$MODULE_DEFINES -# Find the module's source root dir. -MODULE_PROFILE_DIR = $$_PRO_FILE_PWD_ -for(ever) { - exists($$MODULE_PROFILE_DIR/sync.profile):break() - nmpri = $$dirname(MODULE_PROFILE_DIR) - equals(nmpri, $$MODULE_PROFILE_DIR):error("No sync.profile found. This does not look like a Qt module source tree.") - MODULE_PROFILE_DIR = $$nmpri - unset(nmpri) -} - -isEmpty(MODULE_BASE_DIR): MODULE_BASE_DIR = $$MODULE_PROFILE_DIR -isEmpty(MODULE_BASE_OUTDIR): MODULE_BASE_OUTDIR = $$shadowed($$MODULE_BASE_DIR) -isEmpty(MODULE_QMAKE_OUTDIR): MODULE_QMAKE_OUTDIR = $$MODULE_BASE_OUTDIR +load(qt_build_paths) # This check will be removed soon. Weird indentation to avoid reindenting the code later. !isEmpty(MODULE_PRI) { @@ -123,12 +111,6 @@ CONFIG -= fix_output_dirs !isEmpty(QMAKE_DOCS) { doc_subdir = doc - QTDIR = $$[QT_HOST_PREFIX] - !force_independent:exists($$QTDIR/.qmake.cache): \ - mod_component_base = $$QTDIR - else: \ - mod_component_base = $$MODULE_BASE_OUTDIR - unset(QMAKE_DOCS_INDEX) QMAKE_DOCS_OUTPUTDIR = $$mod_component_base/$$doc_subdir/qt$${MODULE} for(qmod, QMAKEMODULES): \ diff --git a/mkspecs/features/qt_module_fwdpri.prf b/mkspecs/features/qt_module_fwdpri.prf index 9a0fd360193..d62092cf6c9 100644 --- a/mkspecs/features/qt_module_fwdpri.prf +++ b/mkspecs/features/qt_module_fwdpri.prf @@ -1,15 +1,6 @@ !build_pass { - QTDIR = $$[QT_HOST_PREFIX] - exists($$QTDIR/.qmake.cache) { - mod_component_base = $$QTDIR - mod_qmake_base = $$QTDIR - } else { - mod_component_base = $$MODULE_BASE_OUTDIR - mod_qmake_base = $$MODULE_QMAKE_OUTDIR - } - # Permit modules to enforce being built outside QTDIR. - force_independent: mod_component_base = $$MODULE_BASE_OUTDIR + load(qt_build_paths) isEmpty(MODULE_INSTALL_LIBS): MODULE_INSTALL_LIBS = $$[QT_INSTALL_LIBS/raw] diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf index 0340f234c55..7c9940b698d 100644 --- a/mkspecs/features/qt_module_headers.prf +++ b/mkspecs/features/qt_module_headers.prf @@ -1,8 +1,4 @@ -QTDIR = $$[QT_HOST_PREFIX] -!force_independent:exists($$QTDIR/.qmake.cache): \ - mod_component_base = $$QTDIR -else: \ - mod_component_base = $$MODULE_BASE_OUTDIR +load(qt_build_paths) !build_pass { qtPrepareTool(QMAKE_SYNCQT, syncqt) diff --git a/mkspecs/features/qt_tool.prf b/mkspecs/features/qt_tool.prf index 01a26b238ec..13caa28a49d 100644 --- a/mkspecs/features/qt_tool.prf +++ b/mkspecs/features/qt_tool.prf @@ -16,20 +16,7 @@ INSTALLS += target MODULE_DEPENDS = $$replace(QT, -private$, ) - # Find the module's source root dir. - MODULE_PROFILE_DIR = $$_PRO_FILE_PWD_ - for(ever) { - exists($$MODULE_PROFILE_DIR/sync.profile):break() - nmpri = $$dirname(MODULE_PROFILE_DIR) - equals(nmpri, $$MODULE_PROFILE_DIR): \ - error("No sync.profile found. This does not look like a Qt module source tree.") - MODULE_PROFILE_DIR = $$nmpri - unset(nmpri) - } - - isEmpty(MODULE_BASE_DIR): MODULE_BASE_DIR = $$MODULE_PROFILE_DIR - MODULE_BASE_OUTDIR = $$shadowed($$MODULE_BASE_DIR) - isEmpty(MODULE_QMAKE_OUTDIR): MODULE_QMAKE_OUTDIR = $$MODULE_BASE_OUTDIR + load(qt_build_paths) load(resolve_target) cmd = $$shell_path($$QMAKE_RESOLVED_TARGET) From 103ddce67a6d3863caa3ff4466cd8ea7d844a165 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 23 Oct 2012 22:19:53 +0200 Subject: [PATCH 060/134] kill $$mod_component_base & $$mod_qmake_base use $$MODULE_BASE_OUTDIR & $$MODULE_QMAKE_OUTDIR directly. this is a no-op, except that now module pris will be built in qtbase for all modules when building without -prefix - which is only consistent with all other artifacts. Change-Id: I2965b2c7a15aa9e82ba6017f5f4c0daa14b6e6fe Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_build_paths.prf | 12 ++++-------- mkspecs/features/qt_module.prf | 2 +- mkspecs/features/qt_module_fwdpri.prf | 12 ++++++------ mkspecs/features/qt_module_headers.prf | 6 +++--- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/mkspecs/features/qt_build_paths.prf b/mkspecs/features/qt_build_paths.prf index 75b83c0a5a6..62a5a801f3b 100644 --- a/mkspecs/features/qt_build_paths.prf +++ b/mkspecs/features/qt_build_paths.prf @@ -14,12 +14,8 @@ isEmpty(MODULE_QMAKE_OUTDIR): MODULE_QMAKE_OUTDIR = $$MODULE_BASE_OUTDIR QTDIR = $$[QT_HOST_PREFIX] exists($$QTDIR/.qmake.cache) { - mod_component_base = $$QTDIR - mod_qmake_base = $$QTDIR -} else { - mod_component_base = $$MODULE_BASE_OUTDIR - mod_qmake_base = $$MODULE_QMAKE_OUTDIR + # Permit modules to enforce being built outside QTDIR ... + !force_independent: MODULE_BASE_OUTDIR = $$QTDIR + # ... though this sort of breaks the idea. + MODULE_QMAKE_OUTDIR = $$QTDIR } -# Permit modules to enforce being built outside QTDIR. -force_independent: mod_component_base = $$MODULE_BASE_OUTDIR - diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index ac9852b0e8f..878867099a9 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -112,7 +112,7 @@ CONFIG -= fix_output_dirs doc_subdir = doc unset(QMAKE_DOCS_INDEX) - QMAKE_DOCS_OUTPUTDIR = $$mod_component_base/$$doc_subdir/qt$${MODULE} + QMAKE_DOCS_OUTPUTDIR = $$MODULE_BASE_OUTDIR/$$doc_subdir/qt$${MODULE} for(qmod, QMAKEMODULES): \ QMAKE_DOCS_INDEX += $$section(qmod, /, 0, -3)/$$doc_subdir diff --git a/mkspecs/features/qt_module_fwdpri.prf b/mkspecs/features/qt_module_fwdpri.prf index d62092cf6c9..17c0ba20eec 100644 --- a/mkspecs/features/qt_module_fwdpri.prf +++ b/mkspecs/features/qt_module_fwdpri.prf @@ -4,7 +4,7 @@ isEmpty(MODULE_INSTALL_LIBS): MODULE_INSTALL_LIBS = $$[QT_INSTALL_LIBS/raw] - MODULE_FWD_PRI = $$mod_qmake_base/mkspecs/modules/qt_$${MODULE}.pri + MODULE_FWD_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules/qt_$${MODULE}.pri # -rpath-link is used by the linker to find depedencies of dynamic # libraries which were NOT specified on the command line. @@ -51,11 +51,11 @@ # Create a forwarding module .pri file MODULE_FWD_PRI_CONT = \ "QT_MODULE_BASE = $$MODULE_BASE_DIR" \ - "QT_MODULE_BIN_BASE = $$mod_component_base/bin" \ - "QT_MODULE_INCLUDE_BASE = $$mod_component_base/include" \ - "QT_MODULE_IMPORT_BASE = $$mod_component_base/imports" \ - "QT_MODULE_LIB_BASE = $$mod_component_base/lib" \ - "QT_MODULE_PLUGIN_BASE = $$mod_component_base/plugins" \ + "QT_MODULE_BIN_BASE = $$MODULE_BASE_OUTDIR/bin" \ + "QT_MODULE_INCLUDE_BASE = $$MODULE_BASE_OUTDIR/include" \ + "QT_MODULE_IMPORT_BASE = $$MODULE_BASE_OUTDIR/imports" \ + "QT_MODULE_LIB_BASE = $$MODULE_BASE_OUTDIR/lib" \ + "QT_MODULE_PLUGIN_BASE = $$MODULE_BASE_OUTDIR/plugins" \ $$module_rpathlink \ $$module_rpathlink_priv \ "QT.$${MODULE}.rpath = $$MODULE_INSTALL_LIBS" \ diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf index 7c9940b698d..b1918bd67da 100644 --- a/mkspecs/features/qt_module_headers.prf +++ b/mkspecs/features/qt_module_headers.prf @@ -4,13 +4,13 @@ load(qt_build_paths) qtPrepareTool(QMAKE_SYNCQT, syncqt) contains(QT_CONFIG, private_tests): \ # -developer-build QMAKE_SYNCQT += -check-includes - QMAKE_SYNCQT += -module $$TARGET -mkspecsdir $$[QT_HOST_DATA/get]/mkspecs -outdir $$mod_component_base $$MODULE_BASE_DIR + QMAKE_SYNCQT += -module $$TARGET -mkspecsdir $$[QT_HOST_DATA/get]/mkspecs -outdir $$MODULE_BASE_OUTDIR $$MODULE_BASE_DIR !silent: message($$QMAKE_SYNCQT) system($$QMAKE_SYNCQT)|error("Failed to run: $$QMAKE_SYNCQT") } #load up the headers info -include($$mod_component_base/include/$$TARGET/headers.pri, "", true) +include($$MODULE_BASE_OUTDIR/include/$$TARGET/headers.pri, "", true) lctarget = $$lower($$TARGET) uctarget = $$upper($$TARGET) @@ -51,7 +51,7 @@ count(MODULE_VERSION_HEADER, 1) { } # Create a module master header -MODULE_MASTER_HEADER = $$mod_component_base/include/$$TARGET/$$TARGET +MODULE_MASTER_HEADER = $$MODULE_BASE_OUTDIR/include/$$TARGET/$$TARGET !build_pass { MODULE_MASTER_HEADER_CONT = \ "/* This file was generated by qmake with the info from $${_PRO_FILE_}. */" \ From 4010c702692de3986e672c6a5ce0ce60f36a2492 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 24 Oct 2012 15:03:49 +0200 Subject: [PATCH 061/134] namespace "module" pri files we now have tool and soon plugin pri files. make them easily distinguishable. Change-Id: I8904e4182227a78060121e8712446bc43b1dd185 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_module.prf | 2 +- mkspecs/features/qt_module_fwdpri.prf | 2 +- mkspecs/features/qt_tool.prf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index 878867099a9..79a4d80279d 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -41,7 +41,7 @@ load(qt_build_paths) exists($$MODULE_PRI)|error("Specified module pri file $$MODULE_PRI does not exist.") } else { -MODULE_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules-inst/qt_$${MODULE}.pri +MODULE_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules-inst/qt_lib_$${MODULE}.pri !build_pass { diff --git a/mkspecs/features/qt_module_fwdpri.prf b/mkspecs/features/qt_module_fwdpri.prf index 17c0ba20eec..4c3a4b433fb 100644 --- a/mkspecs/features/qt_module_fwdpri.prf +++ b/mkspecs/features/qt_module_fwdpri.prf @@ -4,7 +4,7 @@ isEmpty(MODULE_INSTALL_LIBS): MODULE_INSTALL_LIBS = $$[QT_INSTALL_LIBS/raw] - MODULE_FWD_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules/qt_$${MODULE}.pri + MODULE_FWD_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules/qt_lib_$${MODULE}.pri # -rpath-link is used by the linker to find depedencies of dynamic # libraries which were NOT specified on the command line. diff --git a/mkspecs/features/qt_tool.prf b/mkspecs/features/qt_tool.prf index 13caa28a49d..c17e90816e3 100644 --- a/mkspecs/features/qt_tool.prf +++ b/mkspecs/features/qt_tool.prf @@ -22,7 +22,7 @@ INSTALLS += target cmd = $$shell_path($$QMAKE_RESOLVED_TARGET) qtAddTargetEnv(cmd) - TOOL_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules/qt_$${MODULE}.pri + TOOL_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules/qt_tool_$${MODULE}.pri TOOL_PRI_CONT = "QT_TOOL.$${MODULE}.command = $$val_escape(cmd)" write_file($$TOOL_PRI, TOOL_PRI_CONT)|error("Aborting.") From f0ee55c00a51a2677477de18405b4f61c9142157 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 24 Oct 2012 13:43:13 +0200 Subject: [PATCH 062/134] VERSION makes no sense for plugins Change-Id: I7af058eec1c5a0fdbd9848d2dc2f6bd76ca4747e Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_plugin.prf | 1 - 1 file changed, 1 deletion(-) diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf index 02099102031..6c12a9c9b3c 100644 --- a/mkspecs/features/qt_plugin.prf +++ b/mkspecs/features/qt_plugin.prf @@ -1,5 +1,4 @@ TEMPLATE = lib -isEmpty(VERSION):VERSION = $$QT_VERSION CONFIG += qt plugin if(win32|mac):!macx-xcode { From b493e1ec6f6dd9fffdbb9dc1a8ecedf2e72f3d2e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 24 Oct 2012 14:03:47 +0200 Subject: [PATCH 063/134] introduce tool_plugin CONFIG flag while plugins for libraries need to follow the -debug-and-release switch, plugins for tools must follow the single-config approach of tools. Change-Id: I8a79e98034d2ff8b5d4e6191a9143c9472a5aa02 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_plugin.prf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf index 6c12a9c9b3c..b6036dda42b 100644 --- a/mkspecs/features/qt_plugin.prf +++ b/mkspecs/features/qt_plugin.prf @@ -1,7 +1,9 @@ TEMPLATE = lib CONFIG += qt plugin -if(win32|mac):!macx-xcode { +tool_plugin { + !build_pass:contains(QT_CONFIG, build_all): CONFIG += release +} else:if(win32|mac):!macx-xcode { contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release contains(QT_CONFIG, build_all):CONFIG += build_all } From d802a0019895207e719ed9a51612735d11970887 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 26 Oct 2012 19:59:09 +0200 Subject: [PATCH 064/134] let qt_tool.prf set up DESTDIR Change-Id: Ie30066566fe25859b2a661970b11a58e69361b1d Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_tool.prf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkspecs/features/qt_tool.prf b/mkspecs/features/qt_tool.prf index c17e90816e3..27753f26ddc 100644 --- a/mkspecs/features/qt_tool.prf +++ b/mkspecs/features/qt_tool.prf @@ -1,5 +1,8 @@ TEMPLATE = app +load(qt_build_paths) +DESTDIR = $$MODULE_BASE_OUTDIR/bin + CONFIG += qt warn_on console isEmpty(QMAKE_INFO_PLIST): CONFIG -= app_bundle From f05a392f3ea70d2d446bb3a0bc826ef6d60f1c3b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 29 Oct 2012 11:18:06 +0100 Subject: [PATCH 065/134] fix tool invocation for -prefix + -framework builds on macx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit set DYLD_FRAMEWORK_PATH instead of DYLD_LIBRARY_PATH Change-Id: I9849f12063b8c7a45d040c087f4611c3a48180b8 Reviewed-by: Johanna Äijälä Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_functions.prf | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index f8922e68efd..ce320281388 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -215,14 +215,18 @@ defineTest(qtAddTargetEnv) { for(rpath, QT.$${dep}.rpath_link): \ deppath += $$shell_path($$rpath) } - equals(QMAKE_HOST.os, Windows): \ + equals(QMAKE_HOST.os, Windows) { deppath.name = PATH - else:contains(QMAKE_HOST.os, Linux|FreeBSD): \ + } else:contains(QMAKE_HOST.os, Linux|FreeBSD) { deppath.name = LD_LIBRARY_PATH - else:equals(QMAKE_HOST.os, Darwin): \ - deppath.name = DYLD_LIBRARY_PATH - else: \ + } else:equals(QMAKE_HOST.os, Darwin) { + contains(QT_CONFIG, qt_framework): \ + deppath.name = DYLD_FRAMEWORK_PATH + else: \ + deppath.name = DYLD_LIBRARY_PATH + } else { error("Operating system not supported.") + } deppath.value = $$unique(deppath) deppath.CONFIG = prepend From 3a333f2d92a44feba017c7951049e89adbbda686 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 27 Oct 2012 09:11:36 +0300 Subject: [PATCH 066/134] QSyntaxHighlighter: minor code de-duplication The (r.start != -1) case is equal to (i == formatChanges.count()) case in the loop; no need to exit the loop just to do exactly what it did. Change-Id: I4129d8012399895c2fce70b26716ca5aeadee79c Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qsyntaxhighlighter.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 7baf55caea0..f183e1eb203 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -119,18 +119,14 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() formatsChanged = true; } - QTextCharFormat emptyFormat; - - QTextLayout::FormatRange r; - r.start = -1; - int i = 0; while (i < formatChanges.count()) { + QTextLayout::FormatRange r; - while (i < formatChanges.count() && formatChanges.at(i) == emptyFormat) + while (i < formatChanges.count() && formatChanges.at(i) == r.format) ++i; - if (i >= formatChanges.count()) + if (i == formatChanges.count()) break; r.start = i; @@ -139,9 +135,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() while (i < formatChanges.count() && formatChanges.at(i) == r.format) ++i; - if (i >= formatChanges.count()) - break; - + Q_ASSERT(i <= formatChanges.count()); r.length = i - r.start; if (preeditAreaLength != 0) { @@ -151,21 +145,6 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() r.length += preeditAreaLength; } - ranges << r; - formatsChanged = true; - r.start = -1; - } - - if (r.start != -1) { - r.length = formatChanges.count() - r.start; - - if (preeditAreaLength != 0) { - if (r.start >= preeditAreaStart) - r.start += preeditAreaLength; - else if (r.start + r.length >= preeditAreaStart) - r.length += preeditAreaLength; - } - ranges << r; formatsChanged = true; } From af437047a2d849d19f8de01b5ecfb685f813d6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sun, 28 Oct 2012 15:36:11 +0100 Subject: [PATCH 067/134] QMap - improve QMap stl-map ctor We can insert directly on the most left-most Node. We always enforce an insert here (unlike the insert call), but that is not a problem since the keys in a std::map are unique. Change-Id: Ib409b90ffc57a5a43dab4a4b08d34f6fdabd057f Reviewed-by: Lars Knoll --- src/corelib/tools/qmap.h | 2 +- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 25 ++++++++++++++++++++ tests/benchmarks/corelib/tools/qmap/main.cpp | 15 ++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index e0b267ce208..d44a79473d7 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -939,7 +939,7 @@ Q_OUTOFLINE_TEMPLATE QMap::QMap(const std::map &other) typename std::map::const_iterator it = other.end(); while (it != other.begin()) { --it; - insert((*it).first, (*it).second); + d->createNode((*it).first, (*it).second, d->begin(), true); // insert on most left node. } } diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 9c53563a5cb..e64496352c8 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -55,6 +55,7 @@ protected: public slots: void init(); private slots: + void ctor(); void count(); void clear(); void beginEnd(); @@ -146,6 +147,30 @@ void tst_QMap::init() MyClass::count = 0; } +void tst_QMap::ctor() +{ + std::map map; + for (int i = 0; i < 100000; ++i) + map.insert(std::pair(i * 3, i * 7)); + + QMap qmap(map); // ctor. + + // Check that we have the same + std::map::iterator j = map.begin(); + QMap::const_iterator i = qmap.constBegin(); + + while (i != qmap.constEnd()) { + QCOMPARE( (*j).first, i.key()); + QCOMPARE( (*j).second, i.value()); + ++i; + ++j; + } + + QCOMPARE( (int) map.size(), qmap.size()); +} + + + void tst_QMap::count() { { diff --git a/tests/benchmarks/corelib/tools/qmap/main.cpp b/tests/benchmarks/corelib/tools/qmap/main.cpp index 4d9833b7a18..c11e54ff1de 100644 --- a/tests/benchmarks/corelib/tools/qmap/main.cpp +++ b/tests/benchmarks/corelib/tools/qmap/main.cpp @@ -62,6 +62,8 @@ private slots: void iteration(); void toStdMap(); void iterator_begin(); + + void ctorStdMap(); }; @@ -189,6 +191,19 @@ void tst_QMap::iterator_begin() } } +void tst_QMap::ctorStdMap() +{ + std::map map; + for (int i = 0; i < 100000; ++i) + map.insert(std::pair(i, i)); + + QBENCHMARK { + QMap qmap(map); + qmap.constBegin(); + } +} + + QTEST_MAIN(tst_QMap) #include "main.moc" From 3e52901641f8b3a1cce95709a2c91be59947673f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 27 Oct 2012 09:22:42 -0700 Subject: [PATCH 068/134] Remove qstandardpaths_json.cpp This implementation is unused. It was part of a platform that will unfortunately not see the light of day. Remove it since no one is maintaining it. Change-Id: I9e675225a32f227739c688608f937df66a14e9a4 Reviewed-by: David Faure (KDE) Reviewed-by: Lars Knoll --- src/corelib/io/io.pri | 2 - src/corelib/io/qstandardpaths_json.cpp | 258 ------------------------- 2 files changed, 260 deletions(-) delete mode 100644 src/corelib/io/qstandardpaths_json.cpp diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 9e89f9fdc0e..174e2a2fbf8 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -118,8 +118,6 @@ win32 { } else { SOURCES += io/qstandardpaths_unix.cpp } - } else:standardpathsjson { - SOURCES += io/qstandardpaths_json.cpp } else:blackberry { SOURCES += io/qstandardpaths_blackberry.cpp } else { diff --git a/src/corelib/io/qstandardpaths_json.cpp b/src/corelib/io/qstandardpaths_json.cpp deleted file mode 100644 index 839cd9e8738..00000000000 --- a/src/corelib/io/qstandardpaths_json.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qstandardpaths.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef QT_NO_STANDARDPATHS - -QT_BEGIN_NAMESPACE - -class QStandardPathsPrivate { -public: - QStandardPathsPrivate() : object(0){} - ~QStandardPathsPrivate() { delete object.load(); } - QAtomicPointer object; -}; - -Q_GLOBAL_STATIC(QStandardPathsPrivate, configCache); - -/*! - \internal - Substitute environment variables in the form ${name} - - The JSON QStandardPaths implementation can be configured on a per user - (or per application) basis through the use of environment variables, - which are evaluated each time a location is queried. This function - performs that evaluation on \a value. No substitution is performed - for undefined variables. - - This slightly underselects according to the 2009-09-20 version of - the GNU setenv(3) manual page: It disallows '}' within the variable - name. ${var}} will look for a variable named "var", not "var}". - */ -static QString substituteEnvVars(const QJsonValue & value) -{ - QString str = value.toString(); - if (str.isEmpty() || !str.contains(QLatin1String("${"))) - return str; - - // optimize for a common case - str.replace(QLatin1String("${HOME}"), QDir::homePath()); - - // Do ${} format environment variable substitution if necessary - // repeat this test because ${HOME} might expand to the empty string - if (!str.isEmpty() && str.contains(QLatin1String("${"))) { - QRegularExpression varRegExp(QLatin1String("\\$\\{([^\\}=]*)\\}")); - QRegularExpressionMatchIterator matchIterator = - varRegExp.globalMatch(str); - while (matchIterator.hasNext()) { - QRegularExpressionMatch match = matchIterator.next(); - QByteArray envValue = - qgetenv(match.captured(1).toLatin1().data()); - if (!envValue.isNull()) { - QString replacement = - QFile::decodeName(envValue); - str.replace(match.captured(0), replacement); - } - } - } - return str; -} - -static void appendOrganizationAndApp(QString &path) -{ - const QString org = QCoreApplication::organizationName(); - if (!org.isEmpty()) - path += QLatin1Char('/') + org; - const QString appName = QCoreApplication::applicationName(); - if (!appName.isEmpty()) - path += QLatin1Char('/') + appName; -} - -QString QStandardPaths::writableLocation(StandardLocation type) -{ - QStringList locations = QStandardPaths::standardLocations(type); - if (locations.isEmpty()) - return QString(); - return locations.first(); -} - -QStringList QStandardPaths::standardLocations(StandardLocation type) -{ - switch (type) { - case HomeLocation: - return QStringList(QDir::homePath()); // set $HOME - case TempLocation: - return QStringList(QDir::tempPath()); // set $TMPDIR - default: - break; - } - - if (isTestModeEnabled()) { - const QString qttestDir = QDir::homePath() + QLatin1String("/.qttest"); - QString path; - switch (type) { - case GenericDataLocation: - case DataLocation: - path = qttestDir + QLatin1String("/share"); - if (type == DataLocation) - appendOrganizationAndApp(path); - return QStringList(path); - case GenericCacheLocation: - case CacheLocation: - path = qttestDir + QLatin1String("/cache"); - if (type == CacheLocation) - appendOrganizationAndApp(path); - return QStringList(path); - case ConfigLocation: - return QStringList(qttestDir + QLatin1String("/config")); - default: - break; - } - } - - - QJsonObject * localConfigObject = configCache()->object.loadAcquire(); - if (localConfigObject == 0) { - QString configHome = QFile::decodeName(qgetenv("PATH_CONFIG_HOME")); - if (configHome.isEmpty()) - configHome = QLatin1String("/etc/user-dirs.json"); - QFile file(configHome); - if (file.open(QIODevice::ReadOnly)) { - QJsonDocument configDoc = QJsonDocument::fromJson(file.readAll()); - if (configDoc.isNull()) - return QStringList(); - - QJsonObject myConfigObject = configDoc.object(); - localConfigObject = new QJsonObject(myConfigObject); - if (!configCache()->object.testAndSetRelease(0, localConfigObject)) { - delete localConfigObject; - localConfigObject = configCache()->object.loadAcquire(); - } - } else { - return QStringList(); - } - } - - QLatin1String key(""); - - switch (type) { - case DocumentsLocation: - key = QLatin1String("DOCUMENTS"); - break; - case PicturesLocation: - key = QLatin1String("PICTURES"); - break; - case MusicLocation: - key = QLatin1String("MUSIC"); - break; - case MoviesLocation: - key = QLatin1String("VIDEOS"); - break; - case DownloadLocation: - key = QLatin1String("DOWNLOAD"); - break; - case ApplicationsLocation: - key = QLatin1String("APPLICATIONS"); - break; - case CacheLocation: - key = QLatin1String("CACHE"); - break; - case GenericCacheLocation: - key = QLatin1String("GENERIC_CACHE"); - break; - case DataLocation: - key = QLatin1String("DATA"); - break; - case GenericDataLocation: - key = QLatin1String("GENERIC_DATA"); - break; - case ConfigLocation: - key = QLatin1String("CONFIG"); - break; - case RuntimeLocation: - key = QLatin1String("RUNTIME"); - break; - case DesktopLocation: - key = QLatin1String("DESKTOP"); - break; - case FontsLocation: - key = QLatin1String("FONTS"); - break; - - default: - return QStringList(); - } - - QJsonObject::const_iterator iter = localConfigObject->constFind(key); - if (iter == localConfigObject->constEnd()) - return QStringList(); - - switch (iter.value().type()) { - case QJsonValue::Array: { - QStringList resultList; - foreach (const QJsonValue &item, iter.value().toArray()) - resultList.append(substituteEnvVars(item)); - return resultList; - } - case QJsonValue::String: - return QStringList(substituteEnvVars(iter.value())); - default: - break; - } - return QStringList(); -} - -QT_END_NAMESPACE - -#endif // QT_NO_STANDARDPATHS From f7893223e84db86dcdd860c625663d7006fcdad6 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 23 Oct 2012 15:31:20 +0200 Subject: [PATCH 069/134] QtNetwork: introduce configure switch to use system proxies by default This option is opt-in (default: no). When configured with "-proxies-system-default", Qt automatically picks up the system proxies. Change-Id: I8cc002f29587854f448d97117b08c43d8eedec76 Reviewed-by: Shane Kearns Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- configure | 21 +++++++++++++++++++++ src/network/kernel/qnetworkproxy.cpp | 3 +++ src/network/socket/socket.pri | 4 ++++ tools/configure/configureapp.cpp | 15 ++++++++++++++- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/configure b/configure index c3e61d63c55..f9e08643e60 100755 --- a/configure +++ b/configure @@ -785,6 +785,7 @@ CFG_JAVASCRIPTCORE_JIT=auto CFG_PKGCONFIG=auto CFG_STACK_PROTECTOR_STRONG=auto CFG_SLOG2=auto +CFG_SYSTEM_PROXIES=no # Target architecture CFG_ARCH= @@ -1003,6 +1004,14 @@ while [ "$#" -gt 0 ]; do VAR=`echo $1 | sed "s,^-\([^-]*\)-.*,\1,"` VAL=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"` ;; + -system-proxies) + VAR=system-proxies + VAL=yes + ;; + -no-system-proxies) + VAR=system-proxies + VAL=no + ;; #Qt Builtin/System style options -no-*|-system-*|-qt-*) VAR=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"` @@ -2090,6 +2099,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + system-proxies) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_SYSTEM_PROXIES="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; *) UNKNOWN_OPT=yes ;; @@ -3291,6 +3307,9 @@ Additional options: OpenGL ES 2, or regular desktop OpenGL. Use es2 for to override auto-detection. + * -no-system-proxies .. Do not use system network proxies by default. + -system-proxies ..... Use system network proxies by default. + $GBN -no-glib ........... Do not compile Glib support. $GBY -glib .............. Compile Glib support. EOF @@ -5454,6 +5473,7 @@ fi [ "$CFG_MAC_HARFBUZZ" = "yes" ] && QT_CONFIG="$QT_CONFIG harfbuzz" [ "$CFG_XCB" = "yes" ] && QT_CONFIG="$QT_CONFIG xcb" [ "$CFG_XINPUT2" = "yes" ] && QT_CONFIG="$QT_CONFIG xinput2" +[ "$CFG_SYSTEM_PROXIES" = "yes" ] && QT_CONFIG="$QT_CONFIG system-proxies" [ '!' -z "$DEFINES" ] && QMakeVar add DEFINES "$DEFINES" [ '!' -z "$L_FLAGS" ] && QMakeVar add LIBS "$L_FLAGS" @@ -6235,6 +6255,7 @@ echo "libudev support ........ $CFG_LIBUDEV" if [ "$XPLATFORM_QNX" = "yes" ]; then echo "SLOG2 support .......... $CFG_SLOG2" fi +echo "Use system proxies ..... $CFG_SYSTEM_PROXIES" if [ "$CFG_OPENGL" = "desktop" ]; then echo "OpenGL support ......... yes (Desktop OpenGL)" diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index adaefac4406..85641895b7b 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -253,6 +253,9 @@ public: , httpSocketEngineHandler(0) #endif { +#ifdef QT_USE_SYSTEM_PROXIES + setApplicationProxyFactory(new QSystemConfigurationProxyFactory); +#endif #ifndef QT_NO_SOCKS5 socks5SocketEngineHandler = new QSocks5SocketEngineHandler(); #endif diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri index 3429275a673..0204a92999b 100644 --- a/src/network/socket/socket.pri +++ b/src/network/socket/socket.pri @@ -60,3 +60,7 @@ integrity: { DEFINES += QT_LOCALSOCKET_TCP } + +contains(QT_CONFIG, system-proxies) { + DEFINES += QT_USE_SYSTEM_PROXIES +} diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 1b75def13f3..113ebf76927 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -236,6 +236,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "QT_CUPS" ] = "auto"; dictionary[ "CFG_GCC_SYSROOT" ] = "yes"; dictionary[ "SLOG2" ] = "no"; + dictionary[ "SYSTEM_PROXIES" ] = "no"; //Only used when cross compiling. dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg"; @@ -877,6 +878,10 @@ void Configure::parseCmdLine() dictionary[ "SLOG2" ] = "no"; } else if (configCmdLine.at(i) == "-slog2") { dictionary[ "SLOG2" ] = "yes"; + } else if (configCmdLine.at(i) == "-no-system-proxies") { + dictionary[ "SYSTEM_PROXIES" ] = "no"; + } else if (configCmdLine.at(i) == "-system-proxies") { + dictionary[ "SYSTEM_PROXIES" ] = "yes"; } // Work around compiler nesting limitation @@ -1682,6 +1687,10 @@ bool Configure::displayHelp() desc("QT_INSTALL_SETTINGS", "auto", "-sysconfdir ", "Settings used by Qt programs will be looked for in\n.\n"); + desc("SYSTEM_PROXIES", "yes", "-system-proxies", "Use system network proxies by default."); + desc("SYSTEM_PROXIES", "no", "-no-system-proxies", "Do not use system network proxies by default.\n"); + + #if !defined(EVAL) desc( "-qtnamespace ", "Wraps all Qt library code in 'namespace name {...}'."); desc( "-qtlibinfix ", "Renames all Qt* libs to Qt*.\n"); @@ -2560,6 +2569,9 @@ void Configure::generateOutputVars() if (dictionary[ "V8SNAPSHOT" ] == "yes") qtConfig += "v8snapshot"; + if (dictionary[ "SYSTEM_PROXIES" ] == "yes") + qtConfig += "system-proxies"; + // Add config levels -------------------------------------------- QStringList possible_configs = QStringList() << "minimal" @@ -3328,7 +3340,8 @@ void Configure::displayConfig() sout << "QtDBus support.............." << dictionary[ "DBUS" ] << endl; sout << "QtWidgets module support...." << dictionary[ "WIDGETS" ] << endl; sout << "QML debugging..............." << dictionary[ "QML_DEBUG" ] << endl; - sout << "DirectWrite support........." << dictionary[ "DIRECTWRITE" ] << endl << endl; + sout << "DirectWrite support........." << dictionary[ "DIRECTWRITE" ] << endl; + sout << "Use system proxies.........." << dictionary[ "SYSTEM_PROXIES" ] << endl << endl; sout << "Third Party Libraries:" << endl; sout << " ZLIB support............" << dictionary[ "ZLIB" ] << endl; From d3c1a9f38784c8d3a439517cc971320d74613869 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Fri, 19 Oct 2012 20:54:32 +1100 Subject: [PATCH 070/134] Define additional math.h constants if not already defined The M_E, M_PI_2, etc. math.h constants are not defined with MinGW-w64 GCC when compiling with -std=c++11. Task-number: QTBUG-27561 Change-Id: I2267c170dd3788abc9c37425a9be514bbae51f5a Reviewed-by: Konstantin Ritt Reviewed-by: Alexey Pavlov Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmath.h | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index e76c2da57c6..c5aa90e519b 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -192,10 +192,58 @@ inline qreal qPow(qreal x, qreal y) return pow(x, y); } +#ifndef M_E +#define M_E (2.7182818284590452354) +#endif + +#ifndef M_LOG2E +#define M_LOG2E (1.4426950408889634074) +#endif + +#ifndef M_LOG10E +#define M_LOG10E (0.43429448190325182765) +#endif + +#ifndef M_LN2 +#define M_LN2 (0.69314718055994530942) +#endif + +#ifndef M_LN10 +#define M_LN10 (2.30258509299404568402) +#endif + #ifndef M_PI #define M_PI (3.14159265358979323846) #endif +#ifndef M_PI_2 +#define M_PI_2 (1.57079632679489661923) +#endif + +#ifndef M_PI_4 +#define M_PI_4 (0.78539816339744830962) +#endif + +#ifndef M_1_PI +#define M_1_PI (0.31830988618379067154) +#endif + +#ifndef M_2_PI +#define M_2_PI (0.63661977236758134308) +#endif + +#ifndef M_2_SQRTPI +#define M_2_SQRTPI (1.12837916709551257390) +#endif + +#ifndef M_SQRT2 +#define M_SQRT2 (1.41421356237309504880) +#endif + +#ifndef M_SQRT1_2 +#define M_SQRT1_2 (0.70710678118654752440) +#endif + inline qreal qFastSin(qreal x) { int si = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower. From 6497649730daeab5d3dfac7e806105e99a237656 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 18 Oct 2012 18:51:20 +0200 Subject: [PATCH 071/134] Check for both A and P when converting QDateTime to string. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hasUnquotedAP currently only checks for an a or A, which is wrong according to both the toString documentation and the comments for hasUnquotedAP. Change-Id: I03015734b846fe761085cf8f8fca2b29210cff97 Reviewed-by: Jon Severinsson Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qdatetime.cpp | 3 ++- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 67dbbef9ad7..12f93359903 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3743,7 +3743,8 @@ static bool hasUnquotedAP(const QString &f) for (int i=0; i Date: Sat, 27 Oct 2012 19:28:25 -0700 Subject: [PATCH 072/134] Use -ffunction-sections in libbootstrap.a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that the linker discards unused functions too. Some of our .cpp are way too big Change-Id: I1a2685be6a5e7fd3cf34f18d545483c63c2343dd Reviewed-by: Olivier Goffart Reviewed-by: Jędrzej Nowacki --- src/tools/bootstrap/bootstrap.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 19c0005bcc9..07c4a10573d 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -114,6 +114,7 @@ macx: { ../../corelib/kernel/qcore_mac.cpp LIBS += -framework CoreServices } +*-g++*: QMAKE_CXXFLAGS += -ffunction-sections if(contains(QT_CONFIG, zlib)|cross_compile):include(../../3rdparty/zlib.pri) else:include(../../3rdparty/zlib_dependency.pri) From adb156e4dd64609ba6c0b172e9c428a79e306a7c Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Wed, 17 Oct 2012 10:16:07 +0200 Subject: [PATCH 073/134] Cocoa: Disable touch events. Enabling touch events has a negative impact on overall performance. In particular, enabling touch events seems to disable scroll event compression, resulting scroll processing lag. Until we find a solution where we can have both proper scrolling and touch events we choose scrolling over touch events. Applications that disagree can enable touch events manually: NSView *qtView = (NSView *)QGuiApplication::platformNativeInterface()-> nativeResourceForWindow("nsview", qtWindow); [qtView setAcceptsTouchEvents:YES]; Change-Id: I85cdd6e8c8ed8685c6cd5418c89fed6af02887cd Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index b9ad35600eb..d6b4ee68a90 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -703,11 +703,6 @@ void QCocoaWindow::setNSWindow(NSWindow *window) name:nil // Get all notifications object:m_nsWindow]; - // ### Accept touch events by default. - // Beware that enabling touch events has a negative impact on the overall performance. - // We probably need a QWindowSystemInterface API to enable/disable touch events. - [m_contentView setAcceptsTouchEvents:YES]; - [window setContentView:m_contentView]; } From edfb24009cf22a0f0277be5d595b48ef9af9c3bf Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 29 Oct 2012 13:12:13 +0100 Subject: [PATCH 074/134] Mac: Correct writingSystem check value for Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For simplified and traditional Chinese. Based on the Apple doc: Internationalization Programming Topics - Language and Locale Designations. Task-number: QTBUG-27130 Change-Id: I677563525edd607583561be20f4dbed24b2443a5 Reviewed-by: Jiang Jiang Reviewed-by: Morten Johan Sørvig --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 8306a47e4f2..66ca2d37fa9 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -79,8 +79,8 @@ static const char *languageForWritingSystem[] = { "my", // Myanmar "ka", // Georgian "km", // Khmer - "zh-cn", // SimplifiedChinese - "zh-tw", // TraditionalChinese + "zh-Hans", // SimplifiedChinese + "zh-Hant", // TraditionalChinese "ja", // Japanese "ko", // Korean "vi", // Vietnamese From d402d0c3e3f177976d31bd7822a735e535562871 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 24 Oct 2012 17:00:08 +0200 Subject: [PATCH 075/134] Bring back native dialogs for Windows XP. The CLSID_FileOpenDialog, CLSID_FileSaveDialog-based dialogs are available from Windows Vista on only, the old Shell-function based ones are required for Windows XP. Add a command line argument to switch dialog types. Extract some common functionality for both dialog types. Task-number: QTBUG-27621 Change-Id: I224c5c4574c2ff54daf354f00d3d1f82abc6f459 Reviewed-by: Miikka Heikkinen --- .../windows/qwindowsdialoghelpers.cpp | 504 ++++++++++++++++-- .../platforms/windows/qwindowsintegration.cpp | 6 + .../platforms/windows/qwindowsintegration.h | 4 +- 3 files changed, 468 insertions(+), 46 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 87cb224d496..9e5578d35de 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -43,12 +43,9 @@ #include "qwindowscontext.h" #include "qwindowswindow.h" +#include "qwindowsintegration.h" #include "qwindowstheme.h" // Color conversion helpers -#include -#include -#include - #include #include @@ -60,6 +57,7 @@ #include #include #include +#include #include #include "qtwindows_additional.h" @@ -384,9 +382,10 @@ void eatMouseMove() \class QWindowsNativeDialogBase \brief Base class for Windows native dialogs. - Base clases for native dialogs that mimick the - behaviour of their QDialog counterparts as close as - possible. + Base classes for native dialogs (using the CLSID-based + dialog interfaces "IFileDialog", etc. available from Windows + Vista on) that mimick the behaviour of their QDialog + counterparts as close as possible. A major difference is that there is only an exec(), which is a modal, blocking call; there is no non-blocking show(). @@ -862,12 +861,45 @@ int QWindowsNativeFileDialogBase::itemPaths(IShellItemArray *items, return itemCount; } -// Copy a string to an Utf16 buffer. -static inline void toBuffer(const QString &what, WCHAR **ptr) +// Split a list of name filters into description and actual filters +struct FilterSpec { - const int length = 1 + what.size(); - memcpy(*ptr, what.utf16(), length * sizeof(WCHAR)); - *ptr += length; + QString description; + QString filter; +}; + +static QList filterSpecs(const QStringList &filters, + bool hideFilterDetails, + int *totalStringLength) +{ + QList result; + result.reserve(filters.size()); + *totalStringLength = 0; + + const QRegExp filterSeparatorRE(QStringLiteral("[;\\s]+")); + const QString separator = QStringLiteral(";"); + Q_ASSERT(filterSeparatorRE.isValid()); + // Split filter specification as 'Texts (*.txt[;] *.doc)' + // into description and filters specification as '*.txt;*.doc' + foreach (const QString &filterString, filters) { + const int openingParenPos = filterString.lastIndexOf(QLatin1Char('(')); + const int closingParenPos = openingParenPos != -1 ? + filterString.indexOf(QLatin1Char(')'), openingParenPos + 1) : -1; + FilterSpec filterSpec; + filterSpec.filter = closingParenPos == -1 ? + QString(QLatin1Char('*')) : + filterString.mid(openingParenPos + 1, closingParenPos - openingParenPos - 1).trimmed(); + filterSpec.filter.replace(filterSeparatorRE, separator); + filterSpec.description = filterString; + if (hideFilterDetails && openingParenPos != -1) { // Do not show pattern in description + filterSpec.description.truncate(openingParenPos); + while (filterSpec.description.endsWith(QLatin1Char(' '))) + filterSpec.description.truncate(filterSpec.description.size() - 1); + } + *totalStringLength += filterSpec.filter.size() + filterSpec.description.size(); + result.push_back(filterSpec); + } + return result; } void QWindowsNativeFileDialogBase::setNameFilters(const QStringList &filters) @@ -875,48 +907,30 @@ void QWindowsNativeFileDialogBase::setNameFilters(const QStringList &filters) /* Populates an array of COMDLG_FILTERSPEC from list of filters, * store the strings in a flat, contiguous buffer. */ m_nameFilters = filters; - const int size = filters.size(); int totalStringLength = 0; - for (int i = 0; i < size; ++i) - totalStringLength += filters.at(i).size(); + const QList specs = filterSpecs(filters, m_hideFiltersDetails, &totalStringLength); + const int size = specs.size(); - QScopedArrayPointer buffer(new WCHAR[totalStringLength * 2 + 2 * size]); + QScopedArrayPointer buffer(new WCHAR[totalStringLength + 2 * size]); QScopedArrayPointer comFilterSpec(new COMDLG_FILTERSPEC[size]); const QString matchesAll = QStringLiteral(" (*)"); - const QRegExp filterSeparatorRE(QStringLiteral("[;\\s]+")); - const QString separator = QStringLiteral(";"); - Q_ASSERT(filterSeparatorRE.isValid()); - WCHAR *ptr = buffer.data(); // Split filter specification as 'Texts (*.txt[;] *.doc)' // into description and filters specification as '*.txt;*.doc' + for (int i = 0; i < size; ++i) { - QString filterString = filters.at(i); - const int openingParenPos = filterString.lastIndexOf(QLatin1Char('(')); - const int closingParenPos = openingParenPos != -1 ? - filterString.indexOf(QLatin1Char(')'), openingParenPos + 1) : -1; - QString filterSpec = closingParenPos == -1 ? - QString(QLatin1Char('*')) : - filterString.mid(openingParenPos + 1, closingParenPos - openingParenPos - 1).trimmed(); - filterSpec.replace(filterSeparatorRE, separator); - if (m_hideFiltersDetails) { - // Do not show pattern in description - if (openingParenPos != -1) { - filterString.truncate(openingParenPos); - while (filterString.endsWith(QLatin1Char(' '))) - filterString.truncate(filterString.size() - 1); - } - } else { - // Display glitch: 'All files (*)' shows up as 'All files (*) (*)' - if (filterString.endsWith(matchesAll)) - filterString.truncate(filterString.size() - matchesAll.size()); - } + // Display glitch (CLSID only): 'All files (*)' shows up as 'All files (*) (*)' + QString description = specs[i].description; + if (!m_hideFiltersDetails && description.endsWith(matchesAll)) + description.truncate(description.size() - matchesAll.size()); // Add to buffer. comFilterSpec[i].pszName = ptr; - toBuffer(filterString, &ptr); + ptr += description.toWCharArray(ptr); + *ptr++ = 0; comFilterSpec[i].pszSpec = ptr; - toBuffer(filterSpec, &ptr); + ptr += specs[i].filter.toWCharArray(ptr); + *ptr++ = 0; } m_fileDialog->SetFileTypes(size, comFilterSpec.data()); @@ -947,9 +961,23 @@ void QWindowsNativeFileDialogBase::setLabelText(QFileDialogOptions::DialogLabel } } +// Return the index of the selected filter, accounting for QFileDialog +// sometimes stripping the filter specification depending on the +// hideFilterDetails setting. +static int indexOfNameFilter(const QStringList &filters, const QString &needle) +{ + const int index = filters.indexOf(needle); + if (index >= 0) + return index; + for (int i = 0; i < filters.size(); ++i) + if (filters.at(i).startsWith(needle)) + return i; + return -1; +} + void QWindowsNativeFileDialogBase::selectNameFilter(const QString &filter) { - const int index = m_nameFilters.indexOf(filter); + const int index = indexOfNameFilter(m_nameFilters, filter); if (index >= 0) { m_fileDialog->SetFileTypeIndex(index + 1); // one-based. } else { @@ -1270,6 +1298,380 @@ QString QWindowsFileDialogHelper::selectedNameFilter() const return QString(); } +#ifndef Q_OS_WINCE + +/*! + \class QWindowsXpNativeFileDialog + \brief Native Windows directory dialog for Windows XP using SHlib-functions. + + Uses the synchronous GetOpenFileNameW(), GetSaveFileNameW() from ComDlg32 + or SHBrowseForFolder() for directories. + + \internal + \sa QWindowsXpFileDialogHelper + + \ingroup qt-lighthouse-win +*/ + +class QWindowsXpNativeFileDialog : public QWindowsNativeDialogBase +{ + Q_OBJECT +public: + typedef QSharedPointer OptionsPtr; + + static QWindowsXpNativeFileDialog *create(const OptionsPtr &options); + + virtual void setWindowTitle(const QString &t) { m_title = t; } + virtual void exec(HWND owner = 0); + virtual QPlatformDialogHelper::DialogCode result() const { return m_result; } + + void setDirectory(const QString &d) { m_directory = d; } + QString directory() const { return m_directory; } + void selectFile(const QString &f) { m_initialFile = f; } + QStringList selectedFiles() const { return m_selectedFiles; } + void setNameFilters(const QStringList &n) { m_nameFilters = n; } + void selectNameFilter(const QString &f); + QString selectedNameFilter() const { return m_selectedNameFilter; } + + int existingDirCallback(HWND hwnd, UINT uMsg, LPARAM lParam); + +public slots: + virtual void close() {} + +private: + typedef BOOL (APIENTRY *PtrGetOpenFileNameW)(LPOPENFILENAMEW); + typedef BOOL (APIENTRY *PtrGetSaveFileNameW)(LPOPENFILENAMEW); + + explicit QWindowsXpNativeFileDialog(const OptionsPtr &options); + void populateOpenFileName(OPENFILENAME *ofn, HWND owner) const; + QStringList execExistingDir(HWND owner); + QStringList execFileNames(HWND owner, int *selectedFilterIndex) const; + + const OptionsPtr m_options; + QString m_title; + QString m_directory; + QString m_initialFile; + QStringList m_selectedFiles; + QString m_selectedNameFilter; + QStringList m_nameFilters; + QPlatformDialogHelper::DialogCode m_result; + + static PtrGetOpenFileNameW m_getOpenFileNameW; + static PtrGetSaveFileNameW m_getSaveFileNameW; +}; + +QWindowsXpNativeFileDialog::PtrGetOpenFileNameW QWindowsXpNativeFileDialog::m_getOpenFileNameW = 0; +QWindowsXpNativeFileDialog::PtrGetSaveFileNameW QWindowsXpNativeFileDialog::m_getSaveFileNameW = 0; + +QWindowsXpNativeFileDialog *QWindowsXpNativeFileDialog::create(const OptionsPtr &options) +{ + // GetOpenFileNameW() GetSaveFileName() are resolved + // dynamically as not to create a dependency on Comdlg32, which + // is used on XP only. + if (!m_getOpenFileNameW) { + QSystemLibrary library(QStringLiteral("Comdlg32")); + m_getOpenFileNameW = (PtrGetOpenFileNameW)(library.resolve("GetOpenFileNameW")); + m_getSaveFileNameW = (PtrGetSaveFileNameW)(library.resolve("GetSaveFileNameW")); + } + if (m_getOpenFileNameW && m_getSaveFileNameW) + return new QWindowsXpNativeFileDialog(options); + return 0; +} + +QWindowsXpNativeFileDialog::QWindowsXpNativeFileDialog(const OptionsPtr &options) : + m_options(options), m_result(QPlatformDialogHelper::Rejected) +{ + const QStringList nameFilters = m_options->nameFilters(); + if (!nameFilters.isEmpty()) + setNameFilters(nameFilters); + const QString initialDirectory = m_options->initialDirectory(); + if (!initialDirectory.isEmpty()) + setDirectory(initialDirectory); + const QString initialNameFilter = m_options->initiallySelectedNameFilter(); + if (!initialNameFilter.isEmpty()) + selectNameFilter(initialNameFilter); + const QStringList selectedFiles = m_options->initiallySelectedFiles(); + if (!selectedFiles.isEmpty()) + selectFile(selectedFiles.front()); + setWindowTitle(m_options->windowTitle()); +} + +void QWindowsXpNativeFileDialog::selectNameFilter(const QString &f) +{ + const int index = indexOfNameFilter(m_nameFilters, f); + if (index >= 0) + m_selectedNameFilter = m_nameFilters.at(index); +} + +void QWindowsXpNativeFileDialog::exec(HWND owner) +{ + int selectedFilterIndex = -1; + m_selectedFiles = m_options->fileMode() == QFileDialogOptions::DirectoryOnly ? + execExistingDir(owner) : execFileNames(owner, &selectedFilterIndex); + QWindowsDialogs::eatMouseMove(); + if (m_selectedFiles.isEmpty()) { + m_result = QPlatformDialogHelper::Rejected; + emit rejected(); + } else { + if (selectedFilterIndex >= 0 && selectedFilterIndex < m_nameFilters.size()) { + m_selectedNameFilter = m_nameFilters.at(selectedFilterIndex); + } else { + m_selectedNameFilter.clear(); + } + m_directory = QFileInfo(m_selectedFiles.front()).absolutePath(); + m_result = QPlatformDialogHelper::Accepted; + emit accepted(); + } +} + +// Callback for QWindowsNativeXpFileDialog directory dialog. +// MFC Directory Dialog. Contrib: Steve Williams (minor parts from Scott Powers) + +static int CALLBACK xpFileDialogGetExistingDirCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) +{ + QWindowsXpNativeFileDialog *dialog = reinterpret_cast(lpData); + return dialog->existingDirCallback(hwnd, uMsg, lParam); +} + +#ifdef Q_CC_MINGW +typedef ITEMIDLIST *qt_LpItemIdList; +#else +typedef PIDLIST_ABSOLUTE qt_LpItemIdList; +#endif + +int QWindowsXpNativeFileDialog::existingDirCallback(HWND hwnd, UINT uMsg, LPARAM lParam) +{ + switch (uMsg) { + case BFFM_INITIALIZED: + if (!m_initialFile.isEmpty()) + SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(m_initialFile.utf16())); + break; + case BFFM_SELCHANGED: { + wchar_t path[MAX_PATH]; + const bool ok = SHGetPathFromIDList(reinterpret_cast(lParam), path) + && path[0]; + SendMessage(hwnd, BFFM_ENABLEOK, ok ? 1 : 0, 1); + } + break; + } + return 0; +} + +QStringList QWindowsXpNativeFileDialog::execExistingDir(HWND owner) +{ + BROWSEINFO bi; + wchar_t initPath[MAX_PATH]; + initPath[0] = 0; + bi.hwndOwner = owner; + bi.pidlRoot = NULL; + //### This does not seem to be respected? - the dialog always displays "Browse for folder" + bi.lpszTitle = (wchar_t*)m_title.utf16(); + bi.pszDisplayName = initPath; + bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE; + bi.lpfn = xpFileDialogGetExistingDirCallbackProc; + bi.lParam = LPARAM(this); + QStringList selectedFiles; + if (qt_LpItemIdList pItemIDList = SHBrowseForFolder(&bi)) { + wchar_t path[MAX_PATH]; + path[0] = 0; + if (SHGetPathFromIDList(pItemIDList, path) && path[0]) + selectedFiles.push_back(QDir::cleanPath(QString::fromWCharArray(path))); + IMalloc *pMalloc; + if (SHGetMalloc(&pMalloc) == NOERROR) { + pMalloc->Free(pItemIDList); + pMalloc->Release(); + } + } + return selectedFiles; +} + +// Return an allocated wchar_t array from a QString, reserve more memory if desired. +static wchar_t *qStringToWCharArray(const QString &s, size_t reserveSize = 0) +{ + const size_t stringSize = s.size(); + wchar_t *result = new wchar_t[qMax(stringSize + 1, reserveSize)]; + s.toWCharArray(result); + result[stringSize] = 0; + return result; +} + +// Open/Save files +void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND owner) const +{ + ZeroMemory(ofn, sizeof(OPENFILENAME)); + ofn->lStructSize = sizeof(OPENFILENAME); + ofn->hwndOwner = owner; + + // Create a buffer with the filter strings. + int totalStringLength = 0; + QList specs = + filterSpecs(m_options->nameFilters(), m_options->options() & QFileDialogOptions::HideNameFilterDetails, &totalStringLength); + const int size = specs.size(); + wchar_t *ptr = new wchar_t[totalStringLength + 2 * size + 1]; + ofn->lpstrFilter = ptr; + foreach (const FilterSpec &spec, specs) { + ptr += spec.description.toWCharArray(ptr); + *ptr++ = 0; + ptr += spec.filter.toWCharArray(ptr); + *ptr++ = 0; + } + *ptr = 0; + const int nameFilterIndex = indexOfNameFilter(m_nameFilters, m_selectedNameFilter); + if (nameFilterIndex >= 0) + ofn->nFilterIndex = nameFilterIndex + 1; // 1..n based. + // lpstrFile receives the initial selection and is the buffer + // for the target. If it contains any invalid character, the dialog + // will not show. + ofn->nMaxFile = 65535; + const QString initiallySelectedFile = + QDir::toNativeSeparators(m_initialFile).remove(QLatin1Char('<')). + remove(QLatin1Char('>')).remove(QLatin1Char('"')).remove(QLatin1Char('|')); + ofn->lpstrFile = qStringToWCharArray(initiallySelectedFile, ofn->nMaxFile); + ofn->lpstrInitialDir = qStringToWCharArray(QDir::toNativeSeparators(m_directory)); + ofn->lpstrTitle = (wchar_t*)m_title.utf16(); + // Determine lpstrDefExt. Note that the current MSDN docs document this + // member wrong. It should rather be documented as "the default extension + // if no extension was given and if the current filter does not have an + // extension (e.g (*)). If the current filter has an extension, use + // the extension of the current filter". + if (m_options->acceptMode() == QFileDialogOptions::AcceptSave) { + QString defaultSuffix = m_options->defaultSuffix(); + if (defaultSuffix.startsWith(QLatin1Char('.'))) + defaultSuffix.remove(0, 1); + if (!defaultSuffix.isEmpty()) + ofn->lpstrDefExt = qStringToWCharArray(defaultSuffix); + } + // Flags. + ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_PATHMUSTEXIST); + if (m_options->fileMode() == QFileDialogOptions::ExistingFile + || m_options->fileMode() == QFileDialogOptions::ExistingFiles) + ofn->Flags |= (OFN_FILEMUSTEXIST); + if (m_options->fileMode() == QFileDialogOptions::ExistingFiles) + ofn->Flags |= (OFN_ALLOWMULTISELECT); + if (!(m_options->options() & QFileDialogOptions::DontConfirmOverwrite)) + ofn->Flags |= OFN_OVERWRITEPROMPT; +} + +QStringList QWindowsXpNativeFileDialog::execFileNames(HWND owner, int *selectedFilterIndex) const +{ + *selectedFilterIndex = -1; + OPENFILENAME ofn; + populateOpenFileName(&ofn, owner); + QStringList result; + const bool isSave = m_options->acceptMode() == QFileDialogOptions::AcceptSave; + if (isSave ? m_getSaveFileNameW(&ofn) : m_getOpenFileNameW(&ofn)) { + *selectedFilterIndex = ofn.nFilterIndex - 1; + result.push_back(QDir::cleanPath(QString::fromWCharArray(ofn.lpstrFile))); + // For multiselection, the first item is the path followed + // by "\0\0\0\0". + if (ofn.Flags & (OFN_ALLOWMULTISELECT)) { + wchar_t *ptr = ofn.lpstrFile + result.front().size() + 1; + if (*ptr) { + const QString path = result.takeAt(0) + QLatin1Char('/'); + while (*ptr) { + const QString fileName = QString::fromWCharArray(ptr); + result.push_back(path + fileName); + ptr += fileName.size() + 1; + } // extract multiple files + } // has multiple files + } // multiple flag set + } + delete [] ofn.lpstrFile; + delete [] ofn.lpstrInitialDir; + delete [] ofn.lpstrFilter; + delete [] ofn.lpstrDefExt; + return result; +} + +/*! + \class QWindowsXpFileDialogHelper + \brief Dialog helper using QWindowsXpNativeFileDialog + + \sa QWindowsXpNativeFileDialog + \internal + \ingroup qt-lighthouse-win +*/ + +class QWindowsXpFileDialogHelper : public QWindowsDialogHelperBase +{ +public: + QWindowsXpFileDialogHelper() {} + virtual bool supportsNonModalDialog() const { return false; } + + virtual bool defaultNameFilterDisables() const + { return true; } + virtual void setDirectory(const QString &directory); + virtual QString directory() const; + virtual void selectFile(const QString &filename); + virtual QStringList selectedFiles() const; + virtual void setFilter() {} + virtual void setNameFilters(const QStringList &); + virtual void selectNameFilter(const QString &); + virtual QString selectedNameFilter() const; + +private: + virtual QWindowsNativeDialogBase *createNativeDialog(); + inline QWindowsXpNativeFileDialog *nativeFileDialog() const + { return static_cast(nativeDialog()); } +}; + +QWindowsNativeDialogBase *QWindowsXpFileDialogHelper::createNativeDialog() +{ + if (QWindowsNativeDialogBase *result = QWindowsXpNativeFileDialog::create(options())) { + QObject::connect(result, SIGNAL(accepted()), this, SIGNAL(accept())); + QObject::connect(result, SIGNAL(rejected()), this, SIGNAL(reject())); + return result; + } + return 0; +} + +void QWindowsXpFileDialogHelper::setDirectory(const QString &directory) +{ + if (QWindowsXpNativeFileDialog *nfd = nativeFileDialog()) + nfd->setDirectory(directory); +} + +QString QWindowsXpFileDialogHelper::directory() const +{ + if (const QWindowsXpNativeFileDialog *nfd = nativeFileDialog()) + return nfd->directory(); + return QString(); +} + +void QWindowsXpFileDialogHelper::selectFile(const QString &filename) +{ + if (QWindowsXpNativeFileDialog *nfd = nativeFileDialog()) + nfd->selectFile(filename); +} + +QStringList QWindowsXpFileDialogHelper::selectedFiles() const +{ + if (const QWindowsXpNativeFileDialog *nfd = nativeFileDialog()) + return nfd->selectedFiles(); + return QStringList(); +} + +void QWindowsXpFileDialogHelper::setNameFilters(const QStringList &n) +{ + if (QWindowsXpNativeFileDialog *nfd = nativeFileDialog()) + nfd->setNameFilters(n); +} + +void QWindowsXpFileDialogHelper::selectNameFilter(const QString &f) +{ + if (QWindowsXpNativeFileDialog *nfd = nativeFileDialog()) + nfd->selectNameFilter(f); +} + +QString QWindowsXpFileDialogHelper::selectedNameFilter() const +{ + if (const QWindowsXpNativeFileDialog *nfd = nativeFileDialog()) + return nfd->selectedNameFilter(); + return QString(); +} + +#endif // Q_OS_WINCE + /*! \class QWindowsNativeColorDialog \brief Native Windows color dialog. @@ -1399,10 +1801,11 @@ namespace QWindowsDialogs { // QWindowsDialogHelperBase creation functions bool useHelper(QPlatformTheme::DialogType type) { + if (QWindowsIntegration::instance()->options() & QWindowsIntegration::NoNativeDialogs) + return false; switch (type) { case QPlatformTheme::FileDialog: - return true; - break; + return QSysInfo::windowsVersion() >= QSysInfo::WV_XP; case QPlatformTheme::ColorDialog: #ifdef USE_NATIVE_COLOR_DIALOG return true; @@ -1417,9 +1820,20 @@ bool useHelper(QPlatformTheme::DialogType type) QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type) { + if (QWindowsIntegration::instance()->options() & QWindowsIntegration::NoNativeDialogs) + return 0; switch (type) { case QPlatformTheme::FileDialog: +#ifndef Q_OS_WINCE + if (QWindowsIntegration::instance()->options() & QWindowsIntegration::XpNativeDialogs + || QSysInfo::windowsVersion() == QSysInfo::WV_XP) { + return new QWindowsXpFileDialogHelper(); + } + if (QSysInfo::windowsVersion() > QSysInfo::WV_XP) + return new QWindowsFileDialogHelper(); +#else return new QWindowsFileDialogHelper(); +#endif // Q_OS_WINCE case QPlatformTheme::ColorDialog: #ifdef USE_NATIVE_COLOR_DIALOG return new QWindowsColorDialogHelper(); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index b7309c3f7cc..3f030ffca76 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -279,6 +279,12 @@ static inline unsigned parseOptions(const QStringList ¶mList) } else if (param.endsWith(QLatin1String("native"))) { options |= QWindowsIntegration::FontDatabaseNative; } + } else if (param.startsWith(QLatin1String("dialogs="))) { + if (param.endsWith(QLatin1String("xp"))) { + options |= QWindowsIntegration::XpNativeDialogs; + } else if (param.endsWith(QLatin1String("none"))) { + options |= QWindowsIntegration::NoNativeDialogs; + } } else if (param == QLatin1String("gl=gdi")) { options |= QWindowsIntegration::DisableArb; } diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index ca47dabb4bd..abf663c0529 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -56,7 +56,9 @@ public: enum Options { // Options to be passed on command line. FontDatabaseFreeType = 0x1, FontDatabaseNative = 0x2, - DisableArb = 0x4 + DisableArb = 0x4, + NoNativeDialogs = 0x8, + XpNativeDialogs = 0x10 }; explicit QWindowsIntegration(const QStringList ¶mList); From 03cd922e312428aca54892039da9ed79479cfa17 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Mon, 29 Oct 2012 12:00:14 +0100 Subject: [PATCH 076/134] QNX: Remember information on whether a file is a link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids an additional call to lstat() When using QDir::entryList() with the QDir::NoSymLinks flag. Change-Id: I3b602546c6a4502ae25a5748a12c60e69325bb5d Reviewed-by: Rafael Roquetto Reviewed-by: Kevin Krammer Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index fe06210fb90..8707aec0b82 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -300,6 +300,13 @@ void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry) const struct dirent_extra_stat * const extra_stat = reinterpret_cast(extra); + // Remember whether this was a link or not, this saves an lstat() call later. + if (extra->d_type == _DTYPE_LSTAT) { + knownFlagsMask |= QFileSystemMetaData::LinkType; + if (S_ISLNK(extra_stat->d_stat.st_mode)) + entryFlags |= QFileSystemMetaData::LinkType; + } + // For symlinks, the extra type _DTYPE_LSTAT doesn't work for filling out the meta data, // as we need the stat() information there, not the lstat() information. // In this case, don't use the extra information. From 792eb1029d0fa1b747deb2cd5b4b3a1cd5d3b13f Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Mon, 29 Oct 2012 23:27:51 +0100 Subject: [PATCH 077/134] test: Remove QSKIP from tst_QListView::setCurrentIndexAfterAppendRowCrash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8d48722b412895e43aa8a522354c5d67d83c19dd Reviewed-by: Jędrzej Nowacki --- tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 8458ca78fb0..8b8f7e89492 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -115,7 +115,9 @@ private slots: void scrollBarAsNeeded(); void moveItems(); void wordWrap(); +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && WINVER >= 0x0500 void setCurrentIndexAfterAppendRowCrash(); +#endif void emptyItemSize(); void task203585_selectAll(); void task228566_infiniteRelayout(); @@ -1510,15 +1512,14 @@ private: }; #endif +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && WINVER >= 0x0500 +// This test only makes sense on windows 2000 and higher. void tst_QListView::setCurrentIndexAfterAppendRowCrash() { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && WINVER >= 0x0500 SetCurrentIndexAfterAppendRowCrashDialog w; w.exec(); -#else - QSKIP("This test only makes sense on windows 2000 and higher."); -#endif } +#endif void tst_QListView::emptyItemSize() { From fd7b3ffe5cbedb180f7cfb9975437f0eb285d05a Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Mon, 29 Oct 2012 23:21:35 +0100 Subject: [PATCH 078/134] test: Remove QSKIP from tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053() Change-Id: I1aa329323767a3e849beca8fe41e39dbe98de4ee Reviewed-by: Caroline Chao --- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 09180b3de9d..be3e68ad38b 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -231,7 +231,9 @@ private slots: void drawRect_task215378(); void drawRect_task247505(); +#if defined(Q_OS_MAC) void drawText_subPixelPositionsInRaster_qtbug5053(); +#endif void drawImage_data(); void drawImage(); @@ -4178,11 +4180,10 @@ void tst_QPainter::clipBoundingRect() } +#if defined(Q_OS_MAC) +// Only Mac supports sub pixel positions in raster engine currently void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053() { -#if !defined(Q_OS_MAC) - QSKIP("Only Mac supports sub pixel positions in raster engine currently"); -#endif QFontMetricsF fm(qApp->font()); QImage baseLine(fm.width(QChar::fromLatin1('e')), fm.height(), QImage::Format_RGB32); @@ -4212,6 +4213,7 @@ void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053() QVERIFY(foundDifferentRasterization); } +#endif void tst_QPainter::drawPointScaled() { From bf722c1ab387e8892242dcaacd8afd36d592ebb6 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Mon, 29 Oct 2012 23:13:05 +0100 Subject: [PATCH 079/134] test: Remove QSKIP from tst_QByteArray::literals() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I07b53cd12790d2161964dd09c5a69fe8aff7c90d Reviewed-by: Jędrzej Nowacki --- tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 331024c5600..848fdb14a4e 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -147,7 +147,9 @@ private slots: void reserveExtended(); void movablity_data(); void movablity(); +#if defined(Q_COMPILER_LAMBDA) void literals(); +#endif }; static const struct StaticByteArrays { @@ -1878,9 +1880,10 @@ void tst_QByteArray::movablity() QVERIFY(true); } +#if defined(Q_COMPILER_LAMBDA) +// Only tested on c++0x compliant compiler or gcc void tst_QByteArray::literals() { -#if defined(Q_COMPILER_LAMBDA) QByteArray str(QByteArrayLiteral("abcd")); QVERIFY(str.length() == 4); @@ -1897,10 +1900,8 @@ void tst_QByteArray::literals() QVERIFY(str2.constData() == s); QVERIFY(str2.data() != s); -#else - QSKIP("Only tested on c++0x compliant compiler or gcc"); -#endif } +#endif const char globalChar = '1'; From 50ec06da2c8a1c680d48b84f8c1267fe78a86b6a Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 25 Oct 2012 06:43:01 +0200 Subject: [PATCH 080/134] Only use the user set page margins for custom paper When the QPrinter is initalized then it will set up page margins based on the default paper size. If the paper size is changed to be a custom one then it should disregard the margins for the default paper size. If the page margins are set explicitly beforehand then it will use these page margins. Change-Id: Ic535c3a80b8b217dbd5eb5f4fb2cbc0ab1354563 Reviewed-by: Titta Heikkala Reviewed-by: Friedemann Kleint Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforms/cocoa/qprintengine_mac.mm | 4 +- src/printsupport/kernel/qprintengine_pdf.cpp | 9 ++- src/printsupport/kernel/qprintengine_pdf_p.h | 2 +- src/printsupport/kernel/qprintengine_win.cpp | 16 +++-- .../kernel/qprinter/tst_qprinter.cpp | 59 +++++++++++++++++++ 5 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index f2c567f0eba..94c89ad8db4 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -795,13 +795,15 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const if (d->hasCustomPageMargins) { margins << d->leftMargin << d->topMargin << d->rightMargin << d->bottomMargin; - } else { + } else if (!d->hasCustomPaperSize) { PMPaperMargins paperMargins; PMPaper paper; PMGetPageFormatPaper(d->format(), &paper); PMPaperGetMargins(paper, &paperMargins); margins << paperMargins.left << paperMargins.top << paperMargins.right << paperMargins.bottom; + } else { + margins << 0 << 0 << 0 << 0; } ret = margins; break; diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp index 3e343176ba9..c4bcb697f5a 100644 --- a/src/printsupport/kernel/qprintengine_pdf.cpp +++ b/src/printsupport/kernel/qprintengine_pdf.cpp @@ -213,6 +213,7 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va d->topMargin = margins.at(1).toReal(); d->rightMargin = margins.at(2).toReal(); d->bottomMargin = margins.at(3).toReal(); + d->pageMarginsSet = true; break; } default: @@ -298,8 +299,11 @@ QVariant QPdfPrintEngine::property(PrintEnginePropertyKey key) const case PPK_PageMargins: { QList margins; - margins << d->leftMargin << d->topMargin - << d->rightMargin << d->bottomMargin; + if (d->printerPaperSize == QPrinter::Custom && !d->pageMarginsSet) + margins << 0 << 0 << 0 << 0; + else + margins << d->leftMargin << d->topMargin + << d->rightMargin << d->bottomMargin; ret = margins; break; } @@ -353,6 +357,7 @@ QPdfPrintEnginePrivate::QPdfPrintEnginePrivate(QPrinter::PrinterMode m) pageOrder(QPrinter::FirstPageFirst), paperSource(QPrinter::Auto), printerPaperSize(QPrinter::A4), + pageMarginsSet(false), fd(-1) { resolution = 72; diff --git a/src/printsupport/kernel/qprintengine_pdf_p.h b/src/printsupport/kernel/qprintengine_pdf_p.h index 36df233f72d..2d70c4619e7 100644 --- a/src/printsupport/kernel/qprintengine_pdf_p.h +++ b/src/printsupport/kernel/qprintengine_pdf_p.h @@ -151,7 +151,7 @@ private: QPrinter::PaperSize printerPaperSize; QSizeF customPaperSize; // in postscript points - + bool pageMarginsSet; int fd; }; diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index 28e0363d6e1..200b5fd1029 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -1540,13 +1540,17 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const case PPK_PageMargins: { QList margins; - QRect pageMargins(d->getPageMargins()); + if (d->has_custom_paper_size && !d->pageMarginsSet) { + margins << 0 << 0 << 0 << 0; + } else { + QRect pageMargins(d->getPageMargins()); - // specified in 1/100 mm - margins << (mmToInches(pageMargins.left()/100.0) * 72) - << (mmToInches(pageMargins.top()/100.0) * 72) - << (mmToInches(pageMargins.width()/100.0) * 72) - << (mmToInches(pageMargins.height()/100.0) * 72); + // specified in 1/100 mm + margins << (mmToInches(pageMargins.left()/100.0) * 72) + << (mmToInches(pageMargins.top()/100.0) * 72) + << (mmToInches(pageMargins.width()/100.0) * 72) + << (mmToInches(pageMargins.height()/100.0) * 72); + } value = margins; break; } diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index 0f7c7f7a84e..b01f311f4f2 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -109,6 +109,8 @@ private slots: void valuePreservation(); void errorReporting(); void testCustomPageSizes(); + void customPaperSizeAndMargins_data(); + void customPaperSizeAndMargins(); #if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) void printDialogCompleter(); #endif @@ -933,6 +935,63 @@ void tst_QPrinter::testCustomPageSizes() QCOMPARE(paperSize, customSize); } +void tst_QPrinter::customPaperSizeAndMargins_data() +{ + QTest::addColumn("pdf"); + QTest::addColumn("before"); + QTest::addColumn("left"); + QTest::addColumn("top"); + QTest::addColumn("right"); + QTest::addColumn("bottom"); + + QTest::newRow("beforeNoPDF") << false << true << qreal(2) << qreal(2) << qreal(2) << qreal(2); + QTest::newRow("beforePDF") << true << true << qreal(2) << qreal(2) << qreal(2) << qreal(2); + QTest::newRow("afterNoPDF") << false << false << qreal(2) << qreal(2) << qreal(2) << qreal(2); + QTest::newRow("afterAfterPDF") << true << false << qreal(2) << qreal(2) << qreal(2) << qreal(2); +} + +void tst_QPrinter::customPaperSizeAndMargins() +{ + QFETCH(bool, pdf); + QFETCH(bool, before); + QFETCH(qreal, left); + QFETCH(qreal, top); + QFETCH(qreal, right); + QFETCH(qreal, bottom); + + qreal tolerance = 0.05; + qreal getLeft = 0; + qreal getRight = 0; + qreal getTop = 0; + qreal getBottom = 0; + QSizeF customSize(8.5, 11.0); + + QPrinter p; + if (pdf) + p.setOutputFormat(QPrinter::PdfFormat); + if (before) + p.setPageMargins(left, top, right, bottom, QPrinter::Millimeter); + p.setPaperSize(customSize, QPrinter::Millimeter); + p.getPageMargins(&getLeft, &getTop, &getRight, &getBottom, QPrinter::Millimeter); + if (before) { + QVERIFY(fabs(left - getLeft) < tolerance); + QVERIFY(fabs(left - getTop) < tolerance); + QVERIFY(fabs(left - getRight) < tolerance); + QVERIFY(fabs(left - getBottom) < tolerance); + } else { + QVERIFY(getLeft == 0); + QVERIFY(getTop == 0); + QVERIFY(getRight == 0); + QVERIFY(getBottom == 0); + p.setPageMargins(left, top, right, bottom, QPrinter::Millimeter); + p.getPageMargins(&getLeft, &getTop, &getRight, &getBottom, QPrinter::Millimeter); + QVERIFY(fabs(left - getLeft) < tolerance); + QVERIFY(fabs(left - getTop) < tolerance); + QVERIFY(fabs(left - getRight) < tolerance); + QVERIFY(fabs(left - getBottom) < tolerance); + } +} + #if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) void tst_QPrinter::printDialogCompleter() { From a48508cd766b056d3cb5b6502cf269a8293bb5a5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 30 Oct 2012 10:21:36 +0200 Subject: [PATCH 081/134] Send leave to most recently entered window when modal dialog is shown. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a modal dialog was shown as a response to button click, the button retained its hover highlight, because it didn't get leave event. Fixed by tracking the most recently entered window and sending a leave to it when modal dialog is shown that blocks it. Also modified tst_QGuiApplication::modalWindow() autotest to check for enters and leaves. Task-number: QTBUG-27644 Change-Id: I387647e18a762a39d523e3df31221b9583a39f9d Reviewed-by: Samuel Rødal --- src/gui/kernel/qguiapplication.cpp | 18 +++++ src/gui/kernel/qguiapplication_p.h | 1 + src/gui/kernel/qwindow.cpp | 4 ++ src/widgets/kernel/qwidgetwindow.cpp | 1 + .../qguiapplication/tst_qguiapplication.cpp | 69 +++++++++++++++++-- 5 files changed, 89 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 64d2f8001f0..6e367ebfcf8 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -105,6 +105,7 @@ QPointF QGuiApplicationPrivate::lastCursorPosition(0.0, 0.0); bool QGuiApplicationPrivate::tabletState = false; QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; +QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; @@ -455,6 +456,19 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) { self->modalWindowList.prepend(modal); + // Send leave for currently entered window if it should be blocked + if (currentMouseWindow && (currentMouseWindow->windowType() & Qt::Popup) != Qt::Popup) { + bool shouldBeBlocked = self->isWindowBlocked(currentMouseWindow); + if (shouldBeBlocked) { + // Remove the new window from modalWindowList temporarily so leave can go through + self->modalWindowList.removeFirst(); + QEvent e(QEvent::Leave); + QGuiApplication::sendEvent(currentMouseWindow, &e); + currentMouseWindow = 0; + self->modalWindowList.prepend(modal); + } + } + QEvent e(QEvent::WindowBlocked); QWindowList windows = QGuiApplication::topLevelWindows(); for (int i = 0; i < windows.count(); ++i) { @@ -1410,6 +1424,8 @@ void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::En return; } + currentMouseWindow = e->enter; + QEvent event(QEvent::Enter); QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event); } @@ -1423,6 +1439,8 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le return; } + currentMouseWindow = 0; + QEvent event(QEvent::Leave); QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event); } diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 44a9275688f..c9eb6722208 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -189,6 +189,7 @@ public: static QPointF lastCursorPosition; static bool tabletState; static QWindow *tabletPressTarget; + static QWindow *currentMouseWindow; #ifndef QT_NO_CLIPBOARD static QClipboard *qt_clipboard; diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 4f1610cb210..a17270912f0 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -214,6 +214,8 @@ QWindow::~QWindow() { if (QGuiApplicationPrivate::focus_window == this) QGuiApplicationPrivate::focus_window = 0; + if (QGuiApplicationPrivate::currentMouseWindow == this) + QGuiApplicationPrivate::currentMouseWindow = 0; QGuiApplicationPrivate::window_list.removeAll(this); destroy(); } @@ -1445,6 +1447,8 @@ bool QWindow::close() if (QGuiApplicationPrivate::focus_window == this) QGuiApplicationPrivate::focus_window = 0; + if (QGuiApplicationPrivate::currentMouseWindow == this) + QGuiApplicationPrivate::currentMouseWindow = 0; QGuiApplicationPrivate::window_list.removeAll(this); destroy(); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index b3d46d5c284..b49441beba6 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -234,6 +234,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) while (enterParent->parent()) enterParent = enterParent->parent(); if (thisParent == enterParent) { + QGuiApplicationPrivate::currentMouseWindow = enterWindow; enter = enterWindow->widget(); QWindowSystemInterfacePrivate::removeWindowSystemEvent(systemEvent); } diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index cc291f72fa5..a7c38d66641 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -336,12 +336,11 @@ class BlockableWindow : public QWindow Q_OBJECT public: int blocked; + int leaves; + int enters; inline BlockableWindow() - : QWindow() - { - blocked = false; - } + : QWindow(), blocked(false), enters(0), leaves(0) {} bool event(QEvent *e) { @@ -352,11 +351,23 @@ public: case QEvent::WindowUnblocked: --blocked; break; + case QEvent::Leave: + leaves++; + break; + case QEvent::Enter: + enters++; + break; default: break; } return QWindow::event(e); } + + void resetCounts() + { + leaves = 0; + enters = 0; + } }; void tst_QGuiApplication::modalWindow() @@ -391,6 +402,12 @@ void tst_QGuiApplication::modalWindow() QCOMPARE(windowModalWindow2->blocked, 0); QCOMPARE(applicationModalWindow1->blocked, 0); + // enter mouse in window1 + QWindowSystemInterface::handleEnterEvent(window1); + QGuiApplication::processEvents(); + QCOMPARE(window1->enters, 1); + QCOMPARE(window1->leaves, 0); + // show applicationModalWindow1, everything is blocked applicationModalWindow1->show(); QCOMPARE(app.modalWindow(), applicationModalWindow1); @@ -400,6 +417,24 @@ void tst_QGuiApplication::modalWindow() QCOMPARE(windowModalWindow2->blocked, 1); QCOMPARE(applicationModalWindow1->blocked, 0); + // opening modal causes leave for previously entered window, but not others + QGuiApplication::processEvents(); + QCOMPARE(window1->enters, 1); + QCOMPARE(window1->leaves, 1); + QCOMPARE(window2->enters, 0); + QCOMPARE(window2->leaves, 0); + QCOMPARE(applicationModalWindow1->enters, 0); + QCOMPARE(applicationModalWindow1->leaves, 0); + window1->resetCounts(); + + // Try entering/leaving blocked window2 - no events should reach it + QWindowSystemInterface::handleEnterEvent(window2); + QGuiApplication::processEvents(); + QWindowSystemInterface::handleLeaveEvent(window2); + QGuiApplication::processEvents(); + QCOMPARE(window2->enters, 0); + QCOMPARE(window2->leaves, 0); + // everything is unblocked when applicationModalWindow1 is hidden applicationModalWindow1->hide(); QCOMPARE(app.modalWindow(), static_cast(0)); @@ -409,6 +444,12 @@ void tst_QGuiApplication::modalWindow() QCOMPARE(windowModalWindow2->blocked, 0); QCOMPARE(applicationModalWindow1->blocked, 0); + // Enter window2 - should not be blocked + QWindowSystemInterface::handleEnterEvent(window2); + QGuiApplication::processEvents(); + QCOMPARE(window2->enters, 1); + QCOMPARE(window2->leaves, 0); + // show the windowModalWindow1, only window1 is blocked windowModalWindow1->show(); QCOMPARE(app.modalWindow(), windowModalWindow1); @@ -418,6 +459,15 @@ void tst_QGuiApplication::modalWindow() QCOMPARE(windowModalWindow2->blocked, 0); QCOMPARE(applicationModalWindow1->blocked, 0); + // opening window modal window doesn't cause leave for unblocked window + QGuiApplication::processEvents(); + QCOMPARE(window1->enters, 0); + QCOMPARE(window1->leaves, 0); + QCOMPARE(window2->enters, 1); + QCOMPARE(window2->leaves, 0); + QCOMPARE(windowModalWindow1->enters, 0); + QCOMPARE(windowModalWindow1->leaves, 0); + // show the windowModalWindow2, windowModalWindow1 is blocked as well windowModalWindow2->show(); QCOMPARE(app.modalWindow(), windowModalWindow2); @@ -472,6 +522,17 @@ void tst_QGuiApplication::modalWindow() QCOMPARE(windowModalWindow2->blocked, 1); QCOMPARE(applicationModalWindow1->blocked, 0); + // window2 gets finally the leave + QGuiApplication::processEvents(); + QCOMPARE(window1->enters, 0); + QCOMPARE(window1->leaves, 0); + QCOMPARE(window2->enters, 1); + QCOMPARE(window2->leaves, 1); + QCOMPARE(windowModalWindow1->enters, 0); + QCOMPARE(windowModalWindow1->leaves, 0); + QCOMPARE(applicationModalWindow1->enters, 0); + QCOMPARE(applicationModalWindow1->leaves, 0); + // hide applicationModalWindow1, windowModalWindow1 and window1 are blocked applicationModalWindow1->hide(); QCOMPARE(app.modalWindow(), windowModalWindow2); From 57fed47ac042f6dd3d5a381ce6b9e5906648ca86 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Mon, 29 Oct 2012 10:17:33 +0100 Subject: [PATCH 082/134] Generate a .qmake.cache in config.tests from configure.exe. We need to generate a .qmake.cache file in the config.tests directory on Windows to ensure that the config.tests can actually be compiled before the qmodule.pri is created. Task-number: QTBUG-27708 Change-Id: I8d9397a8cbdb2aa19a5318497177d76049f9fa91 Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 19 +++++++++++++++++++ tools/configure/configureapp.h | 1 + tools/configure/main.cpp | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 113ebf76927..472563a7606 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2312,6 +2312,25 @@ void Configure::generateBuildKey() build_defines.sort(); } +void Configure::generateSystemVars() +{ + // Generate an empty .qmake.cache file for config.tests + QDir buildDir(buildPath); + bool success = true; + if (!buildDir.exists("config.tests")) + success = buildDir.mkdir("config.tests"); + + QString fileName(buildPath + "/config.tests/.qmake.cache"); + QFile cacheFile(fileName); + success &= cacheFile.open(QIODevice::WriteOnly); + cacheFile.close(); + + if (!success) { + cout << "Failed to create file " << qPrintable(QDir::toNativeSeparators(fileName)) << endl; + dictionary[ "DONE" ] = "error"; + } +} + void Configure::generateOutputVars() { // Generate variables for output diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h index 8cae9da4f86..16d0a1164f8 100644 --- a/tools/configure/configureapp.h +++ b/tools/configure/configureapp.h @@ -83,6 +83,7 @@ public: void generateConfigfiles(); void detectArch(); void generateQConfigPri(); + void generateSystemVars(); #endif void showSummary(); void findProjects( const QString& dirName ); diff --git a/tools/configure/main.cpp b/tools/configure/main.cpp index 53013c969da..e917137837d 100644 --- a/tools/configure/main.cpp +++ b/tools/configure/main.cpp @@ -78,6 +78,10 @@ int runConfigure( int argc, char** argv ) if (!app.isOk()) return 3; + app.generateSystemVars(); + if (!app.isOk()) + return 3; + // Auto-detect modules and settings. app.autoDetection(); From 9f390bb6863fd25cb614447514822ab93c4a8aec Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 26 Oct 2012 16:22:49 +0200 Subject: [PATCH 083/134] ANGLE: Add TextureSSE2.cpp to SSE2_SOURCES. This file needs to be compiled with SSE2 intrinsic support. It happens to compile on x64 system because SSE2 is implied here, but on 32-bit compilers (in this case MinGW 32-bit) it needs to be explicit. Change-Id: I92dd5bc9257b6dd344ab02341475c023327b756a Reviewed-by: Kai Koehne --- src/angle/src/libGLESv2/libGLESv2.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/angle/src/libGLESv2/libGLESv2.pro b/src/angle/src/libGLESv2/libGLESv2.pro index a4e83ea10dc..c8da3798625 100644 --- a/src/angle/src/libGLESv2/libGLESv2.pro +++ b/src/angle/src/libGLESv2/libGLESv2.pro @@ -1,6 +1,7 @@ TEMPLATE = lib TARGET = libGLESv2 DEPENDPATH += . shaders +CONFIG += simd include(../common/common.pri) @@ -60,10 +61,11 @@ SOURCES += \ $$ANGLE_DIR/src/libGLESv2/ResourceManager.cpp \ $$ANGLE_DIR/src/libGLESv2/Shader.cpp \ $$ANGLE_DIR/src/libGLESv2/Texture.cpp \ - $$ANGLE_DIR/src/libGLESv2/TextureSSE2.cpp \ $$ANGLE_DIR/src/libGLESv2/utilities.cpp \ $$ANGLE_DIR/src/libGLESv2/VertexDataManager.cpp +SSE2_SOURCES += $$ANGLE_DIR/src/libGLESv2/TextureSSE2.cpp + float_converter.target = float_converter float_converter.commands = python $$ANGLE_DIR/src/libGLESv2/Float16ToFloat32.py \ > $$ANGLE_DIR/src/libGLESv2/Float16ToFloat32.cpp From fc0cbef59599174589a606838a9b55ba6a07ef06 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Wed, 15 Aug 2012 15:53:43 +0200 Subject: [PATCH 084/134] QNX: Use inotify on QNX systems that support it Change-Id: Ia9bf8d3c202b17746036e203268ef6229aaa900d Reviewed-by: Kevin Krammer Reviewed-by: Rafael Roquetto Reviewed-by: Sean Harmer --- src/corelib/io/io.pri | 2 +- src/corelib/io/qfilesystemwatcher.cpp | 7 +++++-- src/corelib/io/qfilesystemwatcher_inotify.cpp | 8 ++++++++ .../io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 5 +++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 174e2a2fbf8..f57dcebe33d 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -124,7 +124,7 @@ win32 { SOURCES += io/qstandardpaths_unix.cpp } - linux-* { + linux-*|if(qnx:contains(QT_CONFIG, inotify)) { SOURCES += io/qfilesystemwatcher_inotify.cpp HEADERS += io/qfilesystemwatcher_inotify_p.h } diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 77a5959f8f7..449be9b7b5a 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -51,11 +51,14 @@ #include #include +#if defined(Q_OS_LINUX) || (defined(Q_OS_QNX) && !defined(QT_NO_INOTIFY)) +#define USE_INOTIFY +#endif #include "qfilesystemwatcher_polling_p.h" #if defined(Q_OS_WIN) # include "qfilesystemwatcher_win_p.h" -#elif defined(Q_OS_LINUX) +#elif defined(USE_INOTIFY) # include "qfilesystemwatcher_inotify_p.h" #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) # include "qfilesystemwatcher_kqueue_p.h" @@ -67,7 +70,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject { #if defined(Q_OS_WIN) return new QWindowsFileSystemWatcherEngine(parent); -#elif defined(Q_OS_LINUX) +#elif defined(USE_INOTIFY) // there is a chance that inotify may fail on Linux pre-2.6.13 (August // 2005), so we can't just new inotify directly. return QInotifyFileSystemWatcherEngine::create(parent); diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index 390a280ff2e..11ac0e5b5dd 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -52,12 +52,20 @@ #include #include +#if defined(Q_OS_LINUX) #include #include #include #include +#endif #if defined(QT_NO_INOTIFY) + +#if defined(Q_OS_QNX) +// These files should only be compiled on QNX if the inotify headers are found +#error "Should not get here." +#endif + #include #if defined(__i386__) diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 76fa6022baf..82eaa64bc20 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -183,6 +183,9 @@ void tst_QFileSystemWatcher::basicTest() // change the permissions, should get a signal from the watcher testFile.setPermissions(QFile::ReadOwner); + // IN_ATTRIB doesn't work on QNX, so skip this test +#if !defined(Q_OS_QNX) + // waiting max 5 seconds for notification for file permission modification to trigger QTRY_COMPARE(changedSpy.count(), 1); QCOMPARE(changedSpy.at(0).count(), 1); @@ -190,6 +193,8 @@ void tst_QFileSystemWatcher::basicTest() fileName = changedSpy.at(0).at(0).toString(); QCOMPARE(fileName, testFile.fileName()); +#endif + changedSpy.clear(); // remove the watch and modify file permissions, should not get a signal from the watcher From 788e1b2ffa5541b86f62bf468540bb8b5872c033 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 29 Oct 2012 15:16:55 +0100 Subject: [PATCH 085/134] Pixel-align vertical metrics in QTextLayout again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid regressing due to de58eb64bc564fcb8af61a45576783e432d2380c, we need to return a pixel aligned height in QTextLine::height() and also use pixel aligned heights when calculating the position of lines as well as the bounding rect of the layout. Later, we can add a QTextLine::naturalHeight() or something like that which gives the fractional value, but until then, we need to access private API in QPainter to get the correct alignment, since we still don't want to align the height of the last line in the layout, we only want to align the origin of each line. Task-number: QTBUG-27740 Change-Id: I12325f07d33aaf1a1b967e0a11492759d0f565d9 Reviewed-by: Caroline Chao Reviewed-by: Samuel Rødal --- src/gui/painting/qpainter.cpp | 5 ++++- src/gui/text/qtextlayout.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 7070e5732db..0cfe953e434 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7498,8 +7498,11 @@ start_lengthVariant: l.setLineWidth(lineWidth); height += leading; + + // Make sure lines are positioned on whole pixels + height = qCeil(height); l.setPosition(QPointF(0., height)); - height += l.height(); + height += textLayout.engine()->lines[l.lineNumber()].height().toReal(); width = qMax(width, l.naturalTextWidth()); if (!dontclip && !brect && height >= r.height()) break; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index a0a92897c58..0ca8e8d9a67 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -916,7 +916,7 @@ QRectF QTextLayout::boundingRect() const QFixed lineWidth = si.width < QFIXED_MAX ? qMax(si.width, si.textWidth) : si.textWidth; xmax = qMax(xmax, si.x+lineWidth); // ### shouldn't the ascent be used in ymin??? - ymax = qMax(ymax, si.y+si.height()); + ymax = qMax(ymax, si.y+si.height().ceil()); } return QRectF(xmin.toReal(), ymin.toReal(), (xmax-xmin).toReal(), (ymax-ymin).toReal()); } @@ -1466,7 +1466,7 @@ qreal QTextLine::descent() const */ qreal QTextLine::height() const { - return eng->lines[index].height().toReal(); + return eng->lines[index].height().ceil().toReal(); } /*! From 85a8df184b3aaa7f3a5a35895aa1caa3d4c39f42 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 23 Oct 2012 14:39:26 +0200 Subject: [PATCH 086/134] Add QNumberStyleAnimation for fading out scroll bars on Mac Change-Id: I6a85ed069a418d62078af6490a3d3186d5599a95 Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qstyleanimation.cpp | 45 ++++++++++++++++++++++++++ src/widgets/styles/qstyleanimation_p.h | 24 ++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index d81532f8a57..0138996e336 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -163,4 +163,49 @@ bool QProgressStyleAnimation::isUpdateNeeded() const return false; } +QNumberStyleAnimation::QNumberStyleAnimation(QObject *target) : + QStyleAnimation(target), _start(0.0), _end(1.0), _prev(0.0) +{ + setDuration(250); +} + +qreal QNumberStyleAnimation::startValue() const +{ + return _start; +} + +void QNumberStyleAnimation::setStartValue(qreal value) +{ + _start = value; +} + +qreal QNumberStyleAnimation::endValue() const +{ + return _end; +} + +void QNumberStyleAnimation::setEndValue(qreal value) +{ + _end = value; +} + +qreal QNumberStyleAnimation::currentValue() const +{ + qreal step = qreal(currentTime() - delay()) / (duration() - delay()); + return _start + qMax(qreal(0), step) * (_end - _start); +} + +bool QNumberStyleAnimation::isUpdateNeeded() const +{ + if (QStyleAnimation::isUpdateNeeded()) { + qreal current = currentValue(); + if (!qFuzzyCompare(_prev, current)) + { + _prev = current; + return true; + } + } + return false; +} + QT_END_NAMESPACE diff --git a/src/widgets/styles/qstyleanimation_p.h b/src/widgets/styles/qstyleanimation_p.h index 3188eebebc4..d9869533eff 100644 --- a/src/widgets/styles/qstyleanimation_p.h +++ b/src/widgets/styles/qstyleanimation_p.h @@ -110,6 +110,30 @@ private: mutable int _step; }; +class QNumberStyleAnimation : public QStyleAnimation +{ + Q_OBJECT + +public: + QNumberStyleAnimation(QObject *target); + + qreal startValue() const; + void setStartValue(qreal value); + + qreal endValue() const; + void setEndValue(qreal value); + + qreal currentValue() const; + +protected: + bool isUpdateNeeded() const; + +private: + qreal _start; + qreal _end; + mutable qreal _prev; +}; + QT_END_NAMESPACE #endif // QSTYLEANIMATION_P_H From dca34854efc4ff10965794495d7e1d904321a447 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 30 Oct 2012 15:38:32 +0100 Subject: [PATCH 087/134] Fix QCommonStylePrivate::stopAnimation() Make sure that QCommonStylePrivate::animation() does not return an animation that was already stopped. Change-Id: I35b7f8e0fabff9908f247b3632e35388e2c95a6d Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qcommonstyle.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 99ef88af00c..2b6d8437238 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1081,13 +1081,9 @@ void QCommonStylePrivate::startAnimation(QStyleAnimation *animation) const /*! \internal */ void QCommonStylePrivate::stopAnimation(const QObject *target) const { - QStyleAnimation *animation = animations.value(target); - if (animation) { - if (animation->state() == QAbstractAnimation::Stopped) - animations.take(target)->deleteLater(); - else - animation->stop(); - } + QStyleAnimation *animation = animations.take(target); + if (animation && animation->state() != QAbstractAnimation::Stopped) + animation->stop(); } /*! \internal */ From 21d74702d18b2aa745ea847b5aa0fb1c970df817 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 26 Oct 2012 15:26:34 +0200 Subject: [PATCH 088/134] add qml1_{module,plugin}.prf these are in fact thin wrappers around the qml2 variants, which got respective hooks. Change-Id: I1190856aea3f454b6f163e147d39c707a35ec4c6 Reviewed-by: Joerg Bornemann Reviewed-by: Thiago Macieira --- mkspecs/features/qml1_module.prf | 2 ++ mkspecs/features/qml1_plugin.prf | 2 ++ mkspecs/features/qml_module.prf | 9 +++++++-- mkspecs/features/qml_plugin.prf | 14 ++++++++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 mkspecs/features/qml1_module.prf create mode 100644 mkspecs/features/qml1_plugin.prf diff --git a/mkspecs/features/qml1_module.prf b/mkspecs/features/qml1_module.prf new file mode 100644 index 00000000000..8bacddc5493 --- /dev/null +++ b/mkspecs/features/qml1_module.prf @@ -0,0 +1,2 @@ +CONFIG += qml1_target +load(qml_module) diff --git a/mkspecs/features/qml1_plugin.prf b/mkspecs/features/qml1_plugin.prf new file mode 100644 index 00000000000..2914c78ea38 --- /dev/null +++ b/mkspecs/features/qml1_plugin.prf @@ -0,0 +1,2 @@ +CONFIG += qml1_target +load(qml_plugin) diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf index 10ee3bf3a7d..03ef88221e5 100644 --- a/mkspecs/features/qml_module.prf +++ b/mkspecs/features/qml_module.prf @@ -9,6 +9,11 @@ for(qmlf, QML_FILES): fq_qml_files += $$absolute_path($$qmlf, $$_PRO_FILE_PWD_) # Only for Qt Creator's project view OTHER_FILES += $$fq_qml_files +qml1_target: \ + instbase = $$[QT_INSTALL_IMPORTS]/QtDeclarative +else: \ + instbase = $$[QT_INSTALL_IMPORTS] + exists($$[QT_HOST_PREFIX]/.qmake.cache) { # These bizarre rules copy the files to the qtbase build directory @@ -17,7 +22,7 @@ exists($$[QT_HOST_PREFIX]/.qmake.cache) { } qmlfiles2build.input = fq_qml_files - qmlfiles2build.output = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH/${QMAKE_FUNC_FILE_IN_qmlModStripSrcDir} + qmlfiles2build.output = $$instbase/$$TARGETPATH/${QMAKE_FUNC_FILE_IN_qmlModStripSrcDir} !contains(TEMPLATE, vc.*): qmlfiles2build.variable_out = PRE_TARGETDEPS qmlfiles2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} qmlfiles2build.name = COPY ${QMAKE_FILE_IN} @@ -29,5 +34,5 @@ exists($$[QT_HOST_PREFIX]/.qmake.cache) { # Install rules qmldir.base = $$_PRO_FILE_PWD_ qmldir.files = $$fq_qml_files -qmldir.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH +qmldir.path = $$instbase/$$TARGETPATH INSTALLS += qmldir diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf index 8a24e9b36c1..b938bf493e0 100644 --- a/mkspecs/features/qml_plugin.prf +++ b/mkspecs/features/qml_plugin.prf @@ -24,7 +24,12 @@ exists($$QMLTYPEFILE): QML_FILES += $$QMLTYPEFILE # Install rules -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH +qml1_target: \ + instbase = $$[QT_INSTALL_IMPORTS]/QtDeclarative +else: \ + instbase = $$[QT_INSTALL_IMPORTS] + +target.path = $$instbase/$$TARGETPATH INSTALLS += target # Some final setup @@ -46,10 +51,15 @@ load(qt_targets) isEmpty(IMPORT_VERSION): IMPORT_VERSION = $$eval(QT.$${CXX_MODULE}.MAJOR_VERSION).$$eval(QT.$${CXX_MODULE}.MINOR_VERSION) load(resolve_target) - qtPrepareTool(QMLPLUGINDUMP, qmlplugindump) + qml1_target: \ + qmlplugindump = qml1plugindump + else: \ + qmlplugindump = qmlplugindump + qtPrepareTool(QMLPLUGINDUMP, $$qmlplugindump) importpath.value = for(qmod, QMAKEMODULES) { qmod = $$section(qmod, /, 0, -3)/imports + qml1_target: qmod = $$qmod/QtDeclarative exists($$qmod): importpath.value += $$shell_path($$qmod) } importpath.name = QML_IMPORT_PATH From 03b9b423b07a21916b8204047dbc34bf74f914fe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 29 Oct 2012 15:46:26 +0100 Subject: [PATCH 089/134] Generate instances of types in the CMake tests. All modules currently have a test_modules CMake test. The new module_includes test has very similar requirements, and can obsolete the hand-maintained test_modules tests in all modules. After all test_modules have been removed in other repos, the module_includes test can be renamed to that name. The types chosen need to have a constructor which can be invoked with no arguments. QtConcurrent has no public classes which fit that description so it is still tested separately Change-Id: Id7929cd32b3112c293cbf5e6964cc894a697f9b1 Reviewed-by: Rohan McGovern --- src/corelib/Qt5CTestMacros.cmake | 7 ++- tests/auto/cmake/CMakeLists.txt | 9 ++-- .../test_concurrent_module/CMakeLists.txt | 22 ++++++++++ .../main.cpp | 41 +++-------------- tests/auto/cmake/test_modules/CMakeLists.txt | 44 ------------------- 5 files changed, 38 insertions(+), 85 deletions(-) create mode 100644 tests/auto/cmake/test_concurrent_module/CMakeLists.txt rename tests/auto/cmake/{test_modules => test_concurrent_module}/main.cpp (76%) delete mode 100644 tests/auto/cmake/test_modules/CMakeLists.txt diff --git a/src/corelib/Qt5CTestMacros.cmake b/src/corelib/Qt5CTestMacros.cmake index 0db83e3fb3a..715ad9356e7 100644 --- a/src/corelib/Qt5CTestMacros.cmake +++ b/src/corelib/Qt5CTestMacros.cmake @@ -102,6 +102,7 @@ function(test_module_includes) set(all_args ${ARGN}) set(includes_string "") + set(instances_string "") while(all_args) list(GET all_args 0 qtmodule) list(GET all_args 1 qtinclude) @@ -113,6 +114,10 @@ function(test_module_includes) #include #include " ) + set(instances_string + "${instances_string} + ${qtinclude} local${qtinclude}; + ") endwhile() file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/module_includes/main.cpp" @@ -120,7 +125,7 @@ function(test_module_includes) ${includes_string} - int main(int, char **) { return 0; }\n" + int main(int, char **) { ${instances_string} return 0; }\n" ) add_test(module_includes ${CMAKE_CTEST_COMMAND} diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 367832efb6f..46dcdcca2b7 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -74,7 +74,6 @@ if (NOT WIN32) expect_pass(test_add_resources_delayed_file) endif() expect_pass(test_private_includes) -expect_pass(test_modules) expect_pass(test_testlib_definitions) expect_pass(test_json_plugin_includes) @@ -92,23 +91,23 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy set(qt_module_includes Core QObject - Concurrent QtConcurrentRun Gui QImage Widgets QWidget Network QHostInfo - OpenGL QGLContext + OpenGL QGLBuffer Sql QSqlError - Test QSignalSpy + Test QTestEventList Xml QDomDocument PrintSupport QPrintDialog ) if (UNIX AND NOT APPLE AND NOT QNXNTO) list(APPEND qt_module_includes - DBus QDBusConnection + DBus QDBusMessage ) endif() test_module_includes( ${qt_module_includes} ) +expect_pass(test_concurrent_module) diff --git a/tests/auto/cmake/test_concurrent_module/CMakeLists.txt b/tests/auto/cmake/test_concurrent_module/CMakeLists.txt new file mode 100644 index 00000000000..efd7b725ea4 --- /dev/null +++ b/tests/auto/cmake/test_concurrent_module/CMakeLists.txt @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 2.8) + +project(test_concurrent_module) + +find_package(Qt5Concurrent REQUIRED) + +include_directories( + ${Qt5Concurrent_INCLUDE_DIRS} +) + +add_definitions( + ${Qt5Concurrent_DEFINITIONS} +) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(mainapp main.cpp) + +target_link_libraries(mainapp + ${Qt5Concurrent_LIBRARIES} +) diff --git a/tests/auto/cmake/test_modules/main.cpp b/tests/auto/cmake/test_concurrent_module/main.cpp similarity index 76% rename from tests/auto/cmake/test_modules/main.cpp rename to tests/auto/cmake/test_concurrent_module/main.cpp index 2bb885dd5c5..e5693be9bfc 100644 --- a/tests/auto/cmake/test_modules/main.cpp +++ b/tests/auto/cmake/test_concurrent_module/main.cpp @@ -39,44 +39,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef EXPECT_DBUS_AVAILABLE -#include -#endif +#include +#include +#include +#include int main(int argc, char **argv) { - QObject object; - - QtConcurrent::BlockSizeManager blockSizeManager(42); - - QHostAddress hostAddress; - - QGLBuffer glBuffer; - - QSqlQuery sqlQuery; - - QSignalSpy signalSpy(&object, SIGNAL(destroyed())); - - QWidget widget; - - QDomDocument domDocument; - - QPrintDialog printDialog; - -#ifdef EXPECT_DBUS_AVAILABLE - QDBusMessage dBusMessage; -#endif + QByteArray bytearray = "hello world"; + QtConcurrent::run(bytearray, &QByteArray::split, ','); return 0; } diff --git a/tests/auto/cmake/test_modules/CMakeLists.txt b/tests/auto/cmake/test_modules/CMakeLists.txt deleted file mode 100644 index 30a726b10f8..00000000000 --- a/tests/auto/cmake/test_modules/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(test_modules) - -set(qtbase_modules - Core - Concurrent - Gui - Widgets - Network - OpenGL - Sql - Test - Xml - PrintSupport -) - -if (UNIX AND NOT APPLE AND NOT QNXNTO) - add_definitions(-DEXPECT_DBUS_AVAILABLE) - list(APPEND qtbase_modules DBus) -endif() - -foreach(_module ${qtbase_modules}) - find_package(Qt5${_module} REQUIRED) - - include_directories( - ${Qt5${_module}_INCLUDE_DIRS} - ) - - add_definitions( - ${Qt5${_module}_DEFINITIONS} - ) -endforeach() - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") - -add_executable(mainapp main.cpp) - -foreach(_module ${qtbase_modules}) - target_link_libraries(mainapp - ${Qt5${_module}_LIBRARIES} - ) -endforeach() From 8c4d02f97affdca88e25de894788124033133d87 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 31 Oct 2012 16:54:18 +0200 Subject: [PATCH 090/134] Use qt-project.org in tst_hostinfo - qt.nokia.com changed IP address. qt.nokia.com is also going to disapper in future, so I think it is better to use qt-project.org. Change-Id: Ice550fe657a33609472b8e4b8630d7649f9c9fb5 Reviewed-by: Shane Kearns Reviewed-by: Sergio Ahumada --- .../network/kernel/qhostinfo/tst_qhostinfo.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 25ea5ca76ed..f4c585c5940 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -430,10 +430,10 @@ class LookupThread : public QThread protected: inline void run() { - QHostInfo info = QHostInfo::fromName("qt.nokia.com"); + QHostInfo info = QHostInfo::fromName("qt-project.org"); QCOMPARE(info.error(), QHostInfo::NoError); QVERIFY(info.addresses().count() > 0); - QCOMPARE(info.addresses().at(0).toString(), QString("87.238.50.178")); + QCOMPARE(info.addresses().at(0).toString(), QString("87.238.53.172")); } }; @@ -468,7 +468,7 @@ public: void LookupReceiver::start() { for (int i=0;iwait(60000)); foreach (LookupReceiver* receiver, receivers) { QCOMPARE(receiver->result.error(), QHostInfo::NoError); - QCOMPARE(receiver->result.addresses().at(0).toString(), QString("87.238.50.178")); + QCOMPARE(receiver->result.addresses().at(0).toString(), QString("87.238.53.172")); QCOMPARE(receiver->numrequests, 0); } } @@ -536,7 +536,7 @@ void tst_QHostInfo::multipleDifferentLookups_data() void tst_QHostInfo::multipleDifferentLookups() { QStringList hostnameList; - hostnameList << "www.ovi.com" << "www.nokia.com" << "qt.nokia.com" << "www.trolltech.com" << "troll.no" + hostnameList << "www.ovi.com" << "www.nokia.com" << "qt-project.org" << "www.trolltech.com" << "troll.no" << "www.qtcentre.org" << "forum.nokia.com" << "www.nokia.com" << "wiki.forum.nokia.com" << "www.nokia.com" << "nokia.de" << "127.0.0.1" << "----"; @@ -610,7 +610,7 @@ void tst_QHostInfo::abortHostLookup() lookupsDoneCounter = 0; bool valid = false; int id = -1; - QHostInfo result = qt_qhostinfo_lookup("qt.nokia.com", this, SLOT(resultsReady(QHostInfo)), &valid, &id); + QHostInfo result = qt_qhostinfo_lookup("qt-project.org", this, SLOT(resultsReady(QHostInfo)), &valid, &id); QVERIFY(!valid); //it is assumed that the DNS request/response in the backend is slower than it takes to call abort QHostInfo::abortHostLookup(id); @@ -637,7 +637,7 @@ void tst_QHostInfo::abortHostLookupInDifferentThread() lookupsDoneCounter = 0; bool valid = false; int id = -1; - QHostInfo result = qt_qhostinfo_lookup("qt.nokia.com", this, SLOT(resultsReady(QHostInfo)), &valid, &id); + QHostInfo result = qt_qhostinfo_lookup("qt-project.org", this, SLOT(resultsReady(QHostInfo)), &valid, &id); QVERIFY(!valid); QThread thread; LookupAborter aborter; From 4b71432987ca9ff059d04f0e5f567b8eb09717f9 Mon Sep 17 00:00:00 2001 From: Andrey Leonov Date: Fri, 26 Oct 2012 14:56:37 -0400 Subject: [PATCH 091/134] Adding PAC and exclusion list support to BlackBerry Qt proxy implementation. The additional proxy functionality is only available starting BPS API version 3.1.1. Change-Id: Iadd2950119fa1dca706e8cd34804b038e3f704bc Reviewed-by: Peter Hartmann --- src/network/kernel/qnetworkproxy.cpp | 7 +++--- .../kernel/qnetworkproxy_blackberry.cpp | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 85641895b7b..aa16be2b4af 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -1560,10 +1560,9 @@ void QNetworkProxyFactory::setApplicationProxyFactory(QNetworkProxyFactory *fact \li On Windows platforms, this function may take several seconds to execute depending on the configuration of the user's system. - \li On BlackBerry, this function ignores network configuration specified - in \a query. Only UrlRequest quieries are supported. SOCKS is not supported. - The proxy information is retrieved only for the default configuration. - Also, PAC and exclusion lists are currently not supported. + \li On BlackBerry, only UrlRequest queries are supported. SOCKS is + not supported. The proxy credentials are only retrieved for the + default configuration. \endlist */ diff --git a/src/network/kernel/qnetworkproxy_blackberry.cpp b/src/network/kernel/qnetworkproxy_blackberry.cpp index c257f085ffc..2743b904041 100644 --- a/src/network/kernel/qnetworkproxy_blackberry.cpp +++ b/src/network/kernel/qnetworkproxy_blackberry.cpp @@ -79,11 +79,34 @@ QList QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro netstatus_proxy_details_t details; memset(&details, 0, sizeof(netstatus_proxy_details_t)); + +#if BPS_VERSION >= 3001001 + + QByteArray bUrl(url.toEncoded()); + QString sInterface(query.networkConfiguration().name()); + QByteArray bInterface; + if (!sInterface.isEmpty()) { + if (query.networkConfiguration().type() != QNetworkConfiguration::InternetAccessPoint) { + qWarning("Unsupported configuration type: %d", query.networkConfiguration().type()); + return QList() << QNetworkProxy(QNetworkProxy::NoProxy); + } + bInterface = sInterface.toUtf8(); + } + + if (netstatus_get_proxy_details_for_url(bUrl.constData(), (bInterface.isEmpty() ? NULL : bInterface.constData()), &details) != BPS_SUCCESS) { + qWarning("netstatus_get_proxy_details_for_url failed! errno: %d", errno); + return QList() << QNetworkProxy(QNetworkProxy::NoProxy); + } + +#else + if (netstatus_get_proxy_details(&details) != BPS_SUCCESS) { qWarning("netstatus_get_proxy_details failed! errno: %d", errno); return QList() << QNetworkProxy(QNetworkProxy::NoProxy); } +#endif + if (details.http_proxy_host == NULL) { // No proxy netstatus_free_proxy_details(&details); return QList() << QNetworkProxy(QNetworkProxy::NoProxy); From aa49ad58ad57809e0724f1c4152d925bcbd63856 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 30 Oct 2012 19:32:39 +0100 Subject: [PATCH 092/134] test: Moving tst_QMimeDatabase::inheritsPerformance() test tst_QMimeDatabase::inheritsPerformance() is not an unit test but a performance test, so moving it from 'tests/auto/corelib/mimetypes/qmimedatabase' to 'tests/benchmarks/corelib/mimetypes/qmimedatabase' Change-Id: I59e84f61559023659f101666683870f2ca1d2034 Reviewed-by: David Faure (KDE) Reviewed-by: Rohan McGovern --- .../qmimedatabase/tst_qmimedatabase.cpp | 32 ------- .../qmimedatabase/tst_qmimedatabase.h | 1 - tests/benchmarks/corelib/corelib.pro | 1 + .../corelib/mimetypes/mimetypes.pro | 3 + .../corelib/mimetypes/qmimedatabase/main.cpp | 87 +++++++++++++++++++ .../mimetypes/qmimedatabase/qmimedatabase.pro | 6 ++ 6 files changed, 97 insertions(+), 33 deletions(-) create mode 100644 tests/benchmarks/corelib/mimetypes/mimetypes.pro create mode 100644 tests/benchmarks/corelib/mimetypes/qmimedatabase/main.cpp create mode 100644 tests/benchmarks/corelib/mimetypes/qmimedatabase/qmimedatabase.pro diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index b731eaf12a4..0d41328320d 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -517,38 +517,6 @@ void tst_QMimeDatabase::allMimeTypes() } } -void tst_QMimeDatabase::inheritsPerformance() -{ - // Check performance of inherits(). - // This benchmark (which started in 2009 in kmimetypetest.cpp) uses 40 mimetypes. - QStringList mimeTypes; mimeTypes << QLatin1String("image/jpeg") << QLatin1String("image/png") << QLatin1String("image/tiff") << QLatin1String("text/plain") << QLatin1String("text/html"); - mimeTypes += mimeTypes; - mimeTypes += mimeTypes; - mimeTypes += mimeTypes; - QCOMPARE(mimeTypes.count(), 40); - QMimeDatabase db; - QMimeType mime = db.mimeTypeForName(QString::fromLatin1("text/x-chdr")); - QVERIFY(mime.isValid()); - QBENCHMARK { - QString match; - foreach (const QString &mt, mimeTypes) { - if (mime.inherits(mt)) { - match = mt; - // of course there would normally be a "break" here, but we're testing worse-case - // performance here - } - } - QCOMPARE(match, QString::fromLatin1("text/plain")); - } - // Numbers from 2011, in release mode: - // KDE 4.7 numbers: 0.21 msec / 494,000 ticks / 568,345 instr. loads per iteration - // QMimeBinaryProvider (with Qt 5): 0.16 msec / NA / 416,049 instr. reads per iteration - // QMimeXmlProvider (with Qt 5): 0.062 msec / NA / 172,889 instr. reads per iteration - // (but the startup time is way higher) - // And memory usage is flat at 200K with QMimeBinaryProvider, while it peaks at 6 MB when - // parsing XML, and then keeps being around 4.5 MB for all the in-memory hashes. -} - void tst_QMimeDatabase::suffixes_data() { QTest::addColumn("mimeType"); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h index f30eb004615..ea050b5014f 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h @@ -70,7 +70,6 @@ private slots: void mimeTypeForFileAndContent_data(); void mimeTypeForFileAndContent(); void allMimeTypes(); - void inheritsPerformance(); void suffixes_data(); void suffixes(); void knownSuffix(); diff --git a/tests/benchmarks/corelib/corelib.pro b/tests/benchmarks/corelib/corelib.pro index da5247cc424..b5781ad49ef 100644 --- a/tests/benchmarks/corelib/corelib.pro +++ b/tests/benchmarks/corelib/corelib.pro @@ -2,6 +2,7 @@ TEMPLATE = subdirs SUBDIRS = \ io \ json \ + mimetypes \ kernel \ thread \ tools \ diff --git a/tests/benchmarks/corelib/mimetypes/mimetypes.pro b/tests/benchmarks/corelib/mimetypes/mimetypes.pro new file mode 100644 index 00000000000..14dc5f0e10c --- /dev/null +++ b/tests/benchmarks/corelib/mimetypes/mimetypes.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qmimedatabase \ diff --git a/tests/benchmarks/corelib/mimetypes/qmimedatabase/main.cpp b/tests/benchmarks/corelib/mimetypes/qmimedatabase/main.cpp new file mode 100644 index 00000000000..4a4d25d2013 --- /dev/null +++ b/tests/benchmarks/corelib/mimetypes/qmimedatabase/main.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class tst_QMimeDatabase: public QObject +{ + + Q_OBJECT + +private slots: + void inheritsPerformance(); +}; + +void tst_QMimeDatabase::inheritsPerformance() +{ + // Check performance of inherits(). + // This benchmark (which started in 2009 in kmimetypetest.cpp) uses 40 mimetypes. + QStringList mimeTypes; + mimeTypes << QLatin1String("image/jpeg") << QLatin1String("image/png") << QLatin1String("image/tiff") << QLatin1String("text/plain") << QLatin1String("text/html"); + mimeTypes += mimeTypes; + mimeTypes += mimeTypes; + mimeTypes += mimeTypes; + QCOMPARE(mimeTypes.count(), 40); + QMimeDatabase db; + QMimeType mime = db.mimeTypeForName(QString::fromLatin1("text/x-chdr")); + QVERIFY(mime.isValid()); + QBENCHMARK { + QString match; + foreach (const QString &mt, mimeTypes) { + if (mime.inherits(mt)) { + match = mt; + // of course there would normally be a "break" here, but we're testing worse-case + // performance here + } + } + QCOMPARE(match, QString::fromLatin1("text/plain")); + } + // Numbers from 2011, in release mode: + // KDE 4.7 numbers: 0.21 msec / 494,000 ticks / 568,345 instr. loads per iteration + // QMimeBinaryProvider (with Qt 5): 0.16 msec / NA / 416,049 instr. reads per iteration + // QMimeXmlProvider (with Qt 5): 0.062 msec / NA / 172,889 instr. reads per iteration + // (but the startup time is way higher) + // And memory usage is flat at 200K with QMimeBinaryProvider, while it peaks at 6 MB when + // parsing XML, and then keeps being around 4.5 MB for all the in-memory hashes. +} + +QTEST_MAIN(tst_QMimeDatabase) +#include "main.moc" diff --git a/tests/benchmarks/corelib/mimetypes/qmimedatabase/qmimedatabase.pro b/tests/benchmarks/corelib/mimetypes/qmimedatabase/qmimedatabase.pro new file mode 100644 index 00000000000..0a0d9b11930 --- /dev/null +++ b/tests/benchmarks/corelib/mimetypes/qmimedatabase/qmimedatabase.pro @@ -0,0 +1,6 @@ +QT = core testlib + +TARGET = tst_bench_qmimedatabase +SOURCES = main.cpp + +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 From dea233f0ac7c54400ab9d280995d601f39c676b2 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 30 Oct 2012 19:18:27 +0100 Subject: [PATCH 093/134] test: Remove QSKIP from tst_QSettings::dontReorderIniKeysNeedlessly() Change-Id: I7b804592398869278e9a0fec982c235c41f2c3d7 Reviewed-by: Caroline Chao --- tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 84fbfb41313..1cf15e898fc 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -115,7 +115,7 @@ private slots: void setPath(); void setDefaultFormat(); void dontCreateNeedlessPaths(); -#if !defined(Q_OS_WIN) +#if !defined(Q_OS_WIN) && !defined(QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER) void dontReorderIniKeysNeedlessly(); #endif #if defined(Q_OS_WIN) @@ -3017,12 +3017,10 @@ void tst_QSettings::dontCreateNeedlessPaths() QVERIFY(!fileInfo.dir().exists()); } -#if !defined(Q_OS_WIN) +#if !defined(Q_OS_WIN) && !defined(QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER) +// This Qt build does not preserve ordering, as a code size optimization. void tst_QSettings::dontReorderIniKeysNeedlessly() { -#ifdef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER - QSKIP("This Qt build does not preserve ordering, as a code size optimization."); -#endif /* This is a very strong test. It asserts that modifying From 7539fa9143b569733bc6574f4626b5aff22a00c2 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 30 Oct 2012 11:15:35 +0100 Subject: [PATCH 094/134] CONFIG+=uitools is deprecated. Use QT+=uitools instead Change-Id: I45105e5e1dde614d90b1fb392b6e01e698c27a7f Reviewed-by: Oswald Buddenhagen --- doc/src/snippets/code/doc_src_examples_textfinder.pro | 2 +- util/accessibilityinspector/accessibilityinspector.pri | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/snippets/code/doc_src_examples_textfinder.pro b/doc/src/snippets/code/doc_src_examples_textfinder.pro index ae070f4ac2c..4446e8eb7ba 100644 --- a/doc/src/snippets/code/doc_src_examples_textfinder.pro +++ b/doc/src/snippets/code/doc_src_examples_textfinder.pro @@ -1,5 +1,5 @@ #! [0] -CONFIG += uitools +QT += uitools HEADERS = textfinder.h RESOURCES = textfinder.qrc SOURCES = textfinder.cpp main.cpp diff --git a/util/accessibilityinspector/accessibilityinspector.pri b/util/accessibilityinspector/accessibilityinspector.pri index be0a09ccf6f..30519a97184 100644 --- a/util/accessibilityinspector/accessibilityinspector.pri +++ b/util/accessibilityinspector/accessibilityinspector.pri @@ -2,7 +2,7 @@ QT += declarative INCLUDEPATH += $$PWD # DEFINES += ACCESSIBILITYINSPECTOR_NO_UITOOLS -# CONFIG += uitools +# QT += uitools HEADERS += \ $$PWD/screenreader.h \ From a5e95ce39ebb84a5cd21258ceb1b64c544fc6d47 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 25 Oct 2012 12:45:13 +0200 Subject: [PATCH 095/134] Add manual test for dialogs. Implemented for QFileDialog, currently. Task-number: QTBUG-27621 Change-Id: I0c9b7628aa92e3fbca6f737448a7c469893764f1 Reviewed-by: Miikka Heikkinen Reviewed-by: Sergio Ahumada --- tests/manual/dialogs/dialogs.pro | 8 + tests/manual/dialogs/filedialogpanel.cpp | 373 +++++++++++++++++++++++ tests/manual/dialogs/filedialogpanel.h | 93 ++++++ tests/manual/dialogs/main.cpp | 83 +++++ tests/manual/manual.pro | 3 +- 5 files changed, 559 insertions(+), 1 deletion(-) create mode 100644 tests/manual/dialogs/dialogs.pro create mode 100644 tests/manual/dialogs/filedialogpanel.cpp create mode 100644 tests/manual/dialogs/filedialogpanel.h create mode 100644 tests/manual/dialogs/main.cpp diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro new file mode 100644 index 00000000000..ff916d3854b --- /dev/null +++ b/tests/manual/dialogs/dialogs.pro @@ -0,0 +1,8 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = dialogs +TEMPLATE = app + +SOURCES += main.cpp filedialogpanel.cpp +HEADERS += filedialogpanel.h diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp new file mode 100644 index 00000000000..4da3d6ee428 --- /dev/null +++ b/tests/manual/dialogs/filedialogpanel.cpp @@ -0,0 +1,373 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filedialogpanel.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +struct ComboData +{ + const char *description; + int value; +}; + +const ComboData acceptModeComboData[] = +{ +{"AcceptOpen", QFileDialog::AcceptOpen }, +{"AcceptSave", QFileDialog::AcceptSave } +}; + +const ComboData viewModeComboData[] = +{ + {"Detail", QFileDialog::Detail}, + {"List", QFileDialog::List} +}; + +const ComboData fileModeComboData[] = +{ + {"AnyFile", QFileDialog::AnyFile}, + {"ExistingFile", QFileDialog::ExistingFile}, + {"ExistingFiles", QFileDialog::ExistingFiles}, + {"Directory", QFileDialog::Directory}, + {"DirectoryOnly", QFileDialog::DirectoryOnly} +}; + +static QComboBox *createCombo(QWidget *parent, const ComboData *d, size_t size) +{ + QComboBox *c = new QComboBox(parent); + for (size_t i = 0; i < size; ++i) + c->addItem(QLatin1String(d[i].description), QVariant(d[i].value)); + return c; +} + +template +Enum comboBoxValue(const QComboBox *c) +{ + return static_cast(c->itemData(c->currentIndex()).toInt()); +} + +inline void setComboBoxValue(QComboBox *c, int v) +{ + c->setCurrentIndex(c->findData(QVariant(v))); +} + +static inline void addButton(const QString &desription, QBoxLayout *layout, QObject *receiver, const char *slotFunc) +{ + QPushButton *button = new QPushButton(desription); + QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc); + layout->addWidget(button); +} + +// A line edit for editing the label fields of the dialog, keeping track of whether it has +// been modified by the user to avoid applying Qt's default texts to native dialogs. + +class LabelLineEdit : public QLineEdit +{ + Q_OBJECT +public: + explicit LabelLineEdit(QFileDialog::DialogLabel label, QWidget *parent = 0) : QLineEdit(parent), m_label(label), m_dirty(false) + { + connect(this, SIGNAL(textEdited(QString)), this, SLOT(setDirty())); + } + + void restoreDefault(const QFileDialog *d) + { + setText(d->labelText(m_label)); + m_dirty = false; + } + + void apply(QFileDialog *d) const + { + if (m_dirty) + d->setLabelText(m_label, text()); + } + +private slots: + void setDirty() { m_dirty = true; } + +private: + const QFileDialog::DialogLabel m_label; + bool m_dirty; +}; + +FileDialogPanel::FileDialogPanel(QWidget *parent) + : QWidget(parent) + , m_readOnly(new QCheckBox(tr("Read only"))) + , m_confirmOverWrite(new QCheckBox(tr("Confirm overwrite"))) + , m_nameFilterDetailsVisible(new QCheckBox(tr("Name filter details visible"))) + , m_resolveSymLinks(new QCheckBox(tr("Resolve symlinks"))) + , m_native(new QCheckBox(tr("Use native dialog"))) + , m_acceptMode(createCombo(this, acceptModeComboData, sizeof(acceptModeComboData)/sizeof(ComboData))) + , m_fileMode(createCombo(this, fileModeComboData, sizeof(fileModeComboData)/sizeof(ComboData))) + , m_viewMode(createCombo(this, viewModeComboData, sizeof(viewModeComboData)/sizeof(ComboData))) + , m_defaultSuffix(new QLineEdit(this)) + , m_directory(new QLineEdit(this)) + , m_selectedFileName(new QLineEdit(this)) + , m_nameFilters(new QPlainTextEdit) + , m_selectedNameFilter(new QLineEdit(this)) +{ + // Options + QGroupBox *optionsGroupBox = new QGroupBox(tr("Options")); + QFormLayout *optionsLayout = new QFormLayout(optionsGroupBox); + optionsLayout->addRow(tr("AcceptMode:"), m_acceptMode); + optionsLayout->addRow(tr("FileMode:"), m_fileMode); + optionsLayout->addRow(tr("ViewMode:"), m_viewMode); + optionsLayout->addRow(m_native); + optionsLayout->addRow(m_confirmOverWrite); + optionsLayout->addRow(m_nameFilterDetailsVisible); + optionsLayout->addRow(m_resolveSymLinks); + optionsLayout->addRow(m_readOnly); + + // Files + QGroupBox *filesGroupBox = new QGroupBox(tr("Files / Filters")); + QFormLayout *filesLayout = new QFormLayout(filesGroupBox); + filesLayout->addRow(tr("Default Suffix:"), m_defaultSuffix); + filesLayout->addRow(tr("Directory:"), m_directory); + filesLayout->addRow(tr("Selected file:"), m_selectedFileName); + m_nameFilters->setMaximumHeight(80); + filesLayout->addRow(tr("Name filters:"), m_nameFilters); + filesLayout->addRow(tr("Selected name filter:"), m_selectedNameFilter); + + // Optional labels + QGroupBox *labelsGroupBox = new QGroupBox(tr("Labels")); + QFormLayout *labelsLayout = new QFormLayout(labelsGroupBox); + m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::LookIn, this)); + labelsLayout->addRow(tr("Look in label:"), m_labelLineEdits.back()); + m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::FileName, this)); + labelsLayout->addRow(tr("File name label:"), m_labelLineEdits.back()); + m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::FileType, this)); + labelsLayout->addRow(tr("File type label:"), m_labelLineEdits.back()); + m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::Accept, this)); + labelsLayout->addRow(tr("Accept label:"), m_labelLineEdits.back()); + m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::Reject, this)); + labelsLayout->addRow(tr("Reject label:"), m_labelLineEdits.back()); + + // Buttons + QVBoxLayout *buttonLayout = new QVBoxLayout; + buttonLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + addButton(tr("Show modal"), buttonLayout, this, SLOT(showModal())); + addButton(tr("Show non-modal"), buttonLayout, this, SLOT(showNonModal())); + addButton(tr("getOpenFileName"), buttonLayout, this, SLOT(getOpenFileName())); + addButton(tr("getOpenFileNames"), buttonLayout, this, SLOT(getOpenFileNames())); + addButton(tr("getSaveFileName"), buttonLayout, this, SLOT(getSaveFileName())); + addButton(tr("getExistingDirectory"), buttonLayout, this, SLOT(getExistingDirectory())); + addButton(tr("Restore defaults"), buttonLayout, this, SLOT(restoreDefaults())); + QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show")); + QHBoxLayout *buttonsGroupLayout = new QHBoxLayout(buttonsGroupBox); + buttonsGroupLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + buttonsGroupLayout->addLayout(buttonLayout); + + // Main layout + QGridLayout *gridLayout = new QGridLayout(this); + gridLayout->addWidget(optionsGroupBox, 0, 0); + gridLayout->addWidget(filesGroupBox, 0, 1); + gridLayout->addWidget(labelsGroupBox, 1, 0); + gridLayout->addWidget(buttonsGroupBox, 1, 1); + + restoreDefaults(); +} + +void FileDialogPanel::showModal() +{ + QFileDialog dialog(this); + applySettings(&dialog); + dialog.setWindowTitle(tr("Modal File Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR))); + dialog.exec(); +} + +void FileDialogPanel::showNonModal() +{ + QFileDialog *dialog = new QFileDialog(this); + dialog->setAttribute(Qt::WA_DeleteOnClose); + applySettings(dialog); + dialog->setWindowTitle(tr("Non-Modal File Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR))); + dialog->show(); +} + +QString FileDialogPanel::filterString() const +{ + return m_nameFilters->toPlainText().trimmed().replace(QLatin1String("\n"), QLatin1String(";;")); +} + +QFileDialog::Options FileDialogPanel::options() const +{ + QFileDialog::Options result; + if (!m_nameFilterDetailsVisible->isChecked()) + result |= QFileDialog::HideNameFilterDetails; + if (!m_resolveSymLinks->isChecked()) + result |= QFileDialog::DontResolveSymlinks; + if (m_readOnly->isChecked()) + result |= QFileDialog::ReadOnly; + if (!m_confirmOverWrite->isChecked()) + result |= QFileDialog::DontConfirmOverwrite; + if (!m_native->isChecked()) + result |= QFileDialog::DontUseNativeDialog; + return result; +} + +void FileDialogPanel::getOpenFileNames() +{ + QString selectedFilter = m_selectedNameFilter->text().trimmed(); + const QStringList files = + QFileDialog::getOpenFileNames(this, tr("getOpenFileNames Qt %1").arg(QLatin1String(QT_VERSION_STR)), + m_directory->text(), filterString(), &selectedFilter, options()); + if (!files.isEmpty()) { + QString result; + QDebug(&result).nospace() + << "Files: " << files + << "\nName filter: " << selectedFilter; + QMessageBox::information(this, tr("getOpenFileNames"), result, QMessageBox::Ok); + } +} + +void FileDialogPanel::getOpenFileName() +{ + QString selectedFilter = m_selectedNameFilter->text().trimmed(); + const QString file = + QFileDialog::getOpenFileName(this, tr("getOpenFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)), + m_directory->text(), filterString(), &selectedFilter, options()); + if (!file.isEmpty()) { + QString result; + QDebug(&result).nospace() + << "File: " << file + << "\nName filter: " << selectedFilter; + QMessageBox::information(this, tr("getOpenFileName"), result, QMessageBox::Ok); + } +} + +void FileDialogPanel::getSaveFileName() +{ + QString selectedFilter = m_selectedNameFilter->text().trimmed(); + const QString file = + QFileDialog::getSaveFileName(this, tr("getSaveFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)), + m_directory->text(), filterString(), &selectedFilter, options()); + if (!file.isEmpty()) { + QString result; + QDebug(&result).nospace() + << "File: " << file + << "\nName filter: " << selectedFilter; + QMessageBox::information(this, tr("getSaveFileNames"), result, QMessageBox::Ok); + } +} + +void FileDialogPanel::getExistingDirectory() +{ + const QString dir = + QFileDialog::getExistingDirectory(this, tr("getExistingDirectory Qt %1").arg(QLatin1String(QT_VERSION_STR)), + m_directory->text(), options() | QFileDialog::ShowDirsOnly); + if (!dir.isEmpty()) + QMessageBox::information(this, tr("getExistingDirectory"), QLatin1String("Directory: ") + dir, QMessageBox::Ok); +} + +void FileDialogPanel::restoreDefaults() +{ + QFileDialog d; + setComboBoxValue(m_acceptMode, d.acceptMode()); + setComboBoxValue(m_fileMode, d.fileMode()); + setComboBoxValue(m_viewMode, d.viewMode()); + m_confirmOverWrite->setChecked(d.confirmOverwrite()); + m_nameFilterDetailsVisible->setChecked(d.isNameFilterDetailsVisible()); + m_resolveSymLinks->setChecked(d.resolveSymlinks()); + m_readOnly->setChecked(d.isReadOnly()); + m_native->setChecked(true); + m_directory->setText(QDir::homePath()); + m_defaultSuffix->setText(QLatin1String(".txt")); + m_nameFilters->setPlainText(QLatin1String("Any files (*)\nImage files (*.png *.xpm *.jpg)\nText files (*.txt)")); + m_selectedFileName->setText(QString()); + m_selectedNameFilter->setText(QString()); + foreach (LabelLineEdit *l, m_labelLineEdits) + l->restoreDefault(&d); +} + +void FileDialogPanel::applySettings(QFileDialog *d) const +{ + d->setAcceptMode(comboBoxValue(m_acceptMode)); + d->setViewMode(comboBoxValue(m_viewMode)); + d->setFileMode(comboBoxValue(m_fileMode)); + d->setOptions(options()); + d->setDefaultSuffix(m_defaultSuffix->text().trimmed()); + d->setDirectory(m_directory->text().trimmed()); + const QString file = m_selectedFileName->text().trimmed(); + if (!file.isEmpty()) + d->selectFile(file); + d->setNameFilters(m_nameFilters->toPlainText().trimmed().split(QLatin1Char('\n'), QString::SkipEmptyParts)); + const QString filter = m_selectedNameFilter->text().trimmed(); + if (!filter.isEmpty()) + d->selectNameFilter(filter); + foreach (LabelLineEdit *l, m_labelLineEdits) + l->apply(d); + connect(d, SIGNAL(accepted()), this, SLOT(accepted())); +} + +void FileDialogPanel::accepted() +{ + const QFileDialog *d = qobject_cast(sender()); + Q_ASSERT(d); + m_result.clear(); + QDebug(&m_result).nospace() + << "Files: " << d->selectedFiles() + << "\nDirectory: " << d->directory().absolutePath() + << "\nName filter: " << d->selectedNameFilter(); + QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent. +} + +void FileDialogPanel::showAcceptedResult() +{ + QMessageBox::information(this, tr("File Dialog Accepted"), m_result, QMessageBox::Ok); +} + +#include "filedialogpanel.moc" diff --git a/tests/manual/dialogs/filedialogpanel.h b/tests/manual/dialogs/filedialogpanel.h new file mode 100644 index 00000000000..bc8b66535bd --- /dev/null +++ b/tests/manual/dialogs/filedialogpanel.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FILEDIALOGPANEL_H +#define FILEDIALOGPANEL_H + +#include +#include + +class QCheckBox; +class QComboBox; +class QLineEdit; +class QPlainTextEdit; +class LabelLineEdit; + +class FileDialogPanel : public QWidget +{ + Q_OBJECT +public: + explicit FileDialogPanel(QWidget *parent = 0); + +public slots: + void showModal(); + void showNonModal(); + void getOpenFileNames(); + void getOpenFileName(); + void getSaveFileName(); + void getExistingDirectory(); + void accepted(); + void showAcceptedResult(); + void restoreDefaults(); + +private: + QString filterString() const; + QFileDialog::Options options() const; + void applySettings(QFileDialog *d) const; + + QCheckBox *m_readOnly; + QCheckBox *m_confirmOverWrite; + QCheckBox *m_nameFilterDetailsVisible; + QCheckBox *m_resolveSymLinks; + QCheckBox *m_native; + QComboBox *m_acceptMode; + QComboBox *m_fileMode; + QComboBox *m_viewMode; + QLineEdit *m_defaultSuffix; + QLineEdit *m_directory; + QLineEdit *m_selectedFileName; + QList m_labelLineEdits; + QPlainTextEdit *m_nameFilters; + QLineEdit *m_selectedNameFilter; + QString m_result; +}; + +#endif // FILEDIALOGPANEL_H diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp new file mode 100644 index 00000000000..ab6c6239906 --- /dev/null +++ b/tests/manual/dialogs/main.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filedialogpanel.h" + +#include +#include +#include +#include +#include +#include +#include + +// Test for dialogs, allowing to play with all dialog options for implementing native dialogs. +// Currently, only QFileDialog is implemented. +// Compiles with Qt 4.8 and Qt 5. + +class MainWindow : public QMainWindow { + Q_OBJECT +public: + explicit MainWindow(QWidget *parent = 0); +}; + +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) +{ + setWindowTitle(tr("Dialogs Qt %1").arg(QLatin1String(QT_VERSION_STR))); + QMenu *fileMenu = menuBar()->addMenu(tr("File")); + QAction *quitAction = fileMenu->addAction(tr("Quit")); + quitAction->setShortcut(QKeySequence(QKeySequence::Quit)); + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + QTabWidget *tabWidget = new QTabWidget; + tabWidget->addTab(new FileDialogPanel, tr("QFileDialog")); + setCentralWidget(tabWidget); +} + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.move(500, 200); + w.show(); + return a.exec(); +} + +#include "main.moc" diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 04bdff6abcb..cfa812aabae 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -32,7 +32,8 @@ widgets/itemviews/delegate \ windowflags \ windowgeometry \ windowmodality \ -widgetgrab +widgetgrab \ +dialogs !contains(QT_CONFIG, openssl):!contains(QT_CONFIG, openssl-linked):SUBDIRS -= qssloptions From e27a58864366b65803bcd43e0b8994169d3d291a Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 24 Oct 2012 12:25:45 +0200 Subject: [PATCH 096/134] Testlib: Disable gcc warning about deprecated qInstallMsgHandler Fix warning: 'void (* qInstallMsgHandler(QtMsgHandler))(QtMsgType, const char*)' is deprecated (declared at qtestlog.cpp:85) [-Wdeprecated-declarations] Change-Id: I28d2baf696fdeddec90780edc88574fc368468db Reviewed-by: Friedemann Kleint --- src/testlib/qtestlog.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index c56a00237b7..a337a819596 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -238,6 +238,12 @@ namespace QTest { return false; } +// don't warn about qInstallMsgHandler +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && !defined(Q_CC_INTEL) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + static void messageHandler(QtMsgType type, const char *msg) { static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(QTest::maxWarnings); @@ -287,6 +293,10 @@ namespace QTest { break; } } + +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && !defined(Q_CC_INTEL) +# pragma GCC diagnostic pop +#endif } void QTestLog::enterTestFunction(const char* function) From 62b9ca4320dcc952db54bfaf867d68ca49ae38a9 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 1 Nov 2012 13:40:43 +0100 Subject: [PATCH 097/134] Fix buttonsize on macstyle when no widget is defined The previous size was incorrect and added far too much height when the widget was undefined. When it was defined it would get its size corrected so the patch should have very little effect on existing widget code. Change-Id: I7c22f4226eda270f0d71050bc4248686b035cb39 Reviewed-by: Jens Bache-Wiig Reviewed-by: J-P Nurmi --- src/widgets/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index f1d513bc23b..522d43dd28e 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -6176,7 +6176,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, // Do this by add enough space around the contents so that rounded // borders (including highlighting when active) will show. sz.rwidth() += QMacStylePrivate::PushButtonLeftOffset + QMacStylePrivate::PushButtonRightOffset + 12; - sz.rheight() += QMacStylePrivate::PushButtonTopOffset + QMacStylePrivate::PushButtonBottomOffset; + sz.rheight() += 4; break; case QStyle::CT_MenuItem: if (const QStyleOptionMenuItem *mi = qstyleoption_cast(opt)) { From e8702e5cef5880c760e27cc1606ddf656af7b9a0 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Mon, 29 Oct 2012 17:36:06 +0100 Subject: [PATCH 098/134] Qt Core: Removed unnecessary group membership. The 'Non-GUI Classes' page is not relevant. Also removed landing page from the 'modules' group. Change-Id: Ie2d34d36f98a4697becfebd5fbc215913bbb41ce Reviewed-by: Martin Smith --- src/corelib/doc/src/containers.qdoc | 17 ----------------- src/corelib/doc/src/qtcore-index.qdoc | 2 -- 2 files changed, 19 deletions(-) diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index 29c30869bab..262add419cd 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -25,23 +25,6 @@ ** ****************************************************************************/ -/*! - \group tools - \title Non-GUI Classes - \ingroup groups - - \brief Collection classes such as list, queue, stack and string, along - with other classes that can be used without needing QApplication. - - These \l{Qt Core} non-GUI classes are general-purpose collection and string - classes that may be used independently of the GUI classes. - - In particular, these classes do not depend on QApplication at all, - and so can be used in non-GUI programs. - - \annotatedlist tools -*/ - /*! \page containers.html \title Container Classes diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc index 5cf187172b8..f876a362c78 100644 --- a/src/corelib/doc/src/qtcore-index.qdoc +++ b/src/corelib/doc/src/qtcore-index.qdoc @@ -28,7 +28,6 @@ /*! \page qtcore-index.html \title Qt Core - \ingroup modules \brief The Qt Core module is part of Qt's essential modules. @@ -108,7 +107,6 @@ \list \li \l{Animation Framework}{Animation Classes} \li \l{Threading Classes} - \li \l{Non-GUI Classes} \li \l{Container Classes} \li \l{Plugin Classes} \li \l{Implicitly Shared Classes} From 8f62bb343bf48731efdfe1ee27eca18a5156a991 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 31 Oct 2012 10:27:33 +0100 Subject: [PATCH 099/134] move QSystemSemaphore autotest from qtscript to qtbase As the script dependency for that autotest is not really needed it should be moved to qtbase. Task-number: QTBUG-27705 Change-Id: I4ce0d34aca97cadd79b157b0f7c90c406bed4295 Reviewed-by: Joerg Bornemann --- .../qsystemsemaphore/qsystemsemaphore.pro | 3 + .../systemsemaphorehelper/main.cpp | 114 ++++++++ .../systemsemaphorehelper.pro | 9 + .../kernel/qsystemsemaphore/test/test.pro | 10 + .../test/tst_qsystemsemaphore.cpp | 275 ++++++++++++++++++ 5 files changed, 411 insertions(+) create mode 100644 tests/auto/corelib/kernel/qsystemsemaphore/qsystemsemaphore.pro create mode 100644 tests/auto/corelib/kernel/qsystemsemaphore/systemsemaphorehelper/main.cpp create mode 100644 tests/auto/corelib/kernel/qsystemsemaphore/systemsemaphorehelper/systemsemaphorehelper.pro create mode 100644 tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro create mode 100644 tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/qsystemsemaphore.pro b/tests/auto/corelib/kernel/qsystemsemaphore/qsystemsemaphore.pro new file mode 100644 index 00000000000..f8a49254d25 --- /dev/null +++ b/tests/auto/corelib/kernel/qsystemsemaphore/qsystemsemaphore.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS = systemsemaphorehelper test diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/systemsemaphorehelper/main.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/systemsemaphorehelper/main.cpp new file mode 100644 index 00000000000..2e85d8610ec --- /dev/null +++ b/tests/auto/corelib/kernel/qsystemsemaphore/systemsemaphorehelper/main.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int acquire(int count = 1) +{ + QSystemSemaphore sem("store"); + + for (int i = 0; i < count; ++i) { + if (!sem.acquire()) { + qWarning() << "Could not acquire" << sem.key(); + return EXIT_FAILURE; + } + } + qDebug("done aquiring"); + return EXIT_SUCCESS; +} + +int release() +{ + QSystemSemaphore sem("store"); + if (!sem.release()) { + qWarning() << "Could not release" << sem.key(); + return EXIT_FAILURE; + } + qDebug("done releasing"); + return EXIT_SUCCESS; +} + +int acquirerelease() +{ + QSystemSemaphore sem("store"); + if (!sem.acquire()) { + qWarning() << "Could not acquire" << sem.key(); + return EXIT_FAILURE; + } + if (!sem.release()) { + qWarning() << "Could not release" << sem.key(); + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + QStringList arguments = app.arguments(); + // binary name is not used here + arguments.takeFirst(); + if (arguments.count() < 1) { + qWarning("Please call the helper with the function to call as argument"); + return EXIT_FAILURE; + } + QString function = arguments.takeFirst(); + if (function == QLatin1String("acquire")) { + int count = 1; + bool ok = true; + if (arguments.count()) + count = arguments.takeFirst().toInt(&ok); + if (!ok) + count = 1; + return acquire(count); + } else if (function == QLatin1String("release")) { + return release(); + } else if (function == QLatin1String("acquirerelease")) { + return acquirerelease(); + } else { + qWarning() << "Unknown function" << function; + } + return EXIT_SUCCESS; +} diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/systemsemaphorehelper/systemsemaphorehelper.pro b/tests/auto/corelib/kernel/qsystemsemaphore/systemsemaphorehelper/systemsemaphorehelper.pro new file mode 100644 index 00000000000..d1a4e04567f --- /dev/null +++ b/tests/auto/corelib/kernel/qsystemsemaphore/systemsemaphorehelper/systemsemaphorehelper.pro @@ -0,0 +1,9 @@ +QT = core testlib + +DESTDIR = ./ + +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro new file mode 100644 index 00000000000..cc76b2c2338 --- /dev/null +++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +QT = core testlib + +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += tst_qsystemsemaphore.cpp +TARGET = tst_qsystemsemaphore + +DESTDIR = ../ diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp new file mode 100644 index 00000000000..85f7d2a4b21 --- /dev/null +++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#define EXISTING_SHARE "existing" +#define HELPERWAITTIME 10000 + +class tst_QSystemSemaphore : public QObject +{ + Q_OBJECT + +public: + tst_QSystemSemaphore(); + +public Q_SLOTS: + void initTestCase(); + void init(); + void cleanup(); + +private slots: + void key_data(); + void key(); + + void basicacquire(); + void complexacquire(); + + void basicProcesses(); + + void processes_data(); + void processes(); + +#ifndef Q_OS_WIN + void undo(); +#endif + void initialValue(); + +private: + QString helperBinary(); + QSystemSemaphore *existingLock; +}; + +tst_QSystemSemaphore::tst_QSystemSemaphore() +{ +} + +void tst_QSystemSemaphore::initTestCase() +{ + QVERIFY2(!helperBinary().isEmpty(), "Could not find helper binary"); +} + +void tst_QSystemSemaphore::init() +{ + existingLock = new QSystemSemaphore(EXISTING_SHARE, 1, QSystemSemaphore::Create); +} + +void tst_QSystemSemaphore::cleanup() +{ + delete existingLock; +} + +void tst_QSystemSemaphore::key_data() +{ + QTest::addColumn("constructorKey"); + QTest::addColumn("setKey"); + + QTest::newRow("null, null") << QString() << QString(); + QTest::newRow("null, one") << QString() << QString("one"); + QTest::newRow("one, two") << QString("one") << QString("two"); +} + +/*! + Basic key testing + */ +void tst_QSystemSemaphore::key() +{ + QFETCH(QString, constructorKey); + QFETCH(QString, setKey); + + QSystemSemaphore sem(constructorKey); + QCOMPARE(sem.key(), constructorKey); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QCOMPARE(sem.errorString(), QString()); + + sem.setKey(setKey); + QCOMPARE(sem.key(), setKey); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QCOMPARE(sem.errorString(), QString()); +} + +void tst_QSystemSemaphore::basicacquire() +{ + QSystemSemaphore sem("QSystemSemaphore_basicacquire", 1, QSystemSemaphore::Create); + QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QCOMPARE(sem.errorString(), QString()); +} + +void tst_QSystemSemaphore::complexacquire() +{ + QSystemSemaphore sem("QSystemSemaphore_complexacquire", 2, QSystemSemaphore::Create); + QVERIFY(sem.acquire()); + QVERIFY(sem.release()); + QVERIFY(sem.acquire()); + QVERIFY(sem.release()); + QVERIFY(sem.acquire()); + QVERIFY(sem.acquire()); + QVERIFY(sem.release()); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QCOMPARE(sem.errorString(), QString()); +} + +void tst_QSystemSemaphore::basicProcesses() +{ + QSystemSemaphore sem("store", 0, QSystemSemaphore::Create); + + QProcess acquire; + acquire.setProcessChannelMode(QProcess::ForwardedChannels); + + QProcess release; + release.setProcessChannelMode(QProcess::ForwardedChannels); + + acquire.start(helperBinary(), QStringList("acquire")); + QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); + acquire.waitForFinished(HELPERWAITTIME); + QVERIFY(acquire.state() == QProcess::Running); + acquire.kill(); + release.start(helperBinary(), QStringList("release")); + QVERIFY2(release.waitForStarted(), "Could not start helper binary"); + acquire.waitForFinished(HELPERWAITTIME); + release.waitForFinished(HELPERWAITTIME); + QVERIFY(acquire.state() == QProcess::NotRunning); +} + +void tst_QSystemSemaphore::processes_data() +{ + QTest::addColumn("processes"); + for (int i = 0; i < 5; ++i) { + QTest::newRow("1 process") << 1; + QTest::newRow("3 process") << 3; + QTest::newRow("10 process") << 10; + } +} + +void tst_QSystemSemaphore::processes() +{ + QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); + + QFETCH(int, processes); + QVector scripts(processes, "acquirerelease"); + + QList consumers; + for (int i = 0; i < scripts.count(); ++i) { + QProcess *p = new QProcess; + p->setProcessChannelMode(QProcess::ForwardedChannels); + consumers.append(p); + p->start(helperBinary(), QStringList(scripts.at(i))); + } + + while (!consumers.isEmpty()) { + consumers.first()->waitForFinished(); + QCOMPARE(consumers.first()->exitStatus(), QProcess::NormalExit); + QCOMPARE(consumers.first()->exitCode(), 0); + delete consumers.takeFirst(); + } +} + +// This test only checks a unix behavior. +#ifndef Q_OS_WIN +void tst_QSystemSemaphore::undo() +{ + QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); + + QStringList acquireArguments = QStringList("acquire"); + QProcess acquire; + acquire.setProcessChannelMode(QProcess::ForwardedChannels); + acquire.start(helperBinary(), acquireArguments); + QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); + acquire.waitForFinished(HELPERWAITTIME); + QVERIFY(acquire.state()== QProcess::NotRunning); + + // At process exit the kernel should auto undo + + acquire.start(helperBinary(), acquireArguments); + QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); + acquire.waitForFinished(HELPERWAITTIME); + QVERIFY(acquire.state()== QProcess::NotRunning); +} +#endif + +void tst_QSystemSemaphore::initialValue() +{ + QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); + + QStringList acquireArguments = QStringList("acquire"); + QStringList releaseArguments = QStringList("release"); + QProcess acquire; + acquire.setProcessChannelMode(QProcess::ForwardedChannels); + + QProcess release; + release.setProcessChannelMode(QProcess::ForwardedChannels); + + acquire.start(helperBinary(), acquireArguments); + QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); + acquire.waitForFinished(HELPERWAITTIME); + QVERIFY(acquire.state()== QProcess::NotRunning); + + acquire.start(helperBinary(), acquireArguments << QLatin1String("2")); + QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); + acquire.waitForFinished(HELPERWAITTIME); + QVERIFY(acquire.state()== QProcess::Running); + acquire.kill(); + + release.start(helperBinary(), releaseArguments); + QVERIFY2(release.waitForStarted(), "Could not start helper binary"); + acquire.waitForFinished(HELPERWAITTIME); + release.waitForFinished(HELPERWAITTIME); + QVERIFY(acquire.state()== QProcess::NotRunning); +} + +QString tst_QSystemSemaphore::helperBinary() +{ + QString binary = QStringLiteral("systemsemaphorehelper/systemsemaphorehelper"); +#ifdef Q_OS_WIN + binary += QStringLiteral(".exe"); +#endif + return binary; +} +QTEST_MAIN(tst_QSystemSemaphore) +#include "tst_qsystemsemaphore.moc" + From d45cebbf4d6a8fd2406f41e151a63c9f241879f7 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 1 Nov 2012 14:33:36 +0100 Subject: [PATCH 100/134] Remove #ifndef QT_NO_ACCESSIBILITY around qaccessible.{h,cpp} Jens has an use-case for using accessibility from styles. By making the enums always available regardless of QT_NO_ACCESSIBILITY, it makes the style code less littered with ifndefs. It should (ahem) also solve the problem where Qt Desktop components does not compile if QT_NO_ACCESSIBILITY is not defined. This happens on some linux distros, since atspi-2-dev is not installed by default, which again causes grief for those affected. Change-Id: I15d65df8c752a0c4af37cc7b4d908a757cb6a9c4 Reviewed-by: Jens Bache-Wiig --- src/gui/accessible/qaccessible.cpp | 3 --- src/gui/accessible/qaccessible.h | 4 ---- 2 files changed, 7 deletions(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index feaf468c544..61f1773d703 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -41,8 +41,6 @@ #include "qaccessible.h" -#ifndef QT_NO_ACCESSIBILITY - #include "qaccessibleplugin.h" #include "qaccessibleobject.h" #include "qaccessiblebridge.h" @@ -1265,4 +1263,3 @@ QDebug operator<<(QDebug d, const QAccessibleEvent &ev) QT_END_NAMESPACE -#endif diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index 08c0952a5a0..1fb6c654826 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -58,8 +58,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY - class QAccessibleInterface; class QAccessibleEvent; class QWindow; @@ -678,8 +676,6 @@ inline void QAccessible::updateAccessibility(QObject *object, int child, Event r } #endif -#endif // QT_NO_ACCESSIBILITY - QT_END_NAMESPACE QT_END_HEADER From 731ba8ed08f80644b403556638c7f6229e678ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 25 Oct 2012 12:32:52 +0200 Subject: [PATCH 101/134] Fix for leak in QFuture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid leaking when converting a QFuture to a QFuture we need to have a separate ref. counter for QFuture. When the last QFuture goes out of scope, we need to clean out the result data. Task-number: QTBUG-27224 Change-Id: I965a64a11fffbb191ab979cdd030a9aafd4436c2 Reviewed-by: Jędrzej Nowacki --- src/corelib/thread/qfutureinterface.cpp | 10 +++++ src/corelib/thread/qfutureinterface.h | 15 +++++-- src/corelib/thread/qfutureinterface_p.h | 26 ++++++++++- .../qtconcurrentmap/tst_qtconcurrentmap.cpp | 43 +++++++++++++++++++ .../corelib/thread/qfuture/tst_qfuture.cpp | 30 +++++++++---- 5 files changed, 111 insertions(+), 13 deletions(-) diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index ce9eb143d79..e85f632fdf3 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -419,6 +419,16 @@ bool QFutureInterfaceBase::referenceCountIsOne() const return d->refCount.load() == 1; } +bool QFutureInterfaceBase::refT() const +{ + return d->refCount.refT(); +} + +bool QFutureInterfaceBase::derefT() const +{ + return d->refCount.derefT(); +} + QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState) : refCount(1), m_progressValue(0), m_progressMinimum(0), m_progressMaximum(0), state(initialState), pendingResults(0), diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index b7bf7794123..3cbb9506ecc 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -130,6 +130,8 @@ public: protected: bool referenceCountIsOne() const; + bool refT() const; + bool derefT() const; public: #ifndef QFUTURE_TEST @@ -148,13 +150,17 @@ class QFutureInterface : public QFutureInterfaceBase public: QFutureInterface(State initialState = NoState) : QFutureInterfaceBase(initialState) - { } + { + refT(); + } QFutureInterface(const QFutureInterface &other) : QFutureInterfaceBase(other) - { } + { + refT(); + } ~QFutureInterface() { - if (referenceCountIsOne()) + if (!derefT()) resultStore().clear(); } @@ -163,7 +169,8 @@ public: QFutureInterface &operator=(const QFutureInterface &other) { - if (referenceCountIsOne()) + other.refT(); + if (!derefT()) resultStore().clear(); QFutureInterfaceBase::operator=(other); return *this; diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h index a9081d4c897..ece5e56768e 100644 --- a/src/corelib/thread/qfutureinterface_p.h +++ b/src/corelib/thread/qfutureinterface_p.h @@ -129,7 +129,31 @@ class QFutureInterfaceBasePrivate public: QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState); - QAtomicInt refCount; + // When the last QFuture reference is removed, we need to make + // sure that data stored in the ResultStore is cleaned out. + // Since QFutureInterfaceBasePrivate can be shared between QFuture + // and QFuture objects, we use a separate ref. counter + // to keep track of QFuture objects. + class RefCount + { + public: + inline RefCount(int r = 0, int rt = 0) + : m_refCount(r), m_refCountT(rt) {} + // Default ref counter for QFIBP + inline bool ref() { return m_refCount.ref(); } + inline bool deref() { return m_refCount.deref(); } + inline int load() const { return m_refCount.load(); } + // Ref counter for type T + inline bool refT() { return m_refCountT.ref(); } + inline bool derefT() { return m_refCountT.deref(); } + inline int loadT() const { return m_refCountT.load(); } + + private: + QAtomicInt m_refCount; + QAtomicInt m_refCountT; + }; + + RefCount refCount; mutable QMutex m_mutex; QWaitCondition waitCondition; QList outputConnections; diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp index c50e3839b51..b6bc5b085bf 100644 --- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -43,6 +43,7 @@ #include #include +#include #include @@ -75,6 +76,7 @@ private slots: void stlContainers(); void qFutureAssignmentLeak(); void stressTest(); + void persistentResultTest(); public slots: void throttling(); }; @@ -2395,5 +2397,46 @@ void tst_QtConcurrentMap::stressTest() } } +struct LockedCounter +{ + LockedCounter(QMutex *mutex, QAtomicInt *ai) + : mtx(mutex), + ref(ai) {} + + typedef int result_type; + int operator()(int x) + { + QMutexLocker locker(mtx); + ref->ref(); + return ++x; + } + + QMutex *mtx; + QAtomicInt *ref; +}; + +// The Thread engine holds the last reference +// to the QFuture, so this should not leak +// or fail. +void tst_QtConcurrentMap::persistentResultTest() +{ + QFuture voidFuture; + QMutex mtx; + QAtomicInt ref; + LockedCounter lc(&mtx, &ref); + QList list; + { + list << 1 << 2 << 3; + mtx.lock(); + QFuture future = QtConcurrent::mapped(list + ,lc); + voidFuture = future; + } + QCOMPARE(ref.loadAcquire(), 0); + mtx.unlock(); // Unblock + voidFuture.waitForFinished(); + QCOMPARE(ref.loadAcquire(), 3); +} + QTEST_MAIN(tst_QtConcurrentMap) #include "tst_qtconcurrentmap.moc" diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp index 81ba1b0fd9a..6d73755cfc0 100644 --- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp +++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp @@ -1251,18 +1251,32 @@ void tst_QFuture::throttling() void tst_QFuture::voidConversions() { - QFutureInterface iface; - iface.reportStarted(); + { + QFutureInterface iface; + iface.reportStarted(); - QFuture intFuture(&iface); + QFuture intFuture(&iface); + int value = 10; + iface.reportFinished(&value); - int value = 10; - iface.reportFinished(&value); + QFuture voidFuture(intFuture); + voidFuture = intFuture; - QFuture voidFuture(intFuture); - voidFuture = intFuture; + QVERIFY(voidFuture == intFuture); + } - QVERIFY(voidFuture == intFuture); + { + QFuture voidFuture; + { + QFutureInterface > iface; + iface.reportStarted(); + + QFuture > listFuture(&iface); + iface.reportResult(QList() << 1 << 2 << 3); + voidFuture = listFuture; + } + QCOMPARE(voidFuture.resultCount(), 0); + } } From 3de5a8e78be307145340e0867de53dc607eae59c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 1 Nov 2012 12:21:11 +0100 Subject: [PATCH 102/134] Strip trailing whitespace in itemviews. Using git ls-files -z | xargs -0 sed -i 's/ \+$//' in the relevant directories. Change-Id: I861ef9952fb32ed2db9ec8b67864ec7d0d61f0f2 Reviewed-by: Lars Knoll --- src/corelib/itemmodels/qabstractitemmodel_p.h | 2 +- src/gui/itemmodels/qstandarditemmodel.cpp | 18 ++++---- src/widgets/itemviews/qfileiconprovider.cpp | 2 +- src/widgets/itemviews/qitemeditorfactory.cpp | 2 +- src/widgets/itemviews/qstyleditemdelegate.cpp | 4 +- src/widgets/itemviews/qtableview.cpp | 8 ++-- src/widgets/itemviews/qtreeview.cpp | 2 +- src/widgets/itemviews/qtreewidget.cpp | 2 +- .../itemviews/qtreewidgetitemiterator.cpp | 2 +- .../qstandarditem/tst_qstandarditem.cpp | 44 +++++++++---------- .../itemviews/qcolumnview/qcolumnview.pro | 2 +- .../itemviews/qtableview/tst_qtableview.cpp | 6 +-- .../qtablewidget/tst_qtablewidget.cpp | 14 +++--- 13 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/corelib/itemmodels/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h index c6728889922..e44931a16b7 100644 --- a/src/corelib/itemmodels/qabstractitemmodel_p.h +++ b/src/corelib/itemmodels/qabstractitemmodel_p.h @@ -95,7 +95,7 @@ public: void itemsAboutToBeMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation); void itemsMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation); bool allowMove(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation); - + inline QModelIndex createIndex(int row, int column, void *data = 0) const { return q_func()->createIndex(row, column, data); } diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 6e919eb0b29..fdd00fe9802 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -2935,7 +2935,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const return data; QByteArray encoded; QDataStream stream(&encoded, QIODevice::WriteOnly); - + QSet itemsSet; QStack stack; itemsSet.reserve(indexes.count()); @@ -2945,7 +2945,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const itemsSet << item; stack.push(item); } - + //remove duplicates childrens { QSet seen; @@ -2954,7 +2954,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const if (seen.contains(itm)) continue; seen.insert(itm); - + const QVector &childList = itm->d_func()->children; for (int i = 0; i < childList.count(); ++i) { QStandardItem *chi = childList.at(i); @@ -2968,17 +2968,17 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const } } } - + stack.reserve(itemsSet.count()); foreach (QStandardItem *item, itemsSet) { stack.push(item); } - + //stream everything recursively while (!stack.isEmpty()) { QStandardItem *item = stack.pop(); if(itemsSet.contains(item)) { //if the item is selection 'top-level', strem its position - stream << item->row() << item->column(); + stream << item->row() << item->column(); } if(item) { stream << *item << item->columnCount() << item->d_ptr->children.count(); @@ -2996,7 +2996,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const /* \internal Used by QStandardItemModel::dropMimeData - stream out an item and his children + stream out an item and his children */ void QStandardItemModelPrivate::decodeDataRecursive(QDataStream &stream, QStandardItem *item) { @@ -3004,9 +3004,9 @@ void QStandardItemModelPrivate::decodeDataRecursive(QDataStream &stream, QStanda stream >> *item; stream >> colCount >> childCount; item->setColumnCount(colCount); - + int childPos = childCount; - + while(childPos > 0) { childPos--; QStandardItem *child = createItem(); diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index d073867dbb4..43cf8afb796 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -68,7 +68,7 @@ QT_BEGIN_NAMESPACE \class QFileIconProvider \inmodule QtWidgets - + \brief The QFileIconProvider class provides file icons for the QDirModel and the QFileSystemModel classes. */ diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index 5f24c3ea1b1..09e59579b8b 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -560,7 +560,7 @@ void QExpandingLineEdit::updateMinimumWidth() QStyleOptionFrameV2 opt; initStyleOption(&opt); - + int minWidth = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(width, 0). expandedTo(QApplication::globalStrut()), this).width(); setMinimumWidth(minWidth); diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index fa5a62805f9..6a330fc7cbb 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -538,9 +538,9 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor, QStyleOptionViewItem opt = option; initStyleOption(&opt, index); - // let the editor take up all available space + // let the editor take up all available space //if the editor is not a QLineEdit - //or it is in a QTableView + //or it is in a QTableView #if !defined(QT_NO_TABLEVIEW) && !defined(QT_NO_LINEEDIT) if (qobject_cast(editor) && !qobject_cast(widget)) opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, editor); diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 80abb050eea..d84dc608b93 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -2198,7 +2198,7 @@ int QTableView::sizeHintForRow(int row) const option.rect.setX(columnViewportPosition(index.column())); option.rect.setWidth(columnWidth(index.column())); } - + QWidget *editor = d->editorForIndex(index).widget.data(); if (editor && d->persistent.contains(editor)) { hint = qMax(hint, editor->sizeHint().height()); @@ -2206,7 +2206,7 @@ int QTableView::sizeHintForRow(int row) const int max = editor->maximumSize().height(); hint = qBound(min, hint, max); } - + hint = qMax(hint, itemDelegate(index)->sizeHint(option, index).height()); } @@ -2251,7 +2251,7 @@ int QTableView::sizeHintForColumn(int column) const if (d->verticalHeader->isSectionHidden(logicalRow)) continue; index = d->model->index(logicalRow, column, d->root); - + QWidget *editor = d->editorForIndex(index).widget.data(); if (editor && d->persistent.contains(editor)) { hint = qMax(hint, editor->sizeHint().width()); @@ -2259,7 +2259,7 @@ int QTableView::sizeHintForColumn(int column) const int max = editor->maximumSize().width(); hint = qBound(min, hint, max); } - + hint = qMax(hint, itemDelegate(index)->sizeHint(option, index).width()); } diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index ece5b21ae24..bcaf8dc2c3f 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1716,7 +1716,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, // we have to split the focus rect into two rects if (allColumnsShowFocus && !option.showDecorationSelected && header->sectionsMoved() && (header->visualIndex(0) != 0)) { - QRect sectionRect(0, y, header->sectionPosition(0), height); + QRect sectionRect(0, y, header->sectionPosition(0), height); o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), sectionRect); style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter); } diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 5305f64cc9b..f689e87f8d9 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1477,7 +1477,7 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after /*! Destroys this tree widget item. - + The item will be removed from \l{QTreeWidget}s to which it has been added. This makes it safe to delete an item at any time. diff --git a/src/widgets/itemviews/qtreewidgetitemiterator.cpp b/src/widgets/itemviews/qtreewidgetitemiterator.cpp index 0108b80dcfb..c1e2bd8b776 100644 --- a/src/widgets/itemviews/qtreewidgetitemiterator.cpp +++ b/src/widgets/itemviews/qtreewidgetitemiterator.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE \class QTreeWidgetItemIterator \ingroup model-view \inmodule QtWidgets - + \brief The QTreeWidgetItemIterator class provides a way to iterate over the items in a QTreeWidget instance. diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp index ca6d2b0585a..7949e13a71f 100644 --- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp @@ -150,59 +150,59 @@ void tst_QStandardItem::getSetData() QString text = QString("text %0").arg(i); item.setText(text); QCOMPARE(item.text(), text); - + QPixmap pixmap(32, 32); pixmap.fill((i == 1) ? Qt::red : Qt::green); QIcon icon(pixmap); item.setIcon(icon); QCOMPARE(item.icon(), icon); - + QString toolTip = QString("toolTip %0").arg(i); item.setToolTip(toolTip); QCOMPARE(item.toolTip(), toolTip); - + QString statusTip = QString("statusTip %0").arg(i); item.setStatusTip(statusTip); QCOMPARE(item.statusTip(), statusTip); - + QString whatsThis = QString("whatsThis %0").arg(i); item.setWhatsThis(whatsThis); QCOMPARE(item.whatsThis(), whatsThis); - + QSize sizeHint(64*i, 48*i); item.setSizeHint(sizeHint); QCOMPARE(item.sizeHint(), sizeHint); - + QFont font; item.setFont(font); QCOMPARE(item.font(), font); - + Qt::Alignment textAlignment((i == 1) ? Qt::AlignLeft|Qt::AlignVCenter : Qt::AlignRight); item.setTextAlignment(textAlignment); QCOMPARE(item.textAlignment(), textAlignment); - + QColor backgroundColor((i == 1) ? Qt::blue : Qt::yellow); item.setBackground(backgroundColor); QCOMPARE(item.background().color(), backgroundColor); - + QColor textColor((i == i) ? Qt::green : Qt::cyan); item.setForeground(textColor); QCOMPARE(item.foreground().color(), textColor); - + Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked); item.setCheckState(checkState); QCOMPARE(item.checkState(), checkState); - + QString accessibleText = QString("accessibleText %0").arg(i); item.setAccessibleText(accessibleText); QCOMPARE(item.accessibleText(), accessibleText); - + QString accessibleDescription = QString("accessibleDescription %0").arg(i); item.setAccessibleDescription(accessibleDescription); QCOMPARE(item.accessibleDescription(), accessibleDescription); - + QCOMPARE(item.text(), text); QCOMPARE(item.icon(), icon); QCOMPARE(item.toolTip(), toolTip); @@ -216,7 +216,7 @@ void tst_QStandardItem::getSetData() QCOMPARE(item.checkState(), checkState); QCOMPARE(item.accessibleText(), accessibleText); QCOMPARE(item.accessibleDescription(), accessibleDescription); - + QCOMPARE(qvariant_cast(item.data(Qt::DisplayRole)), text); QCOMPARE(qvariant_cast(item.data(Qt::DecorationRole)), icon); QCOMPARE(qvariant_cast(item.data(Qt::ToolTipRole)), toolTip); @@ -250,7 +250,7 @@ void tst_QStandardItem::getSetData() item.setData(QVariant(), Qt::CheckStateRole); item.setData(QVariant(), Qt::AccessibleTextRole); item.setData(QVariant(), Qt::AccessibleDescriptionRole); - + QCOMPARE(item.data(Qt::DisplayRole), QVariant()); QCOMPARE(item.data(Qt::DecorationRole), QVariant()); QCOMPARE(item.data(Qt::ToolTipRole), QVariant()); @@ -296,7 +296,7 @@ void tst_QStandardItem::getSetFlags() QVERIFY(item.isDropEnabled()); QVERIFY(item.flags() & Qt::ItemIsDropEnabled); #endif - + QVERIFY(item.isEnabled()); item.setEnabled(false); QVERIFY(!item.isEnabled()); @@ -332,7 +332,7 @@ void tst_QStandardItem::getSetFlags() item.setCheckState(Qt::Checked); item.setCheckable(true); QCOMPARE(item.checkState(), Qt::Checked); -} +} void tst_QStandardItem::getSetRowAndColumnCount() { @@ -427,7 +427,7 @@ void tst_QStandardItem::parent() QCOMPARE(child->parent(), static_cast(0)); item.setChild(0, 0, child); QCOMPARE(child->parent(), &item); - + QStandardItem *childOfChild = new QStandardItem; child->setChild(0, 0, childOfChild); QCOMPARE(childOfChild->parent(), child); @@ -897,7 +897,7 @@ void tst_QStandardItem::takeRow() void tst_QStandardItem::streamItem() { QStandardItem item; - + item.setText(QLatin1String("text")); item.setToolTip(QLatin1String("toolTip")); item.setStatusTip(QLatin1String("statusTip")); @@ -1006,7 +1006,7 @@ void tst_QStandardItem::sortChildren() two->appendRow(new QStandardItem(QLatin1String("e"))); item->appendRow(one); item->appendRow(two); - + QSignalSpy layoutAboutToBeChangedSpy( model, SIGNAL(layoutAboutToBeChanged())); QSignalSpy layoutChangedSpy( @@ -1021,7 +1021,7 @@ void tst_QStandardItem::sortChildren() QCOMPARE(two->child(0)->text(), QLatin1String("f")); QCOMPARE(two->child(1)->text(), QLatin1String("d")); QCOMPARE(two->child(2)->text(), QLatin1String("e")); - + two->sortChildren(0, Qt::AscendingOrder); // verify sorted QCOMPARE(two->child(0)->text(), QLatin1String("d")); @@ -1031,7 +1031,7 @@ void tst_QStandardItem::sortChildren() QCOMPARE(one->child(0)->text(), QLatin1String("c")); QCOMPARE(one->child(1)->text(), QLatin1String("b")); QCOMPARE(one->child(2)->text(), QLatin1String("a")); - + item->sortChildren(0, Qt::AscendingOrder); // verify everything sorted QCOMPARE(one->child(0)->text(), QLatin1String("a")); diff --git a/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro b/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro index 7acbe016d51..4980b453890 100644 --- a/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro +++ b/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro @@ -3,6 +3,6 @@ CONFIG += parallel_test QT += widgets widgets-private QT += gui-private core-private testlib -SOURCES += tst_qcolumnview.cpp +SOURCES += tst_qcolumnview.cpp TARGET = tst_qcolumnview DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 2bccb038452..80d77aa652d 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -4065,9 +4065,9 @@ void tst_QTableView::taskQTBUG_8777_scrollToSpans() } void tst_QTableView::taskQTBUG_10169_sizeHintForRow() -{ - QtTestTableView tableView; - QStandardItemModel model(1, 3); +{ + QtTestTableView tableView; + QStandardItemModel model(1, 3); model.setData(model.index(0, 0), "Word wrapping text goes here."); tableView.setModel(&model); tableView.verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index 2c93492fe91..e141ec294d2 100644 --- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp +++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp @@ -130,7 +130,7 @@ void tst_QTableWidget::getSetCheck() // QCOMPARE(INT_MAX, obj1.rowCount()); obj1.setRowCount(100); QCOMPARE(100, obj1.rowCount()); - + // int QTableWidget::columnCount() // void QTableWidget::setColumnCount(int) @@ -584,7 +584,7 @@ void tst_QTableWidget::selectedItems() } if (hidden) continue; - + for (int column = 0; columncolumnCount(); ++column) { foreach (int hiddenColumn, hiddenColumns){ if(hiddenColumn == column){ @@ -594,7 +594,7 @@ void tst_QTableWidget::selectedItems() } if (hidden) continue; - + QTableWidgetItem *item = testWidget->item(row, column); if (item && testWidget->isItemSelected(item)) QVERIFY(selectedItems.contains(item)); @@ -1321,7 +1321,7 @@ void tst_QTableWidget::setItemWithSorting() QAbstractItemModel *model = w.model(); QList persistent; - + int ti = 0; for (int r = 0; r < rowCount; ++r) { for (int c = 0; c < columnCount; ++c) { @@ -1330,10 +1330,10 @@ void tst_QTableWidget::setItemWithSorting() } persistent << model->index(r, sortColumn); } - + w.sortItems(sortColumn, static_cast(sortOrder)); w.setSortingEnabled(true); - + QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); QSignalSpy layoutChangedSpy(model, SIGNAL(layoutChanged())); @@ -1354,7 +1354,7 @@ void tst_QTableWidget::setItemWithSorting() QCOMPARE(w.item(r, c)->text(), str); } } - + for (int k = 0; k < persistent.count(); ++k) { QCOMPARE(persistent.at(k).row(), expectedRows.at(k)); int i = (persistent.at(k).row() * columnCount) + sortColumn; From 196c5bfe0fdd245e1819a0247afca0c3371fc0d5 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 1 Nov 2012 11:32:51 +0100 Subject: [PATCH 103/134] Compile fix for tst_qstylesheetstyle.cpp There was a semicolon missing. Change-Id: Id2eb843604907acf952d7d238f80ba8a7010ccd1 Reviewed-by: Friedemann Kleint --- .../widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 29846d619a0..d5ac0c20a82 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -1589,7 +1589,7 @@ class ChangeEventWidget : public QWidget static bool recurse = false; if (!recurse) { recurse = true; - QStyle *style = new QFusionStyle + QStyle *style = new QFusionStyle; style->setParent(this); setStyle(style); recurse = false; From 5b21b6a7f0d9a9462a6b3fa45c32cb81feaaff49 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 29 Oct 2012 10:43:15 +0100 Subject: [PATCH 104/134] Fix build when libQtGui is not available Change-Id: I9e35d9302f58d283459f7e625c4e0b87fd1dc2bf Reviewed-by: Friedemann Kleint --- src/testlib/qtestsystem.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index 2f3f499d473..094570bb8ca 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -45,7 +45,9 @@ #include #include #include -#include +#ifdef QT_GUI_LIB +# include +#endif #ifdef QT_WIDGETS_LIB # include #endif @@ -69,6 +71,7 @@ namespace QTest } while (timer.elapsed() < ms); } +#ifdef QT_GUI_LIB inline static bool qWaitForWindowActive(QWindow *window, int timeout = 1000) { QElapsedTimer timer; @@ -112,6 +115,7 @@ namespace QTest } return window->isExposed(); } +#endif #ifdef QT_WIDGETS_LIB inline static bool qWaitForWindowActive(QWidget *widget, int timeout = 1000) From 8c15be7bb2488a17b2c2f62e2d2a7ed01dd331d6 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 1 Nov 2012 12:47:40 +0100 Subject: [PATCH 105/134] Fix groupboxes for desktop components on mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The logic was a bit odd as it would check if the groupbox had a font set and then override it anyway. Since we anyway want the fallback to be used for components we just make sure that the fallback is to use the same code path. Change-Id: Ic5071b43cda76e2bb7356a6f71cc8458c4e8bf27 Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 522d43dd28e..b0a43c563cd 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5399,7 +5399,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex QStyleOptionGroupBox groupBox(*gb); groupBox.state |= QStyle::State_Mini; // Force mini-sized checkbox to go with small-sized label bool didModifySubControls = false; - if ((widget && !widget->testAttribute(Qt::WA_SetFont)) + if ((!widget || !widget->testAttribute(Qt::WA_SetFont)) && QApplication::desktopSettingsAware()) { groupBox.subControls = groupBox.subControls & ~SC_GroupBoxLabel; didModifySubControls = true; From 70dea61670d0f66482442b41549de8ee19474fa6 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 1 Nov 2012 11:47:37 +0100 Subject: [PATCH 106/134] Make ToolButton work with Macstyle for components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We needed a new helper function for this. The widget cast was breaking desktop components. By using accessible role, we can make it work for both use cases without depending on the widget. Change-Id: Ic854dc45a4e5b7a50c5be701e903d58a4a914ee5 Reviewed-by: Jan Arve Sæther Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qmacstyle_mac.mm | 5 +++-- src/widgets/styles/qstylehelper.cpp | 17 +++++++++++++++++ src/widgets/styles/qstylehelper_p.h | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index b0a43c563cd..83895b64b0b 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5434,7 +5434,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex case CC_ToolButton: if (const QStyleOptionToolButton *tb = qstyleoption_cast(opt)) { - if (widget && qobject_cast(widget->parentWidget())) { + + if (QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)) { if (tb->subControls & SC_ToolButtonMenu) { QStyleOption arrowOpt(0); arrowOpt.rect = proxy()->subControlRect(cc, tb, SC_ToolButtonMenu, widget); @@ -6030,7 +6031,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op break; case CC_ToolButton: ret = QCommonStyle::subControlRect(cc, opt, sc, widget); - if (sc == SC_ToolButtonMenu && widget && !qobject_cast(widget->parentWidget())) { + if (sc == SC_ToolButtonMenu && !QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)) { ret.adjust(-1, 0, 0, 0); } break; diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index e23db2b6378..8d67683eaeb 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -86,6 +86,23 @@ qreal dpiScaled(qreal value) #endif } +// Searches for an ancestor of a particular accessible role +bool hasAncestor(QObject *obj, QAccessible::Role role) +{ + bool found = false; +#ifndef QT_NO_ACCESSIBILITY + QObject *parent = obj ? obj->parent() : 0; + while (parent && !found) { + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parent); + if (iface && iface->role() == role) + found = true; + delete iface; + parent = parent->parent(); + } +#endif // QT_NO_ACCESSIBILITY + return found; +} + #ifndef QT_NO_DIAL diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index e47722bd9fe..ab6a97e59a9 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -44,6 +44,7 @@ #include #include #include +#include #ifndef QSTYLEHELPER_P_H #define QSTYLEHELPER_P_H @@ -81,6 +82,7 @@ namespace QStyleHelper void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left = 0, int top = 0, int right = 0, int bottom = 0); + bool hasAncestor(QObject *obj, QAccessible::Role role); } From f5bc3fb2f0ae547081a74faeaaa80ddb3ac515a6 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 25 Oct 2012 16:16:14 +0200 Subject: [PATCH 107/134] Some Vista style cleanup Creates a function for cloning the style options used by Vista style. Change-Id: I4d83661acd6bdfff5c633447046a206018b537af Reviewed-by: J-P Nurmi --- src/widgets/styles/qwindowsvistastyle.cpp | 53 ++++++++++++----------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 87c67dc84be..b20e6f5ea55 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -151,12 +151,36 @@ inline QObject *styleObject(const QStyleOption *option) { return option ? option->styleObject : 0; } +/* \internal + Checks if we can animate on a style option +*/ bool canAnimate(const QStyleOption *option) { return option && option->styleObject && !option->styleObject->property("_q_no_animation").toBool(); } +/* \internal + Used by animations to clone a styleoption and shift its offset +*/ +QStyleOption *clonedAnimationStyleOption(const QStyleOption*option) { + QStyleOption *styleOption = 0; + if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) + styleOption = new QStyleOptionSlider(*slider); + else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) + styleOption = new QStyleOptionSpinBox(*spinbox); + else if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) + styleOption = new QStyleOptionGroupBox(*groupBox); + else if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) + styleOption = new QStyleOptionComboBox(*combo); + else if (const QStyleOptionButton *button = qstyleoption_cast(option)) + styleOption = new QStyleOptionButton(*button); + else + styleOption = new QStyleOption(*option); + styleOption->rect = QRect(QPoint(0,0), option->rect.size()); + return styleOption; +} + /*! \class QWindowsVistaStyle @@ -402,14 +426,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt doTransition = false; if (doTransition) { - QStyleOption *styleOption = 0; - if (const QStyleOptionGroupBox *combo = qstyleoption_cast(option)) - styleOption = new QStyleOptionGroupBox(*combo); - else - styleOption = new QStyleOption(*option); - + QStyleOption *styleOption = clonedAnimationStyleOption(option); styleOption->state = (QStyle::State)oldState; - styleOption->rect = QRect(QPoint(0,0), newRect.size()); QWindowsVistaAnimation *anim = qobject_cast(d->animation(styleObject)); QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject); @@ -975,16 +993,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject); QWindowsVistaAnimation *anim = qobject_cast(d->animation(styleObject)); - QStyleOption *styleOption = 0; - if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) - styleOption = new QStyleOptionComboBox(*combo); - else if (const QStyleOptionButton *button = qstyleoption_cast(option)) - styleOption = new QStyleOptionButton(*button); - else - styleOption = new QStyleOption(*option); - + QStyleOption *styleOption = clonedAnimationStyleOption(option); styleOption->state = (QStyle::State)oldState; - styleOption->rect = QRect(QPoint(0,0), newRect.size()); QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); startImage.fill(0); @@ -1664,6 +1674,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle } if (doTransition) { + QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); startImage.fill(0); QPainter startPainter(&startImage); @@ -1676,15 +1687,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject); // Draw the image that ends the animation by using the current styleoption - QStyleOptionComplex *styleOption = 0; - if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) - styleOption = new QStyleOptionSlider(*slider); - else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) - styleOption = new QStyleOptionSpinBox(*spinbox); - else - styleOption = new QStyleOptionComplex(*option); - - styleOption->rect = QRect(QPoint(0,0), option->rect.size()); + QStyleOptionComplex *styleOption = qstyleoption_cast(clonedAnimationStyleOption(option)); styleObject->setProperty("_q_no_animation", true); From 8c39b4c05fecf1e0c1713c19b5e077c47e881846 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 24 Oct 2012 14:00:12 +0200 Subject: [PATCH 108/134] beef up qt_plugin.prf it now defines the DESTDIR and creates an INSTALLS rule. Change-Id: I15a462ccad9acbe3521c352fa98327825dc27c05 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_plugin.prf | 13 +++++++++++-- src/plugins/accessible/qaccessiblebase.pri | 2 -- src/plugins/accessible/widgets/widgets.pro | 4 ++-- src/plugins/bearer/blackberry/blackberry.pro | 6 ++---- src/plugins/bearer/connman/connman.pro | 6 ++---- src/plugins/bearer/corewlan/corewlan.pro | 6 ++---- src/plugins/bearer/generic/generic.pro | 6 ++---- src/plugins/bearer/nativewifi/nativewifi.pro | 6 ++---- .../bearer/networkmanager/networkmanager.pro | 6 ++---- src/plugins/bearer/nla/nla.pro | 6 ++---- src/plugins/generic/evdevkeyboard/evdevkeyboard.pro | 6 ++---- src/plugins/generic/evdevmouse/evdevmouse.pro | 6 ++---- src/plugins/generic/evdevtablet/evdevtablet.pro | 6 ++---- src/plugins/generic/evdevtouch/evdevtouch.pro | 6 ++---- src/plugins/generic/meego/meego.pro | 7 ++----- src/plugins/generic/tslib/tslib.pro | 6 ++---- src/plugins/imageformats/gif/gif.pro | 6 ++---- src/plugins/imageformats/ico/ico.pro | 6 ++---- src/plugins/imageformats/jpeg/jpeg.pro | 6 ++---- src/plugins/platforminputcontexts/ibus/ibus.pro | 7 ++----- src/plugins/platforminputcontexts/maliit/maliit.pro | 7 ++----- src/plugins/platforms/cocoa/cocoa.pro | 5 ++--- src/plugins/platforms/directfb/directfb.pro | 5 ++--- src/plugins/platforms/eglfs/eglfs.pro | 7 ++----- src/plugins/platforms/kms/kms.pro | 6 ++---- src/plugins/platforms/linuxfb/linuxfb.pro | 7 ++----- src/plugins/platforms/minimal/minimal.pro | 6 ++---- src/plugins/platforms/minimalegl/minimalegl.pro | 7 ++----- src/plugins/platforms/openwfd/openwf.pro | 5 +---- src/plugins/platforms/qnx/qnx.pro | 5 +---- src/plugins/platforms/windows/windows.pro | 6 ++---- src/plugins/platforms/xcb/xcb.pro | 5 +---- src/plugins/printsupport/cocoa/cocoa.pro | 6 ++---- src/plugins/printsupport/cups/cups.pro | 6 ++---- src/plugins/printsupport/windows/windows.pro | 5 ++--- src/plugins/sqldrivers/qsqldriverbase.pri | 6 ++---- 36 files changed, 76 insertions(+), 141 deletions(-) delete mode 100644 src/plugins/accessible/qaccessiblebase.pri diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf index b6036dda42b..363664bb670 100644 --- a/mkspecs/features/qt_plugin.prf +++ b/mkspecs/features/qt_plugin.prf @@ -1,5 +1,10 @@ +load(qt_build_paths) + +isEmpty(PLUGIN_TYPE): error("PLUGIN_TYPE (plugins/ subdirectory) needs to be defined.") + TEMPLATE = lib -CONFIG += qt plugin +CONFIG += plugin +DESTDIR = $$MODULE_BASE_OUTDIR/plugins/$$PLUGIN_TYPE tool_plugin { !build_pass:contains(QT_CONFIG, build_all): CONFIG += release @@ -7,7 +12,6 @@ tool_plugin { contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release contains(QT_CONFIG, build_all):CONFIG += build_all } -TARGET = $$qtLibraryTarget($$TARGET) contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols contains(QT_CONFIG, separate_debug_info):CONFIG += separate_debug_info contains(QT_CONFIG, separate_debug_info_nocopy):CONFIG += separate_debug_info_nocopy @@ -16,6 +20,11 @@ contains(QT_CONFIG, c++11):CONFIG += c++11 contains(QT_CONFIG, static):CONFIG += static else:CONFIG += shared +target.path = $$[QT_INSTALL_PLUGINS]/$$PLUGIN_TYPE +INSTALLS += target + +TARGET = $$qtLibraryTarget($$TARGET) + load(qt_targets) wince*:LIBS += $$QMAKE_LIBS_GUI diff --git a/src/plugins/accessible/qaccessiblebase.pri b/src/plugins/accessible/qaccessiblebase.pri deleted file mode 100644 index 95c1fad13a0..00000000000 --- a/src/plugins/accessible/qaccessiblebase.pri +++ /dev/null @@ -1,2 +0,0 @@ -target.path += $$[QT_INSTALL_PLUGINS]/accessible -INSTALLS += target diff --git a/src/plugins/accessible/widgets/widgets.pro b/src/plugins/accessible/widgets/widgets.pro index 3bf7dede565..afabbac9bc3 100644 --- a/src/plugins/accessible/widgets/widgets.pro +++ b/src/plugins/accessible/widgets/widgets.pro @@ -1,9 +1,9 @@ TARGET = qtaccessiblewidgets + +PLUGIN_TYPE = accessible load(qt_plugin) -include (../qaccessiblebase.pri) QT += core-private gui-private widgets-private -DESTDIR = $$QT.gui.plugins/accessible QTDIR_build:REQUIRES += "contains(QT_CONFIG, accessibility)" diff --git a/src/plugins/bearer/blackberry/blackberry.pro b/src/plugins/bearer/blackberry/blackberry.pro index 5d4cf29554a..220a506d906 100644 --- a/src/plugins/bearer/blackberry/blackberry.pro +++ b/src/plugins/bearer/blackberry/blackberry.pro @@ -1,4 +1,6 @@ TARGET = qbbbearer + +PLUGIN_TYPE = bearer load(qt_plugin) QT = core-private network-private @@ -15,7 +17,3 @@ SOURCES += qbbengine.cpp \ main.cpp OTHER_FILES += blackberry.json - -DESTDIR = $$QT.network.plugins/bearer -target.path += $$[QT_INSTALL_PLUGINS]/bearer -INSTALLS += target diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro index 679637b37f6..99d9b367f2c 100644 --- a/src/plugins/bearer/connman/connman.pro +++ b/src/plugins/bearer/connman/connman.pro @@ -1,4 +1,6 @@ TARGET = qconnmanbearer + +PLUGIN_TYPE = bearer load(qt_plugin) QT = core network-private dbus @@ -17,7 +19,3 @@ SOURCES += main.cpp \ OTHER_FILES += connman.json -DESTDIR = $$QT.network.plugins/bearer -target.path += $$[QT_INSTALL_PLUGINS]/bearer -INSTALLS += target - diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro index b60dac907c1..481b75c8abb 100644 --- a/src/plugins/bearer/corewlan/corewlan.pro +++ b/src/plugins/bearer/corewlan/corewlan.pro @@ -1,4 +1,6 @@ TARGET = qcorewlanbearer + +PLUGIN_TYPE = bearer load(qt_plugin) QT = core-private network-private @@ -20,7 +22,3 @@ SOURCES += main.cpp \ OBJECTIVE_SOURCES += qcorewlanengine.mm OTHER_FILES += corewlan.json - -DESTDIR = $$QT.network.plugins/bearer -target.path += $$[QT_INSTALL_PLUGINS]/bearer -INSTALLS += target diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro index e66c5b2c7a0..a1da0dddda1 100644 --- a/src/plugins/bearer/generic/generic.pro +++ b/src/plugins/bearer/generic/generic.pro @@ -1,4 +1,6 @@ TARGET = qgenericbearer + +PLUGIN_TYPE = bearer load(qt_plugin) QT = core-private network-private @@ -12,7 +14,3 @@ SOURCES += qgenericengine.cpp \ main.cpp OTHER_FILES += generic.json - -DESTDIR = $$QT.network.plugins/bearer -target.path += $$[QT_INSTALL_PLUGINS]/bearer -INSTALLS += target diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro index 3124d58ff2a..4382cd08cd1 100644 --- a/src/plugins/bearer/nativewifi/nativewifi.pro +++ b/src/plugins/bearer/nativewifi/nativewifi.pro @@ -1,4 +1,6 @@ TARGET = qnativewifibearer + +PLUGIN_TYPE = bearer load(qt_plugin) QT = core-private network-private @@ -13,7 +15,3 @@ SOURCES += main.cpp \ ../qnetworksession_impl.cpp OTHER_FILES += nativewifi.json - -DESTDIR = $$QT.network.plugins/bearer -target.path += $$[QT_INSTALL_PLUGINS]/bearer -INSTALLS += target diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro index c1c6664897f..4f299e22f2d 100644 --- a/src/plugins/bearer/networkmanager/networkmanager.pro +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -1,4 +1,6 @@ TARGET = qnmbearer + +PLUGIN_TYPE = bearer load(qt_plugin) QT = core network-private dbus @@ -16,7 +18,3 @@ SOURCES += main.cpp \ ../qnetworksession_impl.cpp OTHER_FILES += networkmanager.json - -DESTDIR = $$QT.network.plugins/bearer -target.path += $$[QT_INSTALL_PLUGINS]/bearer -INSTALLS += target diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro index 29e98953b16..56c06a57b1b 100644 --- a/src/plugins/bearer/nla/nla.pro +++ b/src/plugins/bearer/nla/nla.pro @@ -1,4 +1,6 @@ TARGET = qnlabearer + +PLUGIN_TYPE = bearer load(qt_plugin) QT = core core-private network network-private @@ -19,7 +21,3 @@ SOURCES += main.cpp \ ../qnetworksession_impl.cpp OTHER_FILES += nla.json - -DESTDIR = $$QT.network.plugins/bearer -target.path += $$[QT_INSTALL_PLUGINS]/bearer -INSTALLS += target diff --git a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro index aa85fdcb06b..97b827b779b 100644 --- a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro +++ b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro @@ -1,9 +1,7 @@ TARGET = qevdevkeyboardplugin -load(qt_plugin) -DESTDIR = $$QT.gui.plugins/generic -target.path = $$[QT_INSTALL_PLUGINS]/generic -INSTALLS += target +PLUGIN_TYPE = generic +load(qt_plugin) QT += core-private platformsupport-private gui-private diff --git a/src/plugins/generic/evdevmouse/evdevmouse.pro b/src/plugins/generic/evdevmouse/evdevmouse.pro index fd7d0fee6ab..c1356593dfb 100644 --- a/src/plugins/generic/evdevmouse/evdevmouse.pro +++ b/src/plugins/generic/evdevmouse/evdevmouse.pro @@ -1,9 +1,7 @@ TARGET = qevdevmouseplugin -load(qt_plugin) -DESTDIR = $$QT.gui.plugins/generic -target.path = $$[QT_INSTALL_PLUGINS]/generic -INSTALLS += target +PLUGIN_TYPE = generic +load(qt_plugin) QT += core-private platformsupport-private gui-private diff --git a/src/plugins/generic/evdevtablet/evdevtablet.pro b/src/plugins/generic/evdevtablet/evdevtablet.pro index 841d7b96f73..066819be33c 100644 --- a/src/plugins/generic/evdevtablet/evdevtablet.pro +++ b/src/plugins/generic/evdevtablet/evdevtablet.pro @@ -1,9 +1,7 @@ TARGET = qevdevtabletplugin -load(qt_plugin) -DESTDIR = $$QT.gui.plugins/generic -target.path = $$[QT_INSTALL_PLUGINS]/generic -INSTALLS += target +PLUGIN_TYPE = generic +load(qt_plugin) SOURCES = main.cpp diff --git a/src/plugins/generic/evdevtouch/evdevtouch.pro b/src/plugins/generic/evdevtouch/evdevtouch.pro index a47d00fbf03..2c1d6913ad1 100644 --- a/src/plugins/generic/evdevtouch/evdevtouch.pro +++ b/src/plugins/generic/evdevtouch/evdevtouch.pro @@ -1,9 +1,7 @@ TARGET = qevdevtouchplugin -load(qt_plugin) -DESTDIR = $$QT.gui.plugins/generic -target.path = $$[QT_INSTALL_PLUGINS]/generic -INSTALLS += target +PLUGIN_TYPE = generic +load(qt_plugin) SOURCES = main.cpp diff --git a/src/plugins/generic/meego/meego.pro b/src/plugins/generic/meego/meego.pro index 692ace485fc..b8845418e86 100644 --- a/src/plugins/generic/meego/meego.pro +++ b/src/plugins/generic/meego/meego.pro @@ -1,11 +1,8 @@ TARGET = qmeegointegration + +PLUGIN_TYPE = generic load(qt_plugin) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/generic - -target.path = $$[QT_INSTALL_PLUGINS]/generic -INSTALLS += target - SOURCES = qmeegointegration.cpp \ main.cpp \ contextkitproperty.cpp diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro index 9046e18f778..ab0645d89ac 100644 --- a/src/plugins/generic/tslib/tslib.pro +++ b/src/plugins/generic/tslib/tslib.pro @@ -1,9 +1,7 @@ TARGET = qtslibplugin -load(qt_plugin) -DESTDIR = $$QT.gui.plugins/generic -target.path = $$[QT_INSTALL_PLUGINS]/generic -INSTALLS += target +PLUGIN_TYPE = generic +load(qt_plugin) HEADERS = qtslib.h diff --git a/src/plugins/imageformats/gif/gif.pro b/src/plugins/imageformats/gif/gif.pro index b85ee984ac6..d5acfedff7d 100644 --- a/src/plugins/imageformats/gif/gif.pro +++ b/src/plugins/imageformats/gif/gif.pro @@ -1,11 +1,9 @@ TARGET = qgif + +PLUGIN_TYPE = imageformats load(qt_plugin) include(../../../gui/image/qgifhandler.pri) SOURCES += $$PWD/main.cpp HEADERS += $$PWD/main.h OTHER_FILES += gif.json - -DESTDIR = $$QT.gui.plugins/imageformats -target.path += $$[QT_INSTALL_PLUGINS]/imageformats -INSTALLS += target diff --git a/src/plugins/imageformats/ico/ico.pro b/src/plugins/imageformats/ico/ico.pro index 242e42b8697..48bfd6b3448 100644 --- a/src/plugins/imageformats/ico/ico.pro +++ b/src/plugins/imageformats/ico/ico.pro @@ -1,4 +1,6 @@ TARGET = qico + +PLUGIN_TYPE = imageformats load(qt_plugin) QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-ico)" @@ -7,7 +9,3 @@ HEADERS += qicohandler.h main.h SOURCES += main.cpp \ qicohandler.cpp OTHER_FILES += ico.json - -DESTDIR = $$QT.gui.plugins/imageformats -target.path += $$[QT_INSTALL_PLUGINS]/imageformats -INSTALLS += target diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro index f2a41129d56..35153eb59c8 100644 --- a/src/plugins/imageformats/jpeg/jpeg.pro +++ b/src/plugins/imageformats/jpeg/jpeg.pro @@ -1,4 +1,6 @@ TARGET = qjpeg + +PLUGIN_TYPE = imageformats load(qt_plugin) QT += core-private @@ -9,7 +11,3 @@ include(../../../gui/image/qjpeghandler.pri) SOURCES += main.cpp HEADERS += main.h OTHER_FILES += jpeg.json - -DESTDIR = $$QT.gui.plugins/imageformats -target.path += $$[QT_INSTALL_PLUGINS]/imageformats -INSTALLS += target diff --git a/src/plugins/platforminputcontexts/ibus/ibus.pro b/src/plugins/platforminputcontexts/ibus/ibus.pro index 8c8ab52c3c3..033d5a4d5c9 100644 --- a/src/plugins/platforminputcontexts/ibus/ibus.pro +++ b/src/plugins/platforminputcontexts/ibus/ibus.pro @@ -1,7 +1,7 @@ TARGET = ibusplatforminputcontextplugin -load(qt_plugin) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforminputcontexts +PLUGIN_TYPE = platforminputcontexts +load(qt_plugin) QT += dbus gui-private SOURCES += $$PWD/qibusplatforminputcontext.cpp \ @@ -16,6 +16,3 @@ HEADERS += $$PWD/qibusplatforminputcontext.h \ $$PWD/qibustypes.h OTHER_FILES += $$PWD/ibus.json - -target.path += $$[QT_INSTALL_PLUGINS]/platforminputcontexts -INSTALLS += target diff --git a/src/plugins/platforminputcontexts/maliit/maliit.pro b/src/plugins/platforminputcontexts/maliit/maliit.pro index 4174072c2b6..dec68331969 100644 --- a/src/plugins/platforminputcontexts/maliit/maliit.pro +++ b/src/plugins/platforminputcontexts/maliit/maliit.pro @@ -1,7 +1,7 @@ TARGET = maliitplatforminputcontextplugin -load(qt_plugin) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforminputcontexts +PLUGIN_TYPE = platforminputcontexts +load(qt_plugin) QT += dbus gui-private SOURCES += $$PWD/qmaliitplatforminputcontext.cpp \ @@ -16,6 +16,3 @@ HEADERS += $$PWD/qmaliitplatforminputcontext.h \ $$PWD/contextadaptor.h OTHER_FILES += $$PWD/maliit.json - -target.path += $$[QT_INSTALL_PLUGINS]/platforminputcontexts -INSTALLS += target diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 106664a6b05..3ea5dc2d1cd 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -1,6 +1,7 @@ TARGET = qcocoa + +PLUGIN_TYPE = platforms load(qt_plugin) -DESTDIR = $$QT.gui.plugins/platforms OBJECTIVE_SOURCES += main.mm \ qcocoaintegration.mm \ @@ -91,8 +92,6 @@ QT += core-private gui-private platformsupport-private } OTHER_FILES += cocoa.json -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target # Build the release libqcocoa.dylib only, skip the debug version. # The Qt plugin loader will dlopen both if found, causing duplicate diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index 85821662a03..29c5ebd99ba 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -1,6 +1,7 @@ TARGET = qdirectfb + +PLUGIN_TYPE = platforms load(qt_plugin) -DESTDIR = $$QT.gui.plugins/platforms QT += core-private gui-private platformsupport-private @@ -46,7 +47,5 @@ contains(QT_CONFIG, directfb_egl) { CONFIG += qpa/genericunixfontdatabase -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target OTHER_FILES += directfb.json diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index f22ccc55d22..1223b6b133f 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -1,10 +1,10 @@ TARGET = qeglfs + +PLUGIN_TYPE = platforms load(qt_plugin) QT += core-private gui-private platformsupport-private -DESTDIR = $$QT.gui.plugins/platforms - #DEFINES += QEGL_EXTRA_DEBUG #Avoid X11 header collision @@ -44,9 +44,6 @@ INCLUDEPATH += $$PWD CONFIG += egl qpa/genericunixfontdatabase -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target - RESOURCES += cursor.qrc OTHER_FILES += \ diff --git a/src/plugins/platforms/kms/kms.pro b/src/plugins/platforms/kms/kms.pro index 2e8af5ba9d5..57191d8d97d 100644 --- a/src/plugins/platforms/kms/kms.pro +++ b/src/plugins/platforms/kms/kms.pro @@ -1,8 +1,9 @@ TARGET = qkms + +PLUGIN_TYPE = platforms load(qt_plugin) QT += core-private gui-private platformsupport-private opengl-private -DESTDIR = $$QT.gui.plugins/platforms DEFINES += MESA_EGL_NO_X11_HEADERS @@ -36,8 +37,5 @@ HEADERS = qkmsintegration.h \ qkmsudevdrmhandler.h \ qkmsvthandler.h -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target - OTHER_FILES += \ kms.json diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index 9834dea7d59..2482a644699 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -1,7 +1,7 @@ TARGET = qlinuxfb -load(qt_plugin) -DESTDIR = $$QT.gui.plugins/platforms +PLUGIN_TYPE = platforms +load(qt_plugin) QT += core-private gui-private platformsupport-private @@ -10,7 +10,4 @@ HEADERS = qlinuxfbintegration.h qlinuxfbscreen.h CONFIG += qpa/genericunixfontdatabase -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target - OTHER_FILES += linuxfb.json diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index 6430ccde753..9c3d37269c6 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -1,8 +1,9 @@ TARGET = qminimal + +PLUGIN_TYPE = platforms load(qt_plugin) QT += core-private gui-private platformsupport-private -DESTDIR = $$QT.gui.plugins/platforms SOURCES = main.cpp \ qminimalintegration.cpp \ @@ -11,6 +12,3 @@ HEADERS = qminimalintegration.h \ qminimalbackingstore.h OTHER_FILES += minimal.json - -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target diff --git a/src/plugins/platforms/minimalegl/minimalegl.pro b/src/plugins/platforms/minimalegl/minimalegl.pro index 22e3729ed79..23a6ad97083 100644 --- a/src/plugins/platforms/minimalegl/minimalegl.pro +++ b/src/plugins/platforms/minimalegl/minimalegl.pro @@ -1,10 +1,10 @@ TARGET = qminimalegl + +PLUGIN_TYPE = platforms load(qt_plugin) QT += core-private gui-private platformsupport-private -DESTDIR = $$QT.gui.plugins/platforms - #DEFINES += QEGL_EXTRA_DEBUG #DEFINES += Q_OPENKODE @@ -25,8 +25,5 @@ HEADERS = qminimaleglintegration.h \ CONFIG += egl qpa/genericunixfontdatabase -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target - OTHER_FILES += \ minimalegl.json diff --git a/src/plugins/platforms/openwfd/openwf.pro b/src/plugins/platforms/openwfd/openwf.pro index d913a84411d..1b177cba04d 100644 --- a/src/plugins/platforms/openwfd/openwf.pro +++ b/src/plugins/platforms/openwfd/openwf.pro @@ -1,7 +1,7 @@ TARGET = qopenwf +PLUGIN_TYPE = platforms load(qt_plugin) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += core-private gui-private platformsupport-private @@ -36,6 +36,3 @@ SOURCES += \ LIBS += -lWFD -lgbm -lGLESv2 -lEGL -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target - diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index 6c13be59656..30c95b16205 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -1,6 +1,5 @@ TARGET = qnx -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += platformsupport platformsupport-private # Uncomment this to build with support for IMF once it becomes available in the BBNDK @@ -137,7 +136,5 @@ QMAKE_CXXFLAGS += -I./private include (../../../platformsupport/eglconvenience/eglconvenience.pri) include (../../../platformsupport/fontdatabases/fontdatabases.pri) -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target - +PLUGIN_TYPE = platforms load(qt_plugin) diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro index 1527f0e4964..ca356e1276e 100644 --- a/src/plugins/platforms/windows/windows.pro +++ b/src/plugins/platforms/windows/windows.pro @@ -1,4 +1,6 @@ TARGET = windows + +PLUGIN_TYPE = platforms load(qt_plugin) QT *= core-private @@ -6,7 +8,6 @@ QT *= gui-private QT *= platformsupport-private INCLUDEPATH += ../../../3rdparty/harfbuzz/src -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms # Note: OpenGL32 must precede Gdi32 as it overwrites some functions. LIBS *= -lole32 @@ -172,6 +173,3 @@ contains(QT_CONFIG, freetype) { OTHER_FILES += windows.json contains(QT_CONFIG, accessibility):include(accessible/accessible.pri) - -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 58521686aaf..34f7c746753 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -1,7 +1,7 @@ TARGET = xcb +PLUGIN_TYPE = platforms load(qt_plugin) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += core-private gui-private platformsupport-private @@ -110,6 +110,3 @@ LIBS += -ldbus-1 } OTHER_FILES += xcb.json - -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target diff --git a/src/plugins/printsupport/cocoa/cocoa.pro b/src/plugins/printsupport/cocoa/cocoa.pro index 477715a8e23..4e99b4a8f51 100644 --- a/src/plugins/printsupport/cocoa/cocoa.pro +++ b/src/plugins/printsupport/cocoa/cocoa.pro @@ -1,6 +1,7 @@ TARGET = cocoaprintersupport + +PLUGIN_TYPE = printsupport load(qt_plugin) -DESTDIR = $$QT.gui.plugins/printsupport QT += gui-private printsupport-private LIBS += -framework Cocoa @@ -8,6 +9,3 @@ LIBS += -framework Cocoa SOURCES += main.cpp OTHER_FILES += cocoa.json - -target.path += $$[QT_INSTALL_PLUGINS]/printsupport -INSTALLS += target diff --git a/src/plugins/printsupport/cups/cups.pro b/src/plugins/printsupport/cups/cups.pro index f23ad3fb5eb..bd0b6af114e 100644 --- a/src/plugins/printsupport/cups/cups.pro +++ b/src/plugins/printsupport/cups/cups.pro @@ -1,6 +1,7 @@ TARGET = cupsprintersupport + +PLUGIN_TYPE = printsupport load(qt_plugin) -DESTDIR = $$QT.gui.plugins/printsupport QT += core-private gui-private printsupport printsupport-private @@ -14,6 +15,3 @@ HEADERS += qcupsprintersupport_p.h \ qcupsprintengine_p.h OTHER_FILES += cups.json - -target.path += $$[QT_INSTALL_PLUGINS]/printsupport -INSTALLS += target diff --git a/src/plugins/printsupport/windows/windows.pro b/src/plugins/printsupport/windows/windows.pro index 3c5f22d411b..a1ba15c727c 100644 --- a/src/plugins/printsupport/windows/windows.pro +++ b/src/plugins/printsupport/windows/windows.pro @@ -1,11 +1,12 @@ TARGET = windows + +PLUGIN_TYPE = printsupport load(qt_plugin) QT *= core-private QT *= gui-private QT *= printsupport-private -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/printsupport INCLUDEPATH *= $$QT_SOURCE_TREE/src/printsupport/kernel SOURCES += \ @@ -17,6 +18,4 @@ HEADERS += \ OTHER_FILES += windows.json -target.path += $$[QT_INSTALL_PLUGINS]/printsupport -INSTALLS += target LIBS += -lwinspool -lcomdlg32 diff --git a/src/plugins/sqldrivers/qsqldriverbase.pri b/src/plugins/sqldrivers/qsqldriverbase.pri index 45638fcd4fe..17424f67644 100644 --- a/src/plugins/sqldrivers/qsqldriverbase.pri +++ b/src/plugins/sqldrivers/qsqldriverbase.pri @@ -1,8 +1,6 @@ -load(qt_plugin) QT = core sql-private -DESTDIR = $$QT.sql.plugins/sqldrivers -target.path += $$[QT_INSTALL_PLUGINS]/sqldrivers -INSTALLS += target +PLUGIN_TYPE = sqldrivers +load(qt_plugin) DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII From 6853f888ebf1fc8b30805b16b05a6d356a25fec6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 29 Oct 2012 11:22:17 +0100 Subject: [PATCH 109/134] use .qmake.conf instead of sync.profile as "anchor" this is less expensive, as qmake already provides us with it. Change-Id: Ifb44ea9126e6b52c02025858c5d88032e7a6cc2a Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_build_paths.prf | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mkspecs/features/qt_build_paths.prf b/mkspecs/features/qt_build_paths.prf index 62a5a801f3b..5f6f08c3db3 100644 --- a/mkspecs/features/qt_build_paths.prf +++ b/mkspecs/features/qt_build_paths.prf @@ -1,13 +1,6 @@ # Find the module's source root dir. -MODULE_PROFILE_DIR = $$_PRO_FILE_PWD_ -for(ever) { - exists($$MODULE_PROFILE_DIR/sync.profile):break() - nmpri = $$dirname(MODULE_PROFILE_DIR) - equals(nmpri, $$MODULE_PROFILE_DIR):error("No sync.profile found. This does not look like a Qt module source tree.") - MODULE_PROFILE_DIR = $$nmpri - unset(nmpri) -} - +isEmpty(_QMAKE_CONF_): error("Project has no top-level .qmake.conf file.") +MODULE_PROFILE_DIR = $$dirname(_QMAKE_CONF_) isEmpty(MODULE_BASE_DIR): MODULE_BASE_DIR = $$MODULE_PROFILE_DIR isEmpty(MODULE_BASE_OUTDIR): MODULE_BASE_OUTDIR = $$shadowed($$MODULE_BASE_DIR) isEmpty(MODULE_QMAKE_OUTDIR): MODULE_QMAKE_OUTDIR = $$MODULE_BASE_OUTDIR From 7db3c4dc1db3f401864292850038e1a0d8c964b5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 29 Oct 2012 18:32:04 +0100 Subject: [PATCH 110/134] remove pointless indirections Change-Id: I2bf6d9a0352dea75f8fd596859ca7939685c9cec Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_module.prf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index 79a4d80279d..50c7c74c821 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -92,10 +92,7 @@ MODULE_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules-inst/qt_lib_$${MODULE}.pri load(qt_module_fwdpri) -MODULE_INCLUDES = $$eval(QT.$${MODULE}.includes) -MODULE_PRIVATE_INCLUDES = $$eval(QT.$${MODULE}.private_includes) -INCLUDEPATH *= $$MODULE_INCLUDES -INCLUDEPATH *= $$MODULE_PRIVATE_INCLUDES +INCLUDEPATH *= $$eval(QT.$${MODULE}.includes) $$eval(QT.$${MODULE}.private_includes) load(qt_module_headers) From 8abfe4bb43616d1a57087bfa2c2cfc889a5dcea4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 29 Oct 2012 19:59:48 +0100 Subject: [PATCH 111/134] purge dead defines Change-Id: I8770416a19fb0951c0096cedf3f36c3493437903 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 3 --- src/tools/bootstrap/bootstrap.pri | 1 - 2 files changed, 4 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 28f8c8dd6dd..679dfc422cc 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -134,6 +134,3 @@ wince*:static:gui { } !isEmpty(QT_NAMESPACE):DEFINES *= QT_NAMESPACE=$$QT_NAMESPACE -mac { - !isEmpty(QT_NAMESPACE_MAC_CRC):DEFINES *= QT_NAMESPACE_MAC_CRC=$$QT_NAMESPACE_MAC_CRC -} diff --git a/src/tools/bootstrap/bootstrap.pri b/src/tools/bootstrap/bootstrap.pri index 7d3b9969fed..2b64b291b9d 100644 --- a/src/tools/bootstrap/bootstrap.pri +++ b/src/tools/bootstrap/bootstrap.pri @@ -7,7 +7,6 @@ CONFIG += exceptions_off DEFINES += \ QT_BOOTSTRAPPED \ QT_LITE_UNICODE \ - QT_TEXTCODEC \ QT_NO_CAST_FROM_ASCII \ QT_NO_CAST_TO_ASCII \ QT_NO_CODECS \ From 7d20f3dd1065a20b40cb4689783fba05190fe317 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 29 Oct 2012 12:43:43 +0100 Subject: [PATCH 112/134] rewrite default spec handling instead of symlinking (on unix) or creating a forwarding spec (on windows), just put the default specs into (the bootstrapped) QLibraryInfo. Change-Id: I595500ef7399f77cb8ec117c4303bc0a2ffe505f Reviewed-by: Joerg Bornemann Reviewed-by: Thiago Macieira --- configure | 10 +++--- qmake/library/qmakeevaluator.cpp | 14 ++++++-- qmake/property.cpp | 2 ++ qtbase.pro | 10 ------ src/corelib/global/qlibraryinfo.cpp | 8 +++++ src/corelib/global/qlibraryinfo.h | 4 ++- tools/configure/configureapp.cpp | 50 +++++++---------------------- tools/configure/configureapp.h | 1 - 8 files changed, 40 insertions(+), 59 deletions(-) diff --git a/configure b/configure index f9e08643e60..0c621fea419 100755 --- a/configure +++ b/configure @@ -2243,7 +2243,6 @@ if [ "$OPT_SHADOW" = "yes" ]; then mkdir -p "$outpath/mkspecs" rm -rf "$outpath"/mkspecs/* ln -s "$relpath"/mkspecs/* "$outpath/mkspecs" - rm -f "$outpath/mkspecs/default" ShadowMkspecs() { @@ -3527,6 +3526,9 @@ esac #------------------------------------------------------------------------------- [ -d "$outpath/src/corelib/global" ] || mkdir -p "$outpath/src/corelib/global" +shortxspec=`echo $XQMAKESPEC | sed "s,^${relpath}/mkspecs/,,"` +shortspec=`echo $QMAKESPEC | sed "s,^${relpath}/mkspecs/,,"` + cat > "$outpath/src/corelib/global/qconfig.cpp.new" < Date: Mon, 29 Oct 2012 15:16:51 +0100 Subject: [PATCH 113/134] Use the new QMAKE_XSPEC to get the mkspec. Change-Id: I7f307ffe0954464f68192f9f3781bdb206f87809 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/create_cmake.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 29d256db7f6..c879103c24d 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -60,7 +60,7 @@ static|staticlib:CMAKE_STATIC_TYPE = true contains(QT_CONFIG, reduce_relocations):CMAKE_ADD_FPIE_FLAGS = "true" -CMAKE_MKSPEC = $$relative_path($$QMAKESPEC, $$[QT_HOST_DATA/get]/mkspecs) +CMAKE_MKSPEC = $$[QMAKE_XSPEC] macx { !isEmpty(CMAKE_STATIC_TYPE) { From 589a18597f9d513e3b46f975844282624c792acc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 23 Oct 2012 20:45:18 +0200 Subject: [PATCH 114/134] move remaining configure'd CONFIG flags to qmodule.pri so they are uniformly available to all modules. Change-Id: I734f703c5923c42cb26f1456ed960cecc01c4b41 Reviewed-by: Joerg Bornemann Reviewed-by: Thiago Macieira --- configure | 5 +---- tools/configure/configureapp.cpp | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 0c621fea419..72eb29a1525 100755 --- a/configure +++ b/configure @@ -6074,7 +6074,7 @@ fi #------------------------------------------------------------------------------- QTMODULE="$outpath/mkspecs/qmodule.pri" -echo "CONFIG += $QMAKE_CONFIG create_prl link_prl" >> "$QTMODULE.tmp" +echo "CONFIG += $QMAKE_CONFIG create_prl link_prl fix_output_dirs no_private_qt_headers_warning QTDIR_build" >> "$QTMODULE.tmp" echo "QT_BUILD_PARTS += $CFG_BUILD_PARTS" >> "$QTMODULE.tmp" if [ -n "$QT_CFLAGS_PSQL" ]; then @@ -6139,9 +6139,6 @@ cat >>"$CACHEFILE.tmp" < Date: Wed, 24 Oct 2012 17:46:58 +0200 Subject: [PATCH 115/134] Improve / fix QRegularExpression* docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a couple of typos; also, wrapped the snippets in a main() function, so that now the snippet file can be compiled (and therefore the compiler can help us at detecting those typos). Change-Id: Ie182a9c4cb451db13a6f4bfa5eaed66bc6966c8f Reviewed-by: Topi Reiniö Reviewed-by: Casper van Donderen Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../src_corelib_tools_qregularexpression.cpp | 124 +++++++++++++----- 1 file changed, 89 insertions(+), 35 deletions(-) diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp index 6538c7178da..f1479a8ed76 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp @@ -38,17 +38,28 @@ ** ****************************************************************************/ +#include +#include +#include +#include +#include + +int main() { + +{ //! [0] QRegularExpression re("a pattern"); //! [0] +} - +{ //! [1] QRegularExpression re; re.setPattern("another pattern"); //! [1] +} - +{ //! [2] // matches two digits followed by a space and a word QRegularExpression re("\\d\\d \\w+"); @@ -56,27 +67,31 @@ QRegularExpression re("\\d\\d \\w+"); // matches a backslash QRegularExpression re2("\\\\"); //! [2] +} - +{ //! [3] QRegularExpression re("a third pattern"); QString pattern = re.pattern(); // pattern == "a third pattern" //! [3] +} - +{ //! [4] // matches "Qt rocks", but also "QT rocks", "QT ROCKS", "qT rOcKs", etc. QRegularExpression re("Qt rocks", QRegularExpression::CaseInsensitiveOption); //! [4] +} - +{ //! [5] QRegularExpression re("^\\d+$"); re.setPatternOptions(QRegularExpression::MultilineOption); // re matches any line in the subject string that contains only digits (but at least one) //! [5] +} - +{ //! [6] QRegularExpression re = QRegularExpression("^two.*words$", QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption); @@ -84,16 +99,18 @@ QRegularExpression re = QRegularExpression("^two.*words$", QRegularExpression::M QRegularExpression::PatternOptions options = re.patternOptions(); // options == QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption //! [6] +} - +{ //! [7] // match two digits followed by a space and a word QRegularExpression re("\\d\\d \\w+"); QRegularExpressionMatch match = re.match("abc123 def"); bool hasMatch = match.hasMatch(); // true //! [7] +} - +{ //! [8] QRegularExpression re("\\d\\d \\w+"); QRegularExpressionMatch match = re.match("abc123 def"); @@ -102,8 +119,9 @@ if (match.hasMatch()) { // ... } //! [8] +} - +{ //! [9] QRegularExpression re("\\d\\d \\w+"); QRegularExpressionMatch match = re.match("12 abc 45 def", 1); @@ -112,31 +130,34 @@ if (match.hasMatch()) { // ... } //! [9] +} - +{ //! [10] QRegularExpression re("^(\\d\\d)/(\\d\\d)/(\\d\\d\\d\\d)$"); QRegularExpressionMatch match = re.match("08/12/1985"); if (match.hasMatch()) { - QString day = re.captured(1); // day == "08" - QString month = re.captured(2); // month == "12" - QString year = re.captured(3); // year == "1985" + QString day = match.captured(1); // day == "08" + QString month = match.captured(2); // month == "12" + QString year = match.captured(3); // year == "1985" // ... } //! [10] +} - +{ //! [11] QRegularExpression re("abc(\\d+)def"); QRegularExpressionMatch match = re.match("XYZabc123defXYZ"); if (match.hasMatch()) { - int startOffset = re.capturedStart(1); // startOffset == 6 - int endOffset = re.capturedEnd(1); // endOffset == 9 + int startOffset = match.capturedStart(1); // startOffset == 6 + int endOffset = match.capturedEnd(1); // endOffset == 9 // ... } //! [11] +} - +{ //! [12] QRegularExpression re("^(?\\d\\d)/(?\\d\\d)/(?\\d\\d\\d\\d)$"); QRegularExpressionMatch match = re.match("08/12/1985"); @@ -146,14 +167,14 @@ if (match.hasMatch()) { QString year = match.captured("year"); // year == 1985 } //! [12] +} - +{ //! [13] QRegularExpression re("(\\w+)"); QRegularExpressionMatchIterator i = re.globalMatch("the quick fox"); //! [13] - //! [14] QStringList words; while (i.hasNext()) { @@ -163,72 +184,86 @@ while (i.hasNext()) { } // words contains "the", "quick", "fox" //! [14] +} - +{ //! [15] QString pattern("^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \\d\\d?, \\d\\d\\d\\d$"); QRegularExpression re(pattern); QString input("Jan 21,"); -QRegularExpressionMatch match = re.match(input, 0, QRegularExpressionMatch::PartialPreferCompleteMatch); +QRegularExpressionMatch match = re.match(input, 0, QRegularExpression::PartialPreferCompleteMatch); bool hasMatch = match.hasMatch(); // false bool hasPartialMatch = match.hasPartialMatch(); // true //! [15] +} - +{ +QString pattern("^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \\d\\d?, \\d\\d\\d\\d$"); +QRegularExpression re(pattern); //! [16] QString input("Dec 8, 1985"); -QRegularExpressionMatch match = re.match(input, 0, QRegularExpressionMatch::PartialPreferCompleteMatch); +QRegularExpressionMatch match = re.match(input, 0, QRegularExpression::PartialPreferCompleteMatch); bool hasMatch = match.hasMatch(); // true bool hasPartialMatch = match.hasPartialMatch(); // false //! [16] +} - +{ //! [17] QRegularExpression re("abc\\w+X|def"); -QRegularExpressionMatch match = re.match("abcdef", 0, QRegularExpressionMatch::PartialPreferCompleteMatch); +QRegularExpressionMatch match = re.match("abcdef", 0, QRegularExpression::PartialPreferCompleteMatch); bool hasMatch = match.hasMatch(); // true bool hasPartialMatch = match.hasPartialMatch(); // false QString captured = match.captured(0); // captured == "def" //! [17] +} - +{ //! [18] QRegularExpression re("abc\\w+X|defY"); -QRegularExpressionMatch match = re.match("abcdef", 0, QRegularExpressionMatch::PartialPreferCompleteMatch); +QRegularExpressionMatch match = re.match("abcdef", 0, QRegularExpression::PartialPreferCompleteMatch); bool hasMatch = match.hasMatch(); // false bool hasPartialMatch = match.hasPartialMatch(); // true QString captured = match.captured(0); // captured == "abcdef" //! [18] +} - +{ //! [19] QRegularExpression re("abc|ab"); -QRegularExpressionMatch match = re.match("ab", 0, QRegularExpressionMatch::PartialPreferFirstMatch); +QRegularExpressionMatch match = re.match("ab", 0, QRegularExpression::PartialPreferFirstMatch); bool hasMatch = match.hasMatch(); // false bool hasPartialMatch = match.hasPartialMatch(); // true //! [19] +} - +{ //! [20] QRegularExpression re("abc(def)?"); -QRegularExpressionMatch match = re.match("abc", 0, QRegularExpressionMatch::PartialPreferFirstMatch); +QRegularExpressionMatch match = re.match("abc", 0, QRegularExpression::PartialPreferFirstMatch); bool hasMatch = match.hasMatch(); // false bool hasPartialMatch = match.hasPartialMatch(); // true //! [20] +} +{ //! [21] QRegularExpression re("(abc)*"); -QRegularExpressionMatch match = re.match("abc", 0, QRegularExpressionMatch::PartialPreferFirstMatch); +QRegularExpressionMatch match = re.match("abc", 0, QRegularExpression::PartialPreferFirstMatch); bool hasMatch = match.hasMatch(); // false bool hasPartialMatch = match.hasPartialMatch(); // true //! [21] +} +{ //! [22] QRegularExpression invalidRe("(unmatched|parenthesis"); bool isValid = invalidRe.isValid(); // false //! [22] +} +{ //! [23] QRegularExpression invalidRe("(unmatched|parenthesis"); if (!invalidRe.isValid()) { @@ -237,44 +272,62 @@ if (!invalidRe.isValid()) { // ... } //! [23] +} +{ //! [24] QRegularExpression re("^this pattern must match exactly$"); //! [24] +} +{ //! [25] QString p("a .*|pattern"); QRegularExpression re("\\A(?:" + p + ")\\z"); // re matches exactly the pattern string p //! [25] +} +{ //! [26] QString escaped = QRegularExpression::escape("a(x) = f(x) + g(x)"); // escaped == "a\\(x\\)\\ \\=\\ f\\(x\\)\\ \\+\\ g\\(x\\)" //! [26] +} +{ +QString name; +QString nickname; //! [27] QString pattern = "(" + QRegularExpression::escape(name) + "|" + QRegularExpression::escape(nickname) + ")"; QRegularExpression re(pattern); //! [27] +} +{ +QString string; +QRegularExpression re; //! [28] -QRegularExpressionMatch match = re.match(...); +QRegularExpressionMatch match = re.match(string); for (int i = 0; i <= match.lastCapturedIndex(); ++i) { QString captured = match.captured(i); // ... } //! [28] +} +{ //! [29] -QRegularExpression("(\\d\\d) (?\\w+)"); +QRegularExpression re("(\\d\\d) (?\\w+)"); QRegularExpressionMatch match = re.match("23 Jordan"); if (match.hasMatch()) { QString number = match.captured(1); // first == "23" QString name = match.captured("name"); // name == "Jordan" } //! [29] +} +{ //! [30] // extracts the words QRegularExpression re("(\\w+)"); @@ -285,5 +338,6 @@ while (i.hasNext()) { // ... } //! [30] +} - +} From 81f8f0db5cb75e29b041a011ca4e7dbbf2d903c5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 30 Oct 2012 10:15:20 +0100 Subject: [PATCH 116/134] disambiguate plugin name vs. windows platform plugin static plugin linking needs unique names. also, non-unique names are generally somewhat counterproductive. Change-Id: Idffba2b442b98dd2b0917f9f0af89f0694a99196 Reviewed-by: Mark Brand Reviewed-by: Robin Burchell --- src/plugins/printsupport/windows/windows.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/printsupport/windows/windows.pro b/src/plugins/printsupport/windows/windows.pro index a1ba15c727c..5e8738554c5 100644 --- a/src/plugins/printsupport/windows/windows.pro +++ b/src/plugins/printsupport/windows/windows.pro @@ -1,4 +1,4 @@ -TARGET = windows +TARGET = windowsprintersupport PLUGIN_TYPE = printsupport load(qt_plugin) From 733ac1f6e6b3155a594376ef99288c6117124000 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 24 Oct 2012 15:02:08 +0200 Subject: [PATCH 117/134] let static plugins have "module" pri files ... and use them in qt.prf instead of (not) maintaining hand-coded lists. Change-Id: Ia21f7864eaf3ca92fa75f23876f71075d0521f4b Reviewed-by: Mark Brand --- mkspecs/features/qt.prf | 32 +------------------------------- mkspecs/features/qt_plugin.prf | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 679dfc422cc..c4b991becda 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -40,37 +40,7 @@ for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) { for(QTPLUG, $$list($$lower($$unique($$QT_CURRENT_VERIFY)))) { # Check if the plugin is known to Qt. We can use this to determine # the plugin path. Unknown plugins must rely on the default link path. - ACCESSIBLEPLUGINS = qtaccessiblewidgets qtaccessiblecompatwidgets - BEARERPLUGINS = qgenericbearer qnativewifibearer - CODECPLUGINS = qcncodecs qjpcodecs qkrcodecs qtwcodecs - DECORATIONPLUGINS = qdecorationdefault qdecorationstyled qdecorationwindows - GFXDRIVERPLUGINS = qscreenvfb qgfxtransformed qgfxshadowfb qgfxpvregl qscreenlinuxfb qeglnullws qdirectfbscreen qahiscreen - GRAPHICSSYSTEMPLUGINS = qmeegographicssystem qglgraphicssystem qvggraphicssystem qshivavggraphicssystem - IMAGEPLUGINS = qgif qico qjpeg qsvg - INPUTPLUGINS = qimsw-multi - KBDDRIVERPLUGINS = qlinuxinputkbddriver - MOUSEDRIVERPLUGINS = qtslibmousehandler qpcmousedriver qlinuxtpmousedriver - SQLPLUGINS = qsqldb2 qsqloci qsqltds qsqlodbc qsqlpsql qsqlibase qsqlmysql qsqlite2 qsqlite - PHONONPLUGINS = phonon_waveout phonon_ds9 phonon_gstreamer phonon_qt7 phonon_mmf - - ALLQTPLUGINS = $$ACCESSIBLEPLUGINS $$BEARERPLUGINS $$CODECPLUGINS $$DECORATIONPLUGINS $$GFXDRIVERPLUGINS $$GRAPHICSSYSTEMPLUGINS $$IMAGEPLUGINS $$INPUTPLUGINS $$KBDDRIVERPLUGINS $$MOUSEDRIVERPLUGINS $$SQLPLUGINS $$PHONONPLUGINS - - QT_PLUGINPATH = - contains(ALLQTPLUGINS, $$QTPLUG) { - # Determine the plugin path - contains(ACCESSIBLEPLUGINS, $$QTPLUG): QT_PLUGINPATH = accessible - contains(BEARERPLUGINS, $$QTPLUG): QT_PLUGINPATH = bearer - contains(CODECPLUGINS, $$QTPLUG): QT_PLUGINPATH = codecs - contains(DECORATIONPLUGINS, $$QTPLUG): QT_PLUGINPATH = decorations - contains(GFXDRIVERPLUGINS, $$QTPLUG): QT_PLUGINPATH = gfxdrivers - contains(GRAPHICSSYSTEMPLUGINS, $$QTPLUG): QT_PLUGINPATH = graphicssystems - contains(IMAGEPLUGINS, $$QTPLUG): QT_PLUGINPATH = imageformats - contains(INPUTPLUGINS, $$QTPLUG): QT_PLUGINPATH = inputmethods - contains(KBDDRIVERPLUGINS, $$QTPLUG): QT_PLUGINPATH = kbddrivers - contains(MOUSEDRIVERPLUGINS, $$QTPLUG): QT_PLUGINPATH = mousedrivers - contains(SQLPLUGINS, $$QTPLUG): QT_PLUGINPATH = sqldrivers - contains(PHONONPLUGINS, $$QTPLUG): QT_PLUGINPATH = phonon_backend - } + QT_PLUGINPATH = $$eval(QT_PLUGIN.$${QTPLUG}.TYPE) # Generate the plugin linker line target_qt:isEqual(TARGET, QTPLUG) { diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf index 363664bb670..b84fa47dd14 100644 --- a/mkspecs/features/qt_plugin.prf +++ b/mkspecs/features/qt_plugin.prf @@ -20,6 +20,20 @@ contains(QT_CONFIG, c++11):CONFIG += c++11 contains(QT_CONFIG, static):CONFIG += static else:CONFIG += shared +!build_pass:static { + isEmpty(MODULE): MODULE = $$section($$list($$basename(_PRO_FILE_)), ., 0, 0) + + MODULE_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules/qt_plugin_$${MODULE}.pri + + MODULE_PRI_CONT = \ + "QT_PLUGIN.$${MODULE}.TYPE = $$PLUGIN_TYPE" + write_file($$MODULE_PRI, MODULE_PRI_CONT)|error("Aborting.") + + pritarget.path = $$[QT_HOST_DATA]/mkspecs/modules + pritarget.files = $$MODULE_PRI + INSTALLS += pritarget +} + target.path = $$[QT_INSTALL_PLUGINS]/$$PLUGIN_TYPE INSTALLS += target From 30542304f19fe967b29f71c67cdcc782dc1fa1a8 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 24 Oct 2012 16:09:52 +0200 Subject: [PATCH 118/134] Mac: Add support for WindowMasks platform capability Also brings back a working QWidgetPrivate::setMask_sys(). Change-Id: Idde9eea15d28bb0299258df81322a5a3ff0b9493 Reviewed-by: Liang Qi Reviewed-by: Jens Bache-Wiig --- .../platforms/cocoa/qcocoaintegration.mm | 13 ++- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 10 ++ src/plugins/platforms/cocoa/qnsview.h | 3 + src/plugins/platforms/cocoa/qnsview.mm | 105 +++++++++++++----- 5 files changed, 100 insertions(+), 32 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index b069446c504..100dc1962cb 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -302,11 +302,14 @@ void QCocoaIntegration::updateScreens() bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { - case ThreadedPixmaps: return true; - case OpenGL : return true; - case ThreadedOpenGL : return true; - case BufferQueueingOpenGL: return true; - default: return QPlatformIntegration::hasCapability(cap); + case ThreadedPixmaps: + case OpenGL: + case ThreadedOpenGL: + case BufferQueueingOpenGL: + case WindowMasks: + return true; + default: + return QPlatformIntegration::hasCapability(cap); } } diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index d5dbe58de9e..db3a20c2be5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -107,6 +107,7 @@ public: void lower(); void propagateSizeHints(); void setOpacity(qreal level); + void setMask(const QRegion ®ion); bool setKeyboardGrabEnabled(bool grab); bool setMouseGrabEnabled(bool grab); QMargins frameMargins() const; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index d6b4ee68a90..de6e7dc43e5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -509,6 +509,16 @@ void QCocoaWindow::setOpacity(qreal level) [m_nsWindow setAlphaValue:level]; } +void QCocoaWindow::setMask(const QRegion ®ion) +{ + if (m_nsWindow) { + [m_nsWindow setOpaque:NO]; + [m_nsWindow setBackgroundColor:[NSColor clearColor]]; + } + + [m_contentView setMaskRegion:®ion]; +} + bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) { if (!m_nsWindow) diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 32e140f9ff7..246d311f7b5 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -54,6 +54,8 @@ QT_END_NAMESPACE @interface QNSView : NSView { CGImageRef m_cgImage; + CGImageRef m_maskImage; + uchar *m_maskData; QWindow *m_window; QCocoaWindow *m_platformWindow; Qt::MouseButtons m_buttons; @@ -68,6 +70,7 @@ QT_END_NAMESPACE - (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow; - (void)setImage:(QImage *)image; +- (void)setMaskRegion:(const QRegion *)region; - (void)drawRect:(NSRect)dirtyRect; - (void)updateGeometry; - (void)windowNotification : (NSNotification *) windowNotification; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 33d0fb4bae2..d62913a7af0 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -75,6 +75,8 @@ static QTouchDevice *touchDevice = 0; self = [super initWithFrame : NSMakeRect(0,0, 300,300)]; if (self) { m_cgImage = 0; + m_maskImage = 0; + m_maskData = 0; m_window = 0; m_buttons = Qt::NoButton; m_sendKeyEvent = false; @@ -93,6 +95,10 @@ static QTouchDevice *touchDevice = 0; { CGImageRelease(m_cgImage); m_cgImage = 0; + CGImageRelease(m_maskImage); + m_maskImage = 0; + delete[] m_maskData; + m_maskData = 0; m_window = 0; [super dealloc]; } @@ -205,47 +211,86 @@ static QTouchDevice *touchDevice = 0; } } -- (void) setImage:(QImage *)image +static CGImageRef qt_mac_toCGImage(QImage *qImage, bool isMask, uchar **dataCopy) { - CGImageRelease(m_cgImage); - - int width = image->width(); - int height = image->height(); + int width = qImage->width(); + int height = qImage->height(); if (width <= 0 || height <= 0) { qWarning() << Q_FUNC_INFO << "setting invalid size" << width << "x" << height << "for qnsview image"; - m_cgImage = 0; - return; + return 0; } - const uchar *imageData = image->bits(); - int bitDepth = image->depth(); + const uchar *imageData = qImage->bits(); + if (dataCopy) { + delete[] *dataCopy; + *dataCopy = new uchar[qImage->byteCount()]; + memcpy(*dataCopy, imageData, qImage->byteCount()); + } + int bitDepth = qImage->depth(); int colorBufferSize = 8; - int bytesPrLine = image->bytesPerLine(); - - CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB(); + int bytesPrLine = qImage->bytesPerLine(); CGDataProviderRef cgDataProviderRef = CGDataProviderCreateWithData( NULL, - imageData, - image->byteCount(), + dataCopy ? *dataCopy : imageData, + qImage->byteCount(), NULL); - m_cgImage = CGImageCreate(width, - height, - colorBufferSize, - bitDepth, - bytesPrLine, - cgColourSpaceRef, - kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, - cgDataProviderRef, - NULL, - false, - kCGRenderingIntentDefault); + CGImageRef cgImage = 0; + if (isMask) { + cgImage = CGImageMaskCreate(width, + height, + colorBufferSize, + bitDepth, + bytesPrLine, + cgDataProviderRef, + NULL, + false); + } else { + CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB(); + cgImage = CGImageCreate(width, + height, + colorBufferSize, + bitDepth, + bytesPrLine, + cgColourSpaceRef, + kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, + cgDataProviderRef, + NULL, + false, + kCGRenderingIntentDefault); + CGColorSpaceRelease(cgColourSpaceRef); + } + return cgImage; +} - CGColorSpaceRelease(cgColourSpaceRef); +- (void) setImage:(QImage *)image +{ + CGImageRelease(m_cgImage); + m_cgImage = qt_mac_toCGImage(image, false, 0); +} +- (void) setMaskRegion:(const QRegion *)region +{ + if (m_maskImage) + CGImageRelease(m_maskImage); + if (region->isEmpty()) { + m_maskImage = 0; + } + + const QRect &rect = qt_mac_toQRect([self frame]); + QImage maskImage(rect.size(), QImage::Format_RGB888); + maskImage.fill(Qt::white); + QPainter p(&maskImage); + p.setRenderHint(QPainter::Antialiasing); + p.setClipRegion(*region); + p.fillRect(rect, QBrush(Qt::black)); + p.end(); + + maskImage = maskImage.convertToFormat(QImage::Format_Indexed8); + m_maskImage = qt_mac_toCGImage(&maskImage, true, &m_maskData); } - (void) drawRect:(NSRect)dirtyRect @@ -263,13 +308,19 @@ static QTouchDevice *touchDevice = 0; CGContextTranslateCTM(cgContext, 0, dy); CGContextScaleCTM(cgContext, 1, -1); + CGImageRef subMask = 0; + if (m_maskImage) { + subMask = CGImageCreateWithImageInRect(m_maskImage, dirtyCGRect); + CGContextClipToMask(cgContext, dirtyCGRect, subMask); + } + CGImageRef subImage = CGImageCreateWithImageInRect(m_cgImage, dirtyCGRect); CGContextDrawImage(cgContext,dirtyCGRect,subImage); CGContextRestoreGState(cgContext); CGImageRelease(subImage); - + CGImageRelease(subMask); } - (BOOL) isFlipped From e3b78896d21000c759ccc1e2781a471327307710 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 31 Oct 2012 10:05:46 +0100 Subject: [PATCH 119/134] Fix warnings when using QImage as QtConcurrent::mapped return type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-27391 Change-Id: I68b37ffa645be21d4d23b205bc052540b9aba7f4 Reviewed-by: Olivier Goffart Reviewed-by: João Abecasis --- src/corelib/tools/qvector.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 94733f77da6..2c688db5074 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -252,7 +252,7 @@ void QVector::defaultConstruct(T *from, T *to) new (from++) T(); } } else { - ::memset(from, 0, (to - from) * sizeof(T)); + ::memset(static_cast(from), 0, (to - from) * sizeof(T)); } } @@ -267,7 +267,7 @@ void QVector::copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom) while (srcFrom != srcTo) new (dstFrom++) T(*srcFrom++); } else { - ::memcpy(dstFrom, srcFrom, (srcTo - srcFrom) * sizeof(T)); + ::memcpy(static_cast(dstFrom), static_cast(srcFrom), (srcTo - srcFrom) * sizeof(T)); } } @@ -467,7 +467,7 @@ void QVector::reallocData(const int asize, const int aalloc, QArrayData::Allo new (dst++) T(*srcBegin++); } } else { - ::memcpy(static_cast(dst), srcBegin, (srcEnd - srcBegin) * sizeof(T)); + ::memcpy(static_cast(dst), static_cast(srcBegin), (srcEnd - srcBegin) * sizeof(T)); dst += srcEnd - srcBegin; // destruct unused / not moved data From 0c1bbf0386680a80678cf75faad1318a424bf401 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 30 Oct 2012 15:28:17 +0200 Subject: [PATCH 120/134] SSL certificate printing: Fix auto test for OpenSSL 1.0.1 version. Different OpenSSL versions produce slightly different output when dumping a certificate. Change-Id: Ida98b24422302e287641be074d6740ca292cf203 Reviewed-by: Richard J. Moore --- .../cert-large-expiration-date.txt.1.0.1 | 42 +++++++++++++++++++ .../qsslcertificate/tst_qsslcertificate.cpp | 25 +++++++---- 2 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1 diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1 b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1 new file mode 100644 index 00000000000..1a7d945b768 --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1 @@ -0,0 +1,42 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + ce:db:31:28:45:c4:05:40 + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd + Validity + Not Before: Aug 4 09:53:41 2010 GMT + Not After : Aug 29 09:53:41 2051 GMT + Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (1024 bit) + Modulus: + 00:cd:aa:db:6f:d6:34:c9:a7:f1:c0:be:e4:41:18: + 19:e2:02:c9:22:e6:a7:d5:ba:03:2e:9e:28:7a:f4: + 5f:1a:77:5f:77:a9:11:3b:8f:7e:f0:2e:c6:9e:eb: + 3a:d9:12:d7:c1:0c:51:e8:24:52:3f:23:c3:42:0c: + 11:c6:f2:1c:a1:42:fe:b4:c2:69:83:ad:f7:70:b1: + 18:15:cc:20:28:62:30:f0:2c:15:e6:33:19:af:c3: + eb:1c:c0:91:f7:11:68:94:50:f8:49:37:08:32:d7: + 3e:75:df:a3:bc:69:00:15:de:cd:87:0f:5c:02:6b: + 82:c8:01:7d:6a:f0:1d:dc:73 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + 8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9 + X509v3 Authority Key Identifier: + keyid:8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9 + + X509v3 Basic Constraints: + CA:TRUE + Signature Algorithm: sha1WithRSAEncryption + a1:74:8e:5d:36:96:2c:05:7e:ea:66:cc:2e:68:c7:3d:93:dc: + 8c:a3:11:ad:b5:7e:6e:d0:04:c4:09:bd:0a:f9:39:3b:97:d7: + f0:bb:0c:09:7b:83:fe:bf:87:b0:47:e8:94:b7:aa:9c:79:ad: + 71:9e:b7:c4:99:98:6f:1d:38:32:f8:a3:75:38:c4:e5:e7:37: + 37:21:ec:7b:50:8b:15:b0:97:1e:17:9c:50:17:3c:c1:df:94: + 55:fb:60:2e:50:40:d1:ea:23:c6:3c:21:6f:97:8c:06:16:a5: + 82:72:c1:63:14:64:86:eb:d7:ff:72:f6:09:f5:6d:e6:04:13: + 7a:6a diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 3ed753d2921..c30a8f5e972 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -854,16 +854,25 @@ void tst_QSslCertificate::toText() QCOMPARE(certList.size(), 1); const QSslCertificate &cert = certList.at(0); - // Openssl's cert dump method changed slightly between 0.9.8 and 1.0.0 versions, so we want it to match any output + // Openssl's cert dump method changed slightly between 0.9.8, 1.0.0 and 1.01 versions, so we want it to match any output - QFile fOld(testDataDir + "/more-certificates/cert-large-expiration-date.txt.0.9.8"); - QVERIFY(fOld.open(QIODevice::ReadOnly | QFile::Text)); - QByteArray txtOld = fOld.readAll(); + QFile f098(testDataDir + "/more-certificates/cert-large-expiration-date.txt.0.9.8"); + QVERIFY(f098.open(QIODevice::ReadOnly | QFile::Text)); + QByteArray txt098 = f098.readAll(); - QFile fNew(testDataDir + "/more-certificates/cert-large-expiration-date.txt.1.0.0"); - QVERIFY(fNew.open(QIODevice::ReadOnly | QFile::Text)); - QByteArray txtNew = fNew.readAll(); - QVERIFY(QString::fromLatin1(txtOld) == cert.toText() || QString::fromLatin1(txtNew) == cert.toText()); + QFile f100(testDataDir + "/more-certificates/cert-large-expiration-date.txt.1.0.0"); + QVERIFY(f100.open(QIODevice::ReadOnly | QFile::Text)); + QByteArray txt100 = f100.readAll(); + + QFile f101(testDataDir + "/more-certificates/cert-large-expiration-date.txt.1.0.1"); + QVERIFY(f101.open(QIODevice::ReadOnly | QFile::Text)); + QByteArray txt101 = f101.readAll(); + + QString txtcert = cert.toText(); + + QVERIFY(QString::fromLatin1(txt098) == txtcert || + QString::fromLatin1(txt100) == txtcert || + QString::fromLatin1(txt101) == txtcert ); } void tst_QSslCertificate::multipleCommonNames() From 39964b94c993d23de07df26e18a62b4bc5bb9ea5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 31 Oct 2012 14:23:26 +0100 Subject: [PATCH 121/134] XCB: Use screen's client leader as fallback for transient parent. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modal dialogs that do not have a QWidget parent may be hidden by their parent unless they actually have a transient parent. Task-number: QTBUG-27786 Change-Id: I7847df3517e5ba6e8d77a2a18c905e908a3cd2f4 Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbwindow.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 48754b0a605..eab18e2435d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -542,16 +542,18 @@ void QXcbWindow::show() propagateSizeHints(); // update WM_TRANSIENT_FOR - if (window()->transientParent() && isTransient(window())) { - QXcbWindow *transientXcbParent = static_cast(window()->transientParent()->handle()); - if (transientXcbParent) { - // ICCCM 4.1.2.6 - xcb_window_t parentWindow = transientXcbParent->xcb_window(); - - // todo: set transient for group (wm_client_leader) if no parent, a la qwidget_x11.cpp + if (isTransient(window())) { + xcb_window_t transientXcbParent = 0; + if (const QWindow *tp = window()->transientParent()) + transientXcbParent = static_cast(tp->handle())->winId(); + // Default to client leader if there is no transient parent, else modal dialogs can + // be hidden by their parents. + if (!transientXcbParent) + transientXcbParent = static_cast(screen())->clientLeader(); + if (transientXcbParent) { // ICCCM 4.1.2.6 Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, - 1, &parentWindow)); + 1, &transientXcbParent)); } } From 5b19228c2af24629dfffb40673f05a3500a66533 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 1 Nov 2012 15:07:16 +0100 Subject: [PATCH 122/134] Compile cocoa with QT_NO_ACCESSIBILITY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I82b5dbf1bce94bd928eee207992c0036edc527ad Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaintegration.h | 2 ++ src/plugins/platforms/cocoa/qcocoaintegration.mm | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index d465d47e129..ea43bbbc10f 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -128,7 +128,9 @@ private: QAbstractEventDispatcher *mEventDispatcher; QScopedPointer mInputContext; +#ifndef QT_NO_ACCESSIBILITY QScopedPointer mAccessibility; +#endif QScopedPointer mPlatformTheme; QList mScreens; QCocoaClipboard *mCocoaClipboard; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 100dc1962cb..2fdb367c629 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -180,7 +180,9 @@ QCocoaIntegration::QCocoaIntegration() : mFontDb(new QCoreTextFontDatabase()) , mEventDispatcher(new QCocoaEventDispatcher()) , mInputContext(new QCocoaInputContext) +#ifndef QT_NO_ACCESSIBILITY , mAccessibility(new QPlatformAccessibility) +#endif , mCocoaClipboard(new QCocoaClipboard) , mCocoaDrag(new QCocoaDrag) , mNativeInterface(new QCocoaNativeInterface) @@ -352,7 +354,11 @@ QPlatformInputContext *QCocoaIntegration::inputContext() const QPlatformAccessibility *QCocoaIntegration::accessibility() const { +#ifndef QT_NO_ACCESSIBILITY return mAccessibility.data(); +#else + return 0; +#endif } QPlatformClipboard *QCocoaIntegration::clipboard() const From 12e92ff8072b06f5f9b68a071223a94e7460a383 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 1 Nov 2012 14:32:46 +0100 Subject: [PATCH 123/134] Expose IAccessibleTable2 to non-conformant screen readers This seems to be the established practice. Change-Id: I75a65d722a026ab0eb1805688743f46aba406e6c Reviewed-by: Frederik Gladhorn --- .../windows/accessible/iaccessible2.cpp | 27 ++++-- .../qaccessibility/tst_qaccessibility.cpp | 82 ++++++++++++++++++- 2 files changed, 101 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index 6acfd6e602c..03bb94db8f3 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -1493,13 +1493,26 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryService(REFGUID guidServic *iface = 0; accessibleDebug("QWindowsIA2Accessible::QS(): %s", IIDToString(riid).constData()); - if (guidService == IID_IAccessible && riid == IID_IAccessible2) { - // The conditions for entering here should be ok (from _dicoveringInterfaces in IAccessible2.idl) - *iface = static_cast(this); - } else if (guidService == IID_IAccessible && (riid == IID_IAccessible || riid == IID_IUnknown || riid == IID_IDispatch)) { - // The above conditions works with AccProbe and NVDA. - *iface = static_cast(this); - } else if (riid == IID_IAccessibleApplication) { + + if (guidService == IID_IAccessible) { + if (riid == IID_IServiceProvider) { + // do not end up calling QueryInterface for IID_IServiceProvider + *iface = 0; + } else if (riid == IID_IAccessible || riid == IID_IUnknown || riid == IID_IDispatch) { + // The above conditions works with AccProbe and NVDA. + *iface = static_cast(this); + } else { + // According to _dicoveringInterfaces Discovery of Interfaces, we should really only + // enter here if riid == IID_IAccessible2, but some screen readers does not like that, + // and other servers seems to have realized that. (Chrome and Mozilla for instance, + // calls QueryInterface more or less in the same way) + + // For instance, accProbe discovers IID_IAccessibleTable2 by a QueryService only. + return QueryInterface(riid, iface); + } + } + + if (riid == IID_IAccessibleApplication) { *iface = new AccessibleApplication; return S_OK; } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 1b8ac101bc5..7d0914b7917 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -52,6 +52,8 @@ # include # include # include +# include +# include # endif #endif #include @@ -3033,8 +3035,29 @@ void tst_QAccessibility::bridgeTest() QPushButton *button = new QPushButton(tr("Push me"), window); QTextEdit *te = new QTextEdit(window); te->setText(QLatin1String("hello world\nhow are you today?\n")); + + // Add QTableWidget + QTableWidget *tableWidget = new QTableWidget(3, 3, window); + tableWidget->setColumnCount(3); + QStringList hHeader; + hHeader << "h1" << "h2" << "h3"; + tableWidget->setHorizontalHeaderLabels(hHeader); + + QStringList vHeader; + vHeader << "v1" << "v2" << "v3"; + tableWidget->setVerticalHeaderLabels(vHeader); + + for (int i = 0; i<9; ++i) { + QTableWidgetItem *item = new QTableWidgetItem; + item->setText(QString::number(i/3) + QString(".") + QString::number(i%3)); + tableWidget->setItem(i/3, i%3, item); + } + + tableWidget->setFixedSize(600, 600); + lay->addWidget(button); lay->addWidget(te); + lay->addWidget(tableWidget); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -3130,7 +3153,7 @@ void tst_QAccessibility::bridgeTest() long nChildren; hr = iaccWindow->get_accChildCount(&nChildren); QVERIFY(SUCCEEDED(hr)); - QCOMPARE(nChildren, (long)2); + QCOMPARE(nChildren, (long)3); /************************************************** * QTextEdit @@ -3170,6 +3193,63 @@ void tst_QAccessibility::bridgeTest() iaccTextEdit->Release(); + /************************************************** + * QTableWidget + **************************************************/ + { + // Get the second child (the accessible interface for the table widget) + varChild.vt = VT_I4; + varChild.lVal = 3; + QVERIFY(iaccWindow); + IAccessible *iaccTable = 0; + hr = iaccWindow->get_accChild(varChild, (IDispatch**)&iaccTable); + QVERIFY(SUCCEEDED(hr)); + QVERIFY(iaccTable); + hr = iaccTable->get_accRole(varSELF, &varRole); + QVERIFY(SUCCEEDED(hr)); + + QCOMPARE(varRole.vt, (VARTYPE)VT_I4); + QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_TABLE); + + +#ifdef QT_SUPPORTS_IACCESSIBLE2 + IAccessibleTable2 *ia2Table = (IAccessibleTable2*)queryIA2(iaccTable, IID_IAccessibleTable2); + QVERIFY(ia2Table); + BSTR bstrDescription; + hr = ia2Table->get_columnDescription(0, &bstrDescription); + QVERIFY(SUCCEEDED(hr)); + const QString description((QChar*)bstrDescription); + QCOMPARE(description, QLatin1String("h1")); + + IAccessible *accTableCell = 0; + hr = ia2Table->get_cellAt(1, 2, (IUnknown**)&accTableCell); + IAccessibleTableCell *ia2TableCell = (IAccessibleTableCell *)queryIA2(accTableCell, IID_IAccessibleTableCell); + QVERIFY(SUCCEEDED(hr)); + QVERIFY(ia2TableCell); + LONG index; + ia2TableCell->get_rowIndex(&index); + QCOMPARE(index, (LONG)1); + ia2TableCell->get_columnIndex(&index); + QCOMPARE(index, (LONG)2); + + IAccessible *iaccTableCell = 0; + hr = ia2TableCell->QueryInterface(IID_IAccessible, (void**)&iaccTableCell); + QVERIFY(SUCCEEDED(hr)); + QVERIFY(iaccTableCell); + BSTR bstrCellName; + hr = iaccTableCell->get_accName(varSELF, &bstrCellName); + QVERIFY(SUCCEEDED(hr)); + QString cellName((QChar*)bstrCellName); + QCOMPARE(cellName, QLatin1String("1.2")); + + accTableCell->Release(); + iaccTableCell->Release(); + ia2TableCell->Release(); + ia2Table->Release(); +#endif + iaccTextEdit->Release(); + } + iaccWindow->Release(); QTestAccessibility::clearEvents(); #endif From 2f6543ebcdc7b233aeb9dc018d4bf756971ad3f4 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 30 Oct 2012 16:27:48 +0200 Subject: [PATCH 124/134] Remove a couple of unused variables. Change-Id: I33528cdb27801317d311d39e4499d2db6a291377 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qguiapplication.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 6e367ebfcf8..efb34ffe9f8 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -469,7 +469,6 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) } } - QEvent e(QEvent::WindowBlocked); QWindowList windows = QGuiApplication::topLevelWindows(); for (int i = 0; i < windows.count(); ++i) { QWindow *window = windows.at(i); @@ -484,7 +483,6 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window) { self->modalWindowList.removeAll(window); - QEvent e(QEvent::WindowUnblocked); QWindowList windows = QGuiApplication::topLevelWindows(); for (int i = 0; i < windows.count(); ++i) { QWindow *window = windows.at(i); From 56552a5633d28b282c13e3641d1f9a2512dd1471 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 19 Oct 2012 12:01:03 +0200 Subject: [PATCH 125/134] Improve QDateTime test coverage. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic521d9d2ffb1b8e3b14d9cebdeb3dc7a5e08580e Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qdatetime.cpp | 3 +- .../corelib/tools/qdatetime/tst_qdatetime.cpp | 391 ++++++++++++------ 2 files changed, 264 insertions(+), 130 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 12f93359903..e463ba9c4e9 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3391,10 +3391,11 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) int year; QStringList timeParts = parts.at(3).split(QLatin1Char(':')); if ((timeParts.count() == 3) || (timeParts.count() == 2)) { + // Year is after time, e.g. "Sun Dec 1 13:02:00 1974" year = parts.at(4).toInt(&ok); if (!ok) return QDateTime(); - } else { + } else { // Year is before time, e.g. "Sun Dec 1 1974 13:02:00" timeParts = parts.at(4).split(QLatin1Char(':')); if ((timeParts.count() != 3) && (timeParts.count() != 2)) return QDateTime(); diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index fc13cba28de..8da5d2808b9 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -74,11 +74,15 @@ private slots: void toTime_t(); void daylightSavingsTimeChange(); void setDate(); + void setTime_data(); void setTime(); + void setTimeSpec_data(); void setTimeSpec(); void setTime_t(); void setMSecsSinceEpoch_data(); void setMSecsSinceEpoch(); + void fromMSecsSinceEpoch_data(); + void fromMSecsSinceEpoch(); void toString_isoDate_data(); void toString_isoDate(); void toString_enumformat(); @@ -333,57 +337,59 @@ void tst_QDateTime::setDate() QCOMPARE(dt6.timeSpec(), Qt::LocalTime); } +void tst_QDateTime::setTime_data() +{ + QTest::addColumn("dateTime"); + QTest::addColumn("newTime"); + + QTest::newRow("data0") << QDateTime(QDate(2004, 3, 25), QTime(0, 45, 57), Qt::UTC) << QTime(23, 11, 22); + QTest::newRow("data1") << QDateTime(QDate(2004, 3, 25), QTime(0, 45, 57), Qt::LocalTime) << QTime(23, 11, 22); + QTest::newRow("data2") << QDateTime(QDate(4004, 3, 25), QTime(0, 45, 57), Qt::UTC) << QTime(23, 11, 22); + QTest::newRow("data3") << QDateTime(QDate(4004, 3, 25), QTime(0, 45, 57), Qt::LocalTime) << QTime(23, 11, 22); + QTest::newRow("data4") << QDateTime(QDate(1760, 3, 25), QTime(0, 45, 57), Qt::UTC) << QTime(23, 11, 22); + QTest::newRow("data5") << QDateTime(QDate(1760, 3, 25), QTime(0, 45, 57), Qt::LocalTime) << QTime(23, 11, 22); + + QTest::newRow("set on std/dst") << QDateTime::currentDateTime() << QTime(23, 11, 22); +} + void tst_QDateTime::setTime() { - QDateTime dt1(QDate(2004, 3, 25), QTime(0, 45, 57), Qt::UTC); - dt1.setTime(QTime(23, 11, 22)); - QCOMPARE(dt1.date(), QDate(2004, 3, 25)); - QCOMPARE(dt1.time(), QTime(23, 11, 22)); - QCOMPARE(dt1.timeSpec(), Qt::UTC); + QFETCH(QDateTime, dateTime); + QFETCH(QTime, newTime); - QDateTime dt2(QDate(2004, 3, 25), QTime(0, 45, 57), Qt::LocalTime); - dt2.setTime(QTime(23, 11, 22)); - QCOMPARE(dt2.date(), QDate(2004, 3, 25)); - QCOMPARE(dt2.time(), QTime(23, 11, 22)); - QCOMPARE(dt2.timeSpec(), Qt::LocalTime); + const QDate expectedDate(dateTime.date()); + const Qt::TimeSpec expectedTimeSpec(dateTime.timeSpec()); - QDateTime dt3(QDate(4004, 3, 25), QTime(0, 45, 57), Qt::UTC); - dt3.setTime(QTime(23, 11, 22)); - QCOMPARE(dt3.date(), QDate(4004, 3, 25)); - QCOMPARE(dt3.time(), QTime(23, 11, 22)); - QCOMPARE(dt3.timeSpec(), Qt::UTC); + dateTime.setTime(newTime); - QDateTime dt4(QDate(4004, 3, 25), QTime(0, 45, 57), Qt::LocalTime); - dt4.setTime(QTime(23, 11, 22)); - QCOMPARE(dt4.date(), QDate(4004, 3, 25)); - QCOMPARE(dt4.time(), QTime(23, 11, 22)); - QCOMPARE(dt4.timeSpec(), Qt::LocalTime); + QCOMPARE(dateTime.date(), expectedDate); + QCOMPARE(dateTime.time(), newTime); + QCOMPARE(dateTime.timeSpec(), expectedTimeSpec); +} - QDateTime dt5(QDate(1760, 3, 25), QTime(0, 45, 57), Qt::UTC); - dt5.setTime(QTime(23, 11, 22)); - QCOMPARE(dt5.date(), QDate(1760, 3, 25)); - QCOMPARE(dt5.time(), QTime(23, 11, 22)); - QCOMPARE(dt5.timeSpec(), Qt::UTC); +void tst_QDateTime::setTimeSpec_data() +{ + QTest::addColumn("dateTime"); + QTest::addColumn("newTimeSpec"); - QDateTime dt6(QDate(1760, 3, 25), QTime(0, 45, 57), Qt::LocalTime); - dt6.setTime(QTime(23, 11, 22)); - QCOMPARE(dt6.date(), QDate(1760, 3, 25)); - QCOMPARE(dt6.time(), QTime(23, 11, 22)); - QCOMPARE(dt6.timeSpec(), Qt::LocalTime); + QTest::newRow("UTC => UTC") << QDateTime(QDate(2004, 3, 25), QTime(0, 45, 57), Qt::UTC) << Qt::UTC; + QTest::newRow("UTC => LocalTime") << QDateTime(QDate(2004, 3, 25), QTime(0, 45, 57), Qt::UTC) << Qt::LocalTime; + QTest::newRow("UTC => OffsetFromUTC") << QDateTime(QDate(2004, 3, 25), QTime(0, 45, 57), Qt::UTC) << Qt::OffsetFromUTC; } void tst_QDateTime::setTimeSpec() { - QDateTime dt1(QDate(2004, 3, 25), QTime(0, 45, 57), Qt::UTC); - dt1.setTimeSpec(Qt::UTC); - QCOMPARE(dt1.date(), QDate(2004, 3, 25)); - QCOMPARE(dt1.time(), QTime(0, 45, 57)); - QCOMPARE(dt1.timeSpec(), Qt::UTC); + QFETCH(QDateTime, dateTime); + QFETCH(Qt::TimeSpec, newTimeSpec); - dt1.setTimeSpec(Qt::LocalTime); - QCOMPARE(dt1.date(), QDate(2004, 3, 25)); - QCOMPARE(dt1.time(), QTime(0, 45, 57)); - QCOMPARE(dt1.timeSpec(), Qt::LocalTime); + const QDate expectedDate(dateTime.date()); + const QTime expectedTime(dateTime.time()); + + dateTime.setTimeSpec(newTimeSpec); + + QCOMPARE(dateTime.date(), expectedDate); + QCOMPARE(dateTime.time(), expectedTime); + QCOMPARE(dateTime.timeSpec(), newTimeSpec); } void tst_QDateTime::setTime_t() @@ -482,6 +488,13 @@ void tst_QDateTime::setMSecsSinceEpoch() QCOMPARE(dt, utc); if (europeanTimeZone) { QCOMPARE(dt.toLocalTime(), european); + + // Test converting from LocalTime to UTC back to LocalTime. + QDateTime localDt; + localDt.setTimeSpec(Qt::LocalTime); + localDt.setMSecsSinceEpoch(msecs); + + QCOMPARE(localDt, utc); } QCOMPARE(dt.toMSecsSinceEpoch(), msecs); @@ -494,6 +507,33 @@ void tst_QDateTime::setMSecsSinceEpoch() QCOMPARE(dt, reference.addMSecs(msecs)); } +void tst_QDateTime::fromMSecsSinceEpoch_data() +{ + setMSecsSinceEpoch_data(); +} + +void tst_QDateTime::fromMSecsSinceEpoch() +{ + QFETCH(qint64, msecs); + QFETCH(QDateTime, utc); + QFETCH(QDateTime, european); + + QDateTime dt(QDateTime::fromMSecsSinceEpoch(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_isoDate_data() { QTest::addColumn("dt"); @@ -514,6 +554,9 @@ void tst_QDateTime::toString_isoDate_data() QTest::newRow("negative OffsetFromUTC") << dt << QString("1978-11-09T13:28:34-02:00"); + QTest::newRow("invalid") + << QDateTime(QDate(-1, 11, 9), QTime(13, 28, 34), Qt::UTC) + << QString(); } void tst_QDateTime::toString_isoDate() @@ -1209,6 +1252,9 @@ void tst_QDateTime::operator_eqeq_data() QTest::newRow("data11") << dateTime3 << dateTime3d << true << false; QTest::newRow("data12") << dateTime3c << dateTime3d << true << false; QTest::newRow("data13") << dateTime3 << dateTime3e << false << false; + QTest::newRow("invalid == invalid") << invalidDateTime() << invalidDateTime() << true << false; + QTest::newRow("invalid == valid #1") << invalidDateTime() << dateTime1 << false << false; + if (europeanTimeZone) { QTest::newRow("data14") << QDateTime(QDate(2004, 1, 2), QTime(2, 2, 3), Qt::LocalTime) << QDateTime(QDate(2004, 1, 2), QTime(1, 2, 3), Qt::UTC) << true << true; @@ -1248,11 +1294,14 @@ void tst_QDateTime::operator_eqeq() } #ifndef Q_OS_WINCE +Q_DECLARE_METATYPE(QDataStream::Version) + void tst_QDateTime::operator_insert_extract_data() { QTest::addColumn("dateTime"); QTest::addColumn("serialiseAs"); QTest::addColumn("deserialiseAs"); + QTest::addColumn("dataStreamVersion"); const QDateTime positiveYear(QDateTime(QDate(2012, 8, 14), QTime(8, 0, 0), Qt::LocalTime)); const QDateTime negativeYear(QDateTime(QDate(-2012, 8, 14), QTime(8, 0, 0), Qt::LocalTime)); @@ -1260,14 +1309,19 @@ void tst_QDateTime::operator_insert_extract_data() const QString westernAustralia(QString::fromLatin1("AWST-8AWDT-9,M10.5.0,M3.5.0/03:00:00")); const QString hawaii(QString::fromLatin1("HAW10")); - QTest::newRow("14/08/2012 08:00 WA => HAWAII") << positiveYear << westernAustralia << hawaii; - QTest::newRow("14/08/2012 08:00 WA => HAWAII") << positiveYear << westernAustralia << hawaii; - QTest::newRow("14/08/2012 08:00 WA => HAWAII") << positiveYear << westernAustralia << hawaii; - QTest::newRow("14/08/2012 08:00 WA => WA") << positiveYear << westernAustralia << westernAustralia; - QTest::newRow("14/08/-2012 08:00 HAWAII => WA") << negativeYear << hawaii << westernAustralia; - QTest::newRow("14/08/-2012 08:00 HAWAII => WA") << negativeYear << hawaii << westernAustralia; - QTest::newRow("14/08/-2012 08:00 HAWAII => WA") << negativeYear << hawaii << westernAustralia; - QTest::newRow("14/08/2012 08:00 HAWAII => HAWAII") << positiveYear << hawaii << hawaii; + const QDataStream tmpDataStream; + const int thisVersion = tmpDataStream.version(); + for (int version = QDataStream::Qt_1_0; version <= thisVersion; ++version) { + const QDataStream::Version dataStreamVersion = static_cast(version); + QTest::newRow(QString::fromLatin1("v%1 WA => HAWAII %2").arg(dataStreamVersion).arg(positiveYear.toString()).toLocal8Bit().constData()) + << positiveYear << westernAustralia << hawaii << dataStreamVersion; + QTest::newRow(QString::fromLatin1("v%1 WA => WA %2").arg(dataStreamVersion).arg(positiveYear.toString()).toLocal8Bit().constData()) + << positiveYear << westernAustralia << westernAustralia << dataStreamVersion; + QTest::newRow(QString::fromLatin1("v%1 HAWAII => WA %2").arg(dataStreamVersion).arg(negativeYear.toString()).toLocal8Bit().constData()) + << negativeYear << hawaii << westernAustralia << dataStreamVersion; + QTest::newRow(QString::fromLatin1("v%1 HAWAII => HAWAII %2").arg(dataStreamVersion).arg(positiveYear.toString()).toLocal8Bit().constData()) + << positiveYear << hawaii << hawaii << dataStreamVersion; + } } void tst_QDateTime::operator_insert_extract() @@ -1275,8 +1329,11 @@ void tst_QDateTime::operator_insert_extract() QFETCH(QDateTime, dateTime); QFETCH(QString, serialiseAs); QFETCH(QString, deserialiseAs); + QFETCH(QDataStream::Version, dataStreamVersion); + // Save the previous timezone so we can restore it afterwards, just in case. QString previousTimeZone = qgetenv("TZ"); + // Start off in a certain timezone. qputenv("TZ", serialiseAs.toLocal8Bit().constData()); tzset(); QDateTime dateTimeAsUTC(dateTime.toUTC()); @@ -1284,8 +1341,15 @@ void tst_QDateTime::operator_insert_extract() QByteArray byteArray; { QDataStream dataStream(&byteArray, QIODevice::WriteOnly); - dataStream << dateTime; - dataStream << dateTime; + dataStream.setVersion(dataStreamVersion); + if (dataStreamVersion >= QDataStream::Qt_5_0) { + // Qt 5 serialises as UTC and converts back to the stored timeSpec when + // deserialising; we don't need to do it ourselves... + dataStream << dateTime << dateTime; + } else { + // ... but lower versions don't, so we have to here. + dataStream << dateTimeAsUTC << dateTimeAsUTC; + } } // Ensure that a change in timezone between serialisation and deserialisation @@ -1296,11 +1360,26 @@ void tst_QDateTime::operator_insert_extract() { // Deserialise whole QDateTime at once. QDataStream dataStream(&byteArray, QIODevice::ReadOnly); + dataStream.setVersion(dataStreamVersion); QDateTime deserialised; dataStream >> deserialised; - // Ensure local time is still correct. - QCOMPARE(deserialised, expectedLocalTime); - // Sanity check UTC times. + + if (dataStreamVersion >= QDataStream::Qt_5_0) { + // Ensure local time is still correct. Again, Qt 5 handles the timeSpec + // conversion (in this case, UTC => LocalTime) for us when deserialising. + QCOMPARE(deserialised, expectedLocalTime); + } else { + if (dataStreamVersion < QDataStream::Qt_4_0) { + // Versions lower than Qt 4 don't serialise the timeSpec, instead + // assuming that everything is LocalTime. + deserialised.setTimeSpec(Qt::UTC); + } + // Qt 4.* versions do serialise the timeSpec, so we only need to convert from UTC here. + deserialised = deserialised.toLocalTime(); + + QCOMPARE(deserialised, expectedLocalTime); + } + // Sanity check UTC times (operator== already converts its operands to UTC before comparing). QCOMPARE(deserialised.toUTC(), expectedLocalTime.toUTC()); // Deserialise each component individually. @@ -1309,9 +1388,11 @@ void tst_QDateTime::operator_insert_extract() QTime deserialisedTime; dataStream >> deserialisedTime; qint8 deserialisedSpec; - dataStream >> deserialisedSpec; + if (dataStreamVersion >= QDataStream::Qt_4_0) + dataStream >> deserialisedSpec; deserialised = QDateTime(deserialisedDate, deserialisedTime, Qt::UTC); - deserialised = deserialised.toTimeSpec(static_cast(deserialisedSpec)); + if (dataStreamVersion >= QDataStream::Qt_4_0) + deserialised = deserialised.toTimeSpec(static_cast(deserialisedSpec)); // Ensure local time is still correct. QCOMPARE(deserialised, expectedLocalTime); // Sanity check UTC times. @@ -1363,6 +1444,22 @@ void tst_QDateTime::toString_strformat_data() << QString("hhhhhaA") << QString("03033aA"); QTest::newRow( "OK A, bad P" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) << QString("hhAX") << QString("00AX"); + QTest::newRow( "single, 0 => 12 AM" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) + << QString("hAP") << QString("12AM"); + QTest::newRow( "double, 0 => 12 AM" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) + << QString("hhAP") << QString("12AM"); + QTest::newRow( "double, garbage" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) + << QString("hhAX") << QString("00AX"); + QTest::newRow( "dddd" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) + << QString("dddd") << QString("Friday"); + QTest::newRow( "ddd" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) + << QString("ddd") << QString("Fri"); + QTest::newRow( "MMMM" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) + << QString("MMMM") << QString("December"); + QTest::newRow( "MMM" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) + << QString("MMM") << QString("Dec"); + QTest::newRow( "emtpy" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999)) + << QString("") << QString(""); } void tst_QDateTime::toString_strformat() @@ -1378,126 +1475,164 @@ void tst_QDateTime::fromStringDateFormat_data() QTest::addColumn("dateTimeStr"); QTest::addColumn("dateFormat"); QTest::addColumn("expected"); - QTest::addColumn("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; + << 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; + << 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; + << 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; + << 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; + << Qt::TextDate << QDateTime(QDate(-4712, 1, 1), QTime(0, 1, 2, 0), Qt::LocalTime); + QTest::newRow("text 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("text data1") << QString::fromLatin1("Thu Jan 2 12:34 1970") + << Qt::TextDate << QDateTime(QDate(1970, 1, 2), QTime(12, 34, 0), Qt::LocalTime); + QTest::newRow("text data2") << QString::fromLatin1("Thu Jan 1 00 1970") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text data3") << QString::fromLatin1("Thu Jan 1 00:00:00:00 1970") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text data4") << QString::fromLatin1("Thu 1. Jan 00:00:00 1970") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 0), Qt::LocalTime); + QTest::newRow("text 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("text data6") << QString::fromLatin1("Thu Jan 1 00:00:00") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text 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("text data8") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT+foo") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text 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("text 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("text 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("text 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("text 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); + QTest::newRow("text empty") << QString::fromLatin1("") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text too many parts") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 gmt +0100") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid month name") << QString::fromLatin1("Thu Jaz 1 1970 00:12:34") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid date") << QString::fromLatin1("Thu Jan 32 1970 00:12:34") + << Qt::TextDate << QDateTime(invalidDate(), QTime(0, 12, 34), Qt::LocalTime); + QTest::newRow("text invalid day #1") << QString::fromLatin1("Thu Jan XX 1970 00:12:34") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid day #2") << QString::fromLatin1("Thu X. Jan 00:00:00 1970") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid day #3") << QString::fromLatin1("Thu 1 Jan 00:00:00 1970") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid year #1") << QString::fromLatin1("Thu 1. Jan 00:00:00 19X0") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid year #2") << QString::fromLatin1("Thu 1. Jan 19X0 00:00:00") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid hour") << QString::fromLatin1("Thu 1. Jan 1970 0X:00:00") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid minute") << QString::fromLatin1("Thu 1. Jan 1970 00:0X:00") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid second") << QString::fromLatin1("Thu 1. Jan 1970 00:00:0X") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid gmt specifier #1") << QString::fromLatin1("Thu 1. Jan 1970 00:00:00 DMT") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid gmt specifier #2") << QString::fromLatin1("Thu 1. Jan 1970 00:00:00 GMTx0200") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid gmt hour") << QString::fromLatin1("Thu 1. Jan 1970 00:00:00 GMT+0X00") + << Qt::TextDate << invalidDateTime(); + QTest::newRow("text invalid gmt minute") << QString::fromLatin1("Thu 1. Jan 1970 00:00:00 GMT+000X") + << Qt::TextDate << invalidDateTime(); // 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; + QTest::newRow("ISO +01:00") << QString::fromLatin1("1987-02-13T13:24:51+01:00") + << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51), Qt::UTC); + QTest::newRow("ISO -01:00") << QString::fromLatin1("1987-02-13T13:24:51-01:00") + << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51), Qt::UTC); + // Not sure about these two... it will currently be created as LocalTime, but it + // should probably be UTC according to the ISO 8601 spec (see 4.2.5.1). + QTest::newRow("ISO +0000") << QString::fromLatin1("1970-01-01T00:12:34+0000") + << Qt::ISODate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::LocalTime); + QTest::newRow("ISO +00:00") << QString::fromLatin1("1970-01-01T00:12:34+00:00") + << Qt::ISODate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::LocalTime); // 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 data3") << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << Qt::ISODate << invalidDateTime(); QTest::newRow("ISO invalid character both ends") << QString::fromLatin1("!2012-01-01T08:00:00!") - << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + << Qt::ISODate << invalidDateTime(); QTest::newRow("ISO invalid character at front, 2 at back") << QString::fromLatin1("!2012-01-01T08:00:00..") - << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + << Qt::ISODate << invalidDateTime(); QTest::newRow("ISO invalid character 2 at front") << QString::fromLatin1("!!2012-01-01T08:00:00") - << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + << Qt::ISODate << invalidDateTime(); // 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; + << 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; + << 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; + << 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; + << 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; + << 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; + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 59, 999), Qt::LocalTime); + QTest::newRow("ISO empty") << QString::fromLatin1("") << Qt::ISODate << invalidDateTime(); } void tst_QDateTime::fromStringDateFormat() @@ -1505,10 +1640,8 @@ 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); } From 774b643b850d770f16d04856aa613ebf394f913b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 23 Oct 2012 15:06:11 +0200 Subject: [PATCH 126/134] Update QDateTime serialisation docs and increase version number. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refer to Qt::TimeSpec instead of listing potential values (which are incomplete). Also, the current QDataStream version number is now 13. Change-Id: I9a68385977dc2fe4dacee75330cb539850478480 Reviewed-by: Jędrzej Nowacki Reviewed-by: Jerome Pasion Reviewed-by: Nico Vertriest --- src/corelib/doc/src/datastreamformat.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc index 8c3b5922766..e2c3f9bae18 100644 --- a/src/corelib/doc/src/datastreamformat.qdoc +++ b/src/corelib/doc/src/datastreamformat.qdoc @@ -33,7 +33,7 @@ The \l QDataStream allows you to serialize some of the Qt data types. The table below lists the data types that QDataStream can serialize and how they are represented. The format described below is - \l{QDataStream::setVersion()}{version 12}. + \l{QDataStream::setVersion()}{version 13}. It is always best to cast integers to a Qt integer type, such as qint16 or quint32, when reading and writing. This ensures that @@ -129,7 +129,7 @@ \li \list \li Date (QDate) \li Time (QTime) - \li 0 for Qt::LocalTime, 1 for Qt::UTC (quint8) + \li The \l{Qt::TimeSpec}{time spec} (quint8) \endlist \row \li QEasingCurve \li \list From f01b498310ea7c05ec73669b34cb83b9f159006f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 1 Nov 2012 17:03:45 +0100 Subject: [PATCH 127/134] Introduced QWindow properties {min/max}imum{Width/Height} These are useful when QWindow is exposed to QML. Change-Id: I7ec49ef365183e2c784605889e8ea22c2ef34781 Reviewed-by: Jens Bache-Wiig --- src/gui/kernel/qwindow.cpp | 50 +++++++++++++++++ src/gui/kernel/qwindow.h | 19 +++++++ src/gui/kernel/qwindow_p.h | 1 + tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 53 +++++++++++++++++++ 4 files changed, 123 insertions(+) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index a17270912f0..d845be3d016 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -941,9 +941,24 @@ void QWindow::setMinimumSize(const QSize &size) QSize adjustedSize = QSize(qBound(0, size.width(), QWINDOWSIZE_MAX), qBound(0, size.height(), QWINDOWSIZE_MAX)); if (d->minimumSize == adjustedSize) return; + QSize oldSize = d->minimumSize; d->minimumSize = adjustedSize; if (d->platformWindow && isTopLevel()) d->platformWindow->propagateSizeHints(); + if (d->minimumSize.width() != oldSize.width()) + emit minimumWidthChanged(d->minimumSize.width()); + if (d->minimumSize.height() != oldSize.height()) + emit minimumHeightChanged(d->minimumSize.height()); +} + +void QWindow::setMinimumWidth(int w) +{ + setMinimumSize(QSize(w, minimumHeight())); +} + +void QWindow::setMinimumHeight(int h) +{ + setMinimumSize(QSize(minimumWidth(), h)); } /*! @@ -959,9 +974,24 @@ void QWindow::setMaximumSize(const QSize &size) QSize adjustedSize = QSize(qBound(0, size.width(), QWINDOWSIZE_MAX), qBound(0, size.height(), QWINDOWSIZE_MAX)); if (d->maximumSize == adjustedSize) return; + QSize oldSize = d->maximumSize; d->maximumSize = adjustedSize; if (d->platformWindow && isTopLevel()) d->platformWindow->propagateSizeHints(); + if (d->maximumSize.width() != oldSize.width()) + emit maximumWidthChanged(d->maximumSize.width()); + if (d->maximumSize.height() != oldSize.height()) + emit maximumHeightChanged(d->maximumSize.height()); +} + +void QWindow::setMaximumWidth(int w) +{ + setMaximumSize(QSize(w, maximumHeight())); +} + +void QWindow::setMaximumHeight(int h) +{ + setMaximumSize(QSize(maximumWidth(), h)); } /*! @@ -1059,6 +1089,26 @@ void QWindow::setGeometry(const QRect &rect) \brief the height of the window's geometry */ +/*! + \property QWindow::minimumWidth + \brief the minimum width of the window's geometry +*/ + +/*! + \property QWindow::minimumHeight + \brief the minimum height of the window's geometry +*/ + +/*! + \property QWindow::maximumWidth + \brief the maximum width of the window's geometry +*/ + +/*! + \property QWindow::maximumHeight + \brief the maximum height of the window's geometry +*/ + /*! Returns the geometry of the window, excluding its window frame. diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 62268cd88a4..4832adfb634 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -104,6 +104,10 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface Q_PROPERTY(QPoint pos READ pos WRITE setPos) Q_PROPERTY(QSize size READ size WRITE resize) Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry) + Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) + Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged) + Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged) + Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged) #ifndef QT_NO_CURSOR @@ -170,6 +174,11 @@ public: bool isExposed() const; + int minimumWidth() const { return minimumSize().width(); } + int minimumHeight() const { return minimumSize().height(); } + int maximumWidth() const { return maximumSize().width(); } + int maximumHeight() const { return maximumSize().height(); } + QSize minimumSize() const; QSize maximumSize() const; QSize baseSize() const; @@ -273,6 +282,11 @@ public Q_SLOTS: setGeometry(QRect(x(), y(), width(), arg)); } + void setMinimumWidth(int w); + void setMinimumHeight(int h); + void setMaximumWidth(int w); + void setMaximumHeight(int h); + Q_SIGNALS: void screenChanged(QScreen *screen); void windowModalityChanged(Qt::WindowModality windowModality); @@ -283,6 +297,11 @@ Q_SIGNALS: void widthChanged(int arg); void heightChanged(int arg); + void minimumWidthChanged(int arg); + void minimumHeightChanged(int arg); + void maximumWidthChanged(int arg); + void maximumHeightChanged(int arg); + void visibleChanged(bool arg); void contentOrientationChanged(Qt::ScreenOrientation orientation); diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 159f05d1a52..bce6a4ff04a 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -80,6 +80,7 @@ public: , positionPolicy(WindowFrameExclusive) , contentOrientation(Qt::PrimaryOrientation) , windowOrientation(Qt::PrimaryOrientation) + , minimumSize(0, 0) , maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX) , modality(Qt::NonModal) , blockedByModalWindow(false) diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 84ba1f4fdf1..f85e48022a6 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -67,6 +67,7 @@ private slots: void touchCancel(); void touchCancelWithTouchToMouse(); void orientation(); + void sizes(); void close(); void activateAndClose(); void mouseEventSequence(); @@ -739,6 +740,58 @@ void tst_QWindow::orientation() QCOMPARE(spy.count(), 1); } +void tst_QWindow::sizes() +{ + QWindow window; + + QSignalSpy minimumWidthSpy(&window, SIGNAL(minimumWidthChanged(int))); + QSignalSpy minimumHeightSpy(&window, SIGNAL(minimumHeightChanged(int))); + QSignalSpy maximumWidthSpy(&window, SIGNAL(maximumWidthChanged(int))); + QSignalSpy maximumHeightSpy(&window, SIGNAL(maximumHeightChanged(int))); + + QSize oldMaximum = window.maximumSize(); + + window.setMinimumWidth(10); + QCOMPARE(window.minimumWidth(), 10); + QCOMPARE(window.minimumHeight(), 0); + QCOMPARE(window.minimumSize(), QSize(10, 0)); + QCOMPARE(window.maximumSize(), oldMaximum); + QCOMPARE(minimumWidthSpy.count(), 1); + QCOMPARE(minimumHeightSpy.count(), 0); + QCOMPARE(maximumWidthSpy.count(), 0); + QCOMPARE(maximumHeightSpy.count(), 0); + + window.setMinimumHeight(10); + QCOMPARE(window.minimumWidth(), 10); + QCOMPARE(window.minimumHeight(), 10); + QCOMPARE(window.minimumSize(), QSize(10, 10)); + QCOMPARE(window.maximumSize(), oldMaximum); + QCOMPARE(minimumWidthSpy.count(), 1); + QCOMPARE(minimumHeightSpy.count(), 1); + QCOMPARE(maximumWidthSpy.count(), 0); + QCOMPARE(maximumHeightSpy.count(), 0); + + window.setMaximumWidth(100); + QCOMPARE(window.maximumWidth(), 100); + QCOMPARE(window.maximumHeight(), oldMaximum.height()); + QCOMPARE(window.minimumSize(), QSize(10, 10)); + QCOMPARE(window.maximumSize(), QSize(100, oldMaximum.height())); + QCOMPARE(minimumWidthSpy.count(), 1); + QCOMPARE(minimumHeightSpy.count(), 1); + QCOMPARE(maximumWidthSpy.count(), 1); + QCOMPARE(maximumHeightSpy.count(), 0); + + window.setMaximumHeight(100); + QCOMPARE(window.maximumWidth(), 100); + QCOMPARE(window.maximumHeight(), 100); + QCOMPARE(window.minimumSize(), QSize(10, 10)); + QCOMPARE(window.maximumSize(), QSize(100, 100)); + QCOMPARE(minimumWidthSpy.count(), 1); + QCOMPARE(minimumHeightSpy.count(), 1); + QCOMPARE(maximumWidthSpy.count(), 1); + QCOMPARE(maximumHeightSpy.count(), 1); +} + void tst_QWindow::close() { QWindow a; From 53e6cb3ff676f91a51d55e5740c7174f0c15e390 Mon Sep 17 00:00:00 2001 From: Jon Severinsson Date: Mon, 8 Oct 2012 06:46:28 +0200 Subject: [PATCH 128/134] Fix the gregorian date <-> julian day calculations in QDate The old code is just plain wrong for negative julian days. Replaced with plain math from The Calendar FAQ [1], which is correct for all julian days, provided you use mathematical integer division (round to negative infinity) rather than c++11 integer division (round to zero). [1] http://www.tondering.dk/claus/cal/julperiod.php While the conversion code works for up to around JD +/- (2^63/4), we only use an int for the year in the API, so this patch limits minJd() and maxJd() to 1 Jan (2^31) BC and 31 Dec (2^31-1) AD, respectively. Note that while the new conversion code looks like it would be more expensive than the old, gcc will in fact be able to optimize it to be slightly faster (probably because x86 hardware implements round to negative infinity, and so GCC manages to optimize floordiv to a single instruction, compared to the three instuctions needed for operator/). In the following test application, run with a release mode Qt and redirecting stderr to /dev/null, I measured an improvement from 6.81s +/- 0.08s to 6.26s +/- 0.16s user time over five runs on an otherwise idle x86_64 system. int main(int, char *[]) { int year, month, day; qint64 jd; for (qint64 i = Q_INT64_C(-1048576) ; i < Q_INT64_C(1048576); ++i) { QDate::fromJulianDay(i).getDate(&year, &month, &day); jd = QDate(year, month, day).toJulianDay(); qDebug() << jd << year << month << day; } } Change-Id: Ifd0dd01f0027f260401f7f9b4f1201d2b7a3b087 Reviewed-by: David Faure (KDE) Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/tools/qdatetime.cpp | 106 ++++++++++--------- src/corelib/tools/qdatetime.h | 4 +- tests/auto/corelib/tools/qdate/tst_qdate.cpp | 34 ++++-- 3 files changed, 79 insertions(+), 65 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index e463ba9c4e9..56dc0fade96 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -93,47 +93,67 @@ static inline QDate fixedDate(int y, int m, int d) return result; } -static inline qint64 julianDayFromDate(qint64 year, int month, int day) +static inline qint64 floordiv(qint64 a, qint64 b) { - // Gregorian calendar - // Algorithm from Henry F. Fliegel and Thomas C. Van Flandern + return (a - (a < 0 ? b-1 : 0)) / b; +} +static inline qint64 floordiv(qint64 a, int b) +{ + return (a - (a < 0 ? b-1 : 0)) / b; +} + +static inline int floordiv(int a, int b) +{ + return (a - (a < 0 ? b-1 : 0)) / b; +} + +static inline qint64 julianDayFromDate(int year, int month, int day) +{ + // Adjust for no year 0 if (year < 0) ++year; - return (1461 * (year + 4800 + (month - 14) / 12)) / 4 - + (367 * (month - 2 - 12 * ((month - 14) / 12))) / 12 - - (3 * ((year + 4900 + (month - 14) / 12) / 100)) / 4 - + day - 32075; +/* + * Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php + * This formula is correct for all julian days, when using mathematical integer + * division (round to negative infinity), not c++11 integer division (round to zero) + */ + int a = floordiv(14 - month, 12); + qint64 y = (qint64)year + 4800 - a; + int m = month + 12 * a - 3; + return day + floordiv(153 * m + 2, 5) + 365 * y + floordiv(y, 4) - floordiv(y, 100) + floordiv(y, 400) - 32045; } -static void getDateFromJulianDay(qint64 julianDay, int *year, int *month, int *day) +static void getDateFromJulianDay(qint64 julianDay, int *yearp, int *monthp, int *dayp) { - int y, m, d; +/* + * Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php + * This formula is correct for all julian days, when using mathematical integer + * division (round to negative infinity), not c++11 integer division (round to zero) + */ + qint64 a = julianDay + 32044; + qint64 b = floordiv(4 * a + 3, 146097); + int c = a - floordiv(146097 * b, 4); - // Gregorian calendar - // This algorithm is from Henry F. Fliegel and Thomas C. Van Flandern - qint64 ell, n, i, j; //TODO These will need to be bigger to prevent overflow!!! - ell = julianDay + 68569; - n = (4 * ell) / 146097; - ell = ell - (146097 * n + 3) / 4; - i = (4000 * (ell + 1)) / 1461001; - ell = ell - (1461 * i) / 4 + 31; - j = (80 * ell) / 2447; - d = ell - (2447 * j) / 80; - ell = j / 11; - m = j + 2 - (12 * ell); - y = 100 * (n - 49) + i + ell; + int d = floordiv(4 * c + 3, 1461); + int e = c - floordiv(1461 * d, 4); + int m = floordiv(5 * e + 2, 153); - if (y<= 0) - --y; + int day = e - floordiv(153 * m + 2, 5) + 1; + int month = m + 3 - 12 * floordiv(m, 10); + int year = 100 * b + d - 4800 + floordiv(m, 10); - if (year) - *year = y; - if (month) - *month = m; - if (day) - *day = d; + // Adjust for no year 0 + if (year <= 0) + --year ; + + if (yearp) + *yearp = year; + if (monthp) + *monthp = month; + if (dayp) + *dayp = day; } @@ -225,14 +245,8 @@ static QString fmtDateTime(const QString& f, const QTime* dt = 0, const QDate* d QDate::toJulianDay() and can be set using QDate::fromJulianDay(). The range of dates able to be stored by QDate as a Julian Day number is - limited for convenience from std::numeric_limits::min() / 2 to - std::numeric_limits::max() / 2, which on most platforms means - from around 2.5 quadrillion BCE to around 2.5 quadrillion CE, effectively - covering the full range of astronomical time. The range of Julian Days - able to be accurately converted to and from valid YMD form Dates is - restricted to 1 January 4800 BCE to 31 December 1400000 CE due to - shortcomings in the available conversion formulas. Conversions outside this - range are not guaranteed to be correct. This may change in the future. + for technical reasons limited to between -784350574879 and 784354017364, + which means from before 2 billion BCE to after 2 billion CE. \sa QTime, QDateTime, QDateEdit, QDateTimeEdit, QCalendarWidget */ @@ -859,9 +873,6 @@ QString QDate::toString(const QString& format) const If the specified date is invalid, the QDate object is set to be invalid. - Note that any date before 4800 BCE or after about 1.4 million CE - may not be accurately stored. - \sa isValid() */ bool QDate::setDate(int year, int month, int day) @@ -882,9 +893,6 @@ bool QDate::setDate(int year, int month, int day) Returns 0 if the date is invalid. - Note that any date before 4800 BCE or after about 1.4 million CE - may not be accurately stored. - \sa year(), month(), day(), isValid() */ void QDate::getDate(int *year, int *month, int *day) @@ -2100,14 +2108,8 @@ int QTime::elapsed() const QDate::toJulianDay() and can be set using QDate::fromJulianDay(). The range of dates able to be stored by QDate as a Julian Day number is - limited for convenience from std::numeric_limits::min() / 2 to - std::numeric_limits::max() / 2, which on most platforms means - from around 2.5 quadrillion BCE to around 2.5 quadrillion CE, effectively - covering the full range of astronomical time. The range of Julian Days - able to be accurately converted to and from valid YMD form Dates is - restricted to 1 January 4800 BCE to 31 December 1400000 CE due to - shortcomings in the available conversion formulas. Conversions outside this - range are not guaranteed to be correct. This may change in the future. + for technical reasons limited to between -784350574879 and 784354017364, + which means from before 2 billion BCE to after 2 billion CE. \section2 Use of System Timezone diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index ed7d8adb5f9..22db5a48300 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -121,8 +121,8 @@ QT_DEPRECATED inline bool setYMD(int y, int m, int d) private: static inline qint64 nullJd() { return std::numeric_limits::min(); } - static inline qint64 minJd() { return std::numeric_limits::min() / 2; } - static inline qint64 maxJd() { return (std::numeric_limits::max()) / 2; } + static inline qint64 minJd() { return Q_INT64_C(-784350574879); } + static inline qint64 maxJd() { return Q_INT64_C( 784354017364); } qint64 jd; diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp index 01805e12710..9978a252bf0 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp @@ -117,8 +117,8 @@ void tst_QDate::isNull_data() QTest::addColumn("jd"); QTest::addColumn("null"); - qint64 minJd = std::numeric_limits::min() / 2; - qint64 maxJd = std::numeric_limits::max() / 2; + qint64 minJd = Q_INT64_C(-784350574879); + qint64 maxJd = Q_INT64_C( 784354017364); QTest::newRow("qint64 min") << std::numeric_limits::min() << true; QTest::newRow("minJd - 1") << minJd - 1 << true; @@ -448,8 +448,8 @@ void tst_QDate::julianDaysLimits() { qint64 min = std::numeric_limits::min(); qint64 max = std::numeric_limits::max(); - qint64 minJd = std::numeric_limits::min() / 2; - qint64 maxJd = std::numeric_limits::max() / 2; + qint64 minJd = Q_INT64_C(-784350574879); + qint64 maxJd = Q_INT64_C( 784354017364); QDate maxDate = QDate::fromJulianDay(maxJd); QDate minDate = QDate::fromJulianDay(minJd); @@ -492,7 +492,7 @@ void tst_QDate::julianDaysLimits() dt = minDate.addDays(min); QCOMPARE(dt.isValid(), false); dt = minDate.addDays(max); - QCOMPARE(dt.isValid(), true); + QCOMPARE(dt.isValid(), false); dt = zeroDate.addDays(-1); QCOMPARE(dt.isValid(), true); @@ -664,8 +664,8 @@ void tst_QDate::addYears_data() void tst_QDate::daysTo() { - qint64 minJd = std::numeric_limits::min() / 2; - qint64 maxJd = std::numeric_limits::max() / 2; + qint64 minJd = Q_INT64_C(-784350574879); + qint64 maxJd = Q_INT64_C( 784354017364); QDate dt1(2000, 1, 1); QDate dt2(2000, 1, 5); @@ -1356,9 +1356,10 @@ void tst_QDate::roundtrip() const // year(), month(), day(), julianDayFromDate(), and getDateFromJulianDay() // to ensure they are internally consistent (but doesn't guarantee correct) - // Test Julian round trip around JD 0 and current low end of valid range + // Test Julian round trip around JD 0 and the c++ integer division rounding + // problem point (eg. negative numbers) in the conversion functions. QDate testDate; - QDate loopDate = QDate::fromJulianDay(-31738); // 1 Jan 4800 BC + QDate loopDate = QDate::fromJulianDay(-50001); // 1 Jan 4850 BC while (loopDate.toJulianDay() <= 5150) { // 31 Dec 4700 BC testDate.setDate(loopDate.year(), loopDate.month(), loopDate.day()); QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); @@ -1389,9 +1390,20 @@ void tst_QDate::roundtrip() const loopDate = loopDate.addDays(1); } + qint64 minJd = Q_INT64_C(-784350574879); + qint64 maxJd = Q_INT64_C( 784354017364); + // Test Gregorian round trip at top end of conversion range - loopDate = QDate::fromJulianDay(513024036); // 1 Jan 1399900 AD - while (loopDate.toJulianDay() <= 513060925) { // 31 Dec 1400000 AD + loopDate = QDate::fromJulianDay(maxJd); + while (loopDate.toJulianDay() >= maxJd - 146397) { + testDate.setDate(loopDate.year(), loopDate.month(), loopDate.day()); + QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); + loopDate = loopDate.addDays(-1); + } + + // Test Gregorian round trip at low end of conversion range + loopDate = QDate::fromJulianDay(minJd); + while (loopDate.toJulianDay() <= minJd + 146397) { testDate.setDate(loopDate.year(), loopDate.month(), loopDate.day()); QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); loopDate = loopDate.addDays(1); From a4aa5ea63fc9f6fa3d1d54398a297d89e7342342 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 26 Oct 2012 10:58:21 +0200 Subject: [PATCH 129/134] Use fusion instead of motif. Change-Id: Ic75ea959ac825efabf0f3a8606dfca4b65fae474 Reviewed-by: Jens Bache-Wiig --- .../doc/snippets/qprocess/qprocess-simpleexecution.cpp | 2 +- src/corelib/io/qprocess.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/doc/snippets/qprocess/qprocess-simpleexecution.cpp b/src/corelib/doc/snippets/qprocess/qprocess-simpleexecution.cpp index e7c1c36e9d6..8181cb04dd7 100644 --- a/src/corelib/doc/snippets/qprocess/qprocess-simpleexecution.cpp +++ b/src/corelib/doc/snippets/qprocess/qprocess-simpleexecution.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) //! [2] QStringList arguments; - arguments << "-style" << "motif"; + arguments << "-style" << "fusion"; QProcess *myProcess = new QProcess(parent); myProcess->start(program, arguments); diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 395effaff9c..c52053000d8 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -458,8 +458,8 @@ void QProcessPrivate::Channel::clear() are supplied as individual strings in a QStringList. For example, the following code snippet runs the analog clock - example in the Motif style on X11 platforms by passing strings - containing "-style" and "motif" as two items in the list of + example in the Fusion style on X11 platforms by passing strings + containing "-style" and "fusion" as two items in the list of arguments: \snippet qprocess/qprocess-simpleexecution.cpp 0 From 44e0d2b3287d3b4e5e9589f887e7d436402d02b4 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 30 Oct 2012 11:37:39 +0100 Subject: [PATCH 130/134] fix tst_QProcess::batFiles for shadow builds Change-Id: If7a9c9aa6ba16b7744d8ef8a66b43e40f375b5e7 Reviewed-by: Friedemann Kleint --- tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 94ecffb1472..49188c30571 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -532,8 +532,8 @@ void tst_QProcess::batFiles_data() QTest::addColumn("batFile"); QTest::addColumn("output"); - QTest::newRow("simple") << QString::fromLatin1("testBatFiles/simple.bat") << QByteArray("Hello"); - QTest::newRow("with space") << QString::fromLatin1("testBatFiles/with space.bat") << QByteArray("Hello"); + QTest::newRow("simple") << QFINDTESTDATA("testBatFiles/simple.bat") << QByteArray("Hello"); + QTest::newRow("with space") << QFINDTESTDATA("testBatFiles/with space.bat") << QByteArray("Hello"); } void tst_QProcess::batFiles() From c6f3d919dd82497183bdf780b0d00aeb374aa934 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 1 Nov 2012 12:14:09 +0100 Subject: [PATCH 131/134] fix error handling bug in QWindowsPipeReader If ReadFile returns with an error then we must set our internal state accordingly. QWindowsPipeReader::readSequenceStarted must be set to false. If ReadFile fails, we're not within a read sequence. Also, we must handle the ERROR_BROKEN_PIPE error. Task-number: QTBUG-25342 Change-Id: Ic9247f170fa9cc47fa7e45d0f47ccfedac06a593 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qwindowspipereader.cpp | 8 ++++++-- tests/auto/corelib/io/qprocess/test/test.pro | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index cca6e80810a..bef6097043b 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -213,7 +213,8 @@ void QWindowsPipeReader::startAsyncRead() // We get notified by the QWinOverlappedIoNotifier - even in the synchronous case. return; } else { - switch (GetLastError()) { + const DWORD dwError = GetLastError(); + switch (dwError) { case ERROR_IO_PENDING: // This is not an error. We're getting notified, when data arrives. return; @@ -223,16 +224,19 @@ void QWindowsPipeReader::startAsyncRead() // didn't fit into the pipe's system buffer. // We're getting notified by the QWinOverlappedIoNotifier. break; + case ERROR_BROKEN_PIPE: case ERROR_PIPE_NOT_CONNECTED: { // It may happen, that the other side closes the connection directly // after writing data. Then we must set the appropriate socket state. + readSequenceStarted = false; pipeBroken = true; emit pipeClosed(); return; } default: - emit winError(GetLastError(), QLatin1String("QWindowsPipeReader::startAsyncRead")); + readSequenceStarted = false; + emit winError(dwError, QLatin1String("QWindowsPipeReader::startAsyncRead")); return; } } diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro index 458bbca7385..79ea53cc6b6 100644 --- a/tests/auto/corelib/io/qprocess/test/test.pro +++ b/tests/auto/corelib/io/qprocess/test/test.pro @@ -11,7 +11,6 @@ win32:TESTDATA += ../testBatFiles/* include(../qprocess.pri) -win32:CONFIG += insignificant_test # QTBUG-25342 - sometimes hangs mac:CONFIG += insignificant_test # QTBUG-25895 - sometimes hangs for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}" From 8727826871c5b1431b3930c996ac6a1de83776ce Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 26 Oct 2012 15:03:00 +0200 Subject: [PATCH 132/134] QFileDialog: Do not pass on file model root to QFileDialogOptions. QFileDialog::selectedFiles() defaults to file model root for 'AnyFile', which confuses native dialogs since selectedFiles == directory in that case. Split up QFileDialog::selectedFiles() and skip the default when initializing QFileDialogOptions for native dialogs. Change-Id: I65cda182df8b1748159058fc361c10d97f5650ce Reviewed-by: Miikka Heikkinen Reviewed-by: Stephen Kelly --- src/widgets/dialogs/qfiledialog.cpp | 38 +++++++++++++++++++---------- src/widgets/dialogs/qfiledialog_p.h | 1 + 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 2ff0d03c350..9a2e32b6315 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -552,7 +552,7 @@ void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) directory.absolutePath() : QString()); options->setInitiallySelectedNameFilter(q->selectedNameFilter()); - options->setInitiallySelectedFiles(q->selectedFiles()); + options->setInitiallySelectedFiles(userSelectedFiles()); } void QFileDialogPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *) @@ -1009,6 +1009,24 @@ QStringList QFileDialogPrivate::typedFiles() const return addDefaultSuffixToFiles(files); } +// Return selected files without defaulting to the root of the file system model +// used for initializing QFileDialogOptions for native dialogs. The default is +// not suitable for native dialogs since it mostly equals directory(). +QStringList QFileDialogPrivate::userSelectedFiles() const +{ + if (nativeDialogInUse) + return addDefaultSuffixToFiles(selectedFiles_sys()); + + QStringList files; + foreach (const QModelIndex &index, qFileDialogUi->listView->selectionModel()->selectedRows()) + files.append(index.data(QFileSystemModel::FilePathRole).toString()); + + if (files.isEmpty() && !lineEdit()->text().isEmpty()) + files = typedFiles(); + + return files; +} + QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList filesToFix) const { QStringList files; @@ -1046,19 +1064,13 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList filesT QStringList QFileDialog::selectedFiles() const { Q_D(const QFileDialog); - if (d->nativeDialogInUse) - return d->addDefaultSuffixToFiles(d->selectedFiles_sys()); - QModelIndexList indexes = d->qFileDialogUi->listView->selectionModel()->selectedRows(); - QStringList files; - for (int i = 0; i < indexes.count(); ++i) - files.append(indexes.at(i).data(QFileSystemModel::FilePathRole).toString()); - - if (files.isEmpty() && !d->lineEdit()->text().isEmpty()) - files = d->typedFiles(); - const FileMode fm = fileMode(); - if (files.isEmpty() && !(fm == ExistingFile || fm == ExistingFiles)) - files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString()); + QStringList files = d->userSelectedFiles(); + if (files.isEmpty()) { + const FileMode fm = fileMode(); + if (fm != ExistingFile && fm != ExistingFiles) + files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString()); + } return files; } diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index b13f36a4d63..592c4a0ac63 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -128,6 +128,7 @@ public: static QString workingDirectory(const QString &path); static QString initialSelection(const QString &path); QStringList typedFiles() const; + QStringList userSelectedFiles() const; QStringList addDefaultSuffixToFiles(const QStringList filesToFix) const; bool removeDirectory(const QString &path); void setLabelTextControl(QFileDialog::DialogLabel label, const QString &text); From 6be78c0712aa4290fed9cf985a52a74869ee85f0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 24 Oct 2012 17:15:06 +0200 Subject: [PATCH 133/134] Exclude ANGLE headers from syncqt-checks. Change-Id: I08797e1cdfc2d79b0292f4d8077847496c4bac62 Reviewed-by: Jason Barron Reviewed-by: Oswald Buddenhagen --- sync.profile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sync.profile b/sync.profile index e51e0aa0c22..2c27d33e132 100644 --- a/sync.profile +++ b/sync.profile @@ -70,9 +70,10 @@ ); @qpa_headers = ( qr/^qplatform/, qr/^qwindowsystem/ ); -@ignore_for_include_check = ( "qsystemdetection.h", "qcompilerdetection.h", "qprocessordetection.h" ); -@ignore_for_qt_begin_header_check = ( "qiconset.h", "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qt_windows.h" ); -@ignore_for_qt_begin_namespace_check = ( "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qatomic_arch.h", "qatomic_windowsce.h", "qt_windows.h", "qatomic_macosx.h" ); +my @angle_headers = ('egl.h', 'eglext.h', 'eglplatform.h', 'gl2.h', 'gl2ext.h', 'gl2platform.h', 'ShaderLang.h', 'khrplatform.h'); +@ignore_for_include_check = ( "qsystemdetection.h", "qcompilerdetection.h", "qprocessordetection.h", @angle_headers); +@ignore_for_qt_begin_header_check = ( "qiconset.h", "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qt_windows.h", @angle_headers); +@ignore_for_qt_begin_namespace_check = ( "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qatomic_arch.h", "qatomic_windowsce.h", "qt_windows.h", "qatomic_macosx.h", @angle_headers); @ignore_for_qt_module_check = ( "$modules{QtCore}/arch", "$modules{QtCore}/global", "$modules{QtTest}", "$modules{QtDBus}" ); %inject_headers = ( "$basedir/src/corelib/global" => [ "qconfig.h" ] ); # Module dependencies. From 300534fc214f2547a63594ce0891e9a54c8f33ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 31 Oct 2012 12:32:31 +0100 Subject: [PATCH 134/134] Added MultipleWindows platform capability. Several platform plugins, like eglfs, kms, etc don't support multiple windows as there's no system compositor, they're rendering directly to a single back buffer. By adding a platform capability we'll be able to provide better error reporting when an application tries to create multiple QWindows on a single-window platform. Also, QML apps can use this capability to figure out whether they should create a QWindow for dialogs / popups / menus, or whether to just create items in the same scene, that are shown on top of the rest of the content. Change-Id: I15b8d21ee2bc4568e9d705dbf32f872c2c25742b Reviewed-by: Andy Nichols --- src/gui/kernel/qplatformintegration.cpp | 4 ++++ src/gui/kernel/qplatformintegration.h | 11 ++++++----- src/plugins/platforms/cocoa/qcocoaintegration.mm | 1 + src/plugins/platforms/minimal/qminimalintegration.cpp | 1 + src/plugins/platforms/windows/qwindowsintegration.cpp | 2 ++ src/plugins/platforms/xcb/qxcbintegration.cpp | 1 + 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index cf55c59bab2..5259ed91646 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -195,6 +195,10 @@ QPlatformServices *QPlatformIntegration::services() const \value BufferQueueingOpenGL The OpenGL implementation on the platform will queue up buffers when swapBuffers() is called and block only when its buffer pipeline is full, rather than block immediately. + + \value MultipleWindows The platform supports multiple QWindows, i.e. does some kind + of compositing either client or server side. Some platforms might only support a + single fullscreen window. */ diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 7e8888407cc..b4c8ebff5a7 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -83,11 +83,12 @@ class Q_GUI_EXPORT QPlatformIntegration public: enum Capability { ThreadedPixmaps = 1, - OpenGL = 2, - ThreadedOpenGL = 3, - SharedGraphicsCache = 4, - BufferQueueingOpenGL = 5, - WindowMasks = 6 + OpenGL, + ThreadedOpenGL, + SharedGraphicsCache, + BufferQueueingOpenGL, + WindowMasks, + MultipleWindows }; virtual ~QPlatformIntegration() { } diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 2fdb367c629..481055aae4d 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -309,6 +309,7 @@ bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) cons case ThreadedOpenGL: case BufferQueueingOpenGL: case WindowMasks: + case MultipleWindows: return true; default: return QPlatformIntegration::hasCapability(cap); diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 6a2db91e349..e9fab6d87c8 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -74,6 +74,7 @@ bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) co { switch (cap) { case ThreadedPixmaps: return true; + case MultipleWindows: return true; default: return QPlatformIntegration::hasCapability(cap); } } diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 3f030ffca76..a02f0cd494e 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -338,6 +338,8 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co #endif // !QT_NO_OPENGL case WindowMasks: return true; + case MultipleWindows: + return true; default: return QPlatformIntegration::hasCapability(cap); } diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index a46d51127fb..2ffe53c04b2 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -216,6 +216,7 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const #endif case ThreadedOpenGL: return false; case WindowMasks: return true; + case MultipleWindows: return true; default: return QPlatformIntegration::hasCapability(cap); } }