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. |