[arch-commits] Commit in qt/trunk (2 files)

Andrea Scarpino andrea at archlinux.org
Sun Sep 26 11:20:42 UTC 2010


    Date: Sunday, September 26, 2010 @ 07:20:42
  Author: andrea
Revision: 91295

fix qt regression: QTreeView scrolls to top if current item is removed

Added:
  qt/trunk/fix-scroll-when-last-item-is-removed.patch
Modified:
  qt/trunk/PKGBUILD

--------------------------------------------+
 PKGBUILD                                   |   11 ++-
 fix-scroll-when-last-item-is-removed.patch |   77 +++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 3 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2010-09-26 10:34:58 UTC (rev 91294)
+++ PKGBUILD	2010-09-26 11:20:42 UTC (rev 91295)
@@ -4,7 +4,7 @@
 
 pkgname=qt
 pkgver=4.7.0
-pkgrel=1
+pkgrel=2
 pkgdesc='A cross-platform application and UI framework'
 arch=('i686' 'x86_64')
 url='http://qt.nokia.com/'
@@ -17,12 +17,14 @@
 options=('!libtool')
 _pkgfqn="qt-everywhere-opensource-src-${pkgver}"
 source=("ftp://ftp.qt.nokia.com/qt/source/${_pkgfqn}.tar.gz"
-        'assistant.desktop' 'designer.desktop' 'linguist.desktop' 'qtconfig.desktop')
+        'assistant.desktop' 'designer.desktop' 'linguist.desktop' 'qtconfig.desktop'
+	'fix-scroll-when-last-item-is-removed.patch')
 md5sums=('3a2f25b9b115037277f4fb759194a7a5'
          'a445c6917086d80f1cfc1e40cb6b0132'
          'd457f0a0ad68a3861c3cadefe3b42ded'
          '668331d9798a0e2b94381efb7be4c513'
-         'c29f2993d6a0f73d756d2fa36e130e1c')
+         'c29f2993d6a0f73d756d2fa36e130e1c'
+         '072a9b008878e171a86fb90cdf8ce52d')
 
 build() {
 	unset QMAKESPEC
@@ -32,6 +34,9 @@
 
 	cd $srcdir/$_pkgfqn
 
+	# Already fixed in 4.7.1
+	patch -Np1 -i ${srcdir}/fix-scroll-when-last-item-is-removed.patch
+
 	sed -i "s|-O2|$CXXFLAGS|" mkspecs/common/g++.conf
 	sed -i "/^QMAKE_RPATH/s| -Wl,-rpath,||g" mkspecs/common/g++.conf
 	sed -i "/^QMAKE_LFLAGS\s/s|+=|+= $LDFLAGS|g" mkspecs/common/g++.conf

Added: fix-scroll-when-last-item-is-removed.patch
===================================================================
--- fix-scroll-when-last-item-is-removed.patch	                        (rev 0)
+++ fix-scroll-when-last-item-is-removed.patch	2010-09-26 11:20:42 UTC (rev 91295)
@@ -0,0 +1,77 @@
+From 6da6b7099d4e0b49329793e4b90703ec3d868048 Mon Sep 17 00:00:00 2001
+From: Frank Reininghaus <frank78ac at googlemail.com>
+Date: Wed, 22 Sep 2010 10:19:59 +0200
+Subject: [PATCH] QTreeView: do not scroll to top if last item is removed
+
+When the last item is the current item and is removed,
+QTreeViewPrivate::updateScrollBars() is called after QTreeViewPrivate's
+viewItems member is cleared. This commit makes sure that viewItems is
+restored by calling QTreeView::doItemsLayout() in this case, preventing
+that the scroll bar range is set to zero temporarily and the view is
+scrolled to the top unexpectedly (this was a regression in 4.7.0:
+QTBUG-13567).
+
+Merge-request: 2481
+Reviewed-by: Olivier Goffart <olivier.goffart at nokia.com>
+---
+ src/gui/itemviews/qtreeview.cpp        |    4 ++++
+ tests/auto/qtreeview/tst_qtreeview.cpp |   22 ++++++++++++++++++++++
+ 2 files changed, 26 insertions(+), 0 deletions(-)
+
+diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
+index b797776..40b51fe 100644
+--- a/src/gui/itemviews/qtreeview.cpp
++++ b/src/gui/itemviews/qtreeview.cpp
+@@ -3435,6 +3435,10 @@ void QTreeViewPrivate::updateScrollBars()
+     if (!viewportSize.isValid())
+         viewportSize = QSize(0, 0);
+ 
++    if (viewItems.isEmpty()) {
++        q->doItemsLayout();
++    }
++
+     int itemsInViewport = 0;
+     if (uniformRowHeights) {
+         if (defaultItemHeight <= 0)
+diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
+index 7e2e800..c7b53e9 100644
+--- a/tests/auto/qtreeview/tst_qtreeview.cpp
++++ b/tests/auto/qtreeview/tst_qtreeview.cpp
+@@ -240,6 +240,7 @@ private slots:
+     void taskQTBUG_6450_selectAllWith1stColumnHidden();
+     void taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint();
+     void taskQTBUG_11466_keyboardNavigationRegression();
++    void taskQTBUG_13567_removeLastItemRegression();
+ };
+ 
+ class QtTestModel: public QAbstractItemModel
+@@ -3910,5 +3911,26 @@ void tst_QTreeView::taskQTBUG_11466_keyboardNavigationRegression()
+     QTRY_COMPARE(treeView.currentIndex(), treeView.selectionModel()->selection().indexes().first());
+ }
+ 
++void tst_QTreeView::taskQTBUG_13567_removeLastItemRegression()
++{
++    QtTestModel model(200, 1);
++
++    QTreeView view;
++    view.setSelectionMode(QAbstractItemView::ExtendedSelection);
++    view.setModel(&model);
++    view.show();
++    QTest::qWaitForWindowShown(&view);
++
++    view.scrollToBottom();
++    QTest::qWait(10);
++    CHECK_VISIBLE(199, 0);
++
++    view.setCurrentIndex(model.index(199, 0));
++    model.removeLastRow();
++    QTest::qWait(10);
++    QCOMPARE(view.currentIndex(), model.index(198, 0));
++    CHECK_VISIBLE(198, 0);
++}
++
+ QTEST_MAIN(tst_QTreeView)
+ #include "tst_qtreeview.moc"
+-- 
+1.6.1
+




More information about the arch-commits mailing list