Set Qt.ItemNeverHasChildren for leaf model items.

This allows Qt to do some optimizations.
This commit is contained in:
Florian Bruhin 2015-05-18 21:35:14 +02:00
parent dd292b0781
commit 8eb483d66b
2 changed files with 3 additions and 2 deletions

View File

@ -1038,7 +1038,7 @@ class DownloadManager(QAbstractListModel):
"""Override flags so items aren't selectable.
The default would be Qt.ItemIsEnabled | Qt.ItemIsSelectable."""
return Qt.ItemIsEnabled
return Qt.ItemIsEnabled | Qt.ItemNeverHasChildren
def rowCount(self, parent=QModelIndex()):
"""Get count of active downloads."""

View File

@ -109,7 +109,8 @@ class BaseCompletionModel(QStandardItemModel):
qtutils.ensure_valid(index)
if index.parent().isValid():
# item
return Qt.ItemIsEnabled | Qt.ItemIsSelectable
return (Qt.ItemIsEnabled | Qt.ItemIsSelectable |
Qt.ItemNeverHasChildren)
else:
# category
return Qt.NoItemFlags