108 |
108 |
109 def __init__(self, parent=None): |
109 def __init__(self, parent=None): |
110 """ |
110 """ |
111 Constructor |
111 Constructor |
112 |
112 |
113 @param parent parent widget (QWidget) |
113 @param parent parent widget |
|
114 @type QWidget |
114 """ |
115 """ |
115 super().__init__(parent) |
116 super().__init__(parent) |
116 |
117 |
117 self.setWindowTitle(QCoreApplication.translate("Browser", "File-Browser")) |
118 self.setWindowTitle(QCoreApplication.translate("Browser", "File-Browser")) |
118 self.setWindowIcon(EricPixmapCache.getIcon("eric")) |
119 self.setWindowIcon(EricPixmapCache.getIcon("eric")) |
406 Protected method of QAbstractItemView. |
407 Protected method of QAbstractItemView. |
407 |
408 |
408 Reimplemented to disable expanding/collapsing of items when |
409 Reimplemented to disable expanding/collapsing of items when |
409 double-clicking. Instead the double-clicked entry is opened. |
410 double-clicking. Instead the double-clicked entry is opened. |
410 |
411 |
411 @param mouseEvent the mouse event (QMouseEvent) |
412 @param mouseEvent the mouse event |
|
413 @type QMouseEvent |
412 """ |
414 """ |
413 index = self.indexAt(mouseEvent.position().toPoint()) |
415 index = self.indexAt(mouseEvent.position().toPoint()) |
414 if index.isValid(): |
416 if index.isValid(): |
415 itm = self.model().item(index) |
417 itm = self.model().item(index) |
416 if isinstance( |
418 if isinstance( |
429 |
431 |
430 def _contextMenuRequested(self, coord): |
432 def _contextMenuRequested(self, coord): |
431 """ |
433 """ |
432 Protected slot to show the context menu of the listview. |
434 Protected slot to show the context menu of the listview. |
433 |
435 |
434 @param coord the position of the mouse pointer (QPoint) |
436 @param coord the position of the mouse pointer |
|
437 @type QPoint |
435 """ |
438 """ |
436 categories = self.getSelectedItemsCountCategorized( |
439 categories = self.getSelectedItemsCountCategorized( |
437 [BrowserDirectoryItem, BrowserFileItem, BrowserClassItem, BrowserMethodItem] |
440 [BrowserDirectoryItem, BrowserFileItem, BrowserClassItem, BrowserMethodItem] |
438 ) |
441 ) |
439 cnt = categories["sum"] |
442 cnt = categories["sum"] |
504 |
507 |
505 def _gotoAttribute(self, act): |
508 def _gotoAttribute(self, act): |
506 """ |
509 """ |
507 Protected slot to handle the selection of the goto menu. |
510 Protected slot to handle the selection of the goto menu. |
508 |
511 |
509 @param act reference to the action (EricAction) |
512 @param act reference to the action |
|
513 @type EricAction |
510 """ |
514 """ |
511 fileName, lineno = act.data() |
515 fileName, lineno = act.data() |
512 self.sourceFile[str, int].emit(fileName, lineno) |
516 self.sourceFile[str, int].emit(fileName, lineno) |
513 |
517 |
514 def handlePreferencesChanged(self): |
518 def handlePreferencesChanged(self): |
823 |
827 |
824 def handleProgramChange(self, fn): |
828 def handleProgramChange(self, fn): |
825 """ |
829 """ |
826 Public slot to handle the programChange signal. |
830 Public slot to handle the programChange signal. |
827 |
831 |
828 @param fn file name (string) |
832 @param fn file name |
|
833 @type str |
829 """ |
834 """ |
830 self.__model.programChange(os.path.dirname(fn)) |
835 self.__model.programChange(os.path.dirname(fn)) |
831 |
836 |
832 def handleInterpreterChanged(self, interpreter): |
837 def handleInterpreterChanged(self, interpreter): |
833 """ |
838 """ |
834 Public slot to handle a change of the debug client's interpreter. |
839 Public slot to handle a change of the debug client's interpreter. |
835 |
840 |
836 @param interpreter interpreter of the debug client (string) |
841 @param interpreter interpreter of the debug client |
|
842 @type str |
837 """ |
843 """ |
838 self.__model.interpreterChanged(interpreter) |
844 self.__model.interpreterChanged(interpreter) |
839 |
845 |
840 def wantedItem(self, itm, filterList=None): |
846 def wantedItem(self, itm, filterList=None): |
841 """ |
847 """ |
842 Public method to check type of an item. |
848 Public method to check type of an item. |
843 |
849 |
844 @param itm the item to check (BrowserItem) |
850 @param itm the item to check |
|
851 @type BrowserItem |
845 @param filterList list of classes to check against |
852 @param filterList list of classes to check against |
846 @return flag indicating item is a valid type (boolean) |
853 @type list of Class |
|
854 @return flag indicating item is a valid type |
|
855 @rtype bool |
847 """ |
856 """ |
848 if filterList is None: |
857 if filterList is None: |
849 filterList = self.selectedItemsFilter |
858 filterList = self.selectedItemsFilter |
850 |
859 |
851 return any(isinstance(itm, typ) for typ in filterList) |
860 return any(isinstance(itm, typ) for typ in filterList) |
853 def getSelectedItems(self, filterList=None): |
862 def getSelectedItems(self, filterList=None): |
854 """ |
863 """ |
855 Public method to get the selected items. |
864 Public method to get the selected items. |
856 |
865 |
857 @param filterList list of classes to check against |
866 @param filterList list of classes to check against |
858 @return list of selected items (list of BrowserItem) |
867 @type list of Class |
|
868 @return list of selected items |
|
869 @rtype list of BrowserItem |
859 """ |
870 """ |
860 selectedItems = [] |
871 selectedItems = [] |
861 indexes = self.selectedIndexes() |
872 indexes = self.selectedIndexes() |
862 for index in indexes: |
873 for index in indexes: |
863 if index.column() == 0: |
874 if index.column() == 0: |
869 def getSelectedItemsCount(self, filterList=None): |
880 def getSelectedItemsCount(self, filterList=None): |
870 """ |
881 """ |
871 Public method to get the count of items selected. |
882 Public method to get the count of items selected. |
872 |
883 |
873 @param filterList list of classes to check against |
884 @param filterList list of classes to check against |
874 @return count of items selected (integer) |
885 @type list of Class |
|
886 @return count of items selected |
|
887 @rtype int |
875 """ |
888 """ |
876 count = 0 |
889 count = 0 |
877 indexes = self.selectedIndexes() |
890 indexes = self.selectedIndexes() |
878 for index in indexes: |
891 for index in indexes: |
879 if index.column() == 0: |
892 if index.column() == 0: |
885 def getSelectedItemsCountCategorized(self, filterList=None): |
898 def getSelectedItemsCountCategorized(self, filterList=None): |
886 """ |
899 """ |
887 Public method to get a categorized count of selected items. |
900 Public method to get a categorized count of selected items. |
888 |
901 |
889 @param filterList list of classes to check against |
902 @param filterList list of classes to check against |
|
903 @type list of Class |
890 @return a dictionary containing the counts of items belonging |
904 @return a dictionary containing the counts of items belonging |
891 to the individual filter classes. The keys of the dictionary |
905 to the individual filter classes. The keys of the dictionary |
892 are the string representation of the classes given in the |
906 are the string representation of the classes given in the |
893 filter (i.e. str(filterClass)). The dictionary contains |
907 filter (i.e. str(filterClass)). The dictionary contains |
894 an additional entry with key "sum", that stores the sum of |
908 an additional entry with key "sum", that stores the sum of |
895 all selected entries fulfilling the filter criteria. |
909 all selected entries fulfilling the filter criteria. |
|
910 @rtype dict |
896 """ |
911 """ |
897 if filterList is None: |
912 if filterList is None: |
898 filterList = self.selectedItemsFilter |
913 filterList = self.selectedItemsFilter |
899 categories = {"sum": 0} |
914 categories = {"sum": 0} |
900 for typ in filterList: |
915 for typ in filterList: |