<div>I am planning similar things and will run into the same issue as you I suspect. My benchmark will be a table model with up to 1 million rows. Each of the rows may have 1,000 items (columns) and I need filter features to select rows (numerical simulations). Related to this and Darryl's question, would someone like to comment in general on the feasibility of using PyQt for such large table models (or tree models etc.) and the maximum responsiveness one can achieve?</div>
<div> </div>
<div>Regards,</div>
<div>Bjorn<br><br></div>
<div class="gmail_quote">On Thu, Apr 8, 2010 at 3:14 PM, Darryl Wallace <span dir="ltr"><<a href="mailto:darryl.wallace@prosensus.ca">darryl.wallace@prosensus.ca</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div lang="EN-CA" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 11pt">Here’s an example of the code:</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 11pt"> </span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">def searchAndSelect(self, searchString, column=0):</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> #If the user searches for nothing, then return and do nothing</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> if len(searchString)==0:</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> return</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> </span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> #get the selection model from the tree view</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> selectionModel=self.obsTreeView.selectionModel()</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> </span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> # Find the items in the model.</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> # obsTreeModel is a QStandardItemModel</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> # This part is very fast </span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> items=self.obsTreeModel.findItems(searchString, QtCore.Qt.MatchContains, column)</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> </span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> #select each item</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> # This part is very slow.</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> for item in items:</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> selectionModel.select(item.index(), selectionModel.Select|selectionModel.Rows)</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">#searchAndSelect</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> </span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">Does anyone have any tips on speeding up the selection part? I’ve tried blocking the signals of the selection model incase the selectionChanged signal of QItemSelectionModel is causing a re-draw but it didn’t seem to help.</span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> </span></b></p>
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">Thanks,<br>Darryl</span></b></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt"> </span></p>
<div>
<div style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 0cm; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<p class="MsoNormal"><b><span style="FONT-SIZE: 10pt" lang="EN-US">From:</span></b><span style="FONT-SIZE: 10pt" lang="EN-US"> Darryl Wallace [mailto:<a href="mailto:darryl.wallace@prosensus.ca" target="_blank">darryl.wallace@prosensus.ca</a>] <br>
<b>Sent:</b> April-08-10 2:23 PM<br><b>To:</b> '<a href="mailto:pyqt@riverbankcomputing.com" target="_blank">pyqt@riverbankcomputing.com</a>'<br><b>Subject:</b> Fast selection of non-contiguous items in QTreeview</span></p>
</div></div>
<div>
<div></div>
<div class="h5">
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt">Hello,</span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt"> </span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt">I’ve done some reading and can’t find anything on non-contiguous selection of items in item views beyond : </span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt"> </span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt">“Selections are made up of <i>selection ranges</i>. These efficiently maintain information about large selections of items by recording only the starting and ending model indexes for each range of selected items. Non-contiguous selections of items are constructed by using more than one selection range to describe the selection.” - </span><a href="http://doc.trolltech.com/4.6/model-view-selection.html#concepts" target="_blank">http://doc.trolltech.com/4.6/model-view-selection.html#concepts</a><span style="COLOR: #1f497d; FONT-SIZE: 11pt"></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt"> </span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt">Currently we have implemented a selection of items by scanning each row in the model to see if it should be “selected” based on certain criteria. Is there a faster way to do this as looping in Python through a large (50,000 rows)? When selections can be specified with selection ranges the selection is fast. However, our worst case scenario is that every-other item need be selected: 25,000 selection ranges would be created and then we would just be looping through everything again anyways.</span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt"> </span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt">Any ideas?</span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt"> </span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt">Thanks,</span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d; FONT-SIZE: 11pt">Darryl</span></p></div></div></div></div><br>_______________________________________________<br>PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br>