17 |
17 |
18 from .Ui_AddFileDialog import Ui_AddFileDialog |
18 from .Ui_AddFileDialog import Ui_AddFileDialog |
19 |
19 |
20 import Utilities |
20 import Utilities |
21 |
21 |
|
22 |
22 class AddFileDialog(QDialog, Ui_AddFileDialog): |
23 class AddFileDialog(QDialog, Ui_AddFileDialog): |
23 """ |
24 """ |
24 Class implementing a dialog to add a file to the project. |
25 Class implementing a dialog to add a file to the project. |
25 """ |
26 """ |
26 def __init__(self, pro, parent = None, filter = None, name = None, |
27 def __init__(self, pro, parent=None, filter=None, name=None, |
27 startdir = None): |
28 startdir=None): |
28 """ |
29 """ |
29 Constructor |
30 Constructor |
30 |
31 |
31 @param pro reference to the project object |
32 @param pro reference to the project object |
32 @param parent parent widget of this dialog (QWidget) |
33 @param parent parent widget of this dialog (QWidget) |
43 |
44 |
44 self.targetDirEdit.setText(pro.ppath) |
45 self.targetDirEdit.setText(pro.ppath) |
45 self.filter = filter |
46 self.filter = filter |
46 self.ppath = pro.ppath |
47 self.ppath = pro.ppath |
47 self.startdir = startdir |
48 self.startdir = startdir |
48 self.filetypes = pro.pdata["FILETYPES"] # save a reference to the filetypes dict |
49 self.filetypes = pro.pdata["FILETYPES"] # save a reference to the filetypes dict |
49 |
50 |
50 if self.filter is not None and self.filter != 'source': |
51 if self.filter is not None and self.filter != 'source': |
51 self.sourcecodeCheckBox.hide() |
52 self.sourcecodeCheckBox.hide() |
52 |
53 |
53 @pyqtSlot() |
54 @pyqtSlot() |
77 dir = self.startdir |
78 dir = self.startdir |
78 else: |
79 else: |
79 dir = self.targetDirEdit.text() |
80 dir = self.targetDirEdit.text() |
80 if self.filter is None: |
81 if self.filter is None: |
81 patterns = { |
82 patterns = { |
82 "SOURCES" : [], |
83 "SOURCES": [], |
83 "FORMS" : [], |
84 "FORMS": [], |
84 "RESOURCES" : [], |
85 "RESOURCES": [], |
85 "INTERFACES" : [], |
86 "INTERFACES": [], |
86 "TRANSLATIONS" : [], |
87 "TRANSLATIONS": [], |
87 } |
88 } |
88 for pattern, filetype in list(self.filetypes.items()): |
89 for pattern, filetype in list(self.filetypes.items()): |
89 if filetype in patterns: |
90 if filetype in patterns: |
90 patterns[filetype].append(pattern) |
91 patterns[filetype].append(pattern) |
91 dfilter = self.trUtf8( |
92 dfilter = self.trUtf8( |
93 "Forms Files ({1});;" |
94 "Forms Files ({1});;" |
94 "Resource Files ({2});;" |
95 "Resource Files ({2});;" |
95 "Interface Files ({3});;" |
96 "Interface Files ({3});;" |
96 "Translation Files ({4});;" |
97 "Translation Files ({4});;" |
97 "All Files (*)").format( |
98 "All Files (*)").format( |
98 " ".join(patterns["SOURCES"]), |
99 " ".join(patterns["SOURCES"]), |
99 " ".join(patterns["FORMS"]), |
100 " ".join(patterns["FORMS"]), |
100 " ".join(patterns["RESOURCES"]), |
101 " ".join(patterns["RESOURCES"]), |
101 " ".join(patterns["INTERFACES"]), |
102 " ".join(patterns["INTERFACES"]), |
102 " ".join(patterns["TRANSLATIONS"])) |
103 " ".join(patterns["TRANSLATIONS"])) |
103 caption = self.trUtf8("Select Files") |
104 caption = self.trUtf8("Select Files") |
104 elif self.filter == 'form': |
105 elif self.filter == 'form': |
105 patterns = [] |
106 patterns = [] |
106 for pattern, filetype in list(self.filetypes.items()): |
107 for pattern, filetype in list(self.filetypes.items()): |
175 |
176 |
176 def getData(self): |
177 def getData(self): |
177 """ |
178 """ |
178 Public slot to retrieve the dialogs data. |
179 Public slot to retrieve the dialogs data. |
179 |
180 |
180 @return tuple of three values (list of string, string, boolean) giving the |
181 @return tuple of three values (list of string, string, boolean) giving the |
181 source files, the target directory and a flag telling, whether |
182 source files, the target directory and a flag telling, whether |
182 the files shall be added as source code |
183 the files shall be added as source code |
183 """ |
184 """ |
184 return (self.sourceFileEdit.text().split(os.pathsep), |
185 return (self.sourceFileEdit.text().split(os.pathsep), |
185 self.targetDirEdit.text(), self.sourcecodeCheckBox.isChecked()) |
186 self.targetDirEdit.text(), self.sourcecodeCheckBox.isChecked()) |