[PyQt] 2 Updates for the modeltest in PyQt4

2011-02-20 Thread Andreas Pakulat
Hi,

just started a new project with PyQt which will involve a model, hence
I've sat down and checked wether the python-version of the modeltest is
up-to-date with the C++ version.

There turned out to be one bug (broken signal names) and the C++ version
now also checks the layoutChanged signal. Attached two patches fix that.
I didn't test yet against an actual model, so might have done something
wrong in porting.

Andreas

-- 
You have the body of a 19 year old.  Please return it before it gets wrinkled.
From f78e30900d928f2e87202509e9ef0ddd14c634fa Mon Sep 17 00:00:00 2001
From: Andreas Pakulat ap...@gmx.de
Date: Sun, 20 Feb 2011 21:56:40 +0100
Subject: [PATCH 1/2] Fix signal names.

The PyQt documentation does not indicate that these signals have been
renamed from their C++ version, so the testing of them was broken.
---
 tests/modeltest/modeltest.py |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/modeltest/modeltest.py b/tests/modeltest/modeltest.py
index 64f0511..e2f7a9a 100644
--- a/tests/modeltest/modeltest.py
+++ b/tests/modeltest/modeltest.py
@@ -40,7 +40,7 @@ class ModelTest(QtCore.QObject):
 
 self.connect( self.model, QtCore.SIGNAL(columnsAboutToBeInserted(const QModelIndex, int, int)), self.runAllTests)
 self.connect( self.model, QtCore.SIGNAL(columnsAboutToBeRemoved(const QModelIndex, int, int)), self.runAllTests)
-self.connect( self.model, QtCore.SIGNAL(columnsBeInserted(const QModelIndex, int, int)), self.runAllTests)
+self.connect( self.model, QtCore.SIGNAL(columnsInserted(const QModelIndex, int, int)), self.runAllTests)
 self.connect( self.model, QtCore.SIGNAL(columnsRemoved(const QModelIndex, int, int)), self.runAllTests)
 self.connect( self.model, QtCore.SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), self.runAllTests)
 self.connect( self.model, QtCore.SIGNAL(headerDataChanged(Qt::Orientation, int, int)), self.runAllTests)
@@ -49,13 +49,13 @@ class ModelTest(QtCore.QObject):
 self.connect( self.model, QtCore.SIGNAL(modelReset()), self.runAllTests)
 self.connect( self.model, QtCore.SIGNAL(rowsAboutToBeInserted(const QModelIndex, int, int)), self.runAllTests)
 self.connect( self.model, QtCore.SIGNAL(rowsAboutToBeRemoved(const QModelIndex, int, int)), self.runAllTests)
-self.connect( self.model, QtCore.SIGNAL(rowsBeInserted(const QModelIndex, int, int)), self.runAllTests)
+self.connect( self.model, QtCore.SIGNAL(rowsInserted(const QModelIndex, int, int)), self.runAllTests)
 self.connect( self.model, QtCore.SIGNAL(rowsRemoved(const QModelIndex, int, int)), self.runAllTests)
 
 # Special checks for inserting/removing
 self.connect( self.model, QtCore.SIGNAL(rowsAboutToBeInserted(const QModelIndex, int, int)), self.rowsAboutToBeInserted)
 self.connect( self.model, QtCore.SIGNAL(rowsAboutToBeRemoved(const QModelIndex, int, int)), self.rowsAboutToBeRemoved)
-self.connect( self.model, QtCore.SIGNAL(rowsBeInserted(const QModelIndex, int, int)), self.rowsInserted)
+self.connect( self.model, QtCore.SIGNAL(rowsInserted(const QModelIndex, int, int)), self.rowsInserted)
 self.connect( self.model, QtCore.SIGNAL(rowsRemoved(const QModelIndex, int, int)), self.rowsRemoved)
 self.runAllTests()
 
-- 
1.7.2.3

From c7fb450a7da01dac6fb7351efb547af4ceba97d6 Mon Sep 17 00:00:00 2001
From: Andreas Pakulat ap...@gmx.de
Date: Sun, 20 Feb 2011 21:57:25 +0100
Subject: [PATCH 2/2] Add new check for layout-changes.

This is a test that has been added to the C++ version at some point, it
verifies the first 100 rows to be changing in the correct way when the
layout changes.
---
 tests/modeltest/modeltest.py |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/tests/modeltest/modeltest.py b/tests/modeltest/modeltest.py
index e2f7a9a..d0c6e12 100644
--- a/tests/modeltest/modeltest.py
+++ b/tests/modeltest/modeltest.py
@@ -35,6 +35,7 @@ class ModelTest(QtCore.QObject):
 self.model = sip.cast(_model, QtCore.QAbstractItemModel)
 self.insert = []
 self.remove = []
+self.changing = []
 self.fetchingMore = False
 assert(self.model)
 
@@ -53,6 +54,9 @@ class ModelTest(QtCore.QObject):
 self.connect( self.model, QtCore.SIGNAL(rowsRemoved(const QModelIndex, int, int)), self.runAllTests)
 
 # Special checks for inserting/removing
+self.connect( self.model, QtCore.SIGNAL(layoutAboutToBeChanged()), self.layoutAboutToBeChanged )
+self.connect( self.model, QtCore.SIGNAL(layoutChanged()), self.layoutChanged )
+
 self.connect( self.model, QtCore.SIGNAL(rowsAboutToBeInserted(const QModelIndex, int, int)), self.rowsAboutToBeInserted)
 self.connect( self.model, QtCore.SIGNAL(rowsAboutToBeRemoved(const QModelIndex, int, int)), self.rowsAboutToBeRemoved)
 self.connect( self.model, 

Re: [PyQt] 2 Updates for the modeltest in PyQt4

2011-02-20 Thread Wolfgang Rohdewald
On Sonntag 20 Februar 2011, Andreas Pakulat wrote:
 I didn't test yet against an actual model, so might have done
 something wrong in porting.

yep.

lists have no add, it is append

I didn't test either but pylint did

Where do you maintain modeltest.py?

I got it from
http://bazaar.launchpad.net/~bzr/ubuntu/maverick/qbzr/bzr-
ppa/annotate/head:/lib/tests/modeltest.py

I made a few bug fixes and I believe I mailed them back to
the author but now that I check again not all of them made
it in, there are still some self. missing in front of model.*

also, checking values for TextAlignmentRole is still  wrong
there: it does not accept ORed values

I also changed some things to make pylint happy
(my local git commit hook does not let me commit unless pylint is 
silent)

my version, now with your patches:
svn cat 
svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/kajongg/src/modeltest.py


there also is a modeltest.py from riverbank in 
contrib/pymodeltest
but it has a lot of missing self and does not contain your
patches.

your paths look like you got it from somewere else again:
tests/modeltest/modeltest.py

so I know about three different copies where
I believe mine has less bugs than the others, and you
seem to be patching a forth copy

-- 
Wolfgang
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt