28 from eric7.EricGui import EricPixmapCache |
28 from eric7.EricGui import EricPixmapCache |
29 from eric7.SystemUtilities import FileSystemUtilities |
29 from eric7.SystemUtilities import FileSystemUtilities |
30 from eric7.Utilities import ClassBrowsers |
30 from eric7.Utilities import ClassBrowsers |
31 from eric7.Utilities.ClassBrowsers import ClbrBaseClasses |
31 from eric7.Utilities.ClassBrowsers import ClbrBaseClasses |
32 |
32 |
|
33 # TODO: change this to enum.Enum |
33 BrowserItemRoot = 0 |
34 BrowserItemRoot = 0 |
34 BrowserItemSimpleDirectory = 1 |
35 BrowserItemSimpleDirectory = 1 |
35 BrowserItemDirectory = 2 |
36 BrowserItemDirectory = 2 |
36 BrowserItemSysPath = 3 |
37 BrowserItemSysPath = 3 |
37 BrowserItemFile = 4 |
38 BrowserItemFile = 4 |
78 |
80 |
79 def columnCount(self, parent=None): |
81 def columnCount(self, parent=None): |
80 """ |
82 """ |
81 Public method to get the number of columns. |
83 Public method to get the number of columns. |
82 |
84 |
83 @param parent index of parent item (QModelIndex) |
85 @param parent index of parent item |
84 @return number of columns (integer) |
86 @type QModelIndex |
|
87 @return number of columns |
|
88 @rtype int |
85 """ |
89 """ |
86 if parent is None: |
90 if parent is None: |
87 parent = QModelIndex() |
91 parent = QModelIndex() |
88 |
92 |
89 item = parent.internalPointer() if parent.isValid() else self.rootItem |
93 item = parent.internalPointer() if parent.isValid() else self.rootItem |
92 |
96 |
93 def data(self, index, role): |
97 def data(self, index, role): |
94 """ |
98 """ |
95 Public method to get data of an item. |
99 Public method to get data of an item. |
96 |
100 |
97 @param index index of the data to retrieve (QModelIndex) |
101 @param index index of the data to retrieve |
98 @param role role of data (Qt.ItemDataRole) |
102 @type QModelIndex |
|
103 @param role role of data |
|
104 @type Qt.ItemDataRole |
99 @return requested data |
105 @return requested data |
|
106 @rtype Any |
100 """ |
107 """ |
101 if not index.isValid(): |
108 if not index.isValid(): |
102 return None |
109 return None |
103 |
110 |
104 if role == Qt.ItemDataRole.DisplayRole: |
111 if role == Qt.ItemDataRole.DisplayRole: |
126 |
133 |
127 def flags(self, index): |
134 def flags(self, index): |
128 """ |
135 """ |
129 Public method to get the item flags. |
136 Public method to get the item flags. |
130 |
137 |
131 @param index index of the data to retrieve (QModelIndex) |
138 @param index index of the data to retrieve |
132 @return requested flags (Qt.ItemFlags) |
139 @type QModelIndex |
|
140 @return requested flags |
|
141 @rtype Qt.ItemFlags |
133 """ |
142 """ |
134 if not index.isValid(): |
143 if not index.isValid(): |
135 return Qt.ItemFlag.ItemIsEnabled |
144 return Qt.ItemFlag.ItemIsEnabled |
136 |
145 |
137 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable |
146 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable |
138 |
147 |
139 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
148 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
140 """ |
149 """ |
141 Public method to get the header data. |
150 Public method to get the header data. |
142 |
151 |
143 @param section number of section to get data for (integer) |
152 @param section number of section to get data for |
144 @param orientation header orientation (Qt.Orientation) |
153 @type int |
145 @param role role of data (Qt.ItemDataRole) |
154 @param orientation header orientation |
|
155 @type Qt.Orientation |
|
156 @param role role of data |
|
157 @type Qt.ItemDataRole |
146 @return requested header data |
158 @return requested header data |
|
159 @rtype Any |
147 """ |
160 """ |
148 if ( |
161 if ( |
149 orientation == Qt.Orientation.Horizontal |
162 orientation == Qt.Orientation.Horizontal |
150 and role == Qt.ItemDataRole.DisplayRole |
163 and role == Qt.ItemDataRole.DisplayRole |
151 ): |
164 ): |
158 |
171 |
159 def index(self, row, column, parent=None): |
172 def index(self, row, column, parent=None): |
160 """ |
173 """ |
161 Public method to create an index. |
174 Public method to create an index. |
162 |
175 |
163 @param row row number of the new index (integer) |
176 @param row row number of the new index |
164 @param column column number of the new index (integer) |
177 @type int |
165 @param parent index of parent item (QModelIndex) |
178 @param column column number of the new index |
166 @return index object (QModelIndex) |
179 @type int |
|
180 @param parent index of parent item |
|
181 @type QModelIndex |
|
182 @return index object |
|
183 @rtype QModelIndex |
167 """ |
184 """ |
168 if parent is None: |
185 if parent is None: |
169 parent = QModelIndex() |
186 parent = QModelIndex() |
170 |
187 |
171 # The model/view framework considers negative values out-of-bounds, |
188 # The model/view framework considers negative values out-of-bounds, |
194 |
211 |
195 def parent(self, index): |
212 def parent(self, index): |
196 """ |
213 """ |
197 Public method to get the index of the parent object. |
214 Public method to get the index of the parent object. |
198 |
215 |
199 @param index index of the item (QModelIndex) |
216 @param index index of the item |
200 @return index of parent item (QModelIndex) |
217 @type QModelIndex |
|
218 @return index of parent item |
|
219 @rtype QModelIndex |
201 """ |
220 """ |
202 if not index.isValid(): |
221 if not index.isValid(): |
203 return QModelIndex() |
222 return QModelIndex() |
204 |
223 |
205 childItem = index.internalPointer() |
224 childItem = index.internalPointer() |
212 |
231 |
213 def rowCount(self, parent=None): |
232 def rowCount(self, parent=None): |
214 """ |
233 """ |
215 Public method to get the number of rows. |
234 Public method to get the number of rows. |
216 |
235 |
217 @param parent index of parent item (QModelIndex) |
236 @param parent index of parent item |
218 @return number of rows (integer) |
237 @type QModelIndex |
|
238 @return number of rows |
|
239 @rtype int |
219 """ |
240 """ |
220 if parent is None: |
241 if parent is None: |
221 parent = QModelIndex() |
242 parent = QModelIndex() |
222 |
243 |
223 # Only the first column should have children |
244 # Only the first column should have children |
238 Public method to check for the presence of child items. |
259 Public method to check for the presence of child items. |
239 |
260 |
240 We always return True for normal items in order to do lazy |
261 We always return True for normal items in order to do lazy |
241 population of the tree. |
262 population of the tree. |
242 |
263 |
243 @param parent index of parent item (QModelIndex) |
264 @param parent index of parent item |
244 @return flag indicating the presence of child items (boolean) |
265 @type QModelIndex |
|
266 @return flag indicating the presence of child items |
|
267 @rtype bool |
245 """ |
268 """ |
246 if parent is None: |
269 if parent is None: |
247 parent = QModelIndex() |
270 parent = QModelIndex() |
248 |
271 |
249 # Only the first column should have children |
272 # Only the first column should have children |
268 |
291 |
269 def item(self, index): |
292 def item(self, index): |
270 """ |
293 """ |
271 Public method to get a reference to an item. |
294 Public method to get a reference to an item. |
272 |
295 |
273 @param index index of the data to retrieve (QModelIndex) |
296 @param index index of the data to retrieve |
274 @return requested item reference (BrowserItem) |
297 @type QModelIndex |
|
298 @return requested item reference |
|
299 @rtype BrowserItem |
275 """ |
300 """ |
276 if not index.isValid(): |
301 if not index.isValid(): |
277 return None |
302 return None |
278 |
303 |
279 return index.internalPointer() |
304 return index.internalPointer() |
280 |
305 |
281 def _addWatchedItem(self, itm): |
306 def _addWatchedItem(self, itm): |
282 """ |
307 """ |
283 Protected method to watch an item. |
308 Protected method to watch an item. |
284 |
309 |
285 @param itm item to be watched (BrowserDirectoryItem) |
310 @param itm item to be watched |
|
311 @type BrowserDirectoryItem |
286 """ |
312 """ |
287 if isinstance(itm, BrowserDirectoryItem): |
313 if isinstance(itm, BrowserDirectoryItem): |
288 dirName = itm.dirName() |
314 dirName = itm.dirName() |
289 if ( |
315 if ( |
290 dirName != "" |
316 dirName != "" |
301 |
327 |
302 def _removeWatchedItem(self, itm): |
328 def _removeWatchedItem(self, itm): |
303 """ |
329 """ |
304 Protected method to remove a watched item. |
330 Protected method to remove a watched item. |
305 |
331 |
306 @param itm item to be removed (BrowserDirectoryItem) |
332 @param itm item to be removed |
|
333 @type BrowserDirectoryItem |
307 """ |
334 """ |
308 if isinstance(itm, BrowserDirectoryItem): |
335 if isinstance(itm, BrowserDirectoryItem): |
309 dirName = itm.dirName() |
336 dirName = itm.dirName() |
310 if dirName in self.watchedItems: |
337 if dirName in self.watchedItems: |
311 if itm in self.watchedItems[dirName]: |
338 if itm in self.watchedItems[dirName]: |
407 |
435 |
408 def interpreterChanged(self, interpreter): |
436 def interpreterChanged(self, interpreter): |
409 """ |
437 """ |
410 Public method to handle a change of the debug client's interpreter. |
438 Public method to handle a change of the debug client's interpreter. |
411 |
439 |
412 @param interpreter interpreter of the debug client (string) |
440 @param interpreter interpreter of the debug client |
|
441 @type str |
413 """ |
442 """ |
414 if interpreter and "python" in interpreter.lower(): |
443 if interpreter and "python" in interpreter.lower(): |
415 if interpreter.endswith("w.exe"): |
444 if interpreter.endswith("w.exe"): |
416 interpreter = interpreter.replace("w.exe", ".exe") |
445 interpreter = interpreter.replace("w.exe", ".exe") |
417 if self.__sysPathInterpreter != interpreter: |
446 if self.__sysPathInterpreter != interpreter: |
466 |
496 |
467 def addTopLevelDir(self, dirname): |
497 def addTopLevelDir(self, dirname): |
468 """ |
498 """ |
469 Public method to add a new toplevel directory. |
499 Public method to add a new toplevel directory. |
470 |
500 |
471 @param dirname name of the new toplevel directory (string) |
501 @param dirname name of the new toplevel directory |
|
502 @type str |
472 """ |
503 """ |
473 if dirname not in self.toplevelDirs: |
504 if dirname not in self.toplevelDirs: |
474 itm = BrowserDirectoryItem(self.rootItem, dirname) |
505 itm = BrowserDirectoryItem(self.rootItem, dirname) |
475 self.addItem(itm) |
506 self.addItem(itm) |
476 self.toplevelDirs.append(itm.dirName()) |
507 self.toplevelDirs.append(itm.dirName()) |
503 |
534 |
504 def _addItem(self, itm, parentItem): |
535 def _addItem(self, itm, parentItem): |
505 """ |
536 """ |
506 Protected slot to add an item. |
537 Protected slot to add an item. |
507 |
538 |
508 @param itm reference to item to add (BrowserItem) |
539 @param itm reference to item to add |
509 @param parentItem reference to item to add to (BrowserItem) |
540 @type BrowserItem |
|
541 @param parentItem reference to item to add to |
|
542 @type BrowserItem |
510 """ |
543 """ |
511 parentItem.appendChild(itm) |
544 parentItem.appendChild(itm) |
512 |
545 |
513 def addItem(self, itm, parent=None): |
546 def addItem(self, itm, parent=None): |
514 """ |
547 """ |
515 Public slot to add an item. |
548 Public slot to add an item. |
516 |
549 |
517 @param itm item to add (BrowserItem) |
550 @param itm item to add |
518 @param parent index of parent item (QModelIndex) |
551 @type BrowserItem |
|
552 @param parent index of parent item |
|
553 @type QModelIndex |
519 """ |
554 """ |
520 if parent is None: |
555 if parent is None: |
521 parent = QModelIndex() |
556 parent = QModelIndex() |
522 |
557 |
523 parentItem = parent.internalPointer() if parent.isValid() else self.rootItem |
558 parentItem = parent.internalPointer() if parent.isValid() else self.rootItem |
530 def populateItem(self, parentItem, repopulate=False): |
565 def populateItem(self, parentItem, repopulate=False): |
531 """ |
566 """ |
532 Public method to populate an item's subtree. |
567 Public method to populate an item's subtree. |
533 |
568 |
534 @param parentItem reference to the item to be populated |
569 @param parentItem reference to the item to be populated |
535 @param repopulate flag indicating a repopulation (boolean) |
570 @type BrowserItem |
|
571 @param repopulate flag indicating a repopulation |
|
572 @type bool |
536 """ |
573 """ |
537 if parentItem.type() == BrowserItemDirectory: |
574 if parentItem.type() == BrowserItemDirectory: |
538 self.populateDirectoryItem(parentItem, repopulate) |
575 self.populateDirectoryItem(parentItem, repopulate) |
539 elif parentItem.type() == BrowserItemSysPath: |
576 elif parentItem.type() == BrowserItemSysPath: |
540 self.populateSysPathItem(parentItem, repopulate) |
577 self.populateSysPathItem(parentItem, repopulate) |
550 def populateDirectoryItem(self, parentItem, repopulate=False): |
587 def populateDirectoryItem(self, parentItem, repopulate=False): |
551 """ |
588 """ |
552 Public method to populate a directory item's subtree. |
589 Public method to populate a directory item's subtree. |
553 |
590 |
554 @param parentItem reference to the directory item to be populated |
591 @param parentItem reference to the directory item to be populated |
555 @param repopulate flag indicating a repopulation (boolean) |
592 @type BrowserDirectoryItem |
|
593 @param repopulate flag indicating a repopulation |
|
594 @type bool |
556 """ |
595 """ |
557 self._addWatchedItem(parentItem) |
596 self._addWatchedItem(parentItem) |
558 |
597 |
559 qdir = QDir(parentItem.dirName()) |
598 qdir = QDir(parentItem.dirName()) |
560 |
599 |
593 def populateSysPathItem(self, parentItem, repopulate=False): |
632 def populateSysPathItem(self, parentItem, repopulate=False): |
594 """ |
633 """ |
595 Public method to populate a sys.path item's subtree. |
634 Public method to populate a sys.path item's subtree. |
596 |
635 |
597 @param parentItem reference to the sys.path item to be populated |
636 @param parentItem reference to the sys.path item to be populated |
598 @param repopulate flag indicating a repopulation (boolean) |
637 @type BrowserSysPathItem |
|
638 @param repopulate flag indicating a repopulation |
|
639 @type bool |
599 """ |
640 """ |
600 if self.__sysPathInterpreter: |
641 if self.__sysPathInterpreter: |
601 script = "import sys, json; print(json.dumps(sys.path))" |
642 script = "import sys, json; print(json.dumps(sys.path))" |
602 proc = QProcess() |
643 proc = QProcess() |
603 proc.start(self.__sysPathInterpreter, ["-c", script]) |
644 proc.start(self.__sysPathInterpreter, ["-c", script]) |
631 def populateFileItem(self, parentItem, repopulate=False): |
672 def populateFileItem(self, parentItem, repopulate=False): |
632 """ |
673 """ |
633 Public method to populate a file item's subtree. |
674 Public method to populate a file item's subtree. |
634 |
675 |
635 @param parentItem reference to the file item to be populated |
676 @param parentItem reference to the file item to be populated |
636 @param repopulate flag indicating a repopulation (boolean) |
677 @type BrowserFileItem |
|
678 @param repopulate flag indicating a repopulation |
|
679 @type bool |
637 """ |
680 """ |
638 from eric7.Utilities import ClassBrowsers |
681 from eric7.Utilities import ClassBrowsers |
639 |
682 |
640 moduleName = parentItem.moduleName() |
683 moduleName = parentItem.moduleName() |
641 fileName = parentItem.fileName() |
684 fileName = parentItem.fileName() |
762 def populateClassItem(self, parentItem, repopulate=False): |
805 def populateClassItem(self, parentItem, repopulate=False): |
763 """ |
806 """ |
764 Public method to populate a class item's subtree. |
807 Public method to populate a class item's subtree. |
765 |
808 |
766 @param parentItem reference to the class item to be populated |
809 @param parentItem reference to the class item to be populated |
767 @param repopulate flag indicating a repopulation (boolean) |
810 @type BrowserClassItem |
|
811 @param repopulate flag indicating a repopulation |
|
812 @type bool |
768 """ |
813 """ |
769 cl = parentItem.classObject() |
814 cl = parentItem.classObject() |
770 file_ = parentItem.fileName() |
815 file_ = parentItem.fileName() |
771 |
816 |
772 if cl is None: |
817 if cl is None: |
819 def populateMethodItem(self, parentItem, repopulate=False): |
864 def populateMethodItem(self, parentItem, repopulate=False): |
820 """ |
865 """ |
821 Public method to populate a method item's subtree. |
866 Public method to populate a method item's subtree. |
822 |
867 |
823 @param parentItem reference to the method item to be populated |
868 @param parentItem reference to the method item to be populated |
824 @param repopulate flag indicating a repopulation (boolean) |
869 @type BrowserItem |
|
870 @param repopulate flag indicating a repopulation |
|
871 @type bool |
825 """ |
872 """ |
826 fn = parentItem.functionObject() |
873 fn = parentItem.functionObject() |
827 file_ = parentItem.fileName() |
874 file_ = parentItem.fileName() |
828 |
875 |
829 if fn is None: |
876 if fn is None: |
902 |
953 |
903 def appendChild(self, child): |
954 def appendChild(self, child): |
904 """ |
955 """ |
905 Public method to add a child to this item. |
956 Public method to add a child to this item. |
906 |
957 |
907 @param child reference to the child item to add (BrowserItem) |
958 @param child reference to the child item to add |
|
959 @type BrowserItem |
908 """ |
960 """ |
909 self.childItems.append(child) |
961 self.childItems.append(child) |
910 self._populated = True |
962 self._populated = True |
911 |
963 |
912 def removeChild(self, child): |
964 def removeChild(self, child): |
913 """ |
965 """ |
914 Public method to remove a child. |
966 Public method to remove a child. |
915 |
967 |
916 @param child reference to the child to remove (BrowserItem) |
968 @param child reference to the child to remove |
|
969 @type BrowserItem |
917 """ |
970 """ |
918 self.childItems.remove(child) |
971 self.childItems.remove(child) |
919 |
972 |
920 def removeChildren(self): |
973 def removeChildren(self): |
921 """ |
974 """ |
925 |
978 |
926 def child(self, row): |
979 def child(self, row): |
927 """ |
980 """ |
928 Public method to get a child id. |
981 Public method to get a child id. |
929 |
982 |
930 @param row number of child to get the id of (integer) |
983 @param row number of child to get the id of |
931 @return reference to the child item (BrowserItem) |
984 @type int |
|
985 @return reference to the child item |
|
986 @rtype BrowserItem |
932 """ |
987 """ |
933 return self.childItems[row] |
988 return self.childItems[row] |
934 |
989 |
935 def children(self): |
990 def children(self): |
936 """ |
991 """ |
937 Public method to get the ids of all child items. |
992 Public method to get the ids of all child items. |
938 |
993 |
939 @return references to all child items (list of BrowserItem) |
994 @return references to all child items |
|
995 @rtype list of BrowserItem |
940 """ |
996 """ |
941 return self.childItems[:] |
997 return self.childItems[:] |
942 |
998 |
943 def childCount(self): |
999 def childCount(self): |
944 """ |
1000 """ |
945 Public method to get the number of available child items. |
1001 Public method to get the number of available child items. |
946 |
1002 |
947 @return number of child items (integer) |
1003 @return number of child items |
|
1004 @rtype int |
948 """ |
1005 """ |
949 return len(self.childItems) |
1006 return len(self.childItems) |
950 |
1007 |
951 def columnCount(self): |
1008 def columnCount(self): |
952 """ |
1009 """ |
953 Public method to get the number of available data items. |
1010 Public method to get the number of available data items. |
954 |
1011 |
955 @return number of data items (integer) |
1012 @return number of data items |
|
1013 @rtype int |
956 """ |
1014 """ |
957 return len(self.itemData) |
1015 return len(self.itemData) |
958 |
1016 |
959 def data(self, column): |
1017 def data(self, column): |
960 """ |
1018 """ |
961 Public method to get a specific data item. |
1019 Public method to get a specific data item. |
962 |
1020 |
963 @param column number of the requested data item (integer) |
1021 @param column number of the requested data item |
|
1022 @type int |
964 @return stored data item |
1023 @return stored data item |
|
1024 @rtype Any |
965 """ |
1025 """ |
966 try: |
1026 try: |
967 return self.itemData[column] |
1027 return self.itemData[column] |
968 except IndexError: |
1028 except IndexError: |
969 return "" |
1029 return "" |
990 def type(self): |
1052 def type(self): |
991 """ |
1053 """ |
992 Public method to get the item type. |
1054 Public method to get the item type. |
993 |
1055 |
994 @return type of the item |
1056 @return type of the item |
995 """ |
1057 @rtype int |
|
1058 """ |
|
1059 # TODO: change this to reference the new Enum |
996 return self.type_ |
1060 return self.type_ |
997 |
1061 |
998 def isPublic(self): |
1062 def isPublic(self): |
999 """ |
1063 """ |
1000 Public method returning the public visibility status. |
1064 Public method returning the public visibility status. |
1001 |
1065 |
1002 @return flag indicating public visibility (boolean) |
1066 @return flag indicating public visibility |
|
1067 @rtype bool |
1003 """ |
1068 """ |
1004 return True |
1069 return True |
1005 |
1070 |
1006 def getIcon(self): |
1071 def getIcon(self): |
1007 """ |
1072 """ |
1008 Public method to get the items icon. |
1073 Public method to get the items icon. |
1009 |
1074 |
1010 @return the icon (QIcon) |
1075 @return the icon |
|
1076 @rtype QIcon |
1011 """ |
1077 """ |
1012 return self.icon |
1078 return self.icon |
1013 |
1079 |
1014 def isPopulated(self): |
1080 def isPopulated(self): |
1015 """ |
1081 """ |
1016 Public method to chek, if this item is populated. |
1082 Public method to chek, if this item is populated. |
1017 |
1083 |
1018 @return population status (boolean) |
1084 @return population status |
|
1085 @rtype bool |
1019 """ |
1086 """ |
1020 return self._populated |
1087 return self._populated |
1021 |
1088 |
1022 def isLazyPopulated(self): |
1089 def isLazyPopulated(self): |
1023 """ |
1090 """ |
1024 Public method to check, if this item should be populated lazyly. |
1091 Public method to check, if this item should be populated lazyly. |
1025 |
1092 |
1026 @return lazy population flag (boolean) |
1093 @return lazy population flag |
|
1094 @rtype bool |
1027 """ |
1095 """ |
1028 return self._lazyPopulation |
1096 return self._lazyPopulation |
1029 |
1097 |
1030 def lessThan(self, other, column, order): # noqa: U100 |
1098 def lessThan(self, other, column, order): # noqa: U100 |
1031 """ |
1099 """ |
1032 Public method to check, if the item is less than the other one. |
1100 Public method to check, if the item is less than the other one. |
1033 |
1101 |
1034 @param other reference to item to compare against (BrowserItem) |
1102 @param other reference to item to compare against |
1035 @param column column number to use for the comparison (integer) |
1103 @type BrowserItem |
1036 @param order sort order (Qt.SortOrder) (for special sorting) |
1104 @param column column number to use for the comparison |
1037 @return true, if this item is less than other (boolean) |
1105 @type int |
|
1106 @param order sort order (for special sorting) |
|
1107 @type Qt.SortOrder |
|
1108 @return true, if this item is less than other |
|
1109 @rtype bool |
1038 """ |
1110 """ |
1039 try: |
1111 try: |
1040 return self.itemData[column] < other.itemData[column] |
1112 return self.itemData[column] < other.itemData[column] |
1041 except IndexError: |
1113 except IndexError: |
1042 return False |
1114 return False |
1043 |
1115 |
1044 def isSymlink(self): |
1116 def isSymlink(self): |
1045 """ |
1117 """ |
1046 Public method to check, if the items is a symbolic link. |
1118 Public method to check, if the items is a symbolic link. |
1047 |
1119 |
1048 @return flag indicating a symbolic link (boolean) |
1120 @return flag indicating a symbolic link |
|
1121 @rtype bool |
1049 """ |
1122 """ |
1050 return self.symlink |
1123 return self.symlink |
1051 |
1124 |
1052 |
1125 |
1053 class BrowserSimpleDirectoryItem(BrowserItem): |
1126 class BrowserSimpleDirectoryItem(BrowserItem): |
1058 def __init__(self, parent, text, path=""): |
1131 def __init__(self, parent, text, path=""): |
1059 """ |
1132 """ |
1060 Constructor |
1133 Constructor |
1061 |
1134 |
1062 @param parent parent item |
1135 @param parent parent item |
1063 @param text text to be displayed (string) |
1136 @type BrowserItem |
1064 @param path path of the directory (string) |
1137 @param text text to be displayed |
|
1138 @type str |
|
1139 @param path path of the directory |
|
1140 @type str |
1065 """ |
1141 """ |
1066 BrowserItem.__init__(self, parent, text) |
1142 BrowserItem.__init__(self, parent, text) |
1067 |
1143 |
1068 self.type_ = BrowserItemSimpleDirectory |
1144 self.type_ = BrowserItemSimpleDirectory |
1069 |
1145 |
1079 |
1155 |
1080 def setName(self, dinfo, full=True): # noqa: U100 |
1156 def setName(self, dinfo, full=True): # noqa: U100 |
1081 """ |
1157 """ |
1082 Public method to set the directory name. |
1158 Public method to set the directory name. |
1083 |
1159 |
1084 @param dinfo dinfo is the string for the directory (string) |
1160 @param dinfo dinfo is the string for the directory |
1085 @param full flag indicating full path name should be displayed (boolean) |
1161 @type str |
|
1162 @param full flag indicating full path name should be displayed |
|
1163 @type bool |
1086 """ |
1164 """ |
1087 self._dirName = os.path.abspath(dinfo) |
1165 self._dirName = os.path.abspath(dinfo) |
1088 self.itemData[0] = os.path.basename(self._dirName) |
1166 self.itemData[0] = os.path.basename(self._dirName) |
1089 |
1167 |
1090 def dirName(self): |
1168 def dirName(self): |
1091 """ |
1169 """ |
1092 Public method returning the directory name. |
1170 Public method returning the directory name. |
1093 |
1171 |
1094 @return directory name (string) |
1172 @return directory name |
|
1173 @rtype str |
1095 """ |
1174 """ |
1096 return self._dirName |
1175 return self._dirName |
1097 |
1176 |
1098 def name(self): |
1177 def name(self): |
1099 """ |
1178 """ |
1100 Public method to return the name of the item. |
1179 Public method to return the name of the item. |
1101 |
1180 |
1102 @return name of the item (string) |
1181 @return name of the item |
|
1182 @rtype str |
1103 """ |
1183 """ |
1104 return self._dirName |
1184 return self._dirName |
1105 |
1185 |
1106 def lessThan(self, other, column, order): |
1186 def lessThan(self, other, column, order): |
1107 """ |
1187 """ |
1108 Public method to check, if the item is less than the other one. |
1188 Public method to check, if the item is less than the other one. |
1109 |
1189 |
1110 @param other reference to item to compare against (BrowserItem) |
1190 @param other reference to item to compare against |
1111 @param column column number to use for the comparison (integer) |
1191 @type BrowserItem |
1112 @param order sort order (Qt.SortOrder) (for special sorting) |
1192 @param column column number to use for the comparison |
1113 @return true, if this item is less than other (boolean) |
1193 @type int |
|
1194 @param order sort order (for special sorting) |
|
1195 @type Qt.SortOrder |
|
1196 @return true, if this item is less than other |
|
1197 @rtype bool |
1114 """ |
1198 """ |
1115 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
1199 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
1116 "BrowsersListFoldersFirst" |
1200 "BrowsersListFoldersFirst" |
1117 ): |
1201 ): |
1118 return order == Qt.SortOrder.AscendingOrder |
1202 return order == Qt.SortOrder.AscendingOrder |
1128 def __init__(self, parent, dinfo, full=True): |
1212 def __init__(self, parent, dinfo, full=True): |
1129 """ |
1213 """ |
1130 Constructor |
1214 Constructor |
1131 |
1215 |
1132 @param parent parent item |
1216 @param parent parent item |
1133 @param dinfo dinfo is the string for the directory (string) |
1217 @type BrowserItem |
1134 @param full flag indicating full pathname should be displayed (boolean) |
1218 @param dinfo dinfo is the string for the directory |
|
1219 @type str |
|
1220 @param full flag indicating full pathname should be displayed |
|
1221 @type bool |
1135 """ |
1222 """ |
1136 self._dirName = os.path.abspath(dinfo) |
1223 self._dirName = os.path.abspath(dinfo) |
1137 dn = self._dirName if full else os.path.basename(self._dirName) |
1224 dn = self._dirName if full else os.path.basename(self._dirName) |
1138 BrowserItem.__init__(self, parent, dn) |
1225 BrowserItem.__init__(self, parent, dn) |
1139 |
1226 |
1152 |
1239 |
1153 def setName(self, dinfo, full=True): |
1240 def setName(self, dinfo, full=True): |
1154 """ |
1241 """ |
1155 Public method to set the directory name. |
1242 Public method to set the directory name. |
1156 |
1243 |
1157 @param dinfo dinfo is the string for the directory (string) |
1244 @param dinfo dinfo is the string for the directory |
1158 @param full flag indicating full pathname should be displayed (boolean) |
1245 @type str |
|
1246 @param full flag indicating full pathname should be displayed |
|
1247 @type bool |
1159 """ |
1248 """ |
1160 self._dirName = os.path.abspath(dinfo) |
1249 self._dirName = os.path.abspath(dinfo) |
1161 dn = self._dirName if full else os.path.basename(self._dirName) |
1250 dn = self._dirName if full else os.path.basename(self._dirName) |
1162 self.itemData[0] = dn |
1251 self.itemData[0] = dn |
1163 |
1252 |
1164 def dirName(self): |
1253 def dirName(self): |
1165 """ |
1254 """ |
1166 Public method returning the directory name. |
1255 Public method returning the directory name. |
1167 |
1256 |
1168 @return directory name (string) |
1257 @return directory name |
|
1258 @rtype str |
1169 """ |
1259 """ |
1170 return self._dirName |
1260 return self._dirName |
1171 |
1261 |
1172 def name(self): |
1262 def name(self): |
1173 """ |
1263 """ |
1174 Public method to return the name of the item. |
1264 Public method to return the name of the item. |
1175 |
1265 |
1176 @return name of the item (string) |
1266 @return name of the item |
|
1267 @rtype str |
1177 """ |
1268 """ |
1178 return self._dirName |
1269 return self._dirName |
1179 |
1270 |
1180 def lessThan(self, other, column, order): |
1271 def lessThan(self, other, column, order): |
1181 """ |
1272 """ |
1182 Public method to check, if the item is less than the other one. |
1273 Public method to check, if the item is less than the other one. |
1183 |
1274 |
1184 @param other reference to item to compare against (BrowserItem) |
1275 @param other reference to item to compare against |
1185 @param column column number to use for the comparison (integer) |
1276 @type BrowserItem |
1186 @param order sort order (Qt.SortOrder) (for special sorting) |
1277 @param column column number to use for the comparison |
1187 @return true, if this item is less than other (boolean) |
1278 @type int |
|
1279 @param order sort order (for special sorting) |
|
1280 @type Qt.SortOrder |
|
1281 @return true, if this item is less than other |
|
1282 @rtype bool |
1188 """ |
1283 """ |
1189 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
1284 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
1190 "BrowsersListFoldersFirst" |
1285 "BrowsersListFoldersFirst" |
1191 ): |
1286 ): |
1192 return order == Qt.SortOrder.AscendingOrder |
1287 return order == Qt.SortOrder.AscendingOrder |
1229 def __init__(self, parent, finfo, full=True, sourceLanguage=""): |
1326 def __init__(self, parent, finfo, full=True, sourceLanguage=""): |
1230 """ |
1327 """ |
1231 Constructor |
1328 Constructor |
1232 |
1329 |
1233 @param parent parent item |
1330 @param parent parent item |
1234 @param finfo the string for the file (string) |
1331 @type BrowserItem |
1235 @param full flag indicating full pathname should be displayed (boolean) |
1332 @param finfo the string for the file |
1236 @param sourceLanguage source code language of the project (string) |
1333 @type str |
|
1334 @param full flag indicating full pathname should be displayed |
|
1335 @type bool |
|
1336 @param sourceLanguage source code language of the project |
|
1337 @type str |
1237 """ |
1338 """ |
1238 BrowserItem.__init__(self, parent, os.path.basename(finfo)) |
1339 BrowserItem.__init__(self, parent, os.path.basename(finfo)) |
1239 |
1340 |
1240 self.type_ = BrowserItemFile |
1341 self.type_ = BrowserItemFile |
1241 self.fileext = os.path.splitext(finfo)[1].lower() |
1342 self.fileext = os.path.splitext(finfo)[1].lower() |
1303 |
1404 |
1304 def setName(self, finfo, full=True): # noqa: U100 |
1405 def setName(self, finfo, full=True): # noqa: U100 |
1305 """ |
1406 """ |
1306 Public method to set the directory name. |
1407 Public method to set the directory name. |
1307 |
1408 |
1308 @param finfo the string for the file (string) |
1409 @param finfo the string for the file |
1309 @param full flag indicating full pathname should be displayed (boolean) |
1410 @type str |
|
1411 @param full flag indicating full pathname should be displayed |
|
1412 @type bool |
1310 """ |
1413 """ |
1311 self._filename = os.path.abspath(finfo) |
1414 self._filename = os.path.abspath(finfo) |
1312 self.itemData[0] = os.path.basename(finfo) |
1415 self.itemData[0] = os.path.basename(finfo) |
1313 self.fileext = os.path.splitext(finfo)[1].lower() |
1416 self.fileext = os.path.splitext(finfo)[1].lower() |
1314 if self.isPython3File() or self.isRubyFile() or self.isParsableFile(): |
1417 if self.isPython3File() or self.isRubyFile() or self.isParsableFile(): |
1317 |
1420 |
1318 def fileName(self): |
1421 def fileName(self): |
1319 """ |
1422 """ |
1320 Public method returning the filename. |
1423 Public method returning the filename. |
1321 |
1424 |
1322 @return filename (string) |
1425 @return filename |
|
1426 @rtype str |
1323 """ |
1427 """ |
1324 return self._filename |
1428 return self._filename |
1325 |
1429 |
1326 def name(self): |
1430 def name(self): |
1327 """ |
1431 """ |
1328 Public method to return the name of the item. |
1432 Public method to return the name of the item. |
1329 |
1433 |
1330 @return name of the item (string) |
1434 @return name of the item |
|
1435 @rtype str |
1331 """ |
1436 """ |
1332 return self._filename |
1437 return self._filename |
1333 |
1438 |
1334 def fileExt(self): |
1439 def fileExt(self): |
1335 """ |
1440 """ |
1336 Public method returning the file extension. |
1441 Public method returning the file extension. |
1337 |
1442 |
1338 @return file extension (string) |
1443 @return file extension |
|
1444 @rtype str |
1339 """ |
1445 """ |
1340 return self.fileext |
1446 return self.fileext |
1341 |
1447 |
1342 def dirName(self): |
1448 def dirName(self): |
1343 """ |
1449 """ |
1344 Public method returning the directory name. |
1450 Public method returning the directory name. |
1345 |
1451 |
1346 @return directory name (string) |
1452 @return directory name |
|
1453 @rtype str |
1347 """ |
1454 """ |
1348 return self._dirName |
1455 return self._dirName |
1349 |
1456 |
1350 def moduleName(self): |
1457 def moduleName(self): |
1351 """ |
1458 """ |
1352 Public method returning the module name. |
1459 Public method returning the module name. |
1353 |
1460 |
1354 @return module name (string) |
1461 @return module name |
|
1462 @rtype str |
1355 """ |
1463 """ |
1356 return self._moduleName |
1464 return self._moduleName |
1357 |
1465 |
1358 def isPython3File(self): |
1466 def isPython3File(self): |
1359 """ |
1467 """ |
1504 |
1613 |
1505 def lessThan(self, other, column, order): |
1614 def lessThan(self, other, column, order): |
1506 """ |
1615 """ |
1507 Public method to check, if the item is less than the other one. |
1616 Public method to check, if the item is less than the other one. |
1508 |
1617 |
1509 @param other reference to item to compare against (BrowserItem) |
1618 @param other reference to item to compare against |
1510 @param column column number to use for the comparison (integer) |
1619 @type BrowserItem |
1511 @param order sort order (Qt.SortOrder) (for special sorting) |
1620 @param column column number to use for the comparison |
1512 @return true, if this item is less than other (boolean) |
1621 @type int |
|
1622 @param order sort order (for special sorting) |
|
1623 @type Qt.SortOrder |
|
1624 @return true, if this item is less than other |
|
1625 @rtype bool |
1513 """ |
1626 """ |
1514 if not issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
1627 if not issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
1515 "BrowsersListFoldersFirst" |
1628 "BrowsersListFoldersFirst" |
1516 ): |
1629 ): |
1517 return order == Qt.SortOrder.DescendingOrder |
1630 return order == Qt.SortOrder.DescendingOrder |
1535 def __init__(self, parent, cl, filename): |
1648 def __init__(self, parent, cl, filename): |
1536 """ |
1649 """ |
1537 Constructor |
1650 Constructor |
1538 |
1651 |
1539 @param parent parent item |
1652 @param parent parent item |
|
1653 @type BrowserItem |
1540 @param cl Class object to be shown |
1654 @param cl Class object to be shown |
1541 @param filename filename of the file defining this class |
1655 @type Class |
|
1656 @param filename file name of the file defining this class |
|
1657 @type str |
1542 """ |
1658 """ |
1543 name = cl.name |
1659 name = cl.name |
1544 if hasattr(cl, "super") and cl.super: |
1660 if hasattr(cl, "super") and cl.super: |
1545 supers = [] |
1661 supers = [] |
1546 for sup in cl.super: |
1662 for sup in cl.super: |
1603 |
1719 |
1604 def name(self): |
1720 def name(self): |
1605 """ |
1721 """ |
1606 Public method to return the name of the item. |
1722 Public method to return the name of the item. |
1607 |
1723 |
1608 @return name of the item (string) |
1724 @return name of the item |
|
1725 @rtype str |
1609 """ |
1726 """ |
1610 return "{0}@@{1}".format(self._filename, self.lineno()) |
1727 return "{0}@@{1}".format(self._filename, self.lineno()) |
1611 |
1728 |
1612 def fileName(self): |
1729 def fileName(self): |
1613 """ |
1730 """ |
1614 Public method returning the filename. |
1731 Public method returning the filename. |
1615 |
1732 |
1616 @return filename (string) |
1733 @return filename |
|
1734 @rtype str |
1617 """ |
1735 """ |
1618 return self._filename |
1736 return self._filename |
1619 |
1737 |
1620 def classObject(self): |
1738 def classObject(self): |
1621 """ |
1739 """ |
1622 Public method returning the class object. |
1740 Public method returning the class object. |
1623 |
1741 |
1624 @return reference to the class object |
1742 @return reference to the class object |
|
1743 @rtype Class |
1625 """ |
1744 """ |
1626 return self._classObject |
1745 return self._classObject |
1627 |
1746 |
1628 def lineno(self): |
1747 def lineno(self): |
1629 """ |
1748 """ |
1630 Public method returning the line number defining this object. |
1749 Public method returning the line number defining this object. |
1631 |
1750 |
1632 @return line number defining the object (integer) |
1751 @return line number defining the object |
|
1752 @rtype int |
1633 """ |
1753 """ |
1634 return self._classObject.lineno |
1754 return self._classObject.lineno |
1635 |
1755 |
1636 def boundaries(self): |
1756 def boundaries(self): |
1637 """ |
1757 """ |
1638 Public method returning the boundaries of the method definition. |
1758 Public method returning the boundaries of the method definition. |
1639 |
1759 |
1640 @return tuple with start end end line number (integer, integer) |
1760 @return tuple with start end end line number |
|
1761 @rtype tuple of (int, int) |
1641 """ |
1762 """ |
1642 return (self._classObject.lineno, self._classObject.endlineno) |
1763 return (self._classObject.lineno, self._classObject.endlineno) |
1643 |
1764 |
1644 def lessThan(self, other, column, order): |
1765 def lessThan(self, other, column, order): |
1645 """ |
1766 """ |
1646 Public method to check, if the item is less than the other one. |
1767 Public method to check, if the item is less than the other one. |
1647 |
1768 |
1648 @param other reference to item to compare against (BrowserItem) |
1769 @param other reference to item to compare against |
1649 @param column column number to use for the comparison (integer) |
1770 @type BrowserItem |
1650 @param order sort order (Qt.SortOrder) (for special sorting) |
1771 @param column column number to use for the comparison |
1651 @return true, if this item is less than other (boolean) |
1772 @type int |
|
1773 @param order sort order (for special sorting) |
|
1774 @type Qt.SortOrder |
|
1775 @return true, if this item is less than other |
|
1776 @rtype bool |
1652 """ |
1777 """ |
1653 if issubclass(other.__class__, (BrowserCodingItem, BrowserClassAttributesItem)): |
1778 if issubclass(other.__class__, (BrowserCodingItem, BrowserClassAttributesItem)): |
1654 return order == Qt.SortOrder.DescendingOrder |
1779 return order == Qt.SortOrder.DescendingOrder |
1655 |
1780 |
1656 if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
1781 if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
1678 def __init__(self, parent, fn, filename): |
1804 def __init__(self, parent, fn, filename): |
1679 """ |
1805 """ |
1680 Constructor |
1806 Constructor |
1681 |
1807 |
1682 @param parent parent item |
1808 @param parent parent item |
|
1809 @type BrowserItem |
1683 @param fn Function object to be shown |
1810 @param fn Function object to be shown |
1684 @param filename filename of the file defining this class (string) |
1811 @type Function |
|
1812 @param filename filename of the file defining this class |
|
1813 @type str |
1685 """ |
1814 """ |
1686 name = fn.name |
1815 name = fn.name |
1687 BrowserItem.__init__(self, parent, name) |
1816 BrowserItem.__init__(self, parent, name) |
1688 |
1817 |
1689 self.type_ = BrowserItemMethod |
1818 self.type_ = BrowserItemMethod |
1719 |
1848 |
1720 def name(self): |
1849 def name(self): |
1721 """ |
1850 """ |
1722 Public method to return the name of the item. |
1851 Public method to return the name of the item. |
1723 |
1852 |
1724 @return name of the item (string) |
1853 @return name of the item |
|
1854 @rtype str |
1725 """ |
1855 """ |
1726 return "{0}@@{1}".format(self._filename, self.lineno()) |
1856 return "{0}@@{1}".format(self._filename, self.lineno()) |
1727 |
1857 |
1728 def fileName(self): |
1858 def fileName(self): |
1729 """ |
1859 """ |
1730 Public method returning the filename. |
1860 Public method returning the filename. |
1731 |
1861 |
1732 @return filename (string) |
1862 @return filename |
|
1863 @rtype str |
1733 """ |
1864 """ |
1734 return self._filename |
1865 return self._filename |
1735 |
1866 |
1736 def functionObject(self): |
1867 def functionObject(self): |
1737 """ |
1868 """ |
1738 Public method returning the function object. |
1869 Public method returning the function object. |
1739 |
1870 |
1740 @return reference to the function object |
1871 @return reference to the function object |
|
1872 @rtype Function |
1741 """ |
1873 """ |
1742 return self._functionObject |
1874 return self._functionObject |
1743 |
1875 |
1744 def lineno(self): |
1876 def lineno(self): |
1745 """ |
1877 """ |
1746 Public method returning the line number defining this object. |
1878 Public method returning the line number defining this object. |
1747 |
1879 |
1748 @return line number defining the object (integer) |
1880 @return line number defining the object |
|
1881 @rtype int |
1749 """ |
1882 """ |
1750 return self._functionObject.lineno |
1883 return self._functionObject.lineno |
1751 |
1884 |
1752 def boundaries(self): |
1885 def boundaries(self): |
1753 """ |
1886 """ |
1754 Public method returning the boundaries of the method definition. |
1887 Public method returning the boundaries of the method definition. |
1755 |
1888 |
1756 @return tuple with start end end line number (integer, integer) |
1889 @return tuple with start end end line number |
|
1890 @rtype tuple of (int, int) |
1757 """ |
1891 """ |
1758 return (self._functionObject.lineno, self._functionObject.endlineno) |
1892 return (self._functionObject.lineno, self._functionObject.endlineno) |
1759 |
1893 |
1760 def lessThan(self, other, column, order): |
1894 def lessThan(self, other, column, order): |
1761 """ |
1895 """ |
1762 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. |
1763 |
1897 |
1764 @param other reference to item to compare against (BrowserItem) |
1898 @param other reference to item to compare against |
1765 @param column column number to use for the comparison (integer) |
1899 @type BrowserItem |
1766 @param order sort order (Qt.SortOrder) (for special sorting) |
1900 @param column column number to use for the comparison |
1767 @return true, if this item is less than other (boolean) |
1901 @type int |
|
1902 @param order sort order (for special sorting) |
|
1903 @type Qt.SortOrder |
|
1904 @return true, if this item is less than other |
|
1905 @rtype bool |
1768 """ |
1906 """ |
1769 if issubclass(other.__class__, BrowserMethodItem): |
1907 if issubclass(other.__class__, BrowserMethodItem): |
1770 if self._name.startswith("__init__"): |
1908 if self._name.startswith("__init__"): |
1771 return order == Qt.SortOrder.AscendingOrder |
1909 return order == Qt.SortOrder.AscendingOrder |
1772 if other._name.startswith("__init__"): |
1910 if other._name.startswith("__init__"): |
1799 def __init__(self, parent, attributes, text, isClass=False): |
1938 def __init__(self, parent, attributes, text, isClass=False): |
1800 """ |
1939 """ |
1801 Constructor |
1940 Constructor |
1802 |
1941 |
1803 @param parent parent item |
1942 @param parent parent item |
|
1943 @type BrowserItem |
1804 @param attributes list of attributes |
1944 @param attributes list of attributes |
1805 @param text text to be shown by this item (string) |
1945 @type list of Attribute |
1806 @param isClass flag indicating class attributes (boolean) |
1946 @param text text to be shown by this item |
|
1947 @type str |
|
1948 @param isClass flag indicating class attributes |
|
1949 @type bool |
1807 """ |
1950 """ |
1808 BrowserItem.__init__(self, parent, text) |
1951 BrowserItem.__init__(self, parent, text) |
1809 |
1952 |
1810 self.type_ = BrowserItemAttributes |
1953 self.type_ = BrowserItemAttributes |
1811 self._attributes = attributes.copy() |
1954 self._attributes = attributes.copy() |
1819 |
1962 |
1820 def name(self): |
1963 def name(self): |
1821 """ |
1964 """ |
1822 Public method to return the name of the item. |
1965 Public method to return the name of the item. |
1823 |
1966 |
1824 @return name of the item (string) |
1967 @return name of the item |
|
1968 @rtype str |
1825 """ |
1969 """ |
1826 return "{0}@@{1}".format(self.parentItem.name(), self.data(0)) |
1970 return "{0}@@{1}".format(self.parentItem.name(), self.data(0)) |
1827 |
1971 |
1828 def attributes(self): |
1972 def attributes(self): |
1829 """ |
1973 """ |
1830 Public method returning the attribute list. |
1974 Public method returning the attribute list. |
1831 |
1975 |
1832 @return reference to the list of attributes |
1976 @return reference to the list of attributes |
|
1977 @rtype list of Attribute |
1833 """ |
1978 """ |
1834 return self._attributes |
1979 return self._attributes |
1835 |
1980 |
1836 def isClassAttributes(self): |
1981 def isClassAttributes(self): |
1837 """ |
1982 """ |
1838 Public method returning the attributes type. |
1983 Public method returning the attributes type. |
1839 |
1984 |
1840 @return flag indicating class attributes (boolean) |
1985 @return flag indicating class attributes |
|
1986 @rtype bool |
1841 """ |
1987 """ |
1842 return self.__isClass |
1988 return self.__isClass |
1843 |
1989 |
1844 def lessThan(self, other, column, order): |
1990 def lessThan(self, other, column, order): |
1845 """ |
1991 """ |
1846 Public method to check, if the item is less than the other one. |
1992 Public method to check, if the item is less than the other one. |
1847 |
1993 |
1848 @param other reference to item to compare against (BrowserItem) |
1994 @param other reference to item to compare against |
1849 @param column column number to use for the comparison (integer) |
1995 @type BrowserItem |
1850 @param order sort order (Qt.SortOrder) (for special sorting) |
1996 @param column column number to use for the comparison |
1851 @return true, if this item is less than other (boolean) |
1997 @type int |
|
1998 @param order sort order (for special sorting) |
|
1999 @type Qt.SortOrder |
|
2000 @return true, if this item is less than other |
|
2001 @rtype bool |
1852 """ |
2002 """ |
1853 if issubclass(other.__class__, BrowserCodingItem): |
2003 if issubclass(other.__class__, BrowserCodingItem): |
1854 return order == Qt.SortOrder.DescendingOrder |
2004 return order == Qt.SortOrder.DescendingOrder |
1855 elif issubclass(other.__class__, (BrowserClassItem, BrowserMethodItem)): |
2005 elif issubclass(other.__class__, (BrowserClassItem, BrowserMethodItem)): |
1856 return order == Qt.SortOrder.AscendingOrder |
2006 return order == Qt.SortOrder.AscendingOrder |
1866 def __init__(self, parent, attribute, isClass=False): |
2016 def __init__(self, parent, attribute, isClass=False): |
1867 """ |
2017 """ |
1868 Constructor |
2018 Constructor |
1869 |
2019 |
1870 @param parent parent item |
2020 @param parent parent item |
|
2021 @type BrowserItem |
1871 @param attribute reference to the attribute object |
2022 @param attribute reference to the attribute object |
1872 @param isClass flag indicating a class attribute (boolean) |
2023 @type Attribute |
|
2024 @param isClass flag indicating a class attribute |
|
2025 @type bool |
1873 """ |
2026 """ |
1874 BrowserItem.__init__(self, parent, attribute.name) |
2027 BrowserItem.__init__(self, parent, attribute.name) |
1875 |
2028 |
1876 self.type_ = BrowserItemAttribute |
2029 self.type_ = BrowserItemAttribute |
1877 self._attributeObject = attribute |
2030 self._attributeObject = attribute |
1887 |
2040 |
1888 def isPublic(self): |
2041 def isPublic(self): |
1889 """ |
2042 """ |
1890 Public method returning the public visibility status. |
2043 Public method returning the public visibility status. |
1891 |
2044 |
1892 @return flag indicating public visibility (boolean) |
2045 @return flag indicating public visibility |
|
2046 @rtype bool |
1893 """ |
2047 """ |
1894 return self.__public |
2048 return self.__public |
1895 |
2049 |
1896 def attributeObject(self): |
2050 def attributeObject(self): |
1897 """ |
2051 """ |
1898 Public method returning the class object. |
2052 Public method returning the class object. |
1899 |
2053 |
1900 @return reference to the class object |
2054 @return reference to the class object |
|
2055 @rtype Class |
1901 """ |
2056 """ |
1902 return self._attributeObject |
2057 return self._attributeObject |
1903 |
2058 |
1904 def fileName(self): |
2059 def fileName(self): |
1905 """ |
2060 """ |
1906 Public method returning the filename. |
2061 Public method returning the filename. |
1907 |
2062 |
1908 @return filename (string) |
2063 @return filename |
|
2064 @rtype str |
1909 """ |
2065 """ |
1910 return self._attributeObject.file |
2066 return self._attributeObject.file |
1911 |
2067 |
1912 def lineno(self): |
2068 def lineno(self): |
1913 """ |
2069 """ |
1914 Public method returning the line number defining this object. |
2070 Public method returning the line number defining this object. |
1915 |
2071 |
1916 @return line number defining the object (integer) |
2072 @return line number defining the object |
|
2073 @rtype int |
1917 """ |
2074 """ |
1918 return self._attributeObject.lineno |
2075 return self._attributeObject.lineno |
1919 |
2076 |
1920 def linenos(self): |
2077 def linenos(self): |
1921 """ |
2078 """ |
1922 Public method returning the line numbers this object is assigned to. |
2079 Public method returning the line numbers this object is assigned to. |
1923 |
2080 |
1924 @return line number the object is assigned to (list of integers) |
2081 @return line number the object is assigned to |
|
2082 @rtype list of int |
1925 """ |
2083 """ |
1926 return self._attributeObject.linenos[:] |
2084 return self._attributeObject.linenos[:] |
1927 |
2085 |
1928 def lessThan(self, other, column, order): |
2086 def lessThan(self, other, column, order): |
1929 """ |
2087 """ |
1930 Public method to check, if the item is less than the other one. |
2088 Public method to check, if the item is less than the other one. |
1931 |
2089 |
1932 @param other reference to item to compare against (BrowserItem) |
2090 @param other reference to item to compare against |
1933 @param column column number to use for the comparison (integer) |
2091 @type BrowserItem |
1934 @param order sort order (Qt.SortOrder) (for special sorting) |
2092 @param column column number to use for the comparison |
1935 @return true, if this item is less than other (boolean) |
2093 @type int |
|
2094 @param order sort order (for special sorting) |
|
2095 @type Qt.SortOrder |
|
2096 @return true, if this item is less than other |
|
2097 @rtype bool |
1936 """ |
2098 """ |
1937 if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
2099 if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
1938 if order == Qt.SortOrder.AscendingOrder: |
2100 if order == Qt.SortOrder.AscendingOrder: |
1939 return self.lineno() < other.lineno() |
2101 return self.lineno() < other.lineno() |
1940 else: |
2102 else: |
1951 def __init__(self, parent, attributes, text): |
2113 def __init__(self, parent, attributes, text): |
1952 """ |
2114 """ |
1953 Constructor |
2115 Constructor |
1954 |
2116 |
1955 @param parent parent item |
2117 @param parent parent item |
|
2118 @type BrowserItem |
1956 @param attributes list of attributes |
2119 @param attributes list of attributes |
1957 @param text text to be shown by this item (string) |
2120 @type list of Attribute |
|
2121 @param text text to be shown by this item |
|
2122 @type str |
1958 """ |
2123 """ |
1959 BrowserClassAttributesItem.__init__(self, parent, attributes, text) |
2124 BrowserClassAttributesItem.__init__(self, parent, attributes, text) |
1960 |
2125 |
1961 |
2126 |
1962 class BrowserCodingItem(BrowserItem): |
2127 class BrowserCodingItem(BrowserItem): |
1993 |
2158 |
1994 def lessThan(self, other, column, order): |
2159 def lessThan(self, other, column, order): |
1995 """ |
2160 """ |
1996 Public method to check, if the item is less than the other one. |
2161 Public method to check, if the item is less than the other one. |
1997 |
2162 |
1998 @param other reference to item to compare against (BrowserItem) |
2163 @param other reference to item to compare against |
1999 @param column column number to use for the comparison (integer) |
2164 @type BrowserItem |
2000 @param order sort order (Qt.SortOrder) (for special sorting) |
2165 @param column column number to use for the comparison |
2001 @return true, if this item is less than other (boolean) |
2166 @type int |
|
2167 @param order sort order (for special sorting) |
|
2168 @type Qt.SortOrder |
|
2169 @return true, if this item is less than other |
|
2170 @rtype bool |
2002 """ |
2171 """ |
2003 if issubclass( |
2172 if issubclass( |
2004 other.__class__, |
2173 other.__class__, |
2005 (BrowserClassItem, BrowserClassAttributesItem, BrowserImportItem), |
2174 (BrowserClassItem, BrowserClassAttributesItem, BrowserImportItem), |
2006 ): |
2175 ): |
2017 def __init__(self, parent, text): |
2186 def __init__(self, parent, text): |
2018 """ |
2187 """ |
2019 Constructor |
2188 Constructor |
2020 |
2189 |
2021 @param parent parent item |
2190 @param parent parent item |
2022 @param text text to be shown by this item (string) |
2191 @type BrowserItem |
|
2192 @param text text to be shown by this item |
|
2193 @type str |
2023 """ |
2194 """ |
2024 BrowserItem.__init__(self, parent, text) |
2195 BrowserItem.__init__(self, parent, text) |
2025 |
2196 |
2026 self.type_ = BrowserItemImports |
2197 self.type_ = BrowserItemImports |
2027 self.icon = EricPixmapCache.getIcon("imports") |
2198 self.icon = EricPixmapCache.getIcon("imports") |
2028 |
2199 |
2029 def lessThan(self, other, column, order): |
2200 def lessThan(self, other, column, order): |
2030 """ |
2201 """ |
2031 Public method to check, if the item is less than the other one. |
2202 Public method to check, if the item is less than the other one. |
2032 |
2203 |
2033 @param other reference to item to compare against (BrowserItem) |
2204 @param other reference to item to compare against |
2034 @param column column number to use for the comparison (integer) |
2205 @type BrowserItem |
2035 @param order sort order (Qt.SortOrder) (for special sorting) |
2206 @param column column number to use for the comparison |
2036 @return true, if this item is less than other (boolean) |
2207 @type int |
|
2208 @param order sort order (for special sorting) |
|
2209 @type Qt.SortOrder |
|
2210 @return true, if this item is less than other |
|
2211 @rtype bool |
2037 """ |
2212 """ |
2038 if issubclass(other.__class__, (BrowserClassItem, BrowserClassAttributesItem)): |
2213 if issubclass(other.__class__, (BrowserClassItem, BrowserClassAttributesItem)): |
2039 return order == Qt.SortOrder.AscendingOrder |
2214 return order == Qt.SortOrder.AscendingOrder |
2040 |
2215 |
2041 return BrowserItem.lessThan(self, other, column, order) |
2216 return BrowserItem.lessThan(self, other, column, order) |
2050 def __init__(self, parent, text, filename, lineNumbers, isModule=True): |
2225 def __init__(self, parent, text, filename, lineNumbers, isModule=True): |
2051 """ |
2226 """ |
2052 Constructor |
2227 Constructor |
2053 |
2228 |
2054 @param parent parent item |
2229 @param parent parent item |
2055 @param text text to be shown by this item (string) |
2230 @type BrowserItem |
2056 @param filename name of the file (string) |
2231 @param text text to be shown by this item |
|
2232 @type str |
|
2233 @param filename name of the file |
|
2234 @type str |
2057 @param lineNumbers list of line numbers of the import statement |
2235 @param lineNumbers list of line numbers of the import statement |
2058 (list of integer) |
2236 @type list of int |
2059 @param isModule flag indicating a module item entry (boolean) |
2237 @param isModule flag indicating a module item entry |
|
2238 @type bool |
2060 """ |
2239 """ |
2061 BrowserItem.__init__(self, parent, text) |
2240 BrowserItem.__init__(self, parent, text) |
2062 |
2241 |
2063 self.__filename = filename |
2242 self.__filename = filename |
2064 self.__linenos = lineNumbers[:] |
2243 self.__linenos = lineNumbers[:] |
2071 |
2250 |
2072 def fileName(self): |
2251 def fileName(self): |
2073 """ |
2252 """ |
2074 Public method returning the filename. |
2253 Public method returning the filename. |
2075 |
2254 |
2076 @return filename (string) |
2255 @return filename |
|
2256 @rtype str |
2077 """ |
2257 """ |
2078 return self.__filename |
2258 return self.__filename |
2079 |
2259 |
2080 def lineno(self): |
2260 def lineno(self): |
2081 """ |
2261 """ |
2082 Public method returning the line number of the first import. |
2262 Public method returning the line number of the first import. |
2083 |
2263 |
2084 @return line number of the first import (integer) |
2264 @return line number of the first import |
|
2265 @rtype int |
2085 """ |
2266 """ |
2086 return self.__linenos[0] |
2267 return self.__linenos[0] |
2087 |
2268 |
2088 def linenos(self): |
2269 def linenos(self): |
2089 """ |
2270 """ |
2090 Public method returning the line numbers of all imports. |
2271 Public method returning the line numbers of all imports. |
2091 |
2272 |
2092 @return line numbers of all imports (list of integers) |
2273 @return line numbers of all imports |
|
2274 @rtype list of int |
2093 """ |
2275 """ |
2094 return self.__linenos[:] |
2276 return self.__linenos[:] |
2095 |
2277 |
2096 def lessThan(self, other, column, order): |
2278 def lessThan(self, other, column, order): |
2097 """ |
2279 """ |
2098 Public method to check, if the item is less than the other one. |
2280 Public method to check, if the item is less than the other one. |
2099 |
2281 |
2100 @param other reference to item to compare against (BrowserItem) |
2282 @param other reference to item to compare against |
2101 @param column column number to use for the comparison (integer) |
2283 @type BrowserItem |
2102 @param order sort order (Qt.SortOrder) (for special sorting) |
2284 @param column column number to use for the comparison |
2103 @return true, if this item is less than other (boolean) |
2285 @type int |
|
2286 @param order sort order (for special sorting) |
|
2287 @type Qt.SortOrder |
|
2288 @return true, if this item is less than other |
|
2289 @rtype bool |
2104 """ |
2290 """ |
2105 if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
2291 if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
2106 if order == Qt.SortOrder.AscendingOrder: |
2292 if order == Qt.SortOrder.AscendingOrder: |
2107 return self.lineno() < other.lineno() |
2293 return self.lineno() < other.lineno() |
2108 else: |
2294 else: |