184 currentFilter = self.filterComboBox.currentText() |
184 currentFilter = self.filterComboBox.currentText() |
185 self.filterComboBox.clear() |
185 self.filterComboBox.clear() |
186 |
186 |
187 # add standard entries |
187 # add standard entries |
188 self.filterComboBox.addItem("") |
188 self.filterComboBox.addItem("") |
189 self.filterComboBox.addItem(self.tr("All Files"), "*") |
189 self.filterComboBox.addItem(self.tr("All Files"), ["*"]) |
190 |
190 |
191 # add configured entries |
191 # add configured entries |
192 # filters is a dictionary with the filter text as key and the pattern as value |
192 # FileFilters is a dictionary with the filter name as key and |
|
193 # a list of file name patterns as value |
193 self.__filters = json.loads( |
194 self.__filters = json.loads( |
194 Preferences.getSettings().value("FindFileWidget/FileFilters", "{}") |
195 Preferences.getSettings().value("FindFileWidget/FileFilters", "{}") |
195 # noqa: M613 |
196 # noqa: M613 |
196 ) |
197 ) |
197 for fileFilter in sorted(self.__filters): |
198 for fileFilter in sorted(self.__filters): |
198 self.filterComboBox.addItem(fileFilter, self.__filters[filter]) |
199 self.filterComboBox.addItem( |
|
200 self.tr("{0} ({1})").format( |
|
201 fileFilter, " ".join(self.__filters[fileFilter]) |
|
202 ), |
|
203 self.__filters[fileFilter], |
|
204 ) |
199 |
205 |
200 # reselect the current entry |
206 # reselect the current entry |
201 index = self.filterComboBox.findText(currentFilter) |
207 index = self.filterComboBox.findText(currentFilter) |
202 if index == -1: |
208 if index == -1: |
203 index = 0 |
209 index = 0 |
554 |
560 |
555 self.__cancelSearch = False |
561 self.__cancelSearch = False |
556 |
562 |
557 if self.filterCheckBox.isChecked(): |
563 if self.filterCheckBox.isChecked(): |
558 fileFilter = self.filterComboBox.currentData() |
564 fileFilter = self.filterComboBox.currentData() |
559 fileFilterList = [ |
565 fileFilterPattern = "|".join( |
560 self.__buildReFileFilter(filter) for filter in fileFilter.split(";") |
566 self.__buildReFileFilter(filter) for filter in fileFilter |
561 ] |
567 ) |
562 filterRe = re.compile("|".join(fileFilterList)) |
568 filterRe = re.compile(fileFilterPattern) |
563 |
569 |
564 if self.projectButton.isChecked(): |
570 if self.projectButton.isChecked(): |
565 if self.filterCheckBox.isChecked(): |
571 if self.filterCheckBox.isChecked(): |
566 files = [ |
572 files = [ |
567 self.__project.getRelativePath(file) |
573 self.__project.getRelativePath(file) |