17 from E5Gui.E5PathPicker import E5PathPickerModes |
17 from E5Gui.E5PathPicker import E5PathPickerModes |
18 |
18 |
19 from .Ui_AddFileDialog import Ui_AddFileDialog |
19 from .Ui_AddFileDialog import Ui_AddFileDialog |
20 |
20 |
21 |
21 |
22 # TODO: add fileTypeFilter 'protocol' |
|
23 class AddFileDialog(QDialog, Ui_AddFileDialog): |
22 class AddFileDialog(QDialog, Ui_AddFileDialog): |
24 """ |
23 """ |
25 Class implementing a dialog to add a file to the project. |
24 Class implementing a dialog to add a file to the project. |
26 """ |
25 """ |
27 def __init__(self, pro, parent=None, fileTypeFilter=None, name=None, |
26 def __init__(self, pro, parent=None, fileTypeFilter=None, name=None, |
72 patterns = { |
71 patterns = { |
73 "SOURCES": [], |
72 "SOURCES": [], |
74 "FORMS": [], |
73 "FORMS": [], |
75 "RESOURCES": [], |
74 "RESOURCES": [], |
76 "INTERFACES": [], |
75 "INTERFACES": [], |
|
76 "PROTOCOLS": [], |
77 "TRANSLATIONS": [], |
77 "TRANSLATIONS": [], |
78 } |
78 } |
79 for pattern, filetype in list(self.filetypes.items()): |
79 for pattern, filetype in list(self.filetypes.items()): |
80 if filetype in patterns: |
80 if filetype in patterns: |
81 patterns[filetype].append(pattern) |
81 patterns[filetype].append(pattern) |
82 dfilter = self.tr( |
82 dfilter = self.tr( |
83 "Source Files ({0});;" |
83 "Source Files ({0});;" |
84 "Forms Files ({1});;" |
84 "Forms Files ({1});;" |
85 "Resource Files ({2});;" |
85 "Resource Files ({2});;" |
86 "Interface Files ({3});;" |
86 "Interface Files ({3});;" |
87 "Translation Files ({4});;" |
87 "Protocol Files ({4});;" |
|
88 "Translation Files ({5});;" |
88 "All Files (*)")\ |
89 "All Files (*)")\ |
89 .format( |
90 .format( |
90 " ".join(patterns["SOURCES"]), |
91 " ".join(patterns["SOURCES"]), |
91 " ".join(patterns["FORMS"]), |
92 " ".join(patterns["FORMS"]), |
92 " ".join(patterns["RESOURCES"]), |
93 " ".join(patterns["RESOURCES"]), |
93 " ".join(patterns["INTERFACES"]), |
94 " ".join(patterns["INTERFACES"]), |
|
95 " ".join(patterns["PROTOCOLS"]), |
94 " ".join(patterns["TRANSLATIONS"])) |
96 " ".join(patterns["TRANSLATIONS"])) |
95 caption = self.tr("Select Files") |
97 caption = self.tr("Select Files") |
96 elif self.fileTypeFilter == 'form': |
98 elif self.fileTypeFilter == 'form': |
97 patterns = [] |
99 patterns = [] |
98 for pattern, filetype in list(self.filetypes.items()): |
100 for pattern, filetype in list(self.filetypes.items()): |
123 if filetype == "INTERFACES": |
125 if filetype == "INTERFACES": |
124 patterns.append(pattern) |
126 patterns.append(pattern) |
125 dfilter = self.tr("Interface Files ({0})")\ |
127 dfilter = self.tr("Interface Files ({0})")\ |
126 .format(" ".join(patterns)) |
128 .format(" ".join(patterns)) |
127 caption = self.tr("Select interface files") |
129 caption = self.tr("Select interface files") |
|
130 elif self.fileTypeFilter == 'protocol': |
|
131 patterns = [] |
|
132 for pattern, filetype in list(self.filetypes.items()): |
|
133 if filetype == "PROTOCOLS": |
|
134 patterns.append(pattern) |
|
135 dfilter = self.tr("Protocol Files ({0})")\ |
|
136 .format(" ".join(patterns)) |
|
137 caption = self.tr("Select protocol files") |
128 elif self.fileTypeFilter == 'translation': |
138 elif self.fileTypeFilter == 'translation': |
129 patterns = [] |
139 patterns = [] |
130 for pattern, filetype in list(self.filetypes.items()): |
140 for pattern, filetype in list(self.filetypes.items()): |
131 if filetype == "TRANSLATIONS": |
141 if filetype == "TRANSLATIONS": |
132 patterns.append(pattern) |
142 patterns.append(pattern) |