diff options
-rw-r--r-- | configure.bat | 8 | ||||
-rw-r--r-- | mkspecs/win32-clang-msvc2015/qmake.conf | 24 | ||||
-rw-r--r-- | mkspecs/win32-clang-msvc2015/qplatformdefs.h | 34 | ||||
-rw-r--r-- | qmake/Makefile.win32 | 19 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 9 | ||||
-rw-r--r-- | src/corelib/global/qnumeric_p.h | 6 | ||||
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 33 | ||||
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.h | 6 | ||||
-rw-r--r-- | src/widgets/itemviews/qabstractitemview_p.h | 4 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 3 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.cpp | 4 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.h | 1 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp | 50 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 28 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 2 | ||||
-rw-r--r-- | tools/configure/Makefile.win32 | 10 |
17 files changed, 218 insertions, 26 deletions
diff --git a/configure.bat b/configure.bat index ecb1518f66..372b3faac5 100644 --- a/configure.bat +++ b/configure.bat @@ -34,7 +34,7 @@ set QTDIR=%CD% if not exist %QTSRC%.gitignore goto sconf echo Please wait while bootstrapping configure ... -for %%C in (cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C +for %%C in (clang-cl.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C if "%perl.exe%" == "" ( echo Perl not found in PATH. Aborting. >&2 @@ -81,6 +81,12 @@ if not "%icl.exe%" == "" ( rem This must have a trailing space. echo QTSRC = %QTSRC% >> Makefile set tmpl=win32 +) else if not "%clang-cl.exe%" == "" ( + echo CXX = clang-cl>>Makefile + echo EXTRA_CXXFLAGS = -fms-compatibility-version=19.00.23506 -Wno-microsoft-enum-value>>Makefile + rem This must have a trailing space. + echo QTSRC = %QTSRC% >> Makefile + set tmpl=win32 ) else if not "%cl.exe%" == "" ( echo CXX = cl>>Makefile echo EXTRA_CXXFLAGS =>>Makefile diff --git a/mkspecs/win32-clang-msvc2015/qmake.conf b/mkspecs/win32-clang-msvc2015/qmake.conf new file mode 100644 index 0000000000..73cfdcbab9 --- /dev/null +++ b/mkspecs/win32-clang-msvc2015/qmake.conf @@ -0,0 +1,24 @@ +# +# qmake configuration for win32-clang-msvc2015 + +# +# Written for Clang 3.8 with Microsoft Visual C++ 2015 Update 1 +# Notice: this uses the clang-cl wrapper +# + +MSC_VER = 1900 +MSVC_VER = 14.0 +include(../common/msvc-desktop.conf) + +QMAKE_COMPILER += clang_cl llvm + +QMAKE_CC = clang-cl +QMAKE_CXX = $$QMAKE_CC + +QMAKE_CFLAGS += -fms-compatibility-version=19.00.23506 -Wno-microsoft-enum-value +QMAKE_CXXFLAGS = $$QMAKE_CFLAGS + +# Precompiled headers are not supported yet by clang +CONFIG -= precompile_header + +load(qt_config) diff --git a/mkspecs/win32-clang-msvc2015/qplatformdefs.h b/mkspecs/win32-clang-msvc2015/qplatformdefs.h new file mode 100644 index 0000000000..7100e3aa41 --- /dev/null +++ b/mkspecs/win32-clang-msvc2015/qplatformdefs.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../win32-msvc2005/qplatformdefs.h" diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 1e8c5129be..1d50f872d9 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -14,6 +14,10 @@ QMKSRC = $(SOURCE_PATH)\qmake CXX = icl LINKER = link CFLAGS_EXTRA = /Zc:forScope /Qstd=c++11 +!elseif "$(QMAKESPEC)" == "win32-clang-msvc2015" +CXX = clang-cl +LINKER = link +CFLAGS_EXTRA = -fms-compatibility-version=19.00.23506 -Wno-microsoft-enum-value !else CXX = cl LINKER = link @@ -21,13 +25,18 @@ LINKER = link CFLAGS_EXTRA = /Zc:wchar_t- ! elseif "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-msvc2013" CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS $(CFLAGS_CRT) -! elseif "$(QMAKESPEC)" == "win32-msvc2015" +! elseif "$(QMAKESPEC)" == "win32-msvc2015" || "$(QMAKESPEC)" == "win32-clang-msvc2015" CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /Zc:strictStrings /w44456 /w44457 /w44458 /wd4577 $(CFLAGS_CRT) ! else ! error Unsupported compiler for this Makefile ! endif !endif # !win32-icc +!if "$(QMAKESPEC)" != "win32-clang-msvc2015" +CFLAGS_PCH = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch +PCH_OBJECT = qmake_pch.obj +!endif + CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \ -W3 -nologo -O1 \ $(CFLAGS_EXTRA) \ @@ -41,7 +50,7 @@ CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \ -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ -DUNICODE -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY -DQT_NO_STANDARDPATHS -CFLAGS = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch $(CFLAGS_BARE) $(CFLAGS) +CFLAGS = $(CFLAGS_PCH) $(CFLAGS_BARE) $(CFLAGS) CXXFLAGS_BARE = $(CFLAGS_BARE) CXXFLAGS = $(CFLAGS) @@ -129,7 +138,7 @@ QTOBJS= \ first all: qmake.exe qmake.exe: $(OBJS) $(QTOBJS) - $(LINKQMAKE) qmake_pch.obj + $(LINKQMAKE) $(PCH_OBJECT) -copy qmake.exe $(BUILD_PATH)\bin\qmake.exe clean:: @@ -158,9 +167,9 @@ distclean:: clean .cxx.obj: $(CXX) $(CXXFLAGS) $< -$(OBJS): qmake_pch.obj +$(OBJS): $(PCH_OBJECT) -$(QTOBJS): qmake_pch.obj +$(QTOBJS): $(PCH_OBJECT) qlibraryinfo.obj: $(BUILD_PATH)\src\corelib\global\qconfig.cpp diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e655aace32..7575fe06b2 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -83,6 +83,9 @@ # endif #elif defined(_MSC_VER) +# ifdef __clang__ +# define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__) +# endif # define Q_CC_MSVC (_MSC_VER) # define Q_CC_MSVC_NET # define Q_OUTOFLINE_TEMPLATE inline @@ -97,7 +100,9 @@ # define Q_UNREACHABLE_IMPL() __assume(0) # define Q_NORETURN __declspec(noreturn) # define Q_DECL_DEPRECATED __declspec(deprecated) -# define Q_DECL_DEPRECATED_X(text) __declspec(deprecated(text)) +# ifndef Q_CC_CLANG +# define Q_DECL_DEPRECATED_X(text) __declspec(deprecated(text)) +# endif # define Q_DECL_EXPORT __declspec(dllexport) # define Q_DECL_IMPORT __declspec(dllimport) /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ @@ -1177,7 +1182,7 @@ # define QT_WARNING_DISABLE_MSVC(number) # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_GCC(text) -#elif defined(Q_CC_MSVC) && _MSC_VER >= 1500 +#elif defined(Q_CC_MSVC) && _MSC_VER >= 1500 && !defined(Q_CC_CLANG) # undef QT_DO_PRAGMA /* not needed */ # define QT_WARNING_PUSH __pragma(warning(push)) # define QT_WARNING_POP __pragma(warning(pop)) diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index f58e062dbd..5705bc29c8 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -222,7 +222,7 @@ template <> inline bool mul_overflow(unsigned long long v1, unsigned long long v # define HAVE_MUL64_OVERFLOW #endif -#if ((defined(Q_CC_MSVC) && _MSC_VER >= 1800) || defined(Q_CC_INTEL)) && defined(Q_PROCESSOR_X86) +#if ((defined(Q_CC_MSVC) && _MSC_VER >= 1800) || defined(Q_CC_INTEL)) && defined(Q_PROCESSOR_X86) && !QT_HAS_BUILTIN(__builtin_uadd_overflow) template <> inline bool add_overflow(unsigned v1, unsigned v2, unsigned *r) { return _addcarry_u32(0, v1, v2, r); } # ifdef Q_CC_MSVC // longs are 32-bit @@ -230,7 +230,7 @@ template <> inline bool add_overflow(unsigned long v1, unsigned long v2, unsigne { return _addcarry_u32(0, v1, v2, reinterpret_cast<unsigned *>(r)); } # endif #endif -#if ((defined(Q_CC_MSVC) && _MSC_VER >= 1800) || defined(Q_CC_INTEL)) && defined(Q_PROCESSOR_X86_64) +#if ((defined(Q_CC_MSVC) && _MSC_VER >= 1800) || defined(Q_CC_INTEL)) && defined(Q_PROCESSOR_X86_64) && !QT_HAS_BUILTIN(__builtin_uadd_overflow) template <> inline bool add_overflow(quint64 v1, quint64 v2, quint64 *r) { return _addcarry_u64(0, v1, v2, reinterpret_cast<unsigned __int64 *>(r)); } # ifndef Q_CC_MSVC // longs are 64-bit @@ -239,7 +239,7 @@ template <> inline bool add_overflow(unsigned long v1, unsigned long v2, unsigne # endif #endif -#if defined(Q_CC_MSVC) && (defined(Q_PROCESSOR_X86_64) || defined(Q_PROCESSOR_IA64)) +#if defined(Q_CC_MSVC) && (defined(Q_PROCESSOR_X86_64) || defined(Q_PROCESSOR_IA64)) && !QT_HAS_BUILTIN(__builtin_uadd_overflow) #pragma intrinsic(_umul128) template <> inline bool mul_overflow(quint64 v1, quint64 v2, quint64 *r) { diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index d98f61b990..9135d1a23c 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -108,7 +108,9 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() currentIndexSet(false), wrapItemText(false), delayedPendingLayout(true), - moveCursorUpdatedView(false) + moveCursorUpdatedView(false), + verticalScrollModeSet(false), + horizontalScrollModeSet(false) { keyboardInputTime.invalidate(); } @@ -137,6 +139,9 @@ void QAbstractItemViewPrivate::init() viewport->setBackgroundRole(QPalette::Base); q->setAttribute(Qt::WA_InputMethodEnabled); + + verticalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, q, 0)); + horizontalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, q, 0)); } void QAbstractItemViewPrivate::setHoverIndex(const QPersistentModelIndex &index) @@ -1237,12 +1242,14 @@ QAbstractItemView::EditTriggers QAbstractItemView::editTriggers() const \brief how the view scrolls its contents in the vertical direction This property controls how the view scroll its contents vertically. - Scrolling can be done either per pixel or per item. + Scrolling can be done either per pixel or per item. Its default value + comes from the style via the QStyle::SH_ItemView_ScrollMode style hint. */ void QAbstractItemView::setVerticalScrollMode(ScrollMode mode) { Q_D(QAbstractItemView); + d->verticalScrollModeSet = true; if (mode == d->verticalScrollMode) return; QModelIndex topLeft = indexAt(QPoint(0, 0)); @@ -1261,18 +1268,27 @@ QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode() const return d->verticalScrollMode; } +void QAbstractItemView::resetVerticalScrollMode() +{ + auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, this, 0)); + setVerticalScrollMode(sm); + d_func()->verticalScrollModeSet = false; +} + /*! \since 4.2 \property QAbstractItemView::horizontalScrollMode \brief how the view scrolls its contents in the horizontal direction This property controls how the view scroll its contents horizontally. - Scrolling can be done either per pixel or per item. + Scrolling can be done either per pixel or per item. Its default value + comes from the style via the QStyle::SH_ItemView_ScrollMode style hint. */ void QAbstractItemView::setHorizontalScrollMode(ScrollMode mode) { Q_D(QAbstractItemView); + d->horizontalScrollModeSet = true; if (mode == d->horizontalScrollMode) return; d->horizontalScrollMode = mode; @@ -1289,6 +1305,13 @@ QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode() const return d->horizontalScrollMode; } +void QAbstractItemView::resetHorizontalScrollMode() +{ + auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, this, 0)); + setHorizontalScrollMode(sm); + d_func()->horizontalScrollModeSet = false; +} + #ifndef QT_NO_DRAGANDDROP /*! \since 4.2 @@ -1627,6 +1650,10 @@ bool QAbstractItemView::event(QEvent *event) break; case QEvent::StyleChange: doItemsLayout(); + if (!d->verticalScrollModeSet) + resetVerticalScrollMode(); + if (!d->horizontalScrollModeSet) + resetHorizontalScrollMode(); break; case QEvent::FocusOut: d->checkPersistentEditorFocus(); diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index fb1d222676..b8d386f234 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -75,8 +75,8 @@ class Q_WIDGETS_EXPORT QAbstractItemView : public QAbstractScrollArea Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior) Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode) - Q_PROPERTY(ScrollMode verticalScrollMode READ verticalScrollMode WRITE setVerticalScrollMode) - Q_PROPERTY(ScrollMode horizontalScrollMode READ horizontalScrollMode WRITE setHorizontalScrollMode) + Q_PROPERTY(ScrollMode verticalScrollMode READ verticalScrollMode WRITE setVerticalScrollMode RESET resetVerticalScrollMode) + Q_PROPERTY(ScrollMode horizontalScrollMode READ horizontalScrollMode WRITE setHorizontalScrollMode RESET resetHorizontalScrollMode) public: enum SelectionMode { @@ -147,9 +147,11 @@ public: void setVerticalScrollMode(ScrollMode mode); ScrollMode verticalScrollMode() const; + void resetVerticalScrollMode(); void setHorizontalScrollMode(ScrollMode mode); ScrollMode horizontalScrollMode() const; + void resetHorizontalScrollMode(); void setAutoScroll(bool enable); bool hasAutoScroll() const; diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index 4ba24a2786..a3af79abcb 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -461,6 +461,10 @@ public: mutable bool delayedPendingLayout; bool moveCursorUpdatedView; + // Whether scroll mode has been explicitly set or its value come from SH_ItemView_ScrollMode + bool verticalScrollModeSet; + bool horizontalScrollModeSet; + private: mutable QBasicTimer delayedLayout; mutable QBasicTimer fetchMoreTimer; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 17c2ea2ba8..c28a70e3f9 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5215,6 +5215,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_Splitter_OpaqueResize: ret = true; break; + case SH_ItemView_ScrollMode: + ret = QAbstractItemView::ScrollPerItem; + break; default: ret = 0; break; diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 009cc1b1b0..74554f6d3d 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -3043,6 +3043,9 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay; } break; + case SH_ItemView_ScrollMode: + ret = QAbstractItemView::ScrollPerPixel; + break; default: ret = QCommonStyle::styleHint(sh, opt, w, hret); break; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 34d5b49ee1..26bb227e29 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1978,6 +1978,10 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, tab is changed while dragging over the tabbar, in milliseconds. This enum value has been introduced in Qt 5.4 + \value SH_ItemView_ScrollMode The default vertical and horizontal scroll mode as specified + by the style. Can be overridden with QAbstractItemView::setVerticalScrollMode() and + QAbstractItemView::setHorizontalScrollMode(). This enum value has been introduced in Qt 5.7. + \sa styleHint() */ diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 425acc8301..0f9c9379f5 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -732,6 +732,7 @@ public: SH_Menu_SubMenuSloppyCloseTimeout, SH_Menu_SubMenuResetWhenReenteringParent, SH_Menu_SubMenuDontStartSloppyOnLeave, + SH_ItemView_ScrollMode, // Add new style hint values here SH_CustomBase = 0xf0000000 diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 2a26427542..2dd0337117 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -50,6 +50,7 @@ #include <qstyleditemdelegate.h> #include <qstringlistmodel.h> #include <qsortfilterproxymodel.h> +#include <qproxystyle.h> static inline void setFrameless(QWidget *w) { @@ -246,6 +247,7 @@ private slots: void sizeHintChangeTriggersLayout(); void shiftSelectionAfterChangingModelContents(); void QTBUG48968_reentrant_updateEditorGeometries(); + void QTBUG50102_SH_ItemView_ScrollMode(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -2018,5 +2020,53 @@ void tst_QAbstractItemView::QTBUG48968_reentrant_updateEditorGeometries() // No crash, all fine. } +class ScrollModeProxyStyle: public QProxyStyle +{ +public: + ScrollModeProxyStyle(QAbstractItemView::ScrollMode sm, QStyle *style = 0) + : QProxyStyle(style) + , scrollMode(sm == QAbstractItemView::ScrollPerItem ? + QAbstractItemView::ScrollPerPixel : QAbstractItemView::ScrollPerItem) + { } + + int styleHint(QStyle::StyleHint hint, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *returnData) const override + { + if (hint == SH_ItemView_ScrollMode) + return scrollMode; + + return baseStyle()->styleHint(hint, opt, w, returnData); + } + + QAbstractItemView::ScrollMode scrollMode; +}; + +void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode() +{ + QListView view; + + // Default comes from the style + auto styleScrollMode = static_cast<QAbstractItemView::ScrollMode>(view.style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, &view, 0)); + QCOMPARE(view.verticalScrollMode(), styleScrollMode); + QCOMPARE(view.horizontalScrollMode(), styleScrollMode); + + // Change style, get new value + view.setStyle(new ScrollModeProxyStyle(styleScrollMode)); + auto proxyScrollMode = static_cast<QAbstractItemView::ScrollMode>(view.style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, &view, 0)); + QVERIFY(styleScrollMode != proxyScrollMode); + QCOMPARE(view.verticalScrollMode(), proxyScrollMode); + QCOMPARE(view.horizontalScrollMode(), proxyScrollMode); + + // Explicitly set vertical, same value + view.setVerticalScrollMode(proxyScrollMode); + QCOMPARE(view.verticalScrollMode(), proxyScrollMode); + QCOMPARE(view.horizontalScrollMode(), proxyScrollMode); + + // Change style, won't change value for vertical, will change for horizontal + view.setStyle(new ScrollModeProxyStyle(proxyScrollMode)); + QCOMPARE(view.verticalScrollMode(), proxyScrollMode); + QCOMPARE(view.horizontalScrollMode(), styleScrollMode); +} + + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index ea9f20d5ba..5058dd2a81 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -279,6 +279,18 @@ public: mutable bool wrongIndex; }; +class ScrollPerItemListView : public QListView +{ +public: + explicit ScrollPerItemListView(QWidget *parent = Q_NULLPTR) + : QListView(parent) + { + // Force per item scroll mode since it comes from the style by default + setVerticalScrollMode(QAbstractItemView::ScrollPerItem); + setHorizontalScrollMode(QAbstractItemView::ScrollPerItem); + } +}; + void tst_QListView::initTestCase() { #ifdef Q_OS_WINCE //disable magic for WindowsCE @@ -823,7 +835,7 @@ void tst_QListView::setCurrentIndex() { QStringListModel model(generateList(QLatin1String("item "), 20)); - QListView view; + ScrollPerItemListView view; view.setModel(&model); view.resize(220,182); @@ -1153,7 +1165,7 @@ void tst_QListView::scrollTo() { QWidget topLevel; setFrameless(&topLevel); - QListView lv(&topLevel); + ScrollPerItemListView lv(&topLevel); QStringListModel model(&lv); QStringList list; list << "Short item 1"; @@ -1189,6 +1201,7 @@ void tst_QListView::scrollTo() model.setStringList(list); lv.setModel(&model); lv.setFixedSize(110, 200); + topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); @@ -1262,7 +1275,7 @@ void tst_QListView::scrollBarRanges() const int rowHeight = 20; QWidget topLevel; - QListView lv(&topLevel); + ScrollPerItemListView lv(&topLevel); QStringListModel model(&lv); QStringList list; for (int i = 0; i < rowCount; ++i) @@ -1271,6 +1284,7 @@ void tst_QListView::scrollBarRanges() model.setStringList(list); lv.setModel(&model); lv.resize(250, 130); + TestDelegate *delegate = new TestDelegate(&lv); delegate->m_sizeHint = QSize(100, rowHeight); lv.setItemDelegate(delegate); @@ -1814,7 +1828,7 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems() QWidget topLevel; setFrameless(&topLevel); - QListView view(&topLevel); + ScrollPerItemListView view(&topLevel); QStringListModel model(&view); QStringList list; for (int i = 0; i < rowCount; ++i) @@ -2060,7 +2074,7 @@ void tst_QListView::taskQTBUG_21115_scrollToAndHiddenItems() { QFETCH(int, flow); - QListView lv; + ScrollPerItemListView lv; lv.setUniformItemSizes(true); lv.setFlow(static_cast<QListView::Flow>(flow)); @@ -2155,7 +2169,7 @@ void tst_QListView::taskQTBUG_21804_hiddenItemsAndScrollingWithKeys() model.setStringList(list); // create listview - QListView lv; + ScrollPerItemListView lv; lv.setFlow(static_cast<QListView::Flow>(flow)); lv.setSpacing(spacing); lv.setModel(&model); @@ -2227,7 +2241,7 @@ void tst_QListView::spacing() model.setStringList(list); // create listview - QListView lv; + ScrollPerItemListView lv; lv.setFlow(static_cast<QListView::Flow>(flow)); lv.setModel(&model); lv.setSpacing(spacing); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index e21aedee1e..137f18e23a 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -503,7 +503,7 @@ void tst_QTreeView::construction() QCOMPARE(view.sizeHintForRow(1), -1); QVERIFY(!view.tabKeyNavigation()); QCOMPARE(view.textElideMode(), Qt::ElideRight); - QCOMPARE(view.verticalScrollMode(), QAbstractItemView::ScrollPerItem); + QCOMPARE(static_cast<int>(view.verticalScrollMode()), view.style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, &view)); QCOMPARE(view.visualRect(QModelIndex()), QRect()); // QTreeView properties diff --git a/tools/configure/Makefile.win32 b/tools/configure/Makefile.win32 index c83ecaaeea..17a758c795 100644 --- a/tools/configure/Makefile.win32 +++ b/tools/configure/Makefile.win32 @@ -2,11 +2,17 @@ CORESRC = $(QTSRC)src\corelib TOOLSRC = $(QTSRC)tools CONFSRC = $(TOOLSRC)\configure -PCH = configure_pch.pch DEFINES = -DUNICODE -DQT_NO_CODECS -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE -DQT_VERSION_STR=\"$(QTVERSION)\" -DQT_VERSION_MAJOR=$(QT_VERSION_MAJOR) -DQT_VERSION_MINOR=$(QT_VERSION_MINOR) -DQT_VERSION_PATCH=$(QT_VERSION_PATCH) INCPATH = -I"..\..\include" -I"..\..\include\QtCore" -I"..\..\include\QtCore\$(QTVERSION)" -I"..\..\include\QtCore\$(QTVERSION)\QtCore" -I"$(TOOLSRC)\shared" -I"$(QTSRC)mkspecs\win32-msvc2012" CXXFLAGS_BARE = -nologo -Zc:wchar_t -W3 -GR -EHsc -w34100 -w34189 -wd4577 $(CFLAGS_CRT) $(EXTRA_CXXFLAGS) $(DEFINES) $(INCPATH) +!IF ("$(CXX)" != "clang-cl") +PCH = configure_pch.pch +PCH_OBJECT = configure_pch.obj CXXFLAGS = -FIconfigure_pch.h -Yuconfigure_pch.h -Fp$(PCH) -MP $(CXXFLAGS_BARE) +!ELSE +PCH = +CXXFLAGS = -Wmicrosoft $(CXXFLAGS_BARE) +!ENDIF LINK = link LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:"configure.intermediate.manifest" LIBS = ole32.lib advapi32.lib shell32.lib @@ -71,7 +77,7 @@ OBJECTS = \ qxmlutils.obj \ quuid.obj \ registry.obj \ - configure_pch.obj + $(PCH_OBJECT) $(TARGET): $(OBJECTS) $(LINK) $(LFLAGS) /OUT:$(TARGET) @<< |