92 @return requested data |
92 @return requested data |
93 """ |
93 """ |
94 if not index.isValid(): |
94 if not index.isValid(): |
95 return None |
95 return None |
96 |
96 |
97 if role == Qt.DisplayRole: |
97 if role == Qt.ItemDataRole.DisplayRole: |
98 item = index.internalPointer() |
98 item = index.internalPointer() |
99 if index.column() < item.columnCount(): |
99 if index.column() < item.columnCount(): |
100 return item.data(index.column()) |
100 return item.data(index.column()) |
101 elif ( |
101 elif ( |
102 index.column() == item.columnCount() and |
102 index.column() == item.columnCount() and |
103 index.column() < self.columnCount(self.parent(index)) |
103 index.column() < self.columnCount(self.parent(index)) |
104 ): |
104 ): |
105 # This is for the case where an item under a multi-column |
105 # This is for the case where an item under a multi-column |
106 # parent doesn't have a value for all the columns |
106 # parent doesn't have a value for all the columns |
107 return "" |
107 return "" |
108 elif role == Qt.DecorationRole: |
108 elif role == Qt.ItemDataRole.DecorationRole: |
109 if index.column() == 0: |
109 if index.column() == 0: |
110 return index.internalPointer().getIcon() |
110 return index.internalPointer().getIcon() |
111 elif role == Qt.FontRole: |
111 elif role == Qt.ItemDataRole.FontRole: |
112 item = index.internalPointer() |
112 item = index.internalPointer() |
113 if item.isSymlink(): |
113 if item.isSymlink(): |
114 font = QFont(QApplication.font("QTreeView")) |
114 font = QFont(QApplication.font("QTreeView")) |
115 font.setItalic(True) |
115 font.setItalic(True) |
116 return font |
116 return font |
123 |
123 |
124 @param index index of the data to retrieve (QModelIndex) |
124 @param index index of the data to retrieve (QModelIndex) |
125 @return requested flags (Qt.ItemFlags) |
125 @return requested flags (Qt.ItemFlags) |
126 """ |
126 """ |
127 if not index.isValid(): |
127 if not index.isValid(): |
128 return Qt.ItemIsEnabled |
128 return Qt.ItemFlag.ItemIsEnabled |
129 |
129 |
130 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
130 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable |
131 |
131 |
132 def headerData(self, section, orientation, role=Qt.DisplayRole): |
132 def headerData(self, section, orientation, |
|
133 role=Qt.ItemDataRole.DisplayRole): |
133 """ |
134 """ |
134 Public method to get the header data. |
135 Public method to get the header data. |
135 |
136 |
136 @param section number of section to get data for (integer) |
137 @param section number of section to get data for (integer) |
137 @param orientation header orientation (Qt.Orientation) |
138 @param orientation header orientation (Qt.Orientation) |
138 @param role role of data (Qt.ItemDataRole) |
139 @param role role of data (Qt.ItemDataRole) |
139 @return requested header data |
140 @return requested header data |
140 """ |
141 """ |
141 if orientation == Qt.Horizontal and role == Qt.DisplayRole: |
142 if ( |
|
143 orientation == Qt.Orientation.Horizontal and |
|
144 role == Qt.ItemDataRole.DisplayRole |
|
145 ): |
142 if section >= self.rootItem.columnCount(): |
146 if section >= self.rootItem.columnCount(): |
143 return "" |
147 return "" |
144 else: |
148 else: |
145 return self.rootItem.data(section) |
149 return self.rootItem.data(section) |
146 |
150 |
315 """ |
319 """ |
316 if path not in self.watchedItems: |
320 if path not in self.watchedItems: |
317 # just ignore the situation we don't have a reference to the item |
321 # just ignore the situation we don't have a reference to the item |
318 return |
322 return |
319 |
323 |
320 dirFilter = QDir.Filters(QDir.AllEntries | QDir.NoDotAndDotDot) |
324 dirFilter = QDir.Filters(QDir.Filter.AllEntries | |
|
325 QDir.Filter.NoDotAndDotDot) |
321 |
326 |
322 for itm in self.watchedItems[path]: |
327 for itm in self.watchedItems[path]: |
323 oldCnt = itm.childCount() |
328 oldCnt = itm.childCount() |
324 |
329 |
325 qdir = QDir(itm.dirName()) |
330 qdir = QDir(itm.dirName()) |
545 """ |
550 """ |
546 self._addWatchedItem(parentItem) |
551 self._addWatchedItem(parentItem) |
547 |
552 |
548 qdir = QDir(parentItem.dirName()) |
553 qdir = QDir(parentItem.dirName()) |
549 |
554 |
550 dirFilter = QDir.Filters(QDir.AllEntries | QDir.NoDotAndDotDot) |
555 dirFilter = QDir.Filters( |
|
556 QDir.Filter.AllEntries | |
|
557 QDir.Filter.NoDotAndDotDot) |
551 entryInfoList = qdir.entryInfoList(dirFilter) |
558 entryInfoList = qdir.entryInfoList(dirFilter) |
552 if len(entryInfoList) > 0: |
559 if len(entryInfoList) > 0: |
553 if repopulate: |
560 if repopulate: |
554 self.beginInsertRows( |
561 self.beginInsertRows( |
555 self.createIndex(parentItem.row(), 0, parentItem), |
562 self.createIndex(parentItem.row(), 0, parentItem), |
1098 @param order sort order (Qt.SortOrder) (for special sorting) |
1105 @param order sort order (Qt.SortOrder) (for special sorting) |
1099 @return true, if this item is less than other (boolean) |
1106 @return true, if this item is less than other (boolean) |
1100 """ |
1107 """ |
1101 if issubclass(other.__class__, BrowserFileItem): |
1108 if issubclass(other.__class__, BrowserFileItem): |
1102 if Preferences.getUI("BrowsersListFoldersFirst"): |
1109 if Preferences.getUI("BrowsersListFoldersFirst"): |
1103 return order == Qt.AscendingOrder |
1110 return order == Qt.SortOrder.AscendingOrder |
1104 |
1111 |
1105 return BrowserItem.lessThan(self, other, column, order) |
1112 return BrowserItem.lessThan(self, other, column, order) |
1106 |
1113 |
1107 |
1114 |
1108 class BrowserSysPathItem(BrowserItem): |
1115 class BrowserSysPathItem(BrowserItem): |
1407 @param order sort order (Qt.SortOrder) (for special sorting) |
1414 @param order sort order (Qt.SortOrder) (for special sorting) |
1408 @return true, if this item is less than other (boolean) |
1415 @return true, if this item is less than other (boolean) |
1409 """ |
1416 """ |
1410 if not issubclass(other.__class__, BrowserFileItem): |
1417 if not issubclass(other.__class__, BrowserFileItem): |
1411 if Preferences.getUI("BrowsersListFoldersFirst"): |
1418 if Preferences.getUI("BrowsersListFoldersFirst"): |
1412 return order == Qt.DescendingOrder |
1419 return order == Qt.SortOrder.DescendingOrder |
1413 |
1420 |
1414 if issubclass(other.__class__, BrowserFileItem): |
1421 if issubclass(other.__class__, BrowserFileItem): |
1415 sinit = os.path.basename(self._filename).startswith('__init__.py') |
1422 sinit = os.path.basename(self._filename).startswith('__init__.py') |
1416 oinit = os.path.basename(other.fileName()).startswith( |
1423 oinit = os.path.basename(other.fileName()).startswith( |
1417 '__init__.py') |
1424 '__init__.py') |
1418 if sinit and not oinit: |
1425 if sinit and not oinit: |
1419 return order == Qt.AscendingOrder |
1426 return order == Qt.SortOrder.AscendingOrder |
1420 if not sinit and oinit: |
1427 if not sinit and oinit: |
1421 return order == Qt.DescendingOrder |
1428 return order == Qt.SortOrder.DescendingOrder |
1422 |
1429 |
1423 return BrowserItem.lessThan(self, other, column, order) |
1430 return BrowserItem.lessThan(self, other, column, order) |
1424 |
1431 |
1425 |
1432 |
1426 class BrowserClassItem(BrowserItem): |
1433 class BrowserClassItem(BrowserItem): |
1553 """ |
1560 """ |
1554 if issubclass( |
1561 if issubclass( |
1555 other.__class__, |
1562 other.__class__, |
1556 (BrowserCodingItem, BrowserClassAttributesItem) |
1563 (BrowserCodingItem, BrowserClassAttributesItem) |
1557 ): |
1564 ): |
1558 return order == Qt.DescendingOrder |
1565 return order == Qt.SortOrder.DescendingOrder |
1559 |
1566 |
1560 if ( |
1567 if ( |
1561 Preferences.getUI("BrowsersListContentsByOccurrence") and |
1568 Preferences.getUI("BrowsersListContentsByOccurrence") and |
1562 column == 0 |
1569 column == 0 |
1563 ): |
1570 ): |
1564 if order == Qt.AscendingOrder: |
1571 if order == Qt.SortOrder.AscendingOrder: |
1565 return self.lineno() < other.lineno() |
1572 return self.lineno() < other.lineno() |
1566 else: |
1573 else: |
1567 return self.lineno() > other.lineno() |
1574 return self.lineno() > other.lineno() |
1568 |
1575 |
1569 return BrowserItem.lessThan(self, other, column, order) |
1576 return BrowserItem.lessThan(self, other, column, order) |
1678 @param order sort order (Qt.SortOrder) (for special sorting) |
1685 @param order sort order (Qt.SortOrder) (for special sorting) |
1679 @return true, if this item is less than other (boolean) |
1686 @return true, if this item is less than other (boolean) |
1680 """ |
1687 """ |
1681 if issubclass(other.__class__, BrowserMethodItem): |
1688 if issubclass(other.__class__, BrowserMethodItem): |
1682 if self._name.startswith('__init__'): |
1689 if self._name.startswith('__init__'): |
1683 return order == Qt.AscendingOrder |
1690 return order == Qt.SortOrder.AscendingOrder |
1684 if other._name.startswith('__init__'): |
1691 if other._name.startswith('__init__'): |
1685 return order == Qt.DescendingOrder |
1692 return order == Qt.SortOrder.DescendingOrder |
1686 elif issubclass(other.__class__, BrowserClassAttributesItem): |
1693 elif issubclass(other.__class__, BrowserClassAttributesItem): |
1687 return order == Qt.DescendingOrder |
1694 return order == Qt.SortOrder.DescendingOrder |
1688 |
1695 |
1689 if ( |
1696 if ( |
1690 Preferences.getUI("BrowsersListContentsByOccurrence") and |
1697 Preferences.getUI("BrowsersListContentsByOccurrence") and |
1691 column == 0 |
1698 column == 0 |
1692 ): |
1699 ): |
1693 if order == Qt.AscendingOrder: |
1700 if order == Qt.SortOrder.AscendingOrder: |
1694 return self.lineno() < other.lineno() |
1701 return self.lineno() < other.lineno() |
1695 else: |
1702 else: |
1696 return self.lineno() > other.lineno() |
1703 return self.lineno() > other.lineno() |
1697 |
1704 |
1698 return BrowserItem.lessThan(self, other, column, order) |
1705 return BrowserItem.lessThan(self, other, column, order) |
1763 @param column column number to use for the comparison (integer) |
1770 @param column column number to use for the comparison (integer) |
1764 @param order sort order (Qt.SortOrder) (for special sorting) |
1771 @param order sort order (Qt.SortOrder) (for special sorting) |
1765 @return true, if this item is less than other (boolean) |
1772 @return true, if this item is less than other (boolean) |
1766 """ |
1773 """ |
1767 if issubclass(other.__class__, BrowserCodingItem): |
1774 if issubclass(other.__class__, BrowserCodingItem): |
1768 return order == Qt.DescendingOrder |
1775 return order == Qt.SortOrder.DescendingOrder |
1769 elif issubclass( |
1776 elif issubclass( |
1770 other.__class__, |
1777 other.__class__, |
1771 (BrowserClassItem, BrowserMethodItem) |
1778 (BrowserClassItem, BrowserMethodItem) |
1772 ): |
1779 ): |
1773 return order == Qt.AscendingOrder |
1780 return order == Qt.SortOrder.AscendingOrder |
1774 |
1781 |
1775 return BrowserItem.lessThan(self, other, column, order) |
1782 return BrowserItem.lessThan(self, other, column, order) |
1776 |
1783 |
1777 |
1784 |
1778 class BrowserClassAttributeItem(BrowserItem): |
1785 class BrowserClassAttributeItem(BrowserItem): |
1852 """ |
1859 """ |
1853 if ( |
1860 if ( |
1854 Preferences.getUI("BrowsersListContentsByOccurrence") and |
1861 Preferences.getUI("BrowsersListContentsByOccurrence") and |
1855 column == 0 |
1862 column == 0 |
1856 ): |
1863 ): |
1857 if order == Qt.AscendingOrder: |
1864 if order == Qt.SortOrder.AscendingOrder: |
1858 return self.lineno() < other.lineno() |
1865 return self.lineno() < other.lineno() |
1859 else: |
1866 else: |
1860 return self.lineno() > other.lineno() |
1867 return self.lineno() > other.lineno() |
1861 |
1868 |
1862 return BrowserItem.lessThan(self, other, column, order) |
1869 return BrowserItem.lessThan(self, other, column, order) |
1919 """ |
1926 """ |
1920 if issubclass( |
1927 if issubclass( |
1921 other.__class__, |
1928 other.__class__, |
1922 (BrowserClassItem, BrowserClassAttributesItem, BrowserImportItem) |
1929 (BrowserClassItem, BrowserClassAttributesItem, BrowserImportItem) |
1923 ): |
1930 ): |
1924 return order == Qt.AscendingOrder |
1931 return order == Qt.SortOrder.AscendingOrder |
1925 |
1932 |
1926 return BrowserItem.lessThan(self, other, column, order) |
1933 return BrowserItem.lessThan(self, other, column, order) |
1927 |
1934 |
1928 |
1935 |
1929 class BrowserImportsItem(BrowserItem): |
1936 class BrowserImportsItem(BrowserItem): |
1953 """ |
1960 """ |
1954 if issubclass( |
1961 if issubclass( |
1955 other.__class__, |
1962 other.__class__, |
1956 (BrowserClassItem, BrowserClassAttributesItem) |
1963 (BrowserClassItem, BrowserClassAttributesItem) |
1957 ): |
1964 ): |
1958 return order == Qt.AscendingOrder |
1965 return order == Qt.SortOrder.AscendingOrder |
1959 |
1966 |
1960 return BrowserItem.lessThan(self, other, column, order) |
1967 return BrowserItem.lessThan(self, other, column, order) |
1961 |
1968 |
1962 |
1969 |
1963 class BrowserImportItem(BrowserItem): |
1970 class BrowserImportItem(BrowserItem): |
2022 """ |
2029 """ |
2023 if ( |
2030 if ( |
2024 Preferences.getUI("BrowsersListContentsByOccurrence") and |
2031 Preferences.getUI("BrowsersListContentsByOccurrence") and |
2025 column == 0 |
2032 column == 0 |
2026 ): |
2033 ): |
2027 if order == Qt.AscendingOrder: |
2034 if order == Qt.SortOrder.AscendingOrder: |
2028 return self.lineno() < other.lineno() |
2035 return self.lineno() < other.lineno() |
2029 else: |
2036 else: |
2030 return self.lineno() > other.lineno() |
2037 return self.lineno() > other.lineno() |
2031 |
2038 |
2032 return BrowserItem.lessThan(self, other, column, order) |
2039 return BrowserItem.lessThan(self, other, column, order) |