[PyQt] 2 Updates for the modeltest in PyQt4

Wolfgang Rohdewald wolfgang at rohdewald.de
Mon Feb 21 22:50:24 GMT 2011


On Montag 21 Februar 2011, Andreas Pakulat wrote:
> 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.

in rowsAboutToBeInserted and rowsInserted,
rowsAboutToBeRemoved and rowsRemoved, several places
similar to
self.model.data(model.index(...

that should be self.model.index

> > also, checking values for TextAlignmentRole is still  wrong
> > there: it does not accept ORed values
> 
> Can you elaborate on this?

diff between launchpad.net file and mine:
-            assert( alignment == QtCore.Qt.AlignLeft or
-                alignment == QtCore.Qt.AlignRight or
-                alignment == QtCore.Qt.AlignHCenter or
-                alignment == QtCore.Qt.AlignJustify)
+            assert( alignment == (alignment & 
int(QtCore.Qt.AlignHorizontal_Mask | 
QtCore.Qt.AlignVertical_Mask)))

and c++:
        Q_ASSERT ( alignment == ( alignment & ( 
Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );


the launchpad.net version would not accept
Qt.AlignLeft|Qt.AlignVCenter
the C++ version and mine do.

> > 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?

yes. And whitespace changes and some docstrings. Maybe
it is easier to look at my single commits for spotting relevant
differences.
 
> 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).

I have no idea. In Kajongg I have an editable treeview and
adding assert(self.model.parent(index) == parent)
passes (just tried). You'll have to ask the author

-- 
Wolfgang


More information about the PyQt mailing list