src/eric7/Project/AddDirectoryDialog.py

branch
eric7
changeset 9516
0f023e61a9b5
parent 9413
80c06d472826
child 9531
155b2646799a
equal deleted inserted replaced
9515:275334bc9607 9516:0f023e61a9b5
19 """ 19 """
20 Class implementing a dialog to add files of a directory to the project. 20 Class implementing a dialog to add files of a directory to the project.
21 """ 21 """
22 22
23 def __init__( 23 def __init__(
24 self, pro, fileTypeFilter="source", parent=None, name=None, startdir=None 24 self, pro, fileTypeFilter="SOURCES", parent=None, name=None, startdir=None
25 ): 25 ):
26 """ 26 """
27 Constructor 27 Constructor
28 28
29 @param pro reference to the project object 29 @param pro reference to the project object
40 self.sourceDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) 40 self.sourceDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
41 self.sourceDirPicker.setDefaultDirectory(startdir) 41 self.sourceDirPicker.setDefaultDirectory(startdir)
42 self.targetDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) 42 self.targetDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
43 self.targetDirPicker.setDefaultDirectory(startdir) 43 self.targetDirPicker.setDefaultDirectory(startdir)
44 44
45 self.ppath = pro.ppath 45 self.__project = pro
46 self.targetDirPicker.setText(self.ppath) 46 self.targetDirPicker.setText(self.__project.getProjectPath())
47 self.on_filterComboBox_highlighted(0) 47
48 # enable all dialog elements 48 if fileTypeFilter and fileTypeFilter != "TRANSLATIONS":
49 if fileTypeFilter == "source": # it is a source file 49 self.filterComboBox.addItem(
50 self.filterComboBox.addItem(self.tr("Source Files"), "SOURCES") 50 self.__project.getFileCategoryString(fileTypeFilter),
51 elif fileTypeFilter == "form": 51 fileTypeFilter,
52 self.filterComboBox.addItem(self.tr("Forms Files"), "FORMS") 52 )
53 elif fileTypeFilter == "resource":
54 self.filterComboBox.addItem(self.tr("Resource Files"), "RESOURCES")
55 elif fileTypeFilter == "interface":
56 self.filterComboBox.addItem(self.tr("Interface Files"), "INTERFACES")
57 elif fileTypeFilter == "protocol":
58 self.filterComboBox.addItem(self.tr("Protocol Files"), "PROTOCOLS")
59 elif fileTypeFilter == "others":
60 self.filterComboBox.addItem(self.tr("Other Files (*)"), "OTHERS")
61 self.on_filterComboBox_highlighted(self.filterComboBox.count() - 1)
62 else: 53 else:
63 self.filterComboBox.addItem(self.tr("Source Files"), "SOURCES") 54 for fileCategory in sorted(
64 self.filterComboBox.addItem(self.tr("Forms Files"), "FORMS") 55 c for c in self.__project.getFileCategories()
65 self.filterComboBox.addItem(self.tr("Resource Files"), "RESOURCES") 56 if c != "TRANSLATIONS"
66 self.filterComboBox.addItem(self.tr("Interface Files"), "INTERFACES") 57 ):
67 self.filterComboBox.addItem(self.tr("Protocol Files"), "PROTOCOLS") 58 self.filterComboBox.addItem(
68 self.filterComboBox.addItem(self.tr("Other Files (*)"), "OTHERS") 59 self.__project.getFileCategoryString(fileCategory),
60 fileCategory,
61 )
69 self.filterComboBox.setCurrentIndex(0) 62 self.filterComboBox.setCurrentIndex(0)
70 63
71 msh = self.minimumSizeHint() 64 msh = self.minimumSizeHint()
72 self.resize(max(self.width(), msh.width()), msh.height()) 65 self.resize(max(self.width(), msh.width()), msh.height())
73 66
74 @pyqtSlot(int) 67 @pyqtSlot(int)
75 def on_filterComboBox_highlighted(self, index): 68 def on_filterComboBox_currentIndexChanged(self, index):
76 """ 69 """
77 Private slot to handle the selection of a file type. 70 Private slot to handle the selection of a file type.
78 71
79 @param index index of the selected entry 72 @param index index of the selected entry
80 @type int 73 @type int
100 It is assumed, that the user wants to add a bunch of files to 93 It is assumed, that the user wants to add a bunch of files to
101 the project in place. 94 the project in place.
102 95
103 @param directory the text of the source directory line edit (string) 96 @param directory the text of the source directory line edit (string)
104 """ 97 """
105 if directory.startswith(self.ppath): 98 if directory.startswith(self.__project.getProjectPath()):
106 self.targetDirPicker.setText(directory) 99 self.targetDirPicker.setText(directory)
107 100
108 def getData(self): 101 def getData(self):
109 """ 102 """
110 Public slot to retrieve the dialogs data. 103 Public slot to retrieve the dialogs data.

eric ide

mercurial