19 |
19 |
20 class AddDirectoryDialog(QDialog, Ui_AddDirectoryDialog): |
20 class AddDirectoryDialog(QDialog, Ui_AddDirectoryDialog): |
21 """ |
21 """ |
22 Class implementing a dialog to add files of a directory to the project. |
22 Class implementing a dialog to add files of a directory to the project. |
23 """ |
23 """ |
24 def __init__(self, pro, filter='source', parent=None, name=None, |
24 def __init__(self, pro, fileTypeFilter='source', parent=None, name=None, |
25 startdir=None): |
25 startdir=None): |
26 """ |
26 """ |
27 Constructor |
27 Constructor |
28 |
28 |
29 @param pro reference to the project object |
29 @param pro reference to the project object |
30 @param filter file type filter (string) |
30 @param fileTypeFilter file type filter (string) |
31 @param parent parent widget of this dialog (QWidget) |
31 @param parent parent widget of this dialog (QWidget) |
32 @param name name of this dialog (string) |
32 @param name name of this dialog (string) |
33 @param startdir start directory for the selection dialog |
33 @param startdir start directory for the selection dialog |
34 """ |
34 """ |
35 super(AddDirectoryDialog, self).__init__(parent) |
35 super(AddDirectoryDialog, self).__init__(parent) |
44 |
44 |
45 self.ppath = pro.ppath |
45 self.ppath = pro.ppath |
46 self.targetDirPicker.setText(self.ppath) |
46 self.targetDirPicker.setText(self.ppath) |
47 self.on_filterComboBox_highlighted('(*.py)') |
47 self.on_filterComboBox_highlighted('(*.py)') |
48 # enable all dialog elements |
48 # enable all dialog elements |
49 if filter == 'source': # it is a source file |
49 if fileTypeFilter == 'source': # it is a source file |
50 self.filterComboBox.addItem( |
50 self.filterComboBox.addItem( |
51 self.tr("Source Files"), "SOURCES") |
51 self.tr("Source Files"), "SOURCES") |
52 elif filter == 'form': |
52 elif fileTypeFilter == 'form': |
53 self.filterComboBox.addItem( |
53 self.filterComboBox.addItem( |
54 self.tr("Forms Files"), "FORMS") |
54 self.tr("Forms Files"), "FORMS") |
55 elif filter == 'resource': |
55 elif fileTypeFilter == 'resource': |
56 self.filterComboBox.addItem( |
56 self.filterComboBox.addItem( |
57 self.tr("Resource Files"), "RESOURCES") |
57 self.tr("Resource Files"), "RESOURCES") |
58 elif filter == 'interface': |
58 elif fileTypeFilter == 'interface': |
59 self.filterComboBox.addItem( |
59 self.filterComboBox.addItem( |
60 self.tr("Interface Files"), "INTERFACES") |
60 self.tr("Interface Files"), "INTERFACES") |
61 elif filter == 'others': |
61 elif fileTypeFilter == 'others': |
62 self.filterComboBox.addItem( |
62 self.filterComboBox.addItem( |
63 self.tr("Other Files (*)"), "OTHERS") |
63 self.tr("Other Files (*)"), "OTHERS") |
64 self.on_filterComboBox_highlighted('(*)') |
64 self.on_filterComboBox_highlighted('(*)') |
65 else: |
65 else: |
66 self.filterComboBox.addItem( |
66 self.filterComboBox.addItem( |
93 self.targetDirLabel.setEnabled(True) |
93 self.targetDirLabel.setEnabled(True) |
94 self.targetDirPicker.setEnabled(True) |
94 self.targetDirPicker.setEnabled(True) |
95 self.recursiveCheckBox.setEnabled(True) |
95 self.recursiveCheckBox.setEnabled(True) |
96 |
96 |
97 @pyqtSlot(str) |
97 @pyqtSlot(str) |
98 def on_sourceDirPicker_textChanged(self, dir): |
98 def on_sourceDirPicker_textChanged(self, directory): |
99 """ |
99 """ |
100 Private slot to handle the source directory text changed. |
100 Private slot to handle the source directory text changed. |
101 |
101 |
102 If the entered source directory is a subdirectory of the current |
102 If the entered source directory is a subdirectory of the current |
103 projects main directory, the target directory path is synchronized. |
103 projects main directory, the target directory path is synchronized. |
104 It is assumed, that the user wants to add a bunch of files to |
104 It is assumed, that the user wants to add a bunch of files to |
105 the project in place. |
105 the project in place. |
106 |
106 |
107 @param dir the text of the source directory line edit (string) |
107 @param directory the text of the source directory line edit (string) |
108 """ |
108 """ |
109 if dir.startswith(self.ppath): |
109 if directory.startswith(self.ppath): |
110 self.targetDirPicker.setText(dir) |
110 self.targetDirPicker.setText(directory) |
111 |
111 |
112 def getData(self): |
112 def getData(self): |
113 """ |
113 """ |
114 Public slot to retrieve the dialogs data. |
114 Public slot to retrieve the dialogs data. |
115 |
115 |