197 return QModelIndex() |
197 return QModelIndex() |
198 |
198 |
199 childItem = index.internalPointer() |
199 childItem = index.internalPointer() |
200 parentItem = childItem.parent() |
200 parentItem = childItem.parent() |
201 |
201 |
202 if parentItem == self.rootItem: |
202 if parentItem is None or parentItem == self.rootItem: |
203 return QModelIndex() |
203 return QModelIndex() |
204 |
204 |
205 return self.createIndex(parentItem.row(), 0, parentItem) |
205 return self.createIndex(parentItem.row(), 0, parentItem) |
206 |
206 |
207 def rowCount(self, parent=None): |
207 def rowCount(self, parent=None): |
655 pass |
655 pass |
656 if "@@Coding@@" in keys: |
656 if "@@Coding@@" in keys: |
657 node = BrowserCodingItem( |
657 node = BrowserCodingItem( |
658 parentItem, |
658 parentItem, |
659 QCoreApplication.translate("BrowserModel", "Coding: {0}") |
659 QCoreApplication.translate("BrowserModel", "Coding: {0}") |
660 .format(dictionary["@@Coding@@"].coding)) |
660 .format(dictionary["@@Coding@@"].coding), |
|
661 dictionary["@@Coding@@"].linenumber) |
661 self._addItem(node, parentItem) |
662 self._addItem(node, parentItem) |
662 if "@@Globals@@" in keys: |
663 if "@@Globals@@" in keys: |
663 node = BrowserGlobalsItem( |
664 node = BrowserGlobalsItem( |
664 parentItem, |
665 parentItem, |
665 dictionary["@@Globals@@"].globals, |
666 dictionary["@@Globals@@"].globals, |
691 isModule=False) |
692 isModule=False) |
692 self._addItem(mn_node, m_node) |
693 self._addItem(mn_node, m_node) |
693 if repopulate: |
694 if repopulate: |
694 self.endInsertRows() |
695 self.endInsertRows() |
695 parentItem._populated = True |
696 parentItem._populated = True |
696 if (parentItem.type_ == BrowserItemFile and |
697 if ( |
|
698 parentItem.type_ == BrowserItemFile and |
697 fileName not in self.watchedFileItems |
699 fileName not in self.watchedFileItems |
698 ): |
700 ): |
699 # watch the file only in the file browser not the project viewer |
701 # watch the file only in the file browser not the project viewer |
700 self.watcher.addPath(fileName) |
702 self.watcher.addPath(fileName) |
701 self.watchedFileItems[fileName] = parentItem |
703 self.watchedFileItems[fileName] = parentItem |
752 keys = [] |
754 keys = [] |
753 for name in list(cl.classes.keys()): |
755 for name in list(cl.classes.keys()): |
754 keys.append((name, 'c')) |
756 keys.append((name, 'c')) |
755 for name in list(cl.methods.keys()): |
757 for name in list(cl.methods.keys()): |
756 keys.append((name, 'm')) |
758 keys.append((name, 'm')) |
|
759 |
|
760 if len(cl.attributes): |
|
761 node = BrowserClassAttributesItem( |
|
762 parentItem, cl.attributes, |
|
763 QCoreApplication.translate("BrowserModel", "Attributes")) |
|
764 if repopulate: |
|
765 self.addItem( |
|
766 node, self.createIndex(parentItem.row(), 0, parentItem)) |
|
767 else: |
|
768 self._addItem(node, parentItem) |
|
769 |
|
770 if len(cl.globals): |
|
771 node = BrowserClassAttributesItem( |
|
772 parentItem, cl.globals, |
|
773 QCoreApplication.translate("BrowserModel", "Class Attributes"), |
|
774 True) |
|
775 if repopulate: |
|
776 self.addItem( |
|
777 node, self.createIndex(parentItem.row(), 0, parentItem)) |
|
778 else: |
|
779 self._addItem(node, parentItem) |
757 |
780 |
758 if len(keys) > 0: |
781 if len(keys) > 0: |
759 if repopulate: |
782 if repopulate: |
760 self.beginInsertRows( |
783 self.beginInsertRows( |
761 self.createIndex(parentItem.row(), 0, parentItem), |
784 self.createIndex(parentItem.row(), 0, parentItem), |
767 node = BrowserMethodItem(parentItem, cl.methods[key], |
790 node = BrowserMethodItem(parentItem, cl.methods[key], |
768 file_) |
791 file_) |
769 self._addItem(node, parentItem) |
792 self._addItem(node, parentItem) |
770 if repopulate: |
793 if repopulate: |
771 self.endInsertRows() |
794 self.endInsertRows() |
772 |
|
773 if len(cl.attributes): |
|
774 node = BrowserClassAttributesItem( |
|
775 parentItem, cl.attributes, |
|
776 QCoreApplication.translate("BrowserModel", "Attributes")) |
|
777 if repopulate: |
|
778 self.addItem( |
|
779 node, self.createIndex(parentItem.row(), 0, parentItem)) |
|
780 else: |
|
781 self._addItem(node, parentItem) |
|
782 |
|
783 if len(cl.globals): |
|
784 node = BrowserClassAttributesItem( |
|
785 parentItem, cl.globals, |
|
786 QCoreApplication.translate("BrowserModel", "Class Attributes"), |
|
787 True) |
|
788 if repopulate: |
|
789 self.addItem( |
|
790 node, self.createIndex(parentItem.row(), 0, parentItem)) |
|
791 else: |
|
792 self._addItem(node, parentItem) |
|
793 |
795 |
794 def populateMethodItem(self, parentItem, repopulate=False): |
796 def populateMethodItem(self, parentItem, repopulate=False): |
795 """ |
797 """ |
796 Public method to populate a method item's subtree. |
798 Public method to populate a method item's subtree. |
797 |
799 |
1860 |
1862 |
1861 class BrowserCodingItem(BrowserItem): |
1863 class BrowserCodingItem(BrowserItem): |
1862 """ |
1864 """ |
1863 Class implementing the data structure for browser coding items. |
1865 Class implementing the data structure for browser coding items. |
1864 """ |
1866 """ |
1865 def __init__(self, parent, text): |
1867 def __init__(self, parent, text, linenumber): |
1866 """ |
1868 """ |
1867 Constructor |
1869 Constructor |
1868 |
1870 |
1869 @param parent parent item |
1871 @param parent parent item |
1870 @param text text to be shown by this item (string) |
1872 @type BrowserItem |
|
1873 @param text text to be shown by this item |
|
1874 @type str |
|
1875 @param linenumber line number of the coding line |
|
1876 @type int |
1871 """ |
1877 """ |
1872 BrowserItem.__init__(self, parent, text) |
1878 BrowserItem.__init__(self, parent, text) |
1873 |
1879 |
1874 self.type_ = BrowserItemCoding |
1880 self.type_ = BrowserItemCoding |
1875 self.icon = UI.PixmapCache.getIcon("textencoding") |
1881 self.icon = UI.PixmapCache.getIcon("textencoding") |
|
1882 |
|
1883 self.__lineno = linenumber |
|
1884 |
|
1885 def lineno(self): |
|
1886 """ |
|
1887 Public method returning the line number of the coding line. |
|
1888 |
|
1889 @return line number defining the coding line |
|
1890 @rtype int |
|
1891 """ |
|
1892 return self.__lineno |
1876 |
1893 |
1877 def lessThan(self, other, column, order): |
1894 def lessThan(self, other, column, order): |
1878 """ |
1895 """ |
1879 Public method to check, if the item is less than the other one. |
1896 Public method to check, if the item is less than the other one. |
1880 |
1897 |