<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Wow!! Wonderful!! I wasn't expecting you answer any more!! Thanks
for you effort!!! <br>
I didn't know about QtGui.QHeaderView.ResizeToContents. Very
interesting.<br>
I've read all of yous optimization and I (obviously) agree with
you!!<br>
(Just keep in mind that I was building the first Model/View PyQt
program... so it isn't and won't be perfect!!) <br>
Only a small doubt on the last fix: isn't too expensive or slow to
recreate a QFileSystemModel at every signal??<br>
Thank you again!!<br>
<pre class="moz-signature" cols="72">Gionata Boccalini</pre>
<br>
Il 01/12/2010 15:00, Hans Meine ha scritto:
<blockquote
cite="mid:201012011500.26785.meine@informatik.uni-hamburg.de"
type="cite">
<pre wrap="">Hi again!
Op den Dunnersdag 25 November 2010 Klock 21:15:19 hett Gionata Boccalini
schreven:
</pre>
<blockquote type="cite">
<pre wrap="">Ok, don't worry, I absolutely don't want to waste your time!! But what
do you mean with
</pre>
<blockquote type="cite">
<pre wrap="">In
general, your code could (and should) be much more concise.
</pre>
</blockquote>
</blockquote>
<pre wrap="">
OK, I had a look again, your code is not much too complex actually.
Anyhow, there's potential for optimization IMHO:
- [duplicate/complex code] remove all QTimer and resizeColumnToContents stuff,
instead use self.__fileView.header().setResizeMode(0,
QtGui.QHeaderView.ResizeToContents) *
- for the minimal example for this list, the updateSelection() stuff is
unnecessary (the smaller the example, the more likely you'll get answers)
- [consistency] rename __treeView to __dirView
- [simplicity] instead of connecting to clicked/expanded on the left, what
about currentChanged?
- [duplicate code] in any case, don't setup the filemodel's root in __init__,
but make sure that the connected signals are emitted - in my case, I would
call setCurrentIndex - in order to let updateFiles() to the job
- [duplicate code] setup the treeviews with your visual preferences only once
- maybe disable expansion in the __fileView (and decoration)
Attached you find a refactored version of your example.
Then, it is easy to solve your problem by just re-creating the model in every
updateFiles() step. I am attaching that, too.
* I just realized that manual resizing might still be desirable. Anyhow, the
timer solution looks quite hacky to my eyes.
HTH,
Hans
</pre>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
PyQt mailing list <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></pre>
</blockquote>
</body>
</html>