Project/ProjectBrowserModel.py

changeset 2769
8cbebde7a984
parent 2763
e4794166ad70
child 2791
a9577f248f04
child 2995
63d874899b8b
equal deleted inserted replaced
2768:eab35f6e709f 2769:8cbebde7a984
583 itm = self.findItem(name) 583 itm = self.findItem(name)
584 if itm is None: 584 if itm is None:
585 index = QModelIndex() 585 index = QModelIndex()
586 else: 586 else:
587 index = self.createIndex(itm.row(), 0, itm) 587 index = self.createIndex(itm.row(), 0, itm)
588 return index
589
590 def itemIndexByNameAndLine(self, name, lineno):
591 """
592 Public method to find an item's index given its name.
593
594 @param name name of the item (string)
595 @param lineno one based line number of the item (integer)
596 @return index of the item found (QModelIndex)
597 """
598 index = QModelIndex()
599 itm = self.findItem(name)
600 if itm is not None and \
601 isinstance(itm, ProjectBrowserFileItem):
602 olditem = itm
603 autoPopulate = Preferences.getProject("AutoPopulateItems")
604 while itm is not None:
605 if not itm.isPopulated():
606 if itm.isLazyPopulated() and autoPopulate:
607 self.populateItem(itm)
608 else:
609 break
610 for child in itm.children():
611 try:
612 start, end = child.boundaries()
613 if end == -1:
614 end = 1000000 # assume end of file
615 if start <= lineno <= end:
616 itm = child
617 break
618 except AttributeError:
619 pass
620 else:
621 itm = None
622 if itm:
623 olditem = itm
624 index = self.createIndex(olditem.row(), 0, olditem)
625
588 return index 626 return index
589 627
590 def directoryChanged(self, path): 628 def directoryChanged(self, path):
591 """ 629 """
592 Public slot to handle the directoryChanged signal of the watcher. 630 Public slot to handle the directoryChanged signal of the watcher.

eric ide

mercurial