1 Star 0 Fork 18

xingwei-liu/qt5-qtbase

forked from src-anolis-os/qt5-qtbase 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
QTBUG-94248-Check-scrollbar-ScrollBarOverlap-when-computing-QListView-margins.patch 3.11 KB
一键复制 编辑 原始数据 按行查看 历史
xingwei-liu 提交于 2022-10-12 16:54 . feature: add patchs for DDE
From c0f754214f5a9a9cc792ca245c6f873cc79ffb33 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Tue, 5 Jul 2022 10:55:11 +0800
Subject: [PATCH]
QTBUG-94248-Check-scrollbar-ScrollBarOverlap-when-computing-QListView-margins
---
src/widgets/itemviews/qlistview.cpp | 1 +
.../itemviews/qlistview/tst_qlistview.cpp | 31 +++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 57bfdcde..99224f9c 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -1823,6 +1823,7 @@ void QListViewPrivate::prepareItemsLayout()
// Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy
// is Qt::ScrollBarAsNeeded
int verticalMargin = (vbarpolicy == Qt::ScrollBarAsNeeded) && (flow == QListView::LeftToRight || vbar->isVisible())
+ && !q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, nullptr, vbar)
? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, vbar) + frameAroundContents
: 0;
int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index d80cc6bd..46589dd7 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -37,6 +37,7 @@
#include <QTest>
#include <QTimer>
#include <QtMath>
+#include <QProxyStyle>
#include <QtTest/private/qtesthelpers_p.h>
#include <QtWidgets/private/qlistview_p.h>
@@ -168,6 +169,7 @@ private slots:
void taskQTBUG_51086_skippingIndexesInSelectedIndexes();
void taskQTBUG_47694_indexOutOfBoundBatchLayout();
void itemAlignment();
+ void spacingWithWordWrap_data();
void spacingWithWordWrap();
void internalDragDropMove_data();
void internalDragDropMove();
@@ -2567,8 +2569,37 @@ void tst_QListView::taskQTBUG_47694_indexOutOfBoundBatchLayout()
/*!
Verify fix for QTBUG-92366
*/
+void tst_QListView::spacingWithWordWrap_data()
+{
+ QTest::addColumn<bool>("scrollBarOverlap");
+
+ QTest::addRow("Without overlap") << false;
+ QTest::addRow("With overlap") << true;
+}
+
void tst_QListView::spacingWithWordWrap()
{
+ QFETCH(bool, scrollBarOverlap);
+
+ class MyStyle : public QProxyStyle
+ {
+ bool scrollBarOverlap;
+ public:
+ MyStyle(bool scrollBarOverlap) : scrollBarOverlap(scrollBarOverlap) {}
+
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr) const override{
+ switch (metric) {
+ case QStyle::PM_ScrollView_ScrollBarOverlap: return scrollBarOverlap;
+ default:
+ break;
+ }
+ return QProxyStyle::pixelMetric(metric, option, widget);
+ }
+ };
+
+ QApplication::setStyle(new MyStyle(scrollBarOverlap));
+
const int listViewResizeCount = 200;
QWidget window;
window.resize(300, 200);
--
2.31.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xingwei-liu/qt5-qtbase.git
git@gitee.com:xingwei-liu/qt5-qtbase.git
xingwei-liu
qt5-qtbase
qt5-qtbase
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385