19 |
19 |
20 import UI.PixmapCache |
20 import UI.PixmapCache |
21 import Preferences |
21 import Preferences |
22 import Utilities |
22 import Utilities |
23 |
23 |
24 BrowserItemRoot = 0 |
24 BrowserItemRoot = 0 |
25 BrowserItemDirectory = 1 |
25 BrowserItemDirectory = 1 |
26 BrowserItemSysPath = 2 |
26 BrowserItemSysPath = 2 |
27 BrowserItemFile = 3 |
27 BrowserItemFile = 3 |
28 BrowserItemClass = 4 |
28 BrowserItemClass = 4 |
29 BrowserItemMethod = 5 |
29 BrowserItemMethod = 5 |
30 BrowserItemAttributes = 6 |
30 BrowserItemAttributes = 6 |
31 BrowserItemAttribute = 7 |
31 BrowserItemAttribute = 7 |
32 BrowserItemCoding = 8 |
32 BrowserItemCoding = 8 |
|
33 |
33 |
34 |
34 class BrowserModel(QAbstractItemModel): |
35 class BrowserModel(QAbstractItemModel): |
35 """ |
36 """ |
36 Class implementing the browser model. |
37 Class implementing the browser model. |
37 """ |
38 """ |
38 def __init__(self, parent = None): |
39 def __init__(self, parent=None): |
39 """ |
40 """ |
40 Constructor |
41 Constructor |
41 |
42 |
42 @param parent reference to parent object (QObject) |
43 @param parent reference to parent object (QObject) |
43 """ |
44 """ |
109 if not index.isValid(): |
110 if not index.isValid(): |
110 return Qt.ItemIsEnabled |
111 return Qt.ItemIsEnabled |
111 |
112 |
112 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
113 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
113 |
114 |
114 def headerData(self, section, orientation, role = Qt.DisplayRole): |
115 def headerData(self, section, orientation, role=Qt.DisplayRole): |
115 """ |
116 """ |
116 Public method to get the header data. |
117 Public method to get the header data. |
117 |
118 |
118 @param section number of section to get data for (integer) |
119 @param section number of section to get data for (integer) |
119 @param orientation header orientation (Qt.Orientation) |
120 @param orientation header orientation (Qt.Orientation) |
126 else: |
127 else: |
127 return self.rootItem.data(section) |
128 return self.rootItem.data(section) |
128 |
129 |
129 return None |
130 return None |
130 |
131 |
131 def index(self, row, column, parent = QModelIndex()): |
132 def index(self, row, column, parent=QModelIndex()): |
132 """ |
133 """ |
133 Public method to create an index. |
134 Public method to create an index. |
134 |
135 |
135 @param row row number of the new index (integer) |
136 @param row row number of the new index (integer) |
136 @param column column number of the new index (integer) |
137 @param column column number of the new index (integer) |
137 @param parent index of parent item (QModelIndex) |
138 @param parent index of parent item (QModelIndex) |
138 @return index object (QModelIndex) |
139 @return index object (QModelIndex) |
139 """ |
140 """ |
140 # The model/view framework considers negative values out-of-bounds, |
141 # The model/view framework considers negative values out-of-bounds, |
141 # however in python they work when indexing into lists. So make sure |
142 # however in python they work when indexing into lists. So make sure |
142 # we return an invalid index for out-of-bounds row/col |
143 # we return an invalid index for out-of-bounds row/col |
143 if row < 0 or column < 0 or \ |
144 if row < 0 or column < 0 or \ |
144 row >= self.rowCount(parent) or column >= self.columnCount(parent): |
145 row >= self.rowCount(parent) or column >= self.columnCount(parent): |
145 return QModelIndex() |
146 return QModelIndex() |
146 |
147 |
176 if parentItem == self.rootItem: |
177 if parentItem == self.rootItem: |
177 return QModelIndex() |
178 return QModelIndex() |
178 |
179 |
179 return self.createIndex(parentItem.row(), 0, parentItem) |
180 return self.createIndex(parentItem.row(), 0, parentItem) |
180 |
181 |
181 def rowCount(self, parent = QModelIndex()): |
182 def rowCount(self, parent=QModelIndex()): |
182 """ |
183 """ |
183 Public method to get the number of rows. |
184 Public method to get the number of rows. |
184 |
185 |
185 @param parent index of parent item (QModelIndex) |
186 @param parent index of parent item (QModelIndex) |
186 @return number of rows (integer) |
187 @return number of rows (integer) |
196 if not parentItem.isPopulated(): # lazy population |
197 if not parentItem.isPopulated(): # lazy population |
197 self.populateItem(parentItem) |
198 self.populateItem(parentItem) |
198 |
199 |
199 return parentItem.childCount() |
200 return parentItem.childCount() |
200 |
201 |
201 def hasChildren(self, parent = QModelIndex()): |
202 def hasChildren(self, parent=QModelIndex()): |
202 """ |
203 """ |
203 Public method to check for the presence of child items. |
204 Public method to check for the presence of child items. |
204 |
205 |
205 We always return True for normal items in order to do lazy |
206 We always return True for normal items in order to do lazy |
206 population of the tree. |
207 population of the tree. |
311 cnt = itm.childCount() |
312 cnt = itm.childCount() |
312 self.beginInsertRows(self.createIndex(itm.row(), 0, itm), |
313 self.beginInsertRows(self.createIndex(itm.row(), 0, itm), |
313 cnt, cnt) |
314 cnt, cnt) |
314 if f.isDir(): |
315 if f.isDir(): |
315 node = BrowserDirectoryItem(itm, |
316 node = BrowserDirectoryItem(itm, |
316 Utilities.toNativeSeparators(f.absoluteFilePath()), |
317 Utilities.toNativeSeparators(f.absoluteFilePath()), |
317 False) |
318 False) |
318 else: |
319 else: |
319 node = BrowserFileItem(itm, |
320 node = BrowserFileItem(itm, |
320 Utilities.toNativeSeparators(f.absoluteFilePath())) |
321 Utilities.toNativeSeparators(f.absoluteFilePath())) |
321 self._addItem(node, itm) |
322 self._addItem(node, itm) |
411 |
412 |
412 def saveToplevelDirs(self): |
413 def saveToplevelDirs(self): |
413 """ |
414 """ |
414 Public slot to save the toplevel directories. |
415 Public slot to save the toplevel directories. |
415 """ |
416 """ |
416 Preferences.Prefs.settings.setValue('BrowserModel/ToplevelDirs', |
417 Preferences.Prefs.settings.setValue('BrowserModel/ToplevelDirs', |
417 self.toplevelDirs) |
418 self.toplevelDirs) |
418 |
419 |
419 def _addItem(self, itm, parentItem): |
420 def _addItem(self, itm, parentItem): |
420 """ |
421 """ |
421 Protected slot to add an item. |
422 Protected slot to add an item. |
423 @param itm reference to item to add (BrowserItem) |
424 @param itm reference to item to add (BrowserItem) |
424 @param parentItem reference to item to add to (BrowserItem) |
425 @param parentItem reference to item to add to (BrowserItem) |
425 """ |
426 """ |
426 parentItem.appendChild(itm) |
427 parentItem.appendChild(itm) |
427 |
428 |
428 def addItem(self, itm, parent = QModelIndex()): |
429 def addItem(self, itm, parent=QModelIndex()): |
429 """ |
430 """ |
430 Puplic slot to add an item. |
431 Puplic slot to add an item. |
431 |
432 |
432 @param itm item to add (BrowserItem) |
433 @param itm item to add (BrowserItem) |
433 @param parent index of parent item (QModelIndex) |
434 @param parent index of parent item (QModelIndex) |
440 cnt = parentItem.childCount() |
441 cnt = parentItem.childCount() |
441 self.beginInsertRows(parent, cnt, cnt) |
442 self.beginInsertRows(parent, cnt, cnt) |
442 self._addItem(itm, parentItem) |
443 self._addItem(itm, parentItem) |
443 self.endInsertRows() |
444 self.endInsertRows() |
444 |
445 |
445 def populateItem(self, parentItem, repopulate = False): |
446 def populateItem(self, parentItem, repopulate=False): |
446 """ |
447 """ |
447 Public method to populate an item's subtree. |
448 Public method to populate an item's subtree. |
448 |
449 |
449 @param parentItem reference to the item to be populated |
450 @param parentItem reference to the item to be populated |
450 @param repopulate flag indicating a repopulation (boolean) |
451 @param repopulate flag indicating a repopulation (boolean) |
460 elif parentItem.type() == BrowserItemMethod: |
461 elif parentItem.type() == BrowserItemMethod: |
461 self.populateMethodItem(parentItem, repopulate) |
462 self.populateMethodItem(parentItem, repopulate) |
462 elif parentItem.type() == BrowserItemAttributes: |
463 elif parentItem.type() == BrowserItemAttributes: |
463 self.populateClassAttributesItem(parentItem, repopulate) |
464 self.populateClassAttributesItem(parentItem, repopulate) |
464 |
465 |
465 def populateDirectoryItem(self, parentItem, repopulate = False): |
466 def populateDirectoryItem(self, parentItem, repopulate=False): |
466 """ |
467 """ |
467 Public method to populate a directory item's subtree. |
468 Public method to populate a directory item's subtree. |
468 |
469 |
469 @param parentItem reference to the directory item to be populated |
470 @param parentItem reference to the directory item to be populated |
470 @param repopulate flag indicating a repopulation (boolean) |
471 @param repopulate flag indicating a repopulation (boolean) |
483 self.beginInsertRows(self.createIndex(parentItem.row(), 0, parentItem), |
484 self.beginInsertRows(self.createIndex(parentItem.row(), 0, parentItem), |
484 0, len(entryInfoList) - 1) |
485 0, len(entryInfoList) - 1) |
485 for f in entryInfoList: |
486 for f in entryInfoList: |
486 if f.isDir(): |
487 if f.isDir(): |
487 node = BrowserDirectoryItem(parentItem, |
488 node = BrowserDirectoryItem(parentItem, |
488 Utilities.toNativeSeparators(f.absoluteFilePath()), |
489 Utilities.toNativeSeparators(f.absoluteFilePath()), |
489 False) |
490 False) |
490 else: |
491 else: |
491 fileFilters = Preferences.getUI("BrowsersFileFilters").split(";") |
492 fileFilters = Preferences.getUI("BrowsersFileFilters").split(";") |
492 if fileFilters: |
493 if fileFilters: |
493 fn = f.fileName() |
494 fn = f.fileName() |
498 Utilities.toNativeSeparators(f.absoluteFilePath())) |
499 Utilities.toNativeSeparators(f.absoluteFilePath())) |
499 self._addItem(node, parentItem) |
500 self._addItem(node, parentItem) |
500 if repopulate: |
501 if repopulate: |
501 self.endInsertRows() |
502 self.endInsertRows() |
502 |
503 |
503 def populateSysPathItem(self, parentItem, repopulate = False): |
504 def populateSysPathItem(self, parentItem, repopulate=False): |
504 """ |
505 """ |
505 Public method to populate a sys.path item's subtree. |
506 Public method to populate a sys.path item's subtree. |
506 |
507 |
507 @param parentItem reference to the sys.path item to be populated |
508 @param parentItem reference to the sys.path item to be populated |
508 @param repopulate flag indicating a repopulation (boolean) |
509 @param repopulate flag indicating a repopulation (boolean) |
518 node = BrowserDirectoryItem(parentItem, p) |
519 node = BrowserDirectoryItem(parentItem, p) |
519 self._addItem(node, parentItem) |
520 self._addItem(node, parentItem) |
520 if repopulate: |
521 if repopulate: |
521 self.endInsertRows() |
522 self.endInsertRows() |
522 |
523 |
523 def populateFileItem(self, parentItem, repopulate = False): |
524 def populateFileItem(self, parentItem, repopulate=False): |
524 """ |
525 """ |
525 Public method to populate a file item's subtree. |
526 Public method to populate a file item's subtree. |
526 |
527 |
527 @param parentItem reference to the file item to be populated |
528 @param parentItem reference to the file item to be populated |
528 @param repopulate flag indicating a repopulation (boolean) |
529 @param repopulate flag indicating a repopulation (boolean) |
529 """ |
530 """ |
530 moduleName = parentItem.moduleName() |
531 moduleName = parentItem.moduleName() |
531 fileName = parentItem.fileName() |
532 fileName = parentItem.fileName() |
532 try: |
533 try: |
533 dict = Utilities.ClassBrowsers.readmodule( |
534 dict = Utilities.ClassBrowsers.readmodule( |
534 moduleName, [parentItem.dirName()], |
535 moduleName, [parentItem.dirName()], |
535 parentItem.isPython2File() or parentItem.isPython3File()) |
536 parentItem.isPython2File() or parentItem.isPython3File()) |
536 except ImportError: |
537 except ImportError: |
537 return |
538 return |
538 |
539 |
539 keys = list(dict.keys()) |
540 keys = list(dict.keys()) |
551 node = BrowserClassItem(parentItem, cl, fileName) |
552 node = BrowserClassItem(parentItem, cl, fileName) |
552 self._addItem(node, parentItem) |
553 self._addItem(node, parentItem) |
553 except AttributeError: |
554 except AttributeError: |
554 pass |
555 pass |
555 if "@@Coding@@" in keys: |
556 if "@@Coding@@" in keys: |
556 node = BrowserCodingItem(parentItem, |
557 node = BrowserCodingItem(parentItem, |
557 QApplication.translate("BrowserModel", "Coding: {0}")\ |
558 QApplication.translate("BrowserModel", "Coding: {0}")\ |
558 .format(dict["@@Coding@@"].coding)) |
559 .format(dict["@@Coding@@"].coding)) |
559 self._addItem(node, parentItem) |
560 self._addItem(node, parentItem) |
560 if "@@Globals@@" in keys: |
561 if "@@Globals@@" in keys: |
561 node = BrowserClassAttributesItem(parentItem, |
562 node = BrowserClassAttributesItem(parentItem, |
562 dict["@@Globals@@"].globals, |
563 dict["@@Globals@@"].globals, |
563 QApplication.translate("BrowserModel", "Globals")) |
564 QApplication.translate("BrowserModel", "Globals")) |
564 self._addItem(node, parentItem) |
565 self._addItem(node, parentItem) |
565 if repopulate: |
566 if repopulate: |
566 self.endInsertRows() |
567 self.endInsertRows() |
567 |
568 |
568 def populateClassItem(self, parentItem, repopulate = False): |
569 def populateClassItem(self, parentItem, repopulate=False): |
569 """ |
570 """ |
570 Public method to populate a class item's subtree. |
571 Public method to populate a class item's subtree. |
571 |
572 |
572 @param parentItem reference to the class item to be populated |
573 @param parentItem reference to the class item to be populated |
573 @param repopulate flag indicating a repopulation (boolean) |
574 @param repopulate flag indicating a repopulation (boolean) |
598 if repopulate: |
599 if repopulate: |
599 self.endInsertRows() |
600 self.endInsertRows() |
600 |
601 |
601 if len(cl.attributes): |
602 if len(cl.attributes): |
602 node = BrowserClassAttributesItem( |
603 node = BrowserClassAttributesItem( |
603 parentItem, cl.attributes, |
604 parentItem, cl.attributes, |
604 QApplication.translate("BrowserModel", "Attributes")) |
605 QApplication.translate("BrowserModel", "Attributes")) |
605 if repopulate: |
606 if repopulate: |
606 self.addItem(node, |
607 self.addItem(node, |
607 self.createIndex(parentItem.row(), 0, parentItem)) |
608 self.createIndex(parentItem.row(), 0, parentItem)) |
608 else: |
609 else: |
609 self._addItem(node, parentItem) |
610 self._addItem(node, parentItem) |
610 |
611 |
611 if len(cl.globals): |
612 if len(cl.globals): |
612 node = BrowserClassAttributesItem( |
613 node = BrowserClassAttributesItem( |
613 parentItem, cl.globals, |
614 parentItem, cl.globals, |
614 QApplication.translate("BrowserModel", "Attributes (global)")) |
615 QApplication.translate("BrowserModel", "Attributes (global)")) |
615 if repopulate: |
616 if repopulate: |
616 self.addItem(node, |
617 self.addItem(node, |
617 self.createIndex(parentItem.row(), 0, parentItem)) |
618 self.createIndex(parentItem.row(), 0, parentItem)) |
618 else: |
619 else: |
619 self._addItem(node, parentItem) |
620 self._addItem(node, parentItem) |
620 |
621 |
621 def populateMethodItem(self, parentItem, repopulate = False): |
622 def populateMethodItem(self, parentItem, repopulate=False): |
622 """ |
623 """ |
623 Public method to populate a method item's subtree. |
624 Public method to populate a method item's subtree. |
624 |
625 |
625 @param parentItem reference to the method item to be populated |
626 @param parentItem reference to the method item to be populated |
626 @param repopulate flag indicating a repopulation (boolean) |
627 @param repopulate flag indicating a repopulation (boolean) |
649 node = BrowserMethodItem(parentItem, fn.methods[key], file_) |
650 node = BrowserMethodItem(parentItem, fn.methods[key], file_) |
650 self._addItem(node, parentItem) |
651 self._addItem(node, parentItem) |
651 if repopulate: |
652 if repopulate: |
652 self.endInsertRows() |
653 self.endInsertRows() |
653 |
654 |
654 def populateClassAttributesItem(self, parentItem, repopulate = False): |
655 def populateClassAttributesItem(self, parentItem, repopulate=False): |
655 """ |
656 """ |
656 Public method to populate a class attributes item's subtree. |
657 Public method to populate a class attributes item's subtree. |
657 |
658 |
658 @param parentItem reference to the class attributes item to be populated |
659 @param parentItem reference to the class attributes item to be populated |
659 @param repopulate flag indicating a repopulation (boolean) |
660 @param repopulate flag indicating a repopulation (boolean) |
671 node = BrowserClassAttributeItem(parentItem, attributes[key]) |
672 node = BrowserClassAttributeItem(parentItem, attributes[key]) |
672 self._addItem(node, parentItem) |
673 self._addItem(node, parentItem) |
673 if repopulate: |
674 if repopulate: |
674 self.endInsertRows() |
675 self.endInsertRows() |
675 |
676 |
|
677 |
676 class BrowserItem(object): |
678 class BrowserItem(object): |
677 """ |
679 """ |
678 Class implementing the data structure for browser items. |
680 Class implementing the data structure for browser items. |
679 """ |
681 """ |
680 def __init__(self, parent, data): |
682 def __init__(self, parent, data): |
838 |
840 |
839 @return flag indicating a symbolic link (boolean) |
841 @return flag indicating a symbolic link (boolean) |
840 """ |
842 """ |
841 return self.symlink |
843 return self.symlink |
842 |
844 |
|
845 |
843 class BrowserDirectoryItem(BrowserItem): |
846 class BrowserDirectoryItem(BrowserItem): |
844 """ |
847 """ |
845 Class implementing the data structure for browser directory items. |
848 Class implementing the data structure for browser directory items. |
846 """ |
849 """ |
847 def __init__(self, parent, dinfo, full = True): |
850 def __init__(self, parent, dinfo, full=True): |
848 """ |
851 """ |
849 Constructor |
852 Constructor |
850 |
853 |
851 @param parent parent item |
854 @param parent parent item |
852 @param dinfo dinfo is the string for the directory (string) |
855 @param dinfo dinfo is the string for the directory (string) |
868 else: |
871 else: |
869 self.icon = UI.PixmapCache.getIcon("dirClosed.png") |
872 self.icon = UI.PixmapCache.getIcon("dirClosed.png") |
870 self._populated = False |
873 self._populated = False |
871 self._lazyPopulation = True |
874 self._lazyPopulation = True |
872 |
875 |
873 def setName(self, dinfo, full = True): |
876 def setName(self, dinfo, full=True): |
874 """ |
877 """ |
875 Public method to set the directory name. |
878 Public method to set the directory name. |
876 |
879 |
877 @param dinfo dinfo is the string for the directory (string) |
880 @param dinfo dinfo is the string for the directory (string) |
878 @param full flag indicating full pathname should be displayed (boolean) |
881 @param full flag indicating full pathname should be displayed (boolean) |
914 if Preferences.getUI("BrowsersListFoldersFirst"): |
917 if Preferences.getUI("BrowsersListFoldersFirst"): |
915 return order == Qt.AscendingOrder |
918 return order == Qt.AscendingOrder |
916 |
919 |
917 return BrowserItem.lessThan(self, other, column, order) |
920 return BrowserItem.lessThan(self, other, column, order) |
918 |
921 |
|
922 |
919 class BrowserSysPathItem(BrowserItem): |
923 class BrowserSysPathItem(BrowserItem): |
920 """ |
924 """ |
921 Class implementing the data structure for browser sys.path items. |
925 Class implementing the data structure for browser sys.path items. |
922 """ |
926 """ |
923 def __init__(self, parent): |
927 def __init__(self, parent): |
931 self.type_ = BrowserItemSysPath |
935 self.type_ = BrowserItemSysPath |
932 self.icon = UI.PixmapCache.getIcon("filePython.png") |
936 self.icon = UI.PixmapCache.getIcon("filePython.png") |
933 self._populated = False |
937 self._populated = False |
934 self._lazyPopulation = True |
938 self._lazyPopulation = True |
935 |
939 |
|
940 |
936 class BrowserFileItem(BrowserItem): |
941 class BrowserFileItem(BrowserItem): |
937 """ |
942 """ |
938 Class implementing the data structure for browser file items. |
943 Class implementing the data structure for browser file items. |
939 """ |
944 """ |
940 def __init__(self, parent, finfo, full = True, sourceLanguage = ""): |
945 def __init__(self, parent, finfo, full=True, sourceLanguage=""): |
941 """ |
946 """ |
942 Constructor |
947 Constructor |
943 |
948 |
944 @param parent parent item |
949 @param parent parent item |
945 @param finfo the string for the file (string) |
950 @param finfo the string for the file (string) |
1006 self.symlink = True |
1011 self.symlink = True |
1007 self.icon = UI.PixmapCache.getSymlinkIcon(pixName) |
1012 self.icon = UI.PixmapCache.getSymlinkIcon(pixName) |
1008 else: |
1013 else: |
1009 self.icon = UI.PixmapCache.getIcon(pixName) |
1014 self.icon = UI.PixmapCache.getIcon(pixName) |
1010 |
1015 |
1011 def setName(self, finfo, full = True): |
1016 def setName(self, finfo, full=True): |
1012 """ |
1017 """ |
1013 Public method to set the directory name. |
1018 Public method to set the directory name. |
1014 |
1019 |
1015 @param finfo the string for the file (string) |
1020 @param finfo the string for the file (string) |
1016 @param full flag indicating full pathname should be displayed (boolean) |
1021 @param full flag indicating full pathname should be displayed (boolean) |
1182 return order == Qt.AscendingOrder |
1187 return order == Qt.AscendingOrder |
1183 if not sinit and oinit: |
1188 if not sinit and oinit: |
1184 return order == Qt.DescendingOrder |
1189 return order == Qt.DescendingOrder |
1185 |
1190 |
1186 return BrowserItem.lessThan(self, other, column, order) |
1191 return BrowserItem.lessThan(self, other, column, order) |
|
1192 |
1187 |
1193 |
1188 class BrowserClassItem(BrowserItem): |
1194 class BrowserClassItem(BrowserItem): |
1189 """ |
1195 """ |
1190 Class implementing the data structure for browser class items. |
1196 Class implementing the data structure for browser class items. |
1191 """ |
1197 """ |
1215 self.type_ = BrowserItemClass |
1221 self.type_ = BrowserItemClass |
1216 self.name = name |
1222 self.name = name |
1217 self._classObject = cl |
1223 self._classObject = cl |
1218 self._filename = filename |
1224 self._filename = filename |
1219 |
1225 |
1220 self.isfunction = isinstance(self._classObject, |
1226 self.isfunction = isinstance(self._classObject, |
1221 Utilities.ClassBrowsers.ClbrBaseClasses.Function) |
1227 Utilities.ClassBrowsers.ClbrBaseClasses.Function) |
1222 self.ismodule = isinstance(self._classObject, |
1228 self.ismodule = isinstance(self._classObject, |
1223 Utilities.ClassBrowsers.ClbrBaseClasses.Module) |
1229 Utilities.ClassBrowsers.ClbrBaseClasses.Module) |
1224 if self.isfunction: |
1230 if self.isfunction: |
1225 if cl.isPrivate(): |
1231 if cl.isPrivate(): |
1226 self.icon = UI.PixmapCache.getIcon("method_private.png") |
1232 self.icon = UI.PixmapCache.getIcon("method_private.png") |
1227 elif cl.isProtected(): |
1233 elif cl.isProtected(): |
1300 |
1306 |
1301 @return flag indicating public visibility (boolean) |
1307 @return flag indicating public visibility (boolean) |
1302 """ |
1308 """ |
1303 return self._classObject.isPublic() |
1309 return self._classObject.isPublic() |
1304 |
1310 |
|
1311 |
1305 class BrowserMethodItem(BrowserItem): |
1312 class BrowserMethodItem(BrowserItem): |
1306 """ |
1313 """ |
1307 Class implementing the data structure for browser method items. |
1314 Class implementing the data structure for browser method items. |
1308 """ |
1315 """ |
1309 def __init__(self, parent, fn, filename): |
1316 def __init__(self, parent, fn, filename): |
1325 self.icon = UI.PixmapCache.getIcon("method_private.png") |
1332 self.icon = UI.PixmapCache.getIcon("method_private.png") |
1326 elif self._functionObject.isProtected(): |
1333 elif self._functionObject.isProtected(): |
1327 self.icon = UI.PixmapCache.getIcon("method_protected.png") |
1334 self.icon = UI.PixmapCache.getIcon("method_protected.png") |
1328 else: |
1335 else: |
1329 self.icon = UI.PixmapCache.getIcon("method.png") |
1336 self.icon = UI.PixmapCache.getIcon("method.png") |
1330 self.itemData[0] = "{0}({1})".format( |
1337 self.itemData[0] = "{0}({1})".format( |
1331 name, ", ".join(self._functionObject.parameters)) |
1338 name, ", ".join(self._functionObject.parameters)) |
1332 # if no defaults are wanted |
1339 # if no defaults are wanted |
1333 # ....format(name, ", ".join( |
1340 # ....format(name, ", ".join( |
1334 # [e.split('=')[0].strip() for e in self._functionObject.parameters])) |
1341 # [e.split('=')[0].strip() for e in self._functionObject.parameters])) |
1335 if self._functionObject and \ |
1342 if self._functionObject and \ |
1392 |
1399 |
1393 @return flag indicating public visibility (boolean) |
1400 @return flag indicating public visibility (boolean) |
1394 """ |
1401 """ |
1395 return self._functionObject.isPublic() |
1402 return self._functionObject.isPublic() |
1396 |
1403 |
|
1404 |
1397 class BrowserClassAttributesItem(BrowserItem): |
1405 class BrowserClassAttributesItem(BrowserItem): |
1398 """ |
1406 """ |
1399 Class implementing the data structure for browser class attributes items. |
1407 Class implementing the data structure for browser class attributes items. |
1400 """ |
1408 """ |
1401 def __init__(self, parent, attributes, text): |
1409 def __init__(self, parent, attributes, text): |
1436 elif issubclass(other.__class__, BrowserClassItem) or \ |
1444 elif issubclass(other.__class__, BrowserClassItem) or \ |
1437 issubclass(other.__class__, BrowserMethodItem): |
1445 issubclass(other.__class__, BrowserMethodItem): |
1438 return order == Qt.AscendingOrder |
1446 return order == Qt.AscendingOrder |
1439 |
1447 |
1440 return BrowserItem.lessThan(self, other, column, order) |
1448 return BrowserItem.lessThan(self, other, column, order) |
|
1449 |
1441 |
1450 |
1442 class BrowserClassAttributeItem(BrowserItem): |
1451 class BrowserClassAttributeItem(BrowserItem): |
1443 """ |
1452 """ |
1444 Class implementing the data structure for browser class attribute items. |
1453 Class implementing the data structure for browser class attribute items. |
1445 """ |
1454 """ |
1509 else: |
1518 else: |
1510 return self.lineno() > other.lineno() |
1519 return self.lineno() > other.lineno() |
1511 |
1520 |
1512 return BrowserItem.lessThan(self, other, column, order) |
1521 return BrowserItem.lessThan(self, other, column, order) |
1513 |
1522 |
|
1523 |
1514 class BrowserCodingItem(BrowserItem): |
1524 class BrowserCodingItem(BrowserItem): |
1515 """ |
1525 """ |
1516 Class implementing the data structure for browser coding items. |
1526 Class implementing the data structure for browser coding items. |
1517 """ |
1527 """ |
1518 def __init__(self, parent, text): |
1528 def __init__(self, parent, text): |