Last active
November 19, 2016 20:10
-
-
Save pashango2/2b088270a844cf207d79e0087da7cd1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def model_row_iter(model, start_index=QModelIndex()): | |
""" モデルのrowイテレータを返す | |
:type start_index: QModelIndex | |
:type model: QAbstractItemModel | |
""" | |
if start_index.isValid(): | |
yield start_index | |
while True: | |
row = start_index.row() | |
if row >= model.rowCount(start_index.parent()) - 1: | |
break | |
start_index = model.index(row + 1, 0, start_index.parent()) | |
yield start_index | |
if model.rowCount(start_index) > 0: | |
for _ in model_row_iter(model, model.index(0, 0, start_index)): | |
yield _ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment