On 20.02.11 23:52:13, Wolfgang Rohdewald wrote:
> 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
[...]
> my version, now with your patches:
> svn cat 
> svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/kajongg/src/modeltest.py

Now did a closer look at the diff between that version of mine, the
attached 3 patches (one is the add vs. append change) contain the
changes.

> 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.*

Couldn't find any of those, just a self. missing in front of insert.

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

Can you elaborate on this?

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

Thats probably all those name-changes and line-breaks etc?

There's one change that I don't quite understand though. Its the "Check
that we can get back our real parent", your version does:

parentIdx = self.model.parent( index )
assert( parentIdx.internalId() == parent.internalId() )
assert( parentIdx.row() == parent.row() )

while the PyQt version just compares the index against the stored one. Do you
have any idea why that was done in qbzr (the log message there is less than
useful).

Andreas

-- 
Living your life is a task so difficult, it has never been attempted before.
>From 26ee4e9e79b87987a530434dd82d439eebf47701 Mon Sep 17 00:00:00 2001
From: Andreas Pakulat <ap...@gmx.de>
Date: Mon, 21 Feb 2011 21:37:20 +0100
Subject: [PATCH 1/3] Fix running, lists only know append

---
 tests/modeltest/modeltest.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tests/modeltest/modeltest.py b/tests/modeltest/modeltest.py
index d0c6e12..9fde497 100644
--- a/tests/modeltest/modeltest.py
+++ b/tests/modeltest/modeltest.py
@@ -347,7 +347,7 @@ class ModelTest(QtCore.QObject):
 
     def layoutAboutToBeChanged(self):
         for i in range(0, max(0, min( self.model.rowCount(), 100))):
-            self.changing.add( QtCore.QPersistentModelIndex( self.model.index( i, 0 ) ) )
+            self.changing.append( QtCore.QPersistentModelIndex( self.model.index( i, 0 ) ) )
 
     def layoutChanged(self):
         for c in self.changing:
-- 
1.7.2.3

>From 500bdf421c34e9a2c4f92c871ce3eb7b776e5029 Mon Sep 17 00:00:00 2001
From: Andreas Pakulat <ap...@gmx.de>
Date: Mon, 21 Feb 2011 21:37:54 +0100
Subject: [PATCH 2/3] Fix this assert to not automatically trigger

Apparently sip.cast creates a new python object each time its invoked.
This changes the id of the object and hence the comparison fails here.
So lets use the original instance of the model we store in self._model
for comparison here. We can't leave away the sip.cast because some
model subclasses re-define visibility of public API of
QAbstractItemModel. (QStringListModel makes columnCount private).
---
 tests/modeltest/modeltest.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tests/modeltest/modeltest.py b/tests/modeltest/modeltest.py
index 9fde497..fefe5b4 100644
--- a/tests/modeltest/modeltest.py
+++ b/tests/modeltest/modeltest.py
@@ -419,7 +419,9 @@ class ModelTest(QtCore.QObject):
                 assert( a == b )
 
                 # Some basic checking on the index that is returned
-                assert( index.model() == self.model )
+                # This raises an error that is not part of the qbzr code.
+                # see http://www.opensubscriber.com/message/pyqt@riverbankcomputing.com/10335500.html
+                assert( index.model() == self._model )
                 assert( index.row() == r )
                 assert( index.column() == c )
                 # While you can technically return a QtCore.QVariant usually this is a sign
-- 
1.7.2.3

>From ec34a8a07f317baffc02d842a6d82586be3020d8 Mon Sep 17 00:00:00 2001
From: Andreas Pakulat <ap...@gmx.de>
Date: Mon, 21 Feb 2011 21:41:36 +0100
Subject: [PATCH 3/3] Add self here.

Thats necessary as the change stored in aboutToBeInserted is being used
after the insertion has taken place.
---
 tests/modeltest/modeltest.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/modeltest/modeltest.py b/tests/modeltest/modeltest.py
index fefe5b4..442eb9b 100644
--- a/tests/modeltest/modeltest.py
+++ b/tests/modeltest/modeltest.py
@@ -305,13 +305,13 @@ class ModelTest(QtCore.QObject):
         c['oldSize'] = self.model.rowCount(parent)
         c['last'] = self.model.data(model.index(start-1, 0, parent))
         c['next'] = self.model.data(model.index(start, 0, parent))
-        insert.append(c)
+        self.insert.append(c)
 
     def rowsInserted(self, parent, start, end):
         """
         Confirm that what was said was going to happen actually did
         """
-        c = insert.pop()
+        c = self.insert.pop()
         assert(c['parent'] == parent)
         assert(c['oldSize'] + (end - start + 1) == self.model.rowCount(parent))
         assert(c['last'] == self.model.data(self.model.index(start-1, 0, c['parent'])))
-- 
1.7.2.3

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to